diff mbox series

target/riscv: fix SBI getchar handler for KVM

Message ID 20230203135155.12449-1-vladimir.isaev@syntacore.com (mailing list archive)
State New, archived
Headers show
Series target/riscv: fix SBI getchar handler for KVM | expand

Commit Message

Vladimir Isaev Feb. 3, 2023, 1:51 p.m. UTC
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>
---
 target/riscv/kvm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Alistair Francis Feb. 5, 2023, 11:17 p.m. UTC | #1
On Sat, Feb 4, 2023 at 12:03 AM Vladimir Isaev
<vladimir.isaev@syntacore.com> wrote:
>
> 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>

Alistair

> ---
>  target/riscv/kvm.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
> index 30f21453d69c..0f932a5b966e 100644
> --- a/target/riscv/kvm.c
> +++ b/target/riscv/kvm.c
> @@ -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,
> --
> 2.39.1
>
>
Alistair Francis Feb. 6, 2023, 12:06 a.m. UTC | #2
On Sat, Feb 4, 2023 at 12:03 AM Vladimir Isaev
<vladimir.isaev@syntacore.com> wrote:
>
> 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>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
>  target/riscv/kvm.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
> index 30f21453d69c..0f932a5b966e 100644
> --- a/target/riscv/kvm.c
> +++ b/target/riscv/kvm.c
> @@ -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,
> --
> 2.39.1
>
>
diff mbox series

Patch

diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
index 30f21453d69c..0f932a5b966e 100644
--- a/target/riscv/kvm.c
+++ b/target/riscv/kvm.c
@@ -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,