1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Page table representation in the virtual address space of FreeBSD

Discussion in 'FreeBSD Development' started by nav143, Dec 5, 2011.

  1. nav143

    nav143 New Member

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

    // 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.
  2. SirDice

    SirDice Moderator Staff Member Moderator

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

    Also, you should be familiar with recursion