From patchwork Sat May 21 00:03:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 574754 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1f0e:0:0:0:0 with SMTP id hs14csp2659853mab; Fri, 20 May 2022 17:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw66z7jV8fvOs2N4nIhCL0hE4kXbPZBx8Q0PADlZJCW5ja1YzcC9+9bE1aIcKbA/nYSz1Kv X-Received: by 2002:a37:4d3:0:b0:6a3:65e0:d168 with SMTP id 202-20020a3704d3000000b006a365e0d168mr618524qke.612.1653091664919; Fri, 20 May 2022 17:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653091664; cv=none; d=google.com; s=arc-20160816; b=hA6DlT9NDBf4QSnS9+UU6tjYLdbHYEYw//FPBbt2W8eynpIbcQm53N2KqPCmCDC1b8 DLqih79epvDw1aSSEJo/va/5MV8h7ZAPJKlI23u2r0AAmZjK6iTQ2OpG/MtjCOLFOSkT jvOH/wVeYwwoCT5byKZnc0/gSWZKB1cdec8NFVSx15qnFKabyfWDSsxrQAtoNJw/38AN D5HKrUqUeXZQKTi+vL7ygIN95QWXA1Pf0mnl3FDzv3qPfayQg9wxMx2faz5g/+Qx7EV1 yyGKrKvXLmdbOqiRR7BTkUuHyciGJzAzrgDQ9VE+PAwfyoYVWrHv1DHcTAP0DPIgSlfr 1+LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=aKx5f32wZeXF1bpQ2oWgZWUKZNBHgky88bygOTggs3c=; b=zH3ZXFyQh7ku3VYtlVCAD1oAgaYRIYumG54QHa7o0AxTVERn1fSVT89pa6Prx3uN8m uDkgq4futsj5nlGz1VffOGDFm7Di5fhb/R34MzrVkreSjChBbjGZEKLWdtEf5V1QGwfo nUhwA9DjMShdWz9ZsBaie8Nv8Dh6NPTXWnpc4HMIGxsmovSJRzQgYNTIghoO36WM9WBo NhpAXLzyfIMz70q4GXzuHN7sCvUy/zLoq23jmQJPV6SmUWvK3nQyhCdQcL/UfHuluaGM xDhIMSYQwDOBTE/9NXa1Xp0OMy+YsQ3ELptzcBtdZLsm+DR/CkjVzxnKzSFUhYOtmBDy cCCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VjwV3rVQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r7-20020ac85c87000000b002f3c65fe7f6si409626qta.497.2022.05.20.17.07.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 May 2022 17:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VjwV3rVQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nsCel-00082U-7x for patch@linaro.org; Fri, 20 May 2022 20:07:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nsCbK-0007zs-80 for qemu-devel@nongnu.org; Fri, 20 May 2022 20:04:11 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:52984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nsCbG-0003y5-50 for qemu-devel@nongnu.org; Fri, 20 May 2022 20:04:07 -0400 Received: by mail-pj1-x102c.google.com with SMTP id l14so9310166pjk.2 for ; Fri, 20 May 2022 17:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aKx5f32wZeXF1bpQ2oWgZWUKZNBHgky88bygOTggs3c=; b=VjwV3rVQiMT56r9p5BgNRIPgaxSx794AgkLgUJT2Av12hHQThbqK5yi7MwJfNL+LLy 5ytaAoH6onkuXKkqlNFdta2g40ZyNvLbqwgxGZ9qRLCwD6rKwJ2vy+xgrW7PnDK1rNtU V/GKK9F0vlInPTVDinvCmXMSSfSIE2stBnsFbSBNKd4313/10fpr5r6Je3wF/XdOmXVe MQZVTjLeQT3bNN1LIdoIsMBr+VRXG+Msdgo9KDwEDMJBkm0IPEgJ5ma8VC/OmxCZGSa5 S+5Y7EO/P4uDZLQkvxEA9eWN6+SDxFgNVIiDQ2jUi7FQRbApiObW9pCTUwEK1/c+UVxZ 1GnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aKx5f32wZeXF1bpQ2oWgZWUKZNBHgky88bygOTggs3c=; b=Dw9PZrdbhAQrSLRkb6qsUyr/0aMy585wuVps3Z9Lc5X/DN8aXcwjaszwsPp9quR2rM hBIkxTS3aUjU5pbkGea7P1ZPWnz5B+Pdu61nt9yEArcA4Aze0S66bX0YwH0pfNM+w24d D0EH1yOTNRlgpNdR31/mtHwuGSXFbjBYHcCtibkONo8nGIkQD+pPYQZtiYDP2expL8bo w1b/Ubp9zs01LZR/EFBVhyHaSYrzg/lcQh05JKU9HLuVV5ksYx6Q/tTm3JMi/UnFUxm8 wgIieMxzqNCHndrVgCTs5hnXAYs22twvoNfMBTkGx87Y6LObqUCDfTd5gf0o+Dd5iMVs 9N2Q== X-Gm-Message-State: AOAM53399Uwmbe8ngnYr5m2jzq6e62znjSAQj5k4yBb2O8uBUf6TcdLR MGiM2ACLmsu8qcz2a1aztyXjI3muo7Pkog== X-Received: by 2002:a17:90b:3b8b:b0:1df:f2ca:c56d with SMTP id pc11-20020a17090b3b8b00b001dff2cac56dmr7415958pjb.199.1653091443136; Fri, 20 May 2022 17:04:03 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id h8-20020a654808000000b003f9d1c020cbsm306369pgs.51.2022.05.20.17.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 17:04:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 00/49] semihosting cleanup Date: Fri, 20 May 2022 17:03:11 -0700 Message-Id: <20220521000400.454525-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Changes for v3: * Split the patch set -- only include arm-compat-semi.c changes here. * Fix softmmu_target_strlen vs mmio (pmm). * Add kerneldoc comments for guestfd.h. r~ Richard Henderson (49): semihosting: Move exec/softmmu-semi.h to semihosting/softmmu-uaccess.h semihosting: Return failure from softmmu-uaccess.h functions semihosting: Improve condition for config.c and console.c semihosting: Move softmmu-uaccess.h functions out of line semihosting: Add target_strlen for softmmu-uaccess.h semihosting: Simplify softmmu_lock_user_string semihosting: Split out guestfd.c semihosting: Inline set_swi_errno into common_semi_cb semihosting: Adjust error checking in common_semi_cb semihosting: Clean up common_semi_flen_cb semihosting: Clean up common_semi_open_cb semihosting: Return void from do_common_semihosting semihosting: Move common-semi.h to include/semihosting/ include/exec: Move gdb open flags to gdbstub.h include/exec: Move gdb_stat and gdb_timeval to gdbstub.h include/exec: Define errno values in gdbstub.h semihosting: Use struct gdb_stat in common_semi_flen_cb semihosting: Split is_64bit_semihosting per target semihosting: Split common_semi_flen_buf per target semihosting: Split out common_semi_has_synccache semihosting: Use env more often in do_common_semihosting semihosting: Move GET_ARG/SET_ARG earlier in the file semihosting: Split out semihost_sys_open semihosting: Split out semihost_sys_close semihosting: Split out semihost_sys_read semihosting: Split out semihost_sys_write semihosting: Bound length for semihost_sys_{read,write} semihosting: Split out semihost_sys_lseek semihosting: Split out semihost_sys_isatty semihosting: Split out semihost_sys_flen semihosting: Split out semihost_sys_remove semihosting: Split out semihost_sys_rename semihosting: Split out semihost_sys_system semihosting: Create semihost_sys_{stat,fstat} semihosting: Create semihost_sys_gettimeofday gdbstub: Widen gdb_syscall_complete_cb return value semihosting: Fix docs comment for qemu_semihosting_console_inc semihosting: Pass CPUState to qemu_semihosting_console_inc semihosting: Expand qemu_semihosting_console_inc to read semihosting: Cleanup chardev init semihosting: Create qemu_semihosting_console_write semihosting: Add GuestFDConsole semihosting: Create qemu_semihosting_guestfd_init semihosting: Use console_in_gf for SYS_READC semihosting: Use console_out_gf for SYS_WRITEC semihosting: Remove qemu_semihosting_console_outc semihosting: Use console_out_gf for SYS_WRITE0 semihosting: Remove qemu_semihosting_console_outs semihosting: Create semihost_sys_poll_one configs/targets/aarch64-linux-user.mak | 1 + configs/targets/aarch64_be-linux-user.mak | 1 + configs/targets/arm-linux-user.mak | 1 + configs/targets/armeb-linux-user.mak | 1 + configs/targets/riscv32-linux-user.mak | 1 + configs/targets/riscv64-linux-user.mak | 1 + include/exec/gdbstub.h | 67 +- include/exec/softmmu-semi.h | 101 -- .../semihosting}/common-semi.h | 2 +- include/semihosting/console.h | 71 +- include/semihosting/guestfd.h | 91 ++ include/semihosting/semihost.h | 14 +- include/semihosting/softmmu-uaccess.h | 59 + include/semihosting/syscalls.h | 75 ++ target/arm/common-semi-target.h | 62 + target/riscv/common-semi-target.h | 50 + gdbstub.c | 7 +- linux-user/aarch64/cpu_loop.c | 2 +- linux-user/arm/cpu_loop.c | 2 +- linux-user/main.c | 9 + linux-user/riscv/cpu_loop.c | 2 +- linux-user/semihost.c | 48 +- semihosting/arm-compat-semi.c | 984 ++++------------ semihosting/config.c | 17 +- semihosting/console.c | 153 +-- semihosting/guestfd.c | 160 +++ semihosting/syscalls.c | 1008 +++++++++++++++++ semihosting/uaccess.c | 91 ++ softmmu/vl.c | 3 +- stubs/semihost.c | 6 +- target/arm/helper.c | 4 +- target/arm/m_helper.c | 2 +- target/m68k/m68k-semi.c | 50 +- target/mips/tcg/sysemu/mips-semi.c | 2 +- target/nios2/nios2-semi.c | 48 +- target/riscv/cpu_helper.c | 2 +- semihosting/meson.build | 6 + 37 files changed, 2055 insertions(+), 1149 deletions(-) delete mode 100644 include/exec/softmmu-semi.h rename {semihosting => include/semihosting}/common-semi.h (96%) create mode 100644 include/semihosting/guestfd.h create mode 100644 include/semihosting/softmmu-uaccess.h create mode 100644 include/semihosting/syscalls.h create mode 100644 target/arm/common-semi-target.h create mode 100644 target/riscv/common-semi-target.h create mode 100644 semihosting/guestfd.c create mode 100644 semihosting/syscalls.c create mode 100644 semihosting/uaccess.c