2026-01-20T13:29:55+05:30, Anup Patel <[email protected]>: > The hstateen0 will be programmed differently for guest HS-mode > and guest VS/VU-mode so don't check hstateen0.SSTATEEN0 bit when > updating sstateen0 CSR in kvm_riscv_vcpu_swap_in_guest_state() > and kvm_riscv_vcpu_swap_in_host_state(). > > Signed-off-by: Anup Patel <[email protected]> > --- > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c > @@ -702,28 +702,22 @@ static __always_inline void > kvm_riscv_vcpu_swap_in_guest_state(struct kvm_vcpu * > - if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SMSTATEEN) && > - (cfg->hstateen0 & SMSTATEEN0_SSTATEEN0)) > - vcpu->arch.host_sstateen0 = csr_swap(CSR_SSTATEEN0, > - smcsr->sstateen0); > + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SMSTATEEN)) > + vcpu->arch.host_sstateen0 = csr_swap(CSR_SSTATEEN0, > smcsr->sstateen0);
This could even be considered as a fix, although there is no bug at the moment (both host and guest sstateen are always 0). In the future, execution of a guest might have been tampering with the host sstateen, because sstateen is active even when hstateen.SE0=0. Reviewed-by: Radim Krčmář <[email protected]>

