#Nyaux
1 messages Β· Page 3 of 1
probably
actually
use liballoc
lib alloc?
allocator library (in C) made to be easily portable
cant import it cause my pmm doesnt alloc physically continigous pages and my vmm relys on the slab
i use liballoc and use my vmm to allocate virtually contiguous pages to map physically separate pages
Yuck! Virtual Memory.
booo
my vmm relys on the slab
allocator
β οΈ
yea and that relys on the slab to make the heckin
vmm region struct
heres my virtual memory allocator
sorry i have school rn
which is why
i didnt do anything yet
when i come back from school ill keep researching about slab allocators so i can implment one that DOESNT fault
Is this turning into obos thread
?
maybe π
i just fell asleep watching a lecture about slabs
and slept for
3 hours
nah thats crazy
a slab allocator works like this
you have a cache that has a pointer to the current slab being used, a list of slabs that are full and list of slabs that arent full but arent empty either.
when we run out of memory on a slab we switch to ones that are in the partial list, if there arent any then we allocate a new one to switch to.
in linux the kmalloc function is implmented by having caches from the pow2
I think linux doesnβt only have pow2 caches
But yeah thatβd be easiest to implement
yea
i guess the next thing to do
is to start implmenting this now
i think i understand it to a point
i can implment it
iirc the generic kmalloc ones are pow2
I donβt know about the others but slub defines non pow2 ones too, and this becomes apparent when cat-ing /proc/slabinfo
Theres like 192 byte generic ones
(For specific slabs like dentries there are more specific sizes too)
yup, couldnt check
not particularly

u tell me how to make it kawaii then
mr know it all
π
get to full userspace, implement a gui and plaster a random anime wallpaper on it?
hmm

yeah memeing the kernel log, or using trash variable names is just you making fun of yourself at your own expense
reminds me of my first kernel like 4 years ago
I had the same type of logs but on vga
i make fun of myself all the time
!!!
lmao
idk man this is just sad
fine ill revert it
you should respect your work more
look i reverted it u happy?
my work is shit
cause my code is shit !
yes im very happy because your kernel now uses ok instead of whatever shit it was before
yes great
ok im gonna work on slab
as long as you treat it like shit it will stay that way
fine i wont
i will treat it like amazing
no just treat it as a reflection of yourself, and actually put in effort to make it look good
then it will be good
okay
anyways i feel like store size in header as well
idk
im just thinking of like
how itll work when freeing and allocing
i think this looks correct
header is 16 bytes
do i even need to size + sizeof(struct pmm_node)
why am i even doing that
yea i dont think i need to do that
that just wastes space
lmao
we can fit 510 objects in the page
cool
i think this is valid?
okay
i feel so scared typing each line of code
i feel like im gonna instant fuck up the page or something
lmao
okay
i think this is good
Looks good
think this looks good
No idea
Add an if addr == 0 return
yea fair
well it seems to work
keyword
seems
Lmao

Because that would mean you're better than oberrow
dangling namespace node?
huh
then it page faults
in nano printf
Yeah im sorry it didn't survive 
TELL ME WHAT DANGLING NAMESPACE NODE MEANS

Its unrelated
why so many memory allocator skill issues recently
The memory is corrupted
literally just use liballoc if u cant write your own
no π
corrupted?
Yes
it means the namespace node points to nowhere
Either you allocated more, or allocated less, or returned the same block twice, or freed it early
lemme look
oh cause it tries to allocate 2
Also enable debug uACPI log for better tracing
how
In the init replace trace with debug
I would also recommend printfs to trace what memory you're returning
i dont fkn know whats wrong 
everything looks right
The oberrow curse is upon you now

