Skip to content

Commit e3219b0

Browse files
jones-drewavpatel
authored andcommitted
riscv: KVM: Fix hart suspend_type use
The spec says suspend_type is 32 bits wide and "In case the data is defined as 32bit wide, higher privilege software must ensure that it only uses 32 bit data." Mask off upper bits of suspend_type before using it. Fixes: 763c8be ("RISC-V: KVM: Implement SBI HSM suspend call") Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250217084506.18763-9-ajones@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent c7db342 commit e3219b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/kvm/vcpu_sbi_hsm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/errno.h>
1010
#include <linux/err.h>
1111
#include <linux/kvm_host.h>
12+
#include <linux/wordpart.h>
1213
#include <asm/sbi.h>
1314
#include <asm/kvm_vcpu_sbi.h>
1415

@@ -109,7 +110,7 @@ static int kvm_sbi_ext_hsm_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,
109110
}
110111
return 0;
111112
case SBI_EXT_HSM_HART_SUSPEND:
112-
switch (cp->a0) {
113+
switch (lower_32_bits(cp->a0)) {
113114
case SBI_HSM_SUSPEND_RET_DEFAULT:
114115
kvm_riscv_vcpu_wfi(vcpu);
115116
break;

0 commit comments

Comments
 (0)