From patchwork Fri Dec 18 10:23:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4jl4n5Wz9s1l for ; Fri, 18 Dec 2020 21:24:43 +1100 (AEDT) Received: from localhost ([::1]:43000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCwC-0002rO-Dc for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:24:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvo-0002qP-JD for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:16 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:33355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvm-00072a-U4 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:16 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MWAay-1kbU8m32Ec-00XdmA; Fri, 18 Dec 2020 11:24:10 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/14] linux-user/mmap.c: check range of mremap result in target address space Date: Fri, 18 Dec 2020 11:23:54 +0100 Message-Id: <20201218102407.597566-2-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:j3gKVhnKa4Q0GO+Crgw8R3KLVLNoUemxtY1bDxMsYC0DGKFvUC4 x98pfaw0kPoov5Je2L+36XKDqBlbkRwwIUHNlFOheVc5CriZqPmnwFLVTUyuSK2WfW6a7M/ P6FqR42gEKr+MalLahkYtPggrdlinda4nHmXc9fhbYtyqj1KPq+a3zfkR/RAX2Wv3bE5ewM QvNsBF47QNqh79UtpkdpQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:n5UsRjsgMjQ=:G8N/W8rzChePCC7EpvNjvM MxskfINOdne9n1S7v8O6zM7rX5Yi5leMAnWWiyZP2ZdmawgP1XFaTTBIeiS3BmtYcIG4J4lgJ nQkI3lJM5Wts3KJ9o7EURJqBBMDxU5updAwYnKU8B4XVmBb0AKScd3Bjfy1b2dNYqBxZDK2sQ +J12GvuQu3D2rzmTUuGgnKb/4xIrGaisX8nPEJXw5/cl8wBLjNLd/JWd4YFI5qsDY52rih9p2 3X2PVY4cOKbmlhbqHjKgZkibsp0Qo0Vflbza/AkD665vymQGQIZeLBpVhe4w8n9U1QT6wHD8B WrCKxb4FqE3cH/2wPWfPdSunkUI4/mpeoJ2BNOKQdlANBc48SAopziShVhW2gg9YwUKJgHHh/ XOVB6LOsYLEv+g7CPDBjt99uBShwXFb9TG18Up5kTbjzDsVu9CxkW+PIaZZWY 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tobias Koch , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Tobias Koch If mremap succeeds, an additional check is performed to ensure that the new address range fits into the target address space. This check was previously perfomed in host address space, with the upper bound fixed to abi_ulong. This patch replaces the static check with a call to `guest_range_valid`, performing the range check against the actual size of the target address space. It also moves the corresponding block to prevent it from being called incorrectly when the mapping itself fails. Signed-off-by: Tobias Koch Message-Id: <20201028213833.26592-1-tobias.koch@nonterra.com> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 00c05e6a0f19..810653c50357 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -767,20 +767,23 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, } if (prot == 0) { host_addr = mremap(g2h(old_addr), old_size, new_size, flags); - if (host_addr != MAP_FAILED && reserved_va && old_size > new_size) { - mmap_reserve(old_addr + old_size, old_size - new_size); + + if (host_addr != MAP_FAILED) { + /* Check if address fits target address space */ + if (!guest_range_valid(h2g(host_addr), new_size)) { + /* Revert mremap() changes */ + host_addr = mremap(g2h(old_addr), new_size, old_size, + flags); + errno = ENOMEM; + host_addr = MAP_FAILED; + } else if (reserved_va && old_size > new_size) { + mmap_reserve(old_addr + old_size, old_size - new_size); + } } } else { errno = ENOMEM; host_addr = MAP_FAILED; } - /* Check if address fits target address space */ - if ((unsigned long)host_addr + new_size > (abi_ulong)-1) { - /* Revert mremap() changes */ - host_addr = mremap(g2h(old_addr), new_size, old_size, flags); - errno = ENOMEM; - host_addr = MAP_FAILED; - } } if (host_addr == MAP_FAILED) { From patchwork Fri Dec 18 10:23:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4rv1FGKz9sVj for ; Fri, 18 Dec 2020 21:30:55 +1100 (AEDT) Received: from localhost ([::1]:38338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD2B-0004CT-SI for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:30:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvs-0002ve-G4 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:20 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:39061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvo-00073g-P0 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:20 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N8GIg-1k3nHn1Aie-014EVA; Fri, 18 Dec 2020 11:24:11 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/14] linux-user/elfload: Move GET_FEATURE macro out of get_elf_hwcap() body Date: Fri, 18 Dec 2020 11:23:55 +0100 Message-Id: <20201218102407.597566-3-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:D1Uk0JZ/yYg3/egXUqysZWc2tggqawqpcMchwhCUoT8xvHbo8H1 H9URKpgkprHG3tyMK2sFE5r/ukLMQZUVLlFthuarDrLNjtfzri1dmBvnA2Zj+rA9YrPutAX byvbj6O5rpTVtrYuecTuw6mePJaYJO2cVr3YoiW5I6NLnf6cWZi9ho9Ikc4LjsUvDdESjvQ gp1fOUJZpBXC4hHKd+1Vw== X-UI-Out-Filterresults: notjunk:1;V03:K0:ArcQcARn68k=:g86WhVYxSqzzkb1Ymvhkqa Wl8Lt2hS80yKUBUE6+7BqvHQBhdt8YsW7B9XjJYaMDLm+U9CaZyuIIz2CKlE182MlyhTDj1nM 2z5VOCmVW1MzNb0eujSPNSypHrpdHTFY7bpkCdwAxDItOKW6VAHD3ptWy/r4ML53DXldrNUXp b1myWeyD5zIOSqcGMSSaZa6ctVP8RLFaKF27HyXpTZbNXT5AlHJRRjU79YQ8XK55fk6yFahyT GYfLg4ilwUZfGoW3CQ/Mh5/mqhno2I0IF+GfJXeAaErLgWdfKxVxnbPRAfFmOrtzw+OQLmmmT YQzVH9zXQUKZE895RJYfJtDor/y3ZX6ciDRWK6kA5NpbRauqMbHYefoDRpWU0XbVOcCNPgsYr JSVytgwim9scSaUapCMT+FfmIETIuXkH7BVLUBZ4p2QPwt6COXIRxCUG0MnQsJQMRPra83KbF pxSWjKh3YQ== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé As we are going to add more macros, keep the function body clear. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201214003215.344522-2-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0b02a926025e..aae28fd929dc 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -989,22 +989,22 @@ enum { #define ELF_HWCAP get_elf_hwcap() +#define GET_FEATURE(_flag, _hwcap) \ + do { if (cpu->env.insn_flags & (_flag)) { hwcaps |= _hwcap; } } while (0) + static uint32_t get_elf_hwcap(void) { MIPSCPU *cpu = MIPS_CPU(thread_cpu); uint32_t hwcaps = 0; -#define GET_FEATURE(flag, hwcap) \ - do { if (cpu->env.insn_flags & (flag)) { hwcaps |= hwcap; } } while (0) - GET_FEATURE(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6); GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA); -#undef GET_FEATURE - return hwcaps; } +#undef GET_FEATURE + #endif /* TARGET_MIPS */ #ifdef TARGET_MICROBLAZE From patchwork Fri Dec 18 10:23:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4jt3wPhz9s1l for ; Fri, 18 Dec 2020 21:24:50 +1100 (AEDT) Received: from localhost ([::1]:43442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCwK-00034i-El for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:24:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvr-0002tC-6O for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:19 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:52191) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvo-00073c-EB for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:18 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N4z2Y-1k754R38WS-010uZs; Fri, 18 Dec 2020 11:24:11 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/14] linux-user/elfload: Rename MIPS GET_FEATURE() as GET_FEATURE_INSN() Date: Fri, 18 Dec 2020 11:23:56 +0100 Message-Id: <20201218102407.597566-4-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ozIWymysu2b10QE1Xj6hzHT+bLvPImC378C+coVVOdm0hoKj87A ABqdI3jxwPCpr551EaoIVEayq9MwqPF4iXrDkReWFxb+/gO9IJ1H5iZ4lkM0Wh4JUQX3bl6 ch7fCbiwbatiW8PPo6XKGz4UaKOvYtpuqGKDTc2RJ0iwfOTnsvKojk1KS9TGIvkRvKEZ4GD oNPSRKWPN6VN6ZPZ+b9rA== X-UI-Out-Filterresults: notjunk:1;V03:K0:VMRNR7rPNmc=:XAQMRi69kHD331oazPw8MC gDIudi2V1AcM+RQhH6fJNPTS/asALrz7Bz0zYQmEP2OOlpPcXJvsVvlGiwX+9O4LZCmtKpw/0 JGRVebeRExqgwCGXMId5gfDEOIZyw9Hf01C0XkyM8K4wplqR4i8L1HkXkynpNAuK4fK03yq6g rJfmOMYoqJm5QvTs0LKpWHpRPo5KcRMRsaqdQFl6tKtWFvEYnn3qBscv6y7Fd1Exhwqv6OtkE U8IEUe58JywXYOYZRb/KR/XZpRJPzSG4dEQINoxuckwa/rh4PvUQXeIQOdlnLjO7Lc+mK7rlw e4pwNcSk4s68fMZjFFqCJX6uRsQrrVFQ2oNkFRN6TC1ik+i5jq3jX+7fVD7QP1jN9Q1NHwefW sj0p+hTWCIwsMhk3HHnTm92mcf1D0PS3PgHZqLtX4lNSn8rP6zeWUwmIcT7mwA0DGIpr/+aRI ibXwfVzrFA== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé We want to add macros similar to GET_FEATURE(). As this one use the 'insn_flags' field, rename it GET_FEATURE_INSN(). Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201214003215.344522-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index aae28fd929dc..0e1d7e7677c8 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -989,7 +989,7 @@ enum { #define ELF_HWCAP get_elf_hwcap() -#define GET_FEATURE(_flag, _hwcap) \ +#define GET_FEATURE_INSN(_flag, _hwcap) \ do { if (cpu->env.insn_flags & (_flag)) { hwcaps |= _hwcap; } } while (0) static uint32_t get_elf_hwcap(void) @@ -997,13 +997,13 @@ static uint32_t get_elf_hwcap(void) MIPSCPU *cpu = MIPS_CPU(thread_cpu); uint32_t hwcaps = 0; - GET_FEATURE(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6); - GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA); + GET_FEATURE_INSN(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6); + GET_FEATURE_INSN(ASE_MSA, HWCAP_MIPS_MSA); return hwcaps; } -#undef GET_FEATURE +#undef GET_FEATURE_INSN #endif /* TARGET_MIPS */ From patchwork Fri Dec 18 10:23:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4mS2bwbz9s1l for ; Fri, 18 Dec 2020 21:27:02 +1100 (AEDT) Received: from localhost ([::1]:50824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCyR-0006Am-5Q for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:26:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-0002rc-Ew for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:18 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:33605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvo-00073d-GY for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:18 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MCsLu-1kz2dQ0xPc-008oSK; Fri, 18 Dec 2020 11:24:12 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/14] linux-user/elfload: Introduce MIPS GET_FEATURE_REG_SET() macro Date: Fri, 18 Dec 2020 11:23:57 +0100 Message-Id: <20201218102407.597566-5-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:wuqXcLWJwT22rsqHIlWK2F1sTo7/1zk1RaJYfjjLYqGYhHVG29G KAs5Z/ITuLXsPVTBeG96/4DbefAKJBVSZnTL0xeJ3E3wX5z4wpK0joYWLslg35d4jbECwmM cL2liQSctXwRG3b+R6Ih+ISiJXVqe10VRI+8YTVEhHMYLU1OimI1gWn9pkTK/g1lTJSE0v6 lMl49y0KcqW9tVYF6Gs6A== X-UI-Out-Filterresults: notjunk:1;V03:K0:f+doaN3aWXY=:orMGH1C7mjD+XeXIwvhtkP XfjMzpwRltIprXRm10MX5QfRWVj+yNMlCdpoxP4hLjYly9vWqnlpgNiCG63qSf0TupO5GCmxP keRNvl9qE3QyXE5FFFP36VokzD1jy/imjOg0/8YUjFw4W4iyKReSVc2VC6xYOQZQnXWAbSeKj I6cCSZj221Hor4u8/txRUPlAEbe6lYkUrfjqdauPRVk5fGykDDUV/+O83p0f1i9wRSvdiEkqm fLivZm3GZk/quCmqmFX5kCZn90Ghq/OYPyVpVhX/xdLtfjvr+96LzdkUQuWccMDcp83K+c+MN Wju4xg9kIpPRey/oVKn9gUrM6abCQzdDJYoOQU7Q8R73KhUIwGBCDDR+jcYHnRLLVR5Gxvq6E H8csrXCycftV+m1QLKZWs71jfan2E6uSKPiyijr7wcwkBRZ4nl12laOd3AlljecFOY90xuMR5 0E7Ue8Zk0Q== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé ISA features are usually denoted in read-only bits from CPU registers. Add the GET_FEATURE_REG_SET() macro which checks if a CPU register has bits set. Use the macro to check for MSA (which sets the MSAP bit of the Config3 register when the ASE implementation is present). Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201214003215.344522-4-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0e1d7e7677c8..b7c6d30723a3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -992,17 +992,21 @@ enum { #define GET_FEATURE_INSN(_flag, _hwcap) \ do { if (cpu->env.insn_flags & (_flag)) { hwcaps |= _hwcap; } } while (0) +#define GET_FEATURE_REG_SET(_reg, _mask, _hwcap) \ + do { if (cpu->env._reg & (_mask)) { hwcaps |= _hwcap; } } while (0) + static uint32_t get_elf_hwcap(void) { MIPSCPU *cpu = MIPS_CPU(thread_cpu); uint32_t hwcaps = 0; GET_FEATURE_INSN(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6); - GET_FEATURE_INSN(ASE_MSA, HWCAP_MIPS_MSA); + GET_FEATURE_REG_SET(CP0_Config3, 1 << CP0C3_MSAP, HWCAP_MIPS_MSA); return hwcaps; } +#undef GET_FEATURE_REG_SET #undef GET_FEATURE_INSN #endif /* TARGET_MIPS */ From patchwork Fri Dec 18 10:23:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4pd2zSjz9s1l for ; Fri, 18 Dec 2020 21:28:57 +1100 (AEDT) Received: from localhost ([::1]:59138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD0J-00016I-DE for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:28:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvr-0002u5-Mr for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:19 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:42643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvo-00073h-Jo for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:19 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N0G5h-1jugbD2rnr-00xOCZ; Fri, 18 Dec 2020 11:24:12 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/14] linux-user/elfload: Introduce MIPS GET_FEATURE_REG_EQU() macro Date: Fri, 18 Dec 2020 11:23:58 +0100 Message-Id: <20201218102407.597566-6-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:zezIeuqzhi3r8oWSXvmkGfZsJCySwYvgoG/Rw2ognH5UPj8egU3 Rw1xWWOh2puACTv6E+w5uDMfxhrFs6P5XxNCAHSQQfU1/43xvm9nA1sh7jnonBpnIFeiTqv Ui0K96DqtKJmX9P3SojvoRYMiK6GQd6xxkUZFLPl98vrIRIM97PTsrUbQt0BexzyVzCyzMC Y1J8bQKRCgmwf/R4JAfrA== X-UI-Out-Filterresults: notjunk:1;V03:K0:/FpwHOKjJnc=:Oqohn0N3AiigjbfUD2qv+h lQ8oa7UAww5uLndh08dypWOOl/+WD1pGSeM/tvnRimxOrsNOArqWrkanEvQUguPPdZHfVdpzr sHDG0GEkEN179kzzxJblR09pjvowqagCYPdmuH+VlqiVTGt3KqtFU7ehElIzVLCSq/foVj/Ll ly/QvhlV67B1vT9c3IDtk0UvZgip0Td+DvKYmyI1RidwsL1V7r1Puykn/iDupNCX4Tz/5uQOf RlYOimvuh5aMDK3rr59NvqsO+ItFJ6eEAQ0+kj/UOOsQPjd2tl/JgJkijAcqXST3Tnxvsm2Wi iX9swera29D6P4gp6xIH56fSXzW/papRempX3xwN/0vG60ItXOjmGCnFB6ruoQP77OgTCEfPp JL9nbPqqZrvXe2AtQZDcCWLp7Bp4n7VvBA79vXQoeTTYQqJ8cfL4JQBJljCsxCTafDH5Xyzwa XnAgosalbw== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé ISA features are usually denoted in read-only bits from CPU registers. Add the GET_FEATURE_REG_EQU() macro which checks if a CPU register has bits set to a specific value. Use the macro to check the 'Architecture Revision' level of the Config0 register, which is '2' when the Release 6 ISA is implemented. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201214003215.344522-5-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 12 +++++++++++- target/mips/cpu.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b7c6d30723a3..8f943f93ba75 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -7,6 +7,7 @@ #include "qemu.h" #include "disas/disas.h" +#include "qemu/bitops.h" #include "qemu/path.h" #include "qemu/queue.h" #include "qemu/guest-random.h" @@ -995,17 +996,26 @@ enum { #define GET_FEATURE_REG_SET(_reg, _mask, _hwcap) \ do { if (cpu->env._reg & (_mask)) { hwcaps |= _hwcap; } } while (0) +#define GET_FEATURE_REG_EQU(_reg, _start, _length, _val, _hwcap) \ + do { \ + if (extract32(cpu->env._reg, (_start), (_length)) == (_val)) { \ + hwcaps |= _hwcap; \ + } \ + } while (0) + static uint32_t get_elf_hwcap(void) { MIPSCPU *cpu = MIPS_CPU(thread_cpu); uint32_t hwcaps = 0; - GET_FEATURE_INSN(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6); + GET_FEATURE_REG_EQU(CP0_Config0, CP0C0_AR, CP0C0_AR_LENGTH, + 2, HWCAP_MIPS_R6); GET_FEATURE_REG_SET(CP0_Config3, 1 << CP0C3_MSAP, HWCAP_MIPS_MSA); return hwcaps; } +#undef GET_FEATURE_REG_EQU #undef GET_FEATURE_REG_SET #undef GET_FEATURE_INSN diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 3ac21d0e9c07..4cbc31c3e8d2 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -844,6 +844,7 @@ struct CPUMIPSState { #define CP0C0_MT 7 /* 9..7 */ #define CP0C0_VI 3 #define CP0C0_K0 0 /* 2..0 */ +#define CP0C0_AR_LENGTH 3 int32_t CP0_Config1; #define CP0C1_M 31 #define CP0C1_MMU 25 /* 30..25 */ From patchwork Fri Dec 18 10:23:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4q11KSYz9sWT for ; Fri, 18 Dec 2020 21:29:17 +1100 (AEDT) Received: from localhost ([::1]:60080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD0d-0001Uu-0J for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:29:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvu-000304-IK for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:22 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:38333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-00074H-5s for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:22 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mz9d7-1jvmWs0Vgh-00wIH1; Fri, 18 Dec 2020 11:24:13 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/14] linux-user/elfload: Update HWCAP bits from linux 5.7 Date: Fri, 18 Dec 2020 11:23:59 +0100 Message-Id: <20201218102407.597566-7-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ln7BD3Vva7z3+0n3K6ePZTRRHrwfDX39fNErvgC+/ZHhdULMGn2 Aq7DasUcLh53oIxAxNZrgFXCfyXDZ0TkeaOrw8+1IPoAsnU4ivlzNTUWza1h0m+IIZgXTTD AjhtYXsTNaRp6elrsO/O8WAEtIPZX8Gldrv5ti4i0a7L6pqdlu98dKD/LPogUWiCZOqKhXB MZzIyoGxQaevQGR1PiFQA== X-UI-Out-Filterresults: notjunk:1;V03:K0:P6X4E4EsIm0=:65KMPFVM+ANAhD3vFxalR0 aDCQ8AUMXZer1we1f3OfUhLR+pQQYX6dxSYUCz2H6AFG81zjWD7S84oCYmKJ/aPDyTqj/lg1S rfygkn4Sarks3cYTz1ZkEXXBUjVz4v0ZSrGf/341WJFbwChxKPduBdM2unwlsNJ+/OPksfKeg NK3pq2RtChirkJMesDmiB3N3bqYS4dRvORG3bVNZAtq2oDRCmCIQVX2kB2y9ux8ZeMAZ8zYg2 k9ceLxscLtDrIMjHq7qd688rSpnv3MO+JOHit87BRsjq3n+nppepn4+ymMo0pVG98rqoDCvDB dxIMkKB2depojpVLHuWWCjkuiwb+UalQWCj94ITGl9gh6TEp2NPRo0yzf2PZT2/97HrrxheiV 4W2qr+0Eu1UftG0gOJwL/bQI6ASC+rmAwdWSrAjHtGd+oNvc3pUczBbp2ureGzZqirqJ8waa0 /mRZreXEDw== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201214003215.344522-6-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8f943f93ba75..0836e72b5ac3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -986,6 +986,19 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e enum { HWCAP_MIPS_R6 = (1 << 0), HWCAP_MIPS_MSA = (1 << 1), + HWCAP_MIPS_CRC32 = (1 << 2), + HWCAP_MIPS_MIPS16 = (1 << 3), + HWCAP_MIPS_MDMX = (1 << 4), + HWCAP_MIPS_MIPS3D = (1 << 5), + HWCAP_MIPS_SMARTMIPS = (1 << 6), + HWCAP_MIPS_DSP = (1 << 7), + HWCAP_MIPS_DSP2 = (1 << 8), + HWCAP_MIPS_DSP3 = (1 << 9), + HWCAP_MIPS_MIPS16E2 = (1 << 10), + HWCAP_LOONGSON_MMI = (1 << 11), + HWCAP_LOONGSON_EXT = (1 << 12), + HWCAP_LOONGSON_EXT2 = (1 << 13), + HWCAP_LOONGSON_CPUCFG = (1 << 14), }; #define ELF_HWCAP get_elf_hwcap() From patchwork Fri Dec 18 10:24:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4sX6r0Fz9sVj for ; Fri, 18 Dec 2020 21:31:28 +1100 (AEDT) Received: from localhost ([::1]:39768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD2k-0004oF-RN for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:31:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvw-00033J-6P for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:24 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:56911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-00074M-8c for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:23 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MWzXj-1kbD9w2Qjx-00XMWj; Fri, 18 Dec 2020 11:24:13 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/14] linux-user: Add support for MIPS Loongson 2F/3A Date: Fri, 18 Dec 2020 11:24:00 +0100 Message-Id: <20201218102407.597566-8-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:EjvWeq5wtv2u7gwt+VE/tzeCrjRn7we95o/YGLSe5rf1J00oeg6 PUL3EgZ5rwx8bt8CEUMU/27wf8Ot/17B1t9W+DYKysNb9YY+zzgxpupigFqpIgJEh/Dvs+h kChbWppufCfaOcQQ1/bjXrWVnxIyAKkKO2R8VSfVPeFkJcFRafNfBe/YOmuyntA6CtYPE9Z MH88yHNmHmDnszN+jZy+w== X-UI-Out-Filterresults: notjunk:1;V03:K0:5NmNh1MMsYE=:C78dy8bjOhAxav9f9QPo95 CK4hTYfTHhtTD3Ff/okMtFwsrvfgupxQKsupwuww3H1LRDNMiWPg32luk9uJVIu9k/9QqDcRb JAmla34Dt6I3pmT7vEENhLp1oduNC3fl32yZ11xAeZz9y8xsxXw5wLoEdPV1SsoBJpBuDyLEY fuwJu7enWjIoSMVEkoX6grYylTsstWECrhQ3+xB89+exmC9gXjbcd3cL64V2vrlcAznpCiESb /Hso18ebr9U92ted0NGLFgaakVSqU3H+euheErQTbxmAoX61COUrnjhQXhJzqDtbkJgazboa7 0wpdsjPQnyNNFHgFNH14zwh4QBewyFon3Zikg4U3w6E/0AQHJhTqd+KDERgnHUZQHb+q05ySh PUQMdk0+GEWw3Vhn1KQ3xi19JSYX/OW71+dLOHCfpWQiuxLtQARWthX9mcDZm 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Userland ELF binaries using Loongson SIMD instructions have the HWCAP_LOONGSON_MMI bit set [1]. Binaries compiled for Loongson 3A [2] have the HWCAP_LOONGSON_EXT bit set for the LQ / SQ instructions. [1] commit 8e2d5831e4b ("target/mips: Legalize Loongson insn flags") [2] commit af868995e1b ("target/mips: Add Loongson-3 CPU definition") Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201214003215.344522-7-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0836e72b5ac3..a64050713f28 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1024,6 +1024,8 @@ static uint32_t get_elf_hwcap(void) GET_FEATURE_REG_EQU(CP0_Config0, CP0C0_AR, CP0C0_AR_LENGTH, 2, HWCAP_MIPS_R6); GET_FEATURE_REG_SET(CP0_Config3, 1 << CP0C3_MSAP, HWCAP_MIPS_MSA); + GET_FEATURE_INSN(ASE_LMMI, HWCAP_LOONGSON_MMI); + GET_FEATURE_INSN(ASE_LEXT, HWCAP_LOONGSON_EXT); return hwcaps; } From patchwork Fri Dec 18 10:24:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4w45fMYz9sVj for ; Fri, 18 Dec 2020 21:33:40 +1100 (AEDT) Received: from localhost ([::1]:46590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD4s-0007vO-OP for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:33:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvu-00030H-P7 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:22 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:48389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-00074I-4D for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:22 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Md6V3-1kHh7u48dH-00aD2t; Fri, 18 Dec 2020 11:24:14 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/14] docs/user: Display linux-user binaries nicely Date: Fri, 18 Dec 2020 11:24:01 +0100 Message-Id: <20201218102407.597566-9-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:aZjga+gCPf6lwOsHveYCJzg6ouMofbZGvYmocBMW1p/8ROvyRGP oxBjQK9tq92zVhmD0Kr/qZX7251LMHwY+72uBK4tUr8AwmHDcPiaN1aAxpY4ShgQR9PQxgQ PPEWYN6q2G9fdDBeOf4L+34xHqUBTnLCZQXgTbi79r2cV4Mz52TNP0jatuZiCX4v8IK+/yg 9rGhon9MGLr18MhN1+Xmg== X-UI-Out-Filterresults: notjunk:1;V03:K0:+AjcLFspfiM=:DkDCO7SrF+hiPzFMWwSVrJ wAREbzQEYFRdtnpNTSIeFqtbNcu0EZWFHFfQTsu1FFiPoEXVgliGlvgkE31vBYai6DwgAZTmc GPv7RmaXSGQBA9MQNrABfT7FBN9e8puE7+MppWGEjIBxw8Cj5ikqvK+khoN6Z4XsC65jMr60i c+XlKwgiavmJQHt8TeQYh8rFeKPJSIVvYYdggjmflLNQKt1X1dT725ttWtJgQPQJNJkDnph0V eLK0CMjewxW8zC1lM23BY3eWX72T54dliGy9OkTHvptbgijyHW3fxTeMre5AL9rainTNtIpit ZPyHLwrFWoLXkNflRijDh02ijHD+tCT3j7E2EbgR050n/NaN8gS9VbyNIkbejHQl2130N+CVu nkIsEMXmv8fKNxzu3oRgTuIjLSGcvc7669HOiESIOivOXJx551woAekXwH3AHvTcEc+2UFNV+ Sfd1BFbBGA== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé linux-user binaries are displayed altogether. Use the '*' character to force displaying them as bullet list (one list per architecture). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20201119160838.1981709-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- docs/user/main.rst | 99 ++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 43 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index bd99b0fdbe9b..8dfe232a3af1 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -170,68 +170,81 @@ QEMU_STRACE Other binaries ~~~~~~~~~~~~~~ -user mode (Alpha) -``qemu-alpha`` TODO. +- user mode (Alpha) -user mode (Arm) -``qemu-armeb`` TODO. + * ``qemu-alpha`` TODO. -user mode (Arm) -``qemu-arm`` is also capable of running Arm \"Angel\" semihosted ELF -binaries (as implemented by the arm-elf and arm-eabi Newlib/GDB -configurations), and arm-uclinux bFLT format binaries. +- user mode (Arm) -user mode (ColdFire) -user mode (M68K) -``qemu-m68k`` is capable of running semihosted binaries using the BDM -(m5xxx-ram-hosted.ld) or m68k-sim (sim.ld) syscall interfaces, and -coldfire uClinux bFLT format binaries. + * ``qemu-armeb`` TODO. -The binary format is detected automatically. + * ``qemu-arm`` is also capable of running Arm \"Angel\" semihosted ELF + binaries (as implemented by the arm-elf and arm-eabi Newlib/GDB + configurations), and arm-uclinux bFLT format binaries. -user mode (Cris) -``qemu-cris`` TODO. +- user mode (ColdFire) -user mode (i386) -``qemu-i386`` TODO. ``qemu-x86_64`` TODO. +- user mode (M68K) -user mode (Microblaze) -``qemu-microblaze`` TODO. + * ``qemu-m68k`` is capable of running semihosted binaries using the BDM + (m5xxx-ram-hosted.ld) or m68k-sim (sim.ld) syscall interfaces, and + coldfire uClinux bFLT format binaries. -user mode (MIPS) -``qemu-mips`` executes 32-bit big endian MIPS binaries (MIPS O32 ABI). + The binary format is detected automatically. -``qemu-mipsel`` executes 32-bit little endian MIPS binaries (MIPS O32 -ABI). +- user mode (Cris) -``qemu-mips64`` executes 64-bit big endian MIPS binaries (MIPS N64 ABI). + * ``qemu-cris`` TODO. -``qemu-mips64el`` executes 64-bit little endian MIPS binaries (MIPS N64 -ABI). +- user mode (i386) -``qemu-mipsn32`` executes 32-bit big endian MIPS binaries (MIPS N32 -ABI). + * ``qemu-i386`` TODO. + * ``qemu-x86_64`` TODO. -``qemu-mipsn32el`` executes 32-bit little endian MIPS binaries (MIPS N32 -ABI). +- user mode (Microblaze) -user mode (NiosII) -``qemu-nios2`` TODO. + * ``qemu-microblaze`` TODO. -user mode (PowerPC) -``qemu-ppc64abi32`` TODO. ``qemu-ppc64`` TODO. ``qemu-ppc`` TODO. +- user mode (MIPS) -user mode (SH4) -``qemu-sh4eb`` TODO. ``qemu-sh4`` TODO. + * ``qemu-mips`` executes 32-bit big endian MIPS binaries (MIPS O32 ABI). -user mode (SPARC) -``qemu-sparc`` can execute Sparc32 binaries (Sparc32 CPU, 32 bit ABI). + * ``qemu-mipsel`` executes 32-bit little endian MIPS binaries (MIPS O32 ABI). -``qemu-sparc32plus`` can execute Sparc32 and SPARC32PLUS binaries -(Sparc64 CPU, 32 bit ABI). + * ``qemu-mips64`` executes 64-bit big endian MIPS binaries (MIPS N64 ABI). -``qemu-sparc64`` can execute some Sparc64 (Sparc64 CPU, 64 bit ABI) and -SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI). + * ``qemu-mips64el`` executes 64-bit little endian MIPS binaries (MIPS N64 + ABI). + + * ``qemu-mipsn32`` executes 32-bit big endian MIPS binaries (MIPS N32 ABI). + + * ``qemu-mipsn32el`` executes 32-bit little endian MIPS binaries (MIPS N32 + ABI). + +- user mode (NiosII) + + * ``qemu-nios2`` TODO. + +- user mode (PowerPC) + + * ``qemu-ppc64abi32`` TODO. + * ``qemu-ppc64`` TODO. + * ``qemu-ppc`` TODO. + +- user mode (SH4) + + * ``qemu-sh4eb`` TODO. + * ``qemu-sh4`` TODO. + +- user mode (SPARC) + + * ``qemu-sparc`` can execute Sparc32 binaries (Sparc32 CPU, 32 bit ABI). + + * ``qemu-sparc32plus`` can execute Sparc32 and SPARC32PLUS binaries + (Sparc64 CPU, 32 bit ABI). + + * ``qemu-sparc64`` can execute some Sparc64 (Sparc64 CPU, 64 bit ABI) and + SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI). BSD User space emulator ----------------------- From patchwork Fri Dec 18 10:24:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418159 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4mc63xVz9s1l for ; Fri, 18 Dec 2020 21:27:12 +1100 (AEDT) Received: from localhost ([::1]:51968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCyc-0006dy-Pj for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:27:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvr-0002uI-Pa for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:19 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:57155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvo-00073l-NU for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:19 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MJm8N-1kWlAV1pQv-00KBET; Fri, 18 Dec 2020 11:24:14 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/14] linux-user: Implement copy_file_range Date: Fri, 18 Dec 2020 11:24:02 +0100 Message-Id: <20201218102407.597566-10-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:M7Y6VUsinl5UsHCnR+fuTEkSA7HvYYIgUxOhWm5zrMN5cZJXslU +i6WKlAPfHaZmbKxtgpDv8Qfm6iqHTSsgW1A+oml+i+AUrweEcHXyUVzM5pSzgfv1wTWs7i ydoVs2OnIQBnYEhXixqTFazpj5tfYE9SDs0iqvkCwhPZebjV371aGeLfSD4OWHMek3Isr6W zTnP8c5KhCWPj3plEQF+w== X-UI-Out-Filterresults: notjunk:1;V03:K0:PDyM3IT3CiE=:HJV2/vpQnxJs2IaCyVVodN +DqOsyxC8MVOggPrIeiVZJqvm/H1CfarWIIbxvxZvaxY+0yUJ0t2vnU8ecAjAf529nJMFvI4I pOVnFGIEgtU6sth+9d26FxrmhxXLyorv6SJZn+GX6uAZCDPoEM5pfawIwJIXvpZjWDvDrbied gS/SuGHKaAIZ8ewjzztUnPcWQQs6VmFicyjJ+elaUKRKZO0frV2S5Iree4unFwPx4aiRlwAwS SIovupTxY9x7vSzGnl99bAaabWmQf4PgkshD3ZtxTCR3IZ2sSK2i56wfkb2cpEEvlIcpyABtf KSbP9RA0XKmD1WXb/1/Eq4y8SccFSOtMRCBaVEOkL0Dcy5ZFnzj7p7a8qB0UPA6T0inwyHgoc usfX5CJ5+RgleIVKp9wPxrxz8NUQcl3yTfdvfA3fWURIRxI7Dsp4rDHxgi0dN 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andreas Schwab , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Andreas Schwab Signed-off-by: Andreas Schwab Reviewed-by: Laurent Vivier Message-Id: [lv: copy back offset only if there is no error] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7bf99beb1814..6091a449fbf0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -813,6 +813,12 @@ safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, timeout) #endif +#if defined(TARGET_NR_copy_file_range) && defined(__NR_copy_file_range) +safe_syscall6(ssize_t, copy_file_range, int, infd, loff_t *, pinoff, + int, outfd, loff_t *, poutoff, size_t, length, + unsigned int, flags) +#endif + /* We do ioctl like this rather than via safe_syscall3 to preserve the * "third argument might be integer or pointer or not present" behaviour of * the libc function. @@ -13065,6 +13071,42 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(membarrier(arg1, arg2)); #endif +#if defined(TARGET_NR_copy_file_range) && defined(__NR_copy_file_range) + case TARGET_NR_copy_file_range: + { + loff_t inoff, outoff; + loff_t *pinoff = NULL, *poutoff = NULL; + + if (arg2) { + if (get_user_u64(inoff, arg2)) { + return -TARGET_EFAULT; + } + pinoff = &inoff; + } + if (arg4) { + if (get_user_u64(outoff, arg4)) { + return -TARGET_EFAULT; + } + poutoff = &outoff; + } + ret = get_errno(safe_copy_file_range(arg1, pinoff, arg3, poutoff, + arg5, arg6)); + if (!is_error(ret) && ret > 0) { + if (arg2) { + if (put_user_u64(inoff, arg2)) { + return -TARGET_EFAULT; + } + } + if (arg4) { + if (put_user_u64(outoff, arg4)) { + return -TARGET_EFAULT; + } + } + } + } + return ret; +#endif + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; From patchwork Fri Dec 18 10:24:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4jr45mBz9s1l for ; Fri, 18 Dec 2020 21:24:48 +1100 (AEDT) Received: from localhost ([::1]:43310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCwI-00030v-Ge for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:24:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvt-0002xf-B3 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:21 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:50493) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvp-00074A-Kj for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:21 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MDQqe-1kyUfY3ity-00AScE; Fri, 18 Dec 2020 11:24:15 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/14] linux-user: Add most IFTUN ioctls Date: Fri, 18 Dec 2020 11:24:03 +0100 Message-Id: <20201218102407.597566-11-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:WX4zhIraeXJ57QngkiIZ3VOefRuMouUQGqnpfcJ6Og/w2Ds0DbP tNpEtW/0GGrRUCzitk0M4IA42CNz+DaB1oQ9n+GpcqegWtjDwdExK1kkxuXw0W3rUXEWHip w10RJwJfQCgZi95w8sXwFsmSVdxCip+Abh317HxMKiUmF/cfNzW50X6TtU4UzhMW2bnt24W Riy+dy3zLx6ZHVX+hIAHw== X-UI-Out-Filterresults: notjunk:1;V03:K0:B0qMyKwVQc0=:JOZBwyKfwdaX6MU8jtQHTP 2at2DlsSpeO0ms0LVapSh4+on2BMfoAmVy5YHzIA4xUXW3uS09ZwdQ2G6CuHoV/eSdy8xsIRf zAT/tPCFEY/u3qH0FQ7PJnp9AsSByCKVrN5NBP8KSxQzRJeIyHXeIACSHPrcYPR3wRqIVEGOW POz2hopNn5GXM5ghyEtJci6mnFiTH1bEKEAuR8i1dOHBCqgx/gZXX+akMNpRpqFsanewppOBJ yzKj5ZSr+7PQ587e6+vgDnggOZeeFSckj3HM/OVMnOjiPztzhmHAeIHuaXZ6mjjKR7Fuf8vCo 4sUO9dgHYxZ3sCUFk55nCTFdmRfdzvZX/FfCoQhstfElMOqhdQxgj24jxPgwfwIVD0zOpB+NF r2rFaZkETjfOfHZkcU+bAFPfzzocDt0i+MPvLYOYI74cILPGkhAn//co/TFP+ 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Josh Kunz , Shu-Chun Weng , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Shu-Chun Weng The three options handling `struct sock_fprog` (TUNATTACHFILTER, TUNDETACHFILTER, and TUNGETFILTER) are not implemented. Linux kernel keeps a user space pointer in them which we cannot correctly handle. Signed-off-by: Josh Kunz Signed-off-by: Shu-Chun Weng Reviewed-by: Laurent Vivier Message-Id: <20200929014801.655524-1-scw@google.com> [lv: use 0 size in unlock_user()] Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 46 +++++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 37 +++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 32 +++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 8efb4d38c014..661b5daa9fd8 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -720,3 +720,49 @@ IOCTL(KCOV_DISABLE, 0, TYPE_NULL) IOCTL(KCOV_INIT_TRACE, IOC_R, TYPE_ULONG) #endif + + IOCTL(TUNSETDEBUG, IOC_W, TYPE_INT) + IOCTL(TUNSETIFF, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_short_ifreq))) + IOCTL(TUNSETPERSIST, IOC_W, TYPE_INT) + IOCTL(TUNSETOWNER, IOC_W, TYPE_INT) + IOCTL(TUNSETLINK, IOC_W, TYPE_INT) + IOCTL(TUNSETGROUP, IOC_W, TYPE_INT) + IOCTL(TUNGETFEATURES, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(TUNSETOFFLOAD, IOC_W, TYPE_LONG) + IOCTL_SPECIAL(TUNSETTXFILTER, IOC_W, do_ioctl_TUNSETTXFILTER, + /* + * We can't represent `struct tun_filter` in thunk so leaving + * it uninterpreted. do_ioctl_TUNSETTXFILTER will do the + * conversion. + */ + TYPE_PTRVOID) + IOCTL(TUNGETIFF, IOC_R, MK_PTR(MK_STRUCT(STRUCT_short_ifreq))) + IOCTL(TUNGETSNDBUF, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(TUNSETSNDBUF, IOC_W, MK_PTR(TYPE_INT)) + /* + * TUNATTACHFILTER and TUNDETACHFILTER are not supported. Linux kernel keeps a + * user pointer in TUNATTACHFILTER, which we are not able to correctly handle. + */ + IOCTL(TUNGETVNETHDRSZ, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(TUNSETVNETHDRSZ, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(TUNSETQUEUE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_short_ifreq))) + IOCTL(TUNSETIFINDEX , IOC_W, MK_PTR(TYPE_INT)) + /* TUNGETFILTER is not supported: see TUNATTACHFILTER. */ + IOCTL(TUNSETVNETLE, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(TUNGETVNETLE, IOC_R, MK_PTR(TYPE_INT)) +#ifdef TUNSETVNETBE + IOCTL(TUNSETVNETBE, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(TUNGETVNETBE, IOC_R, MK_PTR(TYPE_INT)) +#endif +#ifdef TUNSETSTEERINGEBPF + IOCTL(TUNSETSTEERINGEBPF, IOC_W, MK_PTR(TYPE_INT)) +#endif +#ifdef TUNSETFILTEREBPF + IOCTL(TUNSETFILTEREBPF, IOC_W, MK_PTR(TYPE_INT)) +#endif +#ifdef TUNSETCARRIER + IOCTL(TUNSETCARRIER, IOC_W, MK_PTR(TYPE_INT)) +#endif +#ifdef TUNGETDEVNETNS + IOCTL(TUNGETDEVNETNS, IOC_R, TYPE_NULL) +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6091a449fbf0..d182890ff04a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #ifdef CONFIG_TIMERFD @@ -5709,6 +5710,42 @@ static abi_long do_ioctl_drm_i915(const IOCTLEntry *ie, uint8_t *buf_temp, #endif +static abi_long do_ioctl_TUNSETTXFILTER(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + struct tun_filter *filter = (struct tun_filter *)buf_temp; + struct tun_filter *target_filter; + char *target_addr; + + assert(ie->access == IOC_W); + + target_filter = lock_user(VERIFY_READ, arg, sizeof(*target_filter), 1); + if (!target_filter) { + return -TARGET_EFAULT; + } + filter->flags = tswap16(target_filter->flags); + filter->count = tswap16(target_filter->count); + unlock_user(target_filter, arg, 0); + + if (filter->count) { + if (offsetof(struct tun_filter, addr) + filter->count * ETH_ALEN > + MAX_STRUCT_SIZE) { + return -TARGET_EFAULT; + } + + target_addr = lock_user(VERIFY_READ, + arg + offsetof(struct tun_filter, addr), + filter->count * ETH_ALEN, 1); + if (!target_addr) { + return -TARGET_EFAULT; + } + memcpy(filter->addr, target_addr, filter->count * ETH_ALEN); + unlock_user(target_addr, arg + offsetof(struct tun_filter, addr), 0); + } + + return get_errno(safe_ioctl(fd, ie->host_cmd, filter)); +} + IOCTLEntry ioctl_entries[] = { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index b934d0b60676..a00bfc2647c7 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -929,6 +929,38 @@ struct target_rtc_pll_info { #define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */ +/* From */ + +#define TARGET_TUNSETDEBUG TARGET_IOW('T', 201, int) +#define TARGET_TUNSETIFF TARGET_IOW('T', 202, int) +#define TARGET_TUNSETPERSIST TARGET_IOW('T', 203, int) +#define TARGET_TUNSETOWNER TARGET_IOW('T', 204, int) +#define TARGET_TUNSETLINK TARGET_IOW('T', 205, int) +#define TARGET_TUNSETGROUP TARGET_IOW('T', 206, int) +#define TARGET_TUNGETFEATURES TARGET_IOR('T', 207, unsigned int) +#define TARGET_TUNSETOFFLOAD TARGET_IOW('T', 208, unsigned int) +#define TARGET_TUNSETTXFILTER TARGET_IOW('T', 209, unsigned int) +#define TARGET_TUNGETIFF TARGET_IOR('T', 210, unsigned int) +#define TARGET_TUNGETSNDBUF TARGET_IOR('T', 211, int) +#define TARGET_TUNSETSNDBUF TARGET_IOW('T', 212, int) +/* + * TUNATTACHFILTER and TUNDETACHFILTER are not supported. Linux kernel keeps a + * user pointer in TUNATTACHFILTER, which we are not able to correctly handle. + */ +#define TARGET_TUNGETVNETHDRSZ TARGET_IOR('T', 215, int) +#define TARGET_TUNSETVNETHDRSZ TARGET_IOW('T', 216, int) +#define TARGET_TUNSETQUEUE TARGET_IOW('T', 217, int) +#define TARGET_TUNSETIFINDEX TARGET_IOW('T', 218, unsigned int) +/* TUNGETFILTER is not supported: see TUNATTACHFILTER. */ +#define TARGET_TUNSETVNETLE TARGET_IOW('T', 220, int) +#define TARGET_TUNGETVNETLE TARGET_IOR('T', 221, int) +#define TARGET_TUNSETVNETBE TARGET_IOW('T', 222, int) +#define TARGET_TUNGETVNETBE TARGET_IOR('T', 223, int) +#define TARGET_TUNSETSTEERINGEBPF TARGET_IOR('T', 224, int) +#define TARGET_TUNSETFILTEREBPF TARGET_IOR('T', 225, int) +#define TARGET_TUNSETCARRIER TARGET_IOW('T', 226, int) +#define TARGET_TUNGETDEVNETNS TARGET_IO('T', 227) + /* From */ #define TARGET_RNDGETENTCNT TARGET_IOR('R', 0x00, int) From patchwork Fri Dec 18 10:24:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418158 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4mb09Bzz9s1l for ; Fri, 18 Dec 2020 21:27:11 +1100 (AEDT) Received: from localhost ([::1]:51730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCya-0006Wm-UP for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:27:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvs-0002wX-SW for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:20 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:41353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvp-000741-H3 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:20 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M9WqY-1kkjHv1aZI-005YnI; Fri, 18 Dec 2020 11:24:15 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/14] linux-user/sparc: Correct sparc64_get/set_context() FPU handling Date: Fri, 18 Dec 2020 11:24:04 +0100 Message-Id: <20201218102407.597566-12-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:tAA8wzpmcyTJvwGHlgOvaKxlvdE0g2SF7CMassFbzX1PMAMdj4K haISmeZscM90+XOik+FLruL+p5MaO/p0NzkYO3EIeeIAbIxzOMi/cDPdbUhKoCvo9gfa+fH ppik7UmnlV5jrEUWladWNOL4kN309vXCeDw7tPueKjB/QBNkDbRRRFzLftgPjUzb4XZ6bkb 2GYyyI+DXcFtReQjm8wfg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Y55u4TcnwEY=:x3+GQFQNpKep3YgaCxKES8 P+YtFIgafhvsqRcu8cwKbTJJcYifSBYwnNWc1x1y0rYoTZl0CkQcCFCxjqN5HKFXPqrhvdYpz VNj7YTzvLIschvi43KYNxSNYDPWpMsHjfiF26txqu5AMY/WKu7kMtRcW8paiH7j4UaXT9/McK Oas3Noc97xXcLrIVdhv160sWZN4rhKhsNXnnUcTw9aEI/F6fjzf2ltjN7e3ZXLwsYfj06WsJg izPc9YjxIy3DMy8t9RObeKbHF+hV1Sg6Wg9BIjrd2N3sOr586iASW6Qg5/1Z8e5h82OwlGgKH n9vkRgb4TnU6awfJossq8B4XQe0dWytVSen/pRaBlohST1VKbVDYjxs5p7mZ/p2082MIwxUy1 2sXbh6+/DosC0UmqFLTEARehVIx6SaVxPgXuIhPae2Q5LlOVTTrtRDLNmF6Pd 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The handling of the FPU state in sparc64_get_context() and sparc64_set_context() is not the same as what the kernel actually does: we unconditionally read and write the FP registers and the FSR, GSR and FPRS, but the kernel logic is more complicated: * in get_context the kernel has code for saving FPU registers, but it is hidden inside an "if (fenab) condition and the fenab flag is always set to 0 (inside an "#if 1" which has been in the kernel for over 15 years). So the effect is that the FPU state part is always written as zeroes. * in set_context the kernel looks at the fenab field in the structure from the guest, and only restores the state if it is set; it also looks at the structure's FPRS to see whether either the upper or lower or both halves of the register file have valid data. Bring our implementations into line with the kernel: * in get_context: - clear the entire target_ucontext at the top of the function (as the kernel does) - then don't write the FPU state, so those fields remain zero - this fixes Coverity issue CID 1432305 by deleting the code it was complaining about * in set_context: - check the fenab and the fpsr to decide which parts of the FPU data to restore, if any - instead of setting the FPU registers by doing two 32-bit loads and filling in the .upper and .lower parts of the CPU_Double union separately, just do a 64-bit load of the whole register at once. This fixes Coverity issue CID 1432303 because we now access the dregs[] part of the mcfpu_fregs union rather than the sregs[] part (which is not large enough to actually cover the whole of the data, so we were accessing off the end of sregs[]) We change both functions in a single commit to avoid potentially breaking bisection. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20201106152738.26026-2-peter.maydell@linaro.org> [lv: fix FPRS_DU loop s/31/32/] Signed-off-by: Laurent Vivier --- linux-user/sparc/signal.c | 74 +++++++++++++++++++++++---------------- target/sparc/cpu.h | 4 ++- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index d12adc8e6ff9..0057b48fad93 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -402,8 +402,10 @@ void sparc64_set_context(CPUSPARCState *env) abi_ulong ucp_addr; struct target_ucontext *ucp; target_mc_gregset_t *grp; + target_mc_fpu_t *fpup; abi_ulong pc, npc, tstate; unsigned int i; + unsigned char fenab; ucp_addr = env->regwptr[WREG_O0]; if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1)) { @@ -467,26 +469,42 @@ void sparc64_set_context(CPUSPARCState *env) __get_user(env->regwptr[WREG_FP], &(ucp->tuc_mcontext.mc_fp)); __get_user(env->regwptr[WREG_I7], &(ucp->tuc_mcontext.mc_i7)); - /* FIXME this does not match how the kernel handles the FPU in - * its sparc64_set_context implementation. In particular the FPU - * is only restored if fenab is non-zero in: - * __get_user(fenab, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_enab)); - */ - __get_user(env->fprs, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fprs)); - { - uint32_t *src = ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; - for (i = 0; i < 64; i++, src++) { - if (i & 1) { - __get_user(env->fpr[i/2].l.lower, src); - } else { - __get_user(env->fpr[i/2].l.upper, src); + fpup = &ucp->tuc_mcontext.mc_fpregs; + + __get_user(fenab, &(fpup->mcfpu_enab)); + if (fenab) { + abi_ulong fprs; + + /* + * We use the FPRS from the guest only in deciding whether + * to restore the upper, lower, or both banks of the FPU regs. + * The kernel here writes the FPU register data into the + * process's current_thread_info state and unconditionally + * clears FPRS and TSTATE_PEF: this disables the FPU so that the + * next FPU-disabled trap will copy the data out of + * current_thread_info and into the real FPU registers. + * QEMU doesn't need to handle lazy-FPU-state-restoring like that, + * so we always load the data directly into the FPU registers + * and leave FPRS and TSTATE_PEF alone (so the FPU stays enabled). + * Note that because we (and the kernel) always write zeroes for + * the fenab and fprs in sparc64_get_context() none of this code + * will execute unless the guest manually constructed or changed + * the context structure. + */ + __get_user(fprs, &(fpup->mcfpu_fprs)); + if (fprs & FPRS_DL) { + for (i = 0; i < 16; i++) { + __get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i])); + } + } + if (fprs & FPRS_DU) { + for (i = 16; i < 32; i++) { + __get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i])); } } + __get_user(env->fsr, &(fpup->mcfpu_fsr)); + __get_user(env->gsr, &(fpup->mcfpu_gsr)); } - __get_user(env->fsr, - &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fsr)); - __get_user(env->gsr, - &(ucp->tuc_mcontext.mc_fpregs.mcfpu_gsr)); unlock_user_struct(ucp, ucp_addr, 0); return; do_sigsegv: @@ -509,7 +527,9 @@ void sparc64_get_context(CPUSPARCState *env) if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) { goto do_sigsegv; } - + + memset(ucp, 0, sizeof(*ucp)); + mcp = &ucp->tuc_mcontext; grp = &mcp->mc_gregs; @@ -572,19 +592,11 @@ void sparc64_get_context(CPUSPARCState *env) __put_user(env->regwptr[WREG_FP], &(mcp->mc_fp)); __put_user(env->regwptr[WREG_I7], &(mcp->mc_i7)); - { - uint32_t *dst = ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; - for (i = 0; i < 64; i++, dst++) { - if (i & 1) { - __put_user(env->fpr[i/2].l.lower, dst); - } else { - __put_user(env->fpr[i/2].l.upper, dst); - } - } - } - __put_user(env->fsr, &(mcp->mc_fpregs.mcfpu_fsr)); - __put_user(env->gsr, &(mcp->mc_fpregs.mcfpu_gsr)); - __put_user(env->fprs, &(mcp->mc_fpregs.mcfpu_fprs)); + /* + * We don't write out the FPU state. This matches the kernel's + * implementation (which has the code for doing this but + * hidden behind an "if (fenab)" where fenab is always 0). + */ if (err) goto do_sigsegv; diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index b9369398f24b..277254732b93 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -156,7 +156,9 @@ enum { #define PS_IE (1<<1) #define PS_AG (1<<0) /* v9, zero on UA2007 */ -#define FPRS_FEF (1<<2) +#define FPRS_DL (1 << 0) +#define FPRS_DU (1 << 1) +#define FPRS_FEF (1 << 2) #define HS_PRIV (1<<2) #endif From patchwork Fri Dec 18 10:24:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4q06Zw6z9s1l for ; Fri, 18 Dec 2020 21:29:16 +1100 (AEDT) Received: from localhost ([::1]:60108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD0c-0001VP-TI for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:29:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvu-0002z8-3c for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:22 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:32927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-00074F-0c for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:21 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MS3rB-1kg8pw3gOB-00TUuF; Fri, 18 Dec 2020 11:24:16 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/14] linux-user/sparc: Remove unneeded checks of 'err' from sparc64_get_context() Date: Fri, 18 Dec 2020 11:24:05 +0100 Message-Id: <20201218102407.597566-13-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZmAq9ybs8O5o28NnMQotEu1ugm4XdPERtwd950RO8gEeC4I8rcD YUcRpcQiQFywXZkcukoicbqYh/sHIk7diteQmJWrCs5UbCdqpezSibVoO3UI460FULRuoqC 6O/fZriYmLZ4x8Wz8D09JT1oLEDTmUkVtRKcaxNYLFHYhYHOkb+O5RkU68WfN78VeUXQdMT zMEyMnHoFxsOptUK/pKVQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ztmoiu/l2bA=:KI5SRkyExS5Sv0iD3WzIDW R7f+Yi/8EqmncTKNUovIAqI2nvbkpqqfEiswX2Ufew77C6mGS7MgjKJetZvKTlaZ432um/480 rvtJGU1x1lzW9JAk5xauJi/hrnnY3z+AzZKkH7Nzhw3DEicE9yLQYjFpZG7e3lnB/6eaENnBq PCAwyQetCEv54j6KIx/keN4PkUvEFj6g7+coTFSNk9ubzWSmWdk43qQGyNZSWX1OLmPoxsjJ0 r3aEeNgWh5TAasdkDfWWh5svg+YMfBJuG/gzoz0TuKQHELZwjHILbv6LWCnqVZYFEpxqrfMHh ZusrLZ6br+Qp/uBD3nP3GPqOdKNA7iqWvqG7laZ/3BXCD3PwFJKA6XlmU6DGv5T4wR1brbkog Sz0l8it6kYEcotG59GJYX/C8s7xM+rc/f6PN4pJP82R2yLfhzweZImQEVndtMcXUzXBYlaMcW 2csR2wsDbw== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Unlike the kernel macros, our __get_user() and __put_user() do not return a failure code. Kernel code typically has a style of err |= __get_user(...); err |= __get_user(...); and then checking err at the end. In sparc64_get_context() our version of the code dropped the accumulating into err but left the "if (err) goto do_sigsegv" checks, which will never be taken. Delete unnecessary if()s. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20201106152738.26026-3-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/signal.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 0057b48fad93..58b48afe29c9 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -555,8 +555,6 @@ void sparc64_get_context(CPUSPARCState *env) for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) { __put_user(*src, dst); } - if (err) - goto do_sigsegv; } /* XXX: tstate must be saved properly */ @@ -598,8 +596,6 @@ void sparc64_get_context(CPUSPARCState *env) * hidden behind an "if (fenab)" where fenab is always 0). */ - if (err) - goto do_sigsegv; unlock_user_struct(ucp, ucp_addr, 1); return; do_sigsegv: From patchwork Fri Dec 18 10:24:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4mS5hLkz9sWT for ; Fri, 18 Dec 2020 21:27:04 +1100 (AEDT) Received: from localhost ([::1]:51112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqCyU-0006Hk-NB for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:27:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvv-00032N-OR for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:23 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:42843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-00074d-T6 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:23 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MRTEp-1kTTNd1fmP-00NV9V; Fri, 18 Dec 2020 11:24:16 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/14] linux-user/sparc: Don't restore %g7 in sparc64_set_context() Date: Fri, 18 Dec 2020 11:24:06 +0100 Message-Id: <20201218102407.597566-14-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:bhY+mFh4+79meoAigyLRoy7nfbcBXT9YT0XkjqwgRpkXBO8kAHo cSGLSopnN3QQafTXqtdUu2Ar7boCUawUF1+T5Y9t7Bi78zkUxljAbWi0nlc0CKLw1g6u5Z0 sSjSOhNw5qDQRLLFb2jbJyYzOGOVoKNVS8VpKCjaY2Zspr8VolmcrT+FeS72TEZ/Va7I+v7 7S7SeoZMPSFgvNL1JFy6w== X-UI-Out-Filterresults: notjunk:1;V03:K0:Q2Kw8nzRnxg=:6Ocwacmuloa0YLKVmTV7su HL0kr91dcwog4oqgYwF+N+qB7xLr2cGFgbBkUw7I9gcrQsvxjVgH2zuouNoCMokOLGGXG2nX0 NOKY0DncEQ6DJnZJgTG/qMyXvmYdQyic0DZeyl7s+HP5zMSA3cPqxkYLZAPxLe2tDQUKlyKH/ uTesRmLyyerBLlSI4foLXjnMSZiQHRwFwfwPQUYeoT7AtAr3a7RJNSwheGG7XzTcpTLglHCrX fA9cxBcvDGsEOsXqZjvI84E0GgtQSh9z3Xs8bZlfDm25q+1ljNlp0WnB5QsXTMYXjinwb/VTc AnWHxVRlVFrGCNpReI2oZFj+9ndvJJD7uaGGjaFVahaHzjTqGAlYaotOHyghYYSn1VCaM4r++ A9/tYXZ+efrlW1mCuZMPXt7SuMZLk1ZCBeiLPO24pwN3q6KsI0cpVTGiRjyuIYt4hvUZ8m46u 14+W3K2LzA== 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The kernel does not restore the g7 register in sparc64_set_context(); neither should we. (We still save it in sparc64_get_context().) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20201106152738.26026-4-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 58b48afe29c9..d92e096cafa7 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -447,7 +447,7 @@ void sparc64_set_context(CPUSPARCState *env) __get_user(env->gregs[4], (&(*grp)[SPARC_MC_G4])); __get_user(env->gregs[5], (&(*grp)[SPARC_MC_G5])); __get_user(env->gregs[6], (&(*grp)[SPARC_MC_G6])); - __get_user(env->gregs[7], (&(*grp)[SPARC_MC_G7])); + /* Skip g7 as that's the thread register in userspace */ /* * Note that unlike the kernel, we didn't need to mess with the From patchwork Fri Dec 18 10:24:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1418164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 4Cy4sV2yVjz9sVj for ; Fri, 18 Dec 2020 21:31:26 +1100 (AEDT) Received: from localhost ([::1]:39746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqD2i-0004ne-Aj for incoming@patchwork.ozlabs.org; Fri, 18 Dec 2020 05:31:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvw-00033E-4C for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:24 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:43369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqCvq-00074i-Vr for qemu-devel@nongnu.org; Fri, 18 Dec 2020 05:24:23 -0500 Received: from localhost.localdomain ([82.252.144.198]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MmU9X-1kPyrp3bbl-00iQFx; Fri, 18 Dec 2020 11:24:17 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 14/14] linux-user/sparc: Handle tstate in sparc64_get/set_context() Date: Fri, 18 Dec 2020 11:24:07 +0100 Message-Id: <20201218102407.597566-15-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218102407.597566-1-laurent@vivier.eu> References: <20201218102407.597566-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:pIyHsYTh+HsHo3ROoPHIIZFVmmdDt9VfxWKsbQU9GtPva/e2r9C JFjiFG7TExdMFEasjcqJ6PduiAMdudLnmY30Np2QNk3X72XUhyBL0yTHvNcyKOLUSBdwkOZ sLavxvcs3kQzhpDyUJ6soh/IuVWF1F+ue8Um5CO3lctmcaCFrDiD1kShsqGCMLvRZx0Uzv4 Qe2d8N6140vcS50uFVwCw== X-UI-Out-Filterresults: notjunk:1;V03:K0:oT+m3Whhm7o=:8fOxOQ7A6GX3SxVGDKxsvr BKVipxytri2Mxem1bQ4rMTj+xTnFki+VifuDwEfOasY/Qrx+R9LXMK0o6GBAnuS6ZJr+DWNGE mN9SK/4ZW90gsqjnP99R5VhmD672czqfG2LVqvNedznCoccgkb4GL6YL/eAq1gHGHM8GG4hvw Ol+UF/vhq/sM7RnTz8MlDsKyxl7wLD43Pf08wCxOnuXtr89j8Za4A1DxTGiQAKqBN5Zpyz236 bBwwe2pnr09MJoAt4MDx7PG3PCjwqFMtoM1s1onQ4T82ij7NtXYKxRPHwsHuasbK6umU/B94Y KF700yEMLcMAelWyKXg0eIcFVUmxLb33T6AxS6X5BDW6H3tePPrrsUqkQHz0MY6W6C/eXqXZt vNedHFYwNc9AGjYNOKCgPuiWiRNuM+zXE7kCXTZeQZdHrEFygoHjdF/d/0L3d6FJlW9Kc3Zh+ k2VwxlgQRg== 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Correctly implement save/restore of the tstate field in sparc64_get_context() and sparc64_set_context(): * Don't use the CWP value from the guest in set_context * Construct and save a tstate value rather than leaving it as zero in get_context To do this we factor out the "calculate TSTATE value from CPU state" code from sparc_cpu_do_interrupt() into its own sparc64_tstate() function; that in turn requires us to move some of the function prototypes out from inside a CPU_NO_IO_DEFS ifdef guard. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20201106152738.26026-5-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/signal.c | 7 +++---- target/sparc/cpu.h | 24 ++++++++++++++++++++---- target/sparc/int64_helper.c | 5 +---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index d92e096cafa7..d27b7a3af79d 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -438,9 +438,9 @@ void sparc64_set_context(CPUSPARCState *env) env->npc = npc; __get_user(env->y, &((*grp)[SPARC_MC_Y])); __get_user(tstate, &((*grp)[SPARC_MC_TSTATE])); + /* Honour TSTATE_ASI, TSTATE_ICC and TSTATE_XCC only */ env->asi = (tstate >> 24) & 0xff; - cpu_put_ccr(env, tstate >> 32); - cpu_put_cwp64(env, tstate & 0x1f); + cpu_put_ccr(env, (tstate >> 32) & 0xff); __get_user(env->gregs[1], (&(*grp)[SPARC_MC_G1])); __get_user(env->gregs[2], (&(*grp)[SPARC_MC_G2])); __get_user(env->gregs[3], (&(*grp)[SPARC_MC_G3])); @@ -557,8 +557,7 @@ void sparc64_get_context(CPUSPARCState *env) } } - /* XXX: tstate must be saved properly */ - // __put_user(env->tstate, &((*grp)[SPARC_MC_TSTATE])); + __put_user(sparc64_tstate(env), &((*grp)[SPARC_MC_TSTATE])); __put_user(env->pc, &((*grp)[SPARC_MC_PC])); __put_user(env->npc, &((*grp)[SPARC_MC_NPC])); __put_user(env->y, &((*grp)[SPARC_MC_Y])); diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 277254732b93..4b2290650be4 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -608,10 +608,6 @@ target_ulong cpu_get_psr(CPUSPARCState *env1); void cpu_put_psr(CPUSPARCState *env1, target_ulong val); void cpu_put_psr_raw(CPUSPARCState *env1, target_ulong val); #ifdef TARGET_SPARC64 -target_ulong cpu_get_ccr(CPUSPARCState *env1); -void cpu_put_ccr(CPUSPARCState *env1, target_ulong val); -target_ulong cpu_get_cwp64(CPUSPARCState *env1); -void cpu_put_cwp64(CPUSPARCState *env1, int cwp); void cpu_change_pstate(CPUSPARCState *env1, uint32_t new_pstate); void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl); #endif @@ -829,4 +825,24 @@ static inline bool tb_am_enabled(int tb_flags) #endif } +#ifdef TARGET_SPARC64 +/* win_helper.c */ +target_ulong cpu_get_ccr(CPUSPARCState *env1); +void cpu_put_ccr(CPUSPARCState *env1, target_ulong val); +target_ulong cpu_get_cwp64(CPUSPARCState *env1); +void cpu_put_cwp64(CPUSPARCState *env1, int cwp); + +static inline uint64_t sparc64_tstate(CPUSPARCState *env) +{ + uint64_t tstate = (cpu_get_ccr(env) << 32) | + ((env->asi & 0xff) << 24) | ((env->pstate & 0xf3f) << 8) | + cpu_get_cwp64(env); + + if (env->def.features & CPU_FEATURE_GL) { + tstate |= (env->gl & 7ULL) << 40; + } + return tstate; +} +#endif + #endif diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index ba95bf228cc4..7fb8ab211ca8 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -131,9 +131,7 @@ void sparc_cpu_do_interrupt(CPUState *cs) } tsptr = cpu_tsptr(env); - tsptr->tstate = (cpu_get_ccr(env) << 32) | - ((env->asi & 0xff) << 24) | ((env->pstate & 0xf3f) << 8) | - cpu_get_cwp64(env); + tsptr->tstate = sparc64_tstate(env); tsptr->tpc = env->pc; tsptr->tnpc = env->npc; tsptr->tt = intno; @@ -148,7 +146,6 @@ void sparc_cpu_do_interrupt(CPUState *cs) } if (env->def.features & CPU_FEATURE_GL) { - tsptr->tstate |= (env->gl & 7ULL) << 40; cpu_gl_switch_gregs(env, env->gl + 1); env->gl++; }