im trying to think
I GIVE IT CORRECT MEMORY WHY IS IT FKN DANGLING
π
I dont see u logging any addresses
ok wait
THEY LOOK VALID
like wtf
and it page faults in nano printf???? like sorry wtf is going on
Yeah that probably means you're trashing the memory from somewhere
trashing?
Overwriting
when i free i dont memzero
is that a problem
should i memzero the memory before i like
yk
i also dont memzero
when i give the block
@kind root
do i need to memzero?
Yes
man π
void *I_have_no_self_respect
Lol
I MEMZERO'D AND I GOT CLOSER
probs cause the cache i gave was 051i20958190258190285019285125

so bro requested 528
wtf is going on

Round up to next power of two?
Yup
got closer and now it page faults in h->freelist = him->next;

loool
ummm
why is the memory address 30000000
why tf
I DONT FUCKING KNOW
WHY THE ADDRESS IS 30000000

why is it pointing
to 3000000
why
fuck me
why
NO ONE IS OVERWRITING THE HEADER
ITS CORRECT
SO WHY IS IT GETTING tHIS STUPID NUMBER

WHY IN THE WHY
void init_cache(struct cache *cache, size_t size)
{
char shit[64] = "";
cache->size = size;
void *page = pmm_alloc_singlep();
struct Header *h = page + hhdm_request.response->offset;
h->size = size;
cache->slabs = (uint64_t)h;
size_t obj_amount = (4096 - sizeof(struct Header)) / (size);
write_color(ctx, "Slab: Creating Cache of Object Count: ", 0);
write(ctx, itoa(shit, obj_amount));
write(ctx, " and Size: ");
write(ctx, itoa(shit, size));
write(ctx, "\n");
struct pmm_node *start = (uint64_t)h + sizeof(struct Header);
h->freelist = start;
struct pmm_node *prev = start;
for (int i = 1; i < obj_amount; i++)
{
struct pmm_node *new = (uint64_t)start + (i * size);
prev->next = new;
prev = new;
}
write_color(ctx, "Slab: Cache Created!\n", 0);
}
struct Header *make_slab(size_t size)
{
void *page = pmm_alloc_singlep();
struct Header *h = page + hhdm_request.response->offset;
h->size = size;
size_t obj_amount = (4096 - sizeof(struct Header)) / (size);
struct pmm_node *start = (uint64_t)h + sizeof(struct Header);
h->freelist = start;
struct pmm_node *prev = start;
for (int i = 1; i < obj_amount; i++)
{
struct pmm_node *new = (uint64_t)start + (i * size);
prev->next = new;
prev = new;
}
return h;
}
like i create the caches correctly
i allocate and free everything correctly
so why is bro pointing to address 3000000
its not from the free function thats causing this
triple checked
not from the making of a new slab either
gotcha
i got u now
interesting
oh wait
itoah
not itoa
struct Header *make_slab(size_t size)
{
char shit[64] = "";
void *page = pmm_alloc_singlep();
struct Header *h = page + hhdm_request.response->offset;
h->size = size;
size_t obj_amount = (4096 - sizeof(struct Header)) / (size);
struct pmm_node *start = (uint64_t)h + sizeof(struct Header);
h->freelist = start;
struct pmm_node *prev = start;
for (int i = 1; i < obj_amount; i++)
{
struct pmm_node *new = (uint64_t)start + (i * size);
prev->next = new;
prev = new;
}
return h;
}
somethings wrong in this function
the page is valid
dumped the addresses
all valid
I SOLVED IT BUT NOW I TRIPLE FAULT 
wtf
guys new address just dropped!
!!!
this is weird
it general protection faulted here
tf
@finite summit i understand how u feel now
this is straight up
torture

