KVM: arm64: Apply hyp relocations at runtime
authorDavid Brazdil <dbrazdil@google.com>
Tue, 5 Jan 2021 18:05:38 +0000 (18:05 +0000)
committerMarc Zyngier <maz@kernel.org>
Sat, 23 Jan 2021 14:01:00 +0000 (14:01 +0000)
commit6ec6259d7084ed32e164c9f7b69049464dd90fa5
tree775107adfbbf9d41e3591b1083b4f194e9177a07
parent8c49b5d43d4c45ca0bb0d1faa23feef2e76e89fa
KVM: arm64: Apply hyp relocations at runtime

KVM nVHE code runs under a different VA mapping than the kernel, hence
so far it avoided using absolute addressing because the VA in a constant
pool is relocated by the linker to a kernel VA (see hyp_symbol_addr).

Now the kernel has access to a list of positions that contain a kimg VA
but will be accessed only in hyp execution context. These are generated
by the gen-hyprel build-time tool and stored in .hyp.reloc.

Add early boot pass over the entries and convert the kimg VAs to hyp VAs.
Note that this requires for .hyp* ELF sections to be mapped read-write
at that point.

Signed-off-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210105180541.65031-6-dbrazdil@google.com
arch/arm64/include/asm/kvm_mmu.h
arch/arm64/include/asm/sections.h
arch/arm64/kernel/smp.c
arch/arm64/kvm/va_layout.c