Page table representation in the virtual address space of FreeBSD

Kernel development, writing drivers, coding, and questions regarding FreeBSD internals.

Page table representation in the virtual address space of FreeBSD

Postby nav143 » 05 Dec 2011, 14:53

The following echoes the way page tables are represented in the virtual address for FreeBSD (amd64)

Code: Select all
// start by moving entries we care about to the bottom
  vpn_table_entry = vpn >> (9*level);

  // clear out any high order bits (sign extension)
  vpn_table_entry &= (1ul << ((4 - level) * 9)) - 1;

  // now, add in the right number of recursive PML4 entries
  for (i=4; i>=(4-level); i--) {
    vpn_table_entry |= (RECURSIVE << (9*i));
  }

  // shift up to account for size of PTE (64 bits).
  table_entry = (vpn_table_entry << 3);

  // add the sign extension back
  table_entry |= (unsigned long)-1 << 47;


Can someone help me with what does RECURSIVE mean and what values it generally takes? It would be very helpful if someone can explain with an example. I tried figuring it out but was not very clear. The kernel source is also not that clear. This is part of simulator that logs the virtual address of the faulting address in the event of a MMU cache miss.
nav143
Junior Member
 
Posts: 1
Joined: 05 Dec 2011, 09:37

Postby SirDice » 05 Dec 2011, 14:59

nav143 wrote:Can someone help me with what does RECURSIVE mean and what values it generally takes?

I haven't looked at the code but it looks like a macro.

Also, you should be familiar with recursion
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16196
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands


Return to FreeBSD Development

Who is online

Users browsing this forum: No registered users and 0 guests