From patchwork Mon Oct 4 07:43:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535959 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCXz6lD0z9t0G for ; Mon, 4 Oct 2021 18:49:39 +1100 (AEDT) Received: from localhost ([::1]:45342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIjB-0000ab-MW for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:49:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeK-00045H-Or for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:36 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:52663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeI-0004oc-VO for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:36 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MtPzy-1mnC6Q0Zoc-00upgM; Mon, 04 Oct 2021 09:44:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/26] linux-user: Add infrastructure for a signal trampoline page Date: Mon, 4 Oct 2021 09:43:56 +0200 Message-Id: <20211004074421.3141222-2-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:sbMmJtEOpzyb3l+1hVe+4VKoHMWfR4gr/+BEHgNtQw6BC98+dVM lFkCDnQAOgKv2lx2IY2LsQb5ZAHWF7HeITi5cvfmiFD6lMHZ6dpwZAMtM6e96w0Yn7GVGVt ynozdgOIAuecb9wQa+EzLkyn7462tg3cRfJfRift7p/KCCPEdsJRtpMlk7+HtHzoH1PHbKS Q2d0MsOxlyVbUqmvYMYjA== X-UI-Out-Filterresults: notjunk:1;V03:K0:xOWXO5YmaL4=:8n9JHufyYISypNDlKgbI5B xu88iX0ebeFjKmoYPbYhK4xfc3QOboyKz8Cjw9iEyn5pJhwhj6dIuTShu6l9fwWpisstZn6o2 svTPcXy/0sVMd2KjOYqLoByA8E0vxSoB5WmBK5h6iklCdr9wNJpOMdIIMLLwsIrTzjzyJqSmn 305lT1zIkD87hr0rx69yY3ASZoQNkctXFehvZfYTBhl5rKE+eAGXHDjcgTGvX/cvoZUHcc0Cf vDX+Ho0kWynbO2y8tEWiLWocppIyIwisE/ykrx5bkg/+x/ZoA8vYiQH1l2kOWzTplkUtT1CbK 7Ui+BFawSatgaq+4k3VAAqriBaMbtoaOT3D1gC8IMxYZcjStNBoPtafkGTiKHjog5nthrMVBI b/Iyzf9eas/e/vf0X40MnVQLXQiQLURVtTkr/RnXTmJgL9CQr73TIGW6zPahXysPnqZEx4aYs pfOaDJfcgtRPTSzuSOsL066A3242Pr7kWK75bDe55rudymNV7uVHGGGglk28GgHO+dkbYjW/z f/tPhq6a0DALTcse0CRRxVucuq4VadzHDJByBegqVp/3r4q7tnIzx7kvMzn+cs9HPbRaEQCry wyJijpNvaNJq0Lp7S76eJKm689p+8fEtV9CctnXHowgSUIgzKymFXnQMwrYy5Xj/ro6eqQ4dV fqUhZ7hk+Ms/a8W46FxlfPUhr2nfBiHjneZtU+RqQ1Fyk28Y6r4AKJDb1pwmdzW4abrx+h4Xk s8gqAsdkkPWsRYXzLIijFI6cTnxgghYHEqcasg== Received-SPF: none client-ip=212.227.126.187; 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: Max Filippov , Laurent Vivier , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Allocate a page to hold the signal trampoline(s). Invoke a guest-specific hook to fill in the contents of the page before marking it read-execute again. Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 18 ++++++++++++++++++ linux-user/signal-common.h | 6 ++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 5f9e2141ad1e..459a26ef1d93 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -7,6 +7,7 @@ #include "qemu.h" #include "user-internals.h" +#include "signal-common.h" #include "loader.h" #include "user-mmap.h" #include "disas/disas.h" @@ -17,6 +18,7 @@ #include "qemu/units.h" #include "qemu/selfmap.h" #include "qapi/error.h" +#include "target_signal.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -28,6 +30,10 @@ #undef ELF_ARCH #endif +#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 +#endif + #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */ @@ -3249,6 +3255,18 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) #endif } + /* + * TODO: load a vdso, which would also contain the signal trampolines. + * Otherwise, allocate a private page to hold them. + */ + if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) { + abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + setup_sigtramp(tramp_page); + target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC); + } + bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, info, (elf_interpreter ? &interp_info : NULL)); info->start_stack = bprm->p; diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 79511becb4e7..7457f8025c47 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -20,6 +20,12 @@ #ifndef SIGNAL_COMMON_H #define SIGNAL_COMMON_H +/* Fallback addresses into sigtramp page. */ +extern abi_ulong default_sigreturn; +extern abi_ulong default_rt_sigreturn; + +void setup_sigtramp(abi_ulong tramp_page); + int on_sig_stack(unsigned long sp); int sas_ss_flags(unsigned long sp); abi_ulong target_sigsp(abi_ulong sp, struct target_sigaction *ka); diff --git a/linux-user/signal.c b/linux-user/signal.c index 203821645509..14d8fdfde152 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -35,6 +35,9 @@ static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_signum, siginfo_t *info, void *puc); +/* Fallback addresses into sigtramp page. */ +abi_ulong default_sigreturn; +abi_ulong default_rt_sigreturn; /* * System includes define _NSIG as SIGRTMAX + 1, From patchwork Mon Oct 4 07:43:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535958 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCTR0x9Bz9t0G for ; Mon, 4 Oct 2021 18:46:35 +1100 (AEDT) Received: from localhost ([::1]:38784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIgC-0004Cb-UY for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:46:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeM-00048F-DH for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:38 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:57997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeJ-0004oa-6m for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:37 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MEC8L-1mhRfR2stB-00AFRl; Mon, 04 Oct 2021 09:44:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/26] linux-user/aarch64: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:43:57 +0200 Message-Id: <20211004074421.3141222-3-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:UUo/MIhsvSBxqSlSr/5Haj4RKGK6NXQdy2Lhrtm0Ftm+vXIn+ql rLFjFpI/4Af8hUSSlQ6FIJgA23Y9oC3Pi6TAod/vgK4a7LhS+9p8Bs87K6BzdLv2m9bkBL5 G+fc7+VrXDYTm0u2Tb64+QDz/LtsnUL0iE7ayVmVNXvCfiopzFTCbhR8k45hbbVo3YU26Z3 g+5EgQTuQnBpfhZA1eFgQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:QyAXt03HjcQ=:D0yY+QJvZK0rSkIUQp/jKI L2hzrP5sEYxiLmmtJxm0m+BXZtg3ZX5gJeOqhk34s+zcxOWbaBCrTD+OPozuYqlEe0123T2Hj 2C+o06JBwpl2pY+MATE1wAJd/a80mPJbZbQcij81kbCroZgiN10zaVdYp3IrOW8SHqkjRf7WQ FnQoF9pC0PC+7ISqe0UufRL7pFtxcZb2/Y5Yrnx4PeuLj6vFyFrIvRwpiYrlRS7Y0u3il9R4o unIK9iajeLz2Iqz5dWrslA1irXTXo4YXVPXIq1CHe8vZ8q8MYQQ3JSW7fKqzuygHhgV9WpQPR SfRjUciVhQO+VXngGD7d/HQXdAfEw4krXsGozVEtvHF837Cd/7mSIBN0tR1+rfumpASufFfFE 0NGK51mE+Ql7KRhZZS18AKeIDM26C+sWf9cv8arjNnffzBfXakGmmF6Sp+g+R/DLOmMCnBRRH Z1DK+P6NQ0XOI3shpOcywPeF2jXI8e4CWoExGe+7yNr2v0VD47sAH8318b2N+rhl6v7/mQIeX J2Sqxoq7v6PkhOxGGHRDzeUxuo5XLTYMqEXqc+F3IlOPcJPEwoqmsikKg4w/4Q0TPh/2REHEG 0HUO4HCDcSDJZ28waUnLxV7/JsO6F3fDn/5A1dlvSAkpAVHcMZyHByxXf+eDJulTaNSBv1I7w IxjMGB4wgWUC/XTbTqdyvVtI1tVOvhY/wlTdSr31sKuqpqy1FHswWiO/Rztgr2+MHSXKeUVyk 28Msm6JQ3B0+vKZaTW3rCWYXLvhXbhh78F8F3A== Received-SPF: none client-ip=212.227.126.134; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/signal.c | 34 ++++++++++++++++++------------ linux-user/aarch64/target_signal.h | 2 ++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 49025648cb4f..29c52db3f130 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -109,7 +109,6 @@ struct target_rt_sigframe { struct target_rt_frame_record { uint64_t fp; uint64_t lr; - uint32_t tramp[2]; }; static void target_setup_general_frame(struct target_rt_sigframe *sf, @@ -461,9 +460,9 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, layout.total_size = MAX(layout.total_size, sizeof(struct target_rt_sigframe)); - /* Reserve space for the return code. On a real system this would - * be within the VDSO. So, despite the name this is not a "real" - * record within the frame. + /* + * Reserve space for the standard frame unwind pair: fp, lr. + * Despite the name this is not a "real" record within the frame. */ fr_ofs = layout.total_size; layout.total_size += sizeof(struct target_rt_frame_record); @@ -496,15 +495,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { return_addr = ka->sa_restorer; } else { - /* - * mov x8,#__NR_rt_sigreturn; svc #0 - * Since these are instructions they need to be put as little-endian - * regardless of target default or current CPU endianness. - */ - __put_user_e(0xd2801168, &fr->tramp[0], le); - __put_user_e(0xd4000001, &fr->tramp[1], le); - return_addr = frame_addr + fr_ofs - + offsetof(struct target_rt_frame_record, tramp); + return_addr = default_rt_sigreturn; } env->xregs[0] = usig; env->xregs[29] = frame_addr + fr_ofs; @@ -577,3 +568,20 @@ long do_sigreturn(CPUARMState *env) { return do_rt_sigreturn(env); } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * mov x8,#__NR_rt_sigreturn; svc #0 + * Since these are instructions they need to be put as little-endian + * regardless of target default or current CPU endianness. + */ + __put_user_e(0xd2801168, &tramp[0], le); + __put_user_e(0xd4000001, &tramp[1], le); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h index 18013e1b2350..7580d99403cb 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -25,4 +25,6 @@ typedef struct target_sigaltstack { #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* AARCH64_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:43:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535960 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCYS4khvz9t0G for ; Mon, 4 Oct 2021 18:50:04 +1100 (AEDT) Received: from localhost ([::1]:45800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIjZ-0000w3-Sg for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:50:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeM-00049R-Pq for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:38 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:56197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeJ-0004oh-7E for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:38 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M3mHT-1mX1nW0uwN-000vlz; Mon, 04 Oct 2021 09:44:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/26] linux-user/arm: Drop v1 signal frames Date: Mon, 4 Oct 2021 09:43:58 +0200 Message-Id: <20211004074421.3141222-4-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Jjy1kR7GKaMakXoNP65v09xvEXc663oIV0YmRCVH06ZBoFthymT g9NgX0m+rG3pk86iPJM7cXhVRRW5ysTNFFn0kRfELDWVgXlQefzLAc/+9U2RwZCCbmn2Ucy kGRE0Kqxj3H4NgxCP6x1sT6rHz7NMPixPyEN2OM/5ivLAS5zsNsxzFUJVWKNpeFQvUyJvjy rcP1ZP/5Gi94XJ1B2qiTQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:A7XtHWZLtwA=:hSA/2m0+116f+MdzgSqbZZ YCh3y/zpEfvVb6qpjCyz8ucsDkMe8um4jzWCmKTY+bh39QWm1cjVDaesZV4ZiyMtr4zHJyQDw /LGPeZ6wwGTxWY1MqluTR2yBbtV668fUOcrkwOAPr2xf/4BN0jItakiVJBiHfheI6/fi2rD1A Kldf+k9br3rm3tig+1H0JLyuT6Ty2N/EHlOd3WLs2MhZ2nFwH+3pUUafaL2pfiLhvRQuwYXTB GG5qYKHxPn646AvFor0XBVkuggeZE+x8SUzimc/ZolByfqfeG73BspKCOSwMDw6kwpecTWHD6 95grP/fNH7v7rzPoU+WpBALEsUz1TVmurwE3zK70oMVz34T3JrPkJCqDdp3rvvJ9Oxdg8kANy 6iua14WNwJZC6kfL8fSQhLlXaT62EdpuABN1HEm1g7cswswXxEVUsGVg3SXiCeUOInqvO0YfQ tDyhVikUDUN5sqcRkbBKWx6cNF1aPUkeqyp/ztwj40BjcGDbwIhEVJjne4tIX2pJlJUTNAAmT EhBSd82Zjq7DfbTXS5s0jsludHm0+2nANYvoVDfN71KpiKoSZDHMP5a4lNbG7Mdgmf5z87MFR 43VyAFIwLTy9svKoY9XSxcjDmc7VY9o3meQtQWJLOHIoIn0wBwcdtliLk4+8K3vMrSe3ikb7D Td+ttpeVgngjDMYcSuag4r1yAXuG/SqcMV4HV6hpAfaVA90xYhK8tM5FhQDO2BoRA3qen5yP+ 2uzoEt/YuG7H1Y2xqfsj5SWJA1bMETm4YhRn+Q== Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) 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 , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Version 2 signal frames are used from 2.6.12 and since cbc14e6f286, we have set UNAME_MINIMUM_RELEASE to 2.6.32. Suggested-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/signal.c | 220 +--------------------------------------- 1 file changed, 4 insertions(+), 216 deletions(-) diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed144f9455d2..d0940bab479c 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,14 +46,6 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v1 { - abi_ulong tuc_flags; - abi_ulong tuc_link; - target_stack_t tuc_stack; - struct target_sigcontext tuc_mcontext; - target_sigset_t tuc_sigmask; /* mask last for extensibility */ -}; - struct target_ucontext_v2 { abi_ulong tuc_flags; abi_ulong tuc_link; @@ -98,28 +90,12 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v1 -{ - struct target_sigcontext sc; - abi_ulong extramask[TARGET_NSIG_WORDS-1]; - abi_ulong retcode[4]; -}; - struct sigframe_v2 { struct target_ucontext_v2 uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v1 -{ - abi_ulong pinfo; - abi_ulong puc; - struct target_siginfo info; - struct target_ucontext_v1 uc; - abi_ulong retcode[4]; -}; - struct rt_sigframe_v2 { struct target_siginfo info; @@ -363,37 +339,6 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -/* compare linux/arch/arm/kernel/signal.c:setup_frame() */ -static void setup_frame_v1(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - struct sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); - int i; - - trace_user_setup_frame(regs, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - setup_sigcontext(&frame->sc, regs, set->sig[0]); - - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->extramask[i - 1]); - } - - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v1, retcode))) { - goto sigsegv; - } - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); -} - static void setup_frame_v2(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { @@ -422,60 +367,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >= 0x020612) { - setup_frame_v2(usig, ka, set, regs); - } else { - setup_frame_v1(usig, ka, set, regs); - } -} - -/* compare linux/arch/arm/kernel/signal.c:setup_rt_frame() */ -static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - struct rt_sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); - struct target_sigaltstack stack; - int i; - abi_ulong info_addr, uc_addr; - - trace_user_setup_rt_frame(env, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - info_addr = frame_addr + offsetof(struct rt_sigframe_v1, info); - __put_user(info_addr, &frame->pinfo); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v1, uc); - __put_user(uc_addr, &frame->puc); - tswap_siginfo(&frame->info, info); - - /* Clear all the bits of the ucontext we don't use. */ - memset(&frame->uc, 0, offsetof(struct target_ucontext_v1, tuc_mcontext)); - - memset(&stack, 0, sizeof(stack)); - target_save_altstack(&stack, env); - memcpy(&frame->uc.tuc_stack, &stack, sizeof(stack)); - - setup_sigcontext(&frame->uc.tuc_mcontext, env, set->sig[0]); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); - } - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v1, retcode))) { - goto sigsegv; - } - - env->regs[1] = info_addr; - env->regs[2] = uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); + setup_frame_v2(usig, ka, set, regs); } static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, @@ -516,11 +408,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - if (get_osversion() >= 0x020612) { - setup_rt_frame_v2(usig, ka, info, set, env); - } else { - setup_rt_frame_v1(usig, ka, info, set, env); - } + setup_rt_frame_v2(usig, ka, info, set, env); } static int @@ -553,54 +441,6 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static long do_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct sigframe_v1 *frame = NULL; - target_sigset_t set; - sigset_t host_set; - int i; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - __get_user(set.sig[0], &frame->sc.oldmask); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __get_user(set.sig[i], &frame->extramask[i - 1]); - } - - target_to_host_sigset_internal(&host_set, &set); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->sc)) { - goto badframe; - } - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; -} - static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) { int i; @@ -733,55 +573,7 @@ badframe: long do_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_sigreturn_v2(env); - } else { - return do_sigreturn_v1(env); - } -} - -static long do_rt_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct rt_sigframe_v1 *frame = NULL; - sigset_t host_set; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_rt_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { - goto badframe; - } - - target_restore_altstack(&frame->uc.tuc_stack, env); - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - unlock_user_struct(frame, frame_addr, 0); - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; + return do_sigreturn_v2(env); } static long do_rt_sigreturn_v2(CPUARMState *env) @@ -822,9 +614,5 @@ badframe: long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_rt_sigreturn_v2(env); - } else { - return do_rt_sigreturn_v1(env); - } + return do_rt_sigreturn_v2(env); } From patchwork Mon Oct 4 07:43:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535969 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCl24x5jz9t25 for ; Mon, 4 Oct 2021 18:58:22 +1100 (AEDT) Received: from localhost ([::1]:34320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIrc-0004xm-Dg for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:58:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeO-0004Cl-0D for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:40 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:50015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeK-0004pp-Jl for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:39 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MbTCr-1n4RbU3kj3-00bvDd; Mon, 04 Oct 2021 09:44:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/26] linux-user/arm: Drop "_v2" from symbols in signal.c Date: Mon, 4 Oct 2021 09:43:59 +0200 Message-Id: <20211004074421.3141222-5-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ftPMbVF9cQjNs4HTRnOplBPNQXMkSWgTHlt6TYrmpzw7t6keMzi LQKs1q0xJ9QZlNxgPtL6ZvnuUN0ctcrfAhh13uXuT4TlgKMEZJ34WuabeCab3EqnJyMwMSp N7C8LlD1lcybcS5sAGHEodZlwmwIWzzSHyK5ATwjCwXX0X2ytccaI8c9XXqR1Qx4M090I7m /oJuyRLQlKQnQNxamscWg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Fzrn2R16ljs=:hc+mD4NWEvctGvX7sQ231w Kpi1PnKU27u4yV5jIwDwhnRmqvaCRiwS/DfS5J6hVC6KDTjM2KfP8tSE729Se4SqqJceU5MEG g5wblxtd4rN7YCGJzTPQgH6rrzdPUVP77s1NR08rgfBJAq+ZhsGIBqpUBHlLSklYztTvluhR0 VlQVPgDq0IbZHHSxQRpmIHtij8vyCltJVbCBKH1Vbf6dttVZSscjVfFhh/swXz4rcTBjXQWDi 3U0uM3iwA596X/2Vn68kCIndR/zq5CcF+QeDjoH/A5bFuf03ocHkd7aSp8sooDIotyhB2eIR5 LM/5e/m/Of1XsKeNeTMnUzUjF61BCth1abPjUM+IanAhzkdFghSWS3xZbLRlGB/1KrSwcsn+u xr4T3jd00I2BJgTlJSTuEyVUoJDvVooPTAmuFr7kizg1WR1LYLeZAgRdBnyuIRPKRu4wSBcEM 69YgbEUkSgOPzxOZVmknRzQGvMFTZ5gj/GUEm5tw3fJN3hyND8F9/ksV30NKhJu74g8KMbrNZ S1DKgR+cirg4XyUryJY06eeDI5Bvonl6rhwhUSJzdO4OSbH8z7P/d9nxp7f03hMRZNgKNm6R+ ja4oXPbtb4DrELncGIoyt2WA/Qz4xld70VZa/1fqtQcYbIw1cNsnoZ54JB2QjnPzpxfmMMs2Y GTYMUE7bWMVkdWI6hJU0F6EoUHtZuc69i5KwGAXIvDU2DS/oyLLVyqZ6XOn3KWjNMa67eJpuc Wif7hn98cLMyGHalFnGFGYr+uGhH8o22FeUMvA== Received-SPF: none client-ip=212.227.126.135; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Richard Henderson Since we no longer support "v1", there's no need to distinguish "v2". Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/signal.c | 115 ++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 70 deletions(-) diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index d0940bab479c..ed7d1d80bb9c 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,7 +46,7 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v2 { +struct target_ucontext { abi_ulong tuc_flags; abi_ulong tuc_link; target_stack_t tuc_stack; @@ -90,16 +90,16 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v2 +struct sigframe { - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v2 +struct rt_sigframe { struct target_siginfo info; - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; @@ -270,7 +270,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, return 0; } -static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) +static abi_ulong *setup_sigframe_vfp(abi_ulong *regspace, CPUARMState *env) { int i; struct target_vfp_sigframe *vfpframe; @@ -287,8 +287,7 @@ static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) return (abi_ulong*)(vfpframe+1); } -static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, - CPUARMState *env) +static abi_ulong *setup_sigframe_iwmmxt(abi_ulong *regspace, CPUARMState *env) { int i; struct target_iwmmxt_sigframe *iwmmxtframe; @@ -307,15 +306,15 @@ static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, return (abi_ulong*)(iwmmxtframe+1); } -static void setup_sigframe_v2(struct target_ucontext_v2 *uc, - target_sigset_t *set, CPUARMState *env) +static void setup_sigframe(struct target_ucontext *uc, + target_sigset_t *set, CPUARMState *env) { struct target_sigaltstack stack; int i; abi_ulong *regspace; /* Clear all the bits of the ucontext we don't use. */ - memset(uc, 0, offsetof(struct target_ucontext_v2, tuc_mcontext)); + memset(uc, 0, offsetof(struct target_ucontext, tuc_mcontext)); memset(&stack, 0, sizeof(stack)); target_save_altstack(&stack, env); @@ -325,10 +324,10 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, /* Save coprocessor signal frame. */ regspace = uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace = setup_sigframe_v2_vfp(regspace, env); + regspace = setup_sigframe_vfp(regspace, env); } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace = setup_sigframe_v2_iwmmxt(regspace, env); + regspace = setup_sigframe_iwmmxt(regspace, env); } /* Write terminating magic word */ @@ -339,10 +338,10 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -static void setup_frame_v2(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) +void setup_frame(int usig, struct target_sigaction *ka, + target_sigset_t *set, CPUARMState *regs) { - struct sigframe_v2 *frame; + struct sigframe *frame; abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); trace_user_setup_frame(regs, frame_addr); @@ -350,10 +349,10 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, goto sigsegv; } - setup_sigframe_v2(&frame->uc, set, regs); + setup_sigframe(&frame->uc, set, regs); if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v2, retcode))) { + frame_addr + offsetof(struct sigframe, retcode))) { goto sigsegv; } @@ -364,17 +363,11 @@ sigsegv: force_sigsegv(usig); } -void setup_frame(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - setup_frame_v2(usig, ka, set, regs); -} - -static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) +void setup_rt_frame(int usig, struct target_sigaction *ka, + target_siginfo_t *info, + target_sigset_t *set, CPUARMState *env) { - struct rt_sigframe_v2 *frame; + struct rt_sigframe *frame; abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); abi_ulong info_addr, uc_addr; @@ -383,14 +376,14 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, goto sigsegv; } - info_addr = frame_addr + offsetof(struct rt_sigframe_v2, info); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v2, uc); + info_addr = frame_addr + offsetof(struct rt_sigframe, info); + uc_addr = frame_addr + offsetof(struct rt_sigframe, uc); tswap_siginfo(&frame->info, info); - setup_sigframe_v2(&frame->uc, set, env); + setup_sigframe(&frame->uc, set, env); if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v2, retcode))) { + frame_addr + offsetof(struct rt_sigframe, retcode))) { goto sigsegv; } @@ -404,13 +397,6 @@ sigsegv: force_sigsegv(usig); } -void setup_rt_frame(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - setup_rt_frame_v2(usig, ka, info, set, env); -} - static int restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) { @@ -441,7 +427,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) +static abi_ulong *restore_sigframe_vfp(CPUARMState *env, abi_ulong *regspace) { int i; abi_ulong magic, sz; @@ -471,8 +457,8 @@ static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) return (abi_ulong*)(vfpframe + 1); } -static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, - abi_ulong *regspace) +static abi_ulong *restore_sigframe_iwmmxt(CPUARMState *env, + abi_ulong *regspace) { int i; abi_ulong magic, sz; @@ -496,9 +482,9 @@ static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, return (abi_ulong*)(iwmmxtframe + 1); } -static int do_sigframe_return_v2(CPUARMState *env, - target_ulong context_addr, - struct target_ucontext_v2 *uc) +static int do_sigframe_return(CPUARMState *env, + target_ulong context_addr, + struct target_ucontext *uc) { sigset_t host_set; abi_ulong *regspace; @@ -506,19 +492,20 @@ static int do_sigframe_return_v2(CPUARMState *env, target_to_host_sigset(&host_set, &uc->tuc_sigmask); set_sigmask(&host_set); - if (restore_sigcontext(env, &uc->tuc_mcontext)) + if (restore_sigcontext(env, &uc->tuc_mcontext)) { return 1; + } /* Restore coprocessor signal frame */ regspace = uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace = restore_sigframe_v2_vfp(env, regspace); + regspace = restore_sigframe_vfp(env, regspace); if (!regspace) { return 1; } } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace = restore_sigframe_v2_iwmmxt(env, regspace); + regspace = restore_sigframe_iwmmxt(env, regspace); if (!regspace) { return 1; } @@ -535,10 +522,10 @@ static int do_sigframe_return_v2(CPUARMState *env, return 0; } -static long do_sigreturn_v2(CPUARMState *env) +long do_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct sigframe_v2 *frame = NULL; + struct sigframe *frame = NULL; /* * Since we stacked the signal on a 64-bit boundary, @@ -555,10 +542,9 @@ static long do_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, - frame_addr - + offsetof(struct sigframe_v2, uc), - &frame->uc)) { + if (do_sigframe_return(env, + frame_addr + offsetof(struct sigframe, uc), + &frame->uc)) { goto badframe; } @@ -571,15 +557,10 @@ badframe: return -TARGET_QEMU_ESIGRETURN; } -long do_sigreturn(CPUARMState *env) -{ - return do_sigreturn_v2(env); -} - -static long do_rt_sigreturn_v2(CPUARMState *env) +long do_rt_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct rt_sigframe_v2 *frame = NULL; + struct rt_sigframe *frame = NULL; /* * Since we stacked the signal on a 64-bit boundary, @@ -596,10 +577,9 @@ static long do_rt_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, - frame_addr - + offsetof(struct rt_sigframe_v2, uc), - &frame->uc)) { + if (do_sigframe_return(env, + frame_addr + offsetof(struct rt_sigframe, uc), + &frame->uc)) { goto badframe; } @@ -611,8 +591,3 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } - -long do_rt_sigreturn(CPUARMState *env) -{ - return do_rt_sigreturn_v2(env); -} From patchwork Mon Oct 4 07:44:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535957 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCTF2wWdz9t0G for ; Mon, 4 Oct 2021 18:46:23 +1100 (AEDT) Received: from localhost ([::1]:38512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIg0-00040M-NI for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:46:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeF-0003xW-Sz for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:31 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:39501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeD-0004jP-PO for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:31 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MIKs0-1mckhS2EGi-00EOBQ; Mon, 04 Oct 2021 09:44:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/26] linux-user/arm: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:00 +0200 Message-Id: <20211004074421.3141222-6-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:BpMV7MYJ3KBTrwRhXxI8g4uWlxW009SvsHQmydTkkL/8Y5Aytzl BLMesy5q86ZatZMKlmVV/QsiBCIGwW7hNcHsBCXYZcZIPIQHR1iTL7ijyFRjsbXq1B457mU C3OvNKcpA4/co9wFVWeAmb+q4hN7ZeViG6K5RiRtUX51NPLcnQdvUvsWcSyhRqVe4CqDEtG Xn3ZY1e1Bz6Zu90jQsxuw== X-UI-Out-Filterresults: notjunk:1;V03:K0:Yt/O+VDPuPs=:6c1PjHiI5yxwafdn8LEQCM GxUlxSfLTYR+L8DZ7gpJh7rgvt3e9+wTH2nwHEIAL87Kzlb89lMMbK4400iZwjQr3bF/fAhFC HEIWfWLjI5t8OZ7RUT7GhbXxfhodfSVtH7RSc0/HumAHdTNlTKY+3v94l53xgiLolkIqSyo5W DyyIOK7tYpWzYUV1x4K5Uve3XDE5QGiYW/UOdYrJX0yC92kAO22rzTTeptL+qNz5siYyJPR4y ZRvjeBx7MMn6d9V+OCxC0oDrUMVyaiTfn8s3byGtDnPlaF4ZOKt1ZS6USvdkQ9Sc8mYR8seWN T52hfQyIlW7P89WXBTVqMre4k9HxfOVImBmcJAkHNJQzuiBgECDj/Y9XTSduHbhMyqeOZ3lEv 0aLZUzbYfinTm3vT6dhVyiX/5Bd3wZOGx773YRdKAL5YkNr9Pi3L1MprxxgkcuN5U43tn2Hie WR3/y1GSeG5NJVH1aGM6SIjttQ7eDV3oWwGw3LsRF3s3QgXAEIv11I0S5isSt6hw/pd5Yuq/W RjQUUM4LF4a3RQ8uYQMAvMP/2zd/uiKifz2OAGtoP18UGbhOORhwdQdGhMcRizqL05X5mumDn wBin6yrSDHNLG94VcyNBhY/Z1BjQzZ7yG5znsbtLbT92BuduyxsB0DFf5Vu3mMEGGUnKLfe05 rlLtlJqTho0meEjU/kLWuoZIzjUK+tcVaUtYIXc4Ds7cZ92oSJOAGMeCPtftdlVgl9UJm1nUN hhxJSs16EfByM5aK8+9++bzW2TD55PAFonENMg== Received-SPF: none client-ip=212.227.126.135; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Richard Henderson Mirror what the kernel does in arch/arm/kernel/signal.h, using the old sigframe struct in the rt sigframe struct. Update the trampoline code to match the kernel: this uses sp-relative accesses rather than pc-relative. Copy the code into frame->retcode from the trampoline page. This minimises the different cases wrt arm vs thumb vs fdpic. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-Id: <20210929130553.121567-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/signal.c | 179 ++++++++++++++++++++------------- linux-user/arm/target_signal.h | 2 + 2 files changed, 110 insertions(+), 71 deletions(-) diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed7d1d80bb9c..df9f8e8eb200 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -99,43 +99,21 @@ struct sigframe struct rt_sigframe { struct target_siginfo info; - struct target_ucontext uc; - abi_ulong retcode[4]; + struct sigframe sig; }; -/* - * For ARM syscalls, we encode the syscall number into the instruction. - */ -#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE)) -#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE)) - -/* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ -#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigreturn)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn)) - -static const abi_ulong retcodes[4] = { - SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN -}; +static abi_ptr sigreturn_fdpic_tramp; /* - * Stub needed to make sure the FD register (r9) contains the right - * value. + * Up to 3 words of 'retcode' in the sigframe are code, + * with retcode[3] being used by fdpic for the function descriptor. + * This code is not actually executed, but is retained for ABI compat. + * + * We will create a table of 8 retcode variants in the sigtramp page. + * Let each table entry use 3 words. */ -static const unsigned long sigreturn_fdpic_codes[3] = { - 0xe59fc004, /* ldr r12, [pc, #4] to read function descriptor */ - 0xe59c9004, /* ldr r9, [r12, #4] to setup GOT */ - 0xe59cf000 /* ldr pc, [r12] to jump into restorer */ -}; - -static const unsigned long sigreturn_fdpic_thumb_codes[3] = { - 0xc008f8df, /* ldr r12, [pc, #8] to read function descriptor */ - 0x9004f8dc, /* ldr r9, [r12, #4] to setup GOT */ - 0xf000f8dc /* ldr pc, [r12] to jump into restorer */ -}; +#define RETCODE_WORDS 3 +#define RETCODE_BYTES (RETCODE_WORDS * 4) static inline int valid_user_regs(CPUARMState *regs) { @@ -183,15 +161,15 @@ get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize) } static int -setup_return(CPUARMState *env, struct target_sigaction *ka, - abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr) +setup_return(CPUARMState *env, struct target_sigaction *ka, int usig, + struct sigframe *frame, abi_ulong sp_addr) { abi_ulong handler = 0; abi_ulong handler_fdpic_GOT = 0; abi_ulong retcode; - - int thumb; + int thumb, retcode_idx; int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info); + bool copy_retcode; if (is_fdpic) { /* In FDPIC mode, ka->_sa_handler points to a function @@ -208,6 +186,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, } thumb = handler & 1; + retcode_idx = thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0); uint32_t cpsr = cpsr_read(env); @@ -225,44 +204,29 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { if (is_fdpic) { - /* For FDPIC we ensure that the restorer is called with a - * correct r9 value. For that we need to write code on - * the stack that sets r9 and jumps back to restorer - * value. - */ - if (thumb) { - __put_user(sigreturn_fdpic_thumb_codes[0], rc); - __put_user(sigreturn_fdpic_thumb_codes[1], rc + 1); - __put_user(sigreturn_fdpic_thumb_codes[2], rc + 2); - __put_user((abi_ulong)ka->sa_restorer, rc + 3); - } else { - __put_user(sigreturn_fdpic_codes[0], rc); - __put_user(sigreturn_fdpic_codes[1], rc + 1); - __put_user(sigreturn_fdpic_codes[2], rc + 2); - __put_user((abi_ulong)ka->sa_restorer, rc + 3); - } - - retcode = rc_addr + thumb; + __put_user((abi_ulong)ka->sa_restorer, &frame->retcode[3]); + retcode = (sigreturn_fdpic_tramp + + retcode_idx * RETCODE_BYTES + thumb); + copy_retcode = true; } else { retcode = ka->sa_restorer; + copy_retcode = false; } } else { - unsigned int idx = thumb; - - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx += 2; - } - - __put_user(retcodes[idx], rc); + retcode = default_sigreturn + retcode_idx * RETCODE_BYTES + thumb; + copy_retcode = true; + } - retcode = rc_addr + thumb; + /* Copy the code to the stack slot for ABI compatibility. */ + if (copy_retcode) { + memcpy(frame->retcode, g2h_untagged(retcode & ~1), RETCODE_BYTES); } env->regs[0] = usig; if (is_fdpic) { env->regs[9] = handler_fdpic_GOT; } - env->regs[13] = frame_addr; + env->regs[13] = sp_addr; env->regs[14] = retcode; env->regs[15] = handler & (thumb ? ~1 : ~3); cpsr_write(env, cpsr, CPSR_IT | CPSR_T | CPSR_E, CPSRWriteByInstr); @@ -351,8 +315,7 @@ void setup_frame(int usig, struct target_sigaction *ka, setup_sigframe(&frame->uc, set, regs); - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe, retcode))) { + if (setup_return(regs, ka, usig, frame, frame_addr)) { goto sigsegv; } @@ -377,13 +340,12 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, } info_addr = frame_addr + offsetof(struct rt_sigframe, info); - uc_addr = frame_addr + offsetof(struct rt_sigframe, uc); + uc_addr = frame_addr + offsetof(struct rt_sigframe, sig.uc); tswap_siginfo(&frame->info, info); - setup_sigframe(&frame->uc, set, env); + setup_sigframe(&frame->sig.uc, set, env); - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe, retcode))) { + if (setup_return(env, ka, usig, &frame->sig, frame_addr)) { goto sigsegv; } @@ -578,8 +540,8 @@ long do_rt_sigreturn(CPUARMState *env) } if (do_sigframe_return(env, - frame_addr + offsetof(struct rt_sigframe, uc), - &frame->uc)) { + frame_addr + offsetof(struct rt_sigframe, sig.uc), + &frame->sig.uc)) { goto badframe; } @@ -591,3 +553,78 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +/* + * EABI syscalls pass the number via r7. + * Note that the kernel still adds the OABI syscall number to the trap, + * presumably for backward ABI compatibility with unwinders. + */ +#define ARM_MOV_R7_IMM(X) (0xe3a07000 | (X)) +#define ARM_SWI_SYS(X) (0xef000000 | (X) | ARM_SYSCALL_BASE) + +#define THUMB_MOVS_R7_IMM(X) (0x2700 | (X)) +#define THUMB_SWI_SYS 0xdf00 + +static void write_arm_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(ARM_MOV_R7_IMM(syscall), rc); + __put_user(ARM_SWI_SYS(syscall), rc + 1); + /* Wrote 8 of 12 bytes */ +} + +static void write_thm_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(THUMB_SWI_SYS << 16 | THUMB_MOVS_R7_IMM(syscall), rc); + /* Wrote 4 of 12 bytes */ +} + +/* + * Stub needed to make sure the FD register (r9) contains the right value. + * Use the same instruction sequence as the kernel. + */ +static void write_arm_fdpic_sigreturn(uint32_t *rc, int ofs) +{ + assert(ofs <= 0xfff); + __put_user(0xe59d3000 | ofs, rc + 0); /* ldr r3, [sp, #ofs] */ + __put_user(0xe8930908, rc + 1); /* ldm r3, { r3, r9 } */ + __put_user(0xe12fff13, rc + 2); /* bx r3 */ + /* Wrote 12 of 12 bytes */ +} + +static void write_thm_fdpic_sigreturn(void *vrc, int ofs) +{ + uint16_t *rc = vrc; + + assert((ofs & ~0x3fc) == 0); + __put_user(0x9b00 | (ofs >> 2), rc + 0); /* ldr r3, [sp, #ofs] */ + __put_user(0xcb0c, rc + 1); /* ldm r3, { r2, r3 } */ + __put_user(0x4699, rc + 2); /* mov r9, r3 */ + __put_user(0x4710, rc + 3); /* bx r2 */ + /* Wrote 8 of 12 bytes */ +} + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t total_size = 8 * RETCODE_BYTES; + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0); + + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + write_arm_sigreturn(&tramp[0 * RETCODE_WORDS], TARGET_NR_sigreturn); + write_thm_sigreturn(&tramp[1 * RETCODE_WORDS], TARGET_NR_sigreturn); + write_arm_sigreturn(&tramp[2 * RETCODE_WORDS], TARGET_NR_rt_sigreturn); + write_thm_sigreturn(&tramp[3 * RETCODE_WORDS], TARGET_NR_rt_sigreturn); + + sigreturn_fdpic_tramp = sigtramp_page + 4 * RETCODE_BYTES; + write_arm_fdpic_sigreturn(tramp + 4 * RETCODE_WORDS, + offsetof(struct sigframe, retcode[3])); + write_thm_fdpic_sigreturn(tramp + 5 * RETCODE_WORDS, + offsetof(struct sigframe, retcode[3])); + write_arm_fdpic_sigreturn(tramp + 6 * RETCODE_WORDS, + offsetof(struct rt_sigframe, sig.retcode[3])); + write_thm_fdpic_sigreturn(tramp + 7 * RETCODE_WORDS, + offsetof(struct rt_sigframe, sig.retcode[3])); + + unlock_user(tramp, sigtramp_page, total_size); +} diff --git a/linux-user/arm/target_signal.h b/linux-user/arm/target_signal.h index 0998dd6dfa75..1e7fb0cecbdd 100644 --- a/linux-user/arm/target_signal.h +++ b/linux-user/arm/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* ARM_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535970 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCld5rrXz9t25 for ; Mon, 4 Oct 2021 18:58:53 +1100 (AEDT) Received: from localhost ([::1]:35700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIs7-000617-GM for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:58:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeP-0004GJ-7Y for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:41 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:36269) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeL-0004qo-HM for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:40 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MAchM-1mdsEF0VVg-00B4nI; Mon, 04 Oct 2021 09:44:27 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/26] linux-user/alpha: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:01 +0200 Message-Id: <20211004074421.3141222-7-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:XVeBUSeOwZnzOlG+IEND3rgkvbLJ6109GbKVXTYia06403FDWPD B+U4UPe4XFgcBQr0kOGVCYG+VciCuNVvFM0TL5CxXHVvXTiq5IXhRDVzsOqGKUhmBrbLIf4 xdpcOCK91V0H+04KeKLal7mCtxUZVwkuMZM4wUJFkxML07hWnQcqb/CzeDpSK+YTqWkbE2q 2UfFgkCfl7gAX1qhAH3sg== X-UI-Out-Filterresults: notjunk:1;V03:K0:FSkllQucq2U=:YUaKR6QqyjVtDtZE+bvL/b oB3eMiVamvxxrHmhMWTmfHuVtdDDdCb/mJMggLToZFaoNrnphe9Gx4ZrMH1T3Gse0rrap0Pl7 pxcD6HGFgrGs2NqRi2FWsI6j98QMA3XnyD9c4sk2foif7YL00vZOmhpokzWwo95nCUvcRvEe/ IuB3PCKwtAIFW+wUFdNHC0W8Sb+EdJL61G9aOO5jkNSBtfwLnTUUUowOhxp4KidTdTtiYp1HL pgtZ4AXSnH5tdfdkoSx9wxEB2fCX5bOqgqXOGy1P/C4UAtETSnC+Ct6X49g/eG9nIrAid8XWE bGydb69DaWQ+nFRuZofkraBFoWmA9wzVkbOy8TT+11uONWcFBduV6CuL/Vgl5H3vEqcmBuyGz KeYmxPoUINwfulRQoPfG15hbYVbN5oYv5fxj/4mKMbPc3h2TOdiSBrLDa8OA2/f7EP7RBUq9+ yV6tyvdMoui6Q6hMPC3r2BRrf29TV/aINEtlCiJdYY8sUEiBVmEGHqw9Ujor0XI3PahyDhNvn rLE60uqGu5ZSD5lNbQpkuy8xsDAm7WG36OpGG6B0ran6zBywlueAgc7xXivI6y/8H9WB3AzGz aC9YLv5xv/i0SLSoL6ueWvBtFzmncv4cFdUw8Bf2SdVgf2Qx8qv4zFzCCu4QgZVWkya+ECzZT SPynbyTYwGbUghfzLnmtVWJVx2byDgjHiB2MmHQcp8iUEyaGwGwfEdmxYg2LxmBP8xgV6clep GvOzTKxIs1IgY/h89xa8EZLlN33mcXnZf2DFgQ== Received-SPF: none client-ip=212.227.126.131; 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: Richard Henderson Create and record the two signal trampolines. Use them when the guest does not use ka_restorer. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-7-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/alpha/signal.c | 34 +++++++++++++++++++------------- linux-user/alpha/target_signal.h | 1 + 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 3a820f616b3f..bbe3dd175a7c 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -55,13 +55,11 @@ struct target_ucontext { struct target_sigframe { struct target_sigcontext sc; - unsigned int retcode[3]; }; struct target_rt_sigframe { target_siginfo_t info; struct target_ucontext uc; - unsigned int retcode[3]; }; #define INSN_MOV_R30_R16 0x47fe0410 @@ -142,12 +140,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb() */ - r26 = frame_addr + offsetof(struct target_sigframe, retcode); + r26 = default_sigreturn; } unlock_user_struct(frame, frame_addr, 1); @@ -196,12 +189,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb(); */ - r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode); + r26 = default_rt_sigreturn; } if (err) { @@ -269,3 +257,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6 * 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(INSN_MOV_R30_R16, &tramp[0]); + __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, &tramp[1]); + __put_user(INSN_CALLSYS, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 3 * 4; + __put_user(INSN_MOV_R30_R16, &tramp[3]); + __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, &tramp[4]); + __put_user(INSN_CALLSYS, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 6 * 4); +} diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index 250642913e2a..0b6a39de6576 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -93,6 +93,7 @@ typedef struct target_sigaltstack { #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_KA_RESTORER +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ From patchwork Mon Oct 4 07:44:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535973 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCry1FWXz9t25 for ; Mon, 4 Oct 2021 19:03:30 +1100 (AEDT) Received: from localhost ([::1]:43944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIwZ-0003Wy-UK for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:03:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeR-0004Jr-Qn for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:43 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:41309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeM-0004sE-PP for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:42 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MavF5-1n3tdg2jG7-00cTRz; Mon, 04 Oct 2021 09:44:27 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/26] linux-user/cris: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:02 +0200 Message-Id: <20211004074421.3141222-8-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:AYWD5ubbTywWVnEnEWbtAJt1YIMMn+hzNn3Ydo/W2UVOb8idEB9 ayB7BHmXbQWD70dHNpm35qft9JW2b12zmCY3fdaSq6WO7W/0RX6OcfnuvZC7BeMf7JixdiH rxPYtzW0Gr3irH4cxH/06oX3KAhXMgI0g5GQHXDpgxpZvkkJq8SnzYxgBhumaaTG7+qkZb4 DX3hb7GAfF1HOu6a8llxw== X-UI-Out-Filterresults: notjunk:1;V03:K0:SdfmUmY/5fs=:Ww+QdfCfSRkwIHVoo3BXxG 8bRnbhBGg+pA1SQ9235wRIHafgrtToj82uL/bTPJHsrGfOzSikl12zyBbJCmZ6O9kWeEmgbED HDSV9mmoeaUJSA5IB+nvk1HphQkyYMwPcdGFLe8QeTBh5t+0YdjF6rVsP30lB+f22G0R/JU6W gMcHSed2lhzivuPFcjIWHTwfltzyAak/gZEldOjA9bV0wUYv8JXPymWC1obHOLNeaul+7fhdn dIuMq2WN94jwsA1bBU/VyrGpsJVC5WPktgZ1JKl5jaJstAPkS8fi2DVtc2Ldrr9Lj8sNf7rcS gf4hy7aaZsUSBJQAb3qyrdMnfdt3dK1G8si3PYXHwFkaA8XJkGXbi/p4Le5q9qjupybmFTUL8 9ErtXjxJXTYRRHNlJjZLD62i75zAi/epwVDdW50nKPxDPWvHKf0Vk/43IHOTgKUEULywUY/E4 g8k4+AsybKBW6dxChHqFX3POJCPZj3Iqs3pr7DiYg5TUOfwpMUihidPaAkYH+EiHumY4LjfvF aAp3T3gLqdVPVMHRXRlL0KvG86TdXG42inQNMy7M094xWE7iIKHcfVK9FTwnt4DuLzBdORcn+ WCGQZWFeNSAQUA0Alr92Vuwjntr86d97jGJIMuPRvBibefJrQSKSF3NHHtOTjyX+oyoK+Qntn YFxx2vNGDccoPUmyf0qLmZ0BkmWCnOxe2L/NPN9G/ZPZaBp3IhE+4Szoe8XuNWRppiOjIPENb zrfTA2sghjAZB7yinFyvZ2b3q1MQ2dVu6DD03Q== Received-SPF: none client-ip=212.227.126.131; 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: "Edgar E . Iglesias" , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Split out setup_sigreturn so that we can continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/cris/signal.c | 29 +++++++++++++++++++++-------- linux-user/cris/target_signal.h | 2 ++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c index 2c39bdf7277f..7f6aca934e10 100644 --- a/linux-user/cris/signal.c +++ b/linux-user/cris/signal.c @@ -97,6 +97,14 @@ static abi_ulong get_sigframe(CPUCRISState *env, int framesize) return sp - framesize; } +static void setup_sigreturn(uint16_t *retcode) +{ + /* This is movu.w __NR_sigreturn, r9; break 13; */ + __put_user(0x9c5f, retcode + 0); + __put_user(TARGET_NR_sigreturn, retcode + 1); + __put_user(0xe93d, retcode + 2); +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUCRISState *env) { @@ -112,14 +120,8 @@ void setup_frame(int sig, struct target_sigaction *ka, /* * The CRIS signal return trampoline. A real linux/CRIS kernel doesn't * use this trampoline anymore but it sets it up for GDB. - * In QEMU, using the trampoline simplifies things a bit so we use it. - * - * This is movu.w __NR_sigreturn, r9; break 13; */ - __put_user(0x9c5f, frame->retcode+0); - __put_user(TARGET_NR_sigreturn, - frame->retcode + 1); - __put_user(0xe93d, frame->retcode + 2); + setup_sigreturn(frame->retcode); /* Save the mask. */ __put_user(set->sig[0], &frame->sc.oldmask); @@ -135,7 +137,7 @@ void setup_frame(int sig, struct target_sigaction *ka, env->regs[10] = sig; env->pc = (unsigned long) ka->_sa_handler; /* Link SRP so the guest returns through the trampoline. */ - env->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode); + env->pregs[PR_SRP] = default_sigreturn; unlock_user_struct(frame, frame_addr, 1); return; @@ -187,3 +189,14 @@ long do_rt_sigreturn(CPUCRISState *env) qemu_log_mask(LOG_UNIMP, "do_rt_sigreturn: not implemented\n"); return -TARGET_ENOSYS; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + setup_sigreturn(tramp); + + unlock_user(tramp, sigtramp_page, 6); +} diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signal.h index 495a14289681..83a515550745 100644 --- a/linux-user/cris/target_signal.h +++ b/linux-user/cris/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* CRIS_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535981 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNDDV5Q1yz9t25 for ; Mon, 4 Oct 2021 19:20:26 +1100 (AEDT) Received: from localhost ([::1]:46290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJCw-0007oa-AG for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:20:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIed-0004Qq-0x for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:56 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:51971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeX-000520-Sx for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:52 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MiuGK-1n32xU10lw-00exUa; Mon, 04 Oct 2021 09:44:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/26] linux-user/hexagon: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:03 +0200 Message-Id: <20211004074421.3141222-9-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:LoLYmLm85yRnkWD0guv+MYG5Mcs+tcLyixwGFhU7m6rwv2S8ZMN 0Ax2KYBH5XlCMsvEqFoGxka0AfraBjIJj212vX1QqC4NxC+bcDviT12QeO/1S4o5NT0BpUA /qC6LtbCDaYhFpgKnh8DkoHzx7A4jn+gr3zGGlgGZHqoeTSpgSLRk2BiiPvodJ6KchvRnzx am8bFvFuFZnNH3ial25Uw== X-UI-Out-Filterresults: notjunk:1;V03:K0:LKZZj7ZF/a8=:3fQoV7qT7bdH0SF+Pm9AzP v2qAa8+dq+fSIdm4PvKna/1d65B6cQJvf2+Tcg/UaY+u7x0aiXD7XP7LXf3wrPUGqboJSFDau 1a7sOnl9YOiWhaxz0XwYxRunyei/FVz0z3S6Rg7jdb6+n9LtAIRke8qaXsl0w6FGY+AzOAQwP aGT1PeOXENTWmRygf4dqZbr9J0Fev9MEW4TBP2Dct2T9rKc4Ospc4xcHrp6iPH5//3+6c/2TI mCbzwm4HUKPL4cJLBL1/0xXOIJKbuXQnazRGZyMuzPgdXfCoLUVGLjq++/zo2wiSdb4RCdz8K TJYwe1xMOURPrhRFcygcgwhPyiphY7X5zkz8B5N7ue7Bczw9gdS6M+ml8Cbt7D64FBniN87sz MuGEKnc1lSRPTlUjIn2vVVpcHjR3N8yjJO81bba2MeqzQFpASFvxUN2tKm764o0RpD3RUGICg L4rjwUMrsKJ2j/zuGXTfI3fLYGKVbm/VCur20d6t2p5RlCIg4pXt1dbcYE+csNDD59smsLjZY BlOiomyMEuoG767IW6fP0UdqJCCOabhBIoqpZqvzzEBt/dvWXdP4B0m8fGM9m+X3sv4Psu0J6 wt1758RrX3N+hHZaezmERXQfli2FxSnDElyNofg5pBOP0Ea81QVK7r/ltoJFQ69q2TfgRrBQS W1GE6XP72+g5yKIXEh+I+/HP4DP0F2+/TVYTnTqzW7EUGxMn0uhwgeV610iyORljRLx27AOMy cblmdt59zekE7qDqcw2LIaXHNgEIDj6DVM/UHQ== Received-SPF: none client-ip=212.227.126.130; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Taylor Simpson , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Reviewed-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-9-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/hexagon/signal.c | 19 +++++++++++++++++-- linux-user/hexagon/target_signal.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index c7f0bf6b9283..74e61739a0ab 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -162,6 +162,11 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); + /* + * The on-stack signal trampoline is no longer executed; + * however, the libgcc signal frame unwinding code checks + * for the presence of these two numeric magic values. + */ install_sigtramp(frame->tramp); env->gpr[HEX_REG_PC] = ka->_sa_handler; @@ -171,8 +176,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[HEX_REG_R02] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[HEX_REG_LR] = - frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[HEX_REG_LR] = default_rt_sigreturn; return; @@ -271,3 +275,14 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 * 2, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + unlock_user(tramp, sigtramp_page, 4 * 2); +} diff --git a/linux-user/hexagon/target_signal.h b/linux-user/hexagon/target_signal.h index 345cf1cbb843..9e0223d32225 100644 --- a/linux-user/hexagon/target_signal.h +++ b/linux-user/hexagon/target_signal.h @@ -31,4 +31,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535975 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HND043Zj4z9t25 for ; Mon, 4 Oct 2021 19:09:38 +1100 (AEDT) Received: from localhost ([::1]:52268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ2V-0000vk-9k for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeP-0004IL-RR for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:43 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:54897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeM-0004sB-JK for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:41 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N6bHC-1mrXgw3HSA-0180yc; Mon, 04 Oct 2021 09:44:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/26] linux-user/hppa: Document non-use of setup_sigtramp Date: Mon, 4 Oct 2021 09:44:04 +0200 Message-Id: <20211004074421.3141222-10-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:H7hPEbc0/IcgVY0a7EXKCSa4CVlDmHMyMLX+19lYPv7g9ym74Wi O0w1/Ps/0N2WBAEFYTHQ8JEMODn42EcSL8alOtI15kY70k9/i3Zp6GqbhGTBtcotI0cfyFW pKlQ7cWrS2B8T/MIXcpbSbq2f0S6e7622MFpPHqY5qpaERZ4IKZIJyVO3yPyT0abBrJTZ/N HBTmADS+01QtCZn1llATA== X-UI-Out-Filterresults: notjunk:1;V03:K0:AEUs1Usz8F8=:sLi2/Qidxzbztmn4VwzvqR Mz/nIFl9fruobZ5UBmoabsUQZJis8qZs4NXIKtdC5cDm0hWyuMaOTldK2ywhsQzTtMRS6NOfk qwsDzKw36lwL1I7xUON7IDsIxCY1UEAJT3Z7yzEHN99lv4cJ+oY0DMS6i1d9vHW/ozmAjfqN5 dHFIvqNEYphXE6yEg93gGpAt9JFSdWLnqHRlYg6gM58lrR2jojZt0cYBhUohu6w/OjVE2A9TU 6qK1IbfU6yW6yf86oJP8W4CtsNGVQfpXC4xSsJ1e7J0iktmBKTlrFvt+yToVwVyszjBWd5gcv vRHLATzGBho6vEK54253P8pRFE1ScXjpZQAoYlD7e9TIZyC0gv8ZZCjmPBhozfr96I5AC/X3M Hg0CDIqo9Kx85aidtbHACNEWWDp1BQCivceuu3ESRvzdbMPSHZNEHNbnlHszp+MoACkTU4ZFD G+IXSQzC17/GmMfagq45KhKNo9cbSrs5zCgJKdgY8JQizEKX+k6vwejsPa52kiFSzhjOBA/E4 ozsbyaBdbcCP5oCBao8zwyKn1M1iM7WxJvQ94oDRXHQaePv327WFZCHSZ2TN5VsBAc4qIwHSC 6m+vmd5ijoJ10HEhV27PAUhGHMme5vbe/ie46m/xfeqQ2cY2YnjhP5xdzVD2bxgpFpcmnVRjf Xv4WpAyPuLKHS3vk+ryGVgxCdRqh8dGsOIuGQ46A2L9dY6iUksUkCoZyqG9Om1hijtDehEH+5 huve1FMkmsf/XzwuoUJMjIX+TRYGzqVrE2LcKA== Received-SPF: none client-ip=212.227.126.134; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We cannot use a raw sigtramp page for hppa, but must wait for full vdso support. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-10-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/hppa/target_signal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.h index 7f525362e91a..d558119ee7bd 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -71,4 +71,18 @@ typedef struct target_sigaltstack { /* mask for all SS_xxx flags */ #define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM +/* + * We cannot use a bare sigtramp page for hppa-linux. + * + * Unlike other guests where we use the instructions at PC to validate + * an offset from SP, the hppa libgcc signal frame fallback unwinding uses + * the PC address itself to find the frame. This is due to the fact that + * the hppa grows the stack upward, and the frame is of unknown size. + * + * TODO: We should be able to use a VDSO to address this, by providing + * proper unwind info for the sigtramp code, at which point the fallback + * unwinder will not be used. + */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* HPPA_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535974 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCy114dFz9t25 for ; Mon, 4 Oct 2021 19:07:53 +1100 (AEDT) Received: from localhost ([::1]:49092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ0o-00073J-TI for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeR-0004Jq-R0 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:43 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:33885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeM-0004sk-Vv for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:43 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mr7iw-1nBGR918Ew-00oHAM; Mon, 04 Oct 2021 09:44:29 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/26] linux-user/i386: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:05 +0200 Message-Id: <20211004074421.3141222-11-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:3Hn4Y6DOOZamlkovEm0vKdk0tNNiCY9r1+xDPG3nJLDaigqX7Ff QO/v0C8VWCCVNkbIzzAyxWCsm5xCNS5Qgx6a+0orfP24gPMrVV+9m+osgn/TCM3xT8HElBR OtjX+VqbuOK5LcVfo6OQZKUsgGxoj14blTiYFHKTJoZ8CqcjU4A2OOiojuEsyEMBdkGF5iX HtRSCRyT6KX3nNBqS/aqg== X-UI-Out-Filterresults: notjunk:1;V03:K0:KEL9EdmPuG4=:KAo/KQ3jH3oCeu4yqmwnND fxFE6X2insTNGQCwgfpArycwCnCq+KYVMXC5jgmkSIDKTrXIe85bhwE0QeVgWkY9S4oLJV47P F6bemA9KEhB7GcB76mrDvFuufA2PrdbrMIbdwX1kmL6r7jjoO/5V4t1l4mOLQw6Y0pXpAncsv SQp6rmVDKJal3tYEhjP0QBmjsDCtCevvabei/UR9t7TqVJ4ghd7ESCceO80BdyupCa2Dm/gvz 8/oHU4iQgIv6RxFm8wGSr7/3jOG+mE5DmZT7WMGprvefalMOzZv4Wn/Kxc0CkvVoSAV53cj/w k6Qdv6DRlD5d0VHADKYKIITq24KnQZNc4Vbt6yFHVvKgWhZG/VtlDYbzg/ZIveNWwpPWFmYSG N4S2xTzortYwYhPHLcAQq2wHDggQGEM5CIzgs0oVypw5wfpSJbIjFNqcw8DF0r0BNWja7HHr/ h/OS0F/4OwI12vwKtXKKavc+y91BFWBrA79Y6AOAIoBFQgvEDB1V8nJEZqftoGTEYXoUiccP0 I0PL0w9xuzfZS93ZmXR/59ggVWINofaZD1ArsxvQknyijyBKyF5rIxkLJDa9wLIBtR6llzqqe wPfuPWgPqDPqu5vaH+ObVzemojRyBKDQFrzMOu3YUaat9e70yT29xP1N2ulumqfIr+EvLG7Xe SnB9Y5hTuoFVvd4iuSA/TDYKN/iia2cbKlJLlsX/2N1EZBBnetPmq9fG70c3YnAIk1/CDpj30 GeG3wR0yx1bCaEfCMkzTqtaOmGCML7XDJdgxHA== Received-SPF: none client-ip=212.227.126.131; 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: Richard Henderson Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Note that x86_64 does not use this code. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-11-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/i386/signal.c | 56 +++++++++++++++++++++---------- linux-user/i386/target_signal.h | 2 ++ linux-user/x86_64/target_signal.h | 3 ++ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 3b4b55fc0a24..b38b5f108eaf 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -310,6 +310,22 @@ get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_size) } #ifndef TARGET_X86_64 +static void install_sigtramp(void *tramp) +{ + /* This is popl %eax ; movl $syscall,%eax ; int $0x80 */ + __put_user(0xb858, (uint16_t *)(tramp + 0)); + __put_user(TARGET_NR_sigreturn, (int32_t *)(tramp + 2)); + __put_user(0x80cd, (uint16_t *)(tramp + 6)); +} + +static void install_rt_sigtramp(void *tramp) +{ + /* This is movl $syscall,%eax ; int $0x80 */ + __put_user(0xb8, (uint8_t *)(tramp + 0)); + __put_user(TARGET_NR_rt_sigreturn, (int32_t *)(tramp + 1)); + __put_user(0x80cd, (uint16_t *)(tramp + 5)); +} + /* compare linux/arch/i386/kernel/signal.c:setup_frame() */ void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUX86State *env) @@ -338,16 +354,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { - uint16_t val16; - abi_ulong retcode_addr; - retcode_addr = frame_addr + offsetof(struct sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - /* This is popl %eax ; movl $,%eax ; int $0x80 */ - val16 = 0xb858; - __put_user(val16, (uint16_t *)(frame->retcode+0)); - __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+6)); + /* This is no longer used, but is retained for ABI compatibility. */ + install_sigtramp(frame->retcode); + __put_user(default_sigreturn, &frame->pretcode); } /* Set up registers for signal handler */ @@ -416,14 +425,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { - uint16_t val16; - addr = frame_addr + offsetof(struct rt_sigframe, retcode); - __put_user(addr, &frame->pretcode); - /* This is movl $,%eax ; int $0x80 */ - __put_user(0xb8, (char *)(frame->retcode+0)); - __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+5)); + /* This is no longer used, but is retained for ABI compatibility. */ + install_rt_sigtramp(frame->retcode); + __put_user(default_rt_sigreturn, &frame->pretcode); } #else /* XXX: Would be slightly better to return -EFAULT here if test fails @@ -592,3 +596,19 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +#ifndef TARGET_X86_64 +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + default_rt_sigreturn = sigtramp_page + 8; + install_rt_sigtramp(tramp + 8); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signal.h index 50361af8746e..64d09f2e75bd 100644 --- a/linux-user/i386/target_signal.h +++ b/linux-user/i386/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* I386_TARGET_SIGNAL_H */ diff --git a/linux-user/x86_64/target_signal.h b/linux-user/x86_64/target_signal.h index 4ea74f20dd42..4673c5a88691 100644 --- a/linux-user/x86_64/target_signal.h +++ b/linux-user/x86_64/target_signal.h @@ -21,4 +21,7 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +/* For x86_64, use of SA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* X86_64_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535965 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCg457vpz9t0G for ; Mon, 4 Oct 2021 18:54:56 +1100 (AEDT) Received: from localhost ([::1]:54514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIoI-0007JQ-HB for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:54:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeJ-000422-H2 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:35 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:34195) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeG-0004lt-01 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:33 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N3omW-1mxauL3WlM-00zjVI; Mon, 04 Oct 2021 09:44:29 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/26] linux-user/x86_64: Raise SIGSEGV if SA_RESTORER not set Date: Mon, 4 Oct 2021 09:44:06 +0200 Message-Id: <20211004074421.3141222-12-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:+mQEQfC0509EGqg/4LAdEazqc+ZehDxXmp1nPzsudUqmL4bkkOB pqjUi7IBvfyNi3OjHcIzMMqAIM4qVtQwvRVKRLh/ZrY7XWeK5J+2tMyxNJkRjQd8R0aM9i4 wXU3jeHreFia/t59MFS4Ml14S4bU0I1CjJs1TzX20cbuOzLytMRkYmNtb0VgSgL9U42REZv CppibBYnTaUzdZCuB6vhQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:r2e8AkzkGss=:1W7KQWCGhFyeaMZ1eGzZUu wpvxRcqq+K1m04Ki1UGnZuBZzbTFjlSF5WcmUon/VEiIZVaEfjKn3WftjO6EalQTWmceRn+KW Ko8lz9krYpuMPgsoqHIQsklbgLkh757lHlEr/0DFsWaaNnxeY2QXVpM79uZIijkfxPVAH6inT rc/39qdeRIbYEz7OAxB9KkAUg1gQksbvOk8eNq72dH9zQVXBl6WnkPoJqSXVYh6KWVhGnGiyE 8SG1JFpasGJ0lBzF68teJTSD/8fuQidXpUjvWftXjlnRdTCT/0xIyHHzjB3x/VCzfZXreRdmd PFkR6TTCncUzMVf9paSRU+Ng43R8Mm0zS3V8aV4tTBtsjVYj41PJE4Lt0E5hW/vWbl+CJXHj3 2ElVg8sVXIdH0KXUKlW1zrDp3aTRGH8qvVhIlndmm0oZZIcvO0459mfKhNyRcVi8e74Zi1iCt qs9RpOx9xWs/vEuErhkGnaz80WePPYoefLouujOKohOOyUZHZRI1ogBUpTB+d5+WILTI+sCF4 r8dk0ihoGpJDlNNxXrR8LqcQNzRoWAze6tXe+h7EKNBnyj0DFh/q4UVp5jV76osQnYzlORHRN XssW82T52jUbr1LpvdnO81DsWGFTKe/0Zc40sep7zxxTBNNMujc21WQ7CY1N8diGHvyxy8Cnq 7KVVxqDdMw5GioN8oal0jXuXqCri/29fOwocZbQb5Cm2nPd9C1uK89iAjyvXm0Xy6i9wYaBJn GRIJEn0FnRr+HDXy8YbW3+p2Oj86+OwVBXvGuA== Received-SPF: none client-ip=212.227.126.131; 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: Richard Henderson This has been a fixme for some time. The effect of returning -EFAULT from the kernel code is to raise SIGSEGV. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-12-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/i386/signal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index b38b5f108eaf..433efa3d693b 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -421,19 +421,18 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ -#ifndef TARGET_X86_64 if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { +#ifdef TARGET_X86_64 + /* For x86_64, SA_RESTORER is required ABI. */ + goto give_sigsegv; +#else /* This is no longer used, but is retained for ABI compatibility. */ install_rt_sigtramp(frame->retcode); __put_user(default_rt_sigreturn, &frame->pretcode); - } -#else - /* XXX: Would be slightly better to return -EFAULT here if test fails - assert(ka->sa_flags & TARGET_SA_RESTORER); */ - __put_user(ka->sa_restorer, &frame->pretcode); #endif + } /* Set up registers for signal handler */ env->regs[R_ESP] = frame_addr; From patchwork Mon Oct 4 07:44:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535979 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HND5m2fBFz9t25 for ; Mon, 4 Oct 2021 19:14:36 +1100 (AEDT) Received: from localhost ([::1]:37986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ7K-00020W-57 for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:14:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeZ-0004Pt-BE for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:52 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:34427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeK-0004p4-Jc for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:49 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mi4un-1n2Dc71PXt-00e893; Mon, 04 Oct 2021 09:44:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/26] linux-user/m68k: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:07 +0200 Message-Id: <20211004074421.3141222-13-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:1DgHCBPdYMlNL/Lp4AhHSyXZbDc7LU/FnUP6wCSRdv05/tMNsTB 2bLZBoAY86xD344ehaov7bOYrdzkD+JroQn9aPdzXx7vJU+KfIYuLfVrujBu1bTF/Srv8p5 Ijpw0CaNtFsn5ADEUp32rSE92WNLv37oi1xi8TkgjdaQHTB5GoY6r4MpEaWJKygNbg7x77k g4brSshE2CMWrAAwzt3yw== X-UI-Out-Filterresults: notjunk:1;V03:K0:DlnajSSkPlI=:UDu4WeGaNL1/Nxp26rFBx1 1RFzH35h18kqAhIoWeZIbMzonW7fFjNdlOhSCKMwSi0DPmMfb5dCb855lwxzXQwPXnQg7sQWY aprPUPSLvIOIUKFjXjH4Fz9zz1W2zBqJfIUHkPqtDsYS0F3bYrGV+rdsWDGqeEdKfojC9a6S2 AXkG613+fQavwFd/z+hx06hYesy77fjeZi1Xs6Tg6we2KrIBsqUKYg73yVSBvhyPPaTY/wTbB yDofgwD6KRSJXHVyRVXLf2jbVUHEyiJP2JsHR+eTgzNdTNJUEneih5X6lshlgzQXUlX33FBF/ IQygHvb882I9CHoNV0w6QsuBX7zZtomjuy3GZnFKvLa8BkjyYQV8zsKstGMMtS4Qbf/+LgWW8 EGuvBGVZS/oBB1uXiyr4v94dM+kL/0ZHSH17NoPGDFCxxMX+liMzo1O7Uwzfo9TAM75Vmtzvb 8KZpCfqtBy2dMNQQn+u4Dl8oH8NVHAwGNhhWnzMCyBiBkP8ng3cC9xQPX4OZfGXiJGe2OyOji g7G6paqNg21coVY8Oq1zMReAD/+yzowTBPP35CfrfHg2eQmmz8ZhiVdzZEgoE3UlFMQv2humU j9LcPor9Dr4WuT3QmAlB3oUB5DdIcmw8UKVuc0oAc9+Sh2AXsMfZfVu3wbXT38ah8292mhnxP ymph7U4b3KJhaDOjlPgVTGS6U3+TBgbcmepYgMnC3jtSsswt0LApY8AnqkW0NAYFWQDpmY9OF dPO7WeQZaI5W1rh8mI2mhodz2jQU1T6k0IrRvg== Received-SPF: none client-ip=212.227.126.187; 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, 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: Richard Henderson Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-13-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/m68k/signal.c | 47 +++++++++++++++------------------ linux-user/m68k/target_signal.h | 2 ++ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index 4f8eb6f727e4..ec33482e1403 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -39,7 +39,6 @@ struct target_sigframe int sig; int code; abi_ulong psc; - char retcode[8]; abi_ulong extramask[TARGET_NSIG_WORDS-1]; struct target_sigcontext sc; }; @@ -76,7 +75,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -130,7 +128,6 @@ void setup_frame(int sig, struct target_sigaction *ka, { struct target_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong sc_addr; int i; @@ -152,16 +149,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; trap #0 */ - - __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), - (uint32_t *)(frame->retcode)); - - /* Set up to return from userspace */ + __put_user(default_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -288,7 +276,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err = 0; @@ -325,17 +312,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; notb d0; trap #0 */ - - __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), - (uint32_t *)(frame->retcode + 0)); - __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); - - /* Set up to return from userspace */ + __put_user(default_rt_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -411,3 +388,23 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp); + + default_rt_sigreturn = sigtramp_page + 4; + + /* moveq #,d0; notb d0; trap #0 */ + __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), + (uint32_t *)(tramp + 4)); + __put_user(0x4e40, (uint16_t *)(tramp + 8)); + + unlock_user(tramp, sigtramp_page, 4 + 6); +} diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.h index d096544ef842..94157bf1f48d 100644 --- a/linux-user/m68k/target_signal.h +++ b/linux-user/m68k/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* M68K_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535978 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HND475y4Lz9t25 for ; Mon, 4 Oct 2021 19:13:11 +1100 (AEDT) Received: from localhost ([::1]:60560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ5x-0006dA-JA for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:13:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeT-0004LI-Pk for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:45 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:43651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeO-0004ud-RG for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:44 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MaHOX-1mLUvj3iBp-00WCBR; Mon, 04 Oct 2021 09:44:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/26] linux-user/microblaze: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:08 +0200 Message-Id: <20211004074421.3141222-14-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:4l7eGtcRveYhX4odyEQivFKvdbJIzUWFifdlAqmvuB2neBA0v/d GVU4W/P9LZ29soWEb2EFWa1QwQXqSD9ITVIOUs1b8oQ/hY54BGTcOLqxwf838k0h7gxRaun tNF5kWbi1qzvgJ9GdngQxSLayJY5s56LqOmvR9l4TJtMOKgZ/RnXUsNWrAMrwr2DMzwO372 jRvSMb6CDWdJda9QdffWg== X-UI-Out-Filterresults: notjunk:1;V03:K0:IpcpzYlwy5Y=:6F48JdVxwBB7HPWNs5D4Ki yfcPQH6pukA7IxPTE2ZMYIiOXMDyy+EMkUWgtOlik6bGfbOJdTw2oErCY9qsMRVR1WJ3r8odd fG1+GBF82xkJmYYfaXRBELHIAJy/FX3M6VhF96XRWyVOjnYzoZMRikckmmqbJX1N4OSmjQCEu BQEsnowl1SMU7/MfiWeEOkaUGSOFxincBRFD48zjqvpOA5OFNNCoc71bGbWF3YX3y7ir/UYi3 cZjfOiH/HZ8yGEH/bFdGByYUP4v6h8ZYANZoOkEZ9t6RZiS7gPdcuPW9kuuZut7PLL0Oiodnz Df02qi4NcE8gprF5CPUV2693R4zy+mttBtN6RzPnDXsZokGSV2YIlIxblsLXHTA5weZIE2bbW sC4befQc4WgtA8l695RskwB5uewzlrxLNHSttMp/U2Lzm48kihdfup0ogEeAaMqd7wTSFtfNQ 6OJ6lGwp7PPyqpyalhNd2aJKUUNF9jP9DRePg4dsU5oXl6d2ufJ8buMYXSrT0aLezfkL+fcL/ 7TC3WGGBRaVoli/ieUSdTAbdAgR5C1SxP8ISp2pa4FT5a/Iq3nQ/vsWuXhakFrxo4+GPbMwmP 73EzAnMJqOuB6qCZNqZ/Jx8c0mSjt92Ce1qnFiT37r+9/y1qN2TubOhRculsyYe6ElOERX3fh Fhc3MzbwT/lvIoqLfGDiXyVAAelPKZ1BejR5TwC3cLw+mdEWDXUSijdYS5+IwbMzf/yFckoG7 iEQYsQF24NpHSN7NuiCD9SORZ9dw+meXX80a9A== Received-SPF: none client-ip=212.227.126.131; 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: "Edgar E . Iglesias" , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the rt signal trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-14-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/microblaze/signal.c | 24 +++++++++++++++++------- linux-user/microblaze/target_signal.h | 2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c index b822679d1805..8ebb6a1b7dfe 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -161,17 +161,11 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Kernel does not use SA_RESTORER. */ - /* addi r12, r0, __NR_sigreturn */ - __put_user(0x31800000U | TARGET_NR_rt_sigreturn, frame->tramp + 0); - /* brki r14, 0x8 */ - __put_user(0xb9cc0008U, frame->tramp + 1); - /* * Return from sighandler will jump to the tramp. * Negative 8 offset because return is rtsd r15, 8 */ - env->regs[15] = - frame_addr + offsetof(struct target_rt_sigframe, tramp) - 8; + env->regs[15] = default_rt_sigreturn - 8; /* Set up registers for signal handler */ env->regs[1] = frame_addr; @@ -220,3 +214,19 @@ long do_rt_sigreturn(CPUMBState *env) force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * addi r12, r0, __NR_rt_sigreturn + * brki r14, 0x8 + */ + __put_user(0x31800000U | TARGET_NR_rt_sigreturn, tramp); + __put_user(0xb9cc0008U, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} diff --git a/linux-user/microblaze/target_signal.h b/linux-user/microblaze/target_signal.h index 1c326296de42..e8b510f6b182 100644 --- a/linux-user/microblaze/target_signal.h +++ b/linux-user/microblaze/target_signal.h @@ -21,4 +21,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MICROBLAZE_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535966 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCgW0W2Cz9t0G for ; Mon, 4 Oct 2021 18:55:19 +1100 (AEDT) Received: from localhost ([::1]:55510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIoe-000803-QB for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:55:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeN-0004Bj-JC for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:39 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:36207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeJ-0004om-A6 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:39 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MjPYI-1nCNy11fw2-00kxmE; Mon, 04 Oct 2021 09:44:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 14/26] linux-user/mips: Tidy install_sigtramp Date: Mon, 4 Oct 2021 09:44:09 +0200 Message-Id: <20211004074421.3141222-15-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MF1ClMZWLH7snp9g0k31JJ4nz9sKCHsId4zVvy56P3u910pMbcJ sbH1OBPzVpKMblsZgP8WUVjuogAksbzQfSflwr1YTKtSxHlxwNBGNqdWqGu7nsWIURRjJtL UBmCcIlUm/dphBZRRU+0EeiaXCtw8H7sHTSoS5N9qtfss6XfDf6Dp5cSPRD9W9A/ZADQNdy QfjHfvOfhxKSy97Rii5Zg== X-UI-Out-Filterresults: notjunk:1;V03:K0:sKq/+TSn7VA=:ldsHfOsU17GXWA4gBbTvLG nfDqB73jA/PIFwxKSl0Vwy4nVqIope+m+RoQOe/9WtJegYrurNbVcpm7ix+tWHv3cVih6+3tq UnCEMcra36o78VeQ3+FYf0X7Ay6OFWbK+0ERqM4bDP7qhBbLZSNJV5uYDYLPg5jYBDeq4dfsL 63HIqmOlLUVhyDuWiqwaBd68QYfWctZzh0D3rDOLjNCCKH8KSjjEQKOImK9AJ3g41oMZUgXpW zM160BIW4yz/rXJinxH8Mfs2wZxlduGJ2JqciQ0HxqyJy6ttNB8k5T43gZhbxSreD03mOmDMJ 94gmr8pnGJJCA/j+CUH2CMa0ULDJwr44U8COx6plimSLU3iRLfgaysooNn8GHtkm0GWXdXhDj BCLUOcl5lRQe8Tog/DpTwXcM8XshvVnDXQlq3NVn+H2/Ou4iGFhKV6l6B4pxjmRc2XS941k89 sXWzU9Ch8aqKf1vbfeLXespGCWvdlB+cn/ipdn28HhNO02iyhSt5qZhrgYrq25pdn5qvKFRul JBFgQRiGnAtuYog1Hx1OkGFKOjAsT6Cg7/eSKeZz8IJ9FTaf9nvAHtyacjw0cnF2PHaFSbwZW bY9aIE7LUJOO9k0fJv2/UyaEhaB2eV43Ia071q7VSvjcVhdBoyfNlBe4Ylq6lHy7GqMA4IE83 hK/j0PAsj8nuPn9iHCb8GPlHJylVDQyixUrYFKJZIdk9Z91501FBZ2bjSb2xqbjSVudCgHcSC beYQr/jLJvl70NlZ7OE2g7YabthWFvPBWAm34Q== Received-SPF: none client-ip=212.227.126.134; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Richard Henderson The return value is constant 0, and unused as well -- change to void. Drop inline marker. Change tramp type to uint32_t* for clarity. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-15-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/mips/signal.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index d174b3453cc0..64072779b94a 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -87,10 +87,8 @@ struct target_rt_sigframe { }; /* Install trampoline to jump back from signal handler */ -static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) +static void install_sigtramp(uint32_t *tramp, unsigned int syscall) { - int err = 0; - /* * Set up the return code ... * @@ -100,7 +98,6 @@ static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) __put_user(0x24020000 + syscall, tramp + 0); __put_user(0x0000000c , tramp + 1); - return err; } static inline void setup_sigcontext(CPUMIPSState *regs, From patchwork Mon Oct 4 07:44:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535972 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCrP00Wkz9sX3 for ; Mon, 4 Oct 2021 19:02:59 +1100 (AEDT) Received: from localhost ([::1]:42748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIw4-0002hk-89 for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:02:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeO-0004D0-2y for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:40 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:46337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeK-0004po-LP for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:39 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MkW10-1nDUQb3uKE-00m4Ew; Mon, 04 Oct 2021 09:44:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 15/26] linux-user/mips: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:10 +0200 Message-Id: <20211004074421.3141222-16-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:xvvdkEmr98B5CPc7SE/Er3pcIEah+YIIYdmvPXFXP/b2CE7FMsW YwjgEwjUp1Y3LZNJNuyzXvL5Xz6S9SQVhaXxTE/CCMY4w6JqW64SMsc+JCpTZUlK0KdhF/u C2PoCke7CWpS0uOeiEBuFFL3GRZjeqTxYjlGziUeZi81zn2KX+S6gGzxRldcr3CZF2UpLv+ 2CS41U8Cg+jD/XvQVNZNg== X-UI-Out-Filterresults: notjunk:1;V03:K0:OVEiW1ipNe4=:JsTg7sjQtGGIsHiJrUAAj0 xhX1MJgbBcLy4Rrv+N5gRKvAKf/oNT27gRwvq1hXlQzN965Gnu4dH6eyLFgOIZwKntoi08I9c bb+Y0kFq7x4uKvat6gZFhVJEPVPIGoHZB3R0Ajs+OjhPp3UShj/doloHnkiHWaHcKvjlIHdkD cIknS6WRXOYD9MYsYLi0kxFJMh0f+3tC3oyHIBtnhKUDrnmkNa110B+U/mTglJQ+Ad6uApV5g ImHky8H/1VsjmOkqaujey7WgvaeiqeiB94kNxEXvYtuV1kDjUqIT7zXH55hEiyLfHwCXp7F8t T41IZZO8OeW5+Vt2QXJ8J2Ahr5ljWEfUqELRypJ/bWE69qNaRK/F9NDTD7JCn1HyM61KyLdVH vxU/s5avE/xYdNBxeYytVDaivKjtZ9xTGNQt9+CJGPFo/vII6tzdAKv14tTvdhEvF2u1KNyaO 7KeyIdNvhwVqVent38dMXYZRTfXex34OyEKxkrPEetFgmr58ORTsJMrJrqamET+/ixKDrMU1t 8Bpo/Lx+vH6PB/s3XQWZFL5pIeZHRToddgdTdlJ/5I6ZFa97fubnRhfYBlC1Ph0xLVpXFbWcf w6jgN8ysOofwZOq2L0URiPHhlG8IMTT4HgOqSdlga86y6XLSzernjN8bG9A6IEs7Sj3icxtJb XYqNOJctN5O8JWYog3202Ji1OhYlt76cY8wu18X21j+DOs7Z/sj3kaMCfml6QroURfCyN0DWq eSrkuouRcwsEXtl9agRnNX891okY/TXbLbTA4g== Received-SPF: none client-ip=212.227.126.133; 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Richard Henderson Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-16-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/mips/signal.c | 34 ++++++++++++++++++++++--------- linux-user/mips/target_signal.h | 1 + linux-user/mips64/target_signal.h | 2 ++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 64072779b94a..8f79e405ecb7 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -209,8 +209,6 @@ void setup_frame(int sig, struct target_sigaction * ka, goto give_sigsegv; } - install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); - setup_sigcontext(regs, &frame->sf_sc); for(i = 0; i < TARGET_NSIG_WORDS; i++) { @@ -231,7 +229,7 @@ void setup_frame(int sig, struct target_sigaction * ka, regs->active_tc.gpr[ 5] = 0; regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc); regs->active_tc.gpr[29] = frame_addr; - regs->active_tc.gpr[31] = frame_addr + offsetof(struct sigframe, sf_code); + regs->active_tc.gpr[31] = default_sigreturn; /* The original kernel code sets CP0_EPC to the handler * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ @@ -305,8 +303,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn); - tswap_siginfo(&frame->rs_info, info); __put_user(0, &frame->rs_uc.tuc_flags); @@ -335,11 +331,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->active_tc.gpr[ 6] = frame_addr + offsetof(struct target_rt_sigframe, rs_uc); env->active_tc.gpr[29] = frame_addr; - env->active_tc.gpr[31] = frame_addr - + offsetof(struct target_rt_sigframe, rs_code); - /* The original kernel code sets CP0_EPC to the handler - * since it returns to userland using eret - * we cannot do this here, and we must set PC directly */ + env->active_tc.gpr[31] = default_rt_sigreturn; + + /* + * The original kernel code sets CP0_EPC to the handler + * since it returns to userland using eret + * we cannot do this here, and we must set PC directly + */ env->active_tc.PC = env->active_tc.gpr[25] = ka->_sa_handler; mips_set_hflags_isa_mode_from_pc(env); unlock_user_struct(frame, frame_addr, 1); @@ -379,3 +377,19 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.h index d521765f6b2c..780a4ddf29de 100644 --- a/linux-user/mips/target_signal.h +++ b/linux-user/mips/target_signal.h @@ -73,6 +73,7 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index d857c55e4c6c..275e9b7f9a2a 100644 --- a/linux-user/mips64/target_signal.h +++ b/linux-user/mips64/target_signal.h @@ -76,4 +76,6 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MIPS64_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535964 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCf215dGz9t0G for ; Mon, 4 Oct 2021 18:54:02 +1100 (AEDT) Received: from localhost ([::1]:52744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXInP-000635-Ub for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:53:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeN-0004Ab-47 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:39 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:49391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeK-0004ni-Fw for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:38 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M3mHT-1mX1nf1jcZ-000vlz; Mon, 04 Oct 2021 09:44:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 16/26] linux-user/nios2: Document non-use of setup_sigtramp Date: Mon, 4 Oct 2021 09:44:11 +0200 Message-Id: <20211004074421.3141222-17-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Wm3fA3ayo+Vpo1cXsJOJBEgO6suS+FDD9FUn/Xj0CcNrUldiO2F QBFYfVY0Kg4MdygbpL30bsnY5OHMz7b6XIzUSbbrtRNheWgFbynezpnvIszbApIMOJN7ibB 9fF+I+PxEnqs9JBWQn7yaDENwt+G6e7aQmeujiqTgssMyF5B8XzNJMErM6ZVRJ/hB4zeYON itF2Nmz7eBqX2mjv/YEfQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ioMF1ozEAk0=:luPzz7beYWTJSeGL6rsLt8 uX+gA6wZCC76xQIA18/nt2Asd50Qhe9Wt66c4zVwXUyaCmvW1RYimwko4S3b3IEZIdVQXdzzp oHVjSqvuaEJLB/KKAXZIUGhBSE8NqVsNmp37Duj35za3jdLyTE7KirrdvrTINWGNyohEiuGWO lexyqo3NiTCJr9NqQegvutyYbVx+fgc5mS9sI563/McTJOoBZHTOrmLwSu9Yc9ky0GfDipJx+ bq1zvib0S/gOokKpK182qmyhzRMQLDVwRprGRWxdH+3ZnHtg70ZmAyMvZSWAyEpVqHZeyzXpz 5OZ4E8qBoZtc/tBWnvRw+Uq50RAoWx1sq7eQqOwWrQ4GLQBTbCPSk3WgBd5VUCPWrzM4+Vn8N 5II0sjFuQV6ktQWc9cwzzQ4Wi1HTkMIDrPRCDHDOLCmiCTtovGpH1D3o+9PFD/LFAVQiHTfjq X2R8beXP0QBzpKYg9v8Flp3VIm0gMFMnNKQezHpPhJlryAcfoTApOvro4f79Cl2kTfJm1giOB esrfc5g8YBmU5YBlDdd8Nu7rk9OYrmKwjLp+o2mAdRoJJjyKxcOv7gR6KsHmNWsqbfGwkUL4X xS8s1evy5XyOqIykk/EUUrKdMF6YfecvFKkN8x+Wn/8QD6w+3bT3LTE8tf/RJnTZgm/YG/zkz mRXZIVTqzVWs17CVfOxQFfhT+Bd7W6J8iBktMb908BEnBdUVQDZsLSof0vawvV6Cq9hVOrcBd RI1ijiAltteAH9cCtAkp5qpzdK9J8JRtlk7D8A== Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-17-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/target_signal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/nios2/target_signal.h b/linux-user/nios2/target_signal.h index aebf749f1278..fe266c4c51dc 100644 --- a/linux-user/nios2/target_signal.h +++ b/linux-user/nios2/target_signal.h @@ -19,4 +19,7 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +/* Nios2 uses a fixed address on the kuser page for sigreturn. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* NIOS2_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535963 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCdl4Mvvz9t0G for ; Mon, 4 Oct 2021 18:53:47 +1100 (AEDT) Received: from localhost ([::1]:52118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXInB-0005b6-EF for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:53:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeO-0004Ea-Kx for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:40 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:41607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeL-0004qh-9I for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:40 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M91Tq-1mTRIt0D3e-006AyM; Mon, 04 Oct 2021 09:44:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 17/26] linux-user/openrisc: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:12 +0200 Message-Id: <20211004074421.3141222-18-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:IV0ogjXMl7VEDcZT/Xq0tFT3pt51U8A8BqPvpAiQ6Jx9h3PS5h1 XLWriprsXWrjso6sa7E1yuPK8KauGCY0JnkFSsWLREv763aOs/e45CN7moKn6Lb3BRNZQKG /qPDL87JcHSki281cpfcbHdUZFlNmvkRQ31F0NU8uqsHSuHDFfO6kPtRHMRHzKNkIl/twD0 5PqjJrTUmc3Jny5n/ZskQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:tGuIXfAHjlc=:uXwqV4rdXtHs69vVJLzQXi e7ZxQ+GbwqR9CwKR+i/ULnp+ADgyHvPCJEpJjlgx7zvZmb/4ZBRFSQRpWk40TNxyKbE1LeYb8 i7yNDuD9IvQ2+rvW7wzC0Hg+Kde+MBRuQxaSxlGs3SVEa+VibwNbccBrET7S5TOKULrxl92Fb +rFrHFYlKnOpOcxcUohcuW/zjclhaPMj3Cv931ZIL4BzjVnMp3BssgizpJEpW7lGQJKgSttfu XP+91JNzsJ9vHMCKy8SVSuQrgbmBbPHLhLBc1pgi2lEmeZsUB/gjY3yN+4rDz7XWV7aBieyS1 Rshcy6p9UPnY28HiDH2tMNV7u+e7Sbx4qKzU8EJo+xZDoc1Cb5pfOQ69rrAUdzuGw0pclSCh5 ksJISIL6IPYJafXL6uaABCTMLz/mEhLEkW3uoVEc15DoK5f/swcXfw3F20dsO6Ft1PAB/qt14 Y28qkGMkIcCjjmNp7YW6cB78PvRmGgYM33Vw8MVuix9uyzAAWt7fY/p3ciyU4hs/i5YEAOTq0 Q/JXQgx7APtI73/Fqk4z/b71j1ksFGmX/NOa7JAJ/1n8aGFiFWOtvP2rxDV2l8naQNj40MiYs E/nauKx8TPAt5XecbyzOSWtclX4xD1nnNY5go91x2+WVuc02JE395dDk6RztMcQ4MxeoBB8LI huJF7JgFI8EpycgeNlRYr65D3iNAPim36PSAddpnXYd5KuCeXVNf/l2qNkTdMJ5zS51FUYLp4 FikVE+Vq4wqt0311wxI82xlWPZbDyrSLcXHq3Q== Received-SPF: none client-ip=212.227.126.134; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Stafford Horne , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the rt signal trampoline. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-18-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/openrisc/signal.c | 22 ++++++++++++++-------- linux-user/openrisc/target_signal.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index ca2532bf500f..be8b68784a20 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -38,7 +38,6 @@ typedef struct target_ucontext { typedef struct target_rt_sigframe { struct target_siginfo info; target_ucontext uc; - uint32_t retcode[4]; /* trampoline code */ } target_rt_sigframe; static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *sc) @@ -116,14 +115,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ - __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, frame->retcode + 0); - __put_user(0x20000001, frame->retcode + 1); - __put_user(0x15000000, frame->retcode + 2); - __put_user(0x15000000, frame->retcode + 3); - /* Set up registers for signal handler */ - cpu_set_gpr(env, 9, frame_addr + offsetof(target_rt_sigframe, retcode)); + cpu_set_gpr(env, 9, default_rt_sigreturn); cpu_set_gpr(env, 3, sig); cpu_set_gpr(env, 4, frame_addr + offsetof(target_rt_sigframe, info)); cpu_set_gpr(env, 5, frame_addr + offsetof(target_rt_sigframe, uc)); @@ -169,3 +162,16 @@ long do_rt_sigreturn(CPUOpenRISCState *env) force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1 */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_signal.h index 8283eaf54419..077ec3d5e8d7 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -26,4 +26,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* OPENRISC_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535971 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCqH6VWdz9t54 for ; Mon, 4 Oct 2021 19:02:03 +1100 (AEDT) Received: from localhost ([::1]:40612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIvB-0000yA-HY for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:02:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeP-0004Ia-VY for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:43 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:46667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeL-0004rI-Pu for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:41 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MIyiY-1mD1wZ2Sew-00KOT4; Mon, 04 Oct 2021 09:44:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 18/26] linux-user/ppc: Simplify encode_trampoline Date: Mon, 4 Oct 2021 09:44:13 +0200 Message-Id: <20211004074421.3141222-19-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:deIQL4aMLtFiJv9LRvDOHzDeVuluamEtc++PCU1i7nnpBLCSOwi 2CDVXC/K7ISYCacJElVCoSmUuPqRK0Bit4/Hj3gABM87kqx6BSC1IML2X7ue9H3AZRU4oac m0egFsd1TZXW0lQPH1qcZToXyX1EkvgUPf0u098uxKlUZy6YBDUwnGnZQjZrJNgfbCbP0iU SxqOFwYtSG1VTaCD0xG/Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:Pmn51ffgwOA=:bsE8F6YdstWAJZg57eG8zw yLXqSLbYJsfAmtejfBAYW5c7wNyLrdv0X6+lm+GDZKIx4VA0/3oKl+7RGGxBIShJ0bLkoTee7 Y0Y7zTv1TAC1l/5tGssnCFWr/LFyHkUZySrgxDTkJZpImZ2s0ZOM7wuQS/LbsT3qabgdi7pCr OBBVy22pXNbEAZDODHhqw+qLiD5+StZAzombd45u9hOn3cCmrTJTLh+uq59JMlvBAAy2EeAzT US+9o+d5Y8luiNmh6+mIx1Dub7YPxIuff1LddlivhLrv5tgoLFX9onB44G84FK8W5Ftdmv4kQ ewj57vy5nyF0m3kfrnVMbxBAJnTctDlaXxm4xP7c09aocOmwbyGJsEVQaWKo7wb/D7DhjMuKV S7gOx3dxkJyymdZBC2HPge0YS7McFKhdWxvpYd+/yvyuZTIz4FiaFduzt46EQctOOKf8rJh5I IUGQmUD5Mo5jqhfZa3BGUeUk3rVp15YI3dzPZ1DtjZYpQH6e8pLkcjwGInyD3iZgDMQGY75AY YDi1XcY1PvBZU0HoDb85hmPdbTJ0gaFOxgyzOkVbKdGEYTpfGXATvPapmojsAQnRdDHn0inoh 1KrQnW1dHPuZL/FmTk8UirBJQ+Jnku6nL36F4vKeRs+sk1IAWKUYpzvY9l4pnCdlPDoOgEQaS xAzDFIUjJhJbOBgHDBvGxTxMfRsMUY2LJPN6VzrBPXNNV9LX883N8dBCX5t1pZ8XZqFFWQhx8 h+Qj9Da15oh1FegDJBcTAxhfm8SqaQXMlY+BxA== Received-SPF: none client-ip=212.227.126.134; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The sigret parameter is never 0, and even if it was the encoding of the LI instruction would still work. Reported-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-19-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/ppc/signal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index e4d0dfa3bf75..77f37b9f0131 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -309,10 +309,8 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame) static void encode_trampoline(int sigret, uint32_t *tramp) { /* Set up the sigreturn trampoline: li r0,sigret; sc. */ - if (sigret) { - __put_user(0x38000000 | sigret, &tramp[0]); - __put_user(0x44000002, &tramp[1]); - } + __put_user(0x38000000 | sigret, &tramp[0]); + __put_user(0x44000002, &tramp[1]); } static void restore_user_regs(CPUPPCState *env, From patchwork Mon Oct 4 07:44:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535968 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCkX5Lvyz9t25 for ; Mon, 4 Oct 2021 18:57:56 +1100 (AEDT) Received: from localhost ([::1]:60566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIrC-0003W4-J0 for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeO-0004FM-Tp; Mon, 04 Oct 2021 03:44:40 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:40317) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeL-0004qK-Ck; Mon, 04 Oct 2021 03:44:40 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MvazO-1mpNxt0G6I-00sh6y; Mon, 04 Oct 2021 09:44:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 19/26] linux-user/ppc: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:14 +0200 Message-Id: <20211004074421.3141222-20-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:zJQDeNvfKA3D0pmA19DTna78yMG7NV0QZ+MSC7gMdgRf7L3WuCj 57+TdP5GjA0aEFupg66KMZ8cP2Kmlbn8R6DNPCKsIEZzHKH30jJAjpVp59htzJfUU5exSaV lkJ/mL8URDXyWunBrHZaE0osjrNbvZag31kDmfqA+IvuGwMzOC62MLfVHCTq3NQw/koZA0V lQ7pzgh0TM1k3f0yeMy2A== X-UI-Out-Filterresults: notjunk:1;V03:K0:pee8h0ATvpo=:3mfWjJAR2w9x0MJ43r6JvO sVHIbsWBsRir0vyv0gOmO/DEAmjv6BtywiYoAkozSmDJr8FGcKi6yqIh773Dc3gHuFHhJuRLK hICqVznEl0Ugrf3QneRtzblzoXse/EkhuP9SLwEtZ8tadunxvzy6uQRYL5zhjwIMuWA98pYWU R6dBJNOE2hGU8AdLVidGWVQjSoV15F2Nc93f63DXmkKG3PZnFT+orKBUaiZ1ht2rL+4Muo/Ng CD3hrREsrjhsiV+3gtfAiNm6XZiZB83TKk4/biMaOyJmNkBOa3ARI0okVq4K5WLDcRZYd4FYO XrZ8QScdRj3qBTKE+mLpOQNl15cUiqQz7K8Ps4tVjbuF/zK7lPZucG9upA7EL2zFmSVGI02jO SrKLlsjbpVLLzUZ2WgUdM3YMJlLiouvmZ1T4ogpws046NDoSxKs8XMlMgfJlngALPSSiVOYfb wgGd6RsdH8zrQqV/x7rJtP/cZlLs0hoklvdv3EMVVAQtSSrCjxgnljvE/QIU4jsaeKahSCt6A 1CfozmDV2E9lnProvVo6ZLIko2pvJrmQImerV+Qn4fGxVEo80KMijYbgldDrhJttQXDyjusVK HPNf8PFGH9xG2n4cptU+agAuuasXYv/KsfI7iCYTf1sfB1Cbz1r32cvbGh1tJuRtyTIHB4H7p Vj/khk3nmvKKpBBokOZ9YbEuVz859g4Kb1kIM193VsFsRgchNFA/3iOItZZrCd8N/5m9XNCYO qnmecVGt/Ws4YhwyzAlN0ZrgiznKCmazrhdZ6w== Received-SPF: none client-ip=212.227.126.133; 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: qemu-ppc@nongnu.org, Richard Henderson , Laurent Vivier , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-20-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/ppc/signal.c | 34 ++++++++++++++++++---------------- linux-user/ppc/target_signal.h | 2 ++ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 77f37b9f0131..c37744c8fc55 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -203,9 +203,6 @@ struct target_func_ptr { #endif -/* We use the mc_pad field for the signal return trampoline. */ -#define tramp mc_pad - /* See arch/powerpc/kernel/signal.c. */ static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, @@ -436,12 +433,7 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Save user regs. */ save_user_regs(env, &frame->mctx); - /* Construct the trampoline code on the stack. */ - encode_trampoline(TARGET_NR_sigreturn, (uint32_t *)&frame->mctx.tramp); - - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(frame->mctx.tramp); + env->lr = default_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -477,7 +469,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_rt_sigframe *rt_sf; - uint32_t *trampptr = 0; struct target_mcontext *mctx = 0; target_ulong rt_sf_addr, newsp = 0; int i, err = 0; @@ -507,22 +498,17 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, #if defined(TARGET_PPC64) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; - trampptr = &rt_sf->trampoline[0]; sc = &rt_sf->uc.tuc_sigcontext; __put_user(h2g(mctx), &sc->regs); __put_user(sig, &sc->signal); #else mctx = &rt_sf->uc.tuc_mcontext; - trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp; #endif save_user_regs(env, mctx); - encode_trampoline(TARGET_NR_rt_sigreturn, trampptr); - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(trampptr); + env->lr = default_rt_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -720,3 +706,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + encode_trampoline(TARGET_NR_sigreturn, tramp + 0); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} diff --git a/linux-user/ppc/target_signal.h b/linux-user/ppc/target_signal.h index 72fcdd9bfa20..82184ab8f2ef 100644 --- a/linux-user/ppc/target_signal.h +++ b/linux-user/ppc/target_signal.h @@ -24,4 +24,6 @@ typedef struct target_sigaltstack { #if !defined(TARGET_PPC64) #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* PPC_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535976 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HND045168z9t54 for ; Mon, 4 Oct 2021 19:09:40 +1100 (AEDT) Received: from localhost ([::1]:52168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ2X-0000rq-VZ for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:09:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeT-0004LG-Ox for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:45 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:47725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeQ-0004wU-Rl for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:45 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MNc1T-1m8tDM3WGJ-00P9aT; Mon, 04 Oct 2021 09:44:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 20/26] linux-user/riscv: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:15 +0200 Message-Id: <20211004074421.3141222-21-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:AAF27IW3lRIldQ+uE/IG01kCk2OyRCNFh3Xk17b48cO69mqRLTO Eh6RTxhIbvn1ABVjs7W/AoHN8TqQm2mhFEUMKmaS+56iNHGqHJbT1RLaBw5kmaYt1zaWLi7 ZlMLkHJce3c2SYh4HNJz48wh1/Xo38VWLpRM64tAsp5u1IV8nodHyvkOxxJo20PqXLY1zdO AwZzFJPwN+Papmv47pUPQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wjxzRMMCZkw=:PHlWAiIXd+SUXl7/b/bzca 6anktjQ1IQoqRT/sTDZhl9jDiXtSkckfSIazjAPxx1vqbmt1/CH33GwubMb5+kjDsKKxKgipj liRmOqwpfJu3XNwSDq37jxy/3frxDtpdBIqdZf9Qf7k1oQ4xpt8VkVyEgSyw9M61/+LjeBQv3 ssEjVaVtvvG0vJIrrtLnTwtB+kLV81X9nBSW5O1uXglH8/rOcKRYZE9qKPPZglEAQRR7XWf9N zDHWXhTJ3YUQiGfVWVFaB1cEsXtB5eNjg5dXwRooZaX8xQxXsBNLCNPg3Z6cHFo5JcVsKG0lO 310qysyanZfnbk+QVzkmeTe4WJSMHuFgX217r0RHwnq0VhsSzWdGy4Zxl1X6/tZa+//MJ2IQs 8DcrKxv50Z3Ng3nkHLfi1ez5GmmoGkd1QTK6OVFkBS7yexXhtwJ7HQyDcItQUiMHoKvQWwhSU noqkbVKUS0f/xrKSOYoNQWzmwFbIPYv0lw2cZKAHH4dNe2ryI0OuQNAdIpcYVSSOr3qSwvNr1 gMFZ3GRtW65iI8QrSwJURltGFMkRH1gsbU1G1zX3vlxQ/IlPC7mIP5RJ6s6z8sW+YXvcp69e4 P7I34h2UskGn7p08WgrH5OIBI+X9rO39F5Y6qZMibNPIDx560ky/GKHf4G2B26ozwtFkMWuHP qhSmF1ULuzrnEjoh3r+Uo/YrmZIHBZLJiM7XBu060LwmEi30lWHPTTro6xfYwCzX2qgxCIiZV nF2OT0HO1935+hB+sw8whzkUjJAxUQdnsMvUsA== Received-SPF: none client-ip=212.227.126.133; 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Alistair Francis , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the rt signal trampoline. This fixes a bug wrt libgcc fallback unwinding. It expects the stack pointer to point to the siginfo_t, whereas we had inexplicably placed our private signal trampoline at the start of the signal frame instead of the end. Now moot because we have removed it from the stack frame entirely. Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-21-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/riscv/signal.c | 22 +++++++++++++--------- linux-user/riscv/target_signal.h | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index f7f33bc90aed..a0f9542ce39a 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -47,7 +47,6 @@ struct target_ucontext { }; struct target_rt_sigframe { - uint32_t tramp[2]; /* not in kernel, which uses VDSO instead */ struct target_siginfo info; struct target_ucontext uc; }; @@ -105,12 +104,6 @@ static void setup_ucontext(struct target_ucontext *uc, setup_sigcontext(&uc->uc_mcontext, env); } -static inline void install_sigtramp(uint32_t *tramp) -{ - __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ - __put_user(0x00000073, tramp + 1); /* ecall */ -} - void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPURISCVState *env) @@ -127,14 +120,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); - install_sigtramp(frame->tramp); env->pc = ka->_sa_handler; env->gpr[xSP] = frame_addr; env->gpr[xA0] = sig; env->gpr[xA1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[xA2] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[xRA] = frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[xRA] = default_rt_sigreturn; return; @@ -203,3 +195,15 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ + __put_user(0x00000073, tramp + 1); /* ecall */ + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} diff --git a/linux-user/riscv/target_signal.h b/linux-user/riscv/target_signal.h index f113ba9a55f6..3e36fddc9dbb 100644 --- a/linux-user/riscv/target_signal.h +++ b/linux-user/riscv/target_signal.h @@ -15,4 +15,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* RISCV_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535977 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HND2N26cZz9t25 for ; Mon, 4 Oct 2021 19:11:40 +1100 (AEDT) Received: from localhost ([::1]:57610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ4U-0004dK-18 for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeR-0004K7-TH; Mon, 04 Oct 2021 03:44:43 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:36429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeO-0004uM-MJ; Mon, 04 Oct 2021 03:44:43 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MysmQ-1mjrew1vjG-00w0V6; Mon, 04 Oct 2021 09:44:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 21/26] linux-user/s390x: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:16 +0200 Message-Id: <20211004074421.3141222-22-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:c30x3yUmnq8Umz5Jiv9UEsmawYcGms+lxlyFGWhYKfqkKjvF5i/ b/0UJNaHtB2njBXLFQIt0RmodO/UaOLE9MHwetgL7sAq+T61qPXQ0qDrKoQHQzvQY9+WYmO zyMnO+g4IKofj/x2wzj7lNn6/bYHdC+VRhUaL8LO5iu/I6Q8khcHSsd2YGRIsGS8GRptME3 w3miAhemiy06MZoq2bV8A== X-UI-Out-Filterresults: notjunk:1;V03:K0:NIgMMTv4LDg=:l6bhVuCLN/AH4Dv9D4GxmF Z2BreH4FdN5pCnTLTmK5H+AHCP7eFOB04IkLLPC16Vt8wZB94Cwq69GRwOWEf/WX7PmRzZL9o nbs7DXizH4EkDkzd/CQv+tkx9xTLlDhoN3eGeqKSjiqX5+drf44yENUeBUErFftnHS1fp6j/v 4K1oD88DnPojqzz95/vALdfj6znpkfwUzgkHQjMT5h80ZuViWxEXCLFPuDZLYXGaXCzTzD67l 8kIb8G6TIh/3cFDQpU3sH4LmRZo9+nD4apNECu1AiaDknSKe9mMZbUaV4+5VA8B/3q3rsj7V5 yAz+9LWiElUW5C3V+0zR+w7tN0HjEQ1ZqVvZjszuznFHDcIWBbsZwlWxVetpF80kgB0jDnkQl nIcgYtN6p7U2RYot50Ra5tDzHSmzOH+j1isEvycz8uAPr9d4Oma8GDU4uMvxUuNizTzZXLkxX RGWJYJPjwhwSlcX5lbQ/fepUS5gpZntnCdzo9deM7qx7jWxtNYeFeETZ4ESS4+hUv5Xm/6KZ4 f+ihI/9NYC3KmLqLjPf/WTLTeHbirHE6HgGngulzb9pBxk5ThQOCDQC+AMsqnd3wNSLxjoWEe EciuYlyYz+p7iKZKB3N02G1D1YmsX8eBA/LQRO5dyAKwB2jOvJMnAKDwAeI7rFdNa0wKPBfEt U1dIAfX1GpQCO3kEC+8UQAqPYzB/uFKeg7o/iokfzqT/0phKcZamGWhPw/wDiQEUFcP8jgpYs j4uyGQfsnUA/hG+du2LYCPCZK4QCf/cMHbzN2w== Received-SPF: none client-ip=212.227.126.133; 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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?Alex_Benn=C3=A9e?= , qemu-s390x@nongnu.org, Richard Henderson , =?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: Richard Henderson Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: qemu-s390x@nongnu.org Tested-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-22-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/s390x/signal.c | 24 ++++++++++++++++-------- linux-user/s390x/target_signal.h | 2 ++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 80f34086d7b5..676b94814769 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -68,7 +68,6 @@ typedef struct { target_sigregs sregs; int signo; target_sigregs_ext sregs_ext; - uint16_t retcode; } sigframe; #define TARGET_UC_VXRS 2 @@ -85,7 +84,6 @@ struct target_ucontext { typedef struct { uint8_t callee_used_stack[__SIGNAL_FRAMESIZE]; - uint16_t retcode; struct target_siginfo info; struct target_ucontext uc; } rt_sigframe; @@ -209,9 +207,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(sigframe, retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - &frame->retcode); + restorer = default_sigreturn; } /* Set up registers for signal handler */ @@ -262,9 +258,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(typeof(*frame), retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - &frame->retcode); + restorer = default_rt_sigreturn; } /* Create siginfo on the signal stack. */ @@ -405,3 +399,17 @@ long do_rt_sigreturn(CPUS390XState *env) unlock_user_struct(frame, frame_addr, 0); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 + 2, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]); + + default_rt_sigreturn = sigtramp_page + 2; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]); + + unlock_user(tramp, sigtramp_page, 2 + 2); +} diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.h index bbfc464d4417..64f5f422010f 100644 --- a/linux-user/s390x/target_signal.h +++ b/linux-user/s390x/target_signal.h @@ -19,4 +19,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* S390X_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535984 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNDLf621Rz9t25 for ; Mon, 4 Oct 2021 19:25:46 +1100 (AEDT) Received: from localhost ([::1]:57320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJI8-000750-Jh for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:25:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeZ-0004Pw-CT for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:52 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:46171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeT-0004yM-Bg for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:49 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M3loZ-1mX1ni0Fql-000rRB; Mon, 04 Oct 2021 09:44:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 22/26] linux-user/sh4: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:17 +0200 Message-Id: <20211004074421.3141222-23-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:UY5j0COrFLEmlfQfVnJ3koYLiU9Vl3VFrGwXK8OfbZYdruni67y FSBAz7JRYyf+ndjBPINEi9Pq9F79OKb1F8yrieF3vGY8XLfcKdPvhsM7rWiwzhvYCpEZpaM ZlsWgJMsWaMFVLuDjTi/jp+g3++YHo5GxkQnDbuzn5mOGNkiW+ruCV9A3HrIznGP1xfdX8l OC0rh0P9PQvxRYBoMHL6Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:lBjxHDcKciI=:WiWlakfPIck/APP8uhbNij RQGRCRV9LotOilvhEKGtvWWl9qjLZqzHr8hw4BT1PSlO9/n06DoHY+l5VaKmqMmT9iLMGOyGj OlDCyiPjPw7l6IgJBixu2sYxNuYQd9UVGHru2SkVO/2oDsJrDYXkVwCYJVokgagZY5bQPN2XY rrEbXteVciswOrG8gFhPFE6S6REiPjOwQ4mUAXuCG8w7w0ri9pw+DZbVGU+1S5j8G4S9k9Qn+ HClpRGXZATU2YFY4kiAgYBwFlt7wbO8Nu9riSJjQV3DBQc3ZZLS3m7NwfUwnjRbcDzdjODtSm J0DGNX3neq0vR24PiODuvYJ/yfXNycnldKS5TgPmxeTtQ/pDdEas7wbRSY26p8aRn4XCE3Ehx mQmYVFA0PbZMUEHHiwY6ZxTBPEIQ31bzEw8D+IVWaA/6dalXfrTQNlSoTRKu54U04xgu++2uF rxEK2rXXg4iFUJULVMy/6T6SH6EpzKry/pbpgczfki9eqbZR2oeDTbrWbVwVTuZ567uYiJksP jmLF/oHBYoLmpBouwzY/hzMswqiHA9ygiooWDZ56JGny2/jYgkEKelqZ/IkX72mUA/C0jfjGU 9cigO3/2OBn+qA+RaYpd8Of4W8EXr94A8V3Ssu7thCaibPHllzvpg+LCWhYBJ9IUPazQVgJIa AZj/3Cy0k3JxsoM6MzcXFRSUO8crrNojjjBl/kWSlsV0j0OPMiV48Z0EJjOxQ1weGvnJxTqu5 8sfUc09KxWVl2OzP9VkMuNKGbHie/ZCh8LoaZA== Received-SPF: none client-ip=212.227.126.131; 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?= , Yoshinori Sato , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Yoshinori Sato Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-23-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sh4/signal.c | 40 +++++++++++++++++++--------------- linux-user/sh4/target_signal.h | 2 ++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index d70d744befc2..faa869fb1958 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -52,7 +52,6 @@ struct target_sigframe { struct target_sigcontext sc; target_ulong extramask[TARGET_NSIG_WORDS-1]; - uint16_t retcode[3]; }; @@ -68,7 +67,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; @@ -190,15 +188,9 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_sigreturn; } /* Set up registers for signal handler */ @@ -248,15 +240,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_rt_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_rt_sigreturn; } /* Set up registers for signal handler */ @@ -334,3 +320,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(MOVW(2), &tramp[0]); + __put_user(TRAP_NOARG, &tramp[1]); + __put_user(TARGET_NR_sigreturn, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 6; + __put_user(MOVW(2), &tramp[3]); + __put_user(TRAP_NOARG, &tramp[4]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 2 * 6); +} diff --git a/linux-user/sh4/target_signal.h b/linux-user/sh4/target_signal.h index d7309b7136d7..04069cba6641 100644 --- a/linux-user/sh4/target_signal.h +++ b/linux-user/sh4/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* SH4_TARGET_SIGNAL_H */ From patchwork Mon Oct 4 07:44:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535983 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNDK30TKHz9t25 for ; Mon, 4 Oct 2021 19:24:23 +1100 (AEDT) Received: from localhost ([::1]:54582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJGm-0005EA-SC for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:24:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIee-0004RW-Ts for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:58 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:43243) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeZ-000525-27 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:54 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MA7b8-1mdKFr2yx0-00BYno; Mon, 04 Oct 2021 09:44:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 23/26] linux-user/sparc: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:18 +0200 Message-Id: <20211004074421.3141222-24-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:IkPWyBMtCWyULjUUx1wEAPfYlpIRwjtw7JuKjnNDtq8w7xY+fW4 6rpOyb0CtrgFDp5PhfwUojBVoJBlZNBD8Z2IkcntNHRsi8eHvISqsCvy0p012ePQTeBDZEb Q0HB3dCnyX2C1G/AlyA7qh+Hhnlqrc6wJntA1AzWQRYF+G7/6465obcQkIjO/SFj4R99s22 bm0D4bsKijAOBoUNfZeKA== X-UI-Out-Filterresults: notjunk:1;V03:K0:P5ySPbuQEPI=:5L1Txmpq1bxs0sMHVH8ONY pD43oSuAvRnS9hKgut3MaI8/at1bHlzJ5503hVGNtUf2oPZhQBhQsgijfLXeITURRaWPl+woR EJLCYOXfPD1iXiet/+5TgvSRhncfuPhodSmttz1e2EGZ+7ESZUfoglDuzsxmGeyFRFQcjJh+G BONQYBgEgSPQ46bJPQ988pGa5EFyFfOs78Y6cqx4ACqE0+Sc9X65XUMO2WUQakk8+xtKxKX0f lO/Pry3WBby93qzDh47UkX1cpVXRvUkxcPgoctz1pjqgVZEJHJFJEcYt/51z8DiovV6diO0M0 WfdB+tBctUpdD8ZnfvpRFKEM4nFZC2jwC2qg7Kai4dyjPnwg5wTiGMSYh3dArYDrurDtaa9gT jiLmYtX0vJQvRycd9QAq1BO3Hcz81Mg1XIYInEI7azq8jcuQZJSgRQZ+zkOkFzpfFTbCfuInI 8zCuDWBgERDYuqzArB6109YDwU98JPKvSjWszov1gKiGy3fTALbko+v16QuHzVR4S/yqUJ0Hj DDEkD9Aj5beE4ITMEU7lDw9kvOkb1o8J8Glmds56ECzzFZWAy7Jc2uBsyDOZ4kZHTPPiBJXCd lkFVwr/aJ4FyVK7FdThPjoprsLbRag3qlbxvwl2EFQa4yKxg2gAXkIM59IXOpvHHy7GS5CxlE /gVTiLvI9n2mS79Z46bGNkKvQiPfrqq2RFhw2Q+bHMFLaMOTi0RzYkutYb0LJA6lzxoAFP1tT x4f4duB+tLKahVTZG5fbAeiQ9cpwiNTD/rLRCg== Received-SPF: none client-ip=212.227.126.130; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Mark Cave-Ayland , Laurent Vivier , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Acked-by: Mark Cave-Ayland Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-24-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/signal.c | 40 +++++++++++++++++++++----------- linux-user/sparc/target_signal.h | 4 ++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 3bc023d281a7..23e1e761de42 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -242,6 +242,12 @@ static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env) } #ifdef TARGET_ARCH_HAS_SETUP_FRAME +static void install_sigtramp(uint32_t *tramp, int syscall) +{ + __put_user(0x82102000u + syscall, &tramp[0]); /* mov syscall, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUSPARCState *env) { @@ -291,13 +297,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = sf_addr + - offsetof(struct target_signal_frame, insns) - 2 * 4; - - /* mov __NR_sigreturn, %g1 */ - __put_user(0x821020d8u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_sigreturn); + env->regwptr[WREG_O7] = default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -358,13 +360,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = - sf_addr + offsetof(struct target_rt_signal_frame, insns) - 2 * 4; - - /* mov __NR_rt_sigreturn, %g1 */ - __put_user(0x82102065u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_rt_sigreturn); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = ka->ka_restorer; @@ -775,4 +773,18 @@ do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); } +#else +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h index 34f9a1251909..e661ddd6ab3c 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -69,6 +69,10 @@ typedef struct target_sigaltstack { #ifdef TARGET_ABI32 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 +#else +/* For sparc64, use of KA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 #endif /* bit-flags */ From patchwork Mon Oct 4 07:44:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535980 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HND7S5CVsz9t25 for ; Mon, 4 Oct 2021 19:16:03 +1100 (AEDT) Received: from localhost ([::1]:40712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJ8h-0003ov-VX for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:16:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeZ-0004Pr-A4 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:52 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:42841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeR-0004wf-J5 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:49 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1McGtA-1n5GxO1LLg-00cgQY; Mon, 04 Oct 2021 09:44:38 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 24/26] linux-user/xtensa: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:19 +0200 Message-Id: <20211004074421.3141222-25-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yOh9WAT3bb04r9IEmSGWPhDeaPOBZwJRmLGiIoAqiKMoK8onVzq VJmwPPh6lkBuTJOtjoeo5rb4zclA3EWx8uD2mY+keNR9we170TmUibU4hLYgE+eV4vpgwg5 eamVwkupqzNeEPr5lIPxcfKnOsjjejwhwhFNLfoas7nVINlgFPQYnHiZAuXQ0NTQzT0UEJJ 43I3gatgi36OFMnqzVFrQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:/RCtgT+yquE=:LVd1hJxhWUWMLe5lvFAcIm Hc3DYAR4/YY5ETL+VptKGMHKc3EoLf/LGwP3TjqKOoGwW4nQkQ3JUftnDOCAhST8Cu0YNFHXz Wt7pQIhc+CyLvJNNfuZYjwcu2EOoPn3y4YYWVkDj0OUJer2h+F062UCVQxzUaEtUbucTsmpPl Bg0jR5XJGNaCoL8BtnNRMvm5n8uZRff3dz+JVIWOM0jpSiNpqUDhalRVu/1roqnXzALT9bWaf M3OIJz8t9fXFf27K2uCtZN3wr+/FqpjgZ/lxMMwsG9A49oDXEnzIm8LpFFg5mxx/UbvYcptTX g0p9p6cY3Fd9xQ0wOc18FI3TQdlLjAj19sXyWvUy4BmAhPuescE/sONAEjbJVg4zgUufbv0R9 VmP35bTtuMXo6nEa2zrq5J+RYGSi0EMflXDIMwi+zMWp+KCQe9DQaoSWw7FQWbomoR8AYnQD3 K8Ft2j1ftDqsHr7b4+fBzyadQwAxuWnuZwXFofguhfxY+lXGWIF0ZFQBXnU08uaHY+o5TaQbY z5jG7LIxHt6UINqbUAI/kvBpE69KIrVYKhluv+b3DPpYk7CKkmny5q0Bkbrp6PeE0aFProsDG 92DoIgy1HO6+YlsDz3MEkGZprdZELedgnOzmXSyfl8ynKHsPTqO2lK2clFeEu/BZPtBtbj11D y9Oqf7d4c7h1JuF2vSHAR+63dizv12IBPUFUbXxeBQwfImy66qrQcb5W8VnBeW+ppZum1rPfo zcJpEjLj2+XVphupXk7WxL+2cGl/37rsqb1/ww== Received-SPF: none client-ip=212.227.126.135; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Max Filippov , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-25-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/xtensa/signal.c | 56 ++++++++++++++++++++----------- linux-user/xtensa/target_signal.h | 2 ++ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 7a3bfb92cadc..81572a5fc7b3 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -128,6 +128,29 @@ static int setup_sigcontext(struct target_rt_sigframe *frame, return 1; } +static void install_sigtramp(uint8_t *tramp) +{ +#ifdef TARGET_WORDS_BIGENDIAN + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0x0a, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x05, &tramp[4]); + __put_user(0x00, &tramp[5]); +#else + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0xa0, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x50, &tramp[4]); + __put_user(0x00, &tramp[5]); +#endif +} + void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUXtensaState *env) @@ -164,26 +187,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { ra = ka->sa_restorer; } else { - ra = frame_addr + offsetof(struct target_rt_sigframe, retcode); -#ifdef TARGET_WORDS_BIGENDIAN - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0x0a, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x05, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#else - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0xa0, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x50, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#endif + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(frame->retcode); + ra = default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc = ka->_sa_handler; @@ -264,3 +270,13 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint8_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + unlock_user(tramp, sigtramp_page, 6); +} diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_signal.h index c60bf656f6b6..1c7ee73154ac 100644 --- a/linux-user/xtensa/target_signal.h +++ b/linux-user/xtensa/target_signal.h @@ -20,4 +20,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif From patchwork Mon Oct 4 07:44:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535982 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNDGN5h6zz9t25 for ; Mon, 4 Oct 2021 19:22:03 +1100 (AEDT) Received: from localhost ([::1]:49128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJEV-0001QA-KV for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 04:21:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeZ-0004Pu-BY for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:52 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:50677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeR-0004wg-Iq for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:47 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M2NqA-1mVfI03Pqg-003tq8; Mon, 04 Oct 2021 09:44:38 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 25/26] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Mon, 4 Oct 2021 09:44:20 +0200 Message-Id: <20211004074421.3141222-26-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:5soxRWu2yGVdM3Llu+2dQcIuLq9WLfse5gEmizw2FdTMamNUgQv yxKD0aSaWLYVBXNKA+QIzBzCWxQ0jxfQ3GzDhxXyU9se2Ro18BpeUA3BIqEGUFugICZNgYz ZDEn34BcjAx46JcNoDe0FpM9VE6a9XIoVSuG4UXkidbCmekMv9zzTDlY6ttIdfkczBRJ0i7 erhfDr2LfnyzHFYpsu3JA== X-UI-Out-Filterresults: notjunk:1;V03:K0:0ZrXZCwCPrY=:ybyRHnZxh6F/t8qk2CgzfG 23Y/p5wqNR5/h7Uy+P3ACvTgHwxtaC/BUj0iHq9MjILzyez0K25MyYLsTHZ4rPts2dOFG4Isd Gps9btZ1Ml3h/jOJa+QlqNmKPfNqQ3+wLNKySGaSN/p9CNIU5q/Kazb0QzRn9EZL9sjVTvw9I ZpR9ZLXMt+h4SqIiWt2J3dDNWRj45L/aiEyXYOQjiTsqLVN9TzO1mZg0bu1K/EsJCSVGFZEbT LqXwMIftsuWKQjwGOhp5KvR1MfgBWCQgZwAR8Dla/ttVcx6M4kQmhjkzWpjIj0CcXrkhvEdvU fqY8FZKLXBHdkBg9IHK2com1xDFrZYTpMUy9I2KLroGD88+9+XKuHJFoSULn2IpfaorbLoQyV y7kykXQjEzuWc5MfNhvxAunDflNGNfxxDsBBtbGpfQ0QT8Rw8zHPpW8+AViY0+Ly8NhYUIbE3 /GW24MoVfnuMEFV2DXFk7M+vlxvfvf1qjmMg+63My/x+ICCX7sIJLTXTl2AKZHIdWuAI9RYfG WvEiCkN7tWl6yPJUIMGGCI2moEEfzqfDfae3HdZOTa7TUxqH/VFOJ3fPGpE9TQ+IAWoRCPqP1 l588b4cI2tqSqABGtU1vH1BZSUooaLf/Rm7Gb/cMrGNdwEpM9/QXHdOqVNzN2uYvbrarGiO+7 vVBrLJ/8YIV503YDc+3sfcb81oV0GYL7XossniAEpObVzXI7e7k8FhneP2//ra3kpug2ADKCp FuIYk62IMx3k8X5qMYECpjzOiHVu9L0L3O5CMA== Received-SPF: none client-ip=212.227.126.135; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Richard Henderson All targets now define TARGET_ARCH_HAS_SIGTRAMP_PAGE. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-26-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 459a26ef1d93..2404d482bafa 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -30,10 +30,6 @@ #undef ELF_ARCH #endif -#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE -#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 -#endif - #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */ From patchwork Mon Oct 4 07:44:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1535967 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNCk23FDNz9t25 for ; Mon, 4 Oct 2021 18:57:28 +1100 (AEDT) Received: from localhost ([::1]:59604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXIqj-0002mD-Jy for incoming@patchwork.ozlabs.org; Mon, 04 Oct 2021 03:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeT-0004LH-Oi for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:45 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:51831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeP-0004vW-D9 for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:44 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MV5rK-1mP5gf0ztW-00S7ie; Mon, 04 Oct 2021 09:44:39 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 26/26] tests/tcg/multiarch: Re-enable signals test for most guests Date: Mon, 4 Oct 2021 09:44:21 +0200 Message-Id: <20211004074421.3141222-27-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Tcu0udpoESPKie4FDxActY0GmyegS0o83Lu4WhRX0+qwW8ZPWZd 3oybT9Qa4LHuaG8q8Y7RjNKHafaPpq7MliasJUGmox9r2lOKP2/06+eU9LqtcT2YbU6A/q9 I7+RopQaXWrTeZBzeOCRcX7oHwaXxNw6D/TXoVfCeEtH36wX+q/6nuE3Ae6xQZn3pKw7cXm Yp8zYQ4G8OqWHy9/VoqLQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:fyGM0cK832M=:rcibrdgDs3LF5Zzhpy8oMR Bam7Dk1PdCTnAWsoXsooeXhCvl2+mCkyAUoHVotAZAY2ttcxQpe4h4WWQ0GmrXiX7W6aj0UyT qCrXJBUXw8TiDPySLiZlyPxmi5+XoBpMlsOJ9dFNtZ/K0tD7EIVdM8Dzn1v5bxtgUT1kkU9vT YnU47zpXs5Re5Uw1/ZTxclfb5+GfS6Ue8xYr98hltzTTeKlXtoHfh1YCLLF8UVs2TQxHmIKOo lGD+9X8fgXvSo7kUPJahr0zx0pzUTcMt0XoGZ6m7EX9+YpOw8LBCE4ZqdymKN20X7i0La/cKi P8ZkUmYKBdXM/anxMCi1hOFch4C86k0QYfvhsdZ+e8BEouW25MYAjrIdU4avJ8ivVazQfDrI7 G02O3NHqNUH2ILrgwKX9cXV6+hCw/8jUlCHqF8yyFU0NO1fHuTCC60IFM6imJv83pF4lvKAxC 8J1maaCXwYXnxKV/DKTutGGsp7j6sweAHDzscM3H4i3Hcj39B/dy4efXvhxbJT4PU/mYnTOYJ aEpJnj1bGEIDKQW17sI/Pq7/HXIloLdSm1Vx4vDdUwZUArCr9NbFvxW571LE8rOqd2EfURQui A3iX15Ykf+ysHRcLAducfFesubwWICsKc2pjhePseTzjxv7Ph8XuxyNg0wBxfOytj3S2sCjVD 3M3VxkP6gjn13qXXMFIJpeH7WJGkns+lbKokm3QHl/WamMCz7Iedhy5T6sPcxiA/gZVxUNPxM C3xxFK5n0BqrC5npDCmwM8J60+1R146d0fvxFw== Received-SPF: none client-ip=212.227.126.134; 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson With signal trampolines safely off the stack for all guests besides hppa, we can re-enable this test. It does show up a problem with sh4 (unrelated?), so leave that test disabled for now. Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-27-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- tests/tcg/hppa/Makefile.target | 7 +++++++ tests/tcg/i386/Makefile.target | 3 --- tests/tcg/multiarch/Makefile.target | 8 -------- tests/tcg/sh4/Makefile.target | 7 +++++++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/tcg/hppa/Makefile.target b/tests/tcg/hppa/Makefile.target index 473864d1d468..d0d5e0e25761 100644 --- a/tests/tcg/hppa/Makefile.target +++ b/tests/tcg/hppa/Makefile.target @@ -5,3 +5,10 @@ # On parisc Linux supports 4K/16K/64K (but currently only 4k works) EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536 +# This triggers failures for hppa-linux about 1% of the time +# HPPA is the odd target that can't use the sigtramp page; +# it requires the full vdso with dwarf2 unwind info. +run-signals: signals + $(call skip-test, $<, "BROKEN awaiting vdso support") +run-plugin-signals-with-%: + $(call skip-test, $<, "BROKEN awaiting vdso support") diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index a053ca3f1532..38c10379af0f 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -65,9 +65,6 @@ run-plugin-%-with-libinsn.so: -d plugin -D $*-with-libinsn.so.pout $*, \ "$* (inline) on $(TARGET_NAME)") -run-plugin-signals-with-libinsn.so: - $(call skip-test, $<, "BROKEN awaiting sigframe clean-ups and vdso support") - # Update TESTS I386_TESTS:=$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) TESTS=$(MULTIARCH_TESTS) $(I386_TESTS) diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 85a6fb7a2ea0..3f283eabe6da 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -32,14 +32,6 @@ threadcount: LDFLAGS+=-lpthread signals: LDFLAGS+=-lrt -lpthread -# This triggers failures on s390x hosts about 4% of the time -# This triggers failures for hppa-linux about 1% of the time -run-signals: signals - $(call skip-test, $<, "BROKEN awaiting sigframe clean-ups and vdso support") - -run-plugin-signals-with-%: - $(call skip-test, $<, "BROKEN awaiting sigframe clean-ups and vdso support") - # We define the runner for test-mmap after the individual # architectures have defined their supported pages sizes. If no # additional page sizes are defined we only run the default test. diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 9d18d44612e1..47c39a44b690 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -5,3 +5,10 @@ # On sh Linux supports 4k, 8k, 16k and 64k pages (but only 4k currently works) EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-8192 run-test-mmap-16384 run-test-mmap-65536 + +# This triggers failures for sh4-linux about 10% of the time. +# Random SIGSEGV at unpredictable guest address, cause unknown. +run-signals: signals + $(call skip-test, $<, "BROKEN") +run-plugin-signals-with-%: + $(call skip-test, $<, "BROKEN")