#Nyaux
1 messages · Page 4 of 1
sudo pacman -S gdb
okay this is the loop thats causing the issues
It's page faulting right?
page faulting in the slab cause of this loop yea
i have this loop commented out
and it works fine
checked what address pmm_free_singlep got
it was valid
yea cur_node-> base is valid too
the problem is with deallocating the memory?
commented out pmm_free_singlep and it works fine
void *pmm_free_singlep(void *page)
{
struct pmm_node *node = page; // ASSUME PAGE IS VIRTUAL
node->next = head;
head = page;
}
this is lit the entire function lmao
gcc generates a ud2 instruction if you don't return a value from a function that should return a value
So it's probably not a page fault and probably a #UD
☠️
nope
still fault
sad
i dont get why its doing this
physicall address looks valid
virtual address looks valid
"looks"
it does tho
but is it?
well the virtual address is certinally below the hhdm
so it is valid
as a hhdm mapping virtual address
don't you pass an address offsetted by the hhdm though?
where?
here
thats the for pagemap
pml4
i cant figure it out 
why is it that this ONLY happens if i deallocate the page
even tried memsetting it and it didnt NOTHING
wait @kind root could it be that the address is not guaranteed to be page aligned?
cause uacpi
maybe its returning a base that isnt page aligned
or something
idfk
nope
didnt work
What
im still having some weird ass like bug, in my vmm_region_dealloc function that causes some memory fuckery with the slabs and even if i zero all the pages it doesnt seem to solve anything
if i comment out the freeing of the page
it works fine
which makes zero sense
because the address IS valid
and below the hhdm limit
just don’t free 
no 
this is like a mini hell
vmm hell

anytime anyone has a vmm issue call it nyaosmaster hell
wait no
call it
hell.

Skill issue
lack of aptitude
no i can
does uacpi do use after frees?
it seems like
the pages being requested to be deallocated are still in use
cause if i memset them it also corrupts stuff
No it does not lol
memsetting cause a page fault in the uacpi interrupter
commenting that ALSO out
it works
Thats a bug on your part unfortunately

uACPI has been fuzzed to hell
No leaks or use after frees
Also qemu blob has been tested 99999 times by different kernels
physical address must be invalid then or something
or the virtual address isnt right
how my unmap function looks
why "b" specifically in the inline asm btw
stole this from somewhere cause i suck at writing inline asm with C
also you are not checking for cur_table == NULL in the in-between calls to get_next_table_unmap
fair
Looks messy but probably correct
virtual addresses look correct
i dont see an issue with the dealloc function
maybe its somewhere else?
no its not
even this works
HAS to be my vmm
maybe its the alloc function
or something
i dont understand WHATS going on
why is this memory corruption happening
i dont get it
its driving me insane
and i just wanna sleep
but i wont sleep til this is solved
cause i need to finish this before tomorrow
use before free
nvm
this is driving me insane
i might as well just port the vmm to userspace 
wait idk how to do that
nvm
i dont know what to do
im going to sleep
maybe tomorrow we will figure it out
pushing what i have done so far onto github
hell yeah, do it (if you have the time). It's been something I've wanted to do for a bit.
just mmap and a big file on disk to be your secondary storage.
have you tested your pmm's free() function works like you expect?
It should
I don’t know how to
I don’t have swap paging in my vmm ( bro thinks I’m that advanced)
okay i wake up time for more debugging!
every day i wake up i debug that virtual memory manager
I DONT GET WHY THIS SINGLE LINE OF CODE
CAUSES MEMORY CORRUPTION AND FUCKS THE SLAB ALOOCATIOR
THIS ONE LINE
CAUSES PROBLEMS
WHY???
WHY???????
OKAY ITS EITHER
THE PHYSICAL ADDRESS IS COMPLETELY WRONG
OR MY PMM_FREE_SINGLEP IS BROKEN SOMEHOW
void pmm_free_singlep(void *page)
{
struct pmm_node *node = page; // ASSUME PAGE IS VIRTUAL
node->next = head;
head = page;
}
THIS IS THE ENTIRE FUNCTION??
how is this causing problems
can someone help me i dont understand why this bug is happening
im stuck
these addresses look valid
is my kernel cursed
Yes.
i swear
it is
its like a second oberrow curse
okay so vmm frees this region with physical address 67D063
Slab Allocator uses this address yes?
dump of some of the addresses
That ain't the physical address
that's the pte
IM ACTUALLY SO STUPID OMAR 😭
yes we learn
why do you always figure out the problem 😭
bro has a brain bigger then megamind

