#Nyaux
1 messages · Page 30 of 1
huh
-# ||(ˢᵒʳʳʸ)||
real osdevs dont have partners
for they are mere distractions from the road to success
factorio also has no end, as Mathewnd found out the hard way
is this some sorta sigma alpha male bs
If you want to be rich, women will only slow you down.
Invest many monies into my company called "BigScamDepressedLosers"
hey I commited like 4 lines of code yesterday to astral
you did, or infy did?
the alpha leads the beta follows but the sigma walks alone awrooooooo
me
soruce-recipes/libtool: fix build
it was a jinx script but it was code 
what about lambdas?
no way I typod
git commit --amend
I should add working set and swap to astral
nah I wanna tackle that myself some day
someday, aka never
Mathewnd's routine:
- wake up
- factorio
- go to work
- factorio (with a side of work)
- go back home
- factorio
- sleep
- repeat
that sounds gay
wake up
go to university
go to work
the facotyyry must grow
go to sleep
repeat
my friend just told me to hop on factorio so yes
in your routine ofc
and you're not at work or uni, right
(right??)
holy
SEND HELP
ETGHE
I live at 123 seasme street
someone broke in
/j
or at least, I hope is a joke
isnt it not in the quran tbf
oh yeah btw i think i figured out the issue with isr_stub 32
so
😎
You can't just deny the opinion of practically every modern scholar of islam
lets notttt argue about this
why arent any of the other lapic timers firing
tf????
and get lapic id clearly works because well
it worked fine in the print logs
but when used in an interrupt
it shits itself
huh?
like wtfff
anyone know whats going on?
prolly need more context
Give it proper food and it might not anymore
okay
this is what the schedule function looks like
void *sched(struct StackFrame *frame) {
kprintf("CPU %d Says: MY LAPIC TICKED HAHAHAHA\n", get_lapic_id());
send_eoi();
return frame;
}
void bootstrap(struct limine_smp_info *info) {
kprintf("bootstrap(): Hello from CPU %d\n", get_lapic_id());
init_gdt();
init_idt();
per_cpu_vmm_init();
init_lapic();
hcf();
}
void init_smp() {
for (uint64_t i = 0; i < smp_request.response->cpu_count; i++) {
struct limine_smp_info *cpu = smp_request.response->cpus[i];
cpu->goto_address = bootstrap;
kprintf("init_smp(): Found CPU %d\n", cpu->lapic_id);
}
// stall_with_hpetclk(100);
// init_lapic();
}
nothing gets printed on the other cpus
only the bootstrap cpu has it tick???
its the exact same function
to which i read the msr
to get the lapic address per cpu
sti is run on all cpus
????
😭 ???
everythings on github btw
you might want to invest some time into organization
organization
huh?
whats that

also i still cannot figure this out

I gave up trying to figure out what parts of ur code did
all the hardcoded & unannotated constants make it very hard to follow without pulling up the spec side by side
Oh it's calibration for 10 ms
But why...
All APICs should in theory work at the same frequency
especially without messing with power management they do + inside qemu
eh still
either way
dont get why only ONE lapic
wants to work
What are you doing with hpet?
How are you doing it I mean
wdym
Do you just look at how much time has elapsed?
mhm
If you're programming it from several cores at the same time it might be a race condition
Also this
ik
either way this isnt the issue
And just gave up and used one shot for everything
Code quality issues 
i mean all that matters is just i know what its doign right

