arm64: idreg-override: Prepare for place relative reloc patching
authorArd Biesheuvel <ardb@kernel.org>
Wed, 29 Nov 2023 11:16:11 +0000 (12:16 +0100)
committerWill Deacon <will@kernel.org>
Tue, 12 Dec 2023 11:13:52 +0000 (11:13 +0000)
commit01fd29092a35833ef87bd13c0a025e726550d646
tree3253d9382e02632616092fdf345a143824f464d2
parentcbc59c9a4e5785796ccac9a975a94cb52c87feb1
arm64: idreg-override: Prepare for place relative reloc patching

The ID reg override handling code uses a rather elaborate data structure
that relies on statically initialized absolute address values in pointer
fields. This means that this code cannot run until relocation fixups
have been applied, and this is unfortunate, because it means we cannot
discover overrides for KASLR or LVA/LPA without creating the kernel
mapping and performing the relocations first.

This can be solved by switching to place-relative relocations, which can
be applied by the linker at build time. This means some additional
arithmetic is required when dereferencing these pointers, as we can no
longer dereference the pointer members directly.

So let's implement this for idreg-override.c in a preliminary way, i.e.,
convert all the references in code to use a special accessor that
produces the correct absolute value at runtime.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20231129111555.3594833-58-ardb@google.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/idreg-override.c