#uACPI - a portable and easy-to-integrate ACPI implementation

1 messages · Page 69 of 1

fiery ice
#

i'm using ventoy to boot it

#

yeah no, even in memdisk it still is not booting

hallow marten
#

i cant really do anything if I dont have logs

fiery turtle
#

Do u have a way to get serial?

fiery ice
#

nope

#

it's on a laptop

fiery turtle
#

Idk if it has a visual earlycon

hallow marten
#

mhm i just tried on a laptop and I can reproduce

fiery turtle
#

Its kinda hard to die so early in boot tbh im surprised

hallow marten
#

lol ok i got it to print to earlycon but its slow as balls

fiery turtle
#

Which earlycon?

hallow marten
#

efifb

fiery turtle
#

Nice

hallow marten
#

it doesnt actually crash but for some reason busybox doesnt launch

#

I think it's a tty issue

#

it boots!

fiery ice
#

gg

fiery turtle
#

Lesgo

#

Show dmesg

hallow marten
#

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).

fiery ice
#

lol, ofc it's stupid firmare stuff

hallow marten
fiery ice
#

ye

#

nope, not booting

hallow marten
#

wat

#

can you add earlycon=efifb

fiery ice
#

i would have to unpack the iso

hallow marten
#

no

#

in grub

#

you select the entry, press e, then on the linux line you add earlycon=efifb keep_bootcon

fiery ice
#

oh

#

sec

hallow marten
fiery ice
#

ok yep it's doing stuff rn

#

and it had a kernel panic

#

lol

hallow marten
#

where

fiery ice
hallow marten
#

weird

fiery turtle
# hallow marten

Can you send an acpi dump as well so I could take a look later

hallow marten
#

yeah

#

that laptop is fucked tho

#

its very weird

fiery turtle
#

Why

hallow marten
#

the screen is super high res and touch

#

weird resolution

fiery turtle
#

Well thats fine

hallow marten
#

what's the command again? acpidump

fiery turtle
#

Just echo it into a file

fiery turtle
#

Its going to be obvious from the dump

hallow marten
#

ugh why are there no good simple file uploads lol

fiery ice
#

or gdrive

fiery turtle
#

Ill take a look when im home

torpid root
#

self-host it :^)

fiery turtle
# fiery ice

Can u ask the clanker what this thing is about

hallow marten
#

yeah I think it f ound an issue

fiery turtle
#

What was it?

hallow marten
#

uacpi_kernel_map changed

#

NULL is not invalid anymore

fiery turtle
#

Its the other way around

hallow marten
#

what

fiery turtle
#

Null is valid

hallow marten
#

yeah

#

thats what I said

fiery turtle
#

Ah nvm

hallow marten
#

ok try this

fiery turtle
#

So why did linux fail to map it

hallow marten
#

idk what that file uploader is

hallow marten
fiery turtle
#

Lol sure

hallow marten
fiery ice
hallow marten
fiery turtle
#

But thats expected

hallow marten
#

linux failed to map it

#

but uacpi reported it as good

fiery turtle
#

Yes that's what I'm saying

fiery turtle
hallow marten
#

i meant uacpi meme

fiery ice
#

@hallow marten it booted

hallow marten
#

idk why linux failed to map it

hallow marten
fiery turtle
fiery ice
#

it's long AF

fiery turtle
fiery turtle
hallow marten
#

just do dmesg |grep -i acpi

fiery ice
fiery turtle
#

Nor bad I suppose

hallow marten
#

idk if these erros are normal or not

fiery turtle
fiery ice
#

yes

hallow marten
#

"failed to get unique processor ID" is sus

fiery ice
#

but i can't scroll back

fiery turtle
#

Yep

fiery turtle
hallow marten
#

use less

#

dmesg | grep -i acpi | less

fiery ice
#

thx

fiery turtle
fiery turtle
fiery ice
#

power btn not working btw

hallow marten
#
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.
#

🤦‍♂️

fiery turtle
#

AGI

fiery ice
#

XDDDD

hallow marten
#

does poweroff -f work?

