Skip to content

Commit

Permalink
target/riscv: fix SBI getchar handler for KVM
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
visaev-sc authored and alistair23 committed Feb 6, 2023
1 parent 5fc0fc8 commit 947bf7f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions target/riscv/kvm.c
Expand Up @@ -467,10 +467,11 @@ static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run)
case SBI_EXT_0_1_CONSOLE_GETCHAR:
ret = qemu_chr_fe_read_all(serial_hd(0)->be, &ch, sizeof(ch));
if (ret == sizeof(ch)) {
run->riscv_sbi.args[0] = ch;
run->riscv_sbi.ret[0] = ch;
} else {
run->riscv_sbi.args[0] = -1;
run->riscv_sbi.ret[0] = -1;
}
ret = 0;
break;
default:
qemu_log_mask(LOG_UNIMP,
Expand Down

0 comments on commit 947bf7f

Please sign in to comment.