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

Radim Krčmář posted 2 patches 7 months, 1 week ago
[PATCH v2 1/2] KVM: RISC-V: reset smstateen in a better place
Posted by Radim Krčmář 7 months, 1 week ago
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

Re: [PATCH v2 1/2] KVM: RISC-V: reset smstateen in a better place
Posted by Anup Patel 7 months, 1 week ago
On Thu, May 8, 2025 at 8:02 PM Radim Krčmář <rkrcmar@ventanamicro.com> wrote:
>
> 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").

I have squashed this patch into commit 376e3c0f8aa5

Regards,
Anup

> ---
>  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
>
>