#Nyaux
1 messages · Page 31 of 1
I don't think that's the issue
idk im not the expert
it is the issue
an infinite loop leads to a page fault?
oh nvm
just tail call optimize it
its mutual recursion
what do those functions do
some multiplication shit
wtf
oh wait nvm
its my bug
ok sorry
its still kinda broken
but its not that bad
ooops
what
oh
i nuked my cc-runtime
still an LLVM bug tho
💀
fun
time for a bug report then
huh
yeah
check your slab free
maybe you free an incorrect thing, allocate it again and overwrite some data
ok so i dont want to say anythig but im finding it really hard to blame nyaux here
@kind root this doesn't seem like correct decomp for item_array_clear
(this matches disassembly)
at -O0 btw
ah hmm wait
okay nevermind this is probably not a uacpi bug
it's technically just a hint
"hint" fucking what
another joke
probably his skill issue on misusing UACPI_SIZED_FREES
can you mangle symbols so that this can't happen?
how
like use two different symbol names or something
gcc -> g++ 
you gotta define UACPI_SIZED_FREES for all translation units
yeah
sorry translation units?
every file
add -DUACPI_SIZED_FREES to cflags
that fix makes it get to this
RAHHH
nyaux cmon we went over this
476ms its faster now
probably because of some shit i added to make it more likely to catch issues :^)
that doesn't look like the latest uacpi commit
lmao
476 ms faster than astral

faster or slower?
slower?
i cannot figure this out chat
you didnt include it
uhhh i did
a secret third thing
is limine.h included here
yes
send all of elf.h
#include <limine.h>
#include <stdint.h>
#define EI_NIDENT 16
#define Elf64_Addr uint64_t
#define Elf64_Off uint64_t
#define Elf64_Half uint16_t
#define Elf64_Word uint32_t
#define Elf64_Sword int
#define Elf64_Xword uint64_t
#define Elf64_Sxword signed long int
typedef struct {
unsigned char e_ident[EI_NIDENT];
Elf64_Half e_type;
Elf64_Half e_machine;
Elf64_Word e_version;
Elf64_Addr e_entry;
Elf64_Off e_phoff;
Elf64_Off e_shoff;
Elf64_Word e_flags;
Elf64_Half e_ehsize;
Elf64_Half e_phentsize;
Elf64_Half e_phnum;
Elf64_Half e_shentsize;
Elf64_Half e_shnum;
Elf64_Half e_shstrndx;
} Elf64_Ehdr;
typedef struct {
Elf64_Word sh_name; /* Section name */
Elf64_Word sh_type; /* Section type */
Elf64_Xword sh_flags; /* Section attributes */
Elf64_Addr sh_addr; /* Virtual address in memory */
Elf64_Off sh_offset; /* Offset in file */
Elf64_Xword sh_size; /* Size of section */
Elf64_Word sh_link; /* Link to other section */
Elf64_Word sh_info; /* Miscellaneous information */
Elf64_Xword sh_addralign; /* Address alignment boundary */
Elf64_Xword sh_entsize; /* Size of entries, if section has table */
} Elf64_Shdr;
typedef struct {
Elf64_Word st_name;
unsigned char st_info;
unsigned char st_other;
Elf64_Half st_shndx;
Elf64_Addr st_value;
Elf64_Xword st_size;
} Elf64_Sym;
typedef struct {
Elf64_Word p_type;
Elf64_Word p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
Elf64_Xword p_filesz;
Elf64_Xword p_memsz;
Elf64_Xword p_align;
} Elf64_Phdr;
typedef struct {
Elf64_Sxword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
extern volatile struct limine_kernel_file_request kernelfile;
Elf64_Ehdr *get_kernel_elfheader();
uint64_t get_kerneL_address();
a link would be better tbh
fair
#if LIMINE_API_REVISION >= 2
struct limine_executable_file_request {
#else
struct limine_kernel_file_request {
#endif
uint64_t id[4];
uint64_t revision;
#if LIMINE_API_REVISION >= 2
LIMINE_PTR(struct limine_executable_file_response *) response;
#else
LIMINE_PTR(struct limine_kernel_file_response *) response;
#endif
u mind pull requesting ur checks btw
what revision did yo set
2
stare at this code until you figure it out
you fucking opted into it
its called an mp request now lol
real smp is when all cores boot up at the same time and theres no concept of a bsp 
@haughty kite did u pr ur checks yet
runs nicely btw
can u do that pitust
or at least
send the code over
i still am getting 131 ops
and like 12 seconds uacpi init
i need that speed increase lol
pleaseeee
132*
use rep movsb for memcpy
instant speed boost
you can have arch specific memcpy/memset and then a generic fallback with attribute weak

the speed increase is running on a fast laptop i think lol
0 changes and it still runs in 56
oh also, -smp 2
what would that do if the kernel is running on a single core
how do you manage to get that bad score lol
make qemu not do stupid shit
im adding that
now js memset
rep stosd or wtv
yes
because not all memcpys have 8 byte aligned sizes? and also rep movsb/stosb are the only optimized ones iirc
I can't understand how can it be 131/s
its like 6k x slower than my kernel for an example
REALLY Dunno either
unless its your timer somehow but if it also takes a visibly long time then its probably something else
its also visibly a long time
so not my timer
oh
i just enabled kfree
@kind root @haughty kite
wtf
1137 ops per second
LETSS FUCKING GOOO


where is nyaux on the letherboards
do u want to be on the scoreboard
sure
put me onnnn
can someone with an 12th gen i9 run astral so the number can be high 
I can run it on an i3-12100f, should be close enough 
I only have 13 gen i5
you're not ready I will be on top of the leaderboard soon
I don't think there is like a huge difference between the i's after 5 anyway, they are just way more pricey for a very little gain
the key is to have bad timekeeping
these guys are funny
remove all the checks there are 
nah just using object caching
hes right
but uacpi is pretty well tested at this point too
I have Ryzen 9 5900X
Acpica
Maintainer got convicted of criminal damage
In all seriousness though although I favour using community projects anyway
My choice to use uacpi would have been the same regardless
Acpica is a body barely living outwith the foetid confines of the Linux kernel and maintained by 1 or fewer people
speaking of acpica, it's kinda funny how managarm used acpica, lai, and uacpi at various points in time
lol true
real!
say hi to nyaux mascot
(real)
this is a joke obviously
but rate my art
0-10
Furry
eh, I'm probably not much better lol
5
in my defense I made this at one point many years in the past (mockup demonstrating how I could replace my broken CPU cooler with a USB fan ductaped to the bottom of the PSU
)
11/10
exactly
nyaux fursona reveal
My friends said “10, excellent”
TODO list for today:
abstract smp away to architecture specific code
abstract pagemap and mapping functions to architecture specific code
if we have more time
scheduler
What is there to abstract in SMP?
its just the vmm then that needs to be abstracted

yea this is pretty much how i abstract everything
i think its a good way to be honest
so what im gonna do for abstracting away page table things to archiecture yk
im gonna have something like
typedef struct {
uint64_t *root; // on arm this could just be a pointer to the large page table or whatever idfk
} pagemap_t;
void arch_init_pagemap(pagemap_t *take);
void arch_destroy_pagemap(pagemap_t *take);
void arch_map(pagemap_t *take);
void arch_map_hhdm(pagemap_t *take);
void arch_map_framebuffer(pagemap_t *take);
void arch_map_memorymap(pagemap_t *take);
void *arch_map_vmm_region(pagemap_t *take, uint64_t length, uint64_t vmm_region_base); // returns the base of the vmm region
void arch_unmap_vmm_region(pagemap_t *take, uint64_t length, uint64_t vmm_region_base);
having these as seperate functions gives me more control on the archiecture specific code itself
@hexed mango what do u think
no
why
too high level
why arch map_hhdm
just have arch_map which takes a bunch of options (?)
some archiectures might not have pages in 4096 bytes
It doesn't matter
and
some archiectures might not support recursion
sorry, a bit too busy to give it a detailed look atm
wdym
arm
yea
it's obnoxious anyway
some architectures have inverted page tables
yea
exactly
so thats why
im making it this high level
i dont wanna make any assumpations
What I had to implement when porting to riscv was map, unmap and unmap range
(and I've also made my unmap functions take context for tlb shootdowns, but that's an implementation detail i'd suppose)
also some architectured don't even have page tables
as in a page table in form of a radix tree
The only APIs I remember using often in the VMA are:
Map (which is more like modify PTE at this point)
Unmap
Query page info
And unmap is basically deprecated at this point
why
Because the functionality of map can do the same:
Set the page to non present

And in some places related to swap, it is used in that matter
anyways im gonna impl my high level abstraction shit
Mainly so I could keep the PTE flags, but unmap the page itself
Why?
That's just reusing code in many places
look at my responses above
For no reason
again it doesn't matter
Yet you still say "page size in 4kib"
As a parameter
It should at least be in bytes
fuck i cannot spell
forget about it
And if the page size is less than 4096?
Aka 4kib
arm can have 1kib pages
hold on lemme rethink
This is a bad way to abstract it
okay whats ur better way
Abstract it via map and unmap functions that take a base and physical address
Have the arch tell you the page size
And work in that manner
huh
wdym by that
what about mapping the framebuffer with wc enabled
Make the platform tell you what the page size is
what about bigger pages
Map will take flags
Telling it how to map the page
E.g., huge page
E.g., map as x caching mode
Afaik only x86 does that
But someone correct me if I am wrong
what about unmapping
you pass it a flag that says "wc disabled"
Take in a base
you have some cache disabled shenanigans on risc-v and arm
Maybe wc enabled flag?
i need its physical address returned
Then do so
what about mapping in a loop
You can also have a query page info function
Call map in a loop?
That tells you the flags it was mapped with, the physical address, etc.
Why?
this is how i map regiosn currently
^
how am i supposed to change this
PAGE_SIZE constant
You rewrite it
oh use a loopppp
oh my god
sureee
but how about
the amount of times u loop over
do u loop in bytes?
like
Division
You take in a size
Then you can convert that to a count of pages (you have a page size constant from the arch)
And loop that many times
Don't forget to round up
in map? in what function
Idk where is ur loop
im kvm_region_deallloc and kvm_region_alloc
Then that's where you take in a byte size parameter
Or have the size of the region
In the region
i already have that
Then use that
its in bytes
Do this
And then loop that many times to map/unmap
okay so an arch_convert_bytes_to_page
is this correct?
yes
or no
You could have a page size constant so you can do that in an arch agnostic way
Like NYAUX_ARCH_PAGE_SIZE
I mean you can probably have an arch-specific map_range function for optimization
No
Never
I am adding some new features to my VMM so I could experiment with something like that to optimize
My kernel does map several pages at once
But yeah it's totally not mandatory
#define NYAUX_ARCH_PAGE_SIZE #if __x86_64__ \
4096 \
#endif \
#define NYAUX_ARCH_HUGE_PAGE_SIZE #if __x86_64__ \
/*2mib basically*/\
#define \
Yeah
okay
typedef enum {
TINYPAGE = 0,
SMALLERPAGE = 1,
SMALLPAGE = 2,
PAGE = 3,
HUGEPAGE = 4,
humongousPAGE = 5,
GIGTANICPAGE = 6,
cached = 7,
notcached = 8,
} vmmflags;
how about this
Terrible
whats better
Make it a bitmap
wdym
explain
Which I don't plan on explaining
As any other bitmap
Then it's easy
what bit represents what in a bitmap
You define that
how big of a bitmap does it need to be
oh
wait
yea im starting to understand
something like this
wait what about framebuffer @finite summit
like i dont understand how that would work on other archectiures
like say
i did in a bitmap
big page, cached
but its not a framebuffer
what does that mean
like
hold on
okay
sorry my question is
what if u want different types of caching thats archiecture spefic yk
how does that work
You can define an arch specific range of mapping flags
That arch specific functions can use
Rn I'm walking back home from school
different set of arch agnostic flags
that are translated to arch specific actions
iiii
dont understand
im sorry im just really slow
😭
and stupid too
what is there to not understand
finally some code i can read
map(..., flags, page_size, caching)
map then translates flags, psize and cache to arch thingies and does stuff
what if archiectures dont have write_combining
-EINVAL -ENOTSUP
then it's no op
use the default one
okay
wdym default enum
like normal = write_back
normal is a name
ohhh okayyy
enum caching {
uncacheable,
write_through,
write_combining,
write_back,
normal = write_back,
mmio = uncacheable,
framebuffer = write_combining
};
// flags is a unsigned byte
// read | write | exec | user
// uint8_t flags;
Maybe add some namespace to that?
how so
finally some code i can
readcopy
E.g., write_back becomes caching_write_back
yeah there's no enum class in c
all that stuff will end up in the global namespace because of c enums being stupid
if we're bike shedding this enum then maybe have separate caching modes for posted mmio and non-posted mmio
kill meeee
mmio_strong

???
I have never heard of that term
non-posted mmio waits for writes to complete, posted mmio doesn't
im js make everything high level this is basically too much work and i really wanna js write the scheduler already so
flame me all you want its my kernel
it's an osdev group project
x86 doesn't have the distinction but e.g. arm does (device memory with early-write-acknowledge)
and iirc at least on apple silicon for some mmio you have to use a specific type (iirc map pcie mmio as posted?) or you'll get an asynchronous abort when accessing it
I don't have much done with the aarch64 side of the kernel yet
basically nothing, but I will keep that in mind when I get around to it
uncached also works right
on aarch64 no
ah ok
normal memory uncached permits write coalescing and reordering
FINALLY
AFTER LIKE
WHAT
AN HOUR
I GOT IT WORKING CHAT
MY ABSTRACTION WORKS

🔥
LFG
F
why is it stuck

maybe it failed switching to the page map
why???
why didnt it triple fault
bro
hold on more printf debugging fun
lets try this again
like
yea its 0x9000
whats the issue
it got as far as Giving address 0x9000
like
thats literarly it
fucking kill me
it just hangs
doesnt even triple fault
just hangs
well it wouldnt triple fault
idfk
it should work
it works on the vm
why not on real hardware

have you considered zeroing your memory
yes
yes i have
wait
lemme not make ker_map fields uninited at the start
solved absolutely nothing
kill me chat
how tf am i supposed to debug this now
i cant gdb real hardware
it just hangs trying to switch to the pagemap

i genuinely dont know what to do
is it in git
yes
missing gitmodules as usual
oh wait its not missing
yea
its just missing the cc runtime
i even tried randomizing
the memory in qemu with /dev/random
worked fine

@molten grotto if u need any help compiling or have questions just ping me
well can you commit the updated gitmodules file
wait is kernel/cc-runtime a symlink to something
ah now it works
yea
yeah idk, if you haven't figured it out by tomorrow I might take a look again as I am going to go sleep now
okay
didnt find anything
went over the paging code itself
didnt find anything obvious
looks fine
maybe it could also be some kind of framebuffer issue
not really
framebuffer runs fine
under qemu and kvm
and it runs fine up to switching the page tables
korona said theres a possiblity that the page tables could be wrong
not to a point that kvm cares
but to a point real hardware cares
ive been looking up and down the paging code i havent found anything suspicous
and i certinally cannot attach serial to test if its a framebuffer issue
i dont have a serial port on my laptop lmao
make a quick rtl driver + ethernet + ip if it has an rtl card 
lmao
anyway Ill take a look now if I can find anything
I found at least two things (of which the first one is likely unrelated), both your memcpy and memset return wrong pointer and in the code where you map the framebuffer you do ```c
uint64_t page_amount =
align_up(entry->length - disalign, 2097152) / 2097152;
what should i return in my memcpy and memset
the original dest pointer, both rep movsb and rep stosb modify the pointer you give to them
whats wrong with this as well
why do you subtract the disalign from the length
oh
where should i subtract it then
you should add it
understandable
my bad thanks for catching this
okay im adding them now to the length
just switch to my kernel 
It's so stable it doesn't have framebuffer output (totally not because of bad design)
@surreal path please use hex
also constants instead of hardcoded numbers everywhere lol
ik 😭
the code style is also weird
anyways im gonna try this now on my hardware?
will it work?
lets see if it works on a vm first
first kernel to fry a cpu
runs fine on a vm
okay
lemme just push the changes so u can pull them qwinci and ill try them on my laptop hold on
alr time to flash my usb
install limine on your drive
No #1217009725711847465 message
no more need for isos
or if you have two pcs/laptops then pxe
if only mobile discord could properly jump to linked messages
JavaScript reboot
maybe Ill try it on my laptop to see if it has the same issue
alr
literally just ctrl+shift+h
what does that do
it blows your house up
😱
press it in vscode
incredible discovery
@edgy pilot done u happy
no
no
why
at least do
#define MIB(x) (0x100000 * (x))
#define KB 1024ull
#define MB (1024ull * KB)
...
I have that but with constexpr functions
yeah it hangs on my laptop too
at least its repoducable
wow i cannot spell
reproutdanble/
reproduct?
product?
reproducible
@molten grotto did u find anything
wow not even operators :^)
?
""_MB 😋
1_mb?
size_t operator ""_KiB(size_t x) {
return x * 1024;
}
size_t operator ""_MiB(size_t x) {
return x * 1024_KiB;
}```
wow waht di di xo
is that english? :p
what no sleep does to a person
a bad attempt at it, yeah
@molten grotto anything found yet?
what u lookin for
stupid real hardware bug
hangs on switching to page tables on real hardware but kvm and qemu run just fine
read above for more context
fair :)
well we
looked over the paging code, other then a mistake with memcpy and memset and something wrong with the disalign which we fixed and it has solved nothing
still nothing
working

at least the bug is reproducible
thanks for qwinci for teaching me how to spell that word

@surreal path if you don't know if it's actually continuing after switching the pagemap, simply force a hard reset afterwards
if it resets, it works
if it doesn't reset, it doesn't work 
those cpu engineers putting bugs in cpus so nyaux doesn't run on their cpus
wdym
hold the power button?
oh i even put something there
load an invalid idt and divide by zero
it didnt even care
js continues the hang
no triple fault
no thing
js
stuck on switching the page tables
did you actually load an invalid idt so that it wouldn't hit your double fault handler
no idt is valid
then why would it triple fault
oh u want me not to load an idt
yea lemme try that
if it triple faults
not a framebuffer issue
no if it triple faults then it is a framebuffer issue
that means that your code is still running
oh
but can't get to the framebuffer
if it doesnt?
then something else has gone horrifically wrong
i see
you didn't map your framebuffer
no
I'm at school
okay fair
and vmware
I'll send a ball stealer goblin to your house otherwise

you have 3 minutes
runs fine on vbox
change the chipset
okay
we got something
that took so long I thought you were changing the chipset on your mobo :P
??
debuggers are for the weak
look at it better
bruy
bnuy
the hell is a guru mediation
wait
now its doing it the moment i try to load my kernel?
tf?
wow
now i dont know if its vbox or my kernel
wait
its your kernel
i gave the ram 4mb
hold on
it was just the ram
limine couldnt fit my kernel in the ram at 4mb
for some reason
well it runs now
just fine
maybe limine should throw an error message at these really low ram levels or smthin
either way
idfk what to do
time to test the usb
it does
.
weird, just to verify lemme try loading astral at these ram level
if it doesnt throw an error message
not my kernel
anyone got the astral iso rq
found it
so it doenst go into the limine bootloader on astral?
no menu
js straight up says out of memory
but when loading my kernel theres a boot menu but THEN it dies?
astral has abckground
build limine-c-template
okay
oh i just figured it out
it dies trying to init flanterm at 4mb
the video memory is 21mb
so
thats understandable
giving it 1mb of video memory
kinda works
but it seems like i die trying to read my own elf i suppose
which is fine again
so nyaux is fine
so far on vbox
js i dont handle oom very well lol
anyways
im gonna try the usb
hold on
smh you seem to be blaming everything on anything but yourself
that's not very good, especially when programming
no im serious
it even worked fine downstairs on my sisters pc?
tho uacpi cried cause the aml was weird
@kind root do u want to see the errors
for uacpi
like what u want nyaux to run on 4mb, i dont think thats a bug tbh
i know what its crashing
and its my code for not handling oom
thats MY fault
im still blaming myself
in a different way tho
understandable
but again
why isnt nyaux working on my laptop??
but its working on this pc
wtf
screenshot of a photo open in an image vieweer
lol
no not until this bug is gone
boot on my lapto
😭
i booted again into my laptop
same issue
but works fine on the desktop
yea im fuckin ending it all

not only does it work on SOME hardware but not all
but its ONLY on my laptop
so its not even properly reproduicable
fun
how tf does that work
SOME devices the page tables load fine
some devices it hangs
HOW
does that even work
x86 cpus are all the same archiecture
like wtf
is this even a page table issue
what is this
i dont know what to do
i tried getting ubsan enabled
i couldnt get it working
well ksan
which is?
ubsan?
how do i get it working
oh yeah
idk how much thread messages that is anymore
😭
30,841
wtf is this real
30 thousand
im going to eat you
and ur pmos
no more microkernel
vine boom
monolithic kernel >
anyways how to get ubsan to work chat
is there somethign i need to add
or
No I don't know if it's a C++ feature
Yep
some hooks
Feel free to rip this
though this is meant for gcc ubsan
clang has more hooks iirc
then u just add this flag
yes it's called a user defined literal
fun
okay adding them now
ub san doesnt seem difficult ill make for gcc for now
its very easy
okay i finished the functions
ummm
lol???
why is it stuck
???
theres no fault or anything
in the qemu logs
why is it stuck
huh\
hold on ill give u the pastebin or do u prefer github?
what do u prefer?
eitherway
alright
very similar to what u do
does ur kprintf require setup
its possible there is ub before its setup
id recommend hooking it straight to serial
kk
oh my god
its mostly complaining about flanterm
@silver yarrow how can i make ubsan ignore flanterm
stop giving flanterm misaligned addresses
when did i give it a misaligned address
i gave it the framebuffer addres
that shouldnt be misaligned
thats literarly what i do @kind root
idk where it gets the addresses from
from limine