From patchwork Wed May 17 08:01:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CC01C77B7A for ; Wed, 17 May 2023 08:09:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC75-0003kx-B1; Wed, 17 May 2023 04:02:23 -0400 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 1pzC6z-0003SB-Ui for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:17 -0400 Received: from mout.kundenserver.de ([212.227.17.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6t-0000xD-Kp for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:17 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MtfeD-1qIe4L1wnH-00v9US; Wed, 17 May 2023 10:01:54 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Afonso Bordado , Palmer Dabbelt , Laurent Vivier , Alistair Francis , LIU Zhiwei Subject: [PULL 1/9] linux-user: Emulate /proc/cpuinfo output for riscv Date: Wed, 17 May 2023 10:01:44 +0200 Message-Id: <20230517080152.108660-2-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:9Awxo4gQpL5xSuJ+eslw3xyRuWYvgpoLUuwpMFPopIKukzco+Oc o0KXumJVq8fNGiSp4LJpGIac+TlTnM6jNNRpdgXYyXsDQ/QtpIKDXdlH97hrn6magHivB9r 37dhIEZGdbvL6h2Apy1TTpYZyl4b0YKlGy/ZgwszbJa9ppsqlt2c68/a8dJxrFxCTg1lLDc 31kLdGdejmGWunwZW9Gdg== UI-OutboundReport: notjunk:1;M01:P0:DttOHe+P+HY=;u50JeHKqOOT8v0WjBD2zzUT2ebG veqz0tng5JIPF+r+W0fT/C5iWuBXig8RWKfpPZlvIATvb3lsnV2Qe5Uo9s4niVSPFVX27Tf23 qwZ5Zf5iwf8z6zRHI6pq39UrtyS6tqr5Hkc6IvW7GfQvU7AHZaYeDAFkvjm+Eev1inBdw3x0e z0ciZ0QYpeav3r5DVdPlvuGrAbZu+ZDLZxdtA2Cw2vA0SvqndYIXALE9XvwLBP1SjX1BFzG+i SDy+WMglrARFZlpNK5cHCcFw6QCe3PBeOI5mOeJxT2vXeLnAZSeZgHUnNs7sIADilWm+PIoBe pQWtKDNV+TqjNrEa9Jz+kjdSBen6wzzBAT7taERseLQA33NBw/uIzlNFwPgqIOkPO0uVtWSxu XGmEeujs9LL5FcHKbc2Tjt7MsSXMAlYEusrImoT7z2fhLpNrtsKgEZAEw4KmLDwiglxKbXbJL tvF0Pnal+s91u9CrIGUsw/xnzPD+GnxywKVRcJAaG3s6pl+6CUUQDFByWFXpVlJQKMFWU0GwJ CQC3LQs+/0kiuBw/dpPiOL++WUZoyWj6xevL0Iw1wTOnfXEHLuVTm+5Ewt4Jdwt+hJ9shhc8R +9pG1knlby7F7VEXA2AuJ24pnl83b/Tq/dWr0dxvPe3qOpEvU2FMO6iviYoH3d7vwCN++uuPZ ZcfQvrR8DAhRl1WsMSKEBw91QMmoBdGsPaA0l8zjrA== Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Afonso Bordado RISC-V does not expose all extensions via hwcaps, thus some userspace applications may want to query these via /proc/cpuinfo. Currently when querying this file the host's file is shown instead which is slightly confusing. Emulate a basic /proc/cpuinfo file with mmu info and an ISA string. Signed-off-by: Afonso Bordado Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt Reviewed-by: Laurent Vivier Reviewed-by: Alistair Francis Reviewed-by: LIU Zhiwei Message-Id: <167873059442.9885.15152085316575248452-0@git.sr.ht> [lv: removed the test that fails in CI for unknown reason] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 69f740ff98c8..085ce530213e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8231,7 +8231,8 @@ void target_exception_dump(CPUArchState *env, const char *fmt, int code) } #if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN || \ - defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA) + defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA) || \ + defined(TARGET_RISCV) static int is_proc(const char *filename, const char *entry) { return strcmp(filename, entry) == 0; @@ -8309,6 +8310,35 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd) } #endif +#if defined(TARGET_RISCV) +static int open_cpuinfo(CPUArchState *cpu_env, int fd) +{ + int i; + int num_cpus = sysconf(_SC_NPROCESSORS_ONLN); + RISCVCPU *cpu = env_archcpu(cpu_env); + const RISCVCPUConfig *cfg = riscv_cpu_cfg((CPURISCVState *) cpu_env); + char *isa_string = riscv_isa_string(cpu); + const char *mmu; + + if (cfg->mmu) { + mmu = (cpu_env->xl == MXL_RV32) ? "sv32" : "sv48"; + } else { + mmu = "none"; + } + + for (i = 0; i < num_cpus; i++) { + dprintf(fd, "processor\t: %d\n", i); + dprintf(fd, "hart\t\t: %d\n", i); + dprintf(fd, "isa\t\t: %s\n", isa_string); + dprintf(fd, "mmu\t\t: %s\n", mmu); + dprintf(fd, "uarch\t\t: qemu\n\n"); + } + + g_free(isa_string); + return 0; +} +#endif + #if defined(TARGET_M68K) static int open_hardware(CPUArchState *cpu_env, int fd) { @@ -8333,7 +8363,7 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int #if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN { "/proc/net/route", open_net_route, is_proc }, #endif -#if defined(TARGET_SPARC) || defined(TARGET_HPPA) +#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || defined(TARGET_RISCV) { "/proc/cpuinfo", open_cpuinfo, is_proc }, #endif #if defined(TARGET_M68K) From patchwork Wed May 17 08:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3ADDCC77B75 for ; Wed, 17 May 2023 08:10:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC6v-00038F-L9; Wed, 17 May 2023 04:02:13 -0400 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 1pzC6i-0002jt-Ai for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:00 -0400 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6g-0000uD-6d for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:00 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M2fQ9-1q17Fd4BOp-0049IS; Wed, 17 May 2023 10:01:55 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 2/9] linux-user: report ENOTTY for unknown ioctls Date: Wed, 17 May 2023 10:01:45 +0200 Message-Id: <20230517080152.108660-3-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:JHrf53yipW3GNGGa0qVyKTs8oj12+PKYR8ujgwXIXpD2Ly6vutP UrOQMsq9YPsJraVwOhNZ3Rg6vLgumZVf5rU9Q/B+nSOfjbWdQP2cYwxmd5dSr+d2YKO6t8f /iF1rp8in7ePPFdsmWoKhnF8m+o7jlNUoHJP/RtxnIS7ot/7lfPX3zVf+fbkh+IAkImR1f5 kHzQy47woJJ2jENJ0deww== UI-OutboundReport: notjunk:1;M01:P0:kt7MXMvMeyk=;n30AaN9Md5Nm90PbL6UyeWs1BsB fSAceAFDQBzaGDX/xdG4B15RlHIpU2Qymiy+/3+r00aTkZETpPRlcMFBJs6GNUh1ebTzUVoRN m+pbzHcuQzQYbdRIuoZHUEU3C875cDwr263CzYZI1rvq1SN7IVQOiux2uUlBJX04OBOuZGTTn g2QcVKqUurdBk7k4PK2p62QPFSiO7+Wnf5jJemDwsqI61GQbvbgqajD/HCXZ1K1tZwjjb5cZe XJwXUmM6TTUWHeRuWCCMzeWAmScwtTeg2E7DelRSSUi2U51Tmyul8BO95Y+DC0LIfeNAbz7iI 3mb/iOXjomZR4DEm9ehIcyUeupf5TqClVFslT//07ShawS+DMLFNLi+D+TYNAAcbpVGETVoUF wBmL2u6bolbHOn8giBLONicsjbGAR738I0u7+PvCrjyl82ziwamHIaq+mq9YZtFIygQGlyHUq NpmYJzb3Yw40OGEI23HmxyrhiwuVf25V3PTYHD99ywmjzDxpLzTNUky4pL5lKeFXq/Uv5C5fj vAqUj73nrRvW8Lr0Ba72/yvTKEVkWDx+4bsUdB1s4O5SvoMU1v4NF7UzbagFO2Dwnjl/A+FzS ZfguFesdYk/P3x9Cs5GespGYA9l8l044dVy9OUSgcW9dMXzekLpIspkcZwxHUZQ1CkbbVRQoM T4mrCLHVlNatM5AoIMzLH4Og8RK3XFIx645g07RYSA== Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh The correct error number for unknown ioctls is ENOTTY. ENOSYS would mean that the ioctl() syscall itself is not implemented, which is very improbable and unexpected for userspace. ENOTTY means "Inappropriate ioctl for device". This is what the kernel returns on unknown ioctls, what qemu is trying to express and what userspace is prepared to handle. Signed-off-by: Thomas Weißschuh Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230426070659.80649-1-thomas@t-8ch.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 085ce530213e..954ed14df4c0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5747,7 +5747,7 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) if (ie->target_cmd == 0) { qemu_log_mask( LOG_UNIMP, "Unsupported ioctl: cmd=0x%04lx\n", (long)cmd); - return -TARGET_ENOSYS; + return -TARGET_ENOTTY; } if (ie->target_cmd == cmd) break; @@ -5759,7 +5759,7 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) } else if (!ie->host_cmd) { /* Some architectures define BSD ioctls in their headers that are not implemented in Linux. */ - return -TARGET_ENOSYS; + return -TARGET_ENOTTY; } switch(arg_type[0]) { @@ -5817,7 +5817,7 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) qemu_log_mask(LOG_UNIMP, "Unsupported ioctl type: cmd=0x%04lx type=%d\n", (long)cmd, arg_type[0]); - ret = -TARGET_ENOSYS; + ret = -TARGET_ENOTTY; break; } return ret; From patchwork Wed May 17 08:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5E3BC7EE23 for ; Wed, 17 May 2023 08:02:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC70-0003T2-Rm; Wed, 17 May 2023 04:02:19 -0400 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 1pzC6n-0002oQ-JQ for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:05 -0400 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6g-0000uC-FP for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:05 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mqro7-1qUBBy1nSj-00mqxe; Wed, 17 May 2023 10:01:55 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Laurent Vivier Subject: [PULL 3/9] linux-user: Add move_mount() syscall Date: Wed, 17 May 2023 10:01:46 +0200 Message-Id: <20230517080152.108660-4-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:KH00k4QrHYFHPdOrGsGq13QWDwUMHCkOxOge9gv/xEf0Riwcieb eR7DFVPtKhTcCazzw8sod5dU9LVAV8N9Bq18C3COpzbR6y3noyf0cCb74/1aY14clP9NMqR FHeFE4yuGJPYFXqbOOuCnI7PDgkUpe25WzNIKs39Hcvv8FXFOh1aILdiTnXatOpo58ra1B3 OnUT+G7UQpR8vg+2YkCZg== UI-OutboundReport: notjunk:1;M01:P0:JUvrKtqZOtw=;T4Grp5wfpwS+Ly9T5O3bA2ErxgV jdBeI2sjRdKxegq60eloRJDvEP60oYq/3k/553hggeoeaSVlAaxr2XktFXU5GFPH0KTh74o8g bQGdEMcZKNcpnbdMexEEoXaqSj4zGUqeJp1dmrKDmBTThkoth4HMWG1dI3gs71OfrH9XGcFol Ak3SvJS9sV3SoZxQFaDtSfY2yswCjedmsFrf6pps+YhUw0N8h/YRpe8YvurOZ085aiCxBPT0b ppgXN+87bWptvvL7VkU1ZjHF+Rm/4Nxn3y6m3dGlu+dsqNXAP28+Yjz2L1uCpev/WJNpRKSvx WlNIz7dJV8qpmbnEz0r64bJKbirLuXhiYLd30LK7lC6+AIexa120xmW2++OVjS/tdi+IgTvw7 ozb/78uJlzYnFn1V7Kj79Bl4h65VKSWloos6IHLuwbkKH0MN9g5MUz3ellzL961NmMcmuL4gu Iv6O+4ssr/K7bclC+mmqC1DZNx0LpG6Dg837qWS4g6uFYfTCL5B6b8GzETalt3hTvMjGWpnJQ +zRuy6t/mkWVtc+/qTRQGzAX8xko5ySwbcYuCVLs3bWiUToelMA974+lrUq6sYq4BupsTfGYA 7HsGSRtKGvp31nSuElquTBeu/2GOG/CaSpg9+tepryf1zCTlzPmCDCDPjhXSnMA183uPTlJX1 x1xGDIPvRD2EtMKIksp0tP/tWHUq9aXfAD9NQFrliQ== Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Reviewed-by: Laurent Vivier [lv: define syscall] Message-Id: <20230424153429.276788-1-thomas@t-8ch.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 954ed14df4c0..9a99e4557367 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8776,6 +8776,12 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) _syscall2(int, pivot_root, const char *, new_root, const char *, put_old) #endif +#if defined(TARGET_NR_move_mount) && defined(__NR_move_mount) +#define __NR_sys_move_mount __NR_move_mount +_syscall5(int, sys_move_mount, int, __from_dfd, const char *, __from_pathname, + int, __to_dfd, const char *, __to_pathname, unsigned int, flag) +#endif + /* This is an internal helper for do_syscall so that it is easier * to have a single return point, so that actions, such as logging * of syscall results, can be performed. @@ -9169,6 +9175,33 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); return ret; #endif +#if defined(TARGET_NR_move_mount) && defined(__NR_move_mount) + case TARGET_NR_move_mount: + { + void *p2, *p4; + + if (!arg2 || !arg4) { + return -TARGET_EFAULT; + } + + p2 = lock_user_string(arg2); + if (!p2) { + return -TARGET_EFAULT; + } + + p4 = lock_user_string(arg4); + if (!p4) { + unlock_user(p2, arg2, 0); + return -TARGET_EFAULT; + } + ret = get_errno(sys_move_mount(arg1, p2, arg3, p4, arg5)); + + unlock_user(p2, arg2, 0); + unlock_user(p4, arg4, 0); + + return ret; + } +#endif #ifdef TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: { From patchwork Wed May 17 08:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 711B6C77B75 for ; Wed, 17 May 2023 08:11:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC6x-0003KP-Ht; Wed, 17 May 2023 04:02:15 -0400 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 1pzC6m-0002nv-MC for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:05 -0400 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6g-0000uB-E7 for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:04 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MLyzP-1phwCg3VvF-00Hy7O; Wed, 17 May 2023 10:01:56 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Laurent Vivier Subject: [PULL 4/9] linux-user: Add open_tree() syscall Date: Wed, 17 May 2023 10:01:47 +0200 Message-Id: <20230517080152.108660-5-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:nB26NVKetrMmXJOFJGO4fmgeyuLjqBdBC7YVH9UFXjU5PsFJymq sidAyqjY7wqIHfS5p0z6/lOfmbhHF4Yxn6d02BV4DYJItm39sQ3Zg+gONGncNJUCubcCWEE OMyK7gQom1JOMYzskTnWb90oNdzGRxn8w574H7uinmVKJyHCJwK0uwkxSoEkS7IYIkhA5Iq pphQ9QrMRYNZCZ4yDLKXg== UI-OutboundReport: notjunk:1;M01:P0:pCY10uAE3BQ=;LkNmG9CujVFVok+7wpSF6AFA853 rKgrGAv4mcEPoNcA/8F/O0hDiNaKH1gSP2C2ui66odQd/XYrFxw/jVXKhFmpKPpWlTB1neRxJ y1w/Am4corvyUyuSBzrWG2j0yuDtF8p1k8Usckkiic692XnrsDy/E/RbXQrlHdNBxRlEIFDGi 9h1E479dzz+DEF6fWAtCiX+cEBxRGZBFXuPaswYwbckySiZC7U+00X5j5EjFz1C+zYSg3+Wlj 3/h902EUFhUDIKTCsDzKlZnpLeCnt3e8cRrmNcr8YlLsjDuFs8RtrNzyGXiBxZssV94u5u7tI eDcNvzxRKzV5SzchG3rgN1LTkNVrbvVjTBI6dtKi45aD/AZaVwJIllBFRG028jjiloe3gs5QO gEgVodiIvo8pjoUcRLzmgTipxeFkZFgmfRyd36fZewMi0RRQPJIv6HQW1B/8QKO3bcuP8Zd+K aQjDV9l7Pbz9SKUnQt+uqUgfH/V2hcuD3tzIzl9dQ9K0YNYIorOix5vcceekt+BihAX8nZVD9 XTDzMQBEyzw2YnhDejzTXq2OgYoin7+00BbUeO1//TYhyfJVaZiYhux0WloOxhEJcfOUWWfzp mrjtgWalhVwsLPMq7asgHYMTLnd8PKHonte6zRHF73kyjnfrhf9UCN1uDq4Kx2LVw/DHCpdxl 0lQz9fNnHdwYTzIpdZtGli/Q3EjidYAtUbWq0p/TRA== Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Reviewed-by: Laurent Vivier Message-Id: <20230424153429.276788-2-thomas@t-8ch.de> [lv: move declaration at the beginning of the block, define syscall] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9a99e4557367..00a779797efb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8776,6 +8776,12 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) _syscall2(int, pivot_root, const char *, new_root, const char *, put_old) #endif +#if defined(TARGET_NR_open_tree) && defined(__NR_open_tree) +#define __NR_sys_open_tree __NR_open_tree +_syscall3(int, sys_open_tree, int, __dfd, const char *, __filename, + unsigned int, __flags) +#endif + #if defined(TARGET_NR_move_mount) && defined(__NR_move_mount) #define __NR_sys_move_mount __NR_move_mount _syscall5(int, sys_move_mount, int, __from_dfd, const char *, __from_pathname, @@ -9202,6 +9208,33 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return ret; } #endif +#if defined(TARGET_NR_open_tree) && defined(__NR_open_tree) + case TARGET_NR_open_tree: + { + void *p2; + int host_flags; + + if (!arg2) { + return -TARGET_EFAULT; + } + + p2 = lock_user_string(arg2); + if (!p2) { + return -TARGET_EFAULT; + } + + host_flags = arg3 & ~TARGET_O_CLOEXEC; + if (arg3 & TARGET_O_CLOEXEC) { + host_flags |= O_CLOEXEC; + } + + ret = get_errno(sys_open_tree(arg1, p2, host_flags)); + + unlock_user(p2, arg2, 0); + + return ret; + } +#endif #ifdef TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: { From patchwork Wed May 17 08:01:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8A0DC77B75 for ; Wed, 17 May 2023 08:10:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC6z-0003PI-P1; Wed, 17 May 2023 04:02:17 -0400 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 1pzC6o-0002s5-Vq for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:07 -0400 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6i-0000v3-WB for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:05 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MV5G4-1pYM541pF0-00SBNt; Wed, 17 May 2023 10:01:56 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Thomas Huth , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 5/9] linux-user/main: Use list_cpus() instead of cpu_list() Date: Wed, 17 May 2023 10:01:48 +0200 Message-Id: <20230517080152.108660-6-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qimp3/uAReEsbHbhFU2YOHSkDqU6jHjSlSbkY0eaE87bhnH/D+k A4lepgYeW4zaBZmGXI542UwO2BJP+CUXLbnMiRaYFqkgeIsUKWQ1Dvpb3QxnJigDDklC/9d 4pDPYZgDsSZFS8rpjIiBqqV1RaHLQpVMThB4/wxl4imhjJFtPpwgUPEIGuf4gU57VQCIC6P 8jsdHFEdzeLi4xnlP0VcA== UI-OutboundReport: notjunk:1;M01:P0:njDmsY3RH40=;+0FP3SsRfGR4gCl0rYQhgVpTAwb H4cpIZDTjH9PFMegWAtxkS66vHxtu7JcHo7duWfSzl7VHJ3fs7Ju3IFJvdY4EzgDLpp9uHYZr 7UNanRXp5C9lKGSVPseSUShllYuXVU7CVm+/7Z8vRyJa8g57TWenCCIed+t1W/nRCvyCjVGul 7GIt29FXG3HJsauDcuWJgYEzzzBz/XwdJnPfvKjxApAfHKTDBw5hNTL0TOordknRl5lMd9H2e Y43KaJgVt0ycjBSspKxEaFcolCkZ90LkXLLcmSn0aVMZIOllssOoNe/Ns/yX0qu73kYFcIpr1 tgLk7yESatCL9LN9bvbtJ0wQLhLsnbsxdMTCCvNHKl+VWMZlCKQshS0+FqdeWdGcPVdhCXdms 9rcZLyMX3bvvOAdI8bcd9Iam73eg37kGPkxYgLY2au0wVg00plTxI6ryefqdF5omYGxOqvbpQ NclIXeCRyAM4rT8x3xGNqWJzNoMIzq2BVUFCjzxo4QYSR7I0u7l2tPpAPhtws+JRZ9xS7h1qt 8FCMgo/cVZXGieFq+rInAnt/LN5VXfLZC2Lw0yTuDCmCKqMJ/W2eE8CazeLqx+yjoP2aSK6Xk GS0DW/DzRNJ/IRw3/Pbe+4hWd8HYv68vBARF1WG/h5WPUGf6l75yDUmStg+JAeP1LQrVVpYfQ jvrPosj3h/54nBWXMui14SCw2lSJe5yXBd9aIMZc/g== Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Huth This way we can get rid of the if'deffery and the XXX comment here (it's repeated in the list_cpus() function anyway). Signed-off-by: Thomas Huth Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230424122126.236586-1-thuth@redhat.com> Signed-off-by: Laurent Vivier --- linux-user/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index fe03293516a5..aece4d9e9119 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -359,10 +359,7 @@ static void handle_arg_cpu(const char *arg) { cpu_model = strdup(arg); if (cpu_model == NULL || is_help_option(cpu_model)) { - /* XXX: implement xxx_cpu_list for targets that still miss it */ -#if defined(cpu_list) - cpu_list(); -#endif + list_cpus(); exit(EXIT_FAILURE); } } From patchwork Wed May 17 08:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1F0FC77B7A for ; Wed, 17 May 2023 08:06:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC70-0003Sd-Et; Wed, 17 May 2023 04:02:18 -0400 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 1pzC6p-0002sM-77 for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:07 -0400 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6h-0000ud-Lc for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:06 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MmCyE-1qPUMm3dbc-00iC8J; Wed, 17 May 2023 10:01:57 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Laurent Vivier Subject: [PULL 6/9] linux-user: Add new flag VERIFY_NONE Date: Wed, 17 May 2023 10:01:49 +0200 Message-Id: <20230517080152.108660-7-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:oAT+Una1TjyWTn6GqRDNTiKsxtCZy6xtgSSGjhEfdQKcl7CbQcJ RaCWc2yOlzNU71JGA4nhC6UylGF+tvDHKk6EmqR/B6h3P0AIRZjVzAO7xZWBpNAEpRgWupl uxcV8spH8DKinKRv1tfxF7Dq2SSvNkiom/bevSCOzDJuzoOGaxyURf4srHkmys4f4jrhAiK 7FRLW6u3At6RDUXLlsoag== UI-OutboundReport: notjunk:1;M01:P0:UjIRLd+bJ24=;ZKVpAVUDfOaPUv8JY/TOH8SLPCr igT8UlgfR3ON9VsXVN5AxJhY3OphOO612XhDOGZbDz7P58SsCnCg1rQuvg1SKawkAUYKIJjj/ g/snzejH02m47m+qO95/7powrh6Y3biN+9AOdJbfyY5RzexHuFM1YHi2McMKweau3Tc4mrhgQ fM34t7XKQjhRD4kQ6TurIr4ZiqcEDcLkUPgDNl20izygtV5gUmYIOZvBD4+s4XVORbFRk3KST tJ3ZrsMwEB3Yjj6HtFxS/KIFFjQUl7AnAZZyExfeC/pbJ+48LcZ6hFpNS1MRMGisLrUb4ErBZ rlHiIsu2MsTtUng5v7cptiidBYpcYxQ/twt2FUJER0Ie76ur0E6L0Q9Fe4BYvdG5ylMQfcAWd e5SyNsUYJMVEWVDOQrritf8WKOg59T5vLHpedG+wSqKn2nTUQwIP9FiCsQssWR08f5UCTq/oy 3NE+Cx7FUWloWzZJZnsYaDUkdeWpC/U56+B+n43GJh277xGmO8krgcunQ3ays8xdAx6/kGHJk D+NMzzNa5qCW1sP4x3fI3Jb5fPxQCxe5rjv/rYlnwPBa/1aYQ+sU+sVBJq8yA4t5ifMRuW/MB L/RkwCD1FxAAZZOeGNLKQ7NRE3MGERnveHEgI0hBgU+3RUjlQiAan1Sb1RLiPGu4L/SHAbrD4 ivIhzfWk1uDbiKSByga8gt9DEk2DgMsFiL7hh/BX6g== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh This can be used to validate that an address range is mapped but without being readable or writable. It will be used by an updated implementation of mincore(). Signed-off-by: Thomas Weißschuh Reviewed-by: Laurent Vivier Message-Id: <20230422100314.1650-2-thomas@t-8ch.de> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index e2e93fbd1d5d..92f9f5af41c7 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -168,6 +168,7 @@ abi_long do_brk(abi_ulong new_brk); /* user access */ +#define VERIFY_NONE 0 #define VERIFY_READ PAGE_READ #define VERIFY_WRITE (PAGE_READ | PAGE_WRITE) From patchwork Wed May 17 08:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8373C77B7A for ; Wed, 17 May 2023 08:08:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC71-0003Tc-7f; Wed, 17 May 2023 04:02:19 -0400 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 1pzC6k-0002mP-7y for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:02 -0400 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6h-0000ub-JV for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:01 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M3DeV-1q0Z1E16Wz-003b4A; Wed, 17 May 2023 10:01:57 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Laurent Vivier Subject: [PULL 7/9] linux-user: Don't require PROT_READ for mincore Date: Wed, 17 May 2023 10:01:50 +0200 Message-Id: <20230517080152.108660-8-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:cqryMb7V7oFhMu2vdHsnFSagyd+sZZB1Bi3Fr2Jz17mWuf8DSyo BLHml4hLjgOhX0WfYkcZ9mezhguGDMKOrfpXRHXDv6GJp74YgM0MRAkVa1UsFC7Whcrza4q wvR3GgHLCmEzYifgfqhfLNZK3Wi53MxPsZRmkinRYt++/WVzLo3T9clu5NDXymGR3UKzjpM kuVUSpUgp05AIwS+1C6QA== UI-OutboundReport: notjunk:1;M01:P0:k3ah0thcQ8I=;a0SoY/SSPjdLBBXmglTjHVBIXuV Rpi+2AiBHgNa5H7ZqCcxZT+aW4ykXUIGXwKaik+WQvDhFffOEhFu7k5gmevagahVbWoldA6AH jPXVSRUQLge9UeZSrR0GGHhEY/CHjn/fSmPU7gtDkbd9CBUWMvmO86v3hLuzPKOU9MFUoBVS+ 0OxgUO9+o8VQPsZswA9SSOA18AeG1z1XaBwRPFI/WdjgBvtS+YjZgDFqki+ApyPhCzwB5zJIz Wxb0jEJCCI4rncYef3ujotFrI9Z5GB8eBpymRUCD4F8NY6AjquhVzrGYf5G6Yx7jZ5/uVuf6f IhRpokMpbXi00++KcS7QdVPllPoEc7ruy4ViqAeNGZlZJA+PhEBdZggfRCy+YZ10YOVjKQmS+ /nsdLhfoul3O/w0f7xRHL5Opyt/ofL3vrmNWK+fxMupMePoJYl2RA+YReEEnDHgKq7gOPYJHw P+0L49t04/+fATN6/z9S7yv4XqFhtVkEUGXw+zdKx3v8pqzqv0kFQAQbCP7nFHtgp/A1BrUip v4nfdH1VYtfcG1MY+Xvb67KwG2IIh0in/LNNyB5SYlMSYxPAlYDDVrLDG0RL3JkOo4yfFNZvV 5cSPgmIyH2nKuS4+xGEJr0LXufHpXvWOvzVa32ohQPR86OQsw/8aedRwymFhuAgIGtc6MLMoL HF/yD8I/rNqz7dFhMlEyY4FmHFsplVgcQQdoWWkzNw== Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh The kernel does not require PROT_READ for addresses passed to mincore. For example the fincore(1) tool from util-linux uses PROT_NONE and currently does not work under qemu-user. Example (with fincore(1) from util-linux 2.38): $ fincore /proc/self/exe RES PAGES SIZE FILE 24K 6 22.1K /proc/self/exe $ qemu-x86_64 /usr/bin/fincore /proc/self/exe fincore: failed to do mincore: /proc/self/exe: Cannot allocate memory With this patch: $ ./build/qemu-x86_64 /usr/bin/fincore /proc/self/exe RES PAGES SIZE FILE 24K 6 22.1K /proc/self/exe Signed-off-by: Thomas Weißschuh Reviewed-by: Laurent Vivier Message-Id: <20230422100314.1650-3-thomas@t-8ch.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 00a779797efb..6655982821ba 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11993,7 +11993,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { - void *a = lock_user(VERIFY_READ, arg1, arg2, 0); + void *a = lock_user(VERIFY_NONE, arg1, arg2, 0); if (!a) { return -TARGET_ENOMEM; } From patchwork Wed May 17 08:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F04AC77B7A for ; Wed, 17 May 2023 08:11:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC72-0003ZG-Vf; Wed, 17 May 2023 04:02:20 -0400 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 1pzC6p-0002sV-C0 for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:07 -0400 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6k-0000vU-Qc for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:07 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M27ix-1q1ewu3801-002UbS; Wed, 17 May 2023 10:01:57 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Daniil Kovalev , Jiaxun Yang , Laurent Vivier Subject: [PULL 8/9] linux-user: Fix mips fp64 executables loading Date: Wed, 17 May 2023 10:01:51 +0200 Message-Id: <20230517080152.108660-9-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:JsZWCb8o+WmcOT6ilvaEAFIWLP7z2Z5KIRsBNi8BaAIsNL3BfhL IKylcOmLeELSsu2T98nm5rqf3O0CARiABc05/xOZALFwo2f8U+8rdb4Uo1/2CPQoW6//FMo 8N/idZzWu0iBhf/Abhu0fTIOvhyp7zVCHxs/niyRmT4WzMB+yttqFoi4kdw03NOBrj2yihy Al7SwC6Tg84wvgpGzK7Jg== UI-OutboundReport: notjunk:1;M01:P0:DsFU1jWjiYI=;Y/HXhQfn9DN+Vw3W5V7Ig3GZqh4 PgkV0nas8Z4neXiUzDCscuiauwxSkFh2VEB+5vtzEZ6SXSmJJhfg3h42TZOlaCWePttDPWt/6 yUrWHVlEBXbhWqBoECLf0zQObxYzcf/KzBvoUUC77a+HXxmWU+Mm5z6dXn0eMtNuVRfpq0CBK fJuvecTkDV1US1nIT+AZYJ1wXbjmENjDRoJ8IZmQDckAoV4WqscHX2lbkPjXplczLsj6DS5gG 70i6MXFDQWHPxALSYcUShqM7TYyPCIWZnTgWsGCKei848vLhlIBFQzw7EQ7ztby+ejrsZr5yO rnIKOWE9rGBfZcgk6RdB9OJoXguxp6HPUFiL+9oJqSwG1Qk+OMyWbNPLSvBpR4YfqbmZkHsiq s7fhTAXG9iYs8LA8wQXGcW8tjZxHddOe+0xT39mgmv9J/zgqoPL1xcKNkDp/+h+kx8+gr6QSd go7maRyWyHBgEWHRVwWUEIH3yxbXBVG3AUbTmaBhpwt4ShdxrIVryJ1bmYtcWSMmsxkzwXVbF lzyiKV6PZCSjB83jSEihzIiQJD9GuP7A2DDRCDV0giHE4luwKbrnDqN1p5DGVpnX+2x0vAnXy jTUYbpgwcUcIHXhdk2Eau8gi/9d49DBeu4JRPEFd3175f31ugzDQ27FF1Wg+Uo7axZEeiRXh1 PnY1UbDcUYP/ZRGzA+ZoIVeA67WWtfayS+kShyLBDg== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniil Kovalev If a program requires fr1, we should set the FR bit of CP0 control status register and add F64 hardware flag. The corresponding `else if` branch statement is copied from the linux kernel sources (see `arch_check_elf` function in linux/arch/mips/kernel/elf.c). Signed-off-by: Daniil Kovalev Reviewed-by: Jiaxun Yang Message-Id: <20230404052153.16617-1-dkovalev@compiler-toolchain-for.me> Signed-off-by: Laurent Vivier --- linux-user/mips/cpu_loop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index d5c1c7941d34..8735e58bada0 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -290,7 +290,10 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->CP0_Status |= (1 << CP0St_FR); env->hflags |= MIPS_HFLAG_F64; } - } else if (!prog_req.fre && !prog_req.frdefault && + } else if (prog_req.fr1) { + env->CP0_Status |= (1 << CP0St_FR); + env->hflags |= MIPS_HFLAG_F64; + } else if (!prog_req.fre && !prog_req.frdefault && !prog_req.fr1 && !prog_req.single && !prog_req.soft) { fprintf(stderr, "qemu: Can't find a matching FPU mode\n"); exit(1); From patchwork Wed May 17 08:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13244393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 501AAC7EE23 for ; Wed, 17 May 2023 08:10:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzC71-0003UD-Qh; Wed, 17 May 2023 04:02:19 -0400 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 1pzC6n-0002oV-N8 for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:05 -0400 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzC6i-0000uy-P5 for qemu-devel@nongnu.org; Wed, 17 May 2023 04:02:05 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MowX2-1qVYN635uo-00qQOr; Wed, 17 May 2023 10:01:58 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Michael Tokarev , Laurent Vivier Subject: [PULL 9/9] linux-user: fix getgroups/setgroups allocations Date: Wed, 17 May 2023 10:01:52 +0200 Message-Id: <20230517080152.108660-10-laurent@vivier.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517080152.108660-1-laurent@vivier.eu> References: <20230517080152.108660-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:5bS0REqrwP0jfJZFpBWGuhHWADk/Vw5hhajd9CKrvzCA62UrsG/ ggWjYmKE9oF5gvoPCbM1lpytEHt5C/w0RBt7u0945N3WrqPO2N6iDermXpY3mAsgpnWavZi zzhx5ufohs6UXLXMmLoU3oaT3PrKy0PdrH+Jgj0Na9UWWujQUpEHCTmPtSomQjASvytVpHN D76YTMZLQKEFRJ8ciF+IQ== UI-OutboundReport: notjunk:1;M01:P0:AjgeK9plEKY=;97udNDGJmlKI8dsTlzFG+VAwAlr Yn8kWWGUgDbFGp8m9JI4VPPBd8+J5pOOodQqyKG1MG5OD9BoEXBtVW2GHquakxZSRUQGa22yh 6/n653DLLXuzOEANeOv6nrQ5I/CyuWeptlh4t6r7/DCskV9b+nOyPVxLsDJx1Vg41ZA1A5xK8 gMt58VCLrr5NAKko5fB1rKUr5y6Nsf3xLP0IjfZJjNrV1bE5Yl9WT4XmBBUyiVx5kUmw+sw8m ZceqcGsVpofjShaePCXnT/IuMpBslVYarrMInt7ksy4NqKCjf7mxL/gofHpB+OfT9W9VjC+5m RsBVGMD0ysSUREdNp6Ku4BuvFSJh/Zzxkp18KqCr72ef8BCMpDwY1C5eer4C+AvSNNqiTTI4M wcpPtlyt2CvMAUj6TLQPsGdzF2FyjK4sTrFsfdFtehJaFad4sPyKBPFmMqX4ttFO8qHPyRTVM mW3a1qfg72SXn6hftrxTKMQxWomjOXIrlzyIOdEQhWCLuOx70zvuCmFVAhjAipFnxS9F5QI4j AmNHoHg+sJds0b6TqZkHSnLca5WPntRvyg4whnPbzjKFF0Qaa7/l1VR2uYli8lvvv2slbrMqe 5r2bK6bGm64JtU240kUNo+Urc/ld8oq97mxPQS9VBCuXKD0v5CiS5iDDlSLUMbfQ8cnP63B1N WShKlvOKr9xuxX8lxxIogRy9aKRnuzcbl+mhGXIGeA== Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Michael Tokarev linux-user getgroups(), setgroups(), getgroups32() and setgroups32() used alloca() to allocate grouplist arrays, with unchecked gidsetsize coming from the "guest". With NGROUPS_MAX being 65536 (linux, and it is common for an application to allocate NGROUPS_MAX for getgroups()), this means a typical allocation is half the megabyte on the stack. Which just overflows stack, which leads to immediate SIGSEGV in actual system getgroups() implementation. An example of such issue is aptitude, eg https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811087#72 Cap gidsetsize to NGROUPS_MAX (return EINVAL if it is larger than that), and use heap allocation for grouplist instead of alloca(). While at it, fix coding style and make all 4 implementations identical. Try to not impose random limits - for example, allow gidsetsize to be negative for getgroups() - just do not allocate negative-sized grouplist in this case but still do actual getgroups() call. But do not allow negative gidsetsize for setgroups() since its argument is unsigned. Capping by NGROUPS_MAX seems a bit arbitrary, - we can do more, it is not an error if set size will be NGROUPS_MAX+1. But we should not allow integer overflow for the array being allocated. Maybe it is enough to just call g_try_new() and return ENOMEM if it fails. Maybe there's also no need to convert setgroups() since this one is usually smaller and known beforehand (KERN_NGROUPS_MAX is actually 63, - this is apparently a kernel-imposed limit for runtime group set). The patch fixes aptitude segfault mentioned above. Signed-off-by: Michael Tokarev Message-Id: <20230409105327.1273372-1-mjt@msgid.tls.msk.ru> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 99 ++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6655982821ba..89b58b386b17 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11571,39 +11571,58 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, { int gidsetsize = arg1; target_id *target_grouplist; - gid_t *grouplist; + g_autofree gid_t *grouplist = NULL; int i; - grouplist = alloca(gidsetsize * sizeof(gid_t)); + if (gidsetsize > NGROUPS_MAX) { + return -TARGET_EINVAL; + } + if (gidsetsize > 0) { + grouplist = g_try_new(gid_t, gidsetsize); + if (!grouplist) { + return -TARGET_ENOMEM; + } + } ret = get_errno(getgroups(gidsetsize, grouplist)); - if (gidsetsize == 0) - return ret; - if (!is_error(ret)) { - target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0); - if (!target_grouplist) + if (!is_error(ret) && gidsetsize > 0) { + target_grouplist = lock_user(VERIFY_WRITE, arg2, + gidsetsize * sizeof(target_id), 0); + if (!target_grouplist) { return -TARGET_EFAULT; - for(i = 0;i < ret; i++) + } + for (i = 0; i < ret; i++) { target_grouplist[i] = tswapid(high2lowgid(grouplist[i])); - unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id)); + } + unlock_user(target_grouplist, arg2, + gidsetsize * sizeof(target_id)); } + return ret; } - return ret; case TARGET_NR_setgroups: { int gidsetsize = arg1; target_id *target_grouplist; - gid_t *grouplist = NULL; + g_autofree gid_t *grouplist = NULL; int i; - if (gidsetsize) { - grouplist = alloca(gidsetsize * sizeof(gid_t)); - target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1); + + if (gidsetsize > NGROUPS_MAX || gidsetsize < 0) { + return -TARGET_EINVAL; + } + if (gidsetsize > 0) { + grouplist = g_try_new(gid_t, gidsetsize); + if (!grouplist) { + return -TARGET_ENOMEM; + } + target_grouplist = lock_user(VERIFY_READ, arg2, + gidsetsize * sizeof(target_id), 1); if (!target_grouplist) { return -TARGET_EFAULT; } for (i = 0; i < gidsetsize; i++) { grouplist[i] = low2highgid(tswapid(target_grouplist[i])); } - unlock_user(target_grouplist, arg2, 0); + unlock_user(target_grouplist, arg2, + gidsetsize * sizeof(target_id)); } return get_errno(setgroups(gidsetsize, grouplist)); } @@ -11888,41 +11907,59 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, { int gidsetsize = arg1; uint32_t *target_grouplist; - gid_t *grouplist; + g_autofree gid_t *grouplist = NULL; int i; - grouplist = alloca(gidsetsize * sizeof(gid_t)); + if (gidsetsize > NGROUPS_MAX) { + return -TARGET_EINVAL; + } + if (gidsetsize > 0) { + grouplist = g_try_new(gid_t, gidsetsize); + if (!grouplist) { + return -TARGET_ENOMEM; + } + } ret = get_errno(getgroups(gidsetsize, grouplist)); - if (gidsetsize == 0) - return ret; - if (!is_error(ret)) { - target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); + if (!is_error(ret) && gidsetsize > 0) { + target_grouplist = lock_user(VERIFY_WRITE, arg2, + gidsetsize * 4, 0); if (!target_grouplist) { return -TARGET_EFAULT; } - for(i = 0;i < ret; i++) + for (i = 0; i < ret; i++) { target_grouplist[i] = tswap32(grouplist[i]); + } unlock_user(target_grouplist, arg2, gidsetsize * 4); } + return ret; } - return ret; #endif #ifdef TARGET_NR_setgroups32 case TARGET_NR_setgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; - gid_t *grouplist; + g_autofree gid_t *grouplist = NULL; int i; - grouplist = alloca(gidsetsize * sizeof(gid_t)); - target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); - if (!target_grouplist) { - return -TARGET_EFAULT; + if (gidsetsize > NGROUPS_MAX || gidsetsize < 0) { + return -TARGET_EINVAL; + } + if (gidsetsize > 0) { + grouplist = g_try_new(gid_t, gidsetsize); + if (!grouplist) { + return -TARGET_ENOMEM; + } + target_grouplist = lock_user(VERIFY_READ, arg2, + gidsetsize * 4, 1); + if (!target_grouplist) { + return -TARGET_EFAULT; + } + for (i = 0; i < gidsetsize; i++) { + grouplist[i] = tswap32(target_grouplist[i]); + } + unlock_user(target_grouplist, arg2, 0); } - for(i = 0;i < gidsetsize; i++) - grouplist[i] = tswap32(target_grouplist[i]); - unlock_user(target_grouplist, arg2, 0); return get_errno(setgroups(gidsetsize, grouplist)); } #endif