Skip to content

PageTableFlags::PAT_HUGE_PAGE overlaps with address field #612

Description

@phil-opp

The PAT_HUGE_PAGE is bit 1 << 12, which is usually part of the address field. So we mask it out:

const fn physical_address_mask() -> u64 {
0x000f_ffff_ffff_f000
}

This mask is used in many places. This means that PAT_HUGE_PAGE will be never returned by flags even if it is set:

pub const fn flags(&self) -> PageTableFlags {
PageTableFlags::from_bits_retain(self.entry & !Self::physical_address_mask())
}

Another issue is that set_flags/set_addr will blindly OR PAT_HUGE_PAGE in, but this will change the address when applied to a non-huge entry:

pub fn set_flags(&mut self, flags: PageTableFlags) {
self.entry = self.addr().as_u64() | flags.bits();
}

Given that the PAT_HUGE_PAGE only lives on next (introduced in #548), it's probably a good idea to remove it again before cutting the 0.16 release (see #600). We could replace it with a getter/setter (needs to take is_level_1_table as arg).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions