Skip to main content

TableOps

Trait TableOps 

Source
pub trait TableOps: TableReadOps {
    type TableMovability: TableMovability<Self>;

    // Required methods
    unsafe fn alloc_table(&self) -> Self::TableAddr;
    unsafe fn write_entry(
        &self,
        addr: Self::TableAddr,
        entry: PageTableEntry,
    ) -> Option<<Self::TableMovability as TableMovabilityBase<Self>>::TableMoveInfo>;
    unsafe fn update_root(
        &self,
        new_root: <Self::TableMovability as TableMovabilityBase<Self>>::TableMoveInfo,
    );
}
Expand description

The operations used to actually access the page table structures that involve writing to them, used to allow the same code to be used in the host and the guest for page table setup.

Required Associated Types§

Source

type TableMovability: TableMovability<Self>

This marker should be either MayMoveTable or MayNotMoveTable, as the case may be.

If this is MayMoveTable, the return type of Self::write_entry and the parameter type of Self::update_root will be <Self as TableReadOps>::TableAddr. If it is MayNotMoveTable, those types will be Void.

Required Methods§

Source

unsafe fn alloc_table(&self) -> Self::TableAddr

Allocate a zeroed table

§Safety

The current implementations of this function are not inherently unsafe, but the guest implementation will likely become so in the future when a real physical page allocator is implemented.

Currently, callers should take care not to call this on multiple threads at the same time.

§Panics

This function may panic if:

  • The Layout creation fails
  • Memory allocation fails
Source

unsafe fn write_entry( &self, addr: Self::TableAddr, entry: PageTableEntry, ) -> Option<<Self::TableMovability as TableMovabilityBase<Self>>::TableMoveInfo>

Write a u64 to the given address, used to write updated page table entries. In some cases,the page table in which the entry is located may need to be relocated in order for this to succeed; if this is the case, the base address of the new table is returned.

§Safety

This writes to the given memory address, and so all the usual Rust things about raw pointers apply. This will also be used to update guest page tables, so especially in the guest, it is important to ensure that the page tables updates do not break invariants. The implementor of the trait should ensure that nothing else will be reading/writing the address at the same time as mapping code using the trait.

Source

unsafe fn update_root( &self, new_root: <Self::TableMovability as TableMovabilityBase<Self>>::TableMoveInfo, )

Change the root page table to one at a different address

§Safety

This function will directly result in a change to virtual memory translation, and so is inherently unsafe w.r.t. the Rust memory model. All the caveats listed on map apply as well.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§