[PATCH] KVM: arm64: Drop a pending MMIO access when injecting an unmasked SError
Dan Carpenter
dan at pereq.eu
Fri Nov 27 08:23:46 PST 2026
On Wed, Nov 25, 2026 at 01:52:53PM +0000, Fuad Tabba wrote:
> Hi Dan,
>
> On Wed, 25 Nov 2026 12:26:47 +0000, Dan Carpenter <dan at pereq.eu> wrote:
> [...]
> > diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c
> > index 1d5dfd4b9e00..91b835bc939b 100644
> [...]
> > @@ -396,6 +396,14 @@ int kvm_inject_serror_esr(struct kvm_vcpu *vcpu, u64 esr)
> > return 1;
> > }
> >
> > + /*
> > + * Like the emulated entry above, an unmasked SError cancels the MMIO
> > + * access the vcpu exited on. The host's copy of a protected vcpu's
> > + * PSTATE is stale so checking serror_is_masked() doesn't make sense.
> > + */
> > + if (!vcpu_is_protected(vcpu) && !serror_is_masked(vcpu))
> > + vcpu->mmio_needed = false;
>
> Could you check PSTATE.A directly instead of calling
> serror_is_masked()? That helper treats SCTLR2_EL1.NMEA=1 as unmasked,
> but NMEA doesn't affect a virtual SError. With NMEA and PSTATE.A both
> set, the patch would drop the access while the SError stays pending.
>
> Checking PSTATE.A also covers protected vCPUs, since EL2 always sets A
> in the host's copy of a protected vCPU's PSTATE (pvm_host_pstate()).
> You can then drop the vcpu_is_protected() check. Something like:
>
> if (!(*vcpu_cpsr(vcpu) & PSR_A_BIT))
> vcpu->mmio_needed = false;
>
That obviously works. I'll send it. I wonder if it would be prettier
inside a wrapper like if (!vserror_is_masked(vcpu)) instead?
regards,
dan carpenter
More information about the linux-arm-kernel
mailing list