#uACPI - a portable and easy-to-integrate ACPI implementation
1 messages · Page 69 of 1
i cant really do anything if I dont have logs
Enable earlycon in cmdline
Do u have a way to get serial?
Idk if it has a visual earlycon
mhm i just tried on a laptop and I can reproduce
Its kinda hard to die so early in boot tbh im surprised
lol ok i got it to print to earlycon but its slow as balls
Which earlycon?
efifb
Nice
it doesnt actually crash but for some reason busybox doesnt launch
I think it's a tty issue
it boots!
gg
I do get some ACPI errors
The firmware's AML is doing And(SomeLocalOrArg, ...) where that Local/Arg was never initialized. uACPI strictly refuses to treat an Uninitialized object as an Integer. This is a common firmware bug (vendors test against Windows, which tolerates it).
lol, ofc it's stupid firmare stuff
@fiery ice can you try now
i would have to unpack the iso
no
in grub
you select the entry, press e, then on the linux line you add earlycon=efifb keep_bootcon
where
weird
Can you send an acpi dump as well so I could take a look later
Why
Well thats fine
what's the command again? acpidump
Tbh that usually happens with EC memes but ill take a look, maybe clanker forgot to initialize it early with uacpi
Its going to be obvious from the dump
ugh why are there no good simple file uploads lol
Ill take a look when im home
self-host it :^)
yeah I think it f ound an issue
What was it?
Its the other way around
what
Null is valid
Ah nvm
So why did linux fail to map it
idk what that file uploader is
it didnt
Lol sure
what is this
@fiery ice try this
wdym
linux failed to map it
but uacpi reported it as good
Yes that's what I'm saying
But u said this
i meant uacpi 
@hallow marten it booted
idk why linux failed to map it
fuck yeah
Show dmesg
it's long AF
It has 256k max for early remap
Well grep for acpi
idk if these erros are normal or not
yes
"failed to get unique processor ID" is sus
but i can't scroll back
Yep
No less?
thx
Probably not
Irq 0 here is also sus
For Processor() declarations the kernel reads object.processor.proc_id, but my write_obj doesn't handle UACPI_OBJECT_PROCESSOR — it falls through to the default and leaves proc_id = 0 for every CPU, so they all collide → "Failed to get unique processor _UID (0x0)". Let me check uACPI's processor-info accessor and add the marshalling.
🤦♂️
AGI
XDDDD
does poweroff -f work?
It's going to steal our jobs
I mean if there isn't a service listening to it, power button won't do anything
Overall im impressed it got that far
Seems like most stuff works properly
ok it fixed the unique processor thing
no
it's very low brightness
the second boot
before i even ran any cmd
poweroff -f works btw
Crazy
Yeah the power button press is probably not listened to by anyone
"can you go through the whole code and fix any similar gaps if any? and update the patch accordingly"

Lol
Can you ask it about irq 0 as well
Thats definitely wrong
And it was on both computers
this kinda stuff is what LLMs are good at because it's boring work and it's purely iteration and it can work against a spec
its not implementing features
Hm ok
@fiery ice if u wanna try and check if there's no processor _UID thing
k
Would need to compare against acpica to see if thats true
Thats also a code path no hobby os ever reached
uACPI upstreamed into linux would be huge for this shit
once things are a bit more stable il test it on my laptops
im a lil busy still rn
Also it read the thermal zone temperature correctly
So yeah pretty great stuff
Ill investigate abbix warnings when im home
oh also one of my laptops i know has ACPI bugs logged from ACPICA
so may be intersting
adding that to my todo list :^)
idk, never checked
Can you check later
Great, same errors and irq numbers
Btw @hallow marten can you ask why there isn't a single "new power resource" in the uACPI output
But other than that looks identical to me even error wise, which is impressive on hardware where you have 25k aml ops
it doesnt know
maybe the ISO I sent is old
still nope
what are the chances this gets into mainline once it's done
i found the exact line before it should call the new power resources
but i see nothing about them
0.1
it just skips them
i think if done well, it will get in
Maybe in 10 years
especially because of how acpica is shit now
i don't think the intel employee that gives 5 minutes of his time monthly to maintain acpica will be happy
lol
Also _AL0 evaluation failure
well, considreing the last major regression XD
infy atp get hired in intel and get paid the big bucks only to maintain the acpi stuff
I got rate limited so gotta wait a bit
Lol
I dont think they care about the quality of the main repo as long as the linux fork works
Which doesn't accept slop changes instantly
@pallid lava what about becoming a Linux maintainer and getting money through that for the ACPI/AML subsystems
no one is paid by the linux foundation for being a maintainer unless you're one of torvalds' friends
you have to give up your free time or get paid by a corpo
for doing that work
it's either you work at a corpo that pays you like google, oracle, intel or redhat or you get paid by the foundation
but the foundation is only for core maintainers afaik
and those maintainers are people who linus has known for a very long time
yeah, well it makes sense
Simple: just make a time machine
you wont start giving money to a random dude thast been working on the project for a month
just go to the 90s when linux was a hobby os
I was thinking more become linuses childhood friend
yep
all the maintainers are mostly corpo backed
it's not about friends, it's about long-time maintainers
basically u start maintaining it now maybe in 10 years you'll get something 
To be fair if you are already maintaining uacpi
The Linux shims may not be too much overhead to do
And keep up streamed etc
So just wait 10 years for money
- we coauthor the massive patch to linux 2. corpos notice it 3. we all get hired 4. profit
Mark me on there too
I helped

