Paging - strange(?) 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Paging - strange(?) problem

Post by Combuster »

PML4: 0x0000000106000003
// 0x106000 is pml4e->PhysAddr
Can you spot the difference between 106000000 and 106000?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
begin
Posts: 17
Joined: Mon Jun 23, 2014 12:51 pm

Re: Paging - strange(?) problem

Post by begin »

But
0x0000000106000003
is the whole struct isn´t it?
So PhysAddr = 0x106000, Present-bit = 1, RW-bit = 1, everything else = 0... ?
User avatar
Marionumber1
Member
Member
Posts: 56
Joined: Sun May 08, 2011 9:03 am

Re: Paging - strange(?) problem

Post by Marionumber1 »

An entry in the 64-bit paging structures has the lower 12-bits represent the page flags, and the upper 52-bits represent the physical page number.
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.
User avatar
iansjack
Member
Member
Posts: 4709
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Paging - strange(?) problem

Post by iansjack »

begin wrote:But
0x0000000106000003
is the whole struct isn´t it?
So PhysAddr = 0x106000, Present-bit = 1, RW-bit = 1, everything else = 0... ?
It's not a struct; it's the physical address with the proviso that the last 12 bits of that address are always 0. Because of this they can be used as flags piggy-backed onto the address. So to get the address you take the number in the control register or page table entry and mask the last 12 bits to 0 .

Get that wrong and your page table is going to be invalid.
begin
Posts: 17
Joined: Mon Jun 23, 2014 12:51 pm

Re: Paging - strange(?) problem

Post by begin »

Holy **** it works now...
I think I should avoid bit fields from now... this was the real problem. I threw my struct away and used a uint64_t instead. And yes, I know bit fields should be avoided and I dont know why I used them.... :oops: :D

Thank you guys =D>
Post Reply