fiery ice
#

ah didn't test it

#

sec

full nimbus
fiery turtle
#

I mean if there isn't a service listening to it, power button won't do anything

fiery turtle
#

Seems like most stuff works properly

hallow marten
#

ok it fixed the unique processor thing

fiery turtle
#

Even advanced stuff no hobby os touches

#

Like osc etc

fiery ice
#

why is my screen dark now

#

wtf

hallow marten
#

because you shut it down?

#

lol

fiery ice
#

no

#

it's very low brightness

#

the second boot

#

before i even ran any cmd

#

poweroff -f works btw

fiery turtle
#

Crazy

torpid root
#

prod ready

#

ship it

fiery turtle
#

Yeah the power button press is probably not listened to by anyone

hallow marten
#

"can you go through the whole code and fix any similar gaps if any? and update the patch accordingly"

fiery turtle
#

Lol

#

Can you ask it about irq 0 as well

#

Thats definitely wrong

#

And it was on both computers

hallow marten
#

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

hallow marten
fiery turtle
hallow marten
fiery ice
#

k

fiery turtle
#

Would need to compare against acpica to see if thats true

fiery ice
#

yep fixed

#

lemme send pics

#

@hallow marten

fiery turtle
# fiery ice

Damn, it even handled dynamically loaded tables via aml perfectly fine

fiery turtle
#

On linux

fiery turtle
full nimbus
#

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

fiery turtle
# fiery ice

Also it read the thermal zone temperature correctly

#

So yeah pretty great stuff

#

Ill investigate abbix warnings when im home

full nimbus
#

oh also one of my laptops i know has ACPI bugs logged from ACPICA

#

so may be intersting

torpid root
#

adding that to my todo list :^)

fiery ice
fiery turtle
fiery ice
#

i can check now

#

lemme try a random linux iso i have

#

@fiery turtle

fiery turtle
#

Great, same errors and irq numbers

fiery turtle
# fiery ice

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

hallow marten
#

maybe the ISO I sent is old

fiery ice
pallid lava
#

what are the chances this gets into mainline once it's done

fiery ice
#

but i see nothing about them

fiery ice
#

it just skips them

fiery ice
hallow marten
#

Maybe in 10 years

fiery ice
#

especially because of how acpica is shit now

pallid lava
#

i don't think the intel employee that gives 5 minutes of his time monthly to maintain acpica will be happy

#

lol

fiery turtle
fiery ice
pallid lava
#

infy atp get hired in intel and get paid the big bucks only to maintain the acpi stuff

hallow marten
fiery turtle
#

Lol

fiery turtle
#

Which doesn't accept slop changes instantly

full nimbus
#

@pallid lava what about becoming a Linux maintainer and getting money through that for the ACPI/AML subsystems

pallid lava
#

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

full nimbus
#

Ah damn

#

Still looks good on a resume

hallow marten
#

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

pallid lava
#

and those maintainers are people who linus has known for a very long time

hallow marten
#

yeah, well it makes sense

full nimbus
hallow marten
#

you wont start giving money to a random dude thast been working on the project for a month

pallid lava
#

just go to the 90s when linux was a hobby os

full nimbus
#

I was thinking more become linuses childhood friend

fiery turtle
#

all the maintainers are mostly corpo backed

hallow marten
#

basically u start maintaining it now maybe in 10 years you'll get something trl

full nimbus
#

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

hallow marten
#
  1. we coauthor the massive patch to linux 2. corpos notice it 3. we all get hired 4. profit
full nimbus
#

Mark me on there too

#

I helped

#

Well will help

#

By testing on a fuck ton of machines

pallid lava
#

i am helping with motivational support

full nimbus
#

After I eat lunch

full nimbus
#

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

hallow marten
#

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

fiery turtle
#

Yep

hallow marten
#

also infy do you think the AML error might just be an acpica thing

pallid lava
#

also put it in hackernews

hallow marten
#

_AL0

full nimbus
#

If it did get merged it would be marked experanental

hallow marten
#

might just be ACPICA mis-interpreting it correctly

full nimbus
#

But it would be fucking huge

pallid lava
#

"we have replaced the CRUSTY intel acpica code from the 90s which is present on all computers"

hallow marten
#

and uACPI is actually correct

fiery turtle
hallow marten
#

yeah

#

so acpica is interpreting bad bytecode but doesnt fail

full nimbus
hallow marten
#

whereas uacpi does the right thing and error

fiery turtle
#

I doubt it, especially since uacpi didnt log a single error there

hallow marten
#

well idk

fiery turtle
#

So the method definitely didnt get aborted

#

Like what does the code there actually check for

hallow marten
#

I think we'd have to have an aml dump maybe

fiery turtle
#

No like

#

The code that logs that message

#

What does it check for even

fiery ice
fiery turtle
#

The return value?

#

If its the return value we can log it ig

hallow marten
#

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;
    }

hallow marten
#

and risc-v native

#

instant 934859385938493 stars

fiery turtle
#

Because that looks a bit SUS

full nimbus
#

Would we be posting this on hacker news?

hallow marten
#

perhaps

fiery ice
#

after we refine it some more

hallow marten
fiery ice
#

i'm basically always here

#

so dw about that

hallow marten
#

i have other stuff to do rn but I'll clean things up and debug it later

fiery ice
#

i'll keep working on my scheduler rewrite in the meantime, lol

fiery turtle
#
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

fiery turtle
#

but its caused by a firmware bug

calm latch
fiery turtle
#
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

fiery ice
#

bruh

lethal trench
#

least insane aml behaviour

fiery turtle
#

now I have to remember how to work with windbg and amli! stuff nooo

#

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

lethal trench
#

🥀

fiery turtle
#

alright lets see

hollow scaffold
#

im curious

fiery turtle
#

feeding nt custom AML and seeing what it thinks

fiery turtle
#

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
fiery turtle
# fiery turtle this falls through and returns nothing

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)

pallid lava
#

someone show this to that dude who wanted to write an aml interpreter KEKW

fiery turtle
#

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

fiery turtle
#

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

lethal trench
#

huh

calm latch
#

how did this work in the first place?

lethal trench
#

I guess "it works on nt" is no longer the bar

#

the bar officially doesn't exist anymore

fiery turtle
#

if they fail no one will notice really

#

and nt will still boot

#

i guess they dont look at logs

calm latch
#

but what's the point of them then?

fiery turtle
#

_PLD is physical location of device

#

aka it tells u where the usb port is physically on the computer

lethal trench
#

it works on nt has now become "it boots just fucking ship it please"

fiery turtle
#

_DSM is some device speciifc method that enables a feature

hallow marten
#

Is the _AL0 thing also something like that

pallid lava
#

al0 has to do with thermal zones so no

fiery turtle
#

since uacpi didnt print an error

#

probably because that function produces a bogus path aka clanker probably fucked up in some way

hallow marten
#

@fiery ice can you try the power stuff

fiery ice
#

ye

hallow marten
#

I know why _AL0 fails

fiery ice
hallow marten
#

shit

#

well I'll try fixing the other thing first

fiery turtle
hallow marten
#

reference.handle is null

#

thats also why the power stuff doesnt work likely

fiery turtle
#

ah yeah

hallow marten
#

@fiery turtle

fiery turtle
#

huh true

#

lemme fix rq

hallow marten
#

all should be fixed now

fiery turtle
#

did u have clanker fix uacpi code?

hallow marten
#

yea

#
    case UACPI_OBJECT_POWER_RESOURCE:
        dst->power_resource = src->power_resource;
        break;
#

this is the fix

fiery turtle
#

yeah thats the fix

fiery ice
#

k

#

testing

fiery ice
fiery turtle
#

nice

#

does that also fix _AL0?

hallow marten
#

yes

fiery turtle
#

crazy

hallow marten
#

well, both were fixed

fiery turtle
#

how did it fix al0?

hallow marten
#

it was another thing

fiery ice
hallow marten
fiery turtle
#

0 errors

hallow marten
#

ok now i wont review it and send it directly to lkml

fiery turtle
#

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

fiery turtle
hallow marten
#

yeah that's what I wanted to do

#

I'm gonna clean things up a bit tho

fiery turtle
#

since that just did uacpi side by side with acpica

hallow marten
#

did that work or not

#

ah

fiery turtle
#

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

fiery ice
#

well if you give me an iso for that i'll try

fiery turtle
#

is there a poweroff command that allows that?

full nimbus
#

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 😭

fiery turtle
#

meanwhile im installing window 2025 server to test if they changed any aml stuff

full nimbus
#

My condolences

calm latch
#

My laptop doesn't sleep with Linux trl

#

(I mean it has s2idle)

#

But like it wakes up immediately

fiery turtle
#

wtf

#

maybe it will fix itself with uacpi trl

#

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

full nimbus
#

Common uACPI win
Common ACPICA L

fiery turtle
#

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

full nimbus
#

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

fiery ice
#

that should work correctly

full nimbus
#

Does this one handle sleep/resume stuff?

#

And or power button

fiery ice
#

idk if there is a cmd for that

#

no power button

full nimbus
#

Apparently systemd handles alot of the suspend shit?

#

Though there is a sysfs thing for it

fiery ice
#

there is no systemd in that iso afaik

full nimbus
#

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

fiery ice
#

no patches for the current state

#

@hallow marten have them?

fiery ice
#

cool

#

why not make a fork rn tho

fiery turtle
hallow marten
#

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

fiery turtle
#

which ones and why is that a problem KEKW

hallow marten
#

because I get struct redefinitions

#

all the struct acpi_*

fiery turtle
#

do u really need that header included?

#

that header is just raw acpi spec structs

full nimbus
hallow marten
#

yea

#

and clone uacpi

full nimbus
#

into the master of linux?

#

7.1-rc6?

hallow marten
#

yea

hallow marten
#

for stuff like AE_

fiery turtle
#

yeah so include the acpica header but dont include uacpi/acpi.h

hallow marten
#

some stuff includes it I think

full nimbus
#

like this right?

fiery turtle
hallow marten
full nimbus
#

i got the zip but yeah

hallow marten
#

I need event.h without including acpi.h

#

or you rename everything in acpi.h

fiery turtle
#

hmm, does removing acpi.h from it break anything?

#

idk why it includes that file

hallow marten
#

nope it works

fiery turtle
#

yeah its a bug i think, ill get rid of that include

hallow marten
#

io.h wont work tho

fiery turtle
#

it will work just fine with a forward declaration

hallow marten
#

yeah i just did that

#

you should fix that too

fiery turtle
#

great

#

yep

hallow marten
#

there's some cursed stuff in the code ngl 💀

fiery turtle
#

lol

#

show

full nimbus
#

alr im building it on my desktop

hallow marten
fiery turtle
#

are you going to boot into it on your desktop?

hallow marten
#

this is probably not that bad

full nimbus
#

It has some cursed sleep shit

fiery turtle
full nimbus
#

Sometimes it takes 30 seconds for one monitor to come up

#

And somtimes on a fresh boot my mouse dosnt work

#

💀

fiery turtle
#

does acpica give helpers for that or smth

hallow marten
#

this is in acpi_decode_pld_buffer

fiery turtle
full nimbus
#

It’s like not that annoying

#

But like every few weeks

#

I turn on my pc

#

And I have to reboot it

hallow marten
#

also what's the resource thing infy

#

why is it so complex

fiery turtle
fiery turtle
#

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

hallow marten
#

the code isnt actually that bad

#

the resource code is insane

#

but I think that's ACPI's fault

fiery turtle
#

yeah thats true

full nimbus
#

this should work 🤞

#

im not making a new initramfs

fiery turtle
#

nice

hallow marten
full nimbus
#

🥀

#

i copied my main kernels config

#

i stg if nvme or ext4 is a moduke

fiery turtle
#

the header changes unfortunately break backwards compat i.e. may accidentally break compilation for some people so its time for uacpi 6.0 soon KEKW

