Resetting a vcpu keeps the old values of SP_EL1, ELR_EL1 and SPSR_EL1. Commit e47c2055c68e ("KVM: arm64: Make struct kvm_regs userspace-only") changed the reset to only clear the general purpose registers, SP, PC and PSTATE, and later commits moved these three registers to the system register array without a reset value. Commit 85d703746154 ("KVM: arm64: Fully zero the vcpu state on reset") fixed the FP registers and the 32-bit SPSRs the same commit missed, but not these three. The impact is that the guest that boots next can read the previous kernel's stack pointer and exception return address. KVM_GET_ONE_REG also returns the old values to userspace, and a rebooted VM doesn't start in the same state as a new one. Zero them in kvm_reset_vcpu(). Fixes: e47c2055c68e ("KVM: arm64: Make struct kvm_regs userspace-only") Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter --- 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 26081d273408..9c1b42890c96 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -199,6 +199,9 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu) /* Reset core registers */ kvm_reset_vcpu_core(vcpu); + __vcpu_assign_sys_reg(vcpu, SP_EL1, 0); + __vcpu_assign_sys_reg(vcpu, ELR_EL1, 0); + __vcpu_assign_sys_reg(vcpu, SPSR_EL1, 0); vcpu->mmio_needed = false; /* Reset system registers */ -- 2.53.0