Skip to main content

VmmPaging

Trait VmmPaging 

Source
pub trait VmmPaging {
    type PageType;
    type PageTableFlags;

    // Required methods
    fn setup_kernel_paging(
        sections: &KernelSectionInfo,
    ) -> (VirtAddr, [BootMapping; 4]);
    unsafe fn map_page(
        pmm: &mut Pmm,
        page_ptr: VirtAddr,
        virt: VirtAddr,
        phys: PhysAddr,
        page_type: Self::PageType,
        flags: Self::PageTableFlags,
    ) -> Result<(), VmmError>;
    unsafe fn map_range(
        pmm: &mut Pmm,
        page_ptr: VirtAddr,
        virt: VirtAddr,
        phys: PhysAddr,
        size: u64,
        flags: Self::PageTableFlags,
        can_overmap: bool,
    ) -> Result<(), VmmError>;
    unsafe fn unmap_page(
        page_ptr: VirtAddr,
        virt: VirtAddr,
    ) -> Result<(), VmmError>;
    unsafe fn remap_page(
        page_ptr: VirtAddr,
        virt: VirtAddr,
        new_flags: Self::PageTableFlags,
    ) -> Result<(), VmmError>;
    fn translate(page_ptr: VirtAddr, virt: VirtAddr) -> Option<PhysAddr>;
    fn translate_with_size(
        page_ptr: VirtAddr,
        virt: VirtAddr,
    ) -> Option<(PhysAddr, u64)>;
    fn vma_flags_to_page_flags(vma_flags: VmaFlags) -> Self::PageTableFlags;
    unsafe fn clone_kernel_mappings(dst: VirtAddr);
}

Required Associated Types§

Required Methods§

Source

fn setup_kernel_paging( sections: &KernelSectionInfo, ) -> (VirtAddr, [BootMapping; 4])

Initialize the kernel page tables and load them

§Panics

Panics if the PMM cannot allocate memory for the page tables

Source

unsafe fn map_page( pmm: &mut Pmm, page_ptr: VirtAddr, virt: VirtAddr, phys: PhysAddr, page_type: Self::PageType, flags: Self::PageTableFlags, ) -> Result<(), VmmError>

Map one virtual page to a physical frame. PRESENT is forced on regardless of flags.

§Safety

The caller must ensure virt is a valid kernel virtual address and phys is a valid, PMM-allocated frame.

Source

unsafe fn map_range( pmm: &mut Pmm, page_ptr: VirtAddr, virt: VirtAddr, phys: PhysAddr, size: u64, flags: Self::PageTableFlags, can_overmap: bool, ) -> Result<(), VmmError>

Map a certain block of physical memory to virtual pages calculated by the method

§Safety

The caller must ensure virt is a valid kernel virtual address and phys is a valid, PMM-allocated frame.

Source

unsafe fn unmap_page(page_ptr: VirtAddr, virt: VirtAddr) -> Result<(), VmmError>

Unmap one virtual page

§Safety

The caller must ensure virt was previously mapped and that no live code or data references the page after this call returns.

Source

unsafe fn remap_page( page_ptr: VirtAddr, virt: VirtAddr, new_flags: Self::PageTableFlags, ) -> Result<(), VmmError>

Change page table flags of an already mapped page

§Safety

The caller must ensure virt was previously mapped and that changing the page’s flags will not violate anything (example: making a page non-writable while a mutable reference is held to it)

Source

fn translate(page_ptr: VirtAddr, virt: VirtAddr) -> Option<PhysAddr>

Walk the page tables and return the phys address mapped at virt or None if the address is not mapped

Source

fn translate_with_size( page_ptr: VirtAddr, virt: VirtAddr, ) -> Option<(PhysAddr, u64)>

Walk the page tables and return a tuple of the phys address mapped at virt and the size of the page virt is mapped in, or None if the address is not mapped

Source

fn vma_flags_to_page_flags(vma_flags: VmaFlags) -> Self::PageTableFlags

Translate VMA flags to arch-specific page table flags

Source

unsafe fn clone_kernel_mappings(dst: VirtAddr)

Clone the kernel page’s mappings into a user page

§Safety

The caller must ensure that dst is a valid, mapped page

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§