Page 1 of 1

paging problem

Posted: Sun Apr 11, 2004 10:19 am
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 ?

Re:paging problem

Posted: Sun Apr 11, 2004 1:24 pm
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.

Re:paging problem

Posted: Mon Apr 12, 2004 6:01 am
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 :(

Re:paging problem

Posted: Mon Apr 12, 2004 6:56 am
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 ...

Re:paging problem

Posted: Mon Apr 12, 2004 7:34 am
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 ?

Re:paging problem

Posted: Mon Apr 12, 2004 8:20 am
by Pype.Clicker
probably trying to follow a NULL pointer somewhere :)