From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632502919982407.2162905063054; Fri, 24 Sep 2021 10:01:59 -0700 (PDT) Received: from localhost ([::1]:59208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToaE-0005ZQ-RX for importer@patchew.org; Fri, 24 Sep 2021 13:01:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXx-0002dx-2H for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:39550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXq-0006rS-0d for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:36 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id a14so6648490qvb.6 for ; Fri, 24 Sep 2021 09:59:29 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=xfAv5iPtHAieHsIzSI/p1Ty23DbheWyX3t4bsn4MClUY6i59zpx8PcKP4794BPIgoV pfWQKnJe5+OqccwWiI1pTfvv3jNj8bAGrBOB7rJLJuoGm9ILv5AdTHvhX3A/YfYZt4dR xfSNNqbxjwciypCFwQ6G19aWGXywb+X0dt+EvojjpE2e1I5d0bDrPE1gAyyF3dQZ4K7N BXRrGViO7p7t/jV667+NetbZOExWc8z/i7eGFoTo25rUWP+uVgqBa4hEWv3WPUh0Gp4T GEE7QASXo9PFTZtiCrCMKdC+Zoy/rtqV0JVvemmamev45an08Ze+lPlJweoaGZCJvffH XaZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=Z1e/PnHMrFNY/JqFfE0bPseuGlwPvyGUvx3KldKahEm9zI0pRhh7dWCAw4yA6CmAKi FSOzfItu8Hj+osN52PqZmmFHpE5lKwQXK5DOhd0Tx/TrzjjjO6wZm3QGXoMq4etVTEwx YxhBscb3/DFURUuDngPULxYrMnbo+AaOyEfnSufgd7HxY92h+UuZDtmWrM/C80yOiUsS 7UD+3t9d7WJXeHY8qtc2fVn2iy6Ja1MU/hjqIsAiBcBH+c7c4xiWoAW5UNcsB9TRgXwy ioQfLgQkdkCf1Xr0e1YF74CnvLiOc1iY1kehYjuBCl/7IiDUdU6Gn2pJtf/AK6Oqp5xL +Tdw== X-Gm-Message-State: AOAM531UIorv4kbEjhuL3XiLEvpK/bY92V3OIhIOFRPE6Xe0orqAu18B dASwLaGE8hnzVI2MfU6Ax4W4Es7srohUwA== X-Google-Smtp-Source: ABdhPJz6WqI8eaMl1uWaYwCGwV/k/XOmG6amKwoTTXyCouwGERAOkhxAPm9Mo96A3dBI8aFv6vWDfg== X-Received: by 2002:ad4:4629:: with SMTP id x9mr1451260qvv.58.1632502769084; Fri, 24 Sep 2021 09:59:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/27] linux-user: Add infrastructure for a signal trampoline page Date: Fri, 24 Sep 2021 12:59:00 -0400 Message-Id: <20210924165926.752809-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , laurent@vivier.eu, Max Filippov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632502923394100003 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=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/signal-common.h | 6 ++++++ linux-user/elfload.c | 18 ++++++++++++++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 79511becb4..7457f8025c 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 =20 +/* 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/elfload.c b/linux-user/elfload.c index 5f9e2141ad..459a26ef1d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -7,6 +7,7 @@ =20 #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" =20 #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -28,6 +30,10 @@ #undef ELF_ARCH #endif =20 +#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 +#endif + #define ELF_OSABI ELFOSABI_SYSV =20 /* from personality.h */ @@ -3249,6 +3255,18 @@ int load_elf_binary(struct linux_binprm *bprm, struc= t image_info *info) #endif } =20 + /* + * 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 =3D 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_EXE= C); + } + bprm->p =3D create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, info, (elf_interpreter ? &interp_info : NU= LL)); info->start_stack =3D bprm->p; diff --git a/linux-user/signal.c b/linux-user/signal.c index 2038216455..14d8fdfde1 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); =20 +/* Fallback addresses into sigtramp page. */ +abi_ulong default_sigreturn; +abi_ulong default_rt_sigreturn; =20 /* * System includes define _NSIG as SIGRTMAX + 1, --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503649711729.8719679028734; Fri, 24 Sep 2021 10:14:09 -0700 (PDT) Received: from localhost ([::1]:37030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTom0-0003hX-KM for importer@patchew.org; Fri, 24 Sep 2021 13:14:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002gb-UW for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:38828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXq-0006rd-KE for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: by mail-qk1-x732.google.com with SMTP id q81so25089127qke.5 for ; Fri, 24 Sep 2021 09:59:30 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=lwQTK+KUnDVPNS0vgUasmJy86QCOKIYv09hfvX7kHxzm545272dsnNDdHZictKJWN2 BboCrhg6Ofgyk/5BTxUzn1aefIXYszVm0poe4bNhFpflphP5K0YuQFcu1+Lgv0ba0JCH dTSkVJ+KwTz4CYkcbihofXKH1biTw3Qmdd6Tf/eKZlV1oaO15ibkYykwlLG2jzPdM2WA B+whWbj0cmkPHHkn8O8JnC2drkPkf/oOn/agkLufOIi06k6JBwjUMOoOK+eXbUk/XKG2 OWLBYAN9LRadrJwYYvBNyeY81MT07S8tnw6RnpJNIPgV0t1XgK0C5utnYT/DD2fV1qsy vhyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=0eJT1jVc7g6fWhTBDfoiOoWbCkbQP4C/23ZMHe4u29K49nLObXKux88/cwFbY9ITwg jsmvl8EK30Vqghz6d97B35G+boKl5DWd1MdOQ4P4lhJ2pZ0WKa0QNzj0ycgjGmGdILjH r1L2wTzHTXtiXUbr640epsoLGNOlvlPJkDyjRg67L8XFu+3ZexwscnKPKxFDZ3OEDCML rhxZh0ou0Z6hhkB/hqB6HmV2YAxJ1UwiU7TD9NIu3J0t5sugf1sdU/FiteBCS4eiIk1c 2bVv5KkOkgrI+jkXBs24IDlw97e0IMSJ/pc+HdUwqL8cpZZhKzp6k6m437MoH9/8qZcr xv1w== X-Gm-Message-State: AOAM533+IwnklvyBs4Z7GdV7RliYxNgyJTECwsWeViTZSVRNySGKL/5M OxujtKsZqZXpGQHUhrpWndHLT/CxjZNeqA== X-Google-Smtp-Source: ABdhPJxlbXGMRhWbdQ7he+zALI6xzy0KyNLi6APRpjXUvXP+vsQN+KMGyP4CBEnb7rni7M2K4zRHEw== X-Received: by 2002:a37:a904:: with SMTP id s4mr1620281qke.60.1632502769750; Fri, 24 Sep 2021 09:59:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/27] linux-user/aarch64: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:01 -0400 Message-Id: <20210924165926.752809-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503650871100001 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=C3=A9 Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 34 ++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target= _signal.h index 18013e1b23..7580d99403 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 */ =20 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* AARCH64_TARGET_SIGNAL_H */ diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 49025648cb..29c52db3f1 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]; }; =20 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 =3D MAX(layout.total_size, sizeof(struct target_rt_sigframe)); =20 - /* 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 =3D layout.total_size; layout.total_size +=3D 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 =3D ka->sa_restorer; } else { - /* - * mov x8,#__NR_rt_sigreturn; svc #0 - * Since these are instructions they need to be put as little-endi= an - * 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 =3D frame_addr + fr_ofs - + offsetof(struct target_rt_frame_record, tramp); + return_addr =3D default_rt_sigreturn; } env->xregs[0] =3D usig; env->xregs[29] =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp !=3D 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 =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163250312042851.83176535057987; Fri, 24 Sep 2021 10:05:20 -0700 (PDT) Received: from localhost ([::1]:39482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTodT-0003A9-97 for importer@patchew.org; Fri, 24 Sep 2021 13:05:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXv-0002dc-C6 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:39553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXs-0006sq-UE for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: by mail-qv1-xf32.google.com with SMTP id a14so6648536qvb.6 for ; Fri, 24 Sep 2021 09:59:31 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=UBgNzb4w1rN/7zgVQMVmhj2RZkMfo45LY8uLiZPciaA7Dvtjy6dDPslJkzDYpDahOg /wLd0GkJx3tmT0wwhmMEgKfceNKnXAHroaeZqOduySHxK9y3C2/llHCwMN9Gux85B7L7 1yph/8ZXm20ZsdE3RRxT6Ev7PyKyKZEQh7JMhpBp8jRCpQKdW4mdQc59mlFdbc2takNe B8q1ihXqjgME6Wu0RaO8luPT3ofxvwW0hIGiacfqT9RP+julZt9hD4InNQ8eZ47fJLj9 lo4kIKOf+j+UhEl0PkQuBkDsyHn6M4/LzBXQ9SP/gWQ1g3LbYU6bGzfXDGY2kjTNPpdj T9AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=MK5oh8uhgiqIQpneXQFt3Lrtry7rVC8GC5dVA03k7vFQQqkugrHDvMGEQOUatc2lRj it8cX12U/sRfQ1iTtWuXQPitRfGBsVLsaBxpEsHFCGWGRV1EDBeh17oOFJdy8rZ/AoCW nQ/1i8sER6hu0FChSWpDALWEbQdthmPbNg1qg9m4f+nIxrvYe4I5WY+Rdbgy5oX5BuUw J0Hi4o9p3z0H0eIUn3plhapYU37bbzVbmsniOazdrQhv3QRxvLPGDkHgQcx9CzSXfRMn lyrrTjg3krK8LogQjatA58vdtaQmGxWFIvDGHe7mOtJDLD6cgA52Aa7FEgRUVc5AGuHu 2T2w== X-Gm-Message-State: AOAM5306gOeqHriYxmI638JajwzB3YWYEwF4xeFycoe80xT8dYUCMpRf zj9Hk7+9Dimz3iScBNJdu+Ni9Q9zm9vCDg== X-Google-Smtp-Source: ABdhPJybsmPykVnGF0uyApYGTYzM7f9JTUP4MZO5e2oPOa6ZyhLnKu/CN7y3SsJKh9nTs9/N99ye4A== X-Received: by 2002:a0c:cc84:: with SMTP id f4mr2268295qvl.14.1632502770503; Fri, 24 Sep 2021 09:59:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/27] linux-user/arm: Drop v1 signal frames Date: Fri, 24 Sep 2021 12:59:02 -0400 Message-Id: <20210924165926.752809-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503122051100004 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=C3=A9 Signed-off-by: Richard Henderson --- 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 ed144f9455..d0940bab47 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,14 +46,6 @@ struct target_sigcontext { abi_ulong fault_address; }; =20 -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 =20 -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]; }; =20 -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_v= 2 *uc, } } =20 -/* 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 =3D 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 =3D 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() >=3D 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 =3D 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 =3D frame_addr + offsetof(struct rt_sigframe_v1, info); - __put_user(info_addr, &frame->pinfo); - uc_addr =3D 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 =3D 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] =3D info_addr; - env->regs[2] =3D 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); } =20 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() >=3D 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); } =20 static int @@ -553,54 +441,6 @@ restore_sigcontext(CPUARMState *env, struct target_sig= context *sc) return err; } =20 -static long do_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct sigframe_v1 *frame =3D 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 =3D 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 =3D 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 *reg= space) { int i; @@ -733,55 +573,7 @@ badframe: =20 long do_sigreturn(CPUARMState *env) { - if (get_osversion() >=3D 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 =3D 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 =3D 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); } =20 static long do_rt_sigreturn_v2(CPUARMState *env) @@ -822,9 +614,5 @@ badframe: =20 long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >=3D 0x020612) { - return do_rt_sigreturn_v2(env); - } else { - return do_rt_sigreturn_v1(env); - } + return do_rt_sigreturn_v2(env); } --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503119727565.621721973192; Fri, 24 Sep 2021 10:05:19 -0700 (PDT) Received: from localhost ([::1]:39496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTodQ-0003AR-Nv for importer@patchew.org; Fri, 24 Sep 2021 13:05:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXx-0002dw-2T for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:47096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006tc-Fz for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:36 -0400 Received: by mail-qv1-xf30.google.com with SMTP id gs10so6621211qvb.13 for ; Fri, 24 Sep 2021 09:59:32 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=CNvJ3/MsUGCgoyu/DfdaXe5WtCXORRd+leVdiKK8yh9MRBeX2Kplbflijtd4dlTjuU +TYc7Et+MVtZT8flopOOyyNfnwZqDNQZ6kVHCpWpchsKDm0uBA8nzmKH804t8xhW7ICD XU6anPWeYSgVzTv491HK+N/q76I8ApcDU+d9SPKcVlh1q0cTyBy3/9m9TPR7eZiECkoK 9CG6VEKsYHF6TOvRwB18jFzcNU5eJjd5SLLdzk4YPSL2RejOKTFHlJewBzoAo2Q7mmhd f6Z46t8WVHDy1xgF4ZkMJBhpyXjmdEOE9RWhdAXG6XLu2wRPXvCgRkskpODNnMGYh44I Q4ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=6zUK6Jp6M+7uUvYsaiT1FOOlPi5THu2IPK2qmymnkIbNeT6hZcuRA01VbEEJrLAaF/ /pQuQzSY7QJf5iJyuvLSurE7BD1XPV/8bTua1tpUT1w4FAfdx687LMRO5XFWo7D8Ni3Y IYZz9z8b/FBe0NIX5SnkWeeKrSSeau4vW7fYTPqP/VXOHHWVLDtUT9cQ5fVaPV1G/H34 sVahIkCe+s1HWCjQEQnMs5HUa5BLAl0J2u50iMV6lXuadKSOMqRGbtuvaLKpVCK1vpzV tDHwHNvnWHEYJqYx5wAc+FCqB0jemQ4tGvSOu315gsLUkJqBMCCxz3MPpwg+TIz2xXt2 HJDw== X-Gm-Message-State: AOAM5335emqMvbJ1Krteik7VvIFiPkpk3gPVUkP3ojExFux3oWPw3iHM AKMUpTQlOyCklKXVTBwDxr2GGrm3XbJrYg== X-Google-Smtp-Source: ABdhPJx0cwDx/KCohLgI6M+NxwXmPD9FH3fOq0XlGoyIAXjHXWpG50ZwqW72YltK2e2iZMm7+b86vQ== X-Received: by 2002:a0c:c293:: with SMTP id b19mr2799216qvi.22.1632502771245; Fri, 24 Sep 2021 09:59:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/27] linux-user/arm: Drop "_v2" from symbols in signal.c Date: Fri, 24 Sep 2021 12:59:03 -0400 Message-Id: <20210924165926.752809-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf30.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503120015100001 Since we no longer support "v1", there's no need to distinguish "v2". Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 155 +++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 90 deletions(-) diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index d0940bab47..ed7d1d80bb 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,7 +46,7 @@ struct target_sigcontext { abi_ulong fault_address; }; =20 -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 =20 -struct sigframe_v2 +struct sigframe { - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; =20 -struct rt_sigframe_v2 +struct rt_sigframe { struct target_siginfo info; - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; =20 @@ -270,7 +270,7 @@ setup_return(CPUARMState *env, struct target_sigaction = *ka, return 0; } =20 -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 *regs= pace, CPUARMState *env) return (abi_ulong*)(vfpframe+1); } =20 -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); } =20 -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; =20 /* 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)); =20 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 =3D uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace =3D setup_sigframe_v2_vfp(regspace, env); + regspace =3D setup_sigframe_vfp(regspace, env); } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace =3D setup_sigframe_v2_iwmmxt(regspace, env); + regspace =3D setup_sigframe_iwmmxt(regspace, env); } =20 /* Write terminating magic word */ @@ -339,10 +338,10 @@ static void setup_sigframe_v2(struct target_ucontext_= v2 *uc, } } =20 -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 =3D get_sigframe(ka, regs, sizeof(*frame)); =20 trace_user_setup_frame(regs, frame_addr); @@ -350,10 +349,10 @@ static void setup_frame_v2(int usig, struct target_si= gaction *ka, goto sigsegv; } =20 - setup_sigframe_v2(&frame->uc, set, regs); + setup_sigframe(&frame->uc, set, regs); =20 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; } =20 @@ -364,51 +363,38 @@ sigsegv: force_sigsegv(usig); } =20 -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) -{ - struct rt_sigframe_v2 *frame; - abi_ulong frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); - 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 =3D frame_addr + offsetof(struct rt_sigframe_v2, info); - uc_addr =3D frame_addr + offsetof(struct rt_sigframe_v2, uc); - tswap_siginfo(&frame->info, info); - - setup_sigframe_v2(&frame->uc, set, env); - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v2, retcode)= )) { - goto sigsegv; - } - - env->regs[1] =3D info_addr; - env->regs[2] =3D uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - 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); + struct rt_sigframe *frame; + abi_ulong frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); + 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 =3D frame_addr + offsetof(struct rt_sigframe, info); + uc_addr =3D frame_addr + offsetof(struct rt_sigframe, uc); + tswap_siginfo(&frame->info, info); + + setup_sigframe(&frame->uc, set, env); + + if (setup_return(env, ka, frame->retcode, frame_addr, usig, + frame_addr + offsetof(struct rt_sigframe, retcode))) { + goto sigsegv; + } + + env->regs[1] =3D info_addr; + env->regs[2] =3D uc_addr; + + unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + unlock_user_struct(frame, frame_addr, 1); + force_sigsegv(usig); } =20 static int @@ -441,7 +427,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigc= ontext *sc) return err; } =20 -static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *reg= space) +static abi_ulong *restore_sigframe_vfp(CPUARMState *env, abi_ulong *regspa= ce) { 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); } =20 -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(CPUARMStat= e *env, return (abi_ulong*)(iwmmxtframe + 1); } =20 -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); =20 - if (restore_sigcontext(env, &uc->tuc_mcontext)) + if (restore_sigcontext(env, &uc->tuc_mcontext)) { return 1; + } =20 /* Restore coprocessor signal frame */ regspace =3D uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace =3D restore_sigframe_v2_vfp(env, regspace); + regspace =3D restore_sigframe_vfp(env, regspace); if (!regspace) { return 1; } } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace =3D restore_sigframe_v2_iwmmxt(env, regspace); + regspace =3D restore_sigframe_iwmmxt(env, regspace); if (!regspace) { return 1; } @@ -535,10 +522,10 @@ static int do_sigframe_return_v2(CPUARMState *env, return 0; } =20 -static long do_sigreturn_v2(CPUARMState *env) +long do_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct sigframe_v2 *frame =3D NULL; + struct sigframe *frame =3D NULL; =20 /* * Since we stacked the signal on a 64-bit boundary, @@ -555,10 +542,9 @@ static long do_sigreturn_v2(CPUARMState *env) goto badframe; } =20 - 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; } =20 @@ -571,15 +557,10 @@ badframe: return -TARGET_QEMU_ESIGRETURN; } =20 -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 =3D NULL; + struct rt_sigframe *frame =3D NULL; =20 /* * Since we stacked the signal on a 64-bit boundary, @@ -596,10 +577,9 @@ static long do_rt_sigreturn_v2(CPUARMState *env) goto badframe; } =20 - 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; } =20 @@ -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); -} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632502920305783.4540861267957; Fri, 24 Sep 2021 10:02:00 -0700 (PDT) Received: from localhost ([::1]:59138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToaE-0005XC-S0 for importer@patchew.org; Fri, 24 Sep 2021 13:01:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXv-0002dd-Pp for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:36 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:45806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006tj-Fm for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: by mail-qv1-xf32.google.com with SMTP id x9so486539qvn.12 for ; Fri, 24 Sep 2021 09:59:32 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tTWEHxzXUUId2fX/NSdCUm8jXTQGtuUSFGG/XZYirZo=; b=VOCM2nTbaAf0Fx3vPobozgYQV63bh0P3PtyWu4qqmoSMcmJDiCVZmQcdtgg5nc/Kpn 2FdpIOSranUcVQX7PZCMVo2xZyTWODIgK3CS2CbLQNxlroGJ4Tvw52AohfQW4ULU1bYQ RFHoPGhDbDyYOkNAj/mFwnFt2bNm1auMX+F9R86VzUgSC+06kyLvfnoqum+36K/HuUJe TtFBmeOKxvHftD8Zk52XhHGmwWYMxVreGZt2OmSUOGbxCMDut6ELpMh0KgK1vQKX3+RZ LijT7/r0sTqdf8UoOomqZIKxhB8X4QYezz7vcVROFtM/MaRkYS35zHv/+ln/Lf5fdzhe AxJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tTWEHxzXUUId2fX/NSdCUm8jXTQGtuUSFGG/XZYirZo=; b=K3X4lp1FfD9YWKghNa6af0p8NYSADgAKlzeLLoYztnWKq61yD1a9WnW0IiZNmUglKe Yfo8ymv2i6uCXK91+3YB05l0jS1WfUQXsJYbKHQXBk6fSJuaIyo82ynqLEIsfZx1CIzK ayJxfvWAo/nZI4fFLkYXM0xTHMvF4ap6m+X6ZsVlBQfnB5E8uDMfnzY3efgpVq2m5QcA FOOLIoFyYFBlmFmZZQvyai9ICT8lpjWI8NC/rnpBSX8R5ILE2ny2PpeJTTqFTkcIx1Bl CWcIe6pMwBZJl0Je60O72Et89q/x9a+A1svOIWlH8fy4KFYtO/MI7YXwS2dVvfvypY1q ceWQ== X-Gm-Message-State: AOAM531emB7bsQhkXU4TnaR8ftslC9F355zRE/DemRdLmL8Xt5BV4IqQ f4gQ+Sb/Pk3ch9tgeC8BHRvV2wkCPcae0A== X-Google-Smtp-Source: ABdhPJwgGkCCvWc6v7ufaaCb4/J7yAZCT7mID68jiVLWECgQe6BynsckFc/8G/qzf3J3Uni55/27Xw== X-Received: by 2002:ad4:446f:: with SMTP id s15mr11239397qvt.3.1632502771872; Fri, 24 Sep 2021 09:59:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/27] linux-user/arm: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:04 -0400 Message-Id: <20210924165926.752809-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf32.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632502923757100005 Content-Type: text/plain; charset="utf-8" Update the trampoline code to match the kernel: this uses sp-relative accesses rather than pc-relative. Signed-off-by: Richard Henderson --- linux-user/arm/target_signal.h | 2 + linux-user/arm/signal.c | 177 ++++++++++++++++++++++++--------- 2 files changed, 130 insertions(+), 49 deletions(-) diff --git a/linux-user/arm/target_signal.h b/linux-user/arm/target_signal.h index 0998dd6dfa..1e7fb0cecb 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" =20 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* ARM_TARGET_SIGNAL_H */ diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed7d1d80bb..ccfae43028 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -103,39 +103,52 @@ struct rt_sigframe abi_ulong retcode[4]; }; =20 -/* - * For ARM syscalls, we encode the syscall number into the instruction. - */ -#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYS= CALL_BASE)) -#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_= SYSCALL_BASE)) +static abi_ptr sigreturn_fdpic_tramp; =20 /* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. + * 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 SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigret= urn)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sig= return)) +#define ARM_MOV_R7_IMM(X) (0xe3a07000 | (X)) +#define ARM_SWI_SYS(X) (0xef000000 | (X) | ARM_SYSCALL_BASE) =20 -static const abi_ulong retcodes[4] =3D { - SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN -}; +#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); +} + +static void write_thumb_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(THUMB_SWI_SYS << 16 | THUMB_MOVS_R7_IMM(syscall), rc); +} =20 /* - * Stub needed to make sure the FD register (r9) contains the right - * value. + * Stub needed to make sure the FD register (r9) contains the right value. + * Use the same instruction sequence as the kernel. */ -static const unsigned long sigreturn_fdpic_codes[3] =3D { - 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 void write_arm_fdpic_sigreturn(uint32_t *rc, int ofs) +{ + assert(ofs <=3D 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 */ +} =20 -static const unsigned long sigreturn_fdpic_thumb_codes[3] =3D { - 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 */ -}; +static void write_thumb_fdpic_sigreturn(void *vrc, int ofs) +{ + uint16_t *rc =3D vrc; + + assert((ofs & ~0x3fc) =3D=3D 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 */ +} =20 static inline int valid_user_regs(CPUARMState *regs) { @@ -184,13 +197,12 @@ get_sigframe(struct target_sigaction *ka, CPUARMState= *regs, int framesize) =20 static int setup_return(CPUARMState *env, struct target_sigaction *ka, - abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_a= ddr) + abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_o= fs) { abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; abi_ulong retcode; - - int thumb; + int thumb, retcode_idx; int is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->info= ); =20 if (is_fdpic) { @@ -208,6 +220,7 @@ setup_return(CPUARMState *env, struct target_sigaction = *ka, } =20 thumb =3D handler & 1; + retcode_idx =3D thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0); =20 uint32_t cpsr =3D cpsr_read(env); =20 @@ -225,37 +238,39 @@ setup_return(CPUARMState *env, struct target_sigactio= n *ka, =20 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. + /* + * For FDPIC we ensure that the restorer is called with a + * correct r9 value. For that we need a special trampoline + * the reads the function descriptor from the frame, + * sets r9 and jumps back to restorer value. + * + * This on-stack code is unused but retained for ABI complianc= e. */ 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); + write_thumb_fdpic_sigreturn(rc, rc_ofs + 12); } 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); + write_arm_fdpic_sigreturn(rc, rc_ofs + 12); } + __put_user((abi_ulong)ka->sa_restorer, &rc[3]); =20 - retcode =3D rc_addr + thumb; + /* Each trampoline variant consumes a 12-byte slot. */ + retcode =3D sigreturn_fdpic_tramp + retcode_idx * 12 + thumb; } else { retcode =3D ka->sa_restorer; } } else { - unsigned int idx =3D thumb; + int syscall =3D (ka->sa_flags & TARGET_SA_SIGINFO + ? TARGET_NR_rt_sigreturn : TARGET_NR_sigreturn); =20 - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx +=3D 2; + /* This on-stack code is unused but retained for ABI compliance. */ + if (thumb) { + write_thumb_sigreturn(rc, syscall); + } else { + write_arm_sigreturn(rc, syscall); } =20 - __put_user(retcodes[idx], rc); - - retcode =3D rc_addr + thumb; + /* Each trampoline variant consumes 8-byte slot. */ + retcode =3D default_sigreturn + retcode_idx * 8 + thumb; } =20 env->regs[0] =3D usig; @@ -352,7 +367,7 @@ void setup_frame(int usig, struct target_sigaction *ka, setup_sigframe(&frame->uc, set, regs); =20 if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe, retcode))) { + offsetof(struct sigframe, retcode))) { goto sigsegv; } =20 @@ -383,7 +398,7 @@ void setup_rt_frame(int usig, struct target_sigaction *= ka, setup_sigframe(&frame->uc, set, env); =20 if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe, retcode))) { + offsetof(struct rt_sigframe, retcode))) { goto sigsegv; } =20 @@ -591,3 +606,67 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + enum { + SIGFRAME_FDPIC_OFS =3D offsetof(struct sigframe, retcode[3]), + RT_SIGFRAME_FDPIC_OFS =3D offsetof(struct rt_sigframe, retcode[3]), + }; + + uint32_t total_size =3D 4 * 8 + 4 * 12; + uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, total_size,= 0); + uint32_t i =3D 0; + + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + write_arm_sigreturn(&tramp[i], TARGET_NR_sigreturn); + i +=3D 2; + write_thumb_sigreturn(&tramp[i], TARGET_NR_sigreturn); + i +=3D 2; + write_arm_sigreturn(&tramp[i], TARGET_NR_rt_sigreturn); + i +=3D 2; + write_thumb_sigreturn(&tramp[i], TARGET_NR_rt_sigreturn); + i +=3D 2; + + /* + * FDPIC require trampolines to call sa_restorer, and different + * from the pc-relative versions we write to the stack. + * + * ARM versions use: + * ldr r3, [sp, #ofs] + * ldr r9, [r3, #4] + * ldr pc, [r3, #0] + * + * Thumb versions use: + * ldr r3, [sp, #ofs] + * ldmia r3, {r2, r3} + * mov r9, r3 + * bx r2 + */ + sigreturn_fdpic_tramp =3D sigtramp_page + i * 4; + + /* ARM sigframe */ + write_arm_fdpic_sigreturn(tramp + i, + offsetof(struct sigframe, retcode[3])); + i +=3D 3; + + /* Thumb sigframe */ + write_thumb_fdpic_sigreturn(tramp + i, + offsetof(struct sigframe, retcode[3])); + i +=3D 3; + + /* ARM rt_sigframe */ + write_arm_fdpic_sigreturn(tramp + i, + offsetof(struct rt_sigframe, retcode[3])); + i +=3D 3; + + /* Thumb rt_sigframe */ + write_thumb_fdpic_sigreturn(tramp + i, + offsetof(struct rt_sigframe, retcode[3])); + i +=3D 3; + + assert(i * 4 =3D=3D total_size); + unlock_user(tramp, sigtramp_page, total_size); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503123244789.3457021839214; Fri, 24 Sep 2021 10:05:23 -0700 (PDT) Received: from localhost ([::1]:39462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTodV-00039Q-SR for importer@patchew.org; Fri, 24 Sep 2021 13:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXy-0002eH-Dp for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:39697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006uP-GB for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: by mail-qt1-x82b.google.com with SMTP id j13so10052488qtq.6 for ; Fri, 24 Sep 2021 09:59:33 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=ud9lf2mY1kqgyV1OUwTUDcnBBvctQRisFqCtOvkpLfvkZuAFZyOT0ocd6QCPyB/d5z BqEyBG7l7VGVeIwexC5E7oP5JLMrEez13+7nhB9ciddNS0dwTh/P9JatLwaCuV9I6pLS 1+1FftaAZDdeqRlKXGMhnIUCygfUYW65vcj/pDIHLU0KHwfX67Qn7oEzhbF3I8EdUeuB EEKBhtm2yMGIZmRChWlr31hccJ0yIneMaNI9A82OGGJl8wuJE6yTznl4PAui1REJTace BGHThyj9pX3eCm0S93+8u+zJOZxjXrWswnG4uBUe80BXLJO778aC2pLb02BQ4iAEIMmz u8Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=Xs8Wg49WJHE5FM9c/oXmYZrZLIsg0q/mBFCjBudvxJInV55VYMkBOuT7ADT7Nbv3HJ 5CEhJllcde8ovl+zVGgEysDTWivnLmtI3HQmhBKlGdoNLZnk4YmvV8GEPuaDySnI7lTa yN51hLSt1CvIjUQoezEUXr2REPlr6HiTIfUviZG9qnWD6Mou404f/e2ce8ftXrHA5cr9 I62p45NeyA/q41uWm5NAShNpC0e6SdkDfv9yubzjK42Jh0yYbrYI+rXBQYUVg1ftW3t2 ynXyEKN2Chz4gB6a532I8PeRGOTxm6xeb4fWYqO3WPPbUZ0Re6mteX7R1WgbjNkpHrsX QxYg== X-Gm-Message-State: AOAM530D6W7rrk9cCtyWiI19MJhc8w1JVFNNf6+gw7U8WsLe+yubSNAe /55wVAbUXqAw9UHzuCDbmhngixsElM8Xeg== X-Google-Smtp-Source: ABdhPJyykPGKRx5pp/IsyT3tpes0bN+ZMUt4yPaER/MS2arbjQ8fc2GeAm3zqozL0NqQlZ0UEnf62Q== X-Received: by 2002:ac8:7741:: with SMTP id g1mr5283788qtu.366.1632502772511; Fri, 24 Sep 2021 09:59:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/27] linux-user/alpha: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:05 -0400 Message-Id: <20210924165926.752809-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503124361100001 Create and record the two signal trampolines. Use them when the guest does not use ka_restorer. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/alpha/target_signal.h | 1 + linux-user/alpha/signal.c | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_sig= nal.h index 250642913e..0b6a39de65 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -93,6 +93,7 @@ typedef struct target_sigaltstack { =20 #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_KA_RESTORER +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 =20 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling = */ diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 3a820f616b..bbe3dd175a 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -55,13 +55,11 @@ struct target_ucontext { =20 struct target_sigframe { struct target_sigcontext sc; - unsigned int retcode[3]; }; =20 struct target_rt_sigframe { target_siginfo_t info; struct target_ucontext uc; - unsigned int retcode[3]; }; =20 #define INSN_MOV_R30_R16 0x47fe0410 @@ -142,12 +140,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 =3D 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 =3D frame_addr + offsetof(struct target_sigframe, retcode); + r26 =3D default_sigreturn; } =20 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 =3D 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 =3D frame_addr + offsetof(struct target_rt_sigframe, retcode); + r26 =3D default_rt_sigreturn; } =20 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 6 * 4, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D 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 =3D 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); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503323799128.4263276180891; Fri, 24 Sep 2021 10:08:43 -0700 (PDT) Received: from localhost ([::1]:47936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogk-0000ZX-Fq for importer@patchew.org; Fri, 24 Sep 2021 13:08:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY0-0002ep-3v for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:41 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:42613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXu-0006vL-2F for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:39 -0400 Received: by mail-qk1-x734.google.com with SMTP id t4so28576879qkb.9 for ; Fri, 24 Sep 2021 09:59:33 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=eXml2nXat9+Vihtlw6ZwnOLHOSI6g2gFXnIN6qzzVvp+XuCFeRcQUm7FYmiHLZx+T3 nyP/C4ulaqfdsDm6PiQH/NjtqlLqtHDDRPFdUB34RoOogjKONQ/Yo1RhfM0hfoTD0wsH PmC+7evT+7/GZb8mtMrv9gLBb29GtrqU9sGdD8jVIC1vUtPMQ4ojJHzrr906UmgZTNSi kG0ZBPRl/XBwvKdCl3Z19YJ6zthA+jwi33xOgOMx6PNH4PYjkCPTb6EoyQi58Shm0Pjn 1bipsOKuCgA2DBw408s4EYxkFuhIEkCXD/Hq7D9490UxnGHuuyKrLSt2QJnxxB8Ok2OR F6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=2Wkq+O5UvgpPfddzliuJ9NTVOmKgwbgTXreua2rSmstmo6+/9KwTyQxsyDAj6jo7nw ERbqFzK19mnlqeLRkTM349RZ2XZqOOqNm2DlDQs5F3C7L3pks3lM2GYuDpTTYpPW81AK YbzmY9AmLKcDdEk3zYyXPKxv7iVQxpkgUn8dk7kwTstwaX0EyzPvuAsHQlZhPhtUtmJr +vqCXlOmv1gB7Nsa53g8kswh+aOwAmMJ8rnBvIz5pJL6jy7/oYZpo1xJU5pUzSmkCUV1 rZckTxyYn3JFgrwy01AGEU+zKGf626zuc1OLgPCVyksioEdbk9Z25qmUsPN8HoHujvEW xvaw== X-Gm-Message-State: AOAM532oz/073c9U7Dg8BQp1njK6qdqt4whQxCZtw1dh71YAmDjY9Zpy VJkRna9WPofvpGHLP8M4Nk2Lq5zQIRRIuw== X-Google-Smtp-Source: ABdhPJzXCoE1Zr8FK4ghZFUCDxR1/OVKedNqlMgPLNtu51765q9w7Z4EVQbILJkxSh98bGn6io6EgQ== X-Received: by 2002:a37:c42:: with SMTP id 63mr11738951qkm.104.1632502773217; Fri, 24 Sep 2021 09:59:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/27] linux-user/cris: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:06 -0400 Message-Id: <20210924165926.752809-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , laurent@vivier.eu, "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503325665100003 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=C3=A9 Signed-off-by: Richard Henderson --- linux-user/cris/target_signal.h | 2 ++ linux-user/cris/signal.c | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signa= l.h index 495a142896..83a5155507 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" =20 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* CRIS_TARGET_SIGNAL_H */ diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c index 2c39bdf727..7f6aca934e 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 fra= mesize) return sp - framesize; } =20 +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); =20 /* 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] =3D sig; env->pc =3D (unsigned long) ka->_sa_handler; /* Link SRP so the guest returns through the trampoline. */ - env->pregs[PR_SRP] =3D frame_addr + offsetof(typeof(*frame), retcode); + env->pregs[PR_SRP] =3D default_sigreturn; =20 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + setup_sigreturn(tramp); + + unlock_user(tramp, sigtramp_page, 6); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163250332690965.5502429833274; Fri, 24 Sep 2021 10:08:46 -0700 (PDT) Received: from localhost ([::1]:48318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogn-0000pJ-Sq for importer@patchew.org; Fri, 24 Sep 2021 13:08:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXz-0002ej-4N for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:39 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:35522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXu-0006wI-Ur for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: by mail-qk1-x72a.google.com with SMTP id c7so29003543qka.2 for ; Fri, 24 Sep 2021 09:59:34 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=jbqpXiP227iB56KT34GI22QoNKWUmiAL5m0c+fZrYQg9FlTNcu4p5uznvNQNmGexYW aqn7/0JXtTqFHPjdthtVhhyHZ3CWwEPE+cKlfOCaOhh2jyjMKG55xq+uc8YiU/derCI6 U1uhgkf/r1E4r7ZlJdDavHUGL8JwAs6jKdBYxAzSH0x/QtXKLtrIuuc3NdBDw0hnPGBM hEg/I+492spSjz6JKJ7SdW4cd1+U5KOl18jhnaAgE09qnjjXpG4FhGoErpDk4rmIWT2B nFvs1kesh+8vNiN8thn0+hHTcHfDKVyTAfdOk0Z8YigkMtwS5R5zlAZ9S6H7lAfBhLEs esxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=t21JrUq9u7Uofb1gNE//cBbBeS7bfiwxQdBps/suAKsniVz/DIeEzoozMHclFOkcMG zdIsRKAtAm15tZ98f9NG+2eHmEN5rTTZ0SAZdlCPUz61n9DgM1p/PyKTWpqeS7eAmuUa RWVdtfl7tkSmCSfQBU3xO4bxFfdosDK/qds/dqDbD4xN3Yg6pdJK4r6pF51OsA89dr02 bRYuG1HX3rYRlM33DcqiTIWgxNJBG7Qs+p+pwamwiz7rdlhPGcPXsdV7xShyq8JPuHvP FwH34+796NoqXx4L1yGOXFQRyUkn2niP08Bt8FOLdVchVB0v6FBAD5S/DeV+6sCIILq+ OO+Q== X-Gm-Message-State: AOAM532etQCQzCJ8DIaNJHR4fn/Bk9YkZzliEHzu00YvtFpMLFFQnVPj wzN0wBREjBaTL9uWOPguREQ0FKVBaIkfVg== X-Google-Smtp-Source: ABdhPJy495whHwjMo7cor9js8CEzqpkQ8wHBjCmkFtIzIhG4SlxDqKbuUh480GfAKZw/xkfcPS50gQ== X-Received: by 2002:a37:9606:: with SMTP id y6mr11326294qkd.13.1632502774021; Fri, 24 Sep 2021 09:59:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/27] linux-user/hexagon: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:07 -0400 Message-Id: <20210924165926.752809-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, Taylor Simpson , laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503327947100008 Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Taylor Simpson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Taylor Simpson --- linux-user/hexagon/target_signal.h | 2 ++ linux-user/hexagon/signal.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/linux-user/hexagon/target_signal.h b/linux-user/hexagon/target= _signal.h index 345cf1cbb8..9e0223d322 100644 --- a/linux-user/hexagon/target_signal.h +++ b/linux-user/hexagon/target_signal.h @@ -31,4 +31,6 @@ typedef struct target_sigaltstack { =20 #include "../generic/signal.h" =20 +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* TARGET_SIGNAL_H */ diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index c7f0bf6b92..74e61739a0 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, =20 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); =20 env->gpr[HEX_REG_PC] =3D ka->_sa_handler; @@ -171,8 +176,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[HEX_REG_R02] =3D frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[HEX_REG_LR] =3D - frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[HEX_REG_LR] =3D default_rt_sigreturn; =20 return; =20 @@ -271,3 +275,14 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, 4 * 2, 0); + assert(tramp !=3D NULL); + + default_rt_sigreturn =3D sigtramp_page; + install_sigtramp(tramp); + + unlock_user(tramp, sigtramp_page, 4 * 2); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503481551682.7240796908735; Fri, 24 Sep 2021 10:11:21 -0700 (PDT) Received: from localhost ([::1]:56862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTojE-0006YA-NI for importer@patchew.org; Fri, 24 Sep 2021 13:11:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY2-0002fZ-3D for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:41541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXw-0006x0-Mw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:41 -0400 Received: by mail-qk1-x72e.google.com with SMTP id m7so11925475qke.8 for ; Fri, 24 Sep 2021 09:59:35 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=y1R55l3yDenfrNbpwSVjFg0dDYxN3NAVRc4/S5F6XCa3I1mbBizZCnYiqMdkoIiP5J 6M6ipzFF+AG2LVcdEVBcSRVKqMYrjNZYLhY5xIvFNqNghP+cYi6pjc1/fonXga4F/q3U OfzGz8CMN/oJ8UxLCraq2npbYiNwUCCHuMbkPWPxtvLu7VsIychWmtoKnfJw2MVNoUQY TeF4odtEcCqz3m/awjef3Q+k03djVl5WWA6vz3CSdv81jm7N/gehtIMQidr7L0Xxdx5F IsbcJcGGYe+3LZFzVr2Cow1NXfaTbfjULbvoMjwDwy0H+BO6Ism/oGJhft0FqNwtfFzI R+Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=30jGSA9WAC2MBZmKLhTQ5/ISOuT9z7asZcLVOY8+LGCpIOe4XGp8C8p0VhCLZLcMso wIZYYsUqMOpB+Zr7+vvlMHRdseM+pNaCb/P23NzrDD50KlgpccYJj0KjQ38d5YafdJFv mH+FfFY/2AI6C9XHQbYCu0MvombvUHtP7ajWEVmDHDjPtvRdmMBUSOKwJAIOUVUiFeIn dSkxaxmAHFH1NsBvsK/6SB9bO776aRxbfu2QKv8ltkk8LXGp5nom58XpXivWj5j/9j9H D4ednnFACOSkY6dG/pB2c9pHCsbTCMq7+Lc7r3sQCY5MrdZsPb1UeLp3o6MJXt0toARI F1SQ== X-Gm-Message-State: AOAM532NBtOzZLOuT/gOFGUFphihIV1sHYbEGBdMYdfFak14Yi8pGJgh mJB4iG1rNmkoy5335/ZoM5KX41/7azLiug== X-Google-Smtp-Source: ABdhPJwrAeKbWbscNeC9hhJdJpelF0X8l7V28bM6GecKbHCTeJ3iFNz73miTOtQNRKe8Gjveah6IRA== X-Received: by 2002:a37:64cc:: with SMTP id y195mr11350785qkb.97.1632502774804; Fri, 24 Sep 2021 09:59:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/27] linux-user/hppa: Document non-use of setup_sigtramp Date: Fri, 24 Sep 2021 12:59:08 -0400 Message-Id: <20210924165926.752809-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503483088100001 We cannot use a raw sigtramp page for hppa, but must wait for full vdso support. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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_signa= l.h index 7f525362e9..d558119ee7 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 =20 +/* + * 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 */ --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503650395950.7576669230883; Fri, 24 Sep 2021 10:14:10 -0700 (PDT) Received: from localhost ([::1]:37122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTom1-0003kp-8W for importer@patchew.org; Fri, 24 Sep 2021 13:14:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002gK-2K for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:44749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXw-0006xG-OF for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: by mail-qt1-x834.google.com with SMTP id r16so10014205qtw.11 for ; Fri, 24 Sep 2021 09:59:36 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uNdU6ybIJfer/a+2lnb556GEnq4khU62qRteMioxBnA=; b=c6rBbSE92Bl275CCX6hCTkSHXu871oEY/WrE2Ftsa1Xk9LuMFvOtrO6hao3B7CyKMQ vEzbOrOvLBRAoSldiepRD7SWr6DYA/7a1H+93hAmw1pgQUdeIb+oyZT1B+OVWc/IIycE bfUyGaSD5BvRErSXfB4Nj5ksEm+BF9ESKHWhdJV4ZJPHJ9/0OKYUt2biIU/q+SkOEuDE 2522sgkbpORXaF2KZcgzJ0GR/xE+gtWBucbC2i8eIabCM07rLB4DyYSJzKKHAyG7tGCP JI/WSBydWGveNmjAhPkjJk2hPGwFpi5/PWEp83pjpzdqJ8FbH6bXLkFbX4J9C6sZqeIa 6nTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uNdU6ybIJfer/a+2lnb556GEnq4khU62qRteMioxBnA=; b=xwNvtkJnYVT0DaKfooqlpxs+Setg58x2K4NSJDM27YGgkMrtYYo+Sy8aoqHzcoPkGF wmqNib1XOJBjYML8lJDimW7jiuAVEfD72ILD/KuNVHI2mRJAWlmDVjT4z8LeWWYV0CEG pjmgwOCME3go91cGGgbNtFrjlmKFdcK12qpdbrb1xuinzTNVFeafYTa1xNGrjYPRivpf GiOrxcGn53N8prVlgxxn0KPnXEJWmJmwTugmQxENj83x3QEHzeqJfXYBXG8YQHezbX48 PveHMadMwZwlGdp9TJNSyTKi7e90VM+T/T5/TlIu7NmL/MnsYXJiQ8gBGFS2JoxUdAVX 3WIg== X-Gm-Message-State: AOAM533S8u32330FGRKuvqZTT4EwJEUMQTgPK+qHlcwFMgQhv0IKnnUc JzGHbwMAmSNns9/OXnKhfSx+SneYn4LGZQ== X-Google-Smtp-Source: ABdhPJwjVXGATNNtNl05aJiBSzvXatslyG0KeCmZPxhdLcD0oQfdTYGDWfsloYP6Bi274aLU6RMKqA== X-Received: by 2002:a05:622a:11ce:: with SMTP id n14mr5291983qtk.374.1632502775487; Fri, 24 Sep 2021 09:59:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/27] linux-user/i386: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:09 -0400 Message-Id: <20210924165926.752809-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x834.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503650933100003 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Richard Henderson --- linux-user/i386/target_signal.h | 2 ++ linux-user/x86_64/target_signal.h | 3 ++ linux-user/i386/signal.c | 56 +++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signa= l.h index 50361af874..64d09f2e75 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" =20 #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_s= ignal.h index 4ea74f20dd..4673c5a886 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 { =20 #include "../generic/signal.h" =20 +/* For x86_64, use of SA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* X86_64_TARGET_SIGNAL_H */ diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 3b4b55fc0a..94ab6396a0 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) } =20 #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, (int *)(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, (char *)(tramp + 0)); + __put_user(TARGET_NR_rt_sigreturn, (int *)(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 =3D frame_addr + offsetof(struct sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - /* This is popl %eax ; movl $,%eax ; int $0x80 */ - val16 =3D 0xb858; - __put_user(val16, (uint16_t *)(frame->retcode+0)); - __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2)); - val16 =3D 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); } =20 /* 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 =3D 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 =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + install_sigtramp(tramp); + + default_rt_sigreturn =3D sigtramp_page + 8; + install_rt_sigtramp(tramp + 8); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503480686671.3997602297317; Fri, 24 Sep 2021 10:11:20 -0700 (PDT) Received: from localhost ([::1]:56788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTojH-0006Ty-MC for importer@patchew.org; Fri, 24 Sep 2021 13:11:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY2-0002fO-1f for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:46693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXx-0006yT-1b for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:40 -0400 Received: by mail-qk1-x735.google.com with SMTP id b65so28387706qkc.13 for ; Fri, 24 Sep 2021 09:59:36 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ULwFc4fsoMDCKBA2xVTYfXV3nCZVlLyz/guJ8iaI5Rw=; b=KNu6QFb8ex3Ct5FPynmI5DxsbDncOGuIO75EcbmuBF3jbNt79pVcljFkepUYRi89rO T5UMNy6uW5nTrHuYDBMgZwrmoISGPZe6kiQp0xy5LF+HWtCCMT7DOJ4sguKFJWpljxhM 2KXBSdTH8kL/7VW3XeldCmoAwG29i1N8Vbrho6GOYbxHe2olKfoaMEDUBza1wZp2ucAS 8XGJIWh8Ii1Ku5gYSPjPDFJ0m/nodFfUTk1yDhJmgXanietodh1iFKYYpN2TCA9QklAl GlStyjvcnxJ/rbHv3+WQM7R56QBOsiWnfZ5w0wcMfpNgyApkeK4AmsKV23ZjsC1BmMS5 YOOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ULwFc4fsoMDCKBA2xVTYfXV3nCZVlLyz/guJ8iaI5Rw=; b=GEFIOWiOK8W+UIZSB1YY2J+FSiDoyCNqho+HYaisMdfddBSbzgm4/URA8bT82C5zUc cF5+qvgu00iwoSGQRHYwNrOg6YTjjgMCnWzs24OxM9w8MicRoXkQPYyVj1hPjceRiIUa c4thMS8e8Oc0bmheDvm7khU5Iw5U+2Zeu2XmyJQIDpusY2G6Zrr4d6ZER8e7bc+UnwRs HlQOQFbByCpxt7cLN5aw2Ro98NCFZqidUI+67ZLdTOX+03uhe0S+e95DSGh7JMV517LP K/T9RALuWxudBZ+x7wMrRGcBfiWA3NBfYiMEMsJ7W0pGqCWe3EI8ORiltoY+KPP924cU ybuA== X-Gm-Message-State: AOAM532jTHIdIcEiHcLOPmpXiAmJmhjYSRA6FPaLIp08kcKBu6py2r2x vyrI+U4ANPoFYf1K00JDayNCERhgq5UCMg== X-Google-Smtp-Source: ABdhPJzcnoalMdne+5oRp7UtFqy+6h36uNZTRqcWD6U3swv/tttfO+0VUyb4uwjbpVSLvNW+0HtWIw== X-Received: by 2002:a37:b703:: with SMTP id h3mr11870358qkf.240.1632502776173; Fri, 24 Sep 2021 09:59:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/27] linux-user/x86_64: Raise SIGSEGV if SA_RESTORER not set Date: Fri, 24 Sep 2021 12:59:10 -0400 Message-Id: <20210924165926.752809-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503480983100001 Content-Type: text/plain; charset="utf-8" This has been a fixme for some time. The effect of returning -EFAULT from the kernel code is to raise SIGSEGV. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- 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 94ab6396a0..55a36476d1 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, =20 /* 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 + } =20 /* Set up registers for signal handler */ env->regs[R_ESP] =3D frame_addr; --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503119834566.6936457788286; Fri, 24 Sep 2021 10:05:19 -0700 (PDT) Received: from localhost ([::1]:39672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTodS-0003Hm-Kd for importer@patchew.org; Fri, 24 Sep 2021 13:05:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002g7-Uu for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:33763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXy-0006yk-5O for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: by mail-qk1-x72d.google.com with SMTP id d207so29102448qkg.0 for ; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=dISEU4PH/27FdDhhEsf1d0QKp+BVBsRGrWbc3P7OWRVlryT8cR5Omcl6DCRfebKmVj NL1UJin65msHDdhmyGVFQRqHVcLqvydNF/pR9BYZaC/P7VdyhfViWPdnnfR+BBBs8VbQ yb6/3bKx2Frk/f+b7jd4yFDhdI1+7vECVls1ChFvfPvHY01+QlhHvFOBLvbW6NbE4bT0 7cZxHP6p8ThR1+knIxiDx5yL3XG4GlZYcproKjGSzqk9gQAzLuYKD+z5cVEZqIzJlRYe N2uTocIJPjP+kBkX759yS6K7bl8qzkj+rGS4/0QMSoTCB/Cgr4PKBoDVaZIOSt3pEQtg i4aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=pFiSt0Fbfbp6yvehJMot6YE/FzgSk8P1uebQr2HPJ6W3jZcg4iD33ylOQJS5FCaBIq EcXH7UoAWKrYxIzUehVGSViQ+br8VqDy+iunxEoykbtEroIAzAVihDC89AYcO2wgnnDo thEpaqhl/yNcjcmP/u2G6MtcFOswmDwSyCXVb6hbMpDFlb3LiJ8CQnWRdcmAWZCjXce9 yAy+FW+/egkWZ1OPoP6nyMwnC+05yqxGiOD1aPOjiOcCdFKkJGc+nARHRUjyEJzqqu73 4umLPhRtLGfH54ifYHSiYGqxa1M77czJmU5Qn5yHTmONI7jlBiBvbX4tU1ZpqS6JinFU SlBA== X-Gm-Message-State: AOAM530bIIv7QVfSeJ5gm1ct6AJCkrfezreq7tjAy43jTrlPAJ+AitxM nTfuU377l9DWFnInVltcc7Us8yBdr76W6Q== X-Google-Smtp-Source: ABdhPJyZ+YPJB2wxro6fNB0/RKmPcxIUc9f5mwDiIaIcjBWNzJgcuqdgwt4eK0ey9+A34NL31vOudA== X-Received: by 2002:a37:a495:: with SMTP id n143mr11406693qke.339.1632502777017; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/27] linux-user/m68k: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:11 -0400 Message-Id: <20210924165926.752809-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503122016100003 Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/m68k/target_signal.h | 2 ++ linux-user/m68k/signal.c | 47 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signa= l.h index d096544ef8..94157bf1f4 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" =20 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* M68K_TARGET_SIGNAL_H */ diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index 4f8eb6f727..ec33482e14 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; =20 @@ -152,16 +149,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } =20 /* Set up to return from userspace. */ - - retcode_addr =3D 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); =20 env->aregs[7] =3D frame_addr; env->pc =3D ka->_sa_handler; @@ -288,7 +276,6 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err =3D 0; @@ -325,17 +312,7 @@ void setup_rt_frame(int sig, struct target_sigaction *= ka, } =20 /* Set up to return from userspace. */ - - retcode_addr =3D 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); =20 env->aregs[7] =3D frame_addr; env->pc =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp= ); + + default_rt_sigreturn =3D 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); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503326726248.03405599254359; Fri, 24 Sep 2021 10:08:46 -0700 (PDT) Received: from localhost ([::1]:48280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogn-0000nI-Db for importer@patchew.org; Fri, 24 Sep 2021 13:08:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY2-0002fi-J1 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:37455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXy-0006zQ-LN for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:42 -0400 Received: by mail-qk1-x730.google.com with SMTP id 73so28870149qki.4 for ; Fri, 24 Sep 2021 09:59:38 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=zVH3lMoenLl4YiqnnqqgeZ7ttEm0hnZOlGueNBSeUaAjjJXy21eC9UAhtAf87totyx x0Bbn7cBm+VJzCDMbmOaW9IgG9AwV0Z8jTCZoGZS3ue0kl66al9NtKIbrAhVuBr+WRCP KHmSlRgeO3K7KYaWzUsiMEl3EtHECSG8cDd7Pgi0ubUhkEWheb+9Figdzi4qNMEA750o 7oa1scl0OEEBMdyX8IClI75CE8onpSJfS/P7xi5d8pmPyoKyWtgUi70w26vdJpQOyz/I ITvF0BZhPLRiMXAqQxu2QcW4guD02UtS4GVKIP4Fn5QOxyD8Rjjn2wvlHqNUOM8/Em1t UjLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=4XYRImmUTxNHlg2oS/H66cCntdHzOD6PjMj/LzKgUYpyY4Wwg5VeXFZzIWXXiu2dyF kAvdstQ7S7aTEozjRPjVd1CZHxBFp+M0DsBuST7ahOLRnTL/VnZHrpe3aroIdx2RmM0d L06Oji5FFWSiMomSgZG2y3tHteN9Ozh/EMitSfY7HyGknWco7cN3Y1C534jXR9+nh/UR grp8qhFE9+PyfhfY+p2vZzCiN9GiS7vAOLMpxz4t6D9USTZc7DtduSy3lElx7az1ndtJ GG6um7I7uQApDquwfUa6yl3O1HYccSt1+6/50XerqOcOP6E9konmviV5eAFliMQEtsF1 ck2A== X-Gm-Message-State: AOAM530NspMks1JBb4bIMdYr+Me3iXnEcyc4bIp1BpMH0iEw60A0xZsf YsIF64VCxDb2NQ8AkhldbEQvtHh8sG4Prw== X-Google-Smtp-Source: ABdhPJz/xo6dPff/C+fgOYvFc/PLc9yvCDnQe6dzI4ANUAuWZOYAjar3yoMrZFLym82XunDypiHGNQ== X-Received: by 2002:a37:c83:: with SMTP id 125mr12073152qkm.229.1632502777804; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/27] linux-user/microblaze: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:12 -0400 Message-Id: <20210924165926.752809-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , laurent@vivier.eu, "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503327910100007 Create and record the rt signal trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/microblaze/target_signal.h | 2 ++ linux-user/microblaze/signal.c | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/linux-user/microblaze/target_signal.h b/linux-user/microblaze/= target_signal.h index 1c326296de..e8b510f6b1 100644 --- a/linux-user/microblaze/target_signal.h +++ b/linux-user/microblaze/target_signal.h @@ -21,4 +21,6 @@ typedef struct target_sigaltstack { =20 #include "../generic/signal.h" =20 +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MICROBLAZE_TARGET_SIGNAL_H */ diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c index b822679d18..8ebb6a1b7d 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, =20 /* Kernel does not use SA_RESTORER. */ =20 - /* 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] =3D - frame_addr + offsetof(struct target_rt_sigframe, tramp) - 8; + env->regs[15] =3D default_rt_sigreturn - 8; =20 /* Set up registers for signal handler */ env->regs[1] =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp !=3D 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 =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503812855412.01707821609716; Fri, 24 Sep 2021 10:16:52 -0700 (PDT) Received: from localhost ([::1]:45474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTood-0000yC-R4 for importer@patchew.org; Fri, 24 Sep 2021 13:16:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002lP-CB for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:46683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXz-0006zu-Pv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:45 -0400 Received: by mail-qk1-x72a.google.com with SMTP id b65so28387831qkc.13 for ; Fri, 24 Sep 2021 09:59:38 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=vM90U61z9hv+oDAyRUPgTyDwsHvXpznhYBmtvW5yH+XsViEzxYZsj536RuJyNbWYl/ ods1E4qeFHIJtFTo/G16OA7A7SZBdhpAzbpKbd3VdexDhrNhTHYObaiGcifYJBfdj0NP Om0Zo2Nk5iUUoyfYEoDRO/Po6G1Qsp3i6QdPZyE8FeER6o3RGu+AyTP/0R6t8JhKGGtF EExfsOVAPx+OInb8rCUPpNwyo8qOou6nX0grkkFzREXBjlMeVPSDHwuyqq25CFay96b1 63+GtoTTz1jqRZg9fg/iZIQEavbLQwRFDBIr3vmNiLYDf3s4UCxSSEqVRII6Gg7dF8H0 dKWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=kKvR0dQQaU7Efrd4B/S7BIFbeq7zInj0aIZDRhQPGbKgPrOYs0B9BTDLe9nRZ/PgGL KvHxH+sXLCakFarWwcYGxC3J8ZdvQgFM22Lv2k1IbARlvNIrGz4qtWMfYuacPoX80pF3 elcwPieM2cuZeDVOHL9UcVnY0EXKKvajgLgyOOfDN1DfFMBVC9Xh+OXoXY26KG30Y9cN n6XaEpPqt+0jPKkSF5XG0/Z+LabpvLlMTNRq/6qhZhk8oTJi8PJBGgEiOnvha20sMqUv Wec2+t/EVytIPdqo+ioUxBioiTsR9rQWa+T14nDBBJ1vGUBmOaISbnbbYr0cDVSdy6u8 K0Uw== X-Gm-Message-State: AOAM533VDkIRAFwwEHUGHBqlVNVrNnH4+0vmapjr6jYu/XUr9Jw/B5So DIzDTvhPpPmG4isQWzjRzchyzA7daIMTqw== X-Google-Smtp-Source: ABdhPJzIWlj1V9xR4tyXRO/kJH/wEJ8dznA+4ojwBYbrB+wDhU4dLVct98MWwcn99ZWGpLpXgN5DZA== X-Received: by 2002:a37:a904:: with SMTP id s4mr1620915qke.60.1632502778459; Fri, 24 Sep 2021 09:59:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/27] linux-user/mips: Tidy install_sigtramp Date: Fri, 24 Sep 2021 12:59:13 -0400 Message-Id: <20210924165926.752809-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503814899100001 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=C3=A9 Signed-off-by: Richard Henderson --- 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 d174b3453c..64072779b9 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -87,10 +87,8 @@ struct target_rt_sigframe { }; =20 /* Install trampoline to jump back from signal handler */ -static inline int install_sigtramp(unsigned int *tramp, unsigned int sys= call) +static void install_sigtramp(uint32_t *tramp, unsigned int syscall) { - int err =3D 0; - /* * Set up the return code ... * @@ -100,7 +98,6 @@ static inline int install_sigtramp(unsigned int *tramp, = unsigned int syscall) =20 __put_user(0x24020000 + syscall, tramp + 0); __put_user(0x0000000c , tramp + 1); - return err; } =20 static inline void setup_sigcontext(CPUMIPSState *regs, --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503813525652.7692399847516; Fri, 24 Sep 2021 10:16:53 -0700 (PDT) Received: from localhost ([::1]:45518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTooe-0000zs-HF for importer@patchew.org; Fri, 24 Sep 2021 13:16:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002hT-8K for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:34376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY1-00071A-RZ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: by mail-qt1-x829.google.com with SMTP id 2so10095821qtw.1 for ; Fri, 24 Sep 2021 09:59:39 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=ZSoWJQ6iTMEkoSktMtaIQuTX41EcJ9GIq6ilGSxW5bucuCGbYejCOmEdCdxb/VzQSy pGO+OAMkFhZPTa5/S3EC/zjsLVi4+QWp7dFhkGXfa4CdTcfn5wRKcgviKQcpfFr/JBcx weOisHw04m1KU4GjgrpNN9dYnSgYtuZHUqtHLsYfXJgPQkPenEwve/Jfek3CL/qtJ1uB hJAt3Fq+O9mZufP6M/egdTdUGWtjyUd98tfayzeMGG7gdXFX82mOzAByd/7xjqgY4ROp SXs48lilT+YcG3L734Lkjd3cf5vBqyumPsZ9Z1vk+TCJRthsLB3GKe1jSHZFkf62ocNm Xs0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=nEIYUDTxzMtmy9WHJNGDoBGDlQ3evlWff3GGIqP1yahBDVakMrB2KrM+dkPTYKFWAB HTLTHURiH7IWda+sbjzn5WBcWoSoRyNVwF4bishmo6Pl2R0yOE+1lyI9m3+yBy8LyUu+ V6YiKpJ4YUdFNU1MVo5VYQF8TTSOOwhBtleyWmBD0/RjG55USMnBVkCHnfE0EkdN7xh6 pE67+J3if9IgIGJ32SqrQ72+TNV5cbGdkkVnwRb6rPrfd9vb6+CQtO4CZKE9A2HlP/4f SPe3Wlylc971gw8kaLP/R7iarMKPuK51j1uP7pZmHw5szBOMuNq3nsjJ2jiUYWENwo6j xICg== X-Gm-Message-State: AOAM533fR3lzqzlIR44NCIFOq3y5Gc7WFsqaJNYx47m8FrK7YdEd0Uv/ cGK67Zo9Am2Rs1ckxBfCskSW3t5ilQaAlA== X-Google-Smtp-Source: ABdhPJzq6gCRutuqbmu2ZoHcpkwPoEFj53+dIpHWFH02y3FafTvV6KKO8ElDSWWe+dlLpoF97suxlg== X-Received: by 2002:ac8:71d1:: with SMTP id i17mr5231103qtp.210.1632502779205; Fri, 24 Sep 2021 09:59:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/27] linux-user/mips: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:14 -0400 Message-Id: <20210924165926.752809-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503814917100002 Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/mips/target_signal.h | 1 + linux-user/mips64/target_signal.h | 2 ++ linux-user/mips/signal.c | 34 ++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signa= l.h index d521765f6b..780a4ddf29 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 =20 /* 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_s= ignal.h index d857c55e4c..275e9b7f9a 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 */ diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 64072779b9..8f79e405ec 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; } =20 - install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); - setup_sigcontext(regs, &frame->sf_sc); =20 for(i =3D 0; i < TARGET_NSIG_WORDS; i++) { @@ -231,7 +229,7 @@ void setup_frame(int sig, struct target_sigaction * ka, regs->active_tc.gpr[ 5] =3D 0; regs->active_tc.gpr[ 6] =3D frame_addr + offsetof(struct sigframe, sf_= sc); regs->active_tc.gpr[29] =3D frame_addr; - regs->active_tc.gpr[31] =3D frame_addr + offsetof(struct sigframe, sf_= code); + regs->active_tc.gpr[31] =3D 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 *k= a, goto give_sigsegv; } =20 - install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn); - tswap_siginfo(&frame->rs_info, info); =20 __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] =3D frame_addr + offsetof(struct target_rt_sigframe, rs_uc); env->active_tc.gpr[29] =3D frame_addr; - env->active_tc.gpr[31] =3D 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] =3D 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 =3D env->active_tc.gpr[25] =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp !=3D NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn =3D sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); +#endif + + default_rt_sigreturn =3D sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632502947350954.3023411442024; Fri, 24 Sep 2021 10:02:27 -0700 (PDT) Received: from localhost ([::1]:59454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToag-0005jj-3s for importer@patchew.org; Fri, 24 Sep 2021 13:02:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002gU-TI for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:33406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY1-00071g-RY for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: by mail-qv1-xf34.google.com with SMTP id a9so6724748qvf.0 for ; Fri, 24 Sep 2021 09:59:40 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QyWQEo+8inM5iDruY826QX36+Q2J0PKidDJBY0ejKxk=; b=ObdanfZr1BcgLUvvWkMdYOEO77IQ8AWjbRSBuQ9axysAmhzOLHSO/AC2bBSdrUU1Gl lExrkwmAVuiGcYDZWzXUr+qVPxytPecQhQ80w0hC+99tJ29W2XKzr/5hR6sRvxoF/8BD dvSMl467KFLfOcqUnHSeQquGxfVa4yKf0Di74reozUbBN/JvxmAb2vcfRILFYxBaiAHl r721b8jKTY6cz2hkuxlnKuEHESv/k/KCiOKHuEW5xHDpjUOLjLiBRQNktAnFA81RaJPO DqILIryYDKSIw+DmpryQyv++eZb+lVhjC3mUtMVw3XSfhuVvGBNhv9tP4vPUyrfAa90V y3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QyWQEo+8inM5iDruY826QX36+Q2J0PKidDJBY0ejKxk=; b=zp4QWqmNpJyVNgKP/pkPXnRQrSYwMjjXSmHsDieJfbmpY7ww9xy0gcFNSjZfPfe0GX 0BixiEJCclogyRPcuabJ30xY9HagyTqc+OU+xjgFQgVy4CP3HUn9OaHz2OvVxUvHaVNJ 4lCvtZ1rNWeZdoAhffm3JjqBuwArVpBnhEODsiaPRqcxny2qdcpK1wsZlbGjNX+P57EI SQLKCKkmvdEEMUhS2EDrSrFtQIgXE1IIo5HMzQUukogsYH68aX8iYgnrUDUKZfma827R O6E547TOI0whLk6J5CcT7e8nSdiKqlek2sKwuB2zJmzdhwzafZOFHVfWQSzWXXpO24G8 tssQ== X-Gm-Message-State: AOAM531CdfDbh5zSWPextFFhX+mUrhimSvZ5/8VwBwAuyEgbWzbynqoq FqfklZ+5HpR3trcKXm27erZ8gwZmnAILEg== X-Google-Smtp-Source: ABdhPJw+gV9C0wUZs6ULNe93EMc22YH+brLkcZtQhedOHFB4cYyQI7vb6MkcLPN8yVfucadIM0vMBw== X-Received: by 2002:a05:6214:4b4:: with SMTP id w20mr11195739qvz.20.1632502779865; Fri, 24 Sep 2021 09:59:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/27] linux-user/nios2: Properly emulate EXCP_TRAP Date: Fri, 24 Sep 2021 12:59:15 -0400 Message-Id: <20210924165926.752809-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632502947941100001 Content-Type: text/plain; charset="utf-8" The real kernel has to load the instruction and extract the imm5 field; for qemu, modify the translator to do this. The use of R_AT for this in cpu_loop was a bug. Handle the other trap numbers as per the kernel's trap_table. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 5 +++-- linux-user/nios2/cpu_loop.c | 35 ++++++++++++++++++----------------- target/nios2/translate.c | 17 ++++++++++++++++- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 2ab82fdc71..395e4d3281 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -158,9 +158,10 @@ struct Nios2CPUClass { struct CPUNios2State { uint32_t regs[NUM_CORE_REGS]; =20 -#if !defined(CONFIG_USER_ONLY) +#ifdef CONFIG_USER_ONLY + int trap_code; +#else Nios2MMU mmu; - uint32_t irq_pending; #endif }; diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 34290fb3b5..246293a501 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -39,9 +39,10 @@ void cpu_loop(CPUNios2State *env) case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; + case EXCP_TRAP: - if (env->regs[R_AT] =3D=3D 0) { - abi_long ret; + switch (env->trap_code) { + case 0: qemu_log_mask(CPU_LOG_INT, "\nSyscall\n"); =20 ret =3D do_syscall(env, env->regs[2], @@ -55,26 +56,26 @@ void cpu_loop(CPUNios2State *env) =20 env->regs[2] =3D abs(ret); /* Return value is 0..4096 */ - env->regs[7] =3D (ret > 0xfffffffffffff000ULL); - env->regs[CR_ESTATUS] =3D env->regs[CR_STATUS]; - env->regs[CR_STATUS] &=3D ~0x3; - env->regs[R_EA] =3D env->regs[R_PC] + 4; + env->regs[7] =3D ret > 0xfffff000u; env->regs[R_PC] +=3D 4; break; - } else { - qemu_log_mask(CPU_LOG_INT, "\nTrap\n"); =20 - env->regs[CR_ESTATUS] =3D env->regs[CR_STATUS]; - env->regs[CR_STATUS] &=3D ~0x3; - env->regs[R_EA] =3D env->regs[R_PC] + 4; - env->regs[R_PC] =3D cpu->exception_addr; - - info.si_signo =3D TARGET_SIGTRAP; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + case 1: + qemu_log_mask(CPU_LOG_INT, "\nTrap 1\n"); + force_sig_fault(TARGET_SIGUSR1, 0, env->regs[R_PC]); + break; + case 2: + qemu_log_mask(CPU_LOG_INT, "\nTrap 2\n"); + force_sig_fault(TARGET_SIGUSR2, 0, env->regs[R_PC]); + break; + default: + qemu_log_mask(CPU_LOG_INT, "\nTrap %d\n", env->trap_code); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, + env->regs[R_PC]); break; } + break; + case EXCP_DEBUG: info.si_signo =3D TARGET_SIGTRAP; info.si_errno =3D 0; diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 08d7ac5398..485b487665 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -636,6 +636,21 @@ static void divu(DisasContext *dc, uint32_t code, uint= 32_t flags) tcg_temp_free(t0); } =20 +static void trap(DisasContext *dc, uint32_t code, uint32_t flags) +{ +#ifdef CONFIG_USER_ONLY + /* + * The imm5 field is not stored anywhere on real hw; the kernel + * has to load the insn and extract the field. But we can make + * things easier for cpu_loop if we pop this into env->trap_code. + */ + R_TYPE(instr, code); + tcg_gen_st_i32(tcg_constant_i32(instr.imm5), cpu_env, + offsetof(CPUNios2State, trap_code)); +#endif + t_gen_helper_raise_exception(dc, EXCP_TRAP); +} + static const Nios2Instruction r_type_instructions[] =3D { INSTRUCTION_ILLEGAL(), INSTRUCTION(eret), /* eret */ @@ -682,7 +697,7 @@ static const Nios2Instruction r_type_instructions[] =3D= { INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), - INSTRUCTION_FLG(gen_excp, EXCP_TRAP), /* trap */ + INSTRUCTION(trap), /* trap */ INSTRUCTION(wrctl), /* wrctl */ INSTRUCTION_ILLEGAL(), INSTRUCTION_FLG(gen_cmpxx, TCG_COND_LTU), /* cmpltu */ --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503980438127.82026874906524; Fri, 24 Sep 2021 10:19:40 -0700 (PDT) Received: from localhost ([::1]:51732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTorK-00056X-Ut for importer@patchew.org; Fri, 24 Sep 2021 13:19:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYF-0003Dl-Ms for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:55 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:46692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY1-00071o-SJ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:55 -0400 Received: by mail-qk1-x733.google.com with SMTP id b65so28387972qkc.13 for ; Fri, 24 Sep 2021 09:59:41 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rtqr3C3eoq1EPLIGYi3WdYYbWrj10vk/pNHEu4YGvvs=; b=O3fes/8Q7RRsJoVUb03lXxWyPddHN3I9YTFoax+0QZ9uukwbsRVhrrL1p6VYrzBt3o 4NH2DgYJKb5PskLkwoSwFBs3xe85sz4+WTUTzrNgNKHUG0PI81Vu+7I25lzmIVBSkgYX wBr+4sKr3L4KmfZwCri8CTkTkOAzYac73pEOGyvGURgMHIjqR1IrZJZMLruSA5+PTNoq dwNTONQ88++CMDb8DYNhfplT6iiQqTthogSA+bCwIe3X0Ivz1Dt12HZl/+IHNEy0245Y nR5Jh93G3s6c+mpmsynq18bXXRkmCHsvW1j+Kl8Rk+AtC1FtV3AaohRrBkJ8EGQj+7wy ozFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rtqr3C3eoq1EPLIGYi3WdYYbWrj10vk/pNHEu4YGvvs=; b=ardQLA0RBASy8Cqol1VI9Y1DFwL/A/qetc+cLIY5kR9JlQudRwwjWKtAnjG9e50+db K+b2TKcxmHK3gCyNl8su2QFEd+lS1I6IkdnQ8Q1ByZ9RBsFc3xLwYCv39E8ZXy1+Tekn sMD5rF4d6ifjd8xSguQ1Ty3paRMkgXKQn5DUopMaySeu5vCK9uS8XwEmXSN9rzV6/E94 +WcFsRtrQug+ZIhVu0MQiRne7eferNQi0fZlreE/QJmzlRhGlcsS8TlNu+XMZmFM9M+F fYodmOaxrM6ypaT2yLxIGkH6193vggjCz1pQQ9CcN6EyQ4gr3tnkrdjJd7Jmo0TOUDd5 tsNA== X-Gm-Message-State: AOAM532Kd4cGDBg2582YUaEveGfx4V2aIjZ7EGTlpwP2GI96p2jsfuEh jGSGU8h0a8u1oJsA8Mq+9sJy0N9AVPkY1Q== X-Google-Smtp-Source: ABdhPJzuY/ebETeJEvm6mpZYEt5N6aM0c8ZT0DJYjSLSHSfjba92xXIO4nmk88Vdi8tAEMVP/iSJ/g== X-Received: by 2002:a37:a548:: with SMTP id o69mr11577288qke.9.1632502780911; Fri, 24 Sep 2021 09:59:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/27] linux-user/nios2: Map a real kuser page Date: Fri, 24 Sep 2021 12:59:16 -0400 Message-Id: <20210924165926.752809-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503982460100002 Content-Type: text/plain; charset="utf-8" The first word of page1 is data, so the whole thing can't be implemented with emulation of addresses. Hijack trap number 31 to implement cmpxchg. Set default_rt_sigreturn based on the kuser page. Signed-off-by: Richard Henderson --- linux-user/nios2/target_signal.h | 3 ++ linux-user/elfload.c | 35 ++++++++++++++++++++++ linux-user/nios2/cpu_loop.c | 51 +++++++++++++++++--------------- linux-user/nios2/signal.c | 2 +- target/nios2/translate.c | 9 ------ 5 files changed, 66 insertions(+), 34 deletions(-) diff --git a/linux-user/nios2/target_signal.h b/linux-user/nios2/target_sig= nal.h index aebf749f12..fe266c4c51 100644 --- a/linux-user/nios2/target_signal.h +++ b/linux-user/nios2/target_signal.h @@ -19,4 +19,7 @@ typedef struct target_sigaltstack { =20 #include "../generic/signal.h" =20 +/* Nios2 uses a fixed address on the kuser page for sigreturn. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* NIOS2_TARGET_SIGNAL_H */ diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 459a26ef1d..7b3a91b3ed 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1100,6 +1100,41 @@ static void elf_core_copy_regs(target_elf_gregset_t = *regs, const CPUMBState *env =20 static void init_thread(struct target_pt_regs *regs, struct image_info *in= fop) { + static const uint8_t kuser_page[4 + 2 * 64] =3D { + /* __kuser_helper_version */ + [0x00] =3D 0x02, 0x00, 0x00, 0x00, + + /* __kuser_cmpxchg */ + [0x04] =3D 0xfa, 0x6f, 0x3b, 0x00, /* trap 31 */ + 0x3a, 0x28, 0x00, 0xf8, /* ret */ + + /* __kuser_sigtramp */ + [0x44] =3D 0xc4, 0x22, 0x80, 0x00, /* movi r2, __NR_rt_sigreturn = */ + 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ + }; + + abi_ulong pg; + uint8_t *ph; + + pg =3D target_mmap(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + + /* + * If the mmap doesn't give us exactly page 1, there's nothing + * we can do, and it's unlikely that the program will be able + * to continue. FIXME: Error out now? + */ + assert(pg =3D=3D TARGET_PAGE_SIZE); + + ph =3D lock_user(VERIFY_WRITE, pg, sizeof(kuser_page), 0); + memcpy(ph, kuser_page, sizeof(kuser_page)); + unlock_user(ph, pg, sizeof(kuser_page)); + target_mprotect(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE, PROT_READ | PROT_E= XEC); + + /* Install __kuser_sigtramp */ + default_rt_sigreturn =3D TARGET_PAGE_SIZE + 0x44; + regs->ea =3D infop->entry; regs->sp =3D infop->start_stack; regs->estatus =3D 0x3; diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 246293a501..12070c8a3c 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -26,7 +26,6 @@ void cpu_loop(CPUNios2State *env) { CPUState *cs =3D env_cpu(env); - Nios2CPU *cpu =3D NIOS2_CPU(cs); target_siginfo_t info; int trapnr, ret; =20 @@ -73,6 +72,32 @@ void cpu_loop(CPUNios2State *env) force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, env->regs[R_PC]); break; + + case 31: /* QEMU specific, for __kuser_cmpxchg */ + { + abi_ptr g =3D env->regs[4]; + uint32_t *h, n, o; + + if (g & 0x3) { + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, = g); + break; + } + ret =3D page_get_flags(g); + if (!(ret & PAGE_VALID)) { + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR= , g); + break; + } + if (!(ret & PAGE_READ) || !(ret & PAGE_WRITE)) { + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_ACCERR= , g); + break; + } + h =3D g2h(cs, g); + o =3D env->regs[5]; + n =3D env->regs[6]; + env->regs[2] =3D qatomic_cmpxchg(h, o, n) - o; + env->regs[R_PC] +=3D 4; + } + break; } break; =20 @@ -83,29 +108,7 @@ void cpu_loop(CPUNios2State *env) queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case 0xaa: - switch (env->regs[R_PC]) { - /*case 0x1000:*/ /* TODO:__kuser_helper_version */ - case 0x1004: /* __kuser_cmpxchg */ - start_exclusive(); - if (env->regs[4] & 0x3) { - goto kuser_fail; - } - ret =3D get_user_u32(env->regs[2], env->regs[4]); - if (ret) { - end_exclusive(); - goto kuser_fail; - } - env->regs[2] -=3D env->regs[5]; - if (env->regs[2] =3D=3D 0) { - put_user_u32(env->regs[6], env->regs[4]); - } - end_exclusive(); - env->regs[R_PC] =3D env->regs[R_RA]; - break; - /*case 0x1040:*/ /* TODO:__kuser_sigtramp */ - default: - ; -kuser_fail: + { info.si_signo =3D TARGET_SIGSEGV; info.si_errno =3D 0; /* TODO: check env->error_code */ diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index a77e8a40f4..c9a235ded5 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -177,7 +177,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, =20 /* Set up to return from userspace; jump to fixed address sigreturn trampoline on kuser page. */ - env->regs[R_RA] =3D (unsigned long) (0x1044); + env->regs[R_RA] =3D default_rt_sigreturn; =20 /* Set up registers for signal handler */ env->regs[R_SP] =3D (unsigned long) frame; diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 485b487665..77706dd805 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -795,15 +795,6 @@ static void nios2_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cs) dc->base.pc_next =3D pc + 4; =20 /* Decode an instruction */ - -#if defined(CONFIG_USER_ONLY) - /* FIXME: Is this needed ? */ - if (pc >=3D 0x1000 && pc < 0x2000) { - t_gen_helper_raise_exception(dc, 0xaa); - return; - } -#endif - code =3D cpu_ldl_code(env, pc); op =3D get_opcode(code); =20 --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503473415245.17400230665157; Fri, 24 Sep 2021 10:11:13 -0700 (PDT) Received: from localhost ([::1]:56516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTojA-0006JG-7n for importer@patchew.org; Fri, 24 Sep 2021 13:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002mZ-N9 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:36783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY3-00071w-I0 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: by mail-qk1-x72e.google.com with SMTP id p4so28962528qki.3 for ; Fri, 24 Sep 2021 09:59:42 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PTxH4FIm8UZKfO6Q1wb4hu+tVJghYRydXpLjkNTr2zo=; b=VJTfst6MefBeUJw+1PD7rTKn4E+MszmdumrP3jlb+MS5MzK0+FBft8HrFzZqaIAiZi 55VfyDP1VOkGOJ6Zxg1berkvS+gqm+IDZbCiOdSnmgm2TPcqnL2cHcQDYQh5pL0LL1tu QxqB2DhcY9PP6HXHFrtYKLy3rlIZ7YE2YoIDznueAq2zJUlddxw/2fjV4DQNYArYius1 aN3KIWeWP42pMLOKfHPQScOA3yEV8NlxmtlZ64uYLlttF+HpT9rjfHGvlQ3rNRpU6KNm tnbprB7mOdzZdUT02BLFLlJDcG6j5WtwLEGLsZ6B+Xhkqfw4tJc4cW1VQiGPTk0u30UT Okcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PTxH4FIm8UZKfO6Q1wb4hu+tVJghYRydXpLjkNTr2zo=; b=JeSSex8AvJcJog5SIR/d91tDmBKrxyx0XavS6D2/Kpw+snm4NyHWOECCZ2u7HjGAhD FSNOPMRJuwZmwpLcj2COCYqKX/FLkVTmCg8mbYCAZVhLpE2vasFHOxyHxSbexIraaE6a 6y63lSKbSLOxWaWe2R7tYbaBMN5uSg/ffNCP938hLiQMLvuSmDa6E+P4311b8lg1VkoE TPreo6veFHr537E0cOfDd7m4ecCrJyAWfBww5Y45wfbnoLMfye1oGZXkt83MXa0okXCQ U8Uz1S4KkCLzOTSx/hH2HkDnONRyzX1hbwj4Sn6LU1HeL5B7Z6kSHs1XHf5FkhZhqyoQ x5qg== X-Gm-Message-State: AOAM5333j1nlgMDJzdtAYZUELwbsARpezPj49DIB4qATKpLd5xtQp1Kw a1q57Ohvat52t0eYWwYoVFOseY5guhokDg== X-Google-Smtp-Source: ABdhPJx2h/mf/on1G+QFmrxEK5Hj021WGBrocskeRFeiLesUxxeQQml6PqiqEFHlh8SMItm6dgtmZQ== X-Received: by 2002:a37:a88e:: with SMTP id r136mr11551861qke.490.1632502781593; Fri, 24 Sep 2021 09:59:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/27] linux-user/nios2: Fixes for signal frame setup Date: Fri, 24 Sep 2021 12:59:17 -0400 Message-Id: <20210924165926.752809-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503474504100001 Content-Type: text/plain; charset="utf-8" Do not confuse host and guest addresses. Lock and unlock the target_rt_sigframe structure in setup_rt_sigframe. Since rt_setup_ucontext always returns 0, drop the return value entirely. This eliminates the only write to the err variable in setup_rt_sigframe. Always copy the siginfo structure. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/nios2/signal.c | 49 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index c9a235ded5..95f6d737e1 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -42,7 +42,7 @@ struct target_rt_sigframe { struct target_ucontext uc; }; =20 -static int rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *en= v) +static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *e= nv) { unsigned long *gregs =3D uc->tuc_mcontext.gregs; =20 @@ -75,8 +75,6 @@ static int rt_setup_ucontext(struct target_ucontext *uc, = CPUNios2State *env) __put_user(env->regs[R_GP], &gregs[25]); __put_user(env->regs[R_EA], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); - - return 0; } =20 static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext = *uc, @@ -135,8 +133,8 @@ static int rt_restore_ucontext(CPUNios2State *env, stru= ct target_ucontext *uc, return 0; } =20 -static void *get_sigframe(struct target_sigaction *ka, CPUNios2State *env, - size_t frame_size) +static abi_ptr get_sigframe(struct target_sigaction *ka, CPUNios2State *en= v, + size_t frame_size) { unsigned long usp; =20 @@ -144,7 +142,7 @@ static void *get_sigframe(struct target_sigaction *ka, = CPUNios2State *env, usp =3D target_sigsp(get_sp_from_cpustate(env), ka); =20 /* Verify, is it 32 or 64 bit aligned */ - return (void *)((usp - frame_size) & -8UL); + return (usp - frame_size) & -8; } =20 void setup_rt_frame(int sig, struct target_sigaction *ka, @@ -153,26 +151,25 @@ void setup_rt_frame(int sig, struct target_sigaction = *ka, CPUNios2State *env) { struct target_rt_sigframe *frame; - int i, err =3D 0; + abi_ptr frame_addr; + int i; =20 - frame =3D get_sigframe(ka, env, sizeof(*frame)); - - if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + force_sigsegv(sig); + return; } =20 + tswap_siginfo(&frame->info, info); + /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); target_save_altstack(&frame->uc.tuc_stack, env); - err |=3D rt_setup_ucontext(&frame->uc, env); + rt_setup_ucontext(&frame->uc, env); for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __put_user((abi_ulong)set->sig[i], - (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); - } - - if (err) { - goto give_sigsegv; + (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); } =20 /* Set up to return from userspace; jump to fixed address sigreturn @@ -180,19 +177,13 @@ void setup_rt_frame(int sig, struct target_sigaction = *ka, env->regs[R_RA] =3D default_rt_sigreturn; =20 /* Set up registers for signal handler */ - env->regs[R_SP] =3D (unsigned long) frame; - env->regs[4] =3D (unsigned long) sig; - env->regs[5] =3D (unsigned long) &frame->info; - env->regs[6] =3D (unsigned long) &frame->uc; - env->regs[R_EA] =3D (unsigned long) ka->_sa_handler; - return; + env->regs[R_SP] =3D frame_addr; + env->regs[4] =3D sig; + env->regs[5] =3D frame_addr + offsetof(struct target_rt_sigframe, info= ); + env->regs[6] =3D frame_addr + offsetof(struct target_rt_sigframe, uc); + env->regs[R_EA] =3D ka->_sa_handler; =20 -give_sigsegv: - if (sig =3D=3D TARGET_SIGSEGV) { - ka->_sa_handler =3D TARGET_SIG_DFL; - } - force_sigsegv(sig); - return; + unlock_user_struct(frame, frame_addr, 1); } =20 long do_sigreturn(CPUNios2State *env) --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16325039812505.221919636587472; Fri, 24 Sep 2021 10:19:41 -0700 (PDT) Received: from localhost ([::1]:51832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTorM-0005AI-4W for importer@patchew.org; Fri, 24 Sep 2021 13:19:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY7-0002p9-IW for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:40664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY3-00072D-IJ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: by mail-qk1-x734.google.com with SMTP id 72so28625264qkk.7 for ; Fri, 24 Sep 2021 09:59:42 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=TiEHkqLhCxqVrpRpuynLDSiG61R6O8JsvscC0KYwWWQmsnqu3bR4A4c2xfB1jIz8PO 90jU/0nfyp2AlupK8D8pU7k8QvcSKFks8sed1hFwiKniQOQLZPGd2bRqknXQ8cBHY1lT jODWivjgjAZSNobY0iEEvs5XUHlsuubmvzyTshdtduJekVQRwGokoO2V0rW0wx6CnafV YWWiq651InGZxuKXaPMh1zJH1NPcRAZuYOyHLKJ5N6wtQjcWBQxkXvx50cOdGqSdhKTZ +uKTnUS0HpRS2mWhhPbSilrFFw32n6Gap+jjxo0WoKkflhDd6rIfpcJH4hQmLFWuxcc7 +sVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=YEiZpevQ+aDfAz8KwSgLc4EWKUo/KU8vECz1iSe3GE1xNfTwAZKhdYEYEyHgJeX6ky obkU7xBgw8PiDAw+c2oYQIHMZfs3FCZ4T1BTjLNjhAGvrARA1kz/ED5gpHhSE+/EMB+r Rf7N+tojeJTl+CkjexTtWwqqJUHFk1ZgyzDYvQzL6blcvoBoMghdxbkBZPGuvPnb5Ggk h1M+kcIXcUpeVeZFcJmeIkSiSkPq6aWdaEu7vbbnbgT5Usj6tPn0FBZeWyVj55OmHBOJ FEIWJE2xLUauHa7VUz39G3dSuLc+dJG9VG+GJb7JdefAkX7t/7sS9mBRIItwqXmTNshP m7GA== X-Gm-Message-State: AOAM5330btFeo0kweTbmHSECnPMOmb+QrBWWrmOAbpsnJao4wzxhKoog emLpZhV9e1hC49Nxaf9UdULxOExRL7AkuA== X-Google-Smtp-Source: ABdhPJztx75T3gpKR2agxEVhYz3dHXgO2we+/Lp2geSy/mdFSsH/ZjSh+Nv+Tof2ofJeD8xHj9Xx1g== X-Received: by 2002:a37:ae83:: with SMTP id x125mr11855501qke.37.1632502782447; Fri, 24 Sep 2021 09:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/27] linux-user/openrisc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:18 -0400 Message-Id: <20210924165926.752809-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, Stafford Horne , laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503982435100001 Create and record the rt signal trampoline. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/openrisc/target_signal.h | 2 ++ linux-user/openrisc/signal.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/targ= et_signal.h index 8283eaf544..077ec3d5e8 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -26,4 +26,6 @@ typedef struct target_sigaltstack { =20 #include "../generic/signal.h" =20 +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* OPENRISC_TARGET_SIGNAL_H */ diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index ca2532bf50..be8b68784a 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; =20 static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *s= c) @@ -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]); } =20 - /* 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp !=3D 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 =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503322007334.01205254908973; Fri, 24 Sep 2021 10:08:42 -0700 (PDT) Received: from localhost ([::1]:47874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogi-0000XW-B0 for importer@patchew.org; Fri, 24 Sep 2021 13:08:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002mt-Pl for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:44741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY4-00072J-Jw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: by mail-qt1-x82a.google.com with SMTP id r16so10014639qtw.11 for ; Fri, 24 Sep 2021 09:59:43 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rvAlqQQaMJOEemK1f4c76TW1TW8p9KSzHxLmC3ERHiU=; b=fU77HVUZPzfIQjoQJUr0pIf9YHhi/E5OVVhAfXGjRwlE3gdqRrrn3ZOmnQeMffvmQA GNKV7kuuPMLbNbiGBZIGGkRuDsZ+mnRYndT4PDJ54zR4KppaXidApaBEsheLjJiRYwW0 ZYXPiJsx/VkkFfNnkBoPMsbGo2b8MZHEDIamL8WstPH2bEro0GF7d/MyK1e23hQP8XHs fkMqDJJFbX0De/UAzI0ieSDWz2eG3c/LWiopYyl8/fPH3ifJLZS0WlfP3kAluJm23CIU eXBibC2Th8hhyv1iE+/6KTuI9v/ZIt0z1ZQPq9ZNn/iV14pbSePG9omWspN0V80P0aPt 8VYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rvAlqQQaMJOEemK1f4c76TW1TW8p9KSzHxLmC3ERHiU=; b=3thep9HwZLL0+mwDx0zq2y7NFNTr8Ks9issXG5JAonPsn6AXcdCdEnrxnB/yXg70K8 mPH6yMwr0v5iCJqq3AhDlSMTHq1LSGpafICKczZnofhBJfpmQrarYJCK2aZAvKs1AQaq 3kfZvIZEzWpsR2imqX9x9c6sC+8u5+0SoG/o4Cog8ntzCwVYsl6lWlRpVoi4qfGfo0xC bTEwvHm/8LP3XoIyLLNh2hTpOguY2sT3ai0St/V9trheZJCBgX7MUfwuLbA9GUTyfg8A G5reEkLb+b5YZaIFtZ3BSKOr58tdOdCM5FBwFifrdk/4unzR3tXu+y1qd30zzsA0rVaf JhhQ== X-Gm-Message-State: AOAM53349ZIuwMC2TeZBzIMf4LsM7cTq89QbEh3r3iXKNWSZEpZe/qQd AcnPzbKtsCzCxWOqxmfJpRtc13hs0poV2A== X-Google-Smtp-Source: ABdhPJw1vNYQhZ6dwN0LwU6n+K3GOz+tnmPyT/sDCvKpfUOc0sf/t/Jo/eM1z5fJKNeZngWAMOltKg== X-Received: by 2002:ac8:7143:: with SMTP id h3mr5378609qtp.242.1632502783131; Fri, 24 Sep 2021 09:59:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/27] linux-user/ppc: Simplify encode_trampoline Date: Fri, 24 Sep 2021 12:59:19 -0400 Message-Id: <20210924165926.752809-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503323764100001 Content-Type: text/plain; charset="utf-8" The sigret parameter is never 0, and even if it was the encoding of the LI instruction would still work. Reported-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 e4d0dfa3bf..77f37b9f01 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 ta= rget_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]); } =20 static void restore_user_regs(CPUPPCState *env, --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632504215845424.71464050090583; Fri, 24 Sep 2021 10:23:35 -0700 (PDT) Received: from localhost ([::1]:58506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTov8-0001MV-F0 for importer@patchew.org; Fri, 24 Sep 2021 13:23:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY8-0002qi-1r for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:48 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:41546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY4-00072x-Oy for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: by mail-qk1-x732.google.com with SMTP id m7so11926007qke.8 for ; Fri, 24 Sep 2021 09:59:44 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=nvb6X7IgiG4QCH5gBpebZZBVwD0cHgiVSvGUIt3D1q2xOX9C4n11QpThSMrdAjDkPS p8zJdtsIM6H0OnRTenjURypWvqDEAs1Qam7HnngzsT5EPG2b/Nhl6Sv6s+l58SQLMUiJ vgHxcJYQ1rg5ZEeWDLxU6npoh/y+E31kueAmAJpfqnMef8EM8I2/SErBwFNIfNTeasiZ HBQUgw4IILUkzflpG7lQk8rhvCTQOGXzHuciOnJaoA5HeAi310tW0VsNkPMH/SB+2gNn tG6xGpUDFct/reIyhz7YEuL/FAmqwSAhFq87l9RNscJr4rWYOdPOqJJlE1vPw9FTm1hE icjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=Robhj/2FEjwhBdpYkpeRqdGhbXZJBpGyV6V65avN8mn9YubWnmBoU9T5l7JpyF25Jk HZ5k5oXu1ewYMVSUNOBpYoZfcyIM5Mn9k4m6cINYZZcUJvAXjnoxocSj5t6l4aNSaPPz w7TEUCz+U9Hxs5D/ZerlEjeA29WWgXFBipKIxyjvR8KweLzu8b7gMiY4JQ08r/IFW3V3 1FW+hDr5nPAOdT7q79qeYeaQbLsETsdM0xAQWvuyQvnjAopyDhB/1v1HolxouLTtVFSk OWSAVlxRuC8XbfB/B6sQ9WlkJyasIlrJ2HGQWYe+5pw1nGRLevkoBGQVSMKlO/G63cIL JKSg== X-Gm-Message-State: AOAM532qr8y4Qzoyi79/nTsygW22+56mZY9tsuOtrsj+1t7Jlv6Jugi4 MHEYZYAy9tqk3eBicOqpshDQhiqfsBTxQw== X-Google-Smtp-Source: ABdhPJxAaouIPi88gl/FB0L0oVIou3KPkH8kCrCH6t4yclQWS5SHZuiu6H0MjomdTonri39kLs1tBA== X-Received: by 2002:a37:64cc:: with SMTP id y195mr11351439qkb.97.1632502783932; Fri, 24 Sep 2021 09:59:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/27] linux-user/ppc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:20 -0400 Message-Id: <20210924165926.752809-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, qemu-ppc@nongnu.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632504216746100001 Content-Type: text/plain; charset="utf-8" Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/ppc/target_signal.h | 2 ++ linux-user/ppc/signal.c | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/linux-user/ppc/target_signal.h b/linux-user/ppc/target_signal.h index 72fcdd9bfa..82184ab8f2 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 */ diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 77f37b9f01..c37744c8fc 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -203,9 +203,6 @@ struct target_func_ptr { =20 #endif =20 -/* 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); =20 - /* 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 =3D (target_ulong) h2g(frame->mctx.tramp); + env->lr =3D default_sigreturn; =20 /* Turn off all fp exceptions. */ env->fpscr =3D 0; @@ -477,7 +469,6 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, target_sigset_t *set, CPUPPCState *env) { struct target_rt_sigframe *rt_sf; - uint32_t *trampptr =3D 0; struct target_mcontext *mctx =3D 0; target_ulong rt_sf_addr, newsp =3D 0; int i, err =3D 0; @@ -507,22 +498,17 @@ void setup_rt_frame(int sig, struct target_sigaction = *ka, =20 #if defined(TARGET_PPC64) mctx =3D &rt_sf->uc.tuc_sigcontext.mcontext; - trampptr =3D &rt_sf->trampoline[0]; =20 sc =3D &rt_sf->uc.tuc_sigcontext; __put_user(h2g(mctx), &sc->regs); __put_user(sig, &sc->signal); #else mctx =3D &rt_sf->uc.tuc_mcontext; - trampptr =3D (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp; #endif =20 save_user_regs(env, mctx); - encode_trampoline(TARGET_NR_rt_sigreturn, trampptr); =20 - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr =3D (target_ulong) h2g(trampptr); + env->lr =3D default_rt_sigreturn; =20 /* Turn off all fp exceptions. */ env->fpscr =3D 0; @@ -720,3 +706,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong u= old_ctx, =20 return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp !=3D NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn =3D sigtramp_page; + encode_trampoline(TARGET_NR_sigreturn, tramp + 0); +#endif + + default_rt_sigreturn =3D sigtramp_page + 8; + encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503557846577.0322925771856; Fri, 24 Sep 2021 10:12:37 -0700 (PDT) Received: from localhost ([::1]:59426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTokW-0008EO-N5 for importer@patchew.org; Fri, 24 Sep 2021 13:12:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY9-0002xf-Jv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:36789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY6-000745-LZ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qk1-x734.google.com with SMTP id p4so28962711qki.3 for ; Fri, 24 Sep 2021 09:59:45 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=Ofmns6Nb9e8eLHBnOUOL6cJTd3Jelb2Ec+/aJPWv9iev7XxrAnLv7F1oDLJkUj4jdM KpWde5gdWj2Zo7rPrmCLkl5i9EHwBUrg7/KXC/CyXLnMPV95rg7oN9jexpr1mWVgRbcI 7nVnQqy2YB0VJrLW4a7V9iR9WoV2omDtwn4FZqO9WuXWXsPXxFjges9TBL+L6jZrVYsq EkTfUmrndcM/HyQ9q/6fwYIIuUeKbs+1NAolQ39H1E1oGh5x845alwC7E/PVHkUda7zp 5EzXV5gzrUOSw2VMhZj1C0T2zIuajgQZRDpbaif9/QaCy77eabFRVxhYgmYMuh0YFkqS lYfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=CCahY8wS+eTQ0MvGmersg2vPuEF45dyWoLiAJmROT66oYI+do7GxT5bUnvxThSuPZx yh+I86oDgv6RHWzScDVCXB2Pe5mF4gn2z6YmIiXYKZXcCcYR2GEpmkPzjv0XVt62iy6W FYigLJEHjrcqC2Cwh7Af2NA+yB44VufhH9U6HpcDuUiDibKwKVmC/UoIjs2+9PNE2al8 FySu+tgv3U0/Rz4Ljn+k5bOe+FHkGQvLGWL6IIU01UWuM/58a4LDoxM3U+qYNPj3J3AB GvL8h1kR3fUBrdBuWoDDjYqea5WTv7w99aePiB9I5kLdhlW0k+p2PsV9qGb7KNrzCCcN HZRA== X-Gm-Message-State: AOAM5310myAJmTMHMEA93vLYWzEgmgUrpP55Flp1Zpkt+uiN4lrZdxOQ T0fGJeirC7HLy1O5P+6uUqQoywUXCxHg7A== X-Google-Smtp-Source: ABdhPJztLkE1D8lfGRJl8AK7GK6UPn/Lfrr/QM7PJH5AyJauQLGcVDq/7e2eoqUFjccDniPOJTmz6Q== X-Received: by 2002:a37:a54c:: with SMTP id o73mr11744712qke.334.1632502784749; Fri, 24 Sep 2021 09:59:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 22/27] linux-user/riscv: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:21 -0400 Message-Id: <20210924165926.752809-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, Alistair Francis , laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503560088100001 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=C3=A9 Signed-off-by: Richard Henderson --- linux-user/riscv/target_signal.h | 2 ++ linux-user/riscv/signal.c | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/linux-user/riscv/target_signal.h b/linux-user/riscv/target_sig= nal.h index f113ba9a55..3e36fddc9d 100644 --- a/linux-user/riscv/target_signal.h +++ b/linux-user/riscv/target_signal.h @@ -15,4 +15,6 @@ typedef struct target_sigaltstack { =20 #include "../generic/signal.h" =20 +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* RISCV_TARGET_SIGNAL_H */ diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index f7f33bc90a..a0f9542ce3 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -47,7 +47,6 @@ struct target_ucontext { }; =20 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); } =20 -static inline void install_sigtramp(uint32_t *tramp) -{ - __put_user(0x08b00893, tramp + 0); /* li a7, 139 =3D __NR_rt_sigretur= n */ - __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, =20 setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); - install_sigtramp(frame->tramp); =20 env->pc =3D ka->_sa_handler; env->gpr[xSP] =3D frame_addr; env->gpr[xA0] =3D sig; env->gpr[xA1] =3D frame_addr + offsetof(struct target_rt_sigframe, inf= o); env->gpr[xA2] =3D frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[xRA] =3D frame_addr + offsetof(struct target_rt_sigframe, tra= mp); + env->gpr[xRA] =3D default_rt_sigreturn; =20 return; =20 @@ -203,3 +195,15 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp !=3D NULL); + + __put_user(0x08b00893, tramp + 0); /* li a7, 139 =3D __NR_rt_sigretur= n */ + __put_user(0x00000073, tramp + 1); /* ecall */ + + default_rt_sigreturn =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503982386589.0097652888691; Fri, 24 Sep 2021 10:19:42 -0700 (PDT) Received: from localhost ([::1]:51942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTorN-0005Ed-Be for importer@patchew.org; Fri, 24 Sep 2021 13:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY9-0002wV-BM for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:39700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY6-00074K-JH for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qt1-x82d.google.com with SMTP id j13so10053148qtq.6 for ; Fri, 24 Sep 2021 09:59:46 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=izwHaXTWBfwELcDM9unPhyjA1hL02WdAguVFjIjDGbOEcwEngy+DLf/BHM+mdesGbo i5NFVM9DfQoDRdv27arefaurzgH4FtCmCnNkcMit63gUMCZu+Z263VvvgMK5bw2flMQm KgZ6OK7+tAar4WIOveArojcEdLDDT/TYZRGUAS8vuwbOQ9CrCfEwCjgTKuwaipNFkMzZ IdHqTfJjJwsdmi5quk61HqKZ8vSKlY6O1cisjzVilSNtMHLtwApssFqvLW2Yzm8ZN6h2 7t6QEV3AFJV1poFEtk3r8wau0o8B6t9N8vWXHpYdhWqyKmswG9Oh6EDAORR6FMtgGQsx 6QYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=kfxTWTnPH8Xt6fw5YVMCF64YqbhGpQHEtwaffnDyajgPgstWq8UY4i1WD38DoYfPiH kLJpnrvYh0AIqaLDSiKk8Buz3FuwD7nJEWSq/VYmXpLhXhM2/DkY7xRMgDQTmFs1JFI3 NBzK5CHGATFKZmLGL7d7xYcW9UuFnpFA5AJ1s+MKoihj1aYIdf53lcu6dLYN7w7BxhUO QmArskiy8BcSgwfkS+/OLVe4uOn0106H73vfTCqPGaM4eRyXF5mJ1gCBhmvuR/qgCio1 KrNVdSD2f9f/mvx2XktwGSSa7wzmc7pvjY6SwIARAsoXoh0Cb6EKtTUk60uShOkrYWj/ LyvQ== X-Gm-Message-State: AOAM530hGcUJjqHXhQYJJrpSxIHaGc17gOdbFS91O1fQXZRlQWC8EAd2 SClH7Xu2afX3NW+JKNReXguOBcK/E3ASfg== X-Google-Smtp-Source: ABdhPJwLdNjgVrZPNIqskWOlzTo4dAP0GpyX/5aTqMfzocWqO8yv+JBpmE4nSKb2jIrITKNLoR0KaQ== X-Received: by 2002:ac8:74a:: with SMTP id k10mr1304225qth.17.1632502785658; Fri, 24 Sep 2021 09:59:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/27] linux-user/s390x: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:22 -0400 Message-Id: <20210924165926.752809-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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@linaro.org, qemu-s390x@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503984261100005 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=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/s390x/target_signal.h | 2 ++ linux-user/s390x/signal.c | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_sig= nal.h index bbfc464d44..64f5f42201 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" =20 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* S390X_TARGET_SIGNAL_H */ diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 80f34086d7..676b948147 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; =20 #define TARGET_UC_VXRS 2 @@ -85,7 +84,6 @@ struct target_ucontext { =20 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 =3D ka->sa_restorer; } else { - restorer =3D frame_addr + offsetof(sigframe, retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - &frame->retcode); + restorer =3D default_sigreturn; } =20 /* Set up registers for signal handler */ @@ -262,9 +258,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer =3D ka->sa_restorer; } else { - restorer =3D frame_addr + offsetof(typeof(*frame), retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - &frame->retcode); + restorer =3D default_rt_sigreturn; } =20 /* 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 + 2, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]); + + default_rt_sigreturn =3D sigtramp_page + 2; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]); + + unlock_user(tramp, sigtramp_page, 2 + 2); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632504459163455.6101864929766; Fri, 24 Sep 2021 10:27:39 -0700 (PDT) Received: from localhost ([::1]:37508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToz2-0006Jl-6J for importer@patchew.org; Fri, 24 Sep 2021 13:27:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-0002zM-4h for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:38829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY7-00075I-C6 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qk1-x730.google.com with SMTP id q81so25090075qke.5 for ; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=JTHRst3ll0y8WPA4QcJr76vLZXA6cp1hCJovcLAHi1ezcjj2KEIYIGz7r2q2CXZfEm JX4HYvhh0QkLZ1RL7G1GLkK0lSAjmQk4GJOpZCdRmYq4mnW/VBxys9jqTesgm0WghZ1l Hrh9XpfMD++3SbDLSno2qAR4jS2RhQvCrATQnGaLYTMH3HM0kDnJZLO5p9zU95OYgsVv VSmikbFljlQHPbpomEeimENVENfYhnOZL+gHawOKjKEDj+IpiPZxsw2b036FoSm1+icd BnADbM0hfKjrlOuG7lNRhJqt0wL4mbcop1tWod3EOC/AHaGZR6koShb6WIjL8Yg6O7Kg 1Www== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=QnZAHEowDfvItSDERIZFABDQeuoYUBqOvsGVpJnYaNvqEmC6RCoQtS8SNJXjshEEvG XkuY+/qjoyRxRIjNPdl2hD24gq7r6rD5RKj/iTOKJpub7VBvpSv0qu3TvXesIeuVNYTa F2mqRZJqtRvIee9tFqgrQNpu6jH3xK7MPR53DtBMiOThZDMDHLjzQUzzdvhQxAcFJ+9O ar3lbPGlAkpQ6PV9ZMRRdJ4QRkjgxjjJ2xL1f69Y2WvslX2fFid1Kq9zD2uzon2GjEcM X0dq4ACqh89j3uPyWS08yfUbgCoZrKxZrg+P90h059Np5WIdqNQjSBMCzPoJkQ7dvrsn F2Dw== X-Gm-Message-State: AOAM533Ppe1QOPW6n+GNWXzGiXBuRnUwWBw/nd3YcFP/vTA/r2taYFsS e/4jT8RUGvBr9Kz7f90KTzjf3mQ9HQdwDQ== X-Google-Smtp-Source: ABdhPJzReUCuAWhyC91fyk4q0DVnL/qQ70OSTY+o1VrVif/9yNKLybC2RGA9U/GLR5Pg288UauOU7g== X-Received: by 2002:a37:b703:: with SMTP id h3mr11871098qkf.240.1632502786453; Fri, 24 Sep 2021 09:59:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/27] linux-user/sh4: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:23 -0400 Message-Id: <20210924165926.752809-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632504459827100003 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=C3=A9 Signed-off-by: Richard Henderson --- linux-user/sh4/target_signal.h | 2 ++ linux-user/sh4/signal.c | 40 +++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/linux-user/sh4/target_signal.h b/linux-user/sh4/target_signal.h index d7309b7136..04069cba66 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" =20 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* SH4_TARGET_SIGNAL_H */ diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index d70d744bef..faa869fb19 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]; }; =20 =20 @@ -68,7 +67,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; =20 =20 @@ -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 =3D (unsigned long) ka->sa_restorer; + regs->pr =3D ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr =3D 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 =3D (unsigned long) retcode_addr; + regs->pr =3D default_sigreturn; } =20 /* 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 =3D (unsigned long) ka->sa_restorer; + regs->pr =3D ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr =3D frame_addr + - offsetof(struct target_rt_sigframe, retco= de); - __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 =3D (unsigned long) retcode_addr; + regs->pr =3D default_rt_sigreturn; } =20 /* 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 6, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + __put_user(MOVW(2), &tramp[0]); + __put_user(TRAP_NOARG, &tramp[1]); + __put_user(TARGET_NR_sigreturn, &tramp[2]); + + default_rt_sigreturn =3D 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); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503639794544.7591783297137; Fri, 24 Sep 2021 10:13:59 -0700 (PDT) Received: from localhost ([::1]:36698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTolq-0003Uc-1f for importer@patchew.org; Fri, 24 Sep 2021 13:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-00030P-Gw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:39702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY8-000763-2M for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qt1-x82f.google.com with SMTP id j13so10053206qtq.6 for ; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=daLEaNGm2JcBkU6qTxW3+UqnC899+eVTOSVIn7EyU8Dk7RAlC4wGj2VFQlN80RsthD Rh2nmyERAt9nxhAQZ3n4IuQx35c9YR+7/WqRDfIHLSfhzVrZzc3EGOg8ozQSk3IArTQv peUJS/lV92BSFaP39eKF/xeJkKpLf12PmQTshsPzRu+RyDLJkk39rJdSSW9pXfscX+0J ExbMQoTLMQ7HjM9fDGnabNmmvrYjXy2bByeyTxkUN2pe0skvRCfFKG/8RhsyUWX1Uw86 G8OG/dVvk/eKJsVdO48WF5ZJpNwD3os3+wvOpPugzbb0y4mLK5GMiAok472xRwzCTjOm pDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=50GanN+GF0i3mj5z8DjyLfDD9Soc0QUHLxcAJ3TSB11YanC2wrMBwSK+nzhe8vOPIh VxelASetu9oEhR1aaxVLEvLifGwNOcVHhu4GspjJdBNOvLSsTNcO3saFJM8oMh5aebmc QcOd5tN0RU7LteT+msUflJBLHI4GGs2dDyIQGCmHV6cEh1oyLoLrKi59tW8EGvLFJ2Ja MKRujY7IeOYbjinJMGRNztWLoV24zMROxSpsA04p55k6GODKNKqzjR95DR/C73DwXbQs 3DPq7Q3lvSNVfkIJVIu2E6g6yKJiZqg4WL4NVzEoKnQaK6XDPXlpzm/FVWvljTl5sIBF leEg== X-Gm-Message-State: AOAM531fvwpNFlpRzInYn0M0U6n/mK5FMAklkWmcIUmqaWMyvcqZkMo0 ZQ8RIb79mS/+WK3RXbCOOvYRU5E/agzJog== X-Google-Smtp-Source: ABdhPJzLc2yYEs22jUJTSY5HtjZam5ExvpzNe1Qwwfv0ZqrgKX/o8JNOOp0Gxpoc8+cIv0BKmfLiQA== X-Received: by 2002:ac8:5290:: with SMTP id s16mr5162195qtn.412.1632502787172; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 25/27] linux-user/sparc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:24 -0400 Message-Id: <20210924165926.752809-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, Mark Cave-Ayland , laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503642039100001 Content-Type: text/plain; charset="utf-8" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Mark Cave-Ayland Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 40 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_sig= nal.h index 34f9a12519..e661ddd6ab 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -69,6 +69,10 @@ typedef struct target_sigaltstack { =20 #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 =20 /* bit-flags */ diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 3bc023d281..23e1e761de 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) } =20 #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] =3D ka->ka_restorer; } else { - env->regwptr[WREG_O7] =3D 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] =3D 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] =3D ka->ka_restorer; } else { - env->regwptr[WREG_O7] =3D - 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] =3D default_rt_sigreturn; } #else env->regwptr[WREG_O7] =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp !=3D NULL); + + default_sigreturn =3D sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn =3D sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503809903219.64732938860016; Fri, 24 Sep 2021 10:16:49 -0700 (PDT) Received: from localhost ([::1]:45226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTooa-0000o0-OW for importer@patchew.org; Fri, 24 Sep 2021 13:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-00031g-S3 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:34472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY8-00076p-Q1 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qk1-x733.google.com with SMTP id i132so29018409qke.1 for ; Fri, 24 Sep 2021 09:59:48 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TpDW54Nw8YhHP+9jPj0cxZwWHyAWvFzhUjsYMPCYrAg=; b=xIMJ5M1DSDv0410bZB+xxE1p8qx9lod20d293kf53rxCA5EjFT3njJJ95x8bvOHK2A xN3BbstZM5SxiHB11evg/HZoLjt1Kpvi0zjEdVFrW7D2qyVzfc7atyWLpvbefPq5g13K 4HAdMCEZyKGwVhzsFZtowPkzJ11cgviLwdHGvkOa9A3YsWVHRbg5JOhNBQk7UP71+cfh C9yLZ+Mio/Iy9Q+t74rf9LkTNxE7cAeiCdcxtm1TJn5cGeB44VeRLzKNvswjHP2oyjp8 V81I//bgL0v96XaDVV8VrsdjvIAkv4Okwyro/IdIRhrEvgLiyGb3p9h1Q+J9oH6palB2 d4eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TpDW54Nw8YhHP+9jPj0cxZwWHyAWvFzhUjsYMPCYrAg=; b=MfuP75aw2rSNhLPWB4K1umNJw9vle2b2REmh11WwNL1dyOwsfXzD8igd34TY9Bl+7u SoT2GgPmjo01WUACW1o+42+uVNHxzcKKe7SeQBBk1VmyAU5TBW4nKn2OrTs8OAPaWuH5 VWw66wqUFSRbDB0glJcxhr6LoSjGhT1EQvbd0aYViVdCrTobQSAQH0dWfwxMI+tVGy28 8YDlrBbavgqfl2nNjdpa9GjV2euMSwt5B/zaJw4FtELoh0jBz4OrHJRi9ETqUdvkQtON ov9fhNiRX5IJAgt92AmXdienghuYlLHDPcAASSwsFsTKOSFs6BTd3sgKLaVTuGND2T/c v/Lw== X-Gm-Message-State: AOAM530IRy5OLygDolUywo2ohZLHQarPsdrdqkw/JdPhnMYj8m1OV9dJ MfOoJW4FFzzZT/qZVBuqqQoIEIywqDw2HA== X-Google-Smtp-Source: ABdhPJyWttNgDLxAsEHui6tEnE62a9ium5B8PhIf5W2Nqgo55rO3O9oGnTYrEo0gefbBKMPE/VFnFQ== X-Received: by 2002:a37:f613:: with SMTP id y19mr11365789qkj.524.1632502787902; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 26/27] linux-user/xtensa: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:25 -0400 Message-Id: <20210924165926.752809-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, Max Filippov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503810344100001 Content-Type: text/plain; charset="utf-8" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Max Filippov Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/xtensa/target_signal.h | 2 ++ linux-user/xtensa/signal.c | 56 ++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_s= ignal.h index c60bf656f6..1c7ee73154 100644 --- a/linux-user/xtensa/target_signal.h +++ b/linux-user/xtensa/target_signal.h @@ -20,4 +20,6 @@ typedef struct target_sigaltstack { =20 #include "../generic/signal.h" =20 +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 7a3bfb92ca..81572a5fc7 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; } =20 +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 =3D ka->sa_restorer; } else { - ra =3D 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 =3D default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc =3D 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 =3D lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp !=3D NULL); + + default_rt_sigreturn =3D sigtramp_page; + install_sigtramp(tramp); + unlock_user(tramp, sigtramp_page, 6); +} --=20 2.25.1 From nobody Fri May 17 11:05:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632503692608781.006238128069; Fri, 24 Sep 2021 10:14:52 -0700 (PDT) Received: from localhost ([::1]:39796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTomh-0005Xh-IM for importer@patchew.org; Fri, 24 Sep 2021 13:14:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYB-00033C-Dv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:51 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:33402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY9-00077M-Hv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id a9so6724948qvf.0 for ; Fri, 24 Sep 2021 09:59:49 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6YUMG9BLv2uEtpi53x6iY+Kj4bYcd7Wn5Zd273lBD+w=; b=nUkAvkf43ZVpU71HQ49DEBhet9R30v4JNPpMuXHZjlitnrmgEgjbmbNLWt3gtIFMm0 MMFemC5bEeVaP/4v+iOr7hIw+J5C71ggsaZzc3F8TToMdWa/Vf2MN9+0Kej1xdUhFNBg ZfWdgECkhnFRymiw9sT0EZdKh7dvI5VwCSXpQstJW+EJmE1twPPVq3QGPXRI8MUTGDxG p8uXJr6rvbZePRvaNgo4FjyxgpcLPce2VmTMkbZOZsRHkCNPByEoqebO3mXWYyBFibu+ u+gS1tWWkoItVV5CbDk0HnQJkwCV05qTVr7KNUmfy9XiN7c0XDasJSsPC3Fa6AzD6pKG 7NUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6YUMG9BLv2uEtpi53x6iY+Kj4bYcd7Wn5Zd273lBD+w=; b=FSCsVpXU6SkQS43HS9kUMs/FHDHavEV+7nHwgQE1NqU0MKgPoTn9W4CCTZ7XecX8KE Oz5xGiV+9UxvB2WUzqIHUyzZTUPFUvVjzZDQWI+dKqpSFTRmJGHCtYqx1Cj6xO1qLovK aWbDm+DDSfccSYr0lJN2lSzeaG/d/tYmgJ0fs43tZK49uQuBEkzX87Xbudr5aF2CZSvf gB8Ikw+7meoO6x7ibqGhD39D0fMHtlfUm6dmqDFnyLWVByBwsgIQZ0CA9l8/GfOIlUvj KiXu73VOe0yqH3LjIWJm02jGAlhDumiIX4STvxVCFkIVK9pGMvQmoV5l/3qQGdPtkWBr DOoQ== X-Gm-Message-State: AOAM532KQYwR53Kt759PXKEvvh4QtRCnTejNJZA0b9IaOWltAmgWsi2u 2Qx8X4sC3bzbe4LP0T739Z+0G1ExFgtLfA== X-Google-Smtp-Source: ABdhPJwdQFb4rPF2GHwyW1e9pnyPTFC0R2bUOowBoM9vYPCTaXra4BXWT48HtNDzO4VfhrUiHhXFiQ== X-Received: by 2002:a05:6214:13e3:: with SMTP id ch3mr10927371qvb.35.1632502788632; Fri, 24 Sep 2021 09:59:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 27/27] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Fri, 24 Sep 2021 12:59:26 -0400 Message-Id: <20210924165926.752809-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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@linaro.org, laurent@vivier.eu, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632503695631100001 All targets now define TARGET_ARCH_HAS_SIGTRAMP_PAGE. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/elfload.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 7b3a91b3ed..f6a4f8f489 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -30,10 +30,6 @@ #undef ELF_ARCH #endif =20 -#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE -#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 -#endif - #define ELF_OSABI ELFOSABI_SYSV =20 /* from personality.h */ --=20 2.25.1