KVM: arm64: Make hyp_panic() more robust when protected mode is enabled
authorWill Deacon <will@kernel.org>
Fri, 13 Aug 2021 13:03:36 +0000 (14:03 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 18 Aug 2021 09:10:16 +0000 (10:10 +0100)
commitccac96977243d7916053550f62e6489760ad0adc
tree4015300e57259a0f622b5f1b059b9c093c2e9260
parent12593568d7319c34c72038ea799ab1bd0f0eb01c
KVM: arm64: Make hyp_panic() more robust when protected mode is enabled

When protected mode is enabled, the host is unable to access most parts
of the EL2 hypervisor image, including 'hyp_physvirt_offset' and the
contents of the hypervisor's '.rodata.str' section. Unfortunately,
nvhe_hyp_panic_handler() tries to read from both of these locations when
handling a BUG() triggered at EL2; the former for converting the ELR to
a physical address and the latter for displaying the name of the source
file where the BUG() occurred.

Hack the EL2 panic asm to pass both physical and virtual ELR values to
the host and utilise the newly introduced CONFIG_NVHE_EL2_DEBUG so that
we disable stage-2 protection for the host before returning to the EL1
panic handler. If the debug option is not enabled, display the address
instead of the source file:line information.

Cc: Andrew Scull <ascull@google.com>
Cc: Quentin Perret <qperret@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210813130336.8139-1-will@kernel.org
arch/arm64/kvm/handle_exit.c
arch/arm64/kvm/hyp/nvhe/host.S