efi_kaslr_relocate_kernel(9)
π efi_kaslr_relocate_kernel β like, the Kernel API Manual page you didn't know you needed
okay so bestie, this one's from the Kernel API Manual and it's genuinely one of those "small function, huge consequences" situations. it's called efi_kaslr_relocate_kernel and it does exactly what it says on the tin: it relocates the kernel. π¦
β¨ NAME β¨
efi_kaslr_relocate_kernel β relocate the kernel (random if KASLR enabled)
like... that's it. that's the whole vibe. moving the kernel around, and if KASLR is on, it's giving chaos (the good kind). π
πΈ SYNOPSIS πΈ
efi_status_t efi_kaslr_relocate_kernel (unsigned long *image_addr ,
unsigned long *reserve_addr , unsigned long *reserve_size , unsigned
long kernel_size , unsigned long kernel_codesize , unsigned long
kernel_memsize , u32 phys_seed );
seven parameters, one status code, zero chill. copy it exactly, bestie, don't retype it from memory π
π ARGUMENTS π
image_addrβ pointer to where the kernel is right now. its current location. its home address, if you will πreserve_addrβ pointer to where the kernel is gonna end up. the relocated location. main character's new apartment β¨reserve_sizeβ size of the relocated kernelkernel_sizeβ size of the text + datakernel_codesizeβ size of the textkernel_memsizeβ size of the text + data + bss (yes, all three, it's a package deal π )phys_seedβ the random seed used for the relocation. this is the little sprinkle of randomness that makes KASLR do its thing π
π DESCRIPTION π
okay so here's the tea, and it's genuinely not complicated:
if KASLR is not enabled, this function relocates the kernel to a fixed address β or just leaves it chilling wherever it currently is. no drama, no randomness, very lowkey. π«Ά
if KASLR is enabled, the kernel's physical location gets randomized using the seed you pass in the parameter. that's the whole point. that's the assignment. and it ate. π₯
bestie note: the randomization is the security feature β the kernel doesn't sit at a predictable address. that's the why, and it's kind of iconic ngl.
β RETURN β
returns a status code β EFI_SUCCESS if the relocation is successful. that's the one you want. if you see anything else... π
π SEE ALSO π
- Kernel file
./drivers/firmware/efi/libstub/kaslr.c efi_kaslr_get_phys_seed(9)β the sibling. the other half of the seed lore. iykyk π
okay that's the page!! and for the little sign-off: this whole thing lives in ./drivers/firmware/efi/libstub, and the page is dated October 2026 β so yeah, future vibes only β go forth and relocate responsibly, bestie π
π§
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms