#Nyaux
1 messages ยท Page 27 of 1
Lmao
He is using C now
I need to know the first exception that was part of the triple fault, not the last one
Also you cropped off all the useful info like the error code
im using C
bro i got sick of the UB
it's easier to cause UB in C lol
rust basically says "uphold normal safe rust guarantees in ur unsafe code (keep it "sound")"
no bro
the llvm compiler
fucking hated me
what
i prefer sis <3
bro i did everything correct
np
yet the compiler still threw some ub in uacpi or smthin idfk
im not debugging that
im sick of that
rust skill issue
idc
ffi safety is a thing but rustc doesn't compile uacpi :3
ffi safety: don't pass invalid values through ffi
more likely the issues were just caused by you using rust like it was c and some other random unrelated issues
anyway yeah you are probably better doing it in c
surely if i cast everything to references it's safe rust :clueless:
wtf
lol
sir
what
no
tf u on about ๐ญ
okay so
whatever is going on
its happening here
no that takes too much ram
oh yeah im dumb dumb
wait no
im not
tf is going on
๐ญ ?
how did bro 0xd with this
i saw that
๐ก
oki i will slow down qemu
and see
now it suddenly works
huh?
TF???
it only works when i print it
bro tf is the compiler doing
bro
now C UB
fucking hell
am i a bad programmer
result pmm_init() {
spinlock_lock(&pmmlock);
volatile pnode *cur = &head;
result ok = {.type = ERR, .err_msg = "pmm_init() failed"};
kprintf("pmm_init(): entry count %d\n", memmap_request.response->entry_count);
kprintf("%s(): The HHDM is 0x%lx\n", __FUNCTION__,
hhdm_request.response->offset);
for (uint64_t i = 0; i < memmap_request.response->entry_count; i++) {
struct limine_memmap_entry *entry = memmap_request.response->entries[i];
switch (entry->type) {
case LIMINE_MEMMAP_USABLE:
for (uint64_t i = 0; i < entry->length; i += 4096) {
volatile pnode *hi =
(pnode *)(entry->base + i + hhdm_request.response->offset);
cur->next = (struct pnode *)hi;
cur = hi;
}
break;
}
}
kprintf("FreeList Created\n");
kprintf("Free Pages %ju\n", get_free_pages());
spinlock_unlock(&pmmlock);
ok.type = OKAY;
ok.okay = true;
return ok;
}
uint64_t get_free_pages() {
pnode *cur = &head;
uint64_t page = 0;
while (cur != NULL) {
page += 1;
cur = (pnode *)cur->next;
};
return page;
}
i dont understand
whats wrong with my code

this SHOULD work
all the addresses looked fine when i PRINTED them
but when i dont print them
fucking 0xd with some weird ah cr2
what is the compiler doing
bro

the compiler is doing what u told it
uint64_t get_free_pages() {
pnode *cur = &head;
uint64_t page = 0;
while (cur != NULL) {
page += 1;
cur = (pnode *)cur->next;
};
return page;
}
it 0xd'd here
CR2=8948fffffb58858b
that shouldnt happen how tf am i making a weird ah address
like wtf?

what is head
0x0 initally
which is what i set it to
NULL
oh wait
wait
wait
wait
wait
Possible spam detected for user: linuxmaster2.0. Please contact a moderator to be unmuted.
.!unmute @surreal path
Permission Error
You must have MODERATE_MEMBERS to execute this command.
.!unmute @surreal path
@surreal path is not muted.
qwinci beat you to it
@surreal path you are unmuted now
same skill issue
do u have warnings enabled
thats not warnigns enabled
-Wall -Wextra -Wpedantic
okay
i only got this
and this
so um
yea
tf going on

these how i compile
noooo ?
look
sec
wait
u mean
memzero right @kind root
i dont mean anything particular
u were right
look
!!!!
i forgot to memset by stuff
so happy :)
i love C
C :)
pmm done
this good?
0xb?
yea ๐ญ
where???
imagine
Just have uACPI in userspace 
lol
Why did you need ACPI at that stage in first place?
dw
heap stress test
:)
very few people know u in uACPI means userspace

