#EvalynOS

1 messages · Page 29 of 1

haughty acorn
#

im 99% sure id have much less driver issues if i tried linux now lmao

clear bison
#

amdgpu drivers 💀?

hazy saddle
haughty acorn
#

but im lazy and id rather just leave the windows that came on this laptop on it lmao

hazy saddle
clear bison
#

Hell naw

haughty acorn
hazy saddle
clear bison
#

Put me behind 3 lead doors away from that bullshit 💀

haughty acorn
#

i might see if my dad has any old laptops he doesnt need tho, if he does im taking one and putting arch on it and then not using arch on it most of the time anyway because itll be an osdev test bed

hazy saddle
#

Idk if @haughty acorn would wana work on it though

#

It will be C++ or C I think?

#

Probably C++

haughty acorn
#

i had enough in c++ in 2012 and then kept working on that project until like 2014 lmao

hazy saddle
#

Since we are working on some other helpers for disassembly and other shit

haughty acorn
#

if any of you know MultiMC, you can find a link to my twitter in the about menu of that program

#

because i worked on it

hazy saddle
#

Oh that's cool as shit

#

I use a fork called PrismLauncher

#

hey yeah its there

haughty acorn
#

most of what i do nowadays for multimc is get pinged as part of the moderator role when people ignore the multimc discord's rule about not asking for help for forks lmao

hazy saddle
#

lmfaoooooo

haughty acorn
hazy saddle
#

how hard is it to read yaaar

haughty acorn
#

i also get pinged when people start using slurs or trying to sell scams lmao and thats far more common

haughty acorn
hazy saddle
#

tbf it happens here but to less extents

#

and its more so people not listening

haughty acorn
#

mhm

#

but yeah trying to get Qt5 and mingw and whatever editor i was using before clion or vscode existed all working together to work on multimc is a part of why i have such cranky old woman yells at cloud energy sometimes lmao

#

that and constantly watching modding people fighting each other

hazy saddle
#

i used to do MC modding

#

i made some of the most hacky shit that should have never worked

#

i have had some plans to get back into it

#

but large backlog of ideas lol

hazy saddle
#

so as you explore the world shifts behind you

haughty acorn
#

nice

#

i used to be more involved in mc modding (albeit from the multimc side and the user side moreso than making mods) but i saw so many fights and community trying to rip itself apart so often that i just got. melancholy about it. and stopped

hazy saddle
#

I hate the fragmentation with mod loaders

#

Neo forge and fabric is plenty

#

Then there is like 5 other random loaders that pop in and out for no reason

haughty acorn
#

thats not a new problem lmao

hazy saddle
#

Mmmm yes let's needlessly fragment the modding ecosystem more for no reason and make it worse for everyone

haughty acorn
#

goes back to flowerchild

hazy saddle
#

Alot probably was due to forge and lexmanos being kind of a dick iirc?

#

I never interacted with him that much

#

And wasn't a hugeee scale moder but

haughty acorn
hazy saddle
#

That's based as shit

#

Iirc lex did other things too in the past that contributed?

haughty acorn
#

yeah

#

hes always been a dick

#

the first unnecessary modloader split happened in late may-early june 2013 btw

#

its just that forge had such a monopoly that until fabric happened all of the splits were people going off on their own to do no-modloader stuff after being in fights and getting pushed away

#

the way i describe my feelings on mc modding stuff nowadays is its like a veteran walking out on an old battlefield they fought on and getting flashbacks to how things went down and friends were lost

hazy saddle
#

I wish I was ever ingrained enough into a large community to witness stuff like that

#

I've had a few things happen but nothing to large extents

#

Like the Xbox server doing stupid shit to a good mod and then covering up the entire thing

#

🥀

haughty acorn
#

watching communities fall apart like that isnt fun. being in a community is nice though, so its usually worth that risk

hazy saddle
#

Yeah the falling apart isn't fun but sotimes smaller dramas can be Entertaining

#

I do quite like this community though

#

Everyone here is cool

#

I wouldn't want anything to happen here

haughty acorn
#

ive watched the mc modding community tearing itself apart again and again for over a decade now. theres a different community that i literally had to take sides in a massive fight. and now im simultaneously scared to get invested in communities again but also cherish the ones i can be a part of

hazy saddle
#

Why cant the dramas be stupid and funny

#

And not ruining the entire thing

#

I am very young tho so I'm yet to get into things very big™

haughty acorn
#

mhm

#

one of the guys i always liked in the mc modding community recently got a terraria dev armor set so at least chicken bones is goin in a good direction lol

hazy saddle
#

Oooo that's cool

#

I should try and get back into playing modded Minecraft

#

But it's lost its spark for me sadly

#

I should start making dinner though and going to sleep

#

Might take a break from working on it tomorrow

#

And then work on refactors if I'm feeling up to it

#

I Wana sleep before 1:30 because I slept at 4am yesterday

full fern
#

Gtnh scratches the same itch on my brain as osdev

haughty acorn
#

you know you've been in a community too long when you start unironically doing that obi wan gif lmao

hushed oracle
hazy saddle
#

Couldn't get into it fully

#

I probably would like to try again

#

But I'd need good friends to do it with

hazy saddle
#

hmmm

#

today i shall do that refactor perhaps

#

arch/{arch}/arch among other things

#

arch/generic wont need an extra arch subfolder though as its meant to be included by other things anywhere

#

though i wonder if i can just phase it out

#

and add a misc folder for some things under utils?

#

whuch i alr do have

#

i can put the panic boilerplate there

#

i also am consering doing my riscv port a bit earlier perhaps

#

after LA64 paging and irqs maybe?

#

will then need to refactor 3 paging codes though

#

since il have to rework them once i have PFNDB and better OOM handling

hazy saddle
#

Fuck it we ball

#

Im going to port riscv before the other refactors

#

Since it won't be that bad since alot of the paging code can just be reused when I refactor it after regardless

haughty acorn
hazy saddle
#

Then it's #include paging/whatever

#

Then what should I do for things I want in the root level there though?

#

Like panic I probably want to be able to do #include arch/panic.h

#

And not just panic

#

Also instead of including arch/generic/whatever the arch specific header will include the required generic header for you

#

So you just do #include arch/paging/paging.h

#

And that includes the generic paging header too

#

Maybe?

#

Idk that sounds worse

floral kettle
#

I just have arch/paging.{h,hpp} for the arch-specific paging stuff like page flags + an arch/paging_internals.{h,hpp} for some internal stuff the generic paging impl uses (like the level count, size of a level + some other misc things like that)

hazy saddle
#

i think i can do this. arch spesific things will shadow generic includes.
then the arch specific implementation pulls in the generic header which will contain the generic interfaces & other defines?

-I src/arch/${ARCH}
-I src/arch/generic
#

wait no i think ive got it

#
    -I src/arch/                          \
    -I src/arch/${ARCH}                   \
#

Then code does include generic/paging/paging.h

#

But that solves nothing really

#

The other option I guess is making the generic files ifdef every architecture and including the architecture backend for them :/

#

Which would only need to be done for like a few of them tbf

#

Just the ones that have inline assembly

#

the only files like that are
interrupts.h
halt.h
mmio.h

#

il do it like this
merge interrupts.h and halt.h into intrin.h
put that and mmio and panic into arch/generic/lib/
and then intrin.h and mmio.h have to get updated for any arch port to ifdef && include the right backend header

#

Other things won't be static inline in headers so they won't need ifdef soup

#

And relegating ifdef soup such a pattern it ends up working

wraith star
#

stop overthinking it and start writing meme

hazy saddle
#

So true

#

😭

#

I just don't wana have to come back and redo this again

hazy saddle
#

i think ive solved it

#
#define STRINGIFY_IMPL(x) #x
#define STRINGIFY(x) STRINGIFY_IMPL(x)
#include STRINGIFY(arch/ARCH/lib/mmio.h)
#

Then arch just gets passed as a -DARCH =

#

Then the generic headers can just do that bullshit

hushed oracle
#

Bruh

hazy saddle
floral kettle
#

but why, this seems way more cursed than just having arch/<arch>/include/arch/paging.h + -Iarch/<arch>/include

hazy saddle
#

It is very fucking cursed though

sterile plank
#

i dont understand overengineering

floral kettle
hazy saddle
hazy saddle
#

PSP1G_pspTrollar and since this is pissing everyone off it makes me want to keep it too /hj

haughty acorn
tender mantle
#

Keep over engineering

hazy saddle
haughty acorn
tender mantle
#

Most programmers stop right before it’s perfect

hazy saddle
tender mantle
#

Who cares

hazy saddle
#

arch/arch name/arch

hazy saddle
tender mantle
#

All of this stems from you using Kate btw

haughty acorn
tender mantle
#

If you used a decent editor this wouldn’t be a problem :p

hazy saddle
haughty acorn
#

yeah?

hazy saddle
#

I thought you meant it the other way 😭

tender mantle
#

platform/archname/arch is just arch/archname/arch but fancy

haughty acorn
#

didnt realise it was unclear but i woke up sick to my stomach so i was struggling to communicate

hazy saddle
#

How would that work?

haughty acorn
hazy saddle
#

Ah same thing but fancy lol

tender mantle
#

I guess

#

You know

#

At this point

#

Just hash all the folder names

#

Who needs them

hazy saddle
#

Sourcehut actually doesn't collace that lmao

tender mantle
#

it’s 1 extra click oh no

hazy saddle
#

Which is another reason I want to avoid that

haughty acorn
tender mantle
floral kettle
haughty acorn
#

the arch subfolder would be more like the asm subfolder name linux uses for everything and be the stuff that generic needs to include

tender mantle
haughty acorn
#

yeah

tender mantle
#

include folder in src is questionable but fine

hazy saddle
#

So platform/x86_64/arch has the generic headers
And then it can have other things there etc not under arch

haughty acorn
hazy saddle
#

That could work but then I loose the generic folder and other things.
I'm probably either talking myself into the cursed macro solution but I guess I dislike the other ways of doing things. My brain likes having it this way tbh yaaar

tender mantle
haughty acorn
#

(at the end of the day do what you like, just dont be surprised if other people dont want to work with the codebase when doing that macro shit)

tender mantle
#

Headers suck so much

haughty acorn
tender mantle
#

None of this would of been a problem if you used rust :^)

haughty acorn
#

or zig

tender mantle
#

Or hell fucking javascript does it better

floral kettle
tender mantle
#

I tend to not even notice arch/x86_64/arch

haughty acorn
#

literally the important thing is to have a system and stick to it

tender mantle
#

Yeah

haughty acorn
#

whats the system? idk i aint you. but make one and stick to it

tender mantle
#

Pure vibes “yeah this feels like it belongs here”

haughty acorn
#

my os has hal/arch/%ARCH%/ for the path to arch specific stuff

#

and not-arch-specific code for stuff like interrupts etc lives in hal/

hazy saddle
#

well congrats

#

everyone hates this

#

so now im using it

#

