paging problem

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
pini

paging problem

Post by pini »

I have paging enabled, and I want to switch to a CPL 3 function, that increments 0xB8000 byte (just to see if it works).

I have mapped the address 0xB8000 1:1.
The first PDE has last bits set to 7
The 0xB8th PTE for that entry has last bits set to 7 and address field set to 0xB8.

When it comes to my function, I can read the byte at 0xB8000, but can't write it (I got 3rd exception error).

But with last bits set to 7 (=user access + writeable + present), I shoud be able to write that byte, shouldn't I ?

PS : my selector and my GDT are correct, I checked them.

Can anyone give me a hint about that ?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:paging problem

Post by Candy »

pini wrote: I have paging enabled, and I want to switch to a CPL 3 function, that increments 0xB8000 byte (just to see if it works).

I have mapped the address 0xB8000 1:1.
The first PDE has last bits set to 7
The 0xB8th PTE for that entry has last bits set to 7 and address field set to 0xB8.

When it comes to my function, I can read the byte at 0xB8000, but can't write it (I got 3rd exception error).

But with last bits set to 7 (=user access + writeable + present), I shoud be able to write that byte, shouldn't I ?

PS : my selector and my GDT are correct, I checked them.

Can anyone give me a hint about that ?
If you set the PTE to kernel level, load CR3, load the userlevel permission, and then not reload CR3 nor use invlpg you get a page fault. Why? The page has been accessed (the translation is in the TLB) and you do not clear it from there. So, the page translation is still effective from the previous setting, not this setting.

Possibly your invlpg macro is buggy.
pini

Re:paging problem

Post by pini »

cr3 is only loaded when all user permission have been set, and the value is different than the kernel's 1:1 mapping, so all pages should be invalidate.
I tried to force invlpg, but the problem is still there :(
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:paging problem

Post by Pype.Clicker »

i suggest you first create a page fault handler that shows you EIP and CR2 values when a page fault occurs ... from there, things will be *way* easier to solve ...
pini

Re:paging problem

Post by pini »

I checked the value in CR2. From the Intel manual, this should give the linear address where the page fault occurs.
I got 0xFFFFFFC, which is not mapped.

Anyway, I rewrote the whole code and everything works now.
Who will ever know what were the real reason for that page fault ?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:paging problem

Post by Pype.Clicker »

probably trying to follow a NULL pointer somewhere :)
Post Reply