revise pagetable entry to be 7 bytes wide -- this will allow

us to have a full 64-bit address space upon expansion of the page
number (turns out this is probably important because of the crappy
increment-only allocator used for the large blocks)
This commit is contained in:
bunnie 2021-11-24 01:49:22 +08:00
parent 42e926fcab
commit 66a5b97705
2 changed files with 4 additions and 7 deletions

View file

@ -43,12 +43,10 @@ impl Default for PtFlags {
#[repr(packed)]
#[derive(Default)]
pub(crate) struct Pte {
/// the virtual address is 48 bits long
pddb_addr: [u8; 6],
/// the virtual page number is 52 bits long (52 + 12 = 64). 4 bits are wasted in this representation.
pddb_addr: [u8; 7],
/// this maps to a u8
flags: PtFlags,
#[allow(dead_code)]
reserved: u8,
/// 32-bit strength of a nonce, but can be varied
nonce: [u8; 4],
/// 32-bit "weak" checksum, used only for quick scans of the PTE to determine a coarse "in" or "out" classifier
@ -59,9 +57,8 @@ impl Pte {
pub fn new(va: VirtAddr, flags: PtFlags, entropy: Rc<RefCell<TrngPool>>) -> Self {
let nonce_u32 = entropy.borrow_mut().get_u32();
let mut pte = Pte {
pddb_addr: va.get().to_le_bytes()[..6].try_into().unwrap(),
pddb_addr: va.get().to_le_bytes()[..7].try_into().unwrap(),
flags,
reserved: 0,
nonce: nonce_u32.to_le_bytes(),
checksum: [0; 4],
};

View file

@ -483,7 +483,7 @@ class Pte:
return self.bytes
def addr(self):
return int.from_bytes(self.bytes[:6], 'little')
return int.from_bytes(self.bytes[:7], 'little')
def flags(self):
if self.bytes[6] == 1:
return 'CLN'