[PATCH v2 3/8] KVM: arm64: Discard a pending SError when resetting a vcpu

From: Dan Carpenter

Date: Wed Nov 25 2026 - 01:57:07 EST


Resetting a vcpu with the KVM_ARM_VCPU_INIT ioctl keeps a pending
SError. We used to rely on vcpu_reset_hcr() to clear the SError but
commit f1ff3fc5209a ("KVM: arm64: unify code to prepare traps") changed
it to only reset HCR_EL2 before the vcpu's very first KVM_RUN.

If we reboot a guest while there is a pending SError then KVM delivers
it to the freshly booted guest.

Clear HCR_EL2.VSE in kvm_reset_vcpu().

Fixes: f1ff3fc5209a ("KVM: arm64: unify code to prepare traps")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Dan Carpenter <dan@xxxxxxxx>
---
v2: new patch
---
arch/arm64/kvm/reset.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index 9c1b42890c96..a5d298d5ce61 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -207,6 +207,9 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
/* Reset system registers */
kvm_reset_sys_regs(vcpu);

+ /* Discard a pending SError */
+ vcpu->arch.hcr_el2 &= ~HCR_EL2_VSE;
+
/*
* Additional reset state handling that PSCI may have imposed on us.
* Must be done after all the sys_reg reset.

--
2.53.0