#

i have a few other things befor then tho

#

including PLD helpers now ig

full nimbus
fiery ice
#

lol

#

@hallow marten

full nimbus
#

also nvme is a module

#

so im gonna have to make a custom config

hallow marten
full nimbus
fiery ice
hallow marten
#

no

#

did you add the patch

full nimbus
#

yes

#

and what folder does uacpi need to be in

hallow marten
#

root is fine

#

can you check in drivers/acpi/uacpi

#

shim_event.c should be a thing

full nimbus
#

i alr make cleaned because im making a more light config that has nvme built in

hallow marten
#

where u have acpi_install_gpe_handler

full nimbus
#

since i cant make a custom initramfs with modules

hallow marten
#

do you just want me to tarball my linux source

fiery turtle
#

@hallow marten its probably because clanker didnt add EXPORT_SYMBOL_GPL to the implementations

#

so modpost doesnt see them

full nimbus
#

make a patch that includes uacpi sources maybe PSP1G_pspTrollar

hallow marten
#

fuck

#

can you try it evalyn

#

or i can ask the clanka

fiery turtle
#

or i guess just EXPORT_SYMBOL since its not GPL

full nimbus
#

ask the clanker

hallow marten
#

i have decided

#

it is now gpl

fiery turtle
#

gg

hallow marten
full nimbus
#

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

fiery turtle
#

The pld stuff is harmless

#

Its stuck for some other reason

#

Im assuming because of the warnings below

full nimbus
#

this is where it died and i had to force shit it

fiery turtle
#

Huh, why wasn't that in the logs on the screen?

full nimbus
#

it was showing the cachyOS splash screen

#

and it was stuck for a splid 3 minutes

fiery turtle
#

Ah

#

Can you send your aml dump as well btw, ill take a look at that pld stuff

full nimbus
#

how do i dump AML?

#

and let me send the full boot logs

fiery turtle
#

acpidump > dunp.txt

full nimbus
fiery turtle
#

Why does it keep spamming that method KEKW

#

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

full nimbus
fiery turtle
#

acpi or acpica-tools usually

#

Or acpica

#

Depends on your package manager

full nimbus
#

feel free to add this to the repo woth dumps aswell

fiery turtle
#

Thanks

full nimbus
#

this is my board

#

Or should I make a PR with it or whatever else later

#

For ze GitHub points PSP1G_pspTrollar

fiery turtle
full nimbus
#

I got the one that I let run the longest

#

leme get the otherrr

fiery turtle
#

Yeah but that one looked like it made it to Userspace just fine?

full nimbus
full nimbus
#

Unrelated to ACPI

#

I couldn't open any other virtual terminals

#

They just were blank

fiery turtle
#

Ohhh wait

#

Did you just post only the stuff with acpi prefix?

full nimbus
#

Yes

fiery turtle
#

Now I get it

#

I thought that was the last thing logged

full nimbus
#

Lol

fiery turtle
#

Its probably because you changed the config and it didnt like that somehow

full nimbus
#

@hallow marten can you make an ISO that has a way to put the thing to sleep?

fiery turtle
#

Does poweroff really not have that option

full nimbus
#

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?

hallow marten
#

what does halt do

full nimbus
#

Idfk

fiery turtle
#

Maybe suspend involves userspace support as well idfk

#

We need a full distro trl

full nimbus
fiery turtle
#

Ye

hollow elm
#

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

full nimbus
#

@fiery ice can you test that

#

If that works on do it

#

Before I fall asleep

fiery ice
#

Not at my pc rn

full nimbus
#

Test it on the uACPI ISO

fiery ice
#

yes

fiery ice
full nimbus
#

Can it wake up?

fiery ice
#

i'm trying

#

it does not want to

full nimbus
#

That's probably not good

#

@fiery turtle

#

We may need a distro with systemd

#

That can have better logging for this shit

hallow marten
#

someone should rewrite acpica and call it acpicb

full nimbus
hallow marten
#

maybe

#

someone should still rewrite acpica and call it acpicb

full nimbus
lethal trench
#

acpica-rs when?

flat badge
#

Rewrite uacpi in rust halfmemeleft

fiery turtle
#

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

full nimbus
#

Maybe it could have been that?

fiery turtle
#

Yeah perhaps

#

More testing and clanker conversations required

full nimbus
#

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?

fiery turtle
#

Yep

rustic compass
#

@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?

fiery turtle
#

same api, why do u need it tho?

rustic compass
#

does the facs doesnt contain anything of interest for the kernel?

fiery turtle
#

not really, and its managed by uacpi anyway

rustic compass
#

then i wont add it now, maybe later if someone wants to be able to dump the tables via uacpi-rs

fiery turtle
#

yeah i mean

#

struct definitions can be made by the kernel itself

rustic compass
#

i implement them in uacpi-rs as getter

fiery turtle
#

I see

rustic compass
#

so that the user doesnt have to implement a single table in their kernel

flat badge
#

/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);
meme

fiery turtle
#

Why did you post this?

#

Doesnt sound like a useful warning

flat badge
#

this is a warning against accidental sign extension

#

flagged by clang tidy

fiery turtle
#

yeah but what am i supposed to do with it

#

it's intended since it's a formatting function

flat badge
#

clang-tidy wants you to do (unsigned char)(signed char)...

fiery turtle
#

is that better?

flat badge
#

it doesn't sign extend to 0xffffffffffffffxx

fiery turtle
#
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

flat badge
#

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

fiery turtle
#

how do I run this check?

#

it's funny that it got triggered by signed char but not signed short for example

flat badge
#

it's bugprone-signed-char-misuse

fiery turtle
#

ill take a look, why not fix it if its cheap ig

fiery turtle
#

i found a few important memory leaks/potential crashes on OOM as well

#

might roll 6.0.0 very soon

fiery ice
#

lol, the quickest release ever

fiery turtle
#

public header changes 😭

fiery turtle
#

Also updated the wiki a bit

#

if someone could write an example of how to use the barebones/early table stuff thatd be nice

steel inlet
fiery turtle
#

thats not how semver semvers

steel inlet
#

tbh i have no idea what new features there are

fiery turtle
#

i wish changelog existed that i posted and that is available on github releases KEKW

steel inlet
#

lmao

fiery turtle
#

idk but the page has 30k views

calm latch
#

I mean my kernel uses it...

fiery turtle
#

oh u mean the early tables mode?

#

Probably almost everyone

pallid lava
#

i don't trl

calm latch
#

Or the barebones mode

fiery turtle
#

u have scheduling/allocators/pci etc up before acpi init?

#

crazy work

pallid lava
#

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

fiery turtle
#

bruh ok

#

u shouldve said that

pallid lava
#

then after scheduling is done i initialize acpi and then pci

fiery turtle
#

u just reimplemented the early tables mode yourself lol

pallid lava
#

yeah basically

calm latch
#

I set up uACPI barebones mode after allocation and before scheduling

#

Though I guess I can swap those

fiery turtle
#

i set it up after the boot allocator & early MMIO mapping helpers but thats pretty much it, nothing else is available at that point

calm latch
#

Since my kernel bootstraps itself by finding the largest memory region, and bump allocating from it, so uACPI should work

fiery turtle
#

double cv

pallid lava
#

:troll and:

#

shit

calm latch
pallid lava
fiery turtle
#

yeah if im going to support numa id have to redo the order a bit

#

early mmio would have to be first

calm latch
#

I have no early mmio mappings trl

pallid lava
#

imagine having early stuff

fiery turtle
#

how do u map acpi stuff?

pallid lava
#

lmao

calm latch
#

But like not through a special mechanism

#

I set up vmem before pfndb && palloc

fiery turtle
#

so u have an early mapping thing?

calm latch
fiery turtle
#

yeah but how do u allocate the chunk of virtual memory where to map it

calm latch
#

I don't use HHDM

pallid lava
#

based tbh

fiery turtle
#

so like u initialize all these allocators before acpi right