Did I not say I am the local guide for fixing dumb allocator bugs
alr
static uintptr_t s_physAddrMask = 0;
size_t GetPhysicalAddressBits()
{
uint32_t eax = 0, unused = 0;
__cpuid__(0x80000008, 0, &eax, &unused, &unused, &unused);
return eax & 0xff;
}
static uintptr_t MaskPhysicalAddressFromEntry(uintptr_t entry)
{
if (!s_physAddrMask)
s_physAddrMask = (((uint64_t)1 << GetPhysicalAddressBits()) - 1) << 12;
return entry & s_physAddrMask;
}```
That's what my kernel does
__cpuid__ is defined as:
void __cpuid__(uint64_t initialEax, uint64_t initialEcx, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx);
and is defined here (ignore the mangled names):
how big are the physicall address bits usually for 4 level paging on 64 bit
12-57?
can i just assume 12-52
52-57 are reserved for use in the kernel
okay im gonna assume that then
yep the no execute bit
Btw your vmm should have prot flags of some sort
So you can make pages not be able to executed (probably make that the default), make them read-only
etc.
i have flags for
setting the rw flag
maybe later no execute
rn im just gonna
try to do this funny bitmasking
okay im a little confused reading this code
which part
the eax & 0xff
Find what cpuid:0x80000008 does in the intel sdm
okay sec
bits 0-7 are for max physical address bit size
which chapter in the sdm
idk
oh i see
it will be 57 in decimal if the cpu supports 57 bit addressing @finite summit ?
that's for the virtual address bits
that lower byte (bits 0-7) is for physical address bits
.!t sdm
These manuals describe the architecture and programming environment of the Intel® 64 and IA-32 architectures.
ok
I don't want to look
Just trust that bits 0-7 of eax when you do that cpuid is for max physical address bits
will the max physicall address bits be in decimal in the 8 bit field or what
?
It's an integer?
yea okay
okay i understand then
uint8_t addr_bits = 51;

wait probs should be 58
actually wait
51
cause avl can be used by the kernel to store extra flags or smthin
It can
yea
im just gonna hard code the value
of the bitmask
@finite summit isnt this cursed 
these look valid i think
lemme try giving it to pmm_free
IT WORKS
IT WORKSSSSSS
!!!!!!!!!!!!!!!!!!
You're welcome
Well u didn't implement any api but its good that u fixed memory bugs
he probably was expecting some kinda of congratulations
yea 😠
☠️
do you already have system calls? (I do not think so)
well start with that
then do it
userspace comes right after syscalls
we all want to see doom here
i dont need to go to userspace rn
i need an interrupt controller rn
cause currently
i DONT
have a timer
at all
you could use the old pic for now
no
it is very easy to implement, and besides the less time you spend on platform dependent code the better
im gonna try and learn the APIC and figure out how to set it up and start using it
although I do not think you are going to port this to other archs anytime soon
no
x86-64 only baby 😎
before i do anything tho
i wanna do some fun
before anything
cause yea
so im gonna try and like load an image or smthin via limine kernel modules 
and display it onto the framebuffer
just for fun
yep
do it then, should't take more than 20 minutes
what image are you going to use? (weren't you the one who wanted a "kawai" os?)
if that's the case some anime pic should do it
first i need to find out how im gonna decode the file format
ah that. You could convert the image to a binary (very easy), or use stb image (also very easy)
if you use stb image you can directly load a png, jpg, bmp or whatever
ill use stb image
stbi_load_from_memory may be the function you need
do you know how to add a module via limine?
MODULE_PATH=boot:/// + path
MODULE_PATH=boot:///image.png will load the image from the root directory
you also need to interface via the limine protocol requests, but I will leave the fun to you (https://github.com/limine-bootloader/limine/blob/v7.x/PROTOCOL.md)
You want to use modules
what resolution are you targetting?
@surreal path
resolution?
the framebuffer resolution
i dont know limine gives me whatever resolution framebuffer it wants to give
okay wait
just got limine to load the image for like the boot screen which is really easy but i was just modifying my makefile for that to work
now i will make a module and try to load
it
yea
hmmm
maybe you can use the stbi_load_from_memory function to load the image directly inside the framebuffer
Congratulations
thank u 
thats ze address of ze module
lemme try and setup STB_IMAGE.h
@rigid fable will stb_malloc ever allocate a page or more
i probs should have my kmalloc check that actually
yea
i did that but
why tf is stb_image including stdlib
how do i stop that
Ask it nicely
okay i will 
hmmm
I think stb image might not be a good idea, since it seems like it is heavily using userspace functions
nah i only had to comment them out
void *krealloc(void *addr, size_t oldsz, size_t newsz)
{
void *new_shit = kmalloc(newsz);
memcpy(new_shit, addr, oldsz);
kfree(addr, oldsz);
return new_shit;
}

it may not work
for me it is giving a ton of undefined references to C functions
because u have to comment out a lot of stuff
im reading minsukis patch on stbi_image
applying it manually
You might aswell just load a raw binary image
like wait
the entire code is like 5 lines (with the pointer declaration)
framebuffer[i] = image[i];
}```
yea trying to load it with stb image isnt work well
just do as I did
try to see what resolution is your os running on
I did a screenshot of the screen and measured the size in pixels of the qemu window
mine was 1280 * 720 (edit: those 80 pixels were the qemu title bar and I mistakenly thought it was the fb res, so it is actually 16:9)
binary rgb888
As input format I put cf true color
you can also dither
but make sure the image is the correct size, else it will either not fit or crash
do not declare the fb pointer inside the loop
just to try the first couple of pixels
what is happening?
can you send here the actual image?
where pitch
wdym
(sorry if thats a stupid question, i dont know much about framebuffers)
we are doing it in the bad way
the size in bytes per line
okay
we are doing it in a hackish way
@surreal path whats the format of the image youre reading
resize the image to 1280*720 and remove alpha
24 bpp or 32 bpp
binary rgb888
how to remove alpha
Thats probably whats going on
bpp?
?
Bits per pixel
32 i think
This assumes both fb and img are 32 bpp
no no, the issue is the image itself being formatted poorly by the converter, probably because of the alpha channel. I used the exact same way but it worked
yes
Ohh
I see
tried removing alpha channel but still
how did you try? And what is the image size?
used some site do remove the alpha channel then i reconverted it
image size is 522x614
wait
here you go
the image needs to be of the same size as the framebuffer (at least in width), else the loop won't work
oh
but what if i dont want that
wait
for(int x = 0; x < WIDTH; x++) {
fb[x + y * FB_WIDTH] = img[x + y * WIDTH];
}
}```
in theory this should work
good
just for curiosity, did you use my double for loop or wrote something yourself?
because for me it is not working
your double loop
for(int y = 0; y < 597; y++) {
for(int x = 0; x < 507; x++) {
fb[x + y * framebuffer->width] = img[x + y * 507];
}
}
yea
now try with an anime image
so you can flex
time to port xorg to have windows!
@surreal path how is it going? I am eager to see what image you chose
tryharding
are you using qemu from wsl?
yea
what window server are you using?
?
are you using VcXsrv or WSLg or something else?
wslg
anyways loading that image was fun
even got a little bit of transparency going
😎
by rendering the image before the text?
no by doing a check
checking if the pixel we are gonna place the pixel on is black
if it is
place the img pixel
if it isnt
dont do anything
use this in your image rendering function
out = alpha * new + (1 - alpha) * old
out is the framebuffer, new is the color of the image, old is the value at the framebuffer before writing
oh and you do this after the text is rendered. otherwise you would put this inside of the text rendering instead
(you would need to have floating points working)
else just rewrite the function using ints, but it needs some formula conversion
dont have floating points
😎
lf those are page addresses then id what you’re doing but its definitely wrong 💀
bruh discord trolled me
nevermind i guess
what? those arent page addresses
????
ah kk
i was replying to this
discord didnt show me any newer messages for some reason
sooo hows integrating uacpi going, im not following this thread very closely :^)
we have it working
uacpi now loads
hell yeah
yea !!!
we
we

communism
fairyness (in todays tutorial I am going to show you how to get banned from osdev!)
NyaOS is bending the computer to its will
the cpu will listen to whatever nyaos says
😠
btw an update on the slab situation i mentioned yesterday
the slab allocator was fine
so was the pmm
(a) is this the right place for it? (b) what was it?
the bug was somewhere in the ELF load code which would end up writing 0x2000 in an area allocated of size 0x1000
not good
(a) yes, because i brought it up yesterday in here in relation to nyaos's issues getting uACPI to run
that were assumed to be due to the slab allocator
ah
yeah
based
it still runs out of memory after a while
there are leaks i know about, and others i do not
but it's at least stable and reproducible now
well, for the most part
the scheduler still seems to not be 100%, especially when running on 1 core
and glxgears can be made to page fault in userland by running more than 1 instance of it
but anyways it's better than it was before and that's what matters
glxgears is a really intensive process to run
nyaos now runs uacpi nicely!
!!!
no more allocator bugs
what is ur opinion on the cool image loading (via limine modules) i got 😎 😎
yea
i wanted to mention that maybe you may want to look into @edgy pilot 's flanterm version that also handles loading bg images; though i never used it myself so idk how good it is
vinix?
spent a good 10 minutes trying to find a kawaii wallpaper for this (to fit with the theme)
and also, the flanterm submodule doesn't seem to be the latest commit but whatever
they havent updated it in a while
oh wait
ah nice
yea ill update that
oh come on
yea thats old
i know what your real problem is
they need to update it
not enough borrow checking
ryre time
ryre?
worry not, for valex said its going to be in V at some point afaik
rust lyre
which actually would really be super cool
V's autofree works surprisingly well
ryre time
just instead of autofree they usually call it "regular optimizer shit"
Vyre
Vyre
we’ve had destructors and move semantics in c++ for quite a while now
that sounds a lot better than vinix
c++ move semantics are rather weird
im glad v is finally catching up
well i guess we could rename it :^)
maybe i should rename my os to be fair
nyux
nyux?
nyux is good
okay NyaOS is now Nyux
oh god
anything is better than xxxxxOS
i agree
which is why i kinda cringe when people say LyreOS even though that's the org name
it's only the org name because Lyre is taken
same with limine
yea
it would be limine/limine if limine hadn't already been taken
i should probably email gh support about it, to see if they can give it to me
i know someone that did that once and it worked for them
well that's a shame
but i think it changed with the microsoft acquisition
no it isn't
how is it pronounced then
/ɲoks/
i dont know how to pronounce that 😭
Read IPA notation
nyaux
nyaux
oh yeah mint if you dont mind can u like pin this in the thread?
thanksss
oh yeah mint is there like a way to make flanterm not draw the background or smthin
i dont wanna reupdate the image everytime i write text
You can pass a canvas to flanterm
The background image to be used
i can just give it the background image?
and it will load it
???
I imagine you will have to resize the image too
the image has the same width and height of the framebuffer sooo idk
Mintsuki knows how flanterm works better than me they can explain better I think but yeah
Then Indont think you need to resize
@wicked loom how does one use the canvas in flanterm again
wdym?
it's just a background, it's a raw bitmap
but yeah you have to resize it and all
and it doesn't automatically generate the nice box with a margin and alpha blending like Limine does
that's why i suggested using ilobilo's thing, because it does all that
I see
i tried loading it but nothing happens
oh
ok wait
default bg == canvas
as in
you set the background colour to default using escape sequences (or just don't set an alternative bg colour)
this is what i do
i set the bg to null and still nothing happens
try nulling out the default_bg
what is the format of img
its a binary file
produced by this website
oh wait i know why
why?
for the canvas to work you need to pass an allocator to flanterm
how do i do that
oh okay
you can just initialise flanterm twice
rlly?
the first time without the allocator if you need it before you have the allocator initialised, and then afterwards you can deinit the previous context and make another one with the allocator
yeah
deinit with c ctx->deinit(ctx);
size?
no
huh?
I just updated
it takes the free() function, you can pass NULL
since your first context was initialised without allocator
your autocomplete isn't saying size_t, it's saying void (*)(void *, size)
uhhhh
aka a sized free
yeah that just looks like you set the bg to black using escape sequences
that's normal lol
how to undo that
this
does that look like an escape sequence lol
no
whats the escape code for the default background
yeah this also works
fixes nothing
are you sure it's not white on white
also
hmm
i am so confused
how is it still showing the previous terminal context's text
no idea
did you call the init func with sensible parameters?
yea?
idk your screenshot cuts it off
ctx = flanterm_fb_init(kmalloc, kfree, framebuffer->address, framebuffer->width, framebuffer->height, framebuffer->pitch, framebuffer->red_mask_size, framebuffer->red_mask_shift, framebuffer->green_mask_size, framebuffer->green_mask_shift, framebuffer->blue_mask_size, framebuffer->blue_mask_shift, img, NULL, NULL, &bg, NULL, NULL, NULL, NULL, 0, 0, 1, 0, 0, 0);
the function call
no its not null
3G
sounds like your malloc might be bad
does your kfree take a size parameter?
yep
in bytes or pages?
bytes
no not rlly, uacpi ran fine
i went through my oberrow hell already
i dont think they are lol
idk man
you are getting weird artifacting
that could easily be caused by a bad malloc
flanterm works fine under ubsan, asan, and through extensive fuzzing, so i strongly doubt flanterm is the issue
and you are going like "definitely not that"
cause i spent days debugging extensively and working on it to get uacpi to work 😭
it did initally but when i put the img it just
it doenst clear it
what
like
if i dont give flanterm the image
the screen is cleared just fine
like this
why??
you could try using this https://github.com/ilobilo/limine-terminal
it sounds likely your kmalloc is broken for large allocations
to catch issues
does it reliably allocate ranges significantly larger than 1 page?
that says failure
have you tried halting without printing anything?
what kind of font format does flanterm use? A flat binary?
in the new context
idk
ok ill try
yes
did you do the memset thing i mentioned yet
can you try passing a canvas which is just an empty malloc of width*height*4
instead of the image
sure
wouldn't that draw garbage?
well, it would draw whatever
if the mallocs are zeroed out then it would print black
else, whatever garbage
it doesn't matter though as it's just a test
oh its not zeroed out
my kmalloc doesnt zero out by default
have you done any of the testing pitust or i mentioned yet?
sure
i will
sec
something like this?
yes
causes a gpr
thw nightmare has begun
yeah you're malloc is probs broken
okay sec
if you make it never do anything
still gpr'd
sounds like your malloc is pretty broken

oh btw @wicked loom: to find leaks, you can try writing a log of something like c struct entry { bool free_not_malloc; uint32_t alloc_size; uint64_t address, caller; } into the magic ivshmem device i mentioned, and then postprocess than in python or whatever to find all the allocations that don't get freed
you mean gpf, not gpr, right?
gpf? yea a general protection fault. 0xd
you said gpr
alright
should've said gpf
but yea it gpf'd
r13 doesnt look canoical
so its my malloc correct?
well yeah thats the memset
obviously
but memsetting the framebuffer to whatever shouldnt cause a gpf
im not memsetting the framebuffer
im memsetting the kmalloc allocation
the memsetting isnt the FAULTING instruction
memsetting that shouldnt cause a gpf no matter what garbage ends up there

so its my kmalloc
@haughty kite ?
yes
why

ANOTHER
oberrow hell
this time its my vmm
wait i do memset with my vmm
is that a problem
no that shouldnt be
great
this is just great
okay creates the 3mb region

it looks valid
so why does memsetting 0xaa and then giving it to flanterm cause a gpf
why
oh wait...
kmalloc returns a 64 bit address virtual address
img is of uint32
still didnt fix anything
what it looks like just before it gpf'd
and? That is a POINTER variable for 32 bits, so the variable is still 64 bits wide
oh
you might as well implement the pmm and vmm from scratch and test it bit by bit with test cases
np, writing one means you will know every but of it, and can test it more in depth
😀

this emoji is so cool haha
no i need to fix the problem with my current vmm region allocator
smthin funky is going on
void *vmm_region_alloc(uint64_t size, uint8_t flags)
{
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 = align_up(size, 4096);
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++)
{
void *page = pmm_alloc_singlep();
// memzero that shit!
memset(page + hhdm_request.response->offset, 0, 4096);
map((uint64_t)pml4 + hhdm_request.response->offset, new_guy->base + (i * 0x1000), page, 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!
serial_print("NO FREE REGIONS\n");
asm ("cli");
for (;;)
{
asm ("hlt");
}
}
this is how im allocating my vmm region
the problem must be coming from here
cause like
yea
Welcome to osdev
and i had just THOUGHT
I THOUGHT I SOLVED EVERYTHING
and then
this happens
this is painful
Creating Region of Base: FFFF8000BFF31000 with Limit: FFFF8000C0231000
requested: 792
requested: 4096
requested: 32
Creating Region of Base: FFFF8000BFF2D000 with Limit: FFFF8000BFF2E000
requested: 36864
requested: 32
Creating Region of Base: FFFF8000C0231000 with Limit: FFFF8000C023A000
requested: 65088
requested: 32
Creating Region of Base: FFFF8000C023A000 with Limit: FFFF8000C024A000
requested: 173568
requested: 32
Creating Region of Base: FFFF8000C024A000 with Limit: FFFF8000C0275000
requested: 43392
requested: 32
Creating Region of Base: FFFF8000C0275000 with Limit: FFFF8000C0280000
requested: 3145728
requested: 32
Creating Region of Base: FFFF8000C0280000 with Limit: FFFF8000C0580000
now do these virtual addresses look valid
hmm
FFFF8000C0280000 to FFFF8000C0580000
3mb region
addresses look valid
so why is a general protection fault happening
why here of all places
i dont get it
uh huh
that shouldnt be happening
why tf
is it like
not countingous or something???
have you checked why you're getting a GPF?
like, GPFs are fairly specific (in being non specific) in that they are not page faults
uh yea
you can usually infer why you are triggering one
it doesnt trigger a gpf when i dont call flanterms ctx init
but instead produces this weird result
which is odly similar
i mean this makes sense, you should check for 0xaaaaaaaa
it's a uint32_t
okay theres no what the fuck
like at all
so every piece of memory IS 0xaaaaaaaa
and it is being given correctly
if thats the cause
why is it appearing like that
why does flanterm gpf
what the fuck is going on
it doesn't necessarily have to be the cause
there could honestly be any number of issues
so it isnt malloc it seems
ranging from allocator bugs to other sorts of corruptions and whatnot
it could still be your malloc, but only when it is called by flanterm later on
check why you are getting a GPF from flanterm
dump the registers, see the error code if any
etc
check the stack
i dont believe so because uacpi has done thousands of calls upon malloc, to which everything works fine
okay
check_exception old: 0xffffffff new 0xd
413: v=0d e=0000 i=0 cpl=0 IP=0028:ffffffff80016f8b pc=ffffffff80016f8b SP=0030:ffff80007fe8ee50 env->regs[R_EAX]=0000000000000000
RAX=0000000000000000 RBX=ffff800000008018 RCX=0000000000000000 RDX=0000000000000000
RSI=ffff8000c0275000 RDI=ffff800000008018 RBP=ffff80007fe8ee80 RSP=ffff80007fe8ee50
R8 =0000000000001530 R9 =00000000000c03f3 R10=ffff8000c0280000 R11=0000000000000009
R12=0000000000000000 R13=00aaaaaa00aaaaaa R14=ffff8000c0275000 R15=0000000000000090
RIP=ffffffff80016f8b RFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0030 0000000000000000 00000000 00209300 DPL=0 DS [-WA]
CS =0028 0000000000000000 00000000 00209a00 DPL=0 CS64 [-R-]
SS =0030 0000000000000000 00000000 00209300 DPL=0 DS [-WA]
DS =0030 0000000000000000 00000000 00209300 DPL=0 DS [-WA]
FS =0030 0000000000000000 00000000 00209300 DPL=0 DS [-WA]
GS =0030 0000000000000000 00000000 00209300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 00000000 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= ffffffff80101680 00000040
IDT= ffffffff801016e0 00001000
CR0=80010011 CR2=0000000000000000 CR3=0000000000009000 CR4=00000020
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=00aaaaaa00aaaaaa CCO=LOGICQ
EFER=0000000000000d00
e=0000
so not a segment error
Accessing a memory address with bits 48-63 not matching bit 47 (e.g. 0x_0000_8000_0000_0000 instead of 0x_ffff_8000_0000_0000) in 64 bit mode.
diasssemble what's at RIP
okay
static void draw_cursor(struct flanterm_context *_ctx) {
struct flanterm_fb_context *ctx = (void *)_ctx;
if (ctx->cursor_x >= _ctx->cols || ctx->cursor_y >= _ctx->rows) {
return;
}
size_t i = ctx->cursor_x + ctx->cursor_y * _ctx->cols;
struct flanterm_fb_char c;
struct flanterm_fb_queue_item *q = ctx->map[i];
if (q != NULL) {
c = q->c;
} else {
c = ctx->grid[i];
}
uint32_t tmp = c.fg;
c.fg = c.bg;
c.bg = tmp;
plot_char(_ctx, &c, ctx->cursor_x, ctx->cursor_y);
if (q != NULL) {
ctx->grid[i] = q->c;
ctx->map[i] = NULL;
}
}
this function
at line c = q->c;
i said disassemble
oh okay
the first instruction?
it seems to gpf at the first instruction?
yea this instruction
stack trace looks like this?
this is um
very weird
why this instruction specically?
wait r13 has that weird ah address
00aaaaaa00aaaaaa
i think its trying to dereference this????
tf?????
why is it trying to dereference r13
whats going on
looks like you passed in colors by value and not by pointer again?
img is a pointer
i pass in
0xaaaaaa looks like a color
yea
but i did that loop
and all the data
in that img array
is 0xaaaaaaaa
so how is it broken????
and ive checked what vmm_region_alloc gave
it gave a correct base virtual address
and the vmm_region struct holds the correct length for the region
show the full flanterm_fb_init invocation
okay
volatile uint32_t *img = kmalloc(framebuffer->width * framebuffer->height * 4);
memset(img, 0xaa, framebuffer->width * framebuffer->height * 4);
// for (int i = 0; i < framebuffer->width * framebuffer->height; i++)
// {
// if (img[i] != 0xaaaaaaaa)
// {
// serial_print("WHAT THE FUCK\n");
// }
// fb[i] = img[i];
// }
ctx = flanterm_fb_init(kmalloc, NULL, framebuffer->address, framebuffer->width, framebuffer->height, framebuffer->pitch, framebuffer->red_mask_size, framebuffer->red_mask_shift, framebuffer->green_mask_size, framebuffer->green_mask_shift, framebuffer->blue_mask_size, framebuffer->blue_mask_shift, img, NULL, NULL, &bg, NULL, NULL, NULL, NULL, 0, 0, 1, 0, 0, 0);
what if instead of 0xaa you use 0xbb
okay sure
now r13 is 00bbbbbb00bbbbb
faulting at same instruction
and also how many times do i have to repeat "your malloc is broken" until you accept your malloc is in fact broken
and that you should fix that
because i like to cope
because allocator bugs are the bane of my existence
its honestly just annoying at this point
yea okay so mallocs broken, memory corruption or something
is that it?
its annoying that i keep having issues like this

hmmm
what if i dont give flanterm the image and just give it my malloc
no it doesnt fault
all these addresses malloc is returning look valid
so why is this memory corruption happening
why
cant u see im trying to
lol
writing a working allocator is hard
i guess
and why tf did it work under uacpi but failed with flanterm
who knows