#OBOS (not vibecoded)
1 messages ยท Page 28 of 1
thx
how do I get it to work with the acpidump output
like if I did acpidump > acpi.txt
how do I decompile acpi.txt
acpidump > dump.txt && acpixtract -a dump.txt && iasl *.dat && code dsdt.dsl
thanks
wait my laptop actually has "sane" aml for wake from suspend
well as sane as it gets
actually let me make sure
nvm
it delulu
it tells me to put devices into D2 for suspend if I want them to wake me
D2 doesn't exist
lmao
same thing on my dev pc
perhaps ur misunderstanding what it does
have u looked at how linux handles these values
set _S3D to 2 to tell the kernel that this device can only be at a deepest state of 2 to wake the kernel up
no D2 state
linux was my reference
iirc
how does it react in this case
i mean linux
while setting the wake devices
let me see
u can add printfs there like mishakov did to figure out where the power button press comes from
to see which state it puts the devices in and why
I'm sorry but I don't hate myself
(reading linux code has traumatized me)
it takes time
time is something I don't have much of rn
anyway, what obos does in this case is not put it in any D state
Which does it have
So then it doesnt matter what it says in _S right
yeah
So what happens on suspend
I think because _S3D is 0x2, which means the deepest state the device can be to wake us is D2, it's fine if I keep it in D0
it doesn't, it hangs while registering wake gpes
before suspend
Did u figure out where
*configuring wake devices
what I'm tryna do
Yeah
just an acpi spec skill issue
my obos clone on my laptop
is 170 commits behind
and one commit ahead
on commitf989a176ebaaf320ab3e81929508df331922ca83
on the repo
of master
also why is cmake+make so slow compared to cmake+ninja
ninja
i think its because cmake's make target is really bad
but also make is just slower
don't use make
you shite in bed?
typo
I meant to put shit after get out of bed
wake up
get out of bed
shit
do osdev
sleep
repeat
/home/oberrow/Code/obos/src/oboskrnl/power/device.c:244:12: warning: 'useDSW' may be used uninitialized [-Wmaybe-uninitialized]
244 | if (useDSW)
| ^
/home/oberrow/Code/obos/src/oboskrnl/power/device.c:198:10: note: 'useDSW' was declared here
198 | bool useDSW = false;```
we just love this warning
me after turning on all warnings
(that warning is not only a false-positive, a stupid one)
((the line it shows me shows the variable being initialized))
soon I port obos to clang
u confoosing
you do it first
no thanks
i might give it a go
I don't want my compiler to page fault when I throw at it a hello world program
yes nyauxcompiler and it gives u even more UB!!!!
๐ญ

itll do better and somehow kill ur entire kernel
and brick ur system

#include <cstdio>
#include <cstring>
#include <type_traits>
int main() {
}
struct A {
static void (*&_)(int);
A(float b) { int i; _(*(int*)memcpy(&i, &b, 4)); }
};
std::remove_cvref_t<decltype(A::_)> **O, *P, Q;
decltype(A::_) A::_ = (O = &P, P = &Q, **O);
template<float B, int = 0>
struct _ {
static const inline A a = (Q = [](int _) { putchar(_); }, A(B));
};
template struct _<0X1.2p-143f>;
template struct _<0X1.94p-143f>;
template struct _<0X1.bp-143f>;
template struct _<0X1.bp-143f,1>;
template struct _<0X1.bcp-143f>;
template struct _<0X1.6p-144f>;
template struct _<0X1p-144f>;
template struct _<0X1.5cp-143f>;
template struct _<0X1.bcp-143f,1>;
template struct _<0X1.c8p-143f>;
template struct _<0X1.bp-143f,2>;
template struct _<0X1.9p-143f>;
template struct _<0X1.08p-144f>;```
look at this hello world
I found
;compile ```c++
#include <cstdio>
#include <cstring>
#include <type_traits>
int main() {
}
struct A {
static void (&_)(int);
A(float b) { int i; _((int*)memcpy(&i, &b, 4)); }
};
std::remove_cvref_t<decltype(A::)> **O, *P, Q;
decltype(A::) A::_ = (O = &P, P = &Q, **O);
template<float B, int = 0>
struct _ {
static const inline A a = (Q = [](int ) { putchar(); }, A(B));
};
template struct _<0X1.2p-143f>;
template struct _<0X1.94p-143f>;
template struct _<0X1.bp-143f>;
template struct _<0X1.bp-143f,1>;
template struct _<0X1.bcp-143f>;
template struct _<0X1.6p-144f>;
template struct _<0X1p-144f>;
template struct _<0X1.5cp-143f>;
template struct _<0X1.bcp-143f,1>;
template struct _<0X1.c8p-143f>;
template struct _<0X1.bp-143f,2>;
template struct _<0X1.9p-143f>;
template struct _<0X1.08p-144f>;```
<source>:12:6: error: 'remove_cvref_t' in namespace 'std' does not name a template type
12 | std::remove_cvref_t<decltype(A::_)> **O, *P, Q;
| ^~~~~~~~~~~~~~
<source>:12:1: note: 'std::remove_cvref_t' is only available from C++20 onwards
12 | std::remove_cvref_t<decltype(A::_)> **O, *P, Q;
| ^~~
<source>:13:24: error: 'O' was not declared in this scope
13 | decltype(A::_) A::_ = (O = &P, P = &Q, **O);
| ^
<source>:13:29: error: 'P' was not declared in this scope
13 | decltype(A::_) A::_ = (O = &P, P = &Q, **O);
| ^
<source>:13:32: error: 'P' was not declared in this scope
13 | decltype(A::_) A::_ = (O = &P, P = &Q, **O);
| ^
<source>:13:37: error: 'Q' was not declared in this scope
13 | decltype(A::_) A::_ = (O = &P, P = &Q, **O);
| ^
<source>:13:42: error: 'O' was not declared in this scope
13 | decltype(
wait momentarily
;compile -std=c++20 ```c++
#include <cstdio>
#include <cstring>
#include <type_traits>
int main() {
}
struct A {
static void (&_)(int);
A(float b) { int i; _((int*)memcpy(&i, &b, 4)); }
};
std::remove_cvref_t<decltype(A::)> **O, *P, Q;
decltype(A::) A::_ = (O = &P, P = &Q, **O);
template<float B, int = 0>
struct _ {
static const inline A a = (Q = [](int ) { putchar(); }, A(B));
};
template struct _<0X1.2p-143f>;
template struct _<0X1.94p-143f>;
template struct _<0X1.bp-143f>;
template struct _<0X1.bp-143f,1>;
template struct _<0X1.bcp-143f>;
template struct _<0X1.6p-144f>;
template struct _<0X1p-144f>;
template struct _<0X1.5cp-143f>;
template struct _<0X1.bcp-143f,1>;
template struct _<0X1.c8p-143f>;
template struct _<0X1.bp-143f,2>;
template struct _<0X1.9p-143f>;
template struct _<0X1.08p-144f>;```
Hello, World!
@thick jolt
its not even idiomatic c++ and contains reserved identifiers + shadowing lol
more unreadable then complex rust
I added a command line option to obos to set the log level
at runtime
and to do so, I also made a way for the kernel command line to be parsed long before having an allocator
wtf how is that not already the case
omega cringe
I mean theorerically it's not too much work
what's not working
but I've never tried
-fsanitize=kernel-address won't work if I use a generic x86_64-elf target
you shouldn't use that target anyway, its garbage
x86_64-linux??
yes
k
in fact
I'm going to port obos to clang rn
and also I should improve how I get options in cmake
you might also want to make it use out-of-line instrumentation for asan on clang if you don't support inline instrumentation
as in making it always generate calls to the asan functions instead of consulting the shadow map itself like it does by default for functions that have less than some amount of accesses (idk what the default amount is but its not zero like in gcc)
bruh
cmake doesn't support string options using the option command
so I need to do it manually
you could be assigning an uninitialized variable to useDSW and using it afterwards
yeah you just do something like set(CONFIG_MAX_CPUS 24 CACHE STRING "some desc")
wake up
shit
eat breakfast
get out of bed
wow
ur shitting our bed
i shit in my sleep
๐
we are not the same
Do you not sleep in bed?
is this the target triple? x86_64-linux-elf
or do I remove the -elf
or is it x86_64-unknown-linux-elf
I don't really know, I use x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu
but very likely those work too
maybe -gnu instead of -elf is better
all goes well until linking oboskrnl
/usr/bin/ld: src/oboskrnl/CMakeFiles/oboskrnl.dir/arch/x86_64/entry.asm.obj: relocation R_X86_64_32S against symbol `__stack_chk_guard' can not be used when making a PIE object; recompile with -fPIE```
the stack check is probably also using fs:[0x40] for the cookie with -gnu
as of now, I use this triplet
the fix for that should be easy tho, just make the asm position independent
src/oboskrnl/CMakeFiles/oboskrnl.dir/arch/x86_64/smp.c.obj: in function `Arch_SMPStartup':
/home/oberrow/Code/obos/src/oboskrnl/arch/x86_64/smp.c:(.text+0x42f): failed to convert GOTPCREL relocation against 'Arch_SMPTrampolineStart'; relink with --no-relax
/home/oberrow/Code/obos/src/oboskrnl/arch/x86_64/smp.c:(.text+0x435): failed to convert GOTPCREL relocation against 'Arch_SMPTrampolineRSP'; relink with --no-relax
/home/oberrow/Code/obos/src/oboskrnl/arch/x86_64/smp.c:(.text+0x44b): failed to convert GOTPCREL relocation against 'Arch_SMPTrampolineCPULocalPtr'; relink with --no-relax```
now I get those
so I guess I link with --no-relax?
I got it to link
but it triple faults
that sounds like the wrong solution
also i've never seen that error before lol

I switched to lld
instead of binutils
and I now get ld.lld: error: unknown argument '-pic'
for linking drivers
but I do think the kernel linked
it wants to use gs:0x28 to get the stack guard
which doesn't work, obviously
causing a triple fault
debug info?
you can use -mstack-protector-guard-symbol=__stack_chk_guard
thanks
it also works on gcc so you don't have to guard it
is there a way to disable gs/fs relative accesses in its entirety?
because the compiler emits many of those
even with that
no, for something else
for what specifically
it gets the address of __stack_chk_guard
then makes a gs-relative access
with it's address
gcc would never
oh right ๐ I missed the address space part of the llvm code
I guess this is one of the "bad" things about the linux target, you'd have to use either fs or gs relative stack protector cookie
as a poor workaround ig you could setup the gs to point to some dumb static struct with the cookie in the entry asm until you setup a proper per cpu/thread struct
or I could not support stack protector on clang
or that
so how do I set the offset of the variable from gs
if that makes sense
unless the value is in the symbol itself
you can use that symbol thing somehow or just specify the offset manually with -mstack-protector-guard-offset=<some number>
ok
and the reg with -mstack-protector-guard-reg=gs though if you use kernel code model its the default from the looks of it
thx
what is it doing now
wait whats happening why is obos broken
I am porting to clang
ah
this happens both with and without optimizations
infy we hate clang am i right or am i right
clang is great
you're wrong
no ur wrong
hold on I need to say something quickly
kk
FUCK BASHAR AL ASSAD
what
๐ญ
oh yeah
the guy who ruled over syria
yea hes mega cringe
i am partially syrian so
yk
I am syrian
woah
millions dead for no reason as a result of him
exactly
@ infy you're in moscow, find him and torture him for me
kthx
clang is peak
cringe ass gnu toolchain ๐คข
gnu tastes bad
i have already won
gcc gets an automatic L for using autoconf
anything that's not autotools >> autotools
found the portal player
No
aperture science
Your code is just full of UB
his code is UB

I switched from GCC to clang and my stuff worked without changing anything
i didnt try nyaux on clang
Like 3 months ago
mostly because im lazy
you'll have a hard time finding something that's not UB 
but also
wdym lazy just replace gcc with clang
high chance that it'll just work with your kernel
fine ill try it
My kernel ran on 12 PCs with no issues, and I'm using clang and lld
based
llvm > gnu
Well it was triple faulting on my laptop the last time I tried
HERE WE GO
try it again
Well maybe I counted wrong
--target x86-64-elf
where do i put that
I have 7 PCs, and people from this server were also trying it and it was working
yea for ur kernel
nyaux runs perfectly now

before "clang" of course
Can you turn it off with a power button?
bros trying to flex this
๐ญ
i mean i could implment that soon
i js am sick todayh
The only user input I have atm 

Who needs keyboard
okay hold on
how much of the kernel api is unimplemented
anything pci is unimplemented
i dont have pci yet
ive NEVER done pci before
Also I'm the only hobby os which implements AMD GPIO driver
ive always just went straight to userspace and mlibc
with my rewrites
im interestined in it tho
and no scheduling related functions
that's like the most boring part of osdev

I'm using my own libc 
I wonder why
lmfao
lmao 
yes lmao
oh thanks mint
how's that going for you
It's enough for libc++
yeah properly implement ubsan or disable it
i did
also use lld instead of ld
i swear i did
you didn't
how
no you didn't
oh
there are ton of ubsan functions
just disable ubsan
why did rayan put that there
i have ubsan all implmeneted
dont believe me?
read the soruce
Though that's partially why I don't have a shell yet 
because you saw someone had it and you copied it
no
i added that myself
actually
why would you?
i dont remember why tho
doesn't make sense
ubsan works on clang right???
yes
okay
it came from clang
no only Richard stallman knows the magic of UB
skill issue
implement it
fine
you and your "fine" smh
i mean it nicely :)
fine
yk?
fine :)
how does that sound
it'd be easier to copy code if you want to half ass something
I copy+pasted my ubsan implementation
im not gonna half ass this
I have never heard the word "fine" used with a positive meaning
im sorry u took it that why
way*
im future i will say that nicely :)
fine is usually used when someone tells you to do something that you don't want to do, but do anyway
room mate x to y: do the dishes
y: fine
ig but
i mean it positively
is the like a firefox extention that automatically spell checks ur words and replaces them with the spell check
i did not say that
analogy
that is not positively
okay well
listen me and you @weak kestrel are besties okeyyyy :)
depends on the default meaning of the word
yes besties
it's around -10 degrees outside, should I keep my window open
(what could possibly go wrong?)
open it 
climb out of your window and code outside like a real man
it is open, I'm asking should I keep it open
are you cold?
ilobilo force bebestfriended
keep it open then
I don't feel like dropping many meters, so no
check dms lol

