[PATCH] KVM: arm64: Drop %pB on nVHE panic when stage-2 is active
Fuad Tabba
fuad.tabba at linux.dev
Sun Aug 2 04:31:55 PDT 2026
On Fri, 31 Jul 2026 at 19:22, Vincent Donnefort <vdonnefort at google.com> wrote:
>
> Currently, the host stage-2 is lazily mapped. kallsyms, accessed with
> the modifier %pB is therefore potentially unmapped. If the hyp panic
> occured with the host stage-2 lock taken, a dead lock will occur.
>
> Fixes: 6ccf9cb557bd ("KVM: arm64: Symbolize the nVHE HYP addresses")
> Signed-off-by: Vincent Donnefort <vdonnefort at google.com>
>
> diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> index 54aedf93c78b..2e1951c215ae 100644
> --- a/arch/arm64/kvm/handle_exit.c
> +++ b/arch/arm64/kvm/handle_exit.c
> @@ -509,8 +509,12 @@ void handle_exit_early(struct kvm_vcpu *vcpu, int exception_index)
>
> static void print_nvhe_hyp_panic(const char *name, u64 panic_addr)
> {
> - kvm_err("nVHE hyp %s at: [<%016llx>] %pB!\n", name, panic_addr,
> - (void *)(panic_addr + kaslr_offset()));
> + /* Kallsyms might not be mapped in the host stage-2 */
> + if (is_protected_kvm_enabled() && !IS_ENABLED(CONFIG_PKVM_DISABLE_STAGE2_ON_PANIC))
nit: this is the negation of the find_bug() guard a few lines up (not
visible here), so could the two could share a helper?
> + kvm_err("nVHE hyp %s at: %016llx!\n", name, panic_addr);
> + else
> + kvm_err("nVHE hyp %s at: [<%016llx>] %pB!\n", name, panic_addr,
> + (void *)(panic_addr + kaslr_offset()));
> }
Tested on a pKVM host with CONFIG_PKVM_DISABLE_STAGE2_ON_PANIC=n:
triggered an nVHE hyp panic and confirmed the new branch is taken and
the panic reports cleanly. The later dump_kernel_instr() is fine too,
it reads hyp text, which stays RO-mapped in the host stage-2 for
inspection, so no fault.
Reviewed-by: Fuad Tabba <fuad.tabba at linux.dev>
Tested-by: Fuad Tabba < fuad.tabba at linux.dev>
Cheers,
/fuad
>
> static void kvm_nvhe_report_cfi_failure(u64 panic_addr)
>
> base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff
> --
> 2.55.0.508.g3f0d502094-goog
>
More information about the linux-arm-kernel
mailing list