Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Don't retire MMIO instruction w/ pending (emulated) SError

KVM might have an emulated SError queued for the guest if userspace
returned an abort for MMIO. Better yet, it could actually be a
*synchronous* exception in disguise if SCTLR2_ELx.EASE is set.

Don't advance PC if KVM owes an emulated SError, just like the handling
of emulated SEA injection.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20250708172532.1699409-24-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>

+4 -2
+4 -2
arch/arm64/kvm/mmio.c
··· 72 72 return data; 73 73 } 74 74 75 - static bool kvm_pending_sync_exception(struct kvm_vcpu *vcpu) 75 + static bool kvm_pending_external_abort(struct kvm_vcpu *vcpu) 76 76 { 77 77 if (!vcpu_get_flag(vcpu, PENDING_EXCEPTION)) 78 78 return false; ··· 90 90 switch (vcpu_get_flag(vcpu, EXCEPT_MASK)) { 91 91 case unpack_vcpu_flag(EXCEPT_AA64_EL1_SYNC): 92 92 case unpack_vcpu_flag(EXCEPT_AA64_EL2_SYNC): 93 + case unpack_vcpu_flag(EXCEPT_AA64_EL1_SERR): 94 + case unpack_vcpu_flag(EXCEPT_AA64_EL2_SERR): 93 95 return true; 94 96 default: 95 97 return false; ··· 115 113 * Detect if the MMIO return was already handled or if userspace aborted 116 114 * the MMIO access. 117 115 */ 118 - if (unlikely(!vcpu->mmio_needed || kvm_pending_sync_exception(vcpu))) 116 + if (unlikely(!vcpu->mmio_needed || kvm_pending_external_abort(vcpu))) 119 117 return 1; 120 118 121 119 vcpu->mmio_needed = 0;