ts is too funny

#

😭

tender mantle
#

Welp whatever works for you I guess

rancid viper
#

solution: stop using the C preprocessor and write your own

sterile plank
#

stop using C, write rust /j

haughty acorn
#

so if you do this then commit to the bit

hazy saddle
#

Because I have my own pre processor

wide mica
#

To me it seems like you're overthinking it

hazy saddle
#

So I might aswell work within it

wide mica
#

I quite like where I ended up personally

hazy saddle
#

But I think I'm finnaly content with this solution

hazy saddle
#

i think ive also killed two birds with one stone

#

arch/intrin/* contains the fucky headers that auto redirect to the arch folder coresponding in arch/${ARCH}/intrin
and then arch/${ARCH}/intrin can addininaly have arch spesific intrinsics like CPUID portio MSRs/CSRS etc

#

And that feels like a much nicer place to put them

#

Because they basically are just intrinsics / wrappers around raw instructions

#

The only one that's borderline is CPUID on x86 since I do some more advanced wrappings but eh

#

Panic may? Just continue to stay at the top level though. Or I shove it into a panic subdir

haughty acorn
hazy saddle
#

Only took me two weeks to think of this properly 😭

#

At least it was worth it

#

I also wonder if I should document my kernel and the public API functions and other architecture stuff

#

Maybe after I get it to the MVP state I'm working to?

#

I'd probably start with the utils folder for that stuff

#

Since that's the most important stuff to document as it has alot of the data structures and locks etc

#

maybe generic panic can be moved there too?

hazy saddle
#

i think il only move portio into the intrins since its basically just that

#

the other files have some other stuff that may not fit

#

and then arch/cpu looks really empty otherewise

#

it may end up with cpulocal being the only thing there

#

if/when i move smp to its own folder

#

actually CPU local may be an intrinsic type thing

#

since its a pointer de reference on a spesific register in many archetectures

#

eg la64 has one

#

and x86 is similar but fancy

#

other arhctectures would have to define thier own macros that do so similar crap

#

when i do cpu local stuff then i will probally the other things into intrin with it

#

In any case I think stuff is proper for these refactors enough

#

Il clean this up and get it commited tomorrow

#

Then work on getting the bare bones of the riscv port working

#

And then exception handling on both

#

And the refactor with those after that

#

Since I wanted to move thoes arround a little

#

But I need them more complete on non x86 platforms for that

hazy saddle
#

The sourcehut repo is out of date

#

But the main home server should be fine to apply these on

wraith star
#

okay,lemme compile this

hazy saddle
#

You can probably skip the jinx steps if you just put the limine and OVMF shit in the right place btw

#

The make file for the kernel build skips jinx by default

wraith star
#

how do i do that?

#

i see its validating and retrieving some stuff

#

i ran make bootstrap

hazy saddle
#

then you dont need any manual steps

#

make bootstrap just takes ages lol

#

Eventually it will properly build the entire distro tho™

wraith star
#

does it do that yet?

hazy saddle
wraith star
#

ah okau

#

good

hazy saddle
#

Just mentioned as of now you can skip it if you want to

wraith star
#

okay done, built

#

hm, i just have a black screen with some weird resolution

hazy saddle
#

Huh?

#

When does this happen

#

Btw

wraith star
#

after pressing enter

hazy saddle
#

Do you have clang22

wraith star
#

nope

#

i use gcc

hazy saddle
#

Ahh

#

I don't exactly support gcc

wraith star
#

oh wait nvm

hazy saddle
wraith star
#

its using clang

hazy saddle
#

And I require clang 22

#

For defer shit

wraith star
#

let me update my system

#

god i hate cuda nooo

#

every time i have to update i have to download 4gb of cuda garbage

hazy saddle
#

This is why I uninstall the ROCM shit if I haven't used it in a while

#

It's so annoying

#

Not that ROCM works anyways but

young hamlet
#

That and SMRRs help Prevents cache poisoning

gentle quest
wraith star
#

nope

#

theres some weird smp bug

#

i want to see what is it

clear bison
#

They're reporting a bug

gentle quest
#

Ah

clear bison
#

Well i think this is more bizarre than a simple bug

hazy saddle
#

SMP init only dies on KVM + SEABIOS

#

💀

wraith star
#

i have also suffered from smp bugs

hazy saddle
wraith star
#

most commonly its forgetting to set some cr4 bit

hazy saddle
wraith star
#

or some assumption about the segment registers

hazy saddle
#

But I managed to fix them

#

And I set NX and la57 etc

tender mantle
#

this is so random 🥀

hazy saddle
#

I do have a nice way to set registers via an assembly macro though and a bit field for what things need diddling

#

If that does happen to be the case

hazy saddle
#

It's never something simple

clear bison
#

Maybe I'll test it in my machine too

hazy saddle
#

Seems to be a BIOS issue atlwast

#

I only have UEFI systems to test at home

tender mantle
#

I have a bios system iirc

hazy saddle
#

Go my minions

clear bison
hazy saddle
#

Debug my random bullshit

tender mantle
#

give iso

hazy saddle
clear bison
hazy saddle
clear bison
#

I don't think that's supposed to work, isn't seabios just for i440

#

?

hazy saddle
#

it crashes on that too tbf

gentle quest
#

Of course not

tender mantle
#

now im curious

clear bison
gentle quest
#

?

#

What code

clear bison
#

Seabios's code

gentle quest
#

It has q35 chipset specific code even

#

Idk what you're talking about tbh

hazy saddle
#

seems to die somwhere here??

tender mantle
#

what qemu args cause it to die?

hazy saddle
#
    mov eax, [x86_ap_trampoline_cr3 - x86_ap_trampoline + ebx]
    mov cr3, eax
gentle quest
#

Maybe the cr3 is bad

hazy saddle
#

qemu-system-x86_64 -enable-kvm -cdrom evalynOS.iso -m 1G -smp 2 -cpu host -chardev stdio,id=debugcon -device isa-debugcon,chardev=debugcon -d int,cpu_reset -no-reboot -no-shutdown -D qemu_log.txt

tender mantle
#

does it die without the patches?

hazy saddle
gentle quest
hazy saddle
#

EBX is ending up zero here

gentle quest
#

Which they aren't on APs

tender mantle
#

evalyn

wraith star
#

dw, the problem was that the limine version i copied was too old

tender mantle
#

istg

hazy saddle
gentle quest
#

Oh

tender mantle
#

did I not tell you already to fix that

hazy saddle
tender mantle
#

or is it something else?

hazy saddle
#

luna

#

its somthing else

gentle quest
tender mantle
hazy saddle
#

EBX is zero

hazy saddle
tender mantle
gentle quest
#

Yes

wraith star
#

the aps reach the trampoline

#

so yes

hazy saddle
#

do i even use the global bit is the queston??

wraith star
#

cr4 bit probably

tender mantle
#

things I did not know 😭

#

how the fuck does my os even boot

gentle quest
#

Well do u even set the global bit on pts

tender mantle
#

iirc yes

hazy saddle
#

i dont

gentle quest
tender mantle
#

yeah I use global

tender mantle
wraith star
#

well , enabling those bits is not enoigh apparently

#

anyways, i gtg eat, if you dont solve the problem by then ill look harder

hazy saddle
#

tbf EBX == 0

#

for some reason

wraith star
hazy saddle
#

yes

wraith star
#

because when the cpu triple faults

#

thats what you see always

#

with kvm

tender mantle
#

yaeh I never set it lol

#

gg

hazy saddle
#

other registers are filled?

wraith star
#

those are the register values after reset

#

in kvm when a cpu triple faults qemu sees it as if it reset

#

with tcg this does not happen

hazy saddle
#

tbf is that EDX value

wraith star
#

i think its some cpu revision thing

#

check the sdm

hazy saddle
#

okay here it works

#

EBX is correct

young hamlet
tender mantle
#

then it's probably flags bullshit

clear bison
young hamlet
#

Should be what you get from cpuid[1].eax iirc

hazy saddle
#

okay but

#

this dies

young hamlet
#

Like atie said though I wouldn’t trust this triple fault message lol

hazy saddle
#

yes

#

BUT

#

thats where it dies

#

mov eax, [x86_ap_trampoline_cr3 - x86_ap_trampoline + ebx]

young hamlet
#

Gdb

hazy saddle
#

weko that will be annoying with relocated code but yeah

young hamlet
hazy saddle
#

and thoes things get relocated before getting sent down

#

for the gdtr etc

tender mantle
#

:P

young hamlet
#

How do you know the base is correct

#

Have you tried hardcoding the base aswell instead of calculating it on the fly

hazy saddle
#

well my breakpoint isntworking :p

hazy saddle
tender mantle
#

use hardware breakpoints

hazy saddle
#

and patches the trampoline

#

I AM

tender mantle
#

oh gg

hazy saddle
#

I AM USING HARDWARE BREAKPOINTD

tender mantle
#

jesus okay chill

young hamlet
hazy saddle
#

????

young hamlet
#

Because that’s the first time you touch ebx right

hazy saddle
#

thats just a

    mov ebx, cs
    shl ebx, 4
#

which is perfectly valid

young hamlet
#

Fairs

hazy saddle
#

and it is picking a proper space to relocate to

#

being the second free lomem page

#

this should be fine aswell

#

????

clear bison
hazy saddle
#

i allocate it on demand and patch on the BSP

clear bison
#

Because if you're doing so in like 0x00000 that doesn't sounds very good to me

#

There's the IVT still there when you start

hazy saddle
#

nah i avoid the first page alltogether

clear bison
#

And since you're in real mode at that point it still matters

hazy saddle
#

i allocate via this bullshit mmLol

clear bison
hazy saddle
#

Also would it if you don't get any interrupts?

#

Since that would kill me regardless

#

And it dies in protected mode

#

For some god forsaken reason

#

what happens if i skip prot mode?

clear bison
#

Maybe it's just some random NMI bullshit

hazy saddle
#

nop still dies

#

on the same instruction too

clear bison
#

Weird

hazy saddle
#

INB4 QEMU bug

rancid viper
#

what does it die on

hazy saddle
#

mov eax, [x86_ap_trampoline_cr3 - x86_ap_trampoline + ebx]

rancid viper
#

how does it die

hazy saddle
#

Triple faults

rancid viper
#

ok but what exception

hazy saddle
#

QEMU log dosnt even say

#

🥀

rancid viper
#

can u paste qemu log

gentle quest
#

That would be a cpu bug

hazy saddle
#

truke

#

qemu-system-x86_64 -enable-kvm -cdrom evalynOS.iso -m 1G -smp 2 -cpu host -chardev stdio,id=debugcon -device isa-debugcon,chardev=debugcon -d int,cpu_reset -no-reboot -no-shutdown -D qemu_log.txt

rancid viper
#

I mean with kvm u wouldnt get the exception in log anyway

hazy saddle
tender mantle
rancid viper
hazy saddle
rancid viper
#

can u run it w tcg? or does it only manifest on kvm?

#

ah then log is useless yeah

hazy saddle
#

And only with SEABIOS

rancid viper
#

if issue still persists, in an hour or two when I am home, I can debug

clear bison
#

Well GDB time it seems

hazy saddle
#

🥀

#

That address is where it gets relocated to

clear bison
#

Maybe it's because it's never actually getting there

urban mulch
#

Because QEMU could very much just pretend

tender mantle
#

hbreak does a hw breakpoint iirc

urban mulch
#

That's not the point

#

The point is that QEMU might secretly not be

tender mantle
#

I doubt it

urban mulch
#

Because this isn't debugging on actual hw

#

I would not at all be surprised

tender mantle
#

welp only one way to check

#

yeah it does use KVM_SET_GUEST_DEBUG

wraith star
#

; setup CR3
mov eax, [x86_ap_trampoline_cr3 - x86_ap_trampoline + ebx]

#

this is where it faults

hazy saddle
#

yes we found that

wraith star
#

ah okay mvm

#

Nvm

urban mulch
#

but setting the breakpoint on that insn doesn't work?

hazy saddle
#

No dice

urban mulch
#

The fact that it is the AP startup is probably fucking with the breakpoint

#

I wouldn't be surprised if the virtual AP init had bugs that means breakpoints are broken in KVM

wraith star
#

bruh

#

ds is 0x00

#

you did not reload segment registers

#

now it goes all the way up to the far jump to long mode

hazy saddle
urban mulch
#

yes it is

wraith star
#

youre in protected mode

#

you have

hazy saddle
#

Damn I striped that code out for code size

#

Because it worked on everything I tested it on

urban mulch
wraith star
#

suprisingly using 0x10 as data segment index works

urban mulch
#

Stop overoptimizing early

wraith star
#

when at that offset you gave 64 bit code

hazy saddle
urban mulch
#

Especially for size when you're only saving INDIVIDUAL BYTES!!!!

#

Completely counterproductive

wraith star
#

pls bring back the 32 bit data register lol

#

and usei t

#

dq 0 ; Null entry
dq 0x00cf9b000000ffff ; 32-bit code
dq 0x00cf93000000ffff ; 32-bit data
dq 0x00af9b000000ffff ; 64-bit code
dq 0x00cf93000000ffff ; 64-bit data

floral kettle
#

there is no separate 64-bit data anyway

#

32-bit data is the same as 64-bit data

urban mulch
#

Let me put it simply: Do Not Optimize before you clearly have a problem and identified where it is

wraith star
floral kettle
#

its literally the same value lol

wraith star
#

i know, i see lmao

floral kettle
#

unless you set the long mode bit which is ignored on everything except the code segment

urban mulch
#

Long live the GDT, possibly the ugliest cruft left over from segmentation

hazy saddle
#

welp the data segment being valid works

urban mulch
#

no shit sherlock

hazy saddle
#

no need to be rude :p

urban mulch
#

you were basically just hoping whatever the reset value was was correct before

wraith star
#

also

hazy saddle
#

well sorry that i wanted to spend some time hyper optimizing something when i wasnt feeling well and was bored and diddnt catch this crash in a BIOS path lmao mmLol

wraith star
#

in the trampoline, is the hhdm mapped?

hazy saddle
#

esp when bios crap had other issues

hazy saddle
#

also it works now

#

this was the extent of the bugs

#

i can probally skip loading es/fs/gs but then il get yelled at mmLol

#

thaks for all the help

#

this should patch it

tender mantle
#

I’ll check on that pc later

wraith star
#

yeah, now it works lol

#

good job

hazy saddle
#

It worked on like the 3 real machines I tested it on

#

And tcg and OVMF kvm

#

Maybe I should add a BIOS target to my make file

#

So I can do extra testings on thoes paths

wraith star
#

yes

hazy saddle
#

I think after I get all ts committed

#

I'm gonna work on some LA64 stuff

#

Then work on CPU local for both architectures

wraith star
hazy saddle
#

On LA64 it will be a CSR that holds the base that needs to get reloaded on any context switch change

#

To the thread pointer

hazy saddle
#

Or thread migration?

#

Idk when exactly I need to reload the register

hazy saddle
#

@hushed oracle how do you handle this on LA64 and riscv? I know there is a special ABI register for this along with one of the scratch registers.
But my brain is blanking on how to properly do it mmLol

hushed oracle
#

I don't switch it trl

#

It has my per-CPU struct where I change the current running thread pointer to the TCB because 1 stack per CPU

#

But it's a scratch register which you can change, yes

hazy saddle
#

I mean for when I should reload the GPR

#

The scratch registers has that CPUs point of truth yes

hushed oracle
#

And the csrwr instruction has a bad name, and it actually swaps the GPR and CSR

#

So you can use it as a scratch register

#

And their NMIs have separate entry point...

hazy saddle
#

Issue is it's probably slow right? So I want to keep it in the unused elf ABI GPR or whatever

#

Until I'm at a stage I don't know it's valid

hushed oracle
#

Userspace doesn't have access to CSRs

#

And their TLS pointer is one of the GPRs

#

So you don't have to do anything special or swapgs like on x86

hazy saddle
#

Not the CSR the GPR. Which I guess would be the same? Load that CSR into a GPR on every task switch

hushed oracle
#

You can do that, yeah

hazy saddle
hushed oracle
#

Then when you return from an interrupt, it just restores all GPRs

hazy saddle
#

Since whenever you switch it loads properly

hushed oracle
#

The compilers don't touch that register

hazy saddle
#

I'd also have to load it at interrupt entry from userspace

hazy saddle
hushed oracle
#

There is only 1 entry point

hushed oracle
#

TP is exactly the same between two

hazy saddle
#

Yeah but isn't it a similar concept to this given on la64 it's just unused?

hushed oracle
#

And interrupt handling is also basically the same, just with slightly different CSRs

hazy saddle
#

Yeah I was gonna start that soonerish

hushed oracle
hazy saddle
#

I just am trying to make sure I know how CPU local works on RISCs

#

Since GS: is really nice

hazy saddle
#

Yeah exactly, and then I just reload the GPR on certain spots eg task switch and syscall/interrupt entry etc

hushed oracle
#

yeah, i.e. you don't do anything special

#

I mean if you mean for kernel, you can also probably just tread it as a saved register (I think it is a saved register actually per ABI)

hazy saddle
#

I meant more so for making sure that the register dosnt explode on task switches and when they migrate cores and other things

#

I probably want to avoid it ever being touched by things like that?

#

And it getting re loaded after a task switch completes on the new stack

hushed oracle
#

I don't know, it depends on your kernel's design

hazy saddle
#

Fair

#

I guess il deal with the millions of bugs when I do this

#

And struggle hard

hushed oracle
#

Idk I haven't had task switching bugs for like 3 years now trl

hazy saddle
#

Welp

#

Hopefully I can get help when it fucks up

hushed oracle
#

I feel like it's only a problem when you don't know what you're doing

hazy saddle
#

Yeah

#

I'm comfortable with x86 stuff

#

Since I've done it before

hushed oracle
#

RV/LA are much simplier

hazy saddle
#

And have went through that nightmare

hushed oracle
#

Like x86 has a bunch of weird bs that you have to deal with

hazy saddle
#

Though on x86 I get single cycle cpu local stuff and it's in a permanent register I don't have to worry about too bad mmLol

#

By abusing the address calculations shit

hushed oracle
#

On RV/LA it's a GPR, so basically the same but with less limitations

#

Like no need to do gs:0 weirdness or whatever

hazy saddle
#

Yeah so it should be mostly the same except instead of a swapgs is a rdcsr ig?

hushed oracle
#

yeah

#

or rather wrcsr

#

You do wrcsr of tp to the scratch csr (idr its name), then you can save it from there (if you don't want to clobber any registers)

#

But also the ABI gives you a scratch register which you can clobber as a kernel

#

Which you can't use as userspace

hazy saddle
#

Which also makes nested interrupts easier

hushed oracle
#

yeah

hazy saddle
#

Userspace may be using that

hushed oracle
#

Like it's on you if you use it as userspace

hazy saddle
#

Inb4 some software like QEMU wants it

#

Does anything on rv use gp?

hushed oracle
#

I don't like the idea of it since you can then know when you've been preempted and stuff, but like it's probably totally fine

hazy saddle
hushed oracle
hazy saddle
#

How would I handle it with the wrcsr case

urban mulch
#

Again, it's the only place that makes sense because of how RISC-V exceptions work

#

It is explicitly intended to be used for this

hazy saddle
#

Yes of course, but isn't there some GPR it has to go into when you use it? Or in every case you use it you have to do a CSR operation to get the value and then use it

hushed oracle
urban mulch
#

No it's a CSR operation you can read it into literally any register you want

#

RISC-V never assumes a specific register

hazy saddle
#

I mean on every single CPU local operation do you have to load it from the CSR?

urban mulch
#

At most the compressed instructions assume regs 0-15

hazy saddle
#

Isnt that slow / serializing etc?

urban mulch
#

Not necessarily

urban mulch
#

There is NO guarantee about serializing on CSR ops

#

With the sole exception of writing to satp of pmp*

hazy saddle
hushed oracle
urban mulch
#

When you want to access the CPU-local data

hushed oracle
#

Once you load it once

urban mulch
#

Still has to be in sscratch while in usermode

hushed oracle
#

Yes

urban mulch
#

But yes you can cache it there if you don't use tp already

hazy saddle
#

true so I could on every entry into kernel space load it into tp. Which should work across thread migrations etc? Since tp either won't get touched there or it has to re enter into kernel space on the new core when it does???

#

And I can cache it in gp on riscv too ig? Or tp too

urban mulch
#

TP is fine

hazy saddle
#

What even is gp? Also I presume I don't really even need tls on my kernel because CPU local does most of that job anyways

urban mulch
#

My opinion is just use relaxation relative to GP because they must've added that for a reason

urban mulch
#

(Unless you do -mno-relax)

#

Just put it in TP though, especially if you weren't using TP yet already

hazy saddle
hazy saddle
#

Idk if I'd even really want tls regardless in general

urban mulch
tender mantle
urban mulch
#

Whereas most symbols use either an absolute or PC-relative or GOT/PLT address

tender mantle
#

like how -2gb on x86 has optimizations for access afaik

urban mulch
#

Idea is that things likely to be accessed more often (and that are small) go into .sdata, .srodata or .sbss, sections which are near __global_pointer$, so that you need one less instruction to access them

#

And since you were over-optimizing your x86 shit, why disable this?

hazy saddle
#

Yeah exactly

urban mulch
#

But you can disable it and then gp would be unused

hazy saddle
#

I can just use tp for this

#

And then on la64 its the reserved register

#

And I reload it on any kernel entry via a swap of the CSR

#

Though don't I need to check if it's already been swapped before?

urban mulch
#

Yeah so LA64 has basically the same thing

urban mulch
#

You do that only temporarily to have somewhere to put that register you have to save while loading the CPU-local data

#

That's why I have scratch space here:

/// Architecture-specific CPU-local data.
#[repr(C)]
#[derive(Default)]
pub struct ArchCpuLocal {
    /// Stack pointer to use for interrupts; NULL to use current stack ptr.
    pub irq_stack: *mut (),
    /// Scratch space used by the trap and interrupt handlers.
    pub scratch: [usize; 3],
}
hazy saddle
#

So how's that helpful for not clobbering tp?

#

I'm sorry for not understanding any of this yaaar

urban mulch
#

See this:

riscv_exception_asm:
    .cfi_return_column 64
    .cfi_signal_frame
    .cfi_register 64, sepc
    # Get the cpulocal ptr.
    csrrw t0, sscratch, t0
    # Normal save of T1.
    sd t1, 24(t0)
    # Restore sscratch to be cpulocal ptr again.
    csrrw t1, sscratch, t0
    # T1 used to save old value of T0.
    sd t1, 16(t0)

I am saving t0 to sscratch temporarily, saving t1 to ArchCpuLocal::scratch, then swapping back and moving the old value of t0 into there too.

#

Now I have the old t0 and t1 preserved, the CPUlocal in t0 and t1 usable as scratch

#

Later on these are copied back onto the stack, but the stack has not been loaded here yet

#

A simpler sequence happens in reverse to load the context before doing sret:

    # Restore the last regs.
    ld sp, 8(t0)
    ld t1, 24(t0)
    ld t0, 16(t0)
    
    # All done, return from exception handler.
    sret
hazy saddle
#

But what happens in the case of an NMI where then scratch is in a middle state with invalid data?

urban mulch
#

RISC-V has no NMI

#

And if it does it's always fatal so don't bother returning anyway

hazy saddle
#

Ah that's interesting

urban mulch
#

Otherwise you have the RNMI extension, which gives you a different vector than the standard stvec

hazy saddle
#

I think LA64 HAS NMIs though similar to that extension???

urban mulch
#

IMO NMIs have no place in modern CPUs

#

Unless they're fatal

#

For example, a machine check on x86 when trying to access vacant physical memory right?
On RISC-V you get an access (not page!) fault instead

#

Which is synchronous instead of being an NMI

hazy saddle
#

Interesting

#

How does the NMI extention work with handling these btw?

urban mulch
#

You also have these for other failures

hazy saddle
#

Okay but yeah the scratch registers stuff should work out in other cases

urban mulch
#

Which are, again, synchronous

urban mulch
#

And again, it's only supposed to be for fatal things, so chances are the firmware catches it and resets the machine

#

Oh

#

S-mode can't catch NMIs anyway

#

So don't worry about them

#

It's always into M-mode

hazy saddle
#

Ah so I don't have to deal with them myself ever

#

Good

#

Now about them on LA64 @hushed oracle mmLol

#

If that works all properly then I should be good to go

tender mantle
#

ugh

hazy saddle
#

Being with the proper handling on exception entry and task switching it should all work

tender mantle
#

I should just rewrite my kernel for riscv atp lol

#

the grass might be greener :^)

hazy saddle
#

Or

#

Support both

tender mantle
#

nah drop x86

hazy saddle
#

And don't do another rewrite for the love of god

hazy saddle
#

And la64 one too

tender mantle
#

no lol

#

yeah def not lol

hazy saddle
#

I'm not letting you rewrite your kernel

#

For the millionth time

#

Istg

tender mantle
#

the great part about it being my kernel is you have no control over that

#

tho if I was to support another arch

#

idk what it would be

#

anything but aarch64 :^)

hazy saddle
tender mantle
#

ehhhh

#

50/50 on it

hushed oracle
tender mantle
#

on one hand it looks cool

#

on the other the docs are straight ass afaik

hushed oracle
hazy saddle
#

So what do you do on NMIs

hushed oracle
#

I don't handle them trl

#

But idk you handle them as normal?

#

I guess you can even enable paging and stuff and jump to a normal entry point, if you really want that

#

(after you normalize the CSRs)

hazy saddle
#

Issue is

#

How the fuck can you get a stack

#

Or like

#

Do anything properly

#

I guess you can use one of the secondary scratch registers

hushed oracle
#

They give you a different scratch register

#

Yes

hazy saddle
#

And have that as for NMI

hushed oracle
#

They're not secondary, you get a scratch register per entry point

#

One for interrupts, one for tlb refill, one for NMIs

tender mantle
#

see thankfully I'm not evalyn so I don't give a fuck about handling nmis or mces lol

#

🙏

tender mantle
#

(she's gonna force me one day)

hushed oracle
hazy saddle
hushed oracle
hazy saddle
#

okay yeah you have MERRSAVE

tender mantle
#

see

hazy saddle
#

which can be the exat same as SAVE1

tender mantle
#

the good thing about evalyn forcing me to do it

hazy saddle
#

but for NMIs

tender mantle
#

is that I can just beg her to implement it

tender mantle
#

yes I am lol

#

I have no idea about loongarch64

hazy saddle
#

Oh please

#

You will just have Claude fix it

tender mantle
#

🥀

#

shut the fuck up

hazy saddle
#

Only because you asked nicely

tender mantle
#

I don't use ai in my kernel tyvm

rancid viper
#

luna and claude sitting in a tree

tender mantle
hazy saddle
#

Thank you @hushed oracle and @urban mulch
I should be able to handle this properly on RV and LA64 now PSP1G_pspTrollar

rancid viper
hazy saddle
#

Hopefully this doesn't all fall apart in two seconds when implement it

tender mantle
#

(it will)

hazy saddle
#

Il probably store a physical pointer in the machine error thing

hushed oracle
#

Haven't had issues with it trl

#

You're writing a microkernel so there is less surface for bugs trl

clear bison
hazy saddle
haughty acorn
#

the most premature of optimization

tender mantle
#

Think about it tho

#

With those extra 18 bytes

#

You can store a whole 1.7 page structs

#

Assuming your page struct is small as shit

hazy saddle
#

Because I align them to a cache line

vocal estuary
#

Bouta test now

tender mantle
#

Same

hazy saddle
vocal estuary
#

This computer is 1GB of RAM

urban mulch
#

64B page struct seems a bit big

#

What are you keeping in there

tender mantle
#

For my kernel it’s like 24 bytes of data and the rest is padding lol

#

I’m certain I could shrink it as well

urban mulch
#

Mine is exactly 32 bytes

hazy saddle
vocal estuary
#

It seems my PC can't detect it

#

What flashing tool did you use

hazy saddle
#

dd

vocal estuary
#

hmmm

hazy saddle
#

The ISO supports both bios and UEFI boot

vocal estuary
#

HAHA

#

GOT IT THIS TIME

#

lets see how it runs

wide mica
hazy saddle
vocal estuary
#

Could be an issue on my end

hazy saddle
#

I think older hardware needs a custom limine without certain things?

#

I've seen this happen on older machines

#

With ISOs I give

#

You need to make your own ISO / USB with limine on it

vocal estuary
#

...oh shit

#

I will... first I'ma see if I can get FreeDOS on here

haughty acorn
hushed oracle
#

I have a GRUB build of my OS trl

#

(if you want to try something different)

haughty acorn
vocal estuary
#

Idk if this is just my issue

#

Every ISO and image I’ve flashed has failed

#

A2 Oberon, EvalynOS (actually has the USB get detected, unlike others), Haiku, Windows XP Home, FreeDOS. All failed

vocal estuary
#

I'm gonna try running it tomorrow, I got a better USB

hazy saddle
#

inorder to properly compete with 16bit shrekOS evalynOS is now capable of printing out shrek

wraith star
#

someone give evalyn 604849 upvotes!!!

hazy saddle
#

(I'm taking a break today and I just shoved this into a PNG to ascii converter similar to the ralsei art on panic)

hazy saddle
#

No get your own

#

(I'm taking a shit rn)

wanton grove
#

idc

hazy saddle
wanton grove
#

with title

#

shrekos with fred

hazy saddle
#

64bit ShrekOS

#

Maybe next April fool's

wanton grove
#

meoww

hazy saddle
#

that has ze ascii art

hazy saddle
vocal estuary
vocal estuary
viral bison
#

do you have ACs at least?

vocal estuary
viral bison
hazy saddle
#

ended up getting heavily side tracked

#

i think? this is finished

#

for riscv exception handling

#

im probally gonna setup the riscv port soon

#

and add in that

#

and then work on the LA64 version

#

i will also have to work on cpu local and shit

#

but for RV i can just shim it enough mmLol

#

since il only be on one hart

#

and it can use the static copy in the BSS for the BSP's cpu local

vocal estuary
hazy saddle
#

what happens if you manually install limine on it?

vocal estuary
hazy saddle
#

and not use an ISO

hushed oracle
#

Have you tried a different bootloader?

clear bison
hazy saddle
#

ive been working on it a bit more :p

clear bison
hazy saddle
#

well there are 32 GPRs

#

and two of the temps i have to regrab from the cpu local when saving

#

the newer version only uses 2 temps vs 3 aswell

clear bison
#

I don't get what's your obsession with overoptimizing ts

hazy saddle
#

😭

clear bison
#

1 more load or store ain't gonna make a difference

hazy saddle
#

The one register being saved took like 4 seconds to be clear

#

I just had to move one thing somewhere else

#

To reuse another temp

#

And I'm stopping myself from more optimizations that have to do with instruction ordering

hazy saddle
clear bison
hazy saddle
#

😭

#

Fair

#

In other news though

#

42 stars

#

The number of the life the universe and eveything

clear bison
#

6x7=42 so 6-7 is the meaning of life

#

Top 10 math facts nobody knew about

gilded fjord
#

not 42

gilded fjord
#

nah

#

I'm low IQ

hazy saddle
clear bison
#

I'm waiting for your response, dw

gilded fjord
clear bison
#

Lame

urban mulch
hazy saddle
kindred stirrup
hazy saddle
#

I really hate to see it when you think low of yourself lukflug

gilded fjord
sterile plank
#

Lukflug deserves more love

hazy saddle
magic saffron
rancid viper
#

gemini decided to straight up lie

#

lmao

#

oh, it mentions kvm in the third paragraph

hazy saddle
#

shhhh

floral kettle
hazy saddle
#

I just need to wire in the exception handling shit I was working on the other day

#

And then work on CPU local some sched shit

#

Maybe some paging shit

#

But things are coming together

hazy saddle
floral kettle
#

at least you are making more progress than I am with my own kernels KEKW I just keep on rewriting and then getting tired of writing the gdt/idt/paging/mm/sched/lapic/hpet/acpi/other basic stuff a billion times (and not being able to decide what I actually want the kernel to be compatible with)

hazy saddle
#

My plan is to get every thing to a state I'm perfectly happy with

#

Eveything very good

#

But for a minimal state

#

Eveything documented everything very nice and proper and cleaned up

#

All the nice doxygen comments and whatever else