From: Radim Krčmář Date: Thu, 3 Apr 2025 11:25:24 +0000 (+0200) Subject: KVM: RISC-V: reset smstateen CSRs X-Git-Tag: v6.15-rc6~1^2~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87ec7d5249bb8ebf40261420da069fa238c21789;p=thirdparty%2Fkernel%2Flinux.git KVM: RISC-V: reset smstateen CSRs Not resetting smstateen is a potential security hole, because VU might be able to access state that VS does not properly context-switch. Fixes: 81f0f314fec9 ("RISCV: KVM: Add sstateen0 context save/restore") Signed-off-by: Radim Krčmář Link: https://lore.kernel.org/r/20250403112522.1566629-8-rkrcmar@ventanamicro.com Signed-off-by: Anup Patel --- diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 60d684c76c587..02635bac91f17 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -77,6 +77,8 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu) memcpy(cntx, reset_cntx, sizeof(*cntx)); spin_unlock(&vcpu->arch.reset_cntx_lock); + memset(&vcpu->arch.smstateen_csr, 0, sizeof(vcpu->arch.smstateen_csr)); + kvm_riscv_vcpu_fp_reset(vcpu); kvm_riscv_vcpu_vector_reset(vcpu);