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.
CONST_FRAME_METADATA_BASE_VADDR
The constant FRAME_METADATA_BASE_VADDR.
CONST_FRAME_METADATA_CAP_VADDR
The constant FRAME_METADATA_CAP_VADDR.
CONST_LINEAR_MAPPING_BASE_VADDR
The constant LINEAR_MAPPING_BASE_VADDR. The base address of the linear mapping of all physical memory in the kernel address space.
CONST_LINEAR_MAPPING_VADDR_RANGE
The constant LINEAR_MAPPING_VADDR_RANGE.
CONST_VMALLOC_BASE_VADDR
The constant VMALLOC_BASE_VADDR.
CONST_VMALLOC_VADDR_RANGE
The constant VMALLOC_VADDR_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).

Functions§

FRAME_METADATA_BASE_VADDR
FRAME_METADATA_BASE_VADDR_SPEC
FRAME_METADATA_CAP_VADDR
FRAME_METADATA_CAP_VADDR_SPEC
LINEAR_MAPPING_BASE_VADDR
LINEAR_MAPPING_BASE_VADDR_SPEC
LINEAR_MAPPING_VADDR_RANGE
LINEAR_MAPPING_VADDR_RANGE_SPEC
VMALLOC_BASE_VADDR
VMALLOC_BASE_VADDR_SPEC
VMALLOC_VADDR_RANGE
VMALLOC_VADDR_RANGE_SPEC
paddr_to_vaddr
paddr_to_vaddr_spec