[PATCH v2 1/2] KVM: RISC-V: reset smstateen in a better place

Radim Krčmář
2025-05-08T14:31:50Z

This got missed when the series was applied out of order.

Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com>
---
Feel free to squash this patch with 376e3c0f8aa5 ("KVM: RISC-V: remove
unnecessary SBI reset state").
---
arch/riscv/kvm/vcpu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
index 7cc0796999eb..a78f9ec2fa0e 100644
--- a/arch/riscv/kvm/vcpu.c
+++ b/arch/riscv/kvm/vcpu.c
@@ -60,6 +60,7 @@ static void kvm_riscv_vcpu_context_reset(struct kvm_vcpu *vcpu)

memset(cntx, 0, sizeof(*cntx));
memset(csr, 0, sizeof(*csr));
+ memset(&vcpu->arch.smstateen_csr, 0, sizeof(vcpu->arch.smstateen_csr));

/* Restore datap as it's not a part of the guest context. */
cntx->vector.datap = vector_datap;
@@ -101,8 +102,6 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu)

kvm_riscv_vcpu_context_reset(vcpu);

- memset(&vcpu->arch.smstateen_csr, 0, sizeof(vcpu->arch.smstateen_csr));
-
kvm_riscv_vcpu_fp_reset(vcpu);

kvm_riscv_vcpu_vector_reset(vcpu);
--
2.49.0