All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely
@ 2020-04-15  8:29 Ard Biesheuvel
  2020-04-15  8:39 ` Will Deacon
  2020-04-28 14:49 ` Will Deacon
  0 siblings, 2 replies; 17+ messages in thread
From: Ard Biesheuvel @ 2020-04-15  8:29 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: mark.rutland, suzuki.poulose, catalin.marinas, james.morse, will,
	Ard Biesheuvel

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 port was merged for
v3.10, the Image header 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: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 85e4149cc5d5..8e9445faa8ac 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -118,7 +118,7 @@ TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \
 		 int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \
 		 rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")
 else
-TEXT_OFFSET := 0x00080000
+TEXT_OFFSET := 0x0
 endif
 
 ifeq ($(CONFIG_KASAN_SW_TAGS), y)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-06-10  9:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15  8:29 [PATCH] arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely Ard Biesheuvel
2020-04-15  8:39 ` Will Deacon
2020-04-15  8:48   ` Ard Biesheuvel
2020-04-15  9:15     ` Will Deacon
2020-04-28 13:41     ` Will Deacon
2020-04-28 14:49 ` Will Deacon
2020-06-04 14:41   ` Marc Zyngier
2020-06-04 15:01     ` Will Deacon
2020-06-04 15:25       ` Marc Zyngier
2020-06-04 15:41         ` Ard Biesheuvel
2020-06-04 15:48           ` Ard Biesheuvel
2020-06-04 16:07             ` Marc Zyngier
2020-06-09 12:35           ` Jonathan Marek
2020-06-09 12:37             ` Ard Biesheuvel
2020-06-09 12:52               ` Jonathan Marek
2020-06-10  8:57                 ` Mark Rutland
2020-06-10  9:25                   ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.