Page 1 of 1

Page fault on framebuffer access

Posted: Mon Jun 30, 2025 4:02 am
by torii
Hi!
I am currently trying to transition to a graphical terminal using flanterm and framebuffer, however I am currently getting a page fault when accessing the framebuffer.

I am using the address provided to me by the multiboot 2 information tag, so I am unsure why this is happening. Have I missed a step in getting this to work? Based on the page fault, I assume I need to first allocate some pages for the pagebuffer and then load it ther, but I am unsure how I would acheive this.

Any help or pointers in the right direction would be greatly appreciated :D
https://github.com/Toriiiiiiiiii/Solkern
fb pagefault.png

Re: Page fault on framebuffer access

Posted: Mon Jun 30, 2025 5:21 am
by iansjack
You don’t need to allocate any pages for the frame buffer, you just need to map its address in your page table(s). You can either map the same virtual address as the physical one or choose a new virtual address.

You need to bear in mind that, once you enable paging, almost all addresses you access have to be mapped in your page tables. There are a few exceptions - for example, the addresses used in the tables themselves are physical addresses. And certain peripherals, such as NICs need physical addresses.

Re: Page fault on framebuffer access

Posted: Mon Jun 30, 2025 10:12 am
by Octocontrabass
iansjack wrote: Mon Jun 30, 2025 5:21 amcertain peripherals, such as NICs
All peripherals that perform DMA, which is most of them once you've got "proper" drivers.

...Although it isn't always that simple. Some ARM platforms have more than one physical address space, so the "physical" address you use for DMA might be different from the "physical" address you use for your page table. There's also IOMMUs, which basically give you page tables for DMA, meaning you'd program your peripherals with virtual addresses instead of physical addresses.

Fortunately you can ignore all of this on x86 PCs.