just say no
gravity can't legally affect you without your consent
-fuse-ld=lld to clang
np
obos has been hijacked
this talk about ubsan is making me want to go improve my ubsan implementation
it was directly plagarised from sortix, so it only has the features sortix has
?
it's np
okay
I just copied function names from Linux
they print their names and halt the kernel
I just copy pasted the entire file
obsan when
not much more is necessary tbh
just type of error and line:column
I had to implement a few more functions when I had been using it
like what
Better solution: just don't have UB 
I found my bug
lld doesn't emit a symbol hash table
like GNU binutils does
but I use it assuming there is one
causing me to get a bogus pointer
page faulting
rather that OR I find the relocations before the hash table
it has a DT_GNU_HASH
so guess I'm implementing GNU_HASH support now
openbsd is the most freedom bsd right?
that turned out to not be possible
isn't there some flag to make it emit the sysv hash table?
I was able to get it past the driver loading stage
but it mysteriously page faults in the vfs
it page faults in the initrd driver
size_t dirnamelen = uacpi_strnlen(dir_filename, 100);```
const char* dir_filename = (const char*)&dir->filename;```
causing Page fault at 0x3b36 in kernel-mode while to execute page at 0x3b36, which is unpresent. Error code: 16
wait wtf

ok found the bug
lld is putting DT_JMPREL before specifying it's size
fixed the bug
except now wake from suspend triple faults
fixed that
now it gets to:
Kernel Panic on CPU 0 in thread 10, owned by process 2. Reason: OBOS_PANIC_STACK_CORRUPTION. Information on the crash is below:
Stack corruption detected at IP=0xffffffff80029a18 (overwrite of stack canary).```
frick
thread 10 is a user thread
a user thread has wreaked havoc in the kernel

it is specifically the one that syscalls to suspend
and binutils puts it after
somehow causing this all to break
whoops
fixed
yeah there are some bugs with wake from suspend, even on GCC
but other than that, obos now supports clang
I really should add CI tests for obos
rn I feel like I'm getting many config options
and I might accidentally break something
and not notice it until someone tries to do that
option (OBOS_UP "Make a Uniprocessor-Build of obos.")
option (OBOS_ENABLE_UBSAN "Enables UBSan.")
option (OBOS_ENABLE_KASAN "Enables KAsan.")
option (OBOS_ENABLE_FANALYZER "(Developers only) Enables the compiler's static analyzer")
option (OBOS_ENABLE_WERROR "(Developers only) Enables the -Werror option")
option (OBOS_USE_CLANG "Use clang instead of GCC to build.")```
with fanalyzer and werror being mutually exclusive
that's like 32 different possible combinations of options that I might want to test
in both release and debug mode
over two architectures
i love clang
well see which kernel api
mutex doesn't want to talk
sounds like an obos bug?
no
because I added logs around that specific mutex
you never release it
it's from uacpi
which mutex even
I only have a pointer to it atm
I will do a stack trace
to find out where you create it
make sure your get_thread_id() is not bogus
but it's possible for my kernel to tell me
uacpi has its own recursive locks that operate on normal acquire_mutex
well my get thread id is not bogus
return Core_GetCurrentThread()->tid;
yes
what if task gets switched after this call but before we read tid
that's a bug I am planning to fix later in obos
anyway it only reproduces in obos so i doubt its a uacpi bug
but dump stacks and lets see
wait why would you do this
me?
yeah
to get the current TID?
yeah
saves a pointer deref
the thread should still stay the same, it wouldn't make sense for the thread pointer to change even if its switched away from for a moment
or the tid for that matter
The task could get moved to a different core which would return the tid of some other thread that now runs on that core no?
depends on where it gets switched
if it gets switched in get current thread's implementation
then yes
before dereferencing the cpu local pointer
no? unless you mean that it would get switched inside the get current thread function
yeah it's like that
yeah you should prevent that by either preventing the switch inside there or just doing an atomic gs-relative load (or storing the thread in gs instead of cpu)
#1236769772805554206 message
Frame 0: /home/oberrow/Code/obos/dependencies/uACPI/source/types.c:189 (inlined)
Frame 1: /home/oberrow/Code/obos/dependencies/uACPI/source/types.c:199
Frame 2: /home/oberrow/Code/obos/dependencies/uACPI/source/types.c:339
Frame 3: /home/oberrow/Code/obos/dependencies/uACPI/source/namespace.c:102 (inlined)
Frame 4: /home/oberrow/Code/obos/dependencies/uACPI/source/namespace.c:172
Frame 5: /home/oberrow/Code/obos/dependencies/uACPI/source/uacpi.c:318
Frame 6: /home/oberrow/Code/obos/src/oboskrnl/power/init.c:58
Frame 7: /home/oberrow/Code/obos/src/oboskrnl/arch/x86_64/entry.c:573
END
@real pecan I think it's a problem with my specific blob
this is the global lock
I thought that was a spinlock though?
its a mutex, a spinlock, an event, and a field in FACS
and uacpi only modifies it when firmware asks it right?
sure
its acquired in basically one place
access_field_unit
its definitely released there as well
or wait
i think i might be brain damaged
--- a/source/io.c
+++ b/source/io.c
@@ -209,18 +209,22 @@ static uacpi_status access_field_unit(
switch (op) {
case UACPI_REGION_OP_READ:
- return uacpi_read_field_unit(
+ ret = uacpi_read_field_unit(
field->data, in_out, field->access_width_bytes
);
+ break;
case UACPI_REGION_OP_WRITE:
- return uacpi_write_field_unit(
+ ret = uacpi_write_field_unit(
field->data, in_out, field->access_width_bytes
);
+ break;
default:
ret = UACPI_STATUS_INVALID_ARGUMENT;
- goto out;
+ break;
}
+ goto out;
+
like this is definitely a bug but
how did it not trigger before
on that same hw
anyway try this
yup
how to apply
manually
k
IndexField isnt used that much so makes sense it went undetected but im not sure why it didnt break before on your stuff
when was the last time u tested shtudown on this pc
months ago
ah
โฏ grep IndexField *.dsl
dsdt.dsl: IndexField (BRAI, BRAD, ByteAcc, NoLock, Preserve)
โฏ grep IndexField *.dsl
dsdt.dsl: IndexField (INDX, DATA, ByteAcc, NoLock, Preserve)
From 2 dumps that i have from you there isn't a locked indexfield
you're missing my laptop's dump
you must complete your collection of my windows license keys your collection of aml blobs
ah
how were u able to track down the place where the mutex gets created?
I first printed each mutex acquire/release along with the address
until it deadlocked
then I narrowed logging to just that address
is it guaranteed that the address is the same each time lol?
since I have no kaslr or the like, the address of the mutex was the same
pretty much
races and stuff?
on the same machine yes
with one thread, not much stuff race
or is uacpi init before smp
let me rephrase that
uacpi init is after smp, but there is only one thread, which is the one it runs on
the idle threads don't allocate memory
there's my laptop's dump
obos dies because of uacpi bug what a day
dsdt.dsl: IndexField (BKDX, BKDA, ByteAcc, Lock, Preserve) indeed
An invalid DSDT address if facp->x_dsdt is non-zero and the fadt table's length is less than 148 Offending lines: uACPI/source/tables.c Lines 135 to 139 in bf0bbff if (table->signature.id...
lmao
almost one full year since I blamed it on uacpi and was right 
yeah iirc it was just there
it was untested at the time of writing that report, according to you
#560042023638269955 message
i think i know why it didnt reproduce
this lock is recursive obviosuly since its an aml mutex
if u keep running it from the same thread it will always succeed in acquiring
if u shutdown from the same thread as well it will succeed
yeah but I do remember in my third rewrite having a shutdown command in my dumb shell that worked
and the shell was in a user thread
i dont think i even supported the global lock back then
Field (CBK1, ByteAcc, Lock, Preserve)
{
BKDX, 8,
BKDA, 8
}
The fields it references are already locked anyway
it triple faulted
yes
F
nice
ok it doesn't hang in the smp trampoline
so later?
yup
or u mean doesnt triple fault there
triple fault yeah
it triple faults somewhere during void on_wake(cpu_local* info)
or after
or could be e.g. igpu resetting the cpu because the gpu page table is zeroed-out and you're writing via it by using the BAR

but u should trace it down
basically BAR2 (I think) on igpus is the aperture aka a view into gpu virtual memory, so offset 0 is gpu virtual address 0, and usually the framebuffer u get is just that BAR address, with the actual physical memory used for scanout mapped to GPU virtual 0
and writes have to go through it and not to that physical memory directly because it caches stuff internally, so u would only see partial updates otherwise

but its just a guess
well now I know it hangs somewhere here:
irql oldIrql = Core_RaiseIrqlNoThread(0xf);
OBOS_UNUSED(oldIrql);
Arch_InitializeMiscFeatures();
// UC UC- WT WB UC WC WT WB
Arch_RestoreMTRRs();
wrmsr(0x277, 0x0001040600070406);
asm volatile("mov %0, %%cr3" : :"r"(getCR3()));
wbinvd();
Arch_LAPICInitialize(info->isBSP);
wrmsr(0xC0000080 /* IA32_EFER */, rdmsr(0xC0000080)|BIT(0));
Arch_InitializeIDT(false);
OBOSS_InitializeSyscallInterface();
is that before _WAK or after
before
ah
_WAK is called right after the arch revives vital state
like the scheduler timer
idt
gdt
caching stuffs
makes sense
hangs or triple faults
lmao
and I need to relearn english grammar
or start typing slower than I can think
I now know it triple faults somewhere here:
asm volatile("mov %0, %%cr3" : :"r"(getCR3()));
wbinvd();
Arch_LAPICInitialize(info->isBSP);```
it's probably initializing the LAPIC
it is in LAPIC init
it now triple faults somewhere else
somewhere here:
OBOS_Debug("Reinitialized timer for CPU %d.\n", CoreS_GetCPULocalPtr()->id);
if (info->isBSP)
{
OBOS_WokeFromSuspend = true;
Core_SuspendScheduler(false);
}```
it's after the scheduler was unsuspended
brai
that's what they do in south africa
Lol
lol
Le brai est une substance noirรขtre pรขteuse et collante obtenue par pyrolyse de matiรจres organiques en conditions anoxiques ou en atmosphรจre trรจs pauvre en oxygรจne
I pushed the fix to the pr btw, rebase just in case @flint idol
ok
Any ideas why
not yet
well it most definitely crashes in here:
CoreS_SwitchToThreadContext(&CoreS_GetCPULocalPtr()->currentThread->context);
if (info->isBSP)
{
OBOS_WokeFromSuspend = true;
Core_SuspendScheduler(false);
}
CoreS_SwitchToThreadContext(&CoreS_GetCPULocalPtr()->currentThread->context);```
the current thread is not nullptr
so the thread context truly was corrupted
Your ARCH_FLUSH_CACHE is correct right
Hm
cr3 is legit
in the context frame
although I have a idt, so idk why it's triple faulting
I wonder if you're relying on some cpu or hw state that gets reset
Is S3 difficult to implement? 
Its already implemented for you
But wake is difficult yes
Like do I need a GPU driver?
if you want a framebuffer after wake
yes
I have a bochs vbe driver for the sole purpose of restoring the framebuffer on wake
You wake up in real mode and all hw state is reset
(including most, if not all, PCI state)
all devices need to be brought back from the dead
scary zombies
I think
I have 3 generations/architecturs of AMD GPUs
Navi (RX 5700 XT, 780M), GCN (HD 7850) and whatever there was before that (in 3 PCs)
Yes
Do you accept contributions to uDRM?
I have no idea how this stuff works, but...
yes
also yes
we are all eager to see what will happen with uDRM
i'm waiting on headers 
That would be amazing to see
why do uStorPort when you can have uDisk 
why would we need that fadanoid ๐ญ
ustar is like the easier thing to get working
Read that again
That's a hard disk driver
huh
my brain is confused
how does the word ustor have anything to do with disk drives
Search StorPort
storport is windows drivers
for disks
it's fairly simple to use them in a hobby os
yea i see
wait wha
u can use them in hobby oses?
????????????
microsoft pulling a W??
if you implement a shim yea
it's not intended by microsoft
it wasnt made for hobby OSes
shim
but their nature makes it easy to just add a shim layer
?
glue code
oh yea
since its a sys driver
so like you need PE loading and some nt functions
in a way microsoft made a ustorport already
uvm when
tbh this might not be a bad idea
port it to linux while you're on it as well
especially if it's stable
imagine btrfs but stable
i have been using btrfs for almost 2 years but daily for the last year
it fucking loves corruption and it's repair tools are shit
fun fact a random weird windows disk recovery utility happens to be able to read btrfs lol and i can almost guarantee their implementation is probably better than actual btrfs
I can agree with this
btrfs randomly corrupted itself because stupid nvidia made it so my PC couldn't wake from suspend properly
I just got rid of the uacpi table logs in obos
were cluttering the logs
thank god the triple fault isn't in the context switching function
and I am glad to say that it is somewhere here:
uacpi_prepare_for_wake_from_sleep_state(UACPI_SLEEP_STATE_S3);
UACPI_ARCH_ENABLE_INTERRUPTS();
uacpi_wake_from_sleep_state(UACPI_SLEEP_STATE_S3);```
it's when I enable interrupts
so I guess my idt is just fucked then
wait
I wonder if it has anything to do with the PIC
theory: on wake-from-suspend I get a bunch of bogus PIC IRQs because the IMR register of the PICs was reset on suspend
why would that triple fault tho
idk
but masking the PIC fixes the triple fault
ah its probably because u expect an error code to be pushed
oh yeah right
I was able to get it to not triple fault anymore
instead it hangs
so I need to now use triple fault debugging to find the bug
it hangs in uacpi_wake_from_sleep_state(UACPI_SLEEP_STATE_S3);
cc @real pecan
could mean a lot of things
indeed
to make sure you don't forget to release a lock before suspend
I will be dumping every single uacpi lock's status
then debug from there
in theory, all of them are released
and it's a bug somewhere else
but I don't want to speculate right now, I need to find this bug
yeah
first I will make a linked list of mutexes created via uacpi_kernel_create_mutex
all mutexes were released..
Yeah
yeah no highly doubt it
looked through all possible places
probably unrelated to locking
is your scheduler online at that point?
Yes
then we'll have to do kernel api triple fault dehanging
Im going to bed but lemme know
Gngn
Lol
Oh well
One funny thing we could do is store your real hw tables in obos and override dsdt with your laptops one and just uacpi_table_install ssdts
Then it will run this wak when it wakes up
Its not guaranteed to repro or even work because obviously it would be trying to access non existent hw
yeah first I'd need to be able to suspend
I can't do that in qemu with my laptop's blob
Suspend should still work
It doesnt need real aml
Or well
We can hack _S3
To contain what qemu has
Wdym
I think it restores the framebuffer
Oh that's possible yeah
Local0 = \_SB.PCI0.LPCB.EC0.IBT1
If ((\_SB.PCI0.GFX0.TCHE & 0x0100))
{
If ((\_SB.IAOE.ITMR == One))
{
If (((Local0 & One) && ((\_SB.IAOE.WKRS & 0x02) || (
\_SB.IAOE.WKRS & 0x10))))
{
\_SB.PCI0.GFX0.STAT = ((\_SB.PCI0.GFX0.STAT & 0xFFFFFFFC) | One)
}
Else
{
\_SB.PCI0.GFX0.STAT = (\_SB.PCI0.GFX0.STAT & 0xFFFFFFFC)
}
}
ElseIf (CondRefOf (\_SB.PCI0.LPCB.EC0.IBT1))
{
Local0 = \_SB.PCI0.LPCB.EC0.IBT1
If (((Local0 & One) && ((\_SB.IAOE.WKRS & 0x02) || (
\_SB.IAOE.WKRS & 0x10))))
{
\_SB.PCI0.GFX0.STAT = ((\_SB.PCI0.GFX0.STAT & 0xFFFFFFFC) | One)
}
Else
{
\_SB.PCI0.GFX0.STAT = (\_SB.PCI0.GFX0.STAT & 0xFFFFFFFC)
}
}
}```
judging by GFX0
Ah yeah thats probably fine
assuming the firmware isn't dumb and restores the state correctly
Id hope so
and not seabios level of stupidity
restoring ECAM using ECAM
Lmao
it reads ICNF from a fieldop:
Field (GNVS, AnyAcc, Lock, Preserve)```
anding it with 0x10 to do some stuff
Should work
enlighten me, oh infy
NVS is non volatile storage
Technically firmware expects you to preserve it and then restore
That might be why its hanging
If you have any ACPI_NVS stuff
is that what Preserve means here
mhm
ya
uacpi_context_set_while_loop_timeout(3)
Maybe its spinning waiting for something that will never happen
Probably trap into SMM
But u can see implementation
But anyway I think its related to that if its not a bug because of something else
it's uacpi_context_set_loop_timeout(3)
Nvs is supposed to be preserved in s3, Linux suspend to ram impl might give u clues
I can take a look tomorrow as well
but I'll do that
Yeah
Try that who knows
Or maybe your hpet stops counting
So it hangs
that wasn't it
Lmao
I completely forgor to restore hpet state
๐
if it isn't that, it's still a bug you just found for me
I highly doubt it keeps state after reset
HOW COULD U FORGET THE HPET
๐ก