This thread is like my prison
and Iβm yapping to the cell wall
WHY R U POINTING THERE
π
STILL
HOW DOES IT EVEN GET THIS ADDRESS
This is worse than what happened to me
Actually debatable
its worse
i have prints every where
i cant figure out
where its getting this address
im dying
omar help me
this is pain
i cant find
this stupid issue
where is it making up this address
sudo pacman -S gdb
π
> gdb kernel
> target remote :1234
> breakpoint slab_alloc
> c
wont help me find where it made up the address
okay wiat
wait
It'll help more than with prints
not really
since slab_alloc is getitng called
thousands of times
by uacpi
i cant really find the instance where it gets this fake ah address
what the fuckkkk
do the register values looked fucked
i dont know why this is happening
cccccccccccd
cccccccccccd
based ass value ngl
fr
to the point its driving me insane!
at this point i dont know what to do
i've printed every address
everything
oh?
wtf
okay so its attempting to free memory that seems to have corrupted our header
i dont do anything but somehow this is um
i dont know
https://pastebin.com/ZnhNiWZq this is the slab code i guess
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
maybe one of you guys spot something i didnt idk
im going to sleep i have school trrw
@surreal path Take a look into this test function I made for allocators to allow to track the allocation easier
All you'd need to do is break when i == (the allocation that crashes' index) and see what it does
Hell yeah, another completely failing allocator : )
hey π‘
itβs not my fault
My code is simply so pro π
im in hell
im in hell help me
i even brung my laptop to school
to keep trying to debug the code
I STILL CANNOT FIND IT

