Skip to content

Commit 87ec7d5

Browse files
radimkrcmaravpatel
authored andcommitted
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: 81f0f31 ("RISCV: KVM: Add sstateen0 context save/restore") Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com> Link: https://lore.kernel.org/r/20250403112522.1566629-8-rkrcmar@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent b443265 commit 87ec7d5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/riscv/kvm/vcpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu)
7777
memcpy(cntx, reset_cntx, sizeof(*cntx));
7878
spin_unlock(&vcpu->arch.reset_cntx_lock);
7979

80+
memset(&vcpu->arch.smstateen_csr, 0, sizeof(vcpu->arch.smstateen_csr));
81+
8082
kvm_riscv_vcpu_fp_reset(vcpu);
8183

8284
kvm_riscv_vcpu_vector_reset(vcpu);

0 commit comments

Comments
 (0)