• Ard Biesheuvel's avatar
    arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely · cfa7ede2
    Ard Biesheuvel authored
    TEXT_OFFSET on arm64 is a historical artifact from the early days of
    the arm64 port where the boot protocol was basically 'copy this image
    to the base of memory + 512k', giving us 512 KB of guaranteed BSS space
    to put the swapper page tables. When the arm64 Image header was added in
    v3.10, it already carried the actual value of TEXT_OFFSET, to allow the
    bootloader to discover it dynamically rather than hardcode it to 512 KB.
    
    Today, this memory window is not used for any particular purpose, and
    it is simply handed to the page allocator at boot. The only reason it
    still exists is because of the 512k misalignment it causes with respect
    to the 2 MB aligned virtual base address of the kernel, which affects
    the virtual addresses of all statically allocated objects in the kernel
    image.
    
    However, with the introduction of KASLR in v4.6, we added the concept of
    relocatable kernels, which rewrite all absolute symbol references at
    boot anyway, and so the placement of such kernels in the physical address
    space is irrelevant, provided that the minimum segment alignment is
    honoured (64 KB in most cases, 128 KB for 64k pages kernels with vmap'ed
    stacks enabled). This makes 0x0 and 512 KB equally suitable values for
    TEXT_OFFSET on the off chance that we are dealing with boot loaders that
    ignore the value passed via the header entirely.
    
    Considering that the distros as well as Android ship KASLR-capable
    kernels today, and the fact that TEXT_OFFSET was discoverable from the
    Image header from the very beginning, let's change this value to 0x0, in
    preparation for removing it entirely at a later date.
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Link: https://lore.kernel.org/r/20200415082922.32709-1-ardb@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
    cfa7ede2
Makefile 6.21 KB