I mean the interface is basically POSIX
close
It was easy to plug in
i always thought the u meant universal
in my head canon it's ฮผ
to do what
i thought it was UltraOS
like how LAI was the LUX ACPI implementation
didnt know that
i thought you were an osdev old server veteran
i was there probably before lux was a thing
hmm, good question, i dont remember
i think i was curious about acpi and how complex it seemed
2019 was when omarx exited the community it seems
hmm
it just means u
there is no special meaning

who knows maybe thats true
It's ultra
that's just called depression
C ub is only a problem when the compiler leverages it unexpectedly for optimizations
imo
ahem ahem
strict aliasing
ahem ahem
joys of using C
indeed
@thorn bramble i just realized i found a bug within old nyauxkt when reading the code about the page tables
i solved them in my C version now
im doing a similar implementation cause i think it was good
i might use a linked list for the vmm regions this time
but um
yea
bug found
bug squashed
yippie
also btw
you shouldnt do this check when mapping a 2mb page
right?
cause like
that would NEVER happen
am i correct
cause its only on like page level 2 (0, 1, 2, 3)
that happens
! is not bitwise not in C
it may have happened to me
congrats!!!
i nap some more then we work on nyaux, i have page table shit mostly done i just need to write a function to setup a kernel pagemap and switch to such pagemap
then its vmm regions
then uacpi to test the heap
then scheduling straight away
bro what 
tf are u on about
does anyone know how to fix this???
this shouldnt be happening?
a function to invlpg in a separate asm file
what I have is just a bunch of instructions in one file
I have out* and in* for port manip
getCR*
getEFER
getDR6 (idk what happened with the other debug regs
cpuid
*msr
pause
invlpg
wbinvd
xsave
cli
sti
hlt
ugh fine
check_exception old: 0xffffffff new 0xe
133: v=0e e=0010 i=0 cpl=0 IP=0028:ffffffff8000e1c7 pc=ffffffff8000e1c7 SP=0030:ffff800006683f98 CR2=ffffffff8000e1c7
RIP=ffffffff8000e1c7 RFL=00000082 [--S----] CPL=0 II=0 A20=1 SMM=0 HLT=0
CR0=80010011 CR2=ffffffff8000e1c7 CR3=0000000000008000 CR4=00000020
check_exception old: 0xe new 0xe
134: v=08 e=0000 i=0 cpl=0 IP=0028:ffffffff8000e1c7 pc=ffffffff8000e1c7 SP=0030:ffff800006683f98 env->regs[R_EAX]=000000000000000d
RIP=ffffffff8000e1c7 RFL=00000082 [--S----] CPL=0 II=0 A20=1 SMM=0 HLT=0
CR0=80010011 CR2=ffffffff800e9ba0 CR3=0000000000008000 CR4=00000020
check_exception old: 0x8 new 0xe
fun
when switching to the new pagemap
this happens
!!!!!
void map(uint64_t *pt, uint64_t phys, uint64_t virt, uint64_t flags) {
uint64_t *f = find_pte_and_allocate(pt, virt);
*f = phys | flags;
}
uint64_t *find_pte_and_allocate(uint64_t *pt, uint64_t virt) {
uint64_t shift = 48;
for (int i = 0; i < 4; i++) {
shift -= 9;
uint64_t idx = (virt >> shift) & 0x1ff;
uint64_t *page_table =
(uint64_t *)((uint64_t)pt + hhdm_request.response->offset);
if (i == 3) {
return (uint64_t *)((uint64_t)page_table + idx);
}
if (page_table[idx] & ~PRESENT) {
uint64_t *guy =
(uint64_t *)((uint64_t)pmm_alloc() - hhdm_request.response->offset);
page_table[idx] = (uint64_t)guy | PRESENT | RWALLOWED;
pt = guy;
} else if (page_table[idx] & PAGE2MB) {
uint64_t *guy =
(uint64_t *)((uint64_t)pmm_alloc() - hhdm_request.response->offset);
uint64_t old_phys = page_table[idx] & 0x000ffffffffff000;
uint64_t old_flags = page_table[idx] & ~0x000ffffffffff000;
for (int j = 0; j < 512; j++) {
guy[j] = (old_phys + j * 4096) | (old_flags & ~PAGE2MB);
}
} else {
pt = (uint64_t *)(page_table[idx] & 0x000ffffffffff000);
}
}
return 0;
}
i dont see an issue
or the issue*

fun
uint64_t *find_pte_and_allocate2mb(uint64_t *pt, uint64_t virt) {
uint64_t shift = 48;
for (int i = 0; i < 4; i++) {
shift -= 9;
uint64_t idx = (virt >> shift) & 0x1ff;
uint64_t *page_table =
(uint64_t *)((uint64_t)pt + hhdm_request.response->offset);
if (i == 2) {
return (uint64_t *)((uint64_t)page_table + idx);
}
if (page_table[idx] & ~PRESENT) {
uint64_t *guy =
(uint64_t *)((uint64_t)pmm_alloc() - hhdm_request.response->offset);
page_table[idx] = (uint64_t)guy | PRESENT | RWALLOWED;
pt = guy;
} else {
pt = (uint64_t *)(page_table[idx] & 0x000ffffffffff000);
}
}
return 0;
}
gl

the problem is ()
()?
( )?
att syntax is weird
this code is fucking ugly
ik
ALSO
i dont know whats wrong with this ๐
that seems wrong
hai
What's the definition of it in the header file?
no skill issue for you
no its an asm file
its fine if oberrow does something like
compiled in nasm
&addr
huh
huh
invplg [rdi] dereferences what is at rdi
You need a header file so that c knows how to call the asm
yea i extern it
wrong
no
ofc i do
invlpg rdi```
invplg [rdi] is invlpg *rdi in C terms
is invalid
error: invalid combination of opcode and operands
and I directly pass the address of the page to invlpg
containing m
also nasm literally rejects invlpg rdi
this can be a work around for u oberrow
idk it doesnt really make sense
&virt is wrong
or rather
not what you intended
ok i see
[rdi] means "invlpg *rdi"
i know
yes invlpg the address pointed to by rdi
so passing an address as rdi would read whatever is at that address
no
think of it like a mov [rdi], 0
it accesses the memory at rdi
kinda
but instead of moving anything in or out of it
it invalidates the relavant tlb entry
Invalidates any translation lookaside buffer (TLB) entries specified with the source operand. The source operand is a memory address. The processor determines the page that contains that address and flushes all TLB entries for that page.
the source operand is a memory address
It's a memory address, not an integer
same thing
let me open up the sdm quickly
this is the sdm
It's the same as lea
im too depressed to debug this rn i am feeling sucidal thoughts rn so im just ognna try to distract myself or smthin for a bit
but the at&t code does seem fine tho ๐ค I really wonder if that's just a syntax quirk of assemblers
hope you get better soon
they would assemble to the same thing
yeah I'm just saying maybe assemblers have some kind of check for invlpg
Wait so what does your invlpg do?
invlpg:
invlpg [rdi]
ret```
@cinder plinth it seems like it takes an effective address
which is why you wouldn't just give it rdi
yeah so I chalk it up as weird syntax
[rdi] typically means take whatever is there
well I guess it's kinda like lea
whatever
I think we can all agree that we have better stuff to be doing than arguing about invlpg
at least I do
Just reset cr3
genius
Best invlpg
i asked for help on the osdev fourms cause i do not wanna debug this rn, im gonna go play some val then nap again ig
Have you pushed this to GitHub?
yea
Okay I'll take a look
thank you
didnt you already have working code for this
yea
you had old nyaux before tho
You can call rust from c
don't
thats disgusting code i dont wanna touch
please
for the love of god
You can... it's not a good idea but you can
But actually... what do you see when you use gdb pt dump?
i told u i really dont wanna debug this rn
im not feeling good at all
im just trying to distract myself with val
just take a look at it if u want to, if u dont ill try tmrw if im in the mood
wdym
wdym wdim
i invert present
this is how it's done
yes and why?
that's not how it works
wdym
you check if it has everything other than present
~0b00110010 = 0b11001101
oh
inb4 nyaux is fixed
push the code
kk
pushed
Contribute to rayanmargham/NyauxKC development by creating an account on GitHub.
@edgy pilot
take a look
ehhh it dont matter
why do you have so many find_pte functions
make it into a single one
later
pin that
I can't
auto pagemap::getlvl(entry &entry, bool allocate) -> table *
{
table *ret = nullptr;
if (!entry.getflags(valid_table_flags))
{
if (allocate == false)
return nullptr;
entry.clear();
entry.setaddr(reinterpret_cast<std::uintptr_t>(ret = new_table()));
entry.setflags(new_table_flags, true);
}
else ret = reinterpret_cast<table *>(entry.getaddr());
return lib::tohh(ret);
}
// ...
auto pagemap::getpte(std::uintptr_t vaddr, page_size psize, bool allocate) -> std::expected<std::reference_wrapper<entry>, error>
{
static constexpr std::uintptr_t bits = 0b111111111;
static constexpr std::size_t levels = 4; // We don't need more than 256 tib of addresses
static constexpr std::size_t shift_start = 12 + (levels - 1) * 9;
auto pml = lib::tohh(_table);
auto retidx = levels - static_cast<std::size_t>(psize) - 1;
auto shift = shift_start;
for (std::size_t i = 0; i < levels; i++)
{
auto &entry = pml->entries[(vaddr >> shift) & bits];
if (i == retidx)
return std::ref(entry);
pml = getlvl(entry, allocate);
if (pml == nullptr)
return std::unexpected { error::invalid_entry };
shift -= 9;
}
std::unreachable();
}
psize is 0=4kib 1=2mib or 2=1gib
this is c++ code
yes
use it as a reference
also arent u supposed to be finding this weird ah bug ๐ญ
one sorry was enough :p
still im sorry
or even better
~page_table[idx] & PRESENT
its also pretty unreadable when compared to the alternative
idk why but i still feel actually rlly fucking awful

maybe its the bad sleep idfk
maybe ill feel better if i sleep some more
itll be alright 
sleeping too much isnt good either
that's not how that works
sleeping is not really a good coping mechanism
i saw one guy do it and learned it from him
not really?
i feel like !(a & b) is more cumbersome than ~a & b
it looks a bit like -
maybe
at least to me ~a & b takes more time because I have to actually think about what it does
^
btw i see a lot less mods, and those former mods having the secret private club access
just an observation
has there been a reform of mods lately?
no minors
like, reform of the mod system
so there were a lot of mods who were minors before
i didn't know czapek/iretq was a minor
I mean at least for me sleeping has to be the least problematic coping mechanism
sleeping as a coping mechanism can spiral you into a even deeper depression
source: me
I mean thatโs kinda what makes it bad
i mean yeah
must admit i dont really have any other suggestions for coping mechanisms that are good on account of not having had any when i was depressed
Yeah I donโt have any either ๐
as much as im past it now, hindsight says i probably should have seen a psychiatrist lol
but yeah, the only real advice i can give is that it will be alright, and that recovery is not linear
That is generally the advice but speaking to someone can be really hard
yeah, but its also what one should do, as hard as it is
i mean im saying that while having never actually done that to anyone irl, but yea
Because we know what the correct thing is, but the correct thing is sometimes very hard to first come to the realization thatโs itโs the correct thing and then to actually do that
Idk Iโm just saying shit I have been up for over 24 hours
ok you need to go to sleep
lol
if i can decipher that correctly then yeah, agreed
(i think youre trying to say that we know what the correct thing to do is, but that its sometimes very hard to come to the realization that that is the correct thing to do)
Yesss
no im not lol, i just didnt want to be mod and that was made true with the secret club reformโข๏ธ
yea ur right i still feel like shit

oh yeah it came to me in a dream what i was doing wrong with the page tables
i was doing return (uint64_t *)((uint64_t)page_table + idx)
i should be doing
return page_table + idx
it's a sign!
and it's damn right
so :)
the reason this is wrong is im adding the idx to the address and this is without taking into account the fact that idx needs to be multiplied by 8 bytes because every entry is 8 bytes. doing page_table + idx; C does ((uint64_t)pagetable + (idx * 8)) basically
anyways page tables done now
i need to do vmm regions but i feel shit rn so idfk what to do
Take a break, have a drink, watch some YouTube, play some games maybe?
okii
Not surprised
I'd recommend talking with your psychiatrist about your sleeping problems
If you haven't already
opposite
i did
do no use screens
how much time do you spend on screens?
Maybe talk to them again then
i did they said they cannot give anything else
caus eim under 18
It's normal that meds sometimes stop working and need changing/dose adjustments
ill try to ask him again
Ah
I mean yeah, but I'm gonna assume nyaux is currently in a psych ward based on what happened a few days ago, and if my knowledge of them is correct that's not really much of a option
If you want to know, scroll up a few days, other than that, it's for nyaux to share, not me
no im not
but if i do anything
i will go to one
and they'll take away my stuff
which means
no more nyaux
ever

so i cannot try to hurt myself
again
or
yk
If that's your worry, I'd talk to the psychiatrist again
oki
Since they might be able to organise you working on your job/hobbies from within hospital
Source: a person I knew who was in a UK psych ward
i will ask
got vmm regions working
this test works
page faults at memset
because it is
unmapped!!!
this doesnt cause a page fault
is this bad
im sure its fine
time to integrate uacpi
ummmm
idk what this means ???
wha
nvm
i got that working
time to impl kernel_api.h

welp
thats fun
and it fails using my memset so
probs memory corruption
yippie !
nyaux hell 2015i0925890125901285th time
cant figure this out im going sleep
every line should have a different random rgb value
and panic when you're out of colours
the panic should also use the colors
but every letter is of a random one
how would you do this efficiently
the random function?
I recall you can use the timer with a specific algorithm. idk if that actually works but there are probably better methods
any algorithm that guarantees that?
Define a bitmap 255255255 big 
based
well a true rng would return different values each time, and it is unlikely to get the same value (like using a call for each color channel each time)
but what is likely is to get similar colors
iirc ToaruOS had a screen with some random colored chars, maybe I am wrong but whatever
And I specify "true rng" because some unknown company did
int rand() {
return 4;
}``` for an key encryption algorithm
I believe that was on playstation 2
ah
reason why you can't cfw a super slim
Chosen by fair dice roll
Again, I have this on my gallery smh
there's xkcd about that
so it wasn't 4
I have more than 7 gib of memes
but most of that storage is taken up by videos
I actually have 4 memes on my phone ๐
depending on what you'd consider meme
I do that but not really
I assign a random color based on pid for every task
randomise pids on every context switch
Openbsd is scared of this man
to be fair I don't think it's a bad idea if you use a good hash map implementation
has better lookup times than a rb tree
a good hashmap implementation is implemented using a rbtree or avl
I'd just use an array
which is instant
the problem is sparse memory areas
then you need to resize that array
yeah so
I'm not sure what you mean
you keep an array of pages per anonymous mapping
the indices are based on the offset into that mapping
and for sparse areas, you can mitigate that using chunking
wasn't the previous conversation about mapping when page faulting
and you would need to look up the data structure with the faulting address
so
you keep an rbtree or something of mappings
then in that mapping you can find a single page using the array
that's like
O(log n) + O(1) amortized
I'm talking about that first part
lookup would be faster with a proper hashmap
wouldn't it?
well
trees have better worst-case performance
and resizing a hashtable is very inefficient
and self-balanced trees are sorted too
you said good hashmaps are implemented using a rbtree or an avl
so resizing it wouldn't be so bad
pretty sure you still need to rehash everything
you can also lookup ranges better
in a tree
since it's ordered
and less overhead probs
unmap
let's say you have a mapping from [0, 0x1000) and another one [0x1000, 0x2000)
now you unmap 0 with size 0x2000
also I think trees are preferred because worst case hashtables kinda suck while performance can be more easily predicted in a tree
yeah they're O(n) worst case
rbtree is always O(log n)
anyway I'm not a data structure expert but that's probably the biggest reason
hi i woke up (early this time !!!)
anyways
im gonna play one val comp game
then uhhh figure out whats going on lol
me neither lol
I'm just trying to find the best way to do this
(in the future)
but yeah I think tldr hashmaps are less predictable than trees
abseil::btree_map looks interesting
std::map is tree-based
stl has pretty inefficient implementations though
as it needs to work with everything
I have this https://github.com/greg7mdp/parallel-hashmap
it has abseil btee structures ported
basically the same thing
chat what are we talking abt :3
I was already using flat hash map in my "old" kernel
data structures
fair
tbh
hashmap >= anything else
fight me
๐ค
guys multidimensional hashmap
NEED
I plan on using the rbtree+array mechanism I described earlier
might scale better
not for this use case
then again, how many mappings are there in a process
not much
what does that mean
Hashmap<Hashmap<>, Hashmap<>>
multi maps?

would you just hash a pointer to a struct describing the mapping?
then that's overhead too
because this not intrusive like rbtree
if the structure is large then maybe
but I don't think it'll be that large
I don't think you can reasonably uniquely hash a structure like that
just have a good hashing function 
then yeah maybe it'd work but
the main two issues are overhead and predictability/scalability
hashmap
yes
best-case I think a hashmap would be pretty good tho
what is uropion on this information
yes but the need for a sorted structure you brought up makes me thing the btree one is better
might use that
one issue is that btree moves items a lot so the structure needs to not be very large
what else would you store in it:
- paddr
- vaddr
- offset
- length
- prot/flags
not that much
there are probably way more knowledgeable people here
why offset
"and hash tables (which are not kept sorted to be easily traversed in order, and must be tuned for a specific size and hash function where rbtrees scale gracefully storing arbitrary keys)."
according to linux
ah offset if a file is mmaped
and I froggot length
40 bytes max
offset could be stored in the paddr field
and you would use a single byte to differentiate between them
saving 7 bytes
maybe its my slab allocator?
wait nvm
idfk
tried watching it
got nothing rlly
cause
the address changes everytime
what it faults with in cr2

after memsetting with my slabs the cr2 is now consistent
okay interesting
theres no base that exists with this address
so um
wtf
what's at rip
what is it memsetting
printf
you are doing it
no im not?
and uacpi is failing because of that
uacpi is using MY memset
i printf'd all the addresses
being allocated and deallocated
nothing found
maybe it is uacpi failing, but it's your fault it's doing that
0x2
i know
you are clearly not upholding something
0b10
so yeah, print!
lookup error code on osdev
make sure your malloc is up to spec
see what it means
check your mapper
print what else? i printed all the addresses coming in and out
and combine those functions
combine them
no
please
bru
or I'll be sad

what is that
good night
taking away both free functions
causes a different
result
fucking hell

uint64_t *find_pte_and_allocate(uint64_t *pt, uint64_t virt) {
uint64_t shift = 48;
for (int i = 0; i < 4; i++) {
shift -= 9;
uint64_t idx = (virt >> shift) & 0x1ff;
uint64_t *page_table =
(uint64_t *)((uint64_t)pt + hhdm_request.response->offset);
if (i == 3) {
return page_table + idx;
}
if (!(page_table[idx] & PRESENT)) {
uint64_t *guy =
(uint64_t *)((uint64_t)pmm_alloc() - hhdm_request.response->offset);
page_table[idx] = (uint64_t)guy | PRESENT | RWALLOWED;
pt = guy;
} else if (page_table[idx] & PAGE2MB) {
uint64_t *guy = (uint64_t *)((uint64_t)pmm_alloc());
uint64_t old_phys = page_table[idx] & 0x000ffffffffff000;
uint64_t old_flags = page_table[idx] & ~0x000ffffffffff000;
for (int j = 0; j < 512; j++) {
guy[j] = (old_phys + j * 4096) | (old_flags & ~PAGE2MB);
}
pt = (uint64_t *)((uint64_t)guy - hhdm_request.response->offset);
} else {
pt = (uint64_t *)(page_table[idx] & 0x000ffffffffff000);
}
}
return 0;
}
my mapping function
void map(uint64_t *pt, uint64_t phys, uint64_t virt, uint64_t flags) {
uint64_t *f = find_pte_and_allocate(pt, virt);
*f = phys | flags;
}
void kvmm_region_dealloc(void *addr) {
if (addr == NULL) {
return;
}
VMMRegion *cur = (VMMRegion *)ker_map.head;
while (cur != NULL) {
if (cur->base == (uint64_t)addr) {
memset((void *)cur->base, 0, cur->length);
uint64_t amount_to_allocateinpages = cur->length / 4096;
for (uint64_t i = 0; i != amount_to_allocateinpages; i++) {
uint64_t phys = unmap(ker_map.pml4, cur->base + (i * 4096));
pmm_dealloc((void *)(phys + hhdm_request.response->offset));
}
slabfree(cur);
return;
} else {
cur = (VMMRegion *)cur->next;
continue;
}
}
}
region deallocator
void *kvmm_region_alloc(uint64_t amount, uint64_t flags) {
assert(ker_map.head != NULL);
assert(ker_map.pml4 != NULL);
VMMRegion *cur = (VMMRegion *)ker_map.head;
VMMRegion *prev = NULL;
while (cur != NULL) {
if (prev == NULL) {
prev = cur;
cur = (VMMRegion *)cur->next;
continue;
}
if ((cur->base - (prev->base + prev->length)) >=
align_up(amount, 4096) + 0x1000) {
VMMRegion *new =
create_region((prev->base + prev->length), align_up(amount, 4096));
prev->next = (struct VMMRegion *)new;
new->next = (struct VMMRegion *)cur;
uint64_t amount_to_allocateinpages = new->length / 4096;
for (uint64_t i = 0; i != amount_to_allocateinpages; i++) {
void *page = pmm_alloc();
map(ker_map.pml4, (uint64_t)page, new->base + (i * 4096), flags);
}
memset((void *)new->base, 0, new->length);
return (void *)new->base;
} else {
prev = cur;
cur = (VMMRegion *)cur->next;
continue;
}
};
kprintf("No free Regions, Too Much Memory being used!!!\n");
panic("Sir madamm this should never occur");
return NULL;
}
region allcocator
void init_cache(cache *mod, uint64_t size) {
mod->size = size;
mod->slabs = (struct slab *)init_slab(size);
}
void *slab_alloc(cache *mod) {
spinlock_lock(&pmmlock);
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);
spinlock_unlock(&pmmlock);
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);
spinlock_unlock(&pmmlock);
return guy;
}
void *slaballocate(uint64_t amount) {
amount = next_pow2(amount);
for (int i = 0; i != 7; i++) {
cache *c = &caches[i];
assert(c->size != 0);
return slab_alloc(c);
}
return NULL;
}
void slabfree(void *addr) {
spinlock_lock(&pmmlock);
uint64_t real_addr = (uint64_t)addr;
if (real_addr == 0) {
spinlock_unlock(&pmmlock);
return;
}
slab *guy = (slab *)(real_addr & ~0xFFF);
memset(addr, 0, sizeof(pnode));
pnode *node = (pnode *)addr;
pnode *old = (pnode *)guy->freelist;
node->next = (struct pnode *)old;
guy->freelist = (struct pnode *)node;
spinlock_unlock(&pmmlock);
}
slab *init_slab(uint64_t size) {
void *page = pmm_alloc();
uint64_t obj_amount = (4096 - sizeof(slab)) / size;
slab *hdr = (slab *)page;
pnode *first = (pnode *)((uint64_t)page + sizeof(slab));
pnode *cur = first;
hdr->freelist = (struct pnode *)first;
for (uint64_t i = 1; i < obj_amount; i++) {
pnode *new = (pnode *)((uint64_t)first + (i * size));
new->next = (struct pnode *)cur;
cur = new;
};
return hdr;
}
my slab allocator
all on github
and btw
i cannot even figure out whats calling what because memset is being used thousands of times from uacpi
i tried back tracing i got nothinggggg
wtf
wtf is that
why is that
all garbage data
wtf
but C sees it fine
wtf
MORE BUGS??
of course because a shitty programmer like me cannot even fucking do something as simple as a memory allocator
i fuck everything, the stack, the heap
what next

i cannot even go up because the stack is corrupt???
wtf
fucking kill me
im gonna legit cry
doesnt matter what language i write in
i always make UB
I love using hashmaps as the key to my hashmap
osdev is hard, struggling with it doesn't make you a bad programmer
That looks like it's offsetting by the hhdm base
i think that's pretty funny
๐ฃ๏ธ
it's np
all good :)
All good, focus on yourself pls
btw i found something cause i was bored and decided to debug for like 15 minutes
...
ffff8000ffc00000: 00000000ffc00000 --P-----W
ffff8000ffe00000: 00000000ffe00000 --P-----W
ffff800100400000: 0003800000033000 X-------W <------- Messed up
ffff800100401000: 0003800000036000 X-------W <------- Messed up
ffffffff80000000: 0000000002125000 ----A---W
ffffffff80001000: 0000000002126000 ----A---W
ffffffff80002000: 0000000002127000 ----A---W
...
something is wrong with my mapping function
eh
anyways im gonna go back on my break for today
tmrw we figure this out
hi chat todays halloween and i still kinda want to spend this time with my family and go out trick or treating
i didnt realize yesterday that tmrw was halloween
promise tmrw ill get something done
im srry
you do not have to be sorry for not working on your hobby
have fun!
are you feeling pressured to work on this project? if so, i don't think that's particularly healthly
It's not like GitHub is gonna fire you cause you didn't do enough work on Nyaux
Just do whatever you want to, if you decide to abandon this project that's totally fine
im not gonna abandon
im okay now
ill work on it!!!
rn im opening vscode
time to debug this shit
no not rlly
im just letting you guys know whats going on
okay so time for epic nyaux debugging
i found more information
it seems my page entries get messed up at levels 1 and 2
im unsure what is causing this still but
that is useful information to know
it seems like the upper 17 bits get all set?
tf?
lower bits seems fine
but
wtf
is going on

check_exception old: 0xffffffff new 0xe
0: v=0e e=0008 i=0 cpl=0 IP=0028:ffffffff8000114e pc=ffffffff8000114e SP=0030:ffff800007f38fe0 CR2=ffff800007f38fe0```
the nyaux curse ๐ญ๐ญ๐ญ
lol i love operator precedence! :)
apparently pte_flags |= PTE_P * (flags & MMU_PRESENT) != 0; isn't equivalent to pte_flags |= PTE_P * ((flags & MMU_PRESENT) != 0); =w=
it actually makes sense tho, now that i think about it
Sounds like some kind of signed integer bug somehow
i solved that issue, was with the hddm offset
but now a new issue

