Expand description
Kernel memory space management.
The kernel memory space is currently managed as follows, if the address width is 48 bits (with 47 bits kernel space).
TODO: the cap of linear mapping (the start of vm alloc) are raised to workaround for high IO in TDX. We need actual vm alloc API to have a proper fix.
+-+ <- the highest used address (0xffff_ffff_ffff_0000)
| | For the kernel code, 1 GiB.
+-+ <- 0xffff_ffff_8000_0000
| |
| | Unused hole.
+-+ <- 0xffff_e100_0000_0000
| | For frame metadata, 1 TiB.
+-+ <- 0xffff_e000_0000_0000
| | For [`KVirtArea`], 32 TiB.
+-+ <- the middle of the higher half (0xffff_c000_0000_0000)
| |
| |
| |
| | For linear mappings, 64 TiB.
| | Mapped physical addresses are untracked.
| |
| |
| |
+-+ <- the base of high canonical address (0xffff_8000_0000_0000)
If the address width is (according to crate::arch::mm::PagingConsts
)
39 bits or 57 bits, the memory space just adjust proportionally.
Modulesยง
- kvirt_
area ๐ - Kernel virtual memory allocation
Structsยง
- Kernel
PtConfig ๐
Enumsยง
- Mapped
Item ๐
Constantsยง
- ADDR_
WIDTH_ ๐SHIFT - The shortest supported address width is 39 bits. And the literal values are written for 48 bits address width. Adjust the values by arithmetic left shift.
- FRAME_
METADATA_ ๐BASE_ VADDR - FRAME_
METADATA_ ๐CAP_ VADDR - FRAME_
METADATA_ ๐RANGE - KERNEL_
BASE_ VADDR - Start of the kernel address space. This is the lowest address of the x86-64โs high canonical addresses.
- KERNEL_
CODE_ ๐BASE_ VADDR - KERNEL_
END_ VADDR - End of the kernel address space (non inclusive).
- LINEAR_
MAPPING_ BASE_ VADDR - The base address of the linear mapping of all physical memory in the kernel address space.
- LINEAR_
MAPPING_ VADDR_ RANGE - VMALLOC_
BASE_ ๐VADDR - VMALLOC_
VADDR_ RANGE
Staticsยง
- KERNEL_
PAGE_ TABLE - The kernel page table instance.
Functionsยง
- activate_
kernel_ โpage_ table - Activates the kernel page table.
- init_
kernel_ page_ table - Initializes the kernel page table.
- kernel_
loaded_ offset - The kernel code is linear mapped to this address.
- paddr_
to_ vaddr - Convert physical address to virtual address using offset, only available inside
ostd