arm64: omit [_text, _stext) from permanent kernel mapping
authorArd Biesheuvel <ardb@kernel.org>
Tue, 17 Nov 2020 12:47:27 +0000 (13:47 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 17 Nov 2020 16:14:20 +0000 (16:14 +0000)
commite2a073dde9218cdef3c5431bddabf4549dd65fea
tree979aa59ce9533be065c22f316c68346783f5e4d4
parentf8394f232b1eab649ce2df5c5f15b0e528c92091
arm64: omit [_text, _stext) from permanent kernel mapping

In a previous patch, we increased the size of the EFI PE/COFF header
to 64 KB, which resulted in the _stext symbol to appear at a fixed
offset of 64 KB into the image.

Since 64 KB is also the largest page size we support, this completely
removes the need to map the first 64 KB of the kernel image, given that
it only contains the arm64 Image header and the EFI header, neither of
which we ever access again after booting the kernel. More importantly,
we should avoid an executable mapping of non-executable and not entirely
predictable data, to deal with the unlikely event that we inadvertently
emitted something that looks like an opcode that could be used as a
gadget for speculative execution.

So let's limit the kernel mapping of .text to the [_stext, _etext)
region, which matches the view of generic code (such as kallsyms) when
it reasons about the boundaries of the kernel's .text section.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20201117124729.12642-2-ardb@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/efi-header.S
arch/arm64/kernel/setup.c
arch/arm64/kernel/vmlinux.lds.S
arch/arm64/mm/init.c
arch/arm64/mm/mmu.c