If it isn't working then you're probably not doing it right though
yea but it works on ONE core
SOOOO
it works PARTIALLY???
like
huh
it should work on all cores
Doesn't have to?
i mean its the exact same code lol
If you're forgetting to initialize something
in this case what would i have to initialize, lapic should work out of the box right???
js set the vectors and plug in play
RIGHT????
yeah im debugging this tmrw i need sleep
if i cant debug this, ill ask the osdev forums if i cannot figure it out but im sure ill figure it out
like im not stupid lmao
probs js overlooking something
also @silver yarrow maybe ur right about organizing the code
i might js comment anything
everything*
yeah it shows that the code quality sucks but
im not rewriting the entire codebase
again
im js gonna comment things that dont make sense at first glance
wait is the default behavior for the other cores to have the local apic disabled?
Idk I don't remember
*software disabled
But I'm setting this bit explicitly
okay js in case ill have it forcefully enabled
yeah
0x100 is for the software apic enable bit correct?
too lazy to open the SDM
rn
well not but my ram is like
90%
Then there's this
This is what osdev wiki says
@flat nymph still the same issue
Idk
*sur_interrupt = 34 | (*sur_interrupt & ~0xFF) |
(1 << 11);
I was planning to be sleeping one hour ago
No
Bit 8
Bit 11 is the MSR
But I'd suppose it would be set
LAPIC base?
how do i get my lapic base?
reading the msr
its solved
@flat nymph
thank you
Yes, and that same MSR has the bit to disable APIC
i could do that
but i use the sur register instead
also
look guys
🥳
Yeah
pin this
chat
this is really cool
proper multicore
PROPER
i didnt get this working on other nyaux rewrites i think
so
this is rlly cool
You don't need to apologize, there are no expectations
i put expectations on myself tho

You got all the time in the world 😃
hi chat my bad, still stuff going on 
GUESS WAHT
CHAT
ITS TIME
okay so
we need to
how would i like
seperate different archictures
would i have an arch_init?
function
and some macros to check which architecture it is
id just have a per-architecture entry
that calls into main
wdym?
oh
yea that makes sense
but if u booted on lets say an arm archiecture somehow via limine right
and i just went into entry point
do i check the cpu archiecture?
then call into that per architecture entry?
@cinder plinth
yea but this entry point is gonna be the entry point all cpus will go into tho..
void entryallcpusgointo() {
// wtf do i do?
#ifdef __x86_64__
// do stuff here
#else ifdef yadada
// do stuff here
#endif
}
something like this?
@cinder plinth
should be easy then
i dont know how to do that
😭 😭
im just gonna have an arch_init() function in main
and do my shit yada
hi fadanoid!!!
nice to see you lurking nyaux's thread
lol
okay im working on it
Update uacpi for new fun printouts
i did with git submodule update
i dont know if its properly updated
but the kernel api looks the same to yk
Does it print out the installed tables
i didnt even run it 😭
Run it then
i still have to make a generic abstraction
for the arch
// heres what im thinking
void output_to_port(uint64_t data, uint8_t bit_width) {
#if defined(__x86_64__)
// check for the correct instruction for the bit width
outb()
#else defined(riscv or whatever tf)
// idfk there instructions
#endif
}
x86/main.c
Substitute x86 with current arch
Have x86 main call generic_main once its done with arch stuff
i already figured out an abstraction
so im doing that currently
okay nearly done
i just need to make the generic interface now
fixed all the errors
port io is pretty much specific to x86 (along with some other smaller arches)
how should it be done then
you only use port io in x86 code
^
or you have some linux iomem kind of thing
Aarch pci
here
you use mmio maybe?
Yes its not port io but same abstraction applies
idk arm
okay then
ill do mmio in this function otherwise
if its another archiecture
idfk arm either
Macros can get messy
its fine
Just implement it in an arch file
ima take a break for 2 hours
cause im tired
so im gonna nap a little bit
maybe eat
cause i havent eaten yet lol
I have a generic limine function that's jumped to from small assembly function (since I don't use limine's stack)
oh
my
god
after seperating the archiecture through an abstraction
this happens?
wth
null deref anyway
seems to be happening here
but its going so fast
i cannout
find it
the root cause
oh right
im stupid
@kind root wheres the cool tables u promised
beautiful isnt it
maybe it needs pci api implemented
the ops per second thingie
idk
I don't think that is enough to update it
I remember having issues in the past related to that
i did --recursive
i remember having to go into the directory and do git pull
ill try
did it work?
empty the directory and reclone it?
No it needs nanoseconds since booy
*booy
how tf do i get that
**boot
It's a kernel api
For uacpi
You just ask your timekeeper for that
HPET counter is femtoseconds iirc
ik
That's gonna break the counter?
Ops/s counter
Which is the only reason why you are implementing it
ill convert it to nanoseconds
Kk
is the hpet main counter time since boot or could it have been reset?
tables are valid before the namespace is loaded
iirc it maps them in uacpi_init
okay
so you just have to init uacpi in 2 stages
you can reset it
i think
or else just use limine's time at boot feature
nah not really that isnt good for timekeeping
yes but I thought that maybe pci not being implemented somehow made it exit prematurely before printing the stats
yea this is wrong
ME WHEN I CANT GET MATH RIGHT
😭
hpet counter ticks every 10 nanoseconds
i have no fucking idea how to convert the counter to nanoseconds ughhhhh
if a single tick is 10 nanoseconds just ticks * 10
12114 ms isn't right
maybe thats how long it takes in nyaux
💀
does it take 12 seconds to boot?
idk 😭
nested virtualization maybe?
im running via wsl
wait no that wouldnt
nvm
idk
bruh
i mean nyaux has always been slow
so eh
idrc computers are fast nowadays
it runs very fast on kvm/native hardware
this is a little trick for converting ticks to nanoseconds without overflowing that qookie taught me
u64 freq = 10^15 / clk
u64 p = log2(freq)
u64 n = (1'000'000'000ull << p) / freq
// when reading the timer
u64 nanos = (u128(ticks) * n) >> p
did u see the table printout at least?
mhm
thoughts?
thanks
np
good night
goodnight
good morning chat
so
i did some changes and now smp also works with the archiecture abstraction
now whats next is well
the scheduler itself
but we encounter a problem
we need a stackframe and different archiectures have different stackframes
how exactly do we
abstract that
#ifdef ARCH_X86_64
typedef struct {
/* stuff */
} stackframe;
#elif ARCH_ARM64
typedef struct {
/* other stuff */
} stackframe;
#elif ARCH_RISCV
/*[etc.....]*/
#endif
What timezone are you?
thanks
im in irish time
9:28pm
good morning
Ah ok. I'm only asking because its 7:28am here in Australia, so you confused me
😭
Good evening
good evening
hi chat, no work for today BECAUSE AT 12AM TODAY THERES A RUMOR HALF LIFE 3 WILL BE ANNOUNCED?
ive been waiting all day
i need
this is a need not a want
Every year theres a rumor
If it gets announced I will write a driver for nyaux
if it gets announced I will write a gpu driver
okay sure :)
lol it's 10AM for me
It's 4 56 pm here
It's 8:08am for me
here goes every timezone
it's 25:03 here
nothing ever happens
u were right!!
My disappointment is immeasurable and my day is ruined
At least Helldivers 2 update is very good
yea :c
true
And the new IP that was announced at the very end also looks sick
But still
No half life 3

😔 😔
idk what valve is doing chat
they setting on they lazy butts
just
ranking in steam money
Lord gaben knows what is best for us
true
Who art in Valve, Hallowed by thy name.
Thy Half-Life 3 come, thy puchase will be done,
Online as it is in offline.
Give us this day our daily deals,
and forgive us our guest passes,
as we forgive those who guest pass against us.
And lead us not into temptation,
But deliver us from Origin.
For thine is the kingdom,
the power and the glory,
forever and ever.
Gaben.```
🙏
Nothing ever happens
No gta6 either
yep
Amen
welp i just realized one big
thing
before writing the scheduler
THE FUCKING PAGE TABLES ARE NOT ARCHIECTURELLY ABSTRACTED

thats fun
im js gonna do something rlly stupid
do any other architectures have 2mb pages (risc v, arm etc)
?
U dont need this information
To abstract away paging
that's 32-bit arm specifically tho, 64-bit supports 4kb, 2mb and 1gb
he meant the 4/16/64k basic page size
or granule as they call it for some reason
ah like kernel page size
oh wait there are actually different translation granules, I didn't remember that
yeah aarch64 has 4k, 16k, 64k base page size, and from that you get 512*size and 512^2*size and 512^3*size blocks
er, for larger page sizes it's not 512 but you get the point
Yeah arm has some of the more flexible mmu configuration I've seen on any arch
you ain't seen nothing yet then
Lol
Which are more flexible
Wtf is this lol
Damn
pick your own page table geometry
it has large pages as well ("early termination page descriptors") and you can have a PTE point to another PTE to be used instead
Damn!!!
Me too, me too
kill me
genuinely
why is one damn pnode refering to 0xffffffff
wtf
Bruh
and how did uacpi not notice this
You probably aren't clearing that field in the insertion or removal functions
Wait
What are pnodes
Ok, then ya you're def not clearing that field
i memset before inserting though?
Do any other functions touch the pnode list, though?
and on creation too
no newlines 
first->next is uninit here, I think
Could that end up causing this issue?
maybe u'd have full context with the entire file
I have a party all weekend, so I'll be busy
But if you still have this contact me sunday night and I can try to help
okay
Good luck bestie
i have a very slight suspection
its because of free_unused_slabs
im gonna remove the call to it
and see what changes
never fucking mind
okay heres what ill do
NVM
i have no ideas
fucking hell
and wheres my fucking stacktrace
hold on
well
now we have more context
okay i see a calloc
i dont see
a kernel_free() being called
@kind root is the call being called somewhere else?
WHY IS MY LAPTOP LAGGING
okay
um
Page Fault! CR2 0xffffffff
RIP is 0xffffffff80006935
-> Function: slabfree() -- 0xffffffff800068e0
-> Function: uacpi_execute_control_method() -- 0xffffffff80011120
-> Function: uacpi_execute_table() -- 0xffffffff800132e0
-> Function: uacpi_table_load_with_cause() -- 0xffffffff8001a1b0
-> Function: uacpi_namespace_load() -- 0xffffffff8001bf50
-> Function: init_acpi() -- 0xffffffff80001000
-> Function: kmain() -- 0xffffffff80005d70
-> Function: none -- 0x0
that is the full stack trace
i dont know if uacpi is doing some macro shanngains to expand the macro into calling the kernel free
obviously its my code thats at fault here
i just dont know why

Context release gets inlined perhaps?
okay hold up lemme check
yea i see
yea this is a triggy bug
TRICKY
OMG I CANNOT SPELL
😭
okay we know when it is allocated and deallocated
but thats still not the source of the issue
because the slab we free ->next field is ferring to 0xffffffff
and i tried to impl ksan
i couldnt get it working
its still in the source code
for some reason not working
🤷♂️
skill issue
okay memory debug 101
take your free function
and replace it with memset(memory ptr, 0xaa, malloc size)
then insert memset(memory ptr, 0xcc, malloc size) right at the end of your alloc function
wait, you guys actually got memory allocation working? (I gave up before ever actually making it work properly) 
yes cause ur brain is so big
and mine is so small
tried, still found nothing im afraid
might ask the forums and irc chat for help cause i rlly cannot figure this out
well what i found interesting
is
i do this function after uacpi inited
hold on
WAIT
nvm
this is not the problem
cur->next = (struct slab *)init_slab(mod->size);
cur = (slab *)cur->next;
void *guy = cur->freelist;
cur->freelist = ((pnode *)cur->freelist)->next;
memset(guy, 0, mod->size);
return guy;
using a debugger
💀
i cant
why not
i dont know where to put the printfs because i dont know where the memory corruption is happening
shrimple: put it everywhere
now that's based
what have I said that needs proving
im gonna prove thats not gonna help
bru
yo is this a valid address
wtf
he gives me reasonable addresses
then this???
huh
Omg
Me me me me me
i solved it
yea thats a vmm address
TURNS OUT IT WASNT MY ALLOCATOR
BUT JS
some stupid ah
shanngains
im gonna check what size uacpi gave
what lol
so lemme get this straight
uacpi tells me its 10 bytes
gives me a vmm region address
gives me garbage sizes
too
did the printfs work
we got closer yea
can i ask
why for the love of god
is uacpi giving me a bunch of gibberish for size
it is not
kfree is called with gibberish
and you call kfree
not uacpi
no
im js passing whatever size uacpi gave
and therefore
uacpi is giving me gibberish
look at the stacktrace
why do you allocate anything there
maybe it is
and what's the use for that
how??
to check if the offset goes over the len
and when would that happen
return uacpi_status_invalid_argument
it's nyaux, anything is possible
idk maybe infy makes a mistake
it wouldn't be called with an incorrect size
in future
Infy tests sized frees
If that's what ur talking about
did you remove the kfree?
trace your stack
thats the stack trace
when the value is garbage
^
yeah and is that useful at the end?
i cant watch address ^
trace the stack
and im not manually gonna step through every allocation
if kfree is called with a garbage value
fine
sleep then
there definitely something else between 0 and 1
wha
are the optimisations off
use your stack tracer
i already have the stack trace
^
when the value is garbage
not when the exception happens
and how am i supposed to trigger a fault
when that happens
ill add a stupid check in kfree then manually page fault or some shit
???
if (size > some_random_garbage_millions) trace_stack()
in kfree
wait what
you don't need to page fault
just read rbp smh
fine
its better if i trigger a fault im not gonna spaggathi code a bunch of garbage
into that file
id have to load symbols early
and a bunch of other shit
dump the addresses and use addr2line
print size in uacpi kernel free
what kind of printf do you use
nanoprintf
yea this is very weird
yea i ignore those
I totally missed that
well clearly not
what is that size as hex
thats not whats called here
which uacpi commit are you in?
nyaux heap corruption any%
huh
which uacpi commit
please run cd third_party/uACPI && git rev-parse HEAD
are you returning null in some handle in some uacpi kernel api function
or something
still the same
what if you remove the entire free path
hold on
and add 64k to every allocation size
what
150ops/s will plummet
put return; right after that free check
okay
obviously perf will suck the point is to check the heap isnt totally broken
💀
I wonder if u port uacpi to NES will it run faster than 150/s
probably lmfao
its running
as in it just hangs?
i see i see okay
wait how do you get to slabfree if you put a return right after this first check in kfree
this is what you should do
actually, memset(addr, 0xcc, size) first
NO
do u want me to do this? where?
nyaux rewrite 2^64-1
void kfree(void* addr, uint64_t size) {
if (size >> 63) { kprintf("kfree: memory corruption detected\n"); __builtin_trap(); }
kprintf("kfree(%p, %#llx)\n", addr, size);
memset(addr, 0xcc, size);
return;
}
do this
same
i told you
can you send the code?
yep
cool
garbage collector compiler
use gcc
what distro are you on
ah lol
okay i think you have way bigger memory corruption issues @surreal path
i tried building your shit
and it memory corrupts itself to death
idk it hits this #PF every time for me
where
cr2=pc=ffff8...117a
this is fucking weird
im on gcc 14.2
i dont know how to get further
this is probably the issue tbh
the issue is memory corruption obviously
but tracking it down?
idk
this is difficult
initially you map this
mhm
tbh i blame your kmalloc
I would suggest rewriting it
i already printf'd everything
plus 150 ops/s is very slow
you need a better allocator
i was reading the screen from an angle
i think the vmm region stuff is fine
slab allocator? idfk
im not rewriting
yes
it wont solve the issue
how are you so sure of that
because ill write the same design
rewrite means write something else
rewrite a slab allocator how
read them again, read other ones
-# ||shrimply a krill issue||
the slab allocator isnt even
that much code
im geuinely unsure
how that little code is somehow corrupting the entire kernel
why not
- i have read the code for the slab allocator top to bottom i dont see an issue
I'm sorry but clearly you did something wrong
like
slab alloc is literarly
void *slab_alloc(cache *mod) {
if (mod->slabs == NULL || mod->size == 0) {
return NULL;
}
slab *cur = (slab *)mod->slabs;
while (true) {
if (cur->freelist == NULL) {
if (cur->next != NULL) {
cur = (slab *)cur->next;
continue;
}
break;
}
void *guy = cur->freelist;
cur->freelist = ((pnode *)cur->freelist)->next;
memset(guy, 0, mod->size);
return guy;
};
cur->next = (struct slab *)init_slab(mod->size);
cur = (slab *)cur->next;
void *guy = cur->freelist;
cur->freelist = ((pnode *)cur->freelist)->next;
memset(guy, 0, mod->size);
return guy;
}
no point in trying to find problems in some other things
even pitust didnt understand whats going wrong from static analysis
obviously
what if you don't free anything
a few minutes of just looking won't find every bug
give it more memory if that's the case
I see a kfree in there
okay i found the bug @surreal path
oh hold on
WHERE
I retract my statement
removing it runs fine
src/cc-runtime.c:2663 (__mulvXi3_25) and src/cc-runtime.c:2678 (__mulvsi3) are mutually recursive
leading to an infinite loop
thats not even
my code
yeah lol
wait really
who needs freeing anyway
just download more ram
@wicked loom
unused ram is wasted ram
that's not mint's code
llvm or gnu
because that was from the c template
ping the llvm dragon
but i 100% bet the llvm people do build config stuff to make sure this isnt a problem