as usual
nyaux curse continues
Page Fault! CR2 0xffff800100c001d8
RIP is 0xffffffff80010666
NYAUX Panic! Reason: Page Fault:c
happens in uacpi
probs cause my allocator shit or smthin idfk
uhm what da sigma
error code is non present
happens here so def allocator bug

more bug as usual
the nyaux curse continues
welp at least we made progress today
man this is tiring
but maybe its find_pte
to be honest
AND ALSO
sorry for the very slow progress, just this bug is persisent
and honestly i dont wanna burn myself out at the same time so i kinda work on nyaux in bursts now
whenever i feel not horrible
i think its more sustainable
ima sleep
then tmrw ill look into find_pte and see if it is encountering a 2mb entry or smthin
maybe that be the issue who knows

poor nyaux
fr fr
its because
uhhh
idk man
๐คทโโ๏ธ
i just get tortured by bug after bugi

yea i know
it is how i talk ๐
how u know ๐ฑ
also @fa#
@unkempt relic i see u lurking!!
say hiii
hiii
i am NOT used to this 60% keyboard ๐ญ
i cannot type for shit with this
anyways more nyaux debugging after i take a nap!!
also i was debugging all night
i didnt find much
๐
all i know is that its just another page table bug of some kind i THINK
ill keep inspecting every entry and
figure it out
whats interesting tho
is that the cr2 isnt some null deref
is it something with memory corruption cause memset?
no?
i memset all my pages and every piece of memory that goes in and out
maybe its with unmap
idk ima nap then try commenting out unmap
maybe thats ze issue
shit
i have school tmrw
ill debug this rn
i dont have much timne
cause schol

but also not too much
I either sleep 4 hours or 12