Page 1 of 1

Fantastic Page Faults and Where to FInd Them

Posted: Sun Jan 31, 2021 12:09 pm
by austanss
I am currently scratching my head at the number of page faults I am getting for no apparent reason.

I managed to fix one where my bootloader info struct pointer would point to a [page fault] after I replaced EFI's paging structures.

Now I'm getting one when I call util::bitmap::operator[], on a... test instruction?

Code: Select all

  10067c:	84 04 16             	test   BYTE PTR [rsi+rdx*1],al
I found the cause was an array-out-of-bounds error.

So, what causes a page fault?
Where might I find page-faulty code?

Please explain.

Re: Fantastic Page Faults and Where to FInd Them

Posted: Sun Jan 31, 2021 12:14 pm
by iansjack
Page faults are caused by attempts to access to memory which is not mapped or does not have the appropriate access rights. They can be caused by any instruction, so can be found anywhere in your code.

Re: Fantastic Page Faults and Where to FInd Them

Posted: Sun Jan 31, 2021 12:28 pm
by austanss
OK, that makes sense.

So if I have a pointer to 0x78F0000 and 0x78F0000 isn't mapped, and I access the memory: page fault?

Re: Fantastic Page Faults and Where to FInd Them

Posted: Sun Jan 31, 2021 12:29 pm
by iansjack
Yes.

Re: Fantastic Page Faults and Where to FInd Them

Posted: Sun Jan 31, 2021 1:16 pm
by nexos
rizxt wrote:Where might I find page-faulty code?
Anywhere, namely when using pointers or arrays. Page faults will be your enemy for a while, then, when you get into the MM, they end up being a performance and memory saving technique.