Well will help
By testing on a fuck ton of machines
i am helping with motivational support
After I eat lunch
Honestly though
This is like one of the best things you can do
And is the reason why my project is where it's at
Because I have had good friends here to help and talk about the project with me etc
i think if this does end up getting serious it'll probably end up as an experimental fork or something for a few years
/experimental set of patches
Yep
Good plan
also infy do you think the AML error might just be an acpica thing
also put it in hackernews
Which one?
_AL0
If it did get merged it would be marked experanental
might just be ACPICA mis-interpreting it correctly
But it would be fucking huge
"we have replaced the CRUSTY intel acpica code from the 90s which is present on all computers"
and uACPI is actually correct
But that error only happens on uACPI no?
Another win for uACPI
whereas uacpi does the right thing and error
I doubt it, especially since uacpi didnt log a single error there
well idk
So the method definitely didnt get aborted
Like what does the code there actually check for
I think we'd have to have an aml dump maybe
i sent one for this pc already if you want
it's in thermal code
struct acpi_handle_list devices = { 0 };
char method[] = "_PSL";
if (index != ACPI_THERMAL_TRIP_PASSIVE) {
method[1] = 'A';
method[2] = 'L';
method[3] = '0' + index;
}
if (!acpi_evaluate_reference(tz->device->handle, method, NULL, &devices)) {
acpi_handle_info(tz->device->handle, "%s evaluation failure\n", method);
return false;
}
imagine if uACPI had been written in rust
and risc-v native
instant 934859385938493 stars
Could be how it revolves that reference, maybe uacpi returns status not found there
Because that looks a bit SUS
Would we be posting this on hacker news?
perhaps
after we refine it some more
id love debugging it but it's gonna take a lot of ping-pongs between me and diamond master 😭
i have other stuff to do rn but I'll clean things up and debug it later
i'll keep working on my scheduler rewrite in the meantime, lol
Ok so for the _PLD here
Method (PR2S, 1, Serialized)
{
If (((CDID & 0xF000) == 0x8000))
{
Switch (Arg0)
{
Case (One)
{
Return (One)
}
Case (0x02)
{
Return (0x02)
}
Case (0x03)
{
Return (0x04)
}
Case (0x04)
{
Return (0x08)
}
Case (0x05)
{
Return (0x0100)
}
Case (0x06)
{
Return (0x0200)
}
Case (0x07)
{
Return (0x0400)
}
Case (0x08)
{
Return (0x0800)
}
Case (0x09)
{
Return (0x10)
}
Case (0x0A)
{
Return (0x20)
}
Case (0x0B)
{
Return (0x1000)
}
Case (0x0C)
{
Return (0x2000)
}
Case (0x0D)
{
Return (0x40)
}
Case (0x0E)
{
Return (0x80)
}
Case (0x0F)
{
Return (0x4000)
}
}
}
Else
{
Switch (Arg0)
{
Case (One)
{
Return (One)
}
Case (0x02)
{
Return (0x02)
}
Case (0x03)
{
Return (0x04)
}
Case (0x04)
{
Return (0x08)
}
Case (0x05)
{
Return (0x10)
}
Case (0x06)
{
Return (0x20)
}
Case (0x07)
{
Return (0x40)
}
Case (0x08)
{
Return (0x80)
}
Case (0x09)
{
Return (0x0100)
}
}
}
}
this falls through and returns nothing
Which means (CDID & 0xF000) == 0x8000) evaulates to false because Arg0 is always hardcoded by the caller
and CDID is a PCI_Config field
So either: ACPICA emulates return value 0 here (which I think it does in slack mode), or uACPI kernel api for pci config is wrong
ill check how NT behaves if the return value is omitted
iirc there were some quirks related to it returning the last value that was on the execution stack
Okay so from the _DSM thing it looks like a uACPI problem
but its caused by a firmware bug
It is risc-v native 
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
{
Switch (ToInteger (Arg0))
{
Case (ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */){ Switch (ToInteger (Arg2))
{
it does a switch on a UUID buffer but for whatever fucking reason converts it to an integer
So you end up comparing first 8 bytes of UUID == UUID
i could've sworn NT didnt support comparing integers and buffers
Ill confirm that and if it doesnt then we'll leave it at that
WAIT
its even worse
it's a 32-bit DSDT, so you're only comparing the first 4 bytes
ACPI Debug: Buffer [0x10]
0000: D0 37 C9 E5 53 35 7A 4D 91 17 EA 4D 19 C3 43 4D // .7..S5zM...M..CM
ACPI Debug: 0xE5C937D0
ACPI Debug: 0xFFFFFFFF
ACPICA thinks that Buffer of 10 bytes == 0xE5C937D0 => true
I doubt thats correct according to NT but ill test it
bruh
least insane aml behaviour
now I have to remember how to work with windbg and amli! stuff 
Ah, these retards probably saw this warning:
x.dsl 96: Switch (Arg0)
Warning 3124 - ^ Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer
And just blindly slapped a ToInteger
🥀
alright lets see
feeding nt custom AML and seeing what it thinks
If(LEqual(_T_0=0xe5c937d0,Buffer(0x10){
0xd0,0x37,0xc9,0xe5,0x53,0x35,0x7a,0x4d,0x91,0x17,0xea,0x4d,0x19,0xc3
0x43,0x4d})The target has requested that the debugger execute a command: !amli err 0xee 0000000000000000 0000000000000000 0000000000000000 0000000000000000;g
yeah i was right
ACPICA is bullshitting here
uacpi produces the correct result
0: kd> !amli err 0xee 0000000000000000 0000000000000000 0000000000000000 0000000000000000;g
an invalid parameter combination was passed to a function
As for this one, NT produces this return value:
ffff9a85cd0906bc: Store(Local0=<Obj=FFFF9A85CDF28238,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>,Debug)Unknown()
=<Obj=FFFF9A85CD5FF090,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>
Let's see if AndOp will crash on it as well (it probably will)
someone show this to that dude who wanted to write an aml interpreter 
lol
I should maybe try to get the latest win11 image, but i doubt they patched much aml wise as to not break backwards compat
0: kd> !amli err 0xc6 0000000000000000 FFFFF8000532AFB8 0000000000000000 0000000000000000;g
ValidateArgTypes: expected Arg0 to be type Integer (Type=Unknown)
lmfao yeah and ACPICA in slack mode treats it as 0
so yeah that explains it
basically none of those errors are problems
as nt would react the same
huh
how did this work in the first place?
I guess "it works on nt" is no longer the bar
the bar officially doesn't exist anymore
those are misc methods
if they fail no one will notice really
and nt will still boot
i guess they dont look at logs
but what's the point of them then?
_PLD is physical location of device
aka it tells u where the usb port is physically on the computer
it works on nt has now become "it boots just fucking ship it please"
_DSM is some device speciifc method that enables a feature
Is the _AL0 thing also something like that
al0 has to do with thermal zones so no
im almost sure it never got called
since uacpi didnt print an error
probably because that function produces a bogus path aka clanker probably fucked up in some way
ye
I know why _AL0 fails
it's not there
Why?
ah yeah
@fiery turtle
did u have clanker fix uacpi code?
yea
case UACPI_OBJECT_POWER_RESOURCE:
dst->power_resource = src->power_resource;
break;
this is the fix
yeah thats the fix
yepp, it's working fine
yes
crazy
well, both were fixed
how did it fix al0?
it was another thing
this
i guess the proper thing would be to review it and see if there are any places where it did weird shit thats better fixed on the uacpi side as a new type of api etc
for example the object attach instead of insane hashtable stuff that it did
i had the object attach thing as a TODO
btw you could at least make a linux fork and add that patch on top and we could put it under the uacpi org at least
maybe as a replacement for https://github.com/uACPI/uacpi-linux
since that just did uacpi side by side with acpica
its basically just running uacpi code next to acpica, like namespace is initialized twice etc
it was more of a demo to see what sort of score linux would get
good find by the clanker also, such things can only be uncovered by more advanced use cases unfortunately
btw the real test that should be done is suspend/resume with linux uacpi
that exercises a crazy amount of api and is very fragile as well
well if you give me an iso for that i'll try
is there a poweroff command that allows that?
I know my computer is very funky with sleep and resume.
I also just woke up from a nap so I can try and test things hopefully 😭
meanwhile im installing window 2025 server to test if they changed any aml stuff
My condolences
My laptop doesn't sleep with Linux 
(I mean it has s2idle)
But like it wakes up immediately
wtf
maybe it will fix itself with uacpi 
ffffe30ee9706cd0: If(And(Local0=<Obj=FFFFE30EEA034C00,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>,0x123,)ValidateArgTypes: expected Arg0 to be type Integer (Type=Unknown) yeah no change in that behavior between windows 10 and server 2025
ffffc50b840349d5: While(One)
ffffc50b840349d8: {
ffffc50b840349d8: Store(ToInteger(Arg0=Buffer(0x10){
0xd0,0x37,0xc9,0xe5,0x53,0x35,0x7a,0x4d,0x91,0x17,0xea,0x4d,0x19,0xc3
0x43,0x4d},)=0x4d7a3553e5c937d0,_T_0)=0x4d7a3553e5c937d0
ffffc50b840349e0: If(LEqual(_T_0=0xe5c937d0,Buffer(0x10){
0xd0,0x37,0xc9,0xe5,0x53,0x35,0x7a,0x4d,0x91,0x17,0xea,0x4d,0x19,0xc3
0x43,0x4d})an invalid parameter combination was passed to a function
same goes for the switch behavior
yeah looks like theres exactly 0 changes to the aml interpreter in 10 years
Common uACPI win
Common ACPICA L
I did notice a small bug in uACPI so it wasnt wasted time ig
ffffc50b840349b8: Store(Concatenate("ARG0 as integer is ",ToInteger(Arg0=Buffer(0x10){
0xd0,0x37,0xc9,0xe5,0x53,0x35,0x7a,0x4d,0x91,0x17,0xea,0x4d,0x19,0xc3
0x43,0x4d},)=0x4d7a3553e5c937d0,)="ARG0 as integer is e5c937d0",Debug)String(:Str="ARG0 as integer is e5c937d0")
="ARG0 as integer is e5c937d0"
So as you can see here it says ToInteger(Arg0=Buffer(0x10){ 0xd0,0x37,0xc9,0xe5,0x53,0x35,0x7a,0x4d,0x91,0x17,0xea,0x4d,0x19,0xc3 0x43,0x4d},)=0x4d7a3553e5c937d0
Even though DSDT is 32-bits, it prints the result out as a 64-bit integer 0x4d7a3553e5c937d0
so uACPI copied that behavior also
But I see now that it prints out "ARG0 as integer is e5c937d0" so I guess internally it does truncate it somehow
Ill confirm that ToInteger(Arg0) == 0xe5c937d0 is indeed true and then fix that up then
I also meant to comment on this earlier
Shouldnt is say
ACPICA (Standard)
uACPI (Experimental)
It could also be named something better maybe? And what sub menu is this under?
Also if we got a new ISO hand it over
Il force myself to wakeup and do this shit
@full nimbus we have this rn
that should work correctly
Apparently systemd handles alot of the suspend shit?
Though there is a sysfs thing for it
there is no systemd in that iso afaik
Yeah
If there are patches for the current state
I could apply them and make my own kernel build
And install it on one of the laptops
To test suspend/resume
acpi
@full nimbus
that last bit is already fixed on master
because I'm gatekeeping
if i make a linux fork that means I have to do proper signed commits and stuff
ugh @fiery turtle why did you name the structs the same as acpica
which ones and why is that a problem 
just download ze kernel whatever the latest is source and apply these?
yea
yeah so include the acpica header but dont include uacpi/acpi.h
some stuff includes it I think
like this right?
dont think so, since i specifically tried to avoid that
well, from git
event.h
i got the zip but yeah
nope it works
yeah its a bug i think, ill get rid of that include
io.h wont work tho
it will work just fine with a forward declaration
there's some cursed stuff in the code ngl 💀
alr im building it on my desktop
are you going to boot into it on your desktop?
this is probably not that bad
Yeah
It has some cursed sleep shit
why is pld stuff done on uacpi side?
Sometimes it takes 30 seconds for one monitor to come up
And somtimes on a fresh boot my mouse dosnt work
💀
does acpica give helpers for that or smth
this is in acpi_decode_pld_buffer
lol thats gonna be interesting
Imagine if uACPI fixes this

It’s like not that annoying
But like every few weeks
I turn on my pc
And I have to reboot it
ah ok thats not that bad for sure, ill just add that helper to uacpi natively
resources are really complex
its what aml returns via _CRS etc
the resource code converts a compressed varaible length insane aml repr into usable C structs
I just hard to rebuild qemu on windows with an insane MSYS2 setup just to switch the dsdt revision to 2
but it helped me confirm my research
the code isnt actually that bad
the resource code is insane
but I think that's ACPI's fault
yeah thats true
nice
did it work
still building driver modules
🥀
i copied my main kernels config
i stg if nvme or ext4 is a moduke
the header changes unfortunately break backwards compat i.e. may accidentally break compilation for some people so its time for uacpi 6.0 soon 
i have a few other things befor then tho
including PLD helpers now ig
dunno

ask claude
i alr make cleaned because im making a more light config that has nvme built in
where u have acpi_install_gpe_handler
@hallow marten its probably because clanker didnt add EXPORT_SYMBOL_GPL to the implementations
so modpost doesnt see them
make a patch that includes uacpi sources maybe 
ahh
fuck
can you try it evalyn
or i can ask the clanka
or i guess just EXPORT_SYMBOL since its not GPL
ask the clanker
it is
i have decided
it is now gpl
gg
okay this config has nvme/ext4/efifb/amdgpu/uacpi as builtins and not modules
lets try this
Okay it's doing something
It logged a bunch of ACPI errors
And now it's booting
I think
Also it didn't use limine and its by default using the kernel from my main bootloader
So
💀
And it's stuck
@fiery turtle
The pld stuff is harmless
Its stuck for some other reason
Im assuming because of the warnings below
this is where it died and i had to force shit it
Huh, why wasn't that in the logs on the screen?
acpidump > dunp.txt
Why does it keep spamming that method 
07 20:09:20 EvalynPC kernel: ACPI: requested invalid table index 28 (28 tables installed) also lol
Clanker tried to out of bounds it or smth?
Or maybe it doesn't know about the count getter
where do i get this package
Thanks
this is my board
Or should I make a PR with it or whatever else later
For ze GitHub points 
Why is the thin you posted different from this log?
I had two boots
I got the one that I let run the longest
leme get the otherrr
Yeah but that one looked like it made it to Userspace just fine?
Maybe something else was dying?
Unrelated to ACPI
I couldn't open any other virtual terminals
They just were blank
Yes
Lol
Yeah definitely
Its probably because you changed the config and it didnt like that somehow
@hallow marten can you make an ISO that has a way to put the thing to sleep?
Does poweroff really not have that option
Let me check but I can't remember
nope
Options:
--help Show this help
--halt Halt the machine
-p --poweroff Switch off the machine
--reboot Reboot the machine
-f --force Force immediate halt/power-off/reboot
-w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
-d --no-wtmp Don't write wtmp record
--no-wall Don't send wall message before halt/power-off/reboot
Unless halt is sleep?
what does halt do
Idfk
or just somthing super minimal that glues on just enough ad-hoc support
Ye
i think for sleep you can just write some value to some sysfs file
echo deep > /sys/power/mem_sleep; echo mem > /sys/power/state
Test it on the uACPI ISO
yes
it went to sleep
Can it wake up?

That's probably not good
@fiery turtle
We may need a distro with systemd
That can have better logging for this shit
someone should rewrite acpica and call it acpicb
Doesn't ACPICA have a bunch of core architectural problems that make it harder to properly be NT compatible etc?
Rewrite it in the B programming language too
acpica-rs when?
Rewrite uacpi in rust 
Waking up is done by firmware, aka you should at least hear the fan spinning etc, if it doesn't get further its a kernel bug
If it doesn't wake up at all maybe there are no wake sources or smth
Basically it probably never even reached the kernel trampoline
Idk if clanker did GPE programming mapping correctly
Since thats how you set wake sources
Maybe it could have been that?
The firmware for wakeup though basically puts you in a similar state after a SIPI though right? And you basically do the same as an AP trampoline but maybe a little different for setup ig?
Yep
@fiery turtle for the FACS can i just read the ptr in FADT or do i have to use the same table api as for other tables?
same api, why do u need it tho?
does the facs doesnt contain anything of interest for the kernel?
not really, and its managed by uacpi anyway
then i wont add it now, maybe later if someone wants to be able to dump the tables via uacpi-rs
i implement them in uacpi-rs as getter
I see
so that the user doesnt have to implement a single table in their kernel
/var/lib/managarm-buildenv/build/system-root/usr/share/uacpi/source/stdlib.c:606:25: error: 'signed char' to 'uacpi_u64' (aka 'unsigned long long') conversion; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse,-warnings-as-errors]
606 | value = (signed char)uacpi_va_arg(vlist, int);
yeah but what am i supposed to do with it
it's intended since it's a formatting function
clang-tidy wants you to do (unsigned char)(signed char)...
is that better?
it doesn't sign extend to 0xffffffffffffffxx
if (fm->is_signed) {
uacpi_i64 as_ll = value;
if (as_ll < 0) {
value = -as_ll;
negative = UACPI_TRUE;
}
}
It does this later
if I dont sign extend this logic will blow up
I think in that case it wants you to cast to uint64_t directly (?)
I will silence this by ignoring uacpi source i guess but it's still something that you want to fix upstream
how do I run this check?
it's funny that it got triggered by signed char but not signed short for example
ill take a look, why not fix it if its cheap ig
will be fixed in https://github.com/uACPI/uACPI/pull/155
i found a few important memory leaks/potential crashes on OOM as well
might roll 6.0.0 very soon
lol, the quickest release ever
public header changes 😭
Also updated the wiki a bit
if someone could write an example of how to use the barebones/early table stuff thatd be nice
5.0.1
thats not how semver semvers
tbh i have no idea what new features there are
i wish changelog existed that i posted and that is available on github releases 
lmao
How many people even use it? 
idk but the page has 30k views
I could write one in rust 
I mean my kernel uses it...
i don't 
Or the barebones mode
i have allocators and scheduling before acpi init
i just have my own functions for iterating over the madt and retrieving other tables from the rsdt
then after scheduling is done i initialize acpi and then pci
u just reimplemented the early tables mode yourself lol
yeah basically
I set up uACPI barebones mode after allocation and before scheduling
Though I guess I can swap those
i set it up after the boot allocator & early MMIO mapping helpers but thats pretty much it, nothing else is available at that point
Since my kernel bootstraps itself by finding the largest memory region, and bump allocating from it, so uACPI should work
boot allocator boot allocator
Like when decide to support NUMA or whatever

yeah if im going to support numa id have to redo the order a bit
early mmio would have to be first
I have no early mmio mappings 
imagine having early stuff
how do u map acpi stuff?
lmao
As normal
But like not through a special mechanism
I set up vmem before pfndb && palloc
so u have an early mapping thing?
It is a mapping thing
yeah but how do u allocate the chunk of virtual memory where to map it
I don't use HHDM
Though vmem
based tbh
so like u initialize all these allocators before acpi right
Yes
i see
i dont do that so i can get a clock source early
so my logs have timestamps
- early hypervisor detection
which can skip tsc calibration which speeds up boot by 50ms
I map the kernel, then temporary mapper, then switch to kernel page tables, then initialize vmem, then pfndb and page frame allocator after that, then uACPI
Then scheduling, interrupts, SMP, userspace
(in that order)
I see
Idr the order of the first two
early mmio i just have a fixed bitmap of slots, for the late mmio it just reuses vmalloc for allocating virtual memory + applies arch caching attributes etc
Like my kernel allocation functions just bump from the temporary region, then it gets reserved in my pma
the pain for supporting multiboot
So vmem's slab just allocates from that and I map stuff through the normal mechanism
The pain is filtering the memory map
The rest of the code is the same
I guess mapping hhdm would be painful
But I don't do it 
i mean i dont have a single point in my kernel where i dont have access to every single ram page via the hhdm
that simplifies every piece of init code a lot
I just have helpers for it
Which use bootloaders' hhdm/direct map which I set up with multiboot, then I switch to temporary mapper thing
On la64 I use the canonical gap hhdm
did u check if linux uses it btw
I think someone said it does
But idk if it only sets it up or actually uses it
Idk why limine doesn't use it though
wow
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
pgprot_t prot)
{
if (offset > TO_PHYS_MASK)
return NULL;
switch (pgprot_val(prot) & _CACHE_MASK) {
case _CACHE_CC:
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
case _CACHE_SUC:
return (void __iomem *)(unsigned long)(UNCACHE_BASE + offset);
case _CACHE_WUC:
return (void __iomem *)(unsigned long)(WRITECOMBINE_BASE + offset);
default:
return NULL;
}
}
#define ioremap(offset, size) \
ioremap_prot((offset), (size), PAGE_KERNEL_SUC)
This is crazy
Probably because of kaslr?
on other arches ioremap is really complex
holy epic
on other arches its vmalloc + remap
Tbh it sounds like a Linux skill issue
But this isn't complex
accessing everything thats not ram
it's also like tlb sync, traffic for invlidations etc
and LA64 is like, nah just grab an hhdm offset
crazy arch
on x86 its ub to map the same physical page with different caching attributes
and it will blow up
so yes everything is stopping you
What
Wdym
Wtf
linux has a really complex interval tree on x86 thats used to make sure that never happens
e.g. if some ram is mapped as both WB but something wants to map it as WC
that will cause an MCE
Bruh
I don't have checks for that for userspace
I mean my kernel is safe because microkernel
well u should if u allow mmap to specify cache attributes
I'll check it out later (when I get an actual MCE because of that
)
if it detects that RAM is remapped with a different caching attribute it splits the large HHDM pages and also remaps them with that
(thats this code)
From doing what
yeah, i was going to ask something similar
From mapping ram with other permissions
how common is it to map the same physical addresses with different caching attributes?
yeah i guess
im gonna do that also
Like if you're explicitly mapping something as WT or UC check that it's not ram
Since you would only do that for mmio or framebuffer anyway
Though WT and UC still needs to be checked for collisions
u can grep the code for set_memory_*
But like in reality if somebody tries to map that it's a bug
most hits are DRM
But also some control structures, e.g. virtio queues are usually allocated as uncached dma memory in linux (idk if it does that on x86)
probably only for non coherent PCI
Also, this doesn't apply to different ASIDs/address spaces, right?
so maybe thats fine
cache works on physical pages not on virtual ones
so it doesnt matter which asid it came from
Because then some process can trash other's mappings
if it tries to remap ram as UC?
Yeah
well on linux u need to be admin for that
and with admin u can crash the system by a lot of means
its intended
Like map /dev/memory or whatever as UC
yeah sure
Idk, this sounds like a big headache
That's solvable
You can't reject userspace
The issue is with framebuffers
Do GPU memory locations change on mode change?
the framebuffer is usually mapped at an offset in a GPU BAR
so its not physical memory
Or how does the firmare communicate the framebuffer's location?
in the gpu itself you can change the offset in the vram where the framebuffer is located
firmware or software
So it's reserved in memory map as reserved
Like where do limine/hyper get framebuffer memory region information from?
well igpu stolen memory might be in the memory map but thats another unrelated story
its allocated by firmware
vesa/gop
which is implemented by the GPU's vbios
aa long as it's not marked as usable
Like what I don't get it how do I track the framebuffer
on igpu u have a bar that is a view into the global igpu page tables, u map a stolen region of igpu memory in the gpu page tables and set a video mode
for example
For UC/WT
wdym by track
Like if you connect a display, you get a second framebuffer
linux tracks all mmio resources in a resource rb tree
it has one for memory and io ports
you dont magically get it, you allocate the framebuffer backing, set it on the gpu, and get a cursor into it
But I'm a microkernel
you can have device mappings requests go through a server
How does Managarm deal with it?
that validates the caching attributes etc
and then actually requests the kernel to map it
I've been validating it in kernel
Yeah, I can do that through capabilities
Like right now anyone can map any memory, but I can just restrict it to my acpi/dt server and make it give out the capabilities to stuff
to be clear there are MTRRs right, so the double remap is only a problem if you override the MTRR settings
(I wanted to do it that way anyway)
which happens with WC etc
Yeah, the framebuffer
I can just reject that
yeah
Though I'd have to reject UC as well
well u have to have that for non-x86 platforms but thats not a problem there i suppose
Which you won't get anyway unless you're the ACPI server, which deduces the memory from memory map anyway
It's an arch-independent code
on non x86 u have tons of cases for mapping ram as UC
In my os
I think I handle that already
for non coherent pci basically
I allow userspace to request DMA memory
Actually, I don't
I mean I can add it easily
for aarch64 yeah
I think I already map that as UC
Anyway
I'll come back to this in a few weeks when I have time to work on my os
I'll just track it though the memory objects
Is this also UB on arm?
Like mapping the same memory with different caching stuff
i dont think so because arm doesnt have any code for bookkeeping of that sort
Cool
So like all of this in not a problem then 
I can just have a MAP_DMA or whatever thing, which will map as normal ram on x86 and as UC on ARM
When I port to ARM (if I port to ARM
)
there's basically dma_alloc_coherent which you would use to e.g. allocate an nvme queue, so the entire mapping would be UC (or WB for coherent PCI). The second one is dma_map_* thats for mapping arbitrary physical memory as DMA (that also transparently handles IOMMU)
ive just research it a bit more
on arm all it does is evict that physical memory from the data cache to the PoC
then remap it with vmalloc outside of hhdm
hhdm remains mapped as wb-cached
its assumed safe because a speculative access will just read the cache line but not dirty it
U can read b2.11 in ARMARM
it describes the specific side effects of mismatched attributes
whereas on x86 its just UB
it might require a PhD to understand the specific implications tho
cc @ korona
im actually in the need to make a somewhat proper (albiet very minimal) distro for an i686 laptop to make it into a dummy terminal and have somthing that dosnt need a persistent disk. (and possibly for recovery drives to boot into and have a shell + utils)
if @hallow marten finishes up thoes patches a bit more il have that by default build with uACPI + some other crap we need to test it as an "offical" uACPI linux testing distribution
cc: @fiery turtle
it will also have an x86-64 build
What do I need to finish tho
well ideally we debug the suspend thing
General cleanup of anything and if there are any bugs found when testing it
I'm not sure the complete state of it etc
And I don't wana push fully clanker patches for the kernel when I set this up
Does it not work?
it doesnt resume so im assuming the way the clanker translated wake gpe programming is wrong
or other related stuff
but also we only tested on one laptop and idk if that even has s3 or if that uses s2idle or smth
where's the iso? I can test it on some of my systems, they're pretty straight forward acpi wise
what kernel version is the patch for? :^)
wow nice
i'll try on my desktop as well but i need to recompile the kernel for that (need several modules incl. amdgpu)
wait did I miss linux uACPI patches???
And hopefully a uACPI Linux distro
abbix had clanker port linux to uacpi via a compat interface
holy shit, uACPI everywhere 
@hallow marten it would be nice if you could get your patches to run for kernel v6.18.35
btw what kernel config do i use? just defconfig?
MacOS 
apple silicon doesn't have ACPI tho?
well legacy macos
what if i do a hackintosh
uacpi rules world
to me thats really cool and impressive to see, because these gpe and suspend related apis are really advanced/complex logic that no hobby os uses
and to see it work on real hw is cool
also the fact that clanker managed to port it correctly
Probably would work anyway
i dont think there have been many changes to any acpica apis between 6 and 7
so it should work
Yeah
no, those are ultra logs 
close enough 
they dropped it in the latest macos i thibnk :^)
er, legacy hw i mean
no, it sleeps and never wakes up
ok on my desktop it's broken (can't tell where beyond it being after amdgpu enters standby and before the system enters sleep (the power led and fans are still on))
do u have a com port on it?
maybe serial over usb could work?
what does that entail
iirc its like a usb cable that you insert, alternatively theres also pci serial cards but that costs some money ofc
basically theres probably no easy way to debug this
well this is after the drivers are all shut down so I doubt anything relying on the USB controller would work
there has to be some sort of a command line/config option that linux uses to debug suspend issues right
like in general
like early con but the other way around
actually i do have a COM header on the motherboard
but like I said no equipment to use it
and usb to serial should work there
yeah youd have to buy a special cable for it
or even a cheap arduino / rpi
I might do that anyway, it seems like a good thing to have
yeah that sounds pretty useful for debugging in general
you probably need some level shifters too then
not really

