From nobody Tue Feb 10 09:59:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672123770045647.5482139374999; Mon, 26 Dec 2022 22:49:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pA3lc-0006I7-4T; Tue, 27 Dec 2022 01:48:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pA3lZ-0006He-VN for qemu-devel@nongnu.org; Tue, 27 Dec 2022 01:48:49 -0500 Received: from bg4.exmail.qq.com ([43.154.221.58]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pA3lY-0006i7-1C for qemu-devel@nongnu.org; Tue, 27 Dec 2022 01:48:49 -0500 Received: from ubuntu.. ( [111.196.135.79]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 27 Dec 2022 14:48:34 +0800 (CST) X-QQ-mid: bizesmtp64t1672123715t25c56lu X-QQ-SSF: 01200000000000C0C000000A0000000 X-QQ-FEAT: znfcQSa1hKZ0gGTKmLeLCZhBxv49OQqRE+cTZBlSQHBuyR5Fm5LllHtJA13T4 du+2z+uln1omB8Lx3dcx5m07GC1PoFxR/h1KQTopv0+S2T6MjDicdV2XIe5gVJvuPt9Gm1k X0oAhvUOpIJ3yO5g0bJ2C8TbPR1qMvirUsTfx3+nW4mCNYAJ7VrHIAhDP6hDVQzgze7+sKx PYnocaLGgguVf4XdkshC7miSlm2+bJvEy9lyvdHkufSWowGYlR/xNK+l9cDAWHHWFGpxLAo G7jFr+7slAOeCopicD/syLaPz5InQZxiyxwRe0dIxqg0X/g+THpURjiCQKJVFpD0S/XFFRC mJ34JOc+ASRQiFRrgjp+dMu14HrmDrwjIsCZh2M4W1gnpoaBsg= X-QQ-GoodBg: 0 From: Bin Meng To: Alistair Francis , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PATCH 07/12] hw/char: riscv_htif: Support console output via proxy syscall Date: Tue, 27 Dec 2022 14:48:07 +0800 Message-Id: <20221227064812.1903326-8-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221227064812.1903326-1-bmeng@tinylab.org> References: <20221227064812.1903326-1-bmeng@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=43.154.221.58; envelope-from=bmeng@tinylab.org; helo=bg4.exmail.qq.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1672123772438000005 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza --- 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 =20 +/* PK system call number */ +#define PK_SYS_WRITE 64 + static uint64_t fromhost_addr, tohost_addr; static int address_symbol_set; =20 @@ -165,7 +168,19 @@ static void htif_handle_tohost_write(HTIFState *s, uin= t64_t val_written) int exit_code =3D 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] =3D=3D PK_SYS_WRITE && + syscall[1] =3D=3D HTIF_DEV_CONSOLE && + syscall[3] =3D=3D HTIF_CONSOLE_CMD_PUTC) { + uint8_t ch; + cpu_physical_memory_read(syscall[2], &ch, 1); + qemu_chr_fe_write(&s->chr, &ch, 1); + resp =3D 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); --=20 2.34.1