i dont get why tf
and my teacher kept asking
me
"did u find the issue yet"
β οΈ
something i dont know
i think
but i cannot find the issue in my code
Debug the exact location of WHERE memory is WHEN corrupted
You could try finding out where and then watch that address with gdb
okay sure
ill tell u the output
why do not just use printfs (or whatever) to get the values to see if they are what you expect and use infinite loops to find where it crashes
okay back
im watching the value
hm
yea
itsa pointer
it seems it is a pointer to a value in your table so no
as in the pointer is created on the stack
yes that is not relevant
yea okay
so where is it crashing?
somewhere in the slab freelist, its pointing to some non-canoical address
this specfic value 2-smthin i dont have the value in my clipboard but its a value that doesnt make sense, its the same value that causes the crash
every run
Do you have an assert macro
the stack trace looks like this
backtrack until you find a good value
?
no the problem is it shouldnt be pointing to this
it makes zero sense
it is a macro which prints the line number of where it is used on a certain condition
okay and why do i need this?
To make sure everything is going fine and so you can know when and where something goes wrong
I have a bunch of them around my slab implementation and it has saved me a lot of headaches before
that is just pointing tape on the issue
putting*
not fixing it
something is causing this value
someone is like overwritting something where they shouldnt
@kind root its probs memory corruption right?
yea
if it does not work it is because you are doing something wrong
but like ive read through the damn slab allocator code a billion times i dont see the issue where it could be overrwriting something
i mean clearly
well look harder
I AM 
it took oberrow two weeks
Have you written userspace test @surreal path
no
i dont know how to do that
You copy everything you did
But malloc on some big array
Instead of your physical memory
wha
In your kernels allocator you operate on your ram
In your userspace testing program you do everything the same but just operate on fake ram / an array
i printed every fkn address new slab creates
all valid
it HAS to be some kind of memory fuckery
Are you writing to the allocated blocks
wdym
Are you writing to the blocks returned by kmalloc
uacpi is yea of course
You should try to reproduce your allocator in userspace
If you provide it as a standalone program iβd even like to test it
Yes but youre doing the work behind the allocations
void *uacpi_kernel_alloc(uacpi_size size)
{
char shit[64] = "";
if (size < 1024)
{
return kmalloc(size);
}
else
{
return vmm_region_alloc(align_up(size, 4096), NYA_OS_VMM_PRESENT | NYA_OS_VMM_RW);
}
}
void *uacpi_kernel_calloc(uacpi_size count, uacpi_size size)
{
char shit[64] = "";
if (count * size < 1024)
{
void *man = kmalloc(count * size);
memset(man, 0, count * size);
return man;
}
else
{
return vmm_region_alloc(align_up(count * size, 4096), NYA_OS_VMM_PRESENT | NYA_OS_VMM_RW);
}
}
just letting u know that i do memset the allocations when uacpi calls calloc as required
yea
ill try to make a userspace program of my slab allocator i suppose
You can run both uACPI and your allocator in userspace
Oberrow did that and found the bug almost instantly
Wdym
how does it load the acpi tables if its in ring3
You give it the blob with a virtual address
Look at my tests
Tests_runner.cpp
And interface_impl.cpp
Uacpi itself doesnt do anything kernel specific afaik
Only your api functions do
So you just βfakeβ them
Do you have userspace tests for like acpi events and whatever stuff there is too
Uh no because that needs interrupts
what do i return when i want to allocate a page
But I have bytecode tests of course
do i just malloc(4096) or somethin
lol
was my printf statements
okay so it loads
okay how do i setup uacpi to test @kind root
look into the uacpi repo into tests ig?
Np
im trying to compile this but like its saying the functions i made dont exist even tho i add the slab.c to the cmakelists thing
i import the header as well
No idea
if the functions are written in C++, do you use extern "C" or not?
they arent c++, slab.c is C code
maybe the compiler is compiling that as C++
how are you differetiating the compiler between different extension source files?
gcc compiles as C++ by default, it is just that in most cases C code is valid C++ code
no it isnt
unless you specify the -x c flag the compiler compiles code as C++
ah
seems you do see the code as C. But maybe you have not passed the flag
even tried
can you upload to github the test code and share a link?
you are not passing the -x c flag again
what compiler are you using? g++?
im using cmake
i dont know what compiler its using
cmake is not a compiler
i know
you should use gcc for C files (-x c flag) and g++ for C++ files (gcc can be used for C++ too)
see how to specify a compiler
(I have no idea how cmake works)
can you share the github repo?
okay
I FIXED IT
ummm
@kind root what does this mean
how did you fix it?
extern "C"
{
#include "slab.h
}
that should tell you you have serious build problems
oh yeah forgot to init slabs
how im getting the header in kfree?
so how im getting the header
thats removing the 12 bit page offset tho?
???
=================================================================
==949491==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000005000 at pc 0x5578c1810218 bp 0x7ffe8e9bed10 sp 0x7ffe8e9bed00
READ of size 8 at 0x621000005000 thread T0
#0 0x5578c1810217 in kfree /home/rayan/Programming/fard/uACPI/tests/runner/slab.c:109
#1 0x5578c17a4103 in uacpi_kernel_free /home/rayan/Programming/fard/uACPI/tests/runner/interface_impl.cpp:226
#2 0x5578c188f42e in uacpi_free_resources /home/rayan/Programming/fard/uACPI/source/resources.c:2018
#3 0x5578c17c77ab in run_resource_tests() /home/rayan/Programming/fard/uACPI/tests/runner/resource_tests.cpp:2226
#4 0x5578c179a016 in main /home/rayan/Programming/fard/uACPI/tests/runner/test_runner.cpp:181
#5 0x7f0a14752d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#6 0x7f0a14752e3f in __libc_start_main_impl ../csu/libc-start.c:392
#7 0x5578c1797244 in _start (/home/rayan/Programming/fard/uACPI/tests/runner/test-runner+0x146244)
0x621000005000 is located 256 bytes to the left of 4096-byte region [0x621000005100,0x621000006100)
allocated by thread T0 here:
#0 0x7f0a1536e887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x5578c180ef98 in init_cache /home/rayan/Programming/fard/uACPI/tests/runner/slab.c:8
#2 0x5578c1810983 in init_slabs /home/rayan/Programming/fard/uACPI/tests/runner/slab.c:164
#3 0x5578c179a011 in main /home/rayan/Programming/fard/uACPI/tests/runner/test_runner.cpp:180
#4 0x7f0a14752d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/rayan/Programming/fard/uACPI/tests/runner/slab.c:109 in kfree
dont understand what any of this means
Read
heap buffer overflow on address 0x621000005000
0x621000005000 is located 256 bytes to the left of 4096-byte region
if (kmalloc_cache[i].size == h->size)
Yes
struct Header *h = (uint64_t)addr & ~0xFFF;
struct cache *rightcache = NULL;
for (int i = 0; i < 8; i++)
{
if (kmalloc_cache[i].size == h->size)
{
rightcache = &kmalloc_cache[i];
}
}
Debug it
idk if we're debugging the same thing
i have spent the past 2 days trying to figure out why the Vinix slab allocator don't worky
relatable !
the Vinix slab is very similar to the Lyre slab so if you took inspiration from either of those, i am so sorry for you
i came up with this design without looking at the lyre source code, i think r4 told me about this design of like having a header at the start of the page and shit and i just implmented that
idk
no it was qwinci
yeah we do the same
we as in Lyre and Vinix collectively
i need to shelve Lyre because honestly keeping track of 2 mostly-the-same-but-sometimes-a-bit-different OSes gets confusing
Which one do u like more, the one made in the funny V language, or the one made in the funny C language

Vinix
why so?
Lyre was translated for the most part from V to C and not by me, so there are certain copying mistakes and sometimes design alterations which make it hard for me to approach it
meanwhile Vinix is mostly made solely by me
the only things that aren't are segregated into driver code for specific shit and not much else in the way of design or other core stuff
ah okay
well anyway time to spend the next 24 hours of my life trying to figure out why tf addr & ~0xFFF no worky

if i figure anything out i'll let you know
understandable
this bug gives me a brain tumor
btw, a tangential point, but if you take prejudice against V out of the picture, V is a really comfy language for writing a kernel in
at least to me
Was addr aligned in the first place?
is addr 64 bit
not saying you should use it or anything of course, just reporting my experience with the funny
language

yes
how so?
I might give V a try
been wanting to code in something different for a bit now
i do (uint64_t) addr & ~0xFFF
but every language out there has some stuff that C just does better
it has less clutter than C and a lot of things are baked into the language like dynamic arrays and hashmaps
0xfff needs to be 64 bit
btw if you use V for osdev though keep in mind that you need to beat it into submission a bit
it's not very plug-and-play
@surreal path why are you still in voice 0?
cause i like to be in vc
i am alone π
0xFFFUL?
I see, I might give it a try later and look more into it's syntax
yeah
btw for me
the problems really only show up if i free the slab allocations
and the funny part is that the corruption garbage written seems to come from a page frame allocator free
which doesn't really check out in any obvious way
is it the same for you?
the issue only really showed up
when i took uacpi and my slab allocator to userspace
and ran the test
which showed
that kfree
is the issue
which like doesnt make any sense
what is kfree?
it just doesnt make any sense like at all
function for freeing address back into the correct cache slab freelist
do you trash the memory on free?
because for me, even if i do, it still works, as long as i don't try to readd the page to the slab linked list
deallocate? no i dont deallocate it i just put it back into the freelist atm
as in
overwrite with 0xaa or some random garbage
to catch use-after-free and friends
no
try doing it
in your kfree
without actually "freeing" the allocation back to the slab allocator linked list
i keep saying page
i mean allocation
so just overwrite the address or the header?
like
overwrite whatever is written at the allocation that you're trying to free
say X tells you to free count bytes at ptr, then memset(ptr, 0xaa, count) before actually freeing the allocation
but don't actually free it
i wanna see if that works for you as well
because if it does we may literally have the same bug which would be kinda funny
i did that and like it didnt care until i wanted to try getting the header
it would
odd
Once I thought I had a slab bug but it turned out to be in my pmm because I used a 32 bit int somewhere instead of a 64 bit onw
That was fun to debug
i don't think my pmm is wrong because using it instead of the slab as the kernel allocator makes everything workβ’οΈ (at least in appearence)
the problem really just arises when using the slab allocator, and only when freeing
same lol
same
yup
yea
unless you go and formally verify everything
wdym?
I funnily implemented a slab allocator a few days back becuase I wanted to prove to myself that my idea of allocating at pow2round_up(size) alignment was actually sensible
It's not guaranteed to be page aligned if you use malloc
well I broke it so much that I implemented a "sanitizer" for debugging
oh
you can use mmap to emulate the pmm
okay
There's memalign
mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, -1) boom a page :^)
or just malloc more than you need and then cut off a bit at the front
ok printing out the slab addresses that i get from the slab header on free, they seem to check out
sadly
dumb question but where do both of you put the slab header? at the front of the slab itself?
I put mine at the top of the page because Im special
beginning of page
beginning of page
basically the first chunk of the slab is allocated to a pointer to the thing
I decided to steal get inspired by linux idea of a struct page array
works surprisingly great
I can put whatever metadata I want in the page struct
and depending on what it is used at put something else there
thus not needing seperate headers or whatever
I do something like that mostly so I can do some sillier vmm memes in the future
oh oops -1, 0 not 0, -1
0xffffffffffffffff is MAP_FAILED
(because NULL is technically a valid return value)
U didn't run any aml
how to do that
This is basic resource tests
It does
ls
Yeah thats not a leak
??
SO ITS NOT MY SLAB ALLOCATOR HMM?
It is
it didnt crash
Idk what you did in particular, also wsl aml is tiny
what am i supposed to do
Or actually maybe you leaked your own data somehow idk
Because those are not uACPI leaks
Try dumping your pc aml
from windows run the same command
okay
Just download it first
kk
Are you actually freeing stuff
could dump the qemu aml
Or did you comment that out
since that's what nyaos is running on
Yeah its harder tho
Maybe oberrow still has that dump
feed the dst?
Yup
Uhhh this trace looks like itβs calling normal malloc, not your allocator?
for allocations bigger then 1024
Oh ok
Does uacpi maybe have alignment requirements for that?
Nope
Looks like it works
SEEEE
But im not sure how u get leaks
Its very strange
You sure you're not doing anything strange?
all leaks are coming from asan
no
i can give u the code if u want to try it urself
Run this blob against the vanilla test runner
oka
Any leaks?
no leaks
its because i dont deallocate the memory when im done with them
So u dont free?
i put it back into the slab freelist so its "free"
but i never deallocate a slab or anything
Hmm
Well then the bug is in your handling of bigger than 1024 bytes
Try making huge slabs
how big
How do u handle them in your kernel
if bigger than 1024 then i align it up to a page and allocate
That logic is probably bugged
my vmm?
Probably somewhere in that neighborhood
Try it
yeah so if that still works then the bug is in your vmm
same amount of leaks
so my slab allocator has been perfect the whole time
if it survives this then probably
what the actual fuck
so i have been debugging the wrong shit for 2 DAYS
2 FUCKING DAYS
β οΈ
port vmm to userspace
how is that even gonna work
oberrow did that

