Fantastic Page Faults and Where to FInd Them

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Fantastic Page Faults and Where to FInd Them

Post 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.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Fantastic Page Faults and Where to FInd Them

Post 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.
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Fantastic Page Faults and Where to FInd Them

Post 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?
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Fantastic Page Faults and Where to FInd Them

Post by iansjack »

Yes.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Fantastic Page Faults and Where to FInd Them

Post 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.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply