Module kspace

Module kspace 

Source
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.

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
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

Functions§

paddr_to_vaddr
paddr_to_vaddr_spec