calm latch
#

Yes

fiery turtle
#

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

calm latch
#

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)

fiery turtle
#

I see

calm latch
#

Idr the order of the first two

fiery turtle
#

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

calm latch
#

Like my kernel allocation functions just bump from the temporary region, then it gets reserved in my pma

fiery turtle
#

the pain for supporting multiboot

calm latch
#

So vmem's slab just allocates from that and I map stuff through the normal mechanism

calm latch
#

The rest of the code is the same

#

I guess mapping hhdm would be painful

#

But I don't do it trl

fiery turtle
#

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

calm latch
#

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

fiery turtle
#

did u check if linux uses it btw

calm latch
#

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

fiery turtle
#

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

calm latch
#

Probably because of kaslr?

fiery turtle
#

on other arches ioremap is really complex

pallid lava
#

holy epic

fiery turtle
#

on other arches its vmalloc + remap

calm latch
fiery turtle
#

how lol

#

theres no other way to implement it

calm latch
fiery turtle
calm latch
#

Like these are 2 functions in my kernel

#

Also, what's ioremap even used for?

fiery turtle
#

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

calm latch
#

I mean nobody's stopping you from setting up a second hhdm........

#

Except no

fiery turtle
#

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

fiery turtle
#

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

calm latch
#

Bruh

#

I don't have checks for that for userspace

#

I mean my kernel is safe because microkernel

fiery turtle
#

well u should if u allow mmap to specify cache attributes

calm latch
#

But it has so many edge cases

#

Or not

calm latch
#

I'll check it out later (when I get an actual MCE because of that trl)

fiery turtle
#

if it detects that RAM is remapped with a different caching attribute it splits the large HHDM pages and also remaps them with that

calm latch
#

Yeah

#

Obnoxious

#

Can't I just reject userspace from doing it?

fiery turtle
#

From doing what

pallid lava
#

yeah, i was going to ask something similar

calm latch
#

From mapping ram with other permissions

pallid lava
#

how common is it to map the same physical addresses with different caching attributes?

fiery turtle
#

im gonna do that also

calm latch
#

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

fiery turtle
calm latch
#

But like in reality if somebody tries to map that it's a bug

fiery turtle
#

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

calm latch
#

Also, this doesn't apply to different ASIDs/address spaces, right?

fiery turtle
#

so maybe thats fine

fiery turtle
#

so it doesnt matter which asid it came from

calm latch
#

Because then some process can trash other's mappings

fiery turtle
#

if it tries to remap ram as UC?

calm latch
#

Yeah

fiery turtle
#

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

calm latch
#

Like map /dev/memory or whatever as UC

fiery turtle
#

yeah sure

calm latch
#

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?

fiery turtle
#

the framebuffer is usually mapped at an offset in a GPU BAR

#

so its not physical memory

calm latch
#

Or how does the firmare communicate the framebuffer's location?

pallid lava
#

in the gpu itself you can change the offset in the vram where the framebuffer is located

fiery turtle
#

firmware or software

calm latch
fiery turtle
#

nope

#

its not in the memory map

calm latch
#

Like where do limine/hyper get framebuffer memory region information from?

fiery turtle
#

well igpu stolen memory might be in the memory map but thats another unrelated story

fiery turtle
pallid lava
#

nah, that sounds like broken behavior

#

nvm,

gentle peak
#

which is implemented by the GPU's vbios

pallid lava
#

aa long as it's not marked as usable

calm latch
#

Like what I don't get it how do I track the framebuffer

fiery turtle
#

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

calm latch
#

For UC/WT

fiery turtle
#

wdym by track

calm latch
#

Like if you connect a display, you get a second framebuffer

fiery turtle
#

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

calm latch
#

But I'm a microkernel

fiery turtle
#

you can have device mappings requests go through a server

calm latch
#

How does Managarm deal with it?

fiery turtle
#

that validates the caching attributes etc

#

and then actually requests the kernel to map it

calm latch
#

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

fiery turtle
#

to be clear there are MTRRs right, so the double remap is only a problem if you override the MTRR settings

