[PATCH] target/riscv: fix SBI getchar handler for KVM

Vladimir Isaev posted 1 patch 1 year, 2 months ago
target/riscv/kvm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH] target/riscv: fix SBI getchar handler for KVM
Posted by Vladimir Isaev 1 year, 2 months ago
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(-)

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
Re: [PATCH] target/riscv: fix SBI getchar handler for KVM
Posted by Alistair Francis 1 year, 2 months ago
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
>
>
Re: [PATCH] target/riscv: fix SBI getchar handler for KVM
Posted by Alistair Francis 1 year, 2 months ago
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
>
>