target/riscv: fix SBI getchar handler for KVM
Character must be returned via ret[0] field (copied to a0 by KVM). Return value should be set to 0 to indicate successful processing. Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20230203135155.12449-1-vladimir.isaev@syntacore.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
5fc0fc8788
commit
947bf7fe9f
|
@ -467,10 +467,11 @@ static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run)
|
||||||
case SBI_EXT_0_1_CONSOLE_GETCHAR:
|
case SBI_EXT_0_1_CONSOLE_GETCHAR:
|
||||||
ret = qemu_chr_fe_read_all(serial_hd(0)->be, &ch, sizeof(ch));
|
ret = qemu_chr_fe_read_all(serial_hd(0)->be, &ch, sizeof(ch));
|
||||||
if (ret == sizeof(ch)) {
|
if (ret == sizeof(ch)) {
|
||||||
run->riscv_sbi.args[0] = ch;
|
run->riscv_sbi.ret[0] = ch;
|
||||||
} else {
|
} else {
|
||||||
run->riscv_sbi.args[0] = -1;
|
run->riscv_sbi.ret[0] = -1;
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qemu_log_mask(LOG_UNIMP,
|
qemu_log_mask(LOG_UNIMP,
|
||||||
|
|
Loading…
Reference in New Issue