calm latch
#

(I wanted to do it that way anyway)

fiery turtle
#

which happens with WC etc

calm latch
#

Yeah, the framebuffer

fiery turtle
#

yeah

#

or if u remap ram as UC

#

which ioremap rejects by default btw

calm latch
fiery turtle
#

yeah

calm latch
#

Though I'd have to reject UC as well

fiery turtle
#

well u have to have that for non-x86 platforms but thats not a problem there i suppose

calm latch
#

Which you won't get anyway unless you're the ACPI server, which deduces the memory from memory map anyway

fiery turtle
#

on non x86 u have tons of cases for mapping ram as UC

calm latch
#

In my os

fiery turtle
#

the most common is any device directed memory

#

like queues, etc

calm latch
#

I think I handle that already

fiery turtle
#

for non coherent pci basically

calm latch
#

I allow userspace to request DMA memory

#

Actually, I don't

#

I mean I can add it easily

fiery turtle
#

for aarch64 yeah

calm latch
#

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

fiery turtle
#

iirc linux has different allocators for this

#

for short lived and long lived

calm latch
#

I'll just track it though the memory objects

#

Is this also UB on arm?

#

Like mapping the same memory with different caching stuff

fiery turtle
#

i dont think so because arm doesnt have any code for bookkeeping of that sort

calm latch
#

Cool

#

So like all of this in not a problem then trl

#

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 trl)

fiery turtle
# fiery turtle iirc linux has different allocators for this

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)

fiery turtle
#

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

fiery turtle
#

cc @ korona

full nimbus
#

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

fiery turtle
#

Sure sounds fun

#

Im not sure how good its acpi is tho if its i686

full nimbus
hallow marten
fiery turtle
#

well ideally we debug the suspend thing

full nimbus
#

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

hallow marten
fiery turtle
#

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

gentle peak
#

where's the iso? I can test it on some of my systems, they're pretty straight forward acpi wise

hollow elm
#

what kernel version is the patch for? :^)

fiery turtle
#

wow nice

gentle peak
#

i'll try on my desktop as well but i need to recompile the kernel for that (need several modules incl. amdgpu)

kindred beacon
#

wait did I miss linux uACPI patches???

full nimbus
fiery turtle
kindred beacon
#

holy shit, uACPI everywhere meme

full nimbus
#

@hallow marten it would be nice if you could get your patches to run for kernel v6.18.35

gentle peak
kindred beacon
#

✅ Windows
✅ ReactOS
✅ Haiku
✅ Linux
✅ Hobby OSes
so only *BSDs remain?

full nimbus
#

i wonder how generic the ACPICA shim it actually

#

for the BSDs

kindred beacon
#

apple silicon doesn't have ACPI tho?

fiery turtle
#

well legacy macos

kindred beacon
#

eh who cares

#

they used ACPICA anyway

steel inlet
#

what if i do a hackintosh

vocal geyser
#

uacpi rules world

fiery turtle
#

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

fiery turtle
#

i dont think there have been many changes to any acpica apis between 6 and 7

#

so it should work

hallow marten
#

Yeah

pallid lava
fiery turtle
#

close enough trl

hollow elm
#

er, legacy hw i mean

fiery ice
gentle peak
fiery turtle
#

do u have a com port on it?

gentle peak
#

nope

#

and even if I did I wouldn't have the equipment to use it

fiery turtle
#

maybe serial over usb could work?

gentle peak
#

what does that entail

fiery turtle
#

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

gentle peak
#

well this is after the drivers are all shut down so I doubt anything relying on the USB controller would work

fiery turtle
#

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

gentle peak
#

but like I said no equipment to use it

fiery ice
#

and usb to serial should work there

fiery turtle
#

yeah youd have to buy a special cable for it

fiery ice
#

or even a cheap arduino / rpi

gentle peak
fiery turtle
#

yeah that sounds pretty useful for debugging in general

gentle peak
#

no idea how to even find such a thing though

#

like what do I google

sharp lichen
fiery ice
#

not really