Skip to content

Commit

Permalink
KVM: RISC-V: reset smstateen CSRs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Radim Krčmář authored and Anup Patel committed May 1, 2025
1 parent b443265 commit 87ec7d5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/riscv/kvm/vcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 87ec7d5

Please sign in to comment.