Skip to content

Commit a72a99d

Browse files
jones-drewgregkh
authored andcommitted
RISC-V: KVM: Fix sbiret init before forwarding to userspace
[ Upstream commit 6b7b282 ] When forwarding SBI calls to userspace ensure sbiret.error is initialized to SBI_ERR_NOT_SUPPORTED first, in case userspace neglects to set it to anything. If userspace neglects it then we can't be sure it did anything else either, so we just report it didn't do or try anything. Just init sbiret.value to zero, which is the preferred value to return when nothing special is specified. KVM was already initializing both sbiret.error and sbiret.value, but the values used appear to come from a copy+paste of the __sbi_ecall() implementation, i.e. a0 and a1, which don't apply prior to the call being executed, nor at all when forwarding to userspace. Fixes: dea8ee3 ("RISC-V: KVM: Add SBI v0.1 support") Signed-off-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 07b90bb commit a72a99d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/kvm/vcpu_sbi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run)
9191
run->riscv_sbi.args[3] = cp->a3;
9292
run->riscv_sbi.args[4] = cp->a4;
9393
run->riscv_sbi.args[5] = cp->a5;
94-
run->riscv_sbi.ret[0] = cp->a0;
95-
run->riscv_sbi.ret[1] = cp->a1;
94+
run->riscv_sbi.ret[0] = SBI_ERR_NOT_SUPPORTED;
95+
run->riscv_sbi.ret[1] = 0;
9696
}
9797

9898
void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,

0 commit comments

Comments
 (0)