#pmOS - microkernel OS for RISC-V, x86, and LoongArch

1 messages · Page 12 of 1

twilit talon
#

since every tty write is a vmexit

carmine nacelle
#

Nah, it's not that bad

#

And I can just use UEFI

#

Also, I don't normally use kvm anyway

#

Actually, no, it's about the same speed/ a bit slower

twilit talon
#

What did you change?

carmine nacelle
#

Idk, everything

#

Mainly how memory objects are handled

carmine nacelle
#

Bruh, how do I suddenly have so many ideas for async receive?

#

I think I can just do it with a ring buffer, between the kernel and userspace

carmine nacelle
#

Ok, I've kinda implemented it in kernel already, on RISC-V for now (to the point where the kernel compiles)

#

And I think both the userspace api and the implemention is quite clean

#

Also, this allows to share interrupts between drivers now...

#

(After I get it to work on risc-v, I'll do it elsewhere, since the toolchain takes several hours to compile on my laptop)

#

The interrupt signaling/IPC and EOI paths are now allocation free, and almost lock free (the locks are only taken to push stuff into the IPC queue)

carmine nacelle
#

Cool, this stuff basically almost fully worked the first time

twilit talon
#

9k/s trl

carmine nacelle
#

You need a riac-v leaderboard trl

carmine nacelle
toxic torrent
carmine nacelle
#

But TCG is much faster

#

Also, am I still the only uacpi user on loongarch?

toxic torrent
#

as in the jit is more optimized?

carmine nacelle
#

Idk, I get a higher score in uACPI

#

Like 10x

#

I can't check because I don't have disk space on my laptop

plain jungle
#

qemu also uses tcg when running riscv

carmine nacelle
#

ok, what the fuck is going on with my kernel

#

All CPUs have ID 0 galaxybrain

#

Ok, after fixing this stupidity, this is fully working on risc-v...

#

(at least ahci and ns16550 drivers worked with no issues...)

#

Ok, I'm nuking risc-v build and building x86...

carmine nacelle
#

And on RISC-V it was using SBI's timer, and on x86 it's using HPET

#

Is this why I couldn't use copilot and had to debug my shit myself? trl

carmine nacelle
carmine nacelle
#

This is way pre-AI for it to confuse hex and decimal

carmine nacelle
#

This is fun

fringe grove
carmine nacelle
#

Just gonna leave this here, since everything else is broken

#

on loongarch

#

Oh no, my kernel is broken for some reason on loongarch64

#

and it panics before initializing the framebuffer

carmine nacelle
#

Ok, it was a dumb thing, that clanker found for me (but then started writing some insane code)

carmine nacelle
#

I think I found one of the bugs

toxic torrent
#

what's the point of inline without static?

carmine nacelle
#

multiple definitions of the same function?

toxic torrent
#

yeah but like

#

where is this used

carmine nacelle
#

headers

#

why use static?

#

this is C++

carmine nacelle
carmine nacelle
toxic torrent
carmine nacelle
#

afaik

toxic torrent
#

oh

#

sorry i'm not c++ pilled

carmine nacelle
hexed acorn
#

inline in c++ means "it's fine to have multiple definitions of this, and the linker will merge them together" more or less

#

(and having differing definitions is ub)

carmine nacelle
#

Does this stuff need to be aligned to something weird, or something like that???

#

no...

carmine nacelle
#

Why...

#

It's just writing 0xffffffffffffffff to the mailboxes

carmine nacelle
#

What the fuck

#

I wanna kms (figuratively)

#

The clanker was gaslighting me

#

(1 << 31) is 0xffffffff80000000

#

Because numbers are int in C(++)

twilit talon
carmine nacelle
#

I can't believe it, this shit works

carmine nacelle
#

Tbh every time I use AI I wish I didn't

twilit talon
#

you're kinda using it wrong tbh

carmine nacelle
#

How am I supposed to use it?

twilit talon
#

like u expect too much of it

carmine nacelle
#

what should I expect?

twilit talon
#

did you just tell it to debug your code?

carmine nacelle
#

Kinda

twilit talon
#

which model?

carmine nacelle
#

gpt 5.4 mini

twilit talon
#

ok lol

#

if u want it to do complex stuff like that u need the best one with a huge context window

#

at the very least

#

mini is complete shit for anything

carmine nacelle
#

It started hallucinating when it saw loongarch, then it tried to copy linux, and failed miserably at it, then it had found it once I basically did all of the debugging myself and pointed its nose at the problem

twilit talon
#

lol

carmine nacelle
#

Like sure, "you're giving it -1", then "0xffffffff comes from virtual addresses", then after I told it I was sure it was fine, it started reviewing my printf...

carmine nacelle
#

this is nice

carmine nacelle
#

though tbh I should probably update my gcc/binutils toolchain

#

omg, this shit is getting somewhere

#

But it's reading 0 out of mailbox 1 nooo

#

something in qemu is clearing the mailboxes for some reason.......

modest thistle
#

are you sure it's qemu?

carmine nacelle
#

what else would it be?

#

maybe edk2, who knows

#

But I've looked at it in gdb, and it looked like different code was running

carmine nacelle
#

But it still clears the mailboxes

carmine nacelle
#

Ok, I've no idea who and why is doing that, but it looks like (from qemu traces) it passes the mailbox 3 into $a1, and the interrupt vector into $a0 ?

#

Unbelievable

#

(tbh, I need an IPI to stop other CPUs on panic...)

#

This is a very good sign?

#

(I mean it gets stuck...)

carmine nacelle
carmine nacelle
#

What I'm missing is multiple interrupt controllers support

#

(because loongarch is fun, and you basically get a per-cpu lapic, where all of the vectors are shared, and then each cpu gets its own controller)

#

All I have now is one

twilit talon
carmine nacelle
#

SMP on loongarch

#

that particular screenshot is uACPI doing better on loongarch than on risc-v

twilit talon
#

No I mean the ged

carmine nacelle
#

Power button

twilit talon
#

Ah

carmine nacelle
#

Idk, I forgot I even implemented it, but somehow it didn't bitrot and survived a lot of changes and just worked

#

But like I ported to loongarch because risc-v didn't have ged for some reason...

#

and I didn't want to deal with arm

#

(I still don't want to deal with arm)

carmine nacelle
#

Ok, I think I can proclaim SMP to be officially fully working on my loongarch64 port

twilit talon
#

i should add C++ exceptions to uacpi

carmine nacelle
#

Huh?

twilit talon
#

( trl )

carmine nacelle
#

This server is written in C trl

#

Don't ask why

carmine nacelle
#

Ok, missing PCI is very concerning

#

It finds PNP0A03 but then nothing happends?

#

Yep, just nothing happends

#

ok, clanker fixed it

twilit talon
#

what was the issue

carmine nacelle
#

It wasn't finding root bridges

#

Because loongarch doesn't publish them in south bridge

twilit talon
#

yeah find_devices_at doesnt return any error if nothing was found, u kind of know it wasnt if your callback wasnt invoked

carmine nacelle
#

Yeah, ofc

#

I need to check if Managarm is wrong?

twilit talon
#

managarm doesnt even support loongarch

carmine nacelle
#

But this might be a general issue, if I took this code from them

#

Or idk, idr why it'd write it like that

#

(like where this came from)

twilit talon
#

whats the issue part?

twilit talon
carmine nacelle
#

Yeah

twilit talon
#

south bridge lol

#

SB is system bus

#

where the hell does it publish it then?

carmine nacelle
#

Just \\PCI0

twilit talon
#

so weird

carmine nacelle
#

Does this violate any spec?

carmine nacelle
#

Yep, a bunch of other stuff is in _SB_, this is just \PCI0

twilit talon
plain jungle
#

is this qemu or real hw?

carmine nacelle
#

Qemu

plain jungle
#

i think Managarm is correct here and qemu is wrong meme

carmine nacelle
#

Yeah, I should just stop supporting qemu mememan

plain jungle
#

you could patch qemu

#

or send a patch upstream

#

it's probably because loongarch is rather obscure and essentially unused outside of china

carmine nacelle
#

would they care if linux probably doesn't?

plain jungle
#

did you test if linux works

twilit talon
#

linux might just do root relative search

carmine nacelle
#

No galaxybrain

#

I mean their AP init code is also broken, but there's no spec and I couldn't find where in the sources

plain jungle
#

yeah from a quick glance linux searches the entire root

#

actually not sure

twilit talon
#

I think it just does for each from root and registers every device

carmine nacelle
#

but how can you do that if you need PCI for everything else?

plain jungle
#

it does but there are places where it checks for explicit names

#

so stuff may not work correctly if it's not below _SB

twilit talon
#

Yeah maybe

carmine nacelle
#

Cool, my SATA driver seems to be doing better with the latest changes to it...

#

But the MacBook is still trolling

twilit talon
carmine nacelle
#

Yeah, it's saying 4096 physical and 512 logical for some reason, which makes no sense

twilit talon
#

how does that not make sense

carmine nacelle
twilit talon
#

physical is what is actually stored, logical is the smallest adressable unit

carmine nacelle
#

I'm dumb and that check is just wrong

twilit talon
#

LBA units are logical

carmine nacelle
#

Yeah

#

I'll ask clanker to fix trl

#

nah

#

Cool, it didn't find ext4 partitions, because there were none on this MacBook

#

But like it read the disk and everything

twilit talon
#

cool

carmine nacelle
#

(also, how do I still get fascinated seeing my kernel boot on actual PCs and like not shit itself)
(Except the smp init on x86 trl)

carmine nacelle
#

I think I'll finally fix it, then push to main

carmine nacelle
#

Wait, do I not need to send INIT to APs?

#

Alternatively, following a power-up or RESET, since all APs are already in the “wait-for-SIPI state,” the BSP can broadcast just
a single SIPI IPI to the APs to wake them up and initialize them.

#

SDM says this

carmine nacelle
#

Can you not do this??

#

The SDM says it's read/write

#

The TPR (shown in Figure 13-18) is cleared to 0 on reset. In 64-bit mode, software can read and write the TPR
using an alternate interface, MOV CR8 instruction. The new task-priority class is established when the MOV CR8
instruction completes execution. Software does not need to force serialization after loading the TPR using MOV
CR8.

carmine nacelle
#

Ok, my cool new timer function is trolling

#

Well, now I know my double fault handler is broken trl

#

oh no, now it just tripple faults...

#

actually, it's gpfing in the gpf handler...

#

what the fuck

carmine nacelle
#

fuck

#

my smp init is still broken on the macbook nooo

twilit talon
#

Smp init... FAIL

carmine nacelle
#

I'm having a skill issue adding a submodule to my git directory

twilit talon
#

how

#

Just git submodule add URL path

carmine nacelle
#

idfk

#

it doesn't work

twilit talon
#

What does it say

carmine nacelle
#

nothing

#

I think I've gotten it to add but idk

#

the files are there

#

I'm so done with this

#

why does it not work

#

how is it not finding it on my desktop while the same branch works perfectly on my laptop

#

did flanterm change its file structure again???

#

also, I think my keyboard is dying as well

#

All I want is to see kernel logs

hexed knot
#

what is a struct anyway

carmine nacelle
#

(what are you using in your kernel?)

hexed knot
#

(i just have a pl011 driver lol, pl011 is arm uart)

carmine nacelle
#

Anyway, it just freezes when I try starting the APs nooo

#

Also, how does this macbook have smep but not smap?

hexed knot
#

m1+ all have uart

carmine nacelle
#

i mean maybe this has uart as sell through the typical apple weirdness

#

it has firewire and thinderbolt though ultrameme

#

yep, this locks up after sending sipi

carmine nacelle
twilit talon
#

Did you fix the bug

carmine nacelle
#

no

#

its gpfing on rdmsr for no reason

twilit talon
#

Me when no abortable instructions

carmine nacelle
#

actually, only in x2apic mode

#

because I'm dumb and was reading from the wrong register...

carmine nacelle
#

wait, what

#

init init startup?

#

could my error lvt just be broken or something?

#

Maybe I just shouldn't do parallel startup?

carmine nacelle
#

wait a second...

#

I'm so dumb

#

Ofc it crashes in QEMU if I give 16GB of RAM

hexed knot
#

there is actually a funny way to do this without a silly lock carousel (i think youd still need to make an array of all of the capabilities though so it doesnt really let you remove the limit) but

#

you can make a global array of N locks where N is a number that feels right

carmine nacelle
#

Oh no

hexed knot
#

and then an objects lock is some_hash(object_addr) % N

#

and then you make a local N-entry bitmap which tells you which locks you need to lock

#

im doing this kind of really funny global lock hashtable for another thing in my kernel

carmine nacelle
#

Even more deadlock potential, how nice

hexed knot
#

because with a bitmap you always acquire it in one order

carmine nacelle
#

If everything uses this

hexed knot
#

well obviously you only acquire one set of locks at a time

carmine nacelle
#

It's not nice on numa as well

hexed knot
#

fuck numa

carmine nacelle
#

You can make this per nuna cluster though

hexed knot
#

mm true

#

im just gonna target apple which is numa-free

#

and by "numa-free" i mean they stripe cache lines between numa nodes in hardware so that you dont have to care

carmine nacelle
#

How do they do it on M* Max stuff?

hexed knot
#

but anyway yeah the cache lines are striped between numa nodes lol

carmine nacelle
#

Whichever one has 2 CPUs glued together

hexed knot
#

yeah

#

im doing this stupid lock sharding meme for a different thing in my kernel though

hexed knot
#

and this lets you acquire a lock by virtual address without actually requiring the target to be valid

carmine nacelle
#

I just use rcu

hexed knot
#

and its also not something with a nice quiescent period

carmine nacelle
#

tbh my rcu needs some improvements as well

hexed knot
#

also this is much funnier anyway

carmine nacelle
#

lol yeah

carmine nacelle
#

Lol do I finally implement 5 level paging on x86?

#

Now that I'm done with smp

carmine nacelle
carmine nacelle
#

Cool...

#

I think this works both with limine and hyper...

#

(also, I've improved my x86 paging code in general...)

#

though this is unfun...

#

I think it's trying to enable 5 level paging, when it shouldn't be?

carmine nacelle
#

(pushed this stuff to main yesterday)

#

Also, I asked the clanker to check my paging code, and it had found a lot of embarrassing bugs in x86_64 paging stuff

#

And while I was in the mood for fixing paging, I've also finally implemented memory types (and their deduction from memory map for uACPI and whatnot) for physical memory mapping syscall

#

Which can maybe speed up the framebuffer?

#

though qemu kvm feels slower for some reason

#

the macbook does feel faster though

#

idk

carmine nacelle
#

Oh no, I think my smp init code is now broken on i686 nooo

carmine nacelle
#

This is very dumb

#

Like lol why boot when you can just idle

#

it could have crashed, it could have deadlocked, but no, it just had enough and decided to idle()

carmine nacelle
#

(thankfully, this was an easy fix)

carmine nacelle
#

this stuff is refusing to work nooo

carmine nacelle
#

this is weird?

carmine nacelle
#

this is fun

#

this is trolling though

#

I'm declaring this a skill issue of the buildbot trl

#

actually, maybe it's a jinx's skill issue....

#

yeah, dry run doesn't expand the variables

#

(It would be great if I could choose which recipes to build, for each arch)

carmine nacelle
left dew
#

?

#

i didn't make jinx

#

but you are right

#

i already brought it up to mint at some point

#

@vale hinge

carmine nacelle
carmine nacelle
#

Ok, I'm doing the filesystem

carmine nacelle
#

I need to figure out the namecache though

carmine nacelle
#

This is fun...

carmine nacelle
#

Ok, I think I'll merge VFS and process/posix together

#

because I think this stuff is too closely coupled

carmine nacelle
#

So I think I'll rewrite that from Rust to C++ before it's too late...

modest thistle
#

XD

#

the service?

carmine nacelle
#

Yes

carmine nacelle
#

I'm writing VFS, and it's trolling me (and it crashed the kernel...)

#

Address misaligned...

carmine nacelle
#

How am I having a skill issue writing circular list stuff??

hexed knot
#

just dont use a circular list

carmine nacelle
#

but they are nice

#

I'm trying to write swap function for the move constructor

hexed knot
#

move constructor???

#

for what

carmine nacelle
#

for the list

hexed knot
#

like for the list itself? or for the list hook

carmine nacelle
#

for the list

hexed knot
#

for the list itself you are swapping one or two pointers idk its not hard

carmine nacelle
#

like not the list nodes, but the list head

#

Like this looks good I think?

hexed knot
#

uhhhh idk tbh

#

my circular list did not contain the list itself

carmine nacelle
#

huh

#

Imma ask a clanker trl

hexed knot
#

and in rust i cant really make them work properly anyway

hexed knot
carmine nacelle
hexed knot
#

personally i would just SK_NO_COPY(CircularDoubleList); SK_NO_MOVE(CircularDoubleList); ngl but like its your code

hexed knot
carmine nacelle
#

I have no copy, but I think move is nice

hexed knot
#

ehh

carmine nacelle
#

I mean I didn't have them, and it destroyed my code with the default constructors

hexed knot
#

moving an intrusive ds like this CAN work butttt

carmine nacelle
#

I didn't delete the copy constructor, and I was accidentally copying the list map.emplace

hexed knot
#

ah

#

do you not have macros that delete all of the constructors lol

carmine nacelle
#

no

hexed knot
#

they are very handy

#

especially because you basically always want to delete copy constructors tbh

carmine nacelle
#

Sometimes it's fine

#

Like for small structs

#

I mean most of the times

#

Like bit fields for paging trl

carmine nacelle
#

I think I'm getting somewhere...

carmine nacelle
#

Ok, since I have the filesystem, I think the next steps would be

  1. Implementing timer rights
  2. Making send() optionally block (and then implementing async send as well?)
  3. Implementing pagers
  4. Mlibc and other posix stuff till I get bash?
carmine nacelle
#

So my plan for the timers is to have them be per-CPU, and then if the timer object is not on the right core, to IPI the other one to get its attention

carmine nacelle
#

(Like timer rights)

#

I nedd to implement this on risc-v and loongarch64 as well, but I'll do that later (since I can't test it on my laptop)

#

And I also need to get rid of the old syscall

modest thistle
#

btw @carmine nacelle does your pci daemon support pcie or just pci?

carmine nacelle
#

both

#

I mean pci is kinda broken at the moment because of some bs in my early pci init code

carmine nacelle
#

This is trolling

modest thistle
#

lol

carmine nacelle
modest thistle
#

and how do you exchange them?

carmine nacelle
#

exchange what?

modest thistle
#

the pages

#

when you need per thread control

carmine nacelle
#

huh?

modest thistle
#

like, if they are shared for whole per cpu tss, then every process / thread will have them, no?

carmine nacelle
#

No, the TSS will have 4 virtual page frames allocated for it (with the first one having the per-CPU data, the last one for the trailing byte). Then I will be swapping the middle two pages in the page tables, without changing the TSS itself

modest thistle
#

oh the phys pages

carmine nacelle
#

yeah...

modest thistle
#

yeah that could work tbh

carmine nacelle
#

Nevermind, fred is anoying, because of how my idle works...

#

Omg, my brain hurts, FRED is so inconsiderate

#

or maybe nevermind

twilit talon
#

lol its pretty easy actually

carmine nacelle
#

No

#

I've been using CS to know what was preempted by interrupts

#

I guess I should be abusing this

twilit talon
#

whats sti (stb)

carmine nacelle
#

sti instruction

twilit talon
#

but sti enables interrupts

carmine nacelle
#

basically, if interrupts were disabled, it means it's an unwarranted exception

#

I'm pretty sure it's interrupts

twilit talon
#

ah yeah its the thing they use for NMIs

carmine nacelle
#

isn't it only for smi though?

twilit talon
#

wdym

#

what does it have to do with smi

carmine nacelle
#

nmi blocking

#

I didn't know about stb

twilit talon
#

no, i mean

carmine nacelle
#

And can't find it

#

wait, no, then I can't use it

twilit talon
#

anyway tldr its not useful for u

#

cant u just check rflags tho?

carmine nacelle
#

No, I need to switch stack if the exception/interrupt is coming from my idle, and stay on the same stack if it's from the kernel

#

because I treat my kernel threads as userspace threads

#

but if I check rflags, it'll break my SMP init code

#

don't ask why

#

Idk how to do this

#

Like I see the vision that you're just supposed to push everything onto stack, do your stuff, and return, without having to care about all of the special cases

#

But idk, I can't wrap my head around it

#

If I don't give my idle a separate stack, it will be eating kernel's stack as well...

#

Though I had an easy solution for this in risc-v

#

But I'd like not to branch if it's possible...

#

"nested level"

heady garden
carmine nacelle
#

Idk, I just feel depressed now

carmine nacelle
heady garden
#

kernel threads don‘t?

carmine nacelle
#

I have one stack per CPU and not per thread

#

So I switch to a special idle stack when I enter it

heady garden
#

oh ok

carmine nacelle
#

And then the one stack per CPU was a deliberate decision and kind off a differentiating factor, but I feel like I have to fight with hardware design of everything any time I change anything in the kernel...

#

Maybe it's time to get rid of it

#

(one stack per CPU)

#

But then the issue is that the whole kernel was written assuming it, so I'd probably need to redo a lot of locking stuff, implement proper mutex, etc.

#

And then it's gonna be implications on top of implications on top of implications

#

And like at the same time I already feel that I'm pouring too much time into something that's a hobby for me to be making any sort of "big" changes like this right now

twilit talon
#

Yeah

#

One stack per cpu sucks

carmine nacelle
twilit talon
#

But also I wouldn't bother with fred until I can get my hands on hardware that actually has it

#

Which won't happen any time soon

carmine nacelle
#

(I mean I came up with the solution while writing this, which is a software interrupt if the kernel was preempted without installing a preemption point)

carmine nacelle
#

According to some news I read today while researching this

#

(sorry for the rant to anyone reading this lol)

carmine nacelle
twilit talon
#

Including new Intel laptops

#

But I cant justify buying a 1k laptop for fred lmfao

carmine nacelle
#

Yeah

carmine nacelle
#

But yeah

twilit talon
carmine nacelle
twilit talon
#

Yes

#

Is zen6 still am5

carmine nacelle
#

Probably

earnest imp
carmine nacelle
#

They've been releasing new AM4 CPUs for like 8 or 9 years?

#

There's no new memory standard

#

So like they may pull Intel, but I'd expect them to release a couple more generations on AM5 before switching to a new platform

earnest imp
#

I think zen7 would be on AM6
Arround then is when ddr6 is getting up?

carmine nacelle
earnest imp
#

they just add a bit extra

soft turret
carmine nacelle
earnest imp
carmine nacelle
#

And it looks at the return type and returns from rcx/r11 instead?

carmine nacelle
#

Idk if I'm dumb, but I can't get it to detect FRED in qemu??

#

I've given it the +fred flag

earnest imp
carmine nacelle
#

no

earnest imp
#

otherwise QEMU TCG will not support it

#

and you need intel SIMICS

#

#resources message

twilit talon
carmine nacelle
#

Simic's trolling

carmine nacelle
#

I need to figure out the serial io stuff...

#

Is this my OS doing this?

earnest imp
carmine nacelle
#

but there's no screen or serial or anything

#

idk what I'm doing

earnest imp
#

what command did you use to launch it?

#

it should open a display

carmine nacelle
#
$cpu_comp_class = "x86-experimental-fred
$iso_image="\\\\wsl.localhost\\Ubuntu\\home\\misha\\pmos\\build-x86_64\\pmos.iso"
run-script ./targets/qsp-x86/qsp-dvd-boot.simics
run
earnest imp
#

Also that stuff was only tested in Linux™

#

Iirc @marble steeple got it working on windows

twilit talon
twilit talon
carmine nacelle
#

What packages did you install?

twilit talon
#

all of them

carmine nacelle
#

what else did you do?

#

idk

twilit talon
#

idr tbh

#

its like

#

extremely fucking counterintuitive

carmine nacelle
#

There's no gui

twilit talon
#

there is gui lol

#

what are u doing

#

but yeah simics is the worst least intuitive piece of software i have seen maybe ever

carmine nacelle
#

nothing happens?

inland temple
twilit talon
#

lol

carmine nacelle
#

simics is also refusing to work on my pc

earnest imp
#

Let me find them

#

If discord on my pc won’t crash

earnest imp
#

I can toss you my ISO if you wana test to make sure it built right etc

carmine nacelle
#

It has detected fred

#

I haven't implemented it yet

earnest imp
#

Yeah but the patches are still well dubious

carmine nacelle
#

(my kernel I mean)

earnest imp
#

So testing would be good trl

carmine nacelle
#

simics is trolling

earnest imp
#

well

#

it is SIMICS

carmine nacelle
#

idk what I'm doing wrong, but there's no gui

earnest imp
#

its simics simicsing all over the place

#

thats it

carmine nacelle
#

This is cool

#

(I think I've gotten it because it tried to iretq

#

but also it's 3:30 am so I'm going to sleep

#

(I've also implemented guard pages for the stacks...)

#

Also, somehow it seems to get to userspace without crashing with 8KB stacks...

earnest imp
marble steeple
toxic torrent
#

can't you just use offsetof with inline asm ethancat2

carmine nacelle
carmine nacelle
carmine nacelle
#

I've gotten to the timer interrupt??

carmine nacelle
#

Trolling continues

#

I really need an unwinder

twilit talon
#

homeless stack traces are funny

twilit talon
#

well u need a symbolicator since it seems u do unwind it

carmine nacelle
#

but it's a simple rip/rbp thing

twilit talon
#

depends if thats enough for u

#

if u explictly enable frame pointers its fine

carmine nacelle
#

not the proper dwarf2 one which unwinds through nullptr %rips

carmine nacelle
twilit talon
#

dwarf cant unwind through a nullptr, at least not the eh_frame unwind

#

i had to add special code for that

carmine nacelle
#

Bruh, I think GPT 5.5 has managed to get SIMICS to work?

#

Though there's still no GUI

#

Also, I think HPET wasn't the firmware...

#

bruh it has managed to get GUI working as well...

carmine nacelle
#

But this now gets deep into userspace

carmine nacelle
#

Ok, this insanity fully works in vibecoded qemu meme

#

Time to fix HPET...

carmine nacelle
earnest imp
#

btw i can test in simics later if you need to make sure its not just the vibe coded qemu

carmine nacelle
#

I've managed to get it working, but it doesn't like my HPET code

#

so I can't really test fred

carmine nacelle
earnest imp
#

ah yeahhhh

#

this is the only BS the firmware gives

carmine nacelle
#

This is fun

#

Yeah, it seems to be fully working

#

And LASS !!

#

Now I just need shadow stacks trl

earnest imp
carmine nacelle
#

Do you have serial I/O?

#

I mean if it has fred, it should have used it or failed

earnest imp
#

yes but your line control is off trl

carmine nacelle
#

Can you scroll up to right after the kernel loads to see if it's using it?

earnest imp
carmine nacelle
#

Cool

carmine nacelle
#

I think I'm gonna finish getting rid of the old usersapce timers API, implement proper IO ports rights, and push this to main

#

After which I think I'll leave this stuff for a bit, since I have exams in a few weeks

twilit talon
#

Btw when are you actually going to port shit

carmine nacelle
twilit talon
#

Can you run something like bash now?

carmine nacelle
#

No

#

I mean I probably have enough kernel/usersapce stuff to do it if I implement enough stuff in libc

#

Also, I'd need an input subsystem for bash

#

(though I have ns16550)

twilit talon
#

I need to implement proper serial console with interrupts as well so I can use my kernel remotely over amt

#

But thats for later

carmine nacelle
twilit talon
#

U need interrupts for output?

carmine nacelle
#

You don't "need" them

modest thistle
carmine nacelle
#

Because serial is very slow

twilit talon
#

Ah does it generate an irq when the output is empty or smth

twilit talon
#

Is it worth it

#

Like 115k baud is how may chars a second

carmine nacelle
modest thistle
twilit talon
#

The isa com x86 has cant go that high lol

carmine nacelle
twilit talon
#

Lmao why

carmine nacelle
#

On physical hardware

#

(my old test PC)

twilit talon
#

Can it not handle 115k

carmine nacelle
#

It can

#

I mean I had issues with it where the characters weren't arriving

#

But it think it was a Linux skill issue on the other side

#

Also serial has busy bits or however it's called, which lets you block the other side from sending if your buffer is full

#

But I haven't bothered with it

twilit talon
#

Looks like 115k baud is approximately 1 char each microsecond

#

So not really worth interrupts

carmine nacelle
#

Maybe 10 microseconds?

#

But yeah, it probably doesn't matter for logs

twilit talon
#

Yes

carmine nacelle
carmine nacelle
#

Clanker had found gold in my PCI interrupt routing code...

#

And the funny thing is that everything dies if I fix it

#

Cool, new hardware discovered...

carmine nacelle
#

Bruh, I've looked at netbs and it's very easy

#

I basically already have something that's almost like that

hexed knot
#

yes

carmine nacelle
#

Just park/unpark and they fix the race with unpark setting a flag...

#

And userspace handles spurious wakeups

#

I don't really get the pointer hints though

#

But it looks like they don't even use it?

plain jungle
#

what are the netbsd park APIs?

carmine nacelle
#

lwp_park/lwp_unpark

plain jungle
#

smh just do block_on(future)

carmine nacelle
#

I think it comes from Sun

carmine nacelle
plain jungle
#

Managarm's kernel-internal primitive is also park / unpark

#

but this is only used to implement block_on(future) (also kernel-internal)

#

and block_on(future) is used to implement everything else (including futexes)

carmine nacelle
#

So it's basically the same thing?

carmine nacelle
#

Bruh, I'm having a giant skill issue with i8042 again...

#

Which is this

#

The i8042 is 2 ACPI devices...

#

but this is so anoying to deal with...

#

Do I just special case it like managarm?

#

Wait a second, ia64 has i8042??

carmine nacelle
#

Also, this is next level trolling from the kernel ("-ENOMEM")

carmine nacelle
#

I now have proper i8042 interrupts discovered from ACPI, maybe I can do shell trl

twilit talon
#

I wonder why its under SF8

#

What device even is at address 8?

carmine nacelle
#

I've no idea

#

That's what ACPI gave me for the keyboard PNP id

#

It's at LPC_ in simics

twilit talon
#

Lpc makes sense

carmine nacelle
#

what's lpc?

twilit talon
#

I mean sf8 probably does as well but idk what that object is

twilit talon
#

00:00

twilit talon
#

Yeah

carmine nacelle
#

My keyboard driver is also fully working again

#

The more I use my timers API the more I like it

carmine nacelle
#

Do I finally port mlibc?

plain jungle
#

do it meme

carmine nacelle
#

My kernel doesn't meet the first requirement ultrameme

twilit talon
kindred venture
#

sys_libc_log

carmine nacelle
#

But I need to figure out how to bring the stuff I do in userspace in

twilit talon
kindred venture
#

I mean yeah but if you have to stub a required sysdep I don't think it really counts as porting mlibc

carmine nacelle
#

But it's a bunch of IPC

#

Cool...

#

Can limine switch to a different git thing again? trl

#

At least Github's ssh thing still works

#

Where do I put my kernel API?

#

Like should I split my libc into two libraries, or just reimplement everything from scratch in mlibc?

plain jungle
#

up to you

#

one thing that probably doesn't work terribly well is linking against a shared library

#

unless it's a VDSO

#

because ld.so will need some calls before it has processed all DSOs

carmine nacelle
#

I mean static library should be fine?

plain jungle
#

yeah

#

a static lib (compiled as PIC) should work

carmine nacelle
#

I also need to decide what to do with my signal thread

#

Because at the moment, my libc initializes itself, and then does pthread_create for the thread that actually calls main()

#

wait a second, is frigg header only?

dense carbon
carmine nacelle
#

Because then it's very easy to integrate

carmine nacelle
#

Btw @twilit talon is it normal that Hyper doesn't enable NX when booted with BIOS by default?

twilit talon
#

Yeah it doesn't use any memory protection at all

#

It doesn't enable WP in cr0 either

#

Enabled nx under UEFI is probably leftovers from edk2

carmine nacelle
#

Ok

#

I'm asking because limine seems to be enabling everything

#

(but like it's ok that it doesn't, my kernel was just triple faulting yesterday, and I found out that that was because I was assuming this to be done by the bootloader)

twilit talon
#

ah

#

i remap my kernel myself anyway

#

so these mappings arent really relevant for me

carmine nacelle
#

I do too, but I forgot to enable NX in EFER

twilit talon
#

skill issue trl

carmine nacelle
#

Like idk why, but even though it's what I normally run, it has the biggest skill issue with everything

twilit talon
#

how do u even not have common paths for such features for both modes ☠️

carmine nacelle
#

That path is common, loading cr3 is not

#

My paging code is separate

twilit talon
#

ah

#

u dont support PAE?

carmine nacelle
#

I do

twilit talon
#

that has NX too tho

carmine nacelle
#

Yep

#

So I do NX detection for both arches

twilit talon
#

ah i see u just duplicated the cpu stuff also

carmine nacelle
twilit talon
#

the way i do it is a common setup_cpu() detects all features and sets a bit in supported_pt_mask

carmine nacelle
#

But stuff like gdt/IDT is different

twilit talon
#

nx is set unconditionally in pt_prot but cleared if its not supported by the mask

twilit talon
#

☠️

carmine nacelle
#

And now that I think of it, I don't enable it when booted with limine???

twilit talon
#

u support both protocols at the same time right

twilit talon
carmine nacelle
#

In the same binary

twilit talon
#

i might do that as well but too lazy

#

limine doesnt have a kernel binary memory type etc

#

its gonna be a bit annoying

carmine nacelle
#

It has kernel and modules

#

Why do you need it?

twilit talon
#

i exclude kernel from the direct map

#

so i need the precise address for it

carmine nacelle
#

Limine also does

twilit talon
#

yeah but im making my own direct map lol

carmine nacelle
#

It has a feature that gives you the kernel address

carmine nacelle
#

(on x86)

twilit talon
carmine nacelle
#

I've been planning to add it as an optimization though

twilit talon
#

it is a good optimization

#

because less TLB usage due to huge pages

#
  • global pages
carmine nacelle
carmine nacelle
twilit talon
#

yeah id have to do that too

carmine nacelle
#

It's not that difficult

twilit talon
#

yes

carmine nacelle
#

But like my kernel doesn't need a separate kernel memmap entry, as long as it's in some kind of used region

#

Though multiboot2 is annoying because it doesn't do that

twilit talon
#

i wouldnt use multiboot2 without a huge prekernel

carmine nacelle
#

I wanted to implement it with an asm trampoline

#

I mean I had a prekernel before, but I've gotten rid of it...

carmine nacelle
carmine nacelle
#

I need to figure out how to include a static library with a static library...

carmine nacelle
#

I think I'm losing motivation again

carmine nacelle
#

Do I call for contributors? thonk

earnest imp
#

even more general helpers for stuff

#

You should throw on the tag though if you want

#

But you will still get them without it

carmine nacelle
#

But idk I'm worried about it since atm basically all of the code is mine (except the external libraries, etc.)

earnest imp
#

Just do code reviews and add a clang format etc

#

If you don’t like the code point stuff out etc

carmine nacelle
#

I do have clang format

#

But it's broken I think

earnest imp
#

It helps a lot

carmine nacelle
#

I've updated the post

carmine nacelle
#

Ok, I said I was gonna leave pmOS for some time, but I'm suddenly in a mood to add mb2 support trl

carmine nacelle
#

How am I having this skill issue?

check_exception old: 0xffffffff new 0xd
748: v=0d e=03f8 i=0 cpl=0 IP=0018:000000000000000f pc=000000000000000f SP=0020:0000000000064f5c env->regs[R_EAX]=00000000e85250d6
EAX=e85250d6 EBX=0000234a ECX=00071000 EDX=000003f0
ESI=00000004 EDI=00000001 EBP=00000000 ESP=00064f5c
EIP=0000000f EFL=00000003 [------C] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0018 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 00000000 00008200 DPL=0 LDT
TR =0038 00000000 00000000 00008900 DPL=0 TSS32-avl
GDT= 1fe75000 00000047
IDT= 00000000 000003ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=000000d6 CCD=ffffff32 CCO=SUBB
EFER=0000000000000000
check_exception old: 0xd new 0xd
749: v=08 e=0000 i=0 cpl=0 IP=0018:000000000000000f pc=000000000000000f SP=0020:0000000000064f5c env->regs[R_EAX]=00000000e85250d6
EAX=e85250d6 EBX=0000234a ECX=00071000 EDX=000003f0
ESI=00000004 EDI=00000001 EBP=00000000 ESP=00064f5c
EIP=0000000f EFL=00000003 [------C] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0018 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 00000000 00008200 DPL=0 LDT
TR =0038 00000000 00000000 00008900 DPL=0 TSS32-avl
GDT= 1fe75000 00000047
IDT= 00000000 000003ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=000000d6 CCD=ffffff32 CCO=SUBB
EFER=0000000000000000
check_exception old: 0x8 new 0xd

#

This is protected mode without paging

twilit talon
#

Looks like you're executing code at 0

carmine nacelle
#

Yes, because I have no IDT

#

Or no...

twilit talon
#

No, thats the first exception

carmine nacelle
#

yeah

#

I'm dumb

#

Or no

#

Nevermind

#

time for bochs coolmeme

#

gdb refuses to work in protected mode for some reason

#

Nevermind, I fixed it lol

carmine nacelle
#

Why am I having such a hard time writing x86 assembly?

#

Having so little registers is unbearable

carmine nacelle
#

Ok, this stuff is almost working

#

I've gotten to the higher half, but it seems like my (self trl) elf loader is broken

#

Or paging

carmine nacelle
#

Cool, this casual assembly insanity has gotten to higher half/C++

#

(Also, I've learned that gnu toolchain exposes symbols, which let you get pheaders for yourself without requesting it from the bootloader)

toxic torrent
#

what were you doing?

carmine nacelle
#

Adding multiboot2 support trl

#

Which ended up being 1k+ lines of assembly just to get to C++?

plain jungle
#

wtf

carmine nacelle
#

I'm not doing a prekernel

twilit talon
#

sounds totally maintainable

carmine nacelle
#

Also, the plan it to support all three protocols with the same binary

#

(I mean, it's kinda working, but Limine and Ultra have stopped booting, likely after my linker scritp changes)

plain jungle
#

even w/o a prekernel, it shouldn't take 1k lines to get from asm to C

#

also, from this progress thread I get the impression that you often have a ton of regressions halfmemeleft . maybe you should invest a bit of time to set up better automated testing

carmine nacelle
#

I mean it's a bit of an exaggeration probably, I have a bunch of comments and empty lines

#

But there are like 1.2k lines of text

#

Actually, no, I was right

plain jungle
modest thistle
#

oh it's 2 500 lines file

#

for 2 arches

#

lol

twilit talon
#

Id KMS if I had to write so much at&t assembly

carmine nacelle
modest thistle
#

oh

carmine nacelle
#

I don't have i686 trampoline yet

plain jungle
#

well

#

it does a lot more than that

#

why not just embed enough space for a few PTs in the BSS

carmine nacelle
#

It also prints to screen

plain jungle
#

yeah which is completely unnecessary

twilit talon
#

you know what its missing? a builtin kernel shell

carmine nacelle
twilit talon
#

do u have something like a free-after-init section?

carmine nacelle
#

No...

twilit talon
#

😭

carmine nacelle
#

I was thinking about it, but didn't bother with it yet

#

It feels like it's more trouble than what it's worth

#

(In terms of memory consumption)

plain jungle
#

i think it's mostly a waste of effort but yeah a free-after-init (or just re-using the PTs) is probably way simpler than this

twilit talon
#

too late now

carmine nacelle
#

(Also, I had bzt's shell thing in my kernel in the past 💀)

kindred venture
#

you don't need output, dynamic allocation, any of that

#

just allocate a few page tables in .bss, map the lower 4G using 2M mappings, map the kernel image using __executable_start and _end without respecting phdr permissions, and call C

#

that's like 100 instructions at most

#

the C code can figure out the rest

carmine nacelle
#

The obnoxious part now is filtering the memory map...

carmine nacelle
#

limine is trolling trl

#

While the same exact binary does boot with limine protocol

#

I need to check grub...

carmine nacelle
#

Meanwhile multiboot2:

Multiboot e820:
0 - A0000 type 1
100000 - 800000 type 1
800000 - 808000 type 4
808000 - 80B000 type 1
80B000 - 80C000 type 4
80C000 - 811000 type 1
811000 - 900000 type 4
900000 - 1EAEC000 type 1
1EAEC000 - 1EC00000 type 2
1EC00000 - 1F8ED000 type 1
1F8ED000 - 1F9ED000 type 2
1F9ED000 - 1FAED000 type 2
1FAED000 - 1FB6D000 type 2
1FB6D000 - 1FB7F000 type 3
1FB7F000 - 1FBFF000 type 4
1FBFF000 - 1FEC1000 type 1
1FEC1000 - 1FEC5000 type 2
1FEC5000 - 1FEC7000 type 4
1FEC7000 - 1FEF4000 type 1
1FEF4000 - 1FF78000 type 2
1FF78000 - 20000000 type 4
E0000000 - F0000000 type 2
FD00000000 - 10000000000 type 2
#

Or maybe not?

#

Wtf am I supposed to do with LIMINE_MEMMAP_RESERVED_MAPPED ???

#

It's passed as reserved by multiboot2 and RAM by limine protocol...

#

This is trolling

carmine nacelle
#

Omg, why did they have to make multiboot2 so obnoxious?

kindred venture
#

yeah I have no idea why they decided to pass a copy instead of a pointer

toxic torrent
#

do they mean RSDT?

kindred venture
#

nope

#

they include copies of the rsdp

carmine nacelle
#

How am I supposed to use the palettes with flanterm??

#

My kernel fully boots with mb2 now, but I'm missing the framebuffer

toxic torrent
#

you pretty much need to assert that framebuffer_type == 1

carmine nacelle
#

bruh, even if you request modules to be page aligned, grub can allocate multiboot2 struct wherever it wants

#

Why...

#

and so it will intersect

#

(Also, how do I send it as a video?)

scarlet salmon
carmine nacelle
#

Cool, my i686 binary can also boot with multiboot2 now

#

Who said you can't use limine for ia32 trl

#

A small change bruh

carmine nacelle
#

I'm done with exams and stuff so maybe not dead os trl

#

But I kinda don't have motivation for this either

toxic torrent
#

W

carmine nacelle
#

I think the time has come to implement lwp_park and unpark

#

Which means I have to implement thread/task rights

#

And I also need to move processes and signals to the kernel since what I have now is a mess

#

Or I don't even know what to do at this point

carmine nacelle
#

I'm so lost

plain jungle
#

Managarm implements pthreads/processes/thread groups in userspace

#

the kernel has a concept of threads but no concept of processes

#

the kernel also doesn't have a concept of signals

carmine nacelle
#

My kernel is the same

#

Now do you deliver signals?

#

I've briefly looked at the code but didn't really get to it

carmine nacelle
plain jungle
#

signals are delivered by interrupting a thread, reading its register state, writing its register state to its stack, loading a new register state and resuming the thread

#

that's done by posix-subsystem

carmine nacelle
#

I have a signal thread for it... But doesn't it make all of the signal stuff IPC and thus very slow?