All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: Bin Meng <bmeng@tinylab.org>,
	Alistair Francis <Alistair.Francis@wdc.com>,
	qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH 07/12] hw/char: riscv_htif: Support console output via proxy syscall
Date: Tue, 27 Dec 2022 14:37:08 -0300	[thread overview]
Message-ID: <2cd2e26a-a57b-faea-8d07-cf64a630bdf7@ventanamicro.com> (raw)
In-Reply-To: <20221227064812.1903326-8-bmeng@tinylab.org>



On 12/27/22 03:48, Bin Meng wrote:
> At present the HTIF proxy syscall is unsupported. On RV32, only
> device 0 is supported so there is no console device for RV32.
> The only way to implement console funtionality on RV32 is to
> support the SYS_WRITE syscall.
>
> With this commit, the Spike machine is able to boot the 32-bit
> OpenSBI generic image.
>
> Signed-off-by: Bin Meng <bmeng@tinylab.org>
> ---

Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>

>
>   hw/char/riscv_htif.c | 17 ++++++++++++++++-
>   1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
> index 3bb0a37a3e..1477fc0090 100644
> --- a/hw/char/riscv_htif.c
> +++ b/hw/char/riscv_htif.c
> @@ -48,6 +48,9 @@
>   #define HTIF_CONSOLE_CMD_GETC   0
>   #define HTIF_CONSOLE_CMD_PUTC   1
>   
> +/* PK system call number */
> +#define PK_SYS_WRITE            64
> +
>   static uint64_t fromhost_addr, tohost_addr;
>   static int address_symbol_set;
>   
> @@ -165,7 +168,19 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
>                   int exit_code = payload >> 1;
>                   exit(exit_code);
>               } else {
> -                qemu_log_mask(LOG_UNIMP, "pk syscall proxy not supported\n");
> +                uint64_t syscall[8];
> +                cpu_physical_memory_read(payload, syscall, sizeof(syscall));
> +                if (syscall[0] == PK_SYS_WRITE &&
> +                    syscall[1] == HTIF_DEV_CONSOLE &&
> +                    syscall[3] == HTIF_CONSOLE_CMD_PUTC) {
> +                    uint8_t ch;
> +                    cpu_physical_memory_read(syscall[2], &ch, 1);
> +                    qemu_chr_fe_write(&s->chr, &ch, 1);
> +                    resp = 0x100 | (uint8_t)payload;
> +                } else {
> +                    qemu_log_mask(LOG_UNIMP,
> +                                  "pk syscall proxy not supported\n");
> +                }
>               }
>           } else {
>               qemu_log("HTIF device %d: unknown command\n", device);



  reply	other threads:[~2022-12-27 17:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27  6:48 [PATCH 00/12] hw/riscv: Improve Spike HTIF emulation fidelity Bin Meng
2022-12-27  6:48 ` [PATCH 01/12] hw/char: riscv_htif: Avoid using magic numbers Bin Meng
2022-12-27 17:28   ` Daniel Henrique Barboza
2022-12-28  3:31   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 02/12] hw/char: riscv_htif: Drop {to, from}host_size in HTIFState Bin Meng
2022-12-27 17:29   ` [PATCH 02/12] hw/char: riscv_htif: Drop {to,from}host_size " Daniel Henrique Barboza
2022-12-28  3:32   ` [PATCH 02/12] hw/char: riscv_htif: Drop {to, from}host_size " Alistair Francis
2022-12-27  6:48 ` [PATCH 03/12] hw/char: riscv_htif: Drop useless assignment of memory region Bin Meng
2022-12-27 17:30   ` Daniel Henrique Barboza
2022-12-28  3:33   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 04/12] hw/char: riscv_htif: Use conventional 's' for HTIFState Bin Meng
2022-12-27 17:32   ` Daniel Henrique Barboza
2022-12-28  3:35   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 05/12] hw/char: riscv_htif: Move registers from CPUArchState to HTIFState Bin Meng
2022-12-27 17:33   ` Daniel Henrique Barboza
2022-12-28  4:19   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 06/12] hw/char: riscv_htif: Remove forward declarations for non-existent variables Bin Meng
2022-12-27 17:35   ` Daniel Henrique Barboza
2022-12-28  4:22   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 07/12] hw/char: riscv_htif: Support console output via proxy syscall Bin Meng
2022-12-27 17:37   ` Daniel Henrique Barboza [this message]
2022-12-28  4:30   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 08/12] hw/riscv: spike: Remove the out-of-date comments Bin Meng
2022-12-27 17:37   ` Daniel Henrique Barboza
2022-12-28  4:30   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 09/12] hw/riscv/boot.c: make riscv_find_firmware() static Bin Meng
2022-12-27  6:48 ` [PATCH 10/12] hw/riscv/boot.c: introduce riscv_default_firmware_name() Bin Meng
2022-12-27  6:48 ` [PATCH 11/12] hw/riscv/boot.c: Introduce riscv_find_firmware() Bin Meng
2022-12-27 17:40   ` Daniel Henrique Barboza
2022-12-28  4:35   ` Alistair Francis
2022-12-27  6:48 ` [PATCH 12/12] hw/riscv: spike: Decouple create_fdt() dependency to ELF loading Bin Meng
2022-12-27 14:33   ` Daniel Henrique Barboza
2022-12-27 17:51 ` [PATCH 00/12] hw/riscv: Improve Spike HTIF emulation fidelity Daniel Henrique Barboza
2022-12-28  3:58   ` Bin Meng
2022-12-28  4:21     ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cd2e26a-a57b-faea-8d07-cf64a630bdf7@ventanamicro.com \
    --to=dbarboza@ventanamicro.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=bmeng@tinylab.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.