so is like the vmm somehow corrupting the slab memory or smthin
who knows
how tf does that work
what exactly does your vmm do
allocates a region of virtual memory space, maps x pages to it. returns the base of this region
how does it allocate
if it finds a gap between 2 memory regions that is large enough to fit the region
it sets that up
sounds error prone
How do you track allocated regions
simple freelist
struct vmm_region
{
uint64_t base;
uint64_t length;
uint8_t flags;
struct vmm_region *next;
};
void vmm_region_setup(uint64_t hhdm_pages)
{
size_t kernel_size_in_bytes = (size_t)THE_REAL;
kernel_size_in_bytes = align_up(kernel_size_in_bytes, 4096);
struct vmm_region *node = kmalloc(sizeof(struct vmm_region));
node->base = hhdm_request.response->offset;
node->length = hhdm_pages;
node->flags = NYA_OS_VMM_PRESENT | NYA_OS_VMM_RW;
vmm_head = node;
struct vmm_region *kernel_region = kmalloc(sizeof(struct vmm_region));
kernel_region->base = addr_request.response->virtual_base;
kernel_region->length = THE_REAL;
node->next = kernel_region;
// Regions:
// ------- -------
// - HHDM - - KERNEL -
// ------- -------
// - - - - - - - - - - - - - - ^
// next
serial_print_color("VMM Regions Init!\n", 1);
vmm_region_walk();
}
region gets setup like this
void *vmm_region_alloc(uint64_t size, uint8_t flags)
{
char shit[64] = "";
struct vmm_region *cur_node = vmm_head;
struct vmm_region *prev_node = NULL;
while (cur_node != NULL)
{
// ASSUME REGIONS IN ORDER CAUSE WE COOL :sunglasses:
if (prev_node == NULL)
{
prev_node = cur_node;
cur_node = cur_node->next;
continue;
}
if ((cur_node->base - (prev_node->base + prev_node->length)) >= align_up(size, 4096) + 0x1000)
{
struct vmm_region *new_guy = kmalloc(sizeof(struct vmm_region));
new_guy->base = (prev_node->base + prev_node->length);
new_guy->length = size;
prev_node->next = new_guy;
new_guy->next = cur_node;
cur_node = cur_node->next;
int num_of_pages = align_up(size, 4096) / 4096; // num of pages to alloc :sunglasses:
for (int i = 0; i < num_of_pages; i++)
{
map((uint64_t)pml4 + hhdm_request.response->offset, new_guy->base + (i * 0x1000), pmm_alloc_singlep(), flags);
}
return new_guy->base;
}
else
{
// not enough space for our new region sadly, continue
prev_node = cur_node;
cur_node = cur_node->next;
continue;
}
}
// STILL HERE?
// PANIC CAUSE NO REGIONS CAN FIT VMM REGION WOWIE!
write_color(ctx, "No Free Virtual Address Regions!\n", 4);
asm ("cli");
for (;;)
{
asm ("hlt");
}
}
allocation works like this
Should I be questioning THE_REAL
gotten from the linker script
SECTIONS
{
/* We wanna be placed in the topmost 2GiB of the address space, for optimisations */
/* and because that is what the Limine spec mandates. */
/* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
/* that is the beginning of the region. */
. = 0xffffffff80000000;
AMONG_US = .;
.text : {
*(.text .text.*)
} :text
/* Move to the next memory page for .rodata */
. += CONSTANT(MAXPAGESIZE);
.rodata : {
*(.rodata .rodata.*)
} :rodata
/* Move to the next memory page for .data */
. += CONSTANT(MAXPAGESIZE);
.data : {
*(.data .data.*)
} :data
/* Dynamic section for relocations, both in its own PHDR and inside data PHDR */
.dynamic : {
*(.dynamic)
} :data :dynamic
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
/* unnecessary zeros will be written to the binary. */
/* If you need, for example, .init_array and .fini_array, those should be placed */
/* above this. */
.bss : {
*(.bss .bss.*)
*(COMMON)
} :data
/* Discard .note.* and .eh_frame since they may cause issues on some hosts. */
/DISCARD/ : {
*(.eh_frame)
*(.note .note.*)
}
THE_REAL = . - AMONG_US;
}
These naming conventions should be prosecuted
Calling anything in your codebase AMONG_US is just criminal
#ihavenoselfrespect
Thats kinda sussy
Lol at least your self aware
Remorse is the first step to becoming a better human
Comment out and find out
still same issue
Unlucky
wait no
njow its faulting here?
gpr'd here???
but theres no invalid address here
oh
now thats getting fucked
@kind root wtf
Idk
A bug
yes but
why is memory getting so corrupted
the slab allocator was proven to work in userspace
why are you trying to initialize the char array?
yea fair but it doesnt make a difference either way
and what is itoah? Is not it just an integer to ascii? What is that h
its still not the issue
someone is fucking my memory
rbx has the weird ass address
i dont know what to do anymore
i tested the slab allocator in userspace it worked, i dont know whats ruining my memory
unitialized values?
if you do not zero everything, then instead of getting value zero and failing the if nulls it uses garbage values
that's my guess
so should i memzero my memory before i "free it"
I am specifically talking about the memory where the allocator variables are stored
what you should do is bring in managarm/frigg, and have one c++ file to use frg::slab_pool and expose it to the rest of the kernel :^)
i dont want to use someone elses allocator
if theres something wrong with the code then its my fault and i should keep trying til i fix it
im really at a deadend here
yeah i'm joking
yea i know
Add more printfs
i did
Not enough
Then you would see where it goes wrong
Im not talking about slabs
Other components as well
sure
actually, i just remembered
an even better method for emulating mapping memory
memfd for allocating physical pages, mmap to map them into the address space
(replace memfd with tmpfs files if you really want to)
every single region vmm makes
all look valid
i dont know what to do anymore this is pain 
advancement made! oberrow hell
that means it's not the allocator
and btw it did
It's probably the VMM
Does your VMM have an interdependecy on the allocator
if it does that might be your problem
kinda
ye
why would that be a problem
Because
infinite recursion if no space could be found for all regions
rather caches
in the allocator
i check if theres no space
and i just halt
and error out
oh you mean the caches
yes
Then that shouldn't be your problem then
yea
I have.
i dont zero memory when i free
i only zero memory on calloc
as uacpi says to do
okay
don't paste the output
what about all the null dereferences
if a cache isnt inited
some undefined things will happen
thats what these are saying basically
all these null dereferences are if a cache ISNT inited
but i always init them
so this isnt the problem
what if a cache has some garbage memory address because you never zeroed it
or some slab in the cache
will i zero memory i free then?
so zero my slabs before i use them?
yes
alr
WAIT THAT COULD ACTUALLY BE THE ISSUE!!!
WAIT
WAIT WAIT WAIT
IM GONNA TEST THIS
NO MORE GARBAGE MEMORY ADDRESSES?
LETS GO!
but now
it page faults here
definitely allocator issue
If an allocator works in userspace but not in kernel mode
probably an issue with zeroed memory
???
wait i dont memzero when i allocate with the vmm
You sure large allocations are zeroes as well?
could that be also an issue?
Yup
Yes
Well partially unimplemented uACPI
Also you dont call namespace initialize last time I checked
i am
Ok
LOOK
@kind root @kind root @kind root @kind root @kind root @kind root @kind root @kind root
(ping spam) Possible spam detected for user: linuxmaster2.0. Please contact a moderator to be unmuted.
um why is he timed out
spam
ah nvm im an idiot
You're welcome
Lets see who's the next to be put into oberrow hell
π π
bro gonna torture the next osdev
also our vmm_free function seems to be broken
lemme fix it
ah yes our
our
communism in NyaOS confirmed

the page
could have something to do with the analyzer
warnings
Check if it says anything in the vmm_free function'
do you intend to set freelist to him->next
void vmm_region_dealloc(uint64_t base)
{
char shit[64];
struct vmm_region *cur_node = vmm_head; // find prev node and node after it
struct vmm_region *prev_prev_node;
while(cur_node != NULL)
{
if (cur_node->base == base)
{
if (cur_node->next)
{
prev_prev_node->next = cur_node->next;
}
int num_of_pages = align_up(cur_node->length, 4096) / 4096;
for (int i = 0; i < num_of_pages; i++)
{
uint64_t phys = unmap((uint64_t)pml4 + hhdm_request.response->offset, cur_node->base + (i * 0x1000));
pmm_free_singlep((uint64_t)phys + hhdm_request.response->offset);;
}
free(cur_node);
return;
}
else
{
prev_prev_node = cur_node;
cur_node = cur_node->next;
continue;
}
}
// REGION DOESNT EXIST WOWIE!
write_color(ctx, "Region Provided doesn't exist!\n", 4);
asm ("cli");
for (;;)
{
asm ("hlt");
}
}
yep
page fault happened there cause of same noncanoical address issue due to
vmm_region_dealloc
So are allocator bugs just called oberrow hell now
π
His was a simple bug though
took me 3 days
Yes
just goota fix this vmm bug