Re: [PATCH] KVM: arm64: Pend host SErrors for protected vCPUs through HCR_EL2.VSE
From: Oliver Upton
Date: Mon Oct 05 2026 - 04:31:21 EST
Hi Fuad,
On Mon, Oct 05, 2026 at 06:03:52AM +0100, Fuad Tabba wrote:
> diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c
> index d6c4fc16f8795..49a342b078365 100644
> --- a/arch/arm64/kvm/inject_fault.c
> +++ b/arch/arm64/kvm/inject_fault.c
> @@ -378,8 +378,11 @@ int kvm_inject_serror_esr(struct kvm_vcpu *vcpu, u64 esr)
> *
> * As we're emulating the SError injection we need to explicitly populate
> * ESR_ELx.EC because hardware will not do it on our behalf.
> + *
> + * A protected vCPU's PSTATE and SCTLR2_EL1 live at EL2, so pend through
> + * HCR_EL2.VSE and let the guest's own masking apply.
> */
> - if (!serror_is_masked(vcpu)) {
> + if (!vcpu_is_protected(vcpu) && !serror_is_masked(vcpu)) {
> pend_serror_exception(vcpu);
> esr |= FIELD_PREP(ESR_ELx_EC_MASK, ESR_ELx_EC_SERROR) | ESR_ELx_IL;
> vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu));
The emulated injection is only necessary when vcpu_has_nv(), it was just
convenient for the sake of testing that everything short circuits to
emulation instead of VSE.
I see Marc suggests letting the stale PSTATE.A value force the desired
behavior which seems fine to me. If that doesn't work, I'd rather
emulated injection be predicated on vcpu_has_nv() than
vcpu_is_protected() with the appropriate rephrasing of the preceding
comment.
Thanks,
Oliver