From nobody Thu May 2 02:40:52 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 1624044725644177.39198468029338; Fri, 18 Jun 2021 12:32:05 -0700 (PDT) Received: from localhost ([::1]:59400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKDj-00049N-NP for importer@patchew.org; Fri, 18 Jun 2021 15:32:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBh-0001ME-3v for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:57 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:36365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBe-0001P9-Fg for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:56 -0400 Received: by mail-pj1-x102a.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so8694477pjn.1 for ; Fri, 18 Jun 2021 12:29:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:52 -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=HS+I0dvUMHSdSBpKd/9G4tO8nimAsDvjzWITh6jD/wc=; b=PS5F61YQ+NVkboL5qTD/DEB9kwGdQ0/wMJDxhQcoWnq0aWUuMrRpSUwvtZ2OxtVSum ISLMP+VWs0Ibpd1F6iKUsxe2xTDCDhYcPjiUyYlCLN+SonaZjVOfpb+WgWygbEiXjZ1y MDKkucdkgvNWm44fQpd95iL5NX0iLgbXuS1DKX2RFTm3AxT830Z4NIcRN8guYFTILQzF aVJY9/bKWOkZVqOgTCtjXynXKiVh2ny2D+lZzmUftRUwsrG6eFiBZ1Z98E0LA4gZay/4 Ot3/rfmaplvCX5mq3RJWz2TlG1fU4mmOgqoiNxSUA2F5QOpd7yTA9bOcTQnxwVQrs1Hv 7i+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HS+I0dvUMHSdSBpKd/9G4tO8nimAsDvjzWITh6jD/wc=; b=sms1XaNpRXHndXsYt6O1OtKgG6OZlHkkxpjhyth/MWNFgP5T+8++okiC477HfBHEWI 0Uzp1Sxr2tFxDDDS0HlQPvWqzApg956WOay0ThQVL9bc2MX0JVcyVFXnwELBmTUZFdHi 4gMLBUPPrMEzRdGxxAI/rv4yfrLudLx1hSzXwCsVh0OTl/ah58AavRCNmzJ7SOdQwCzD RfS2/PThar4HWbqmPgZ7h9CThxjK2vf1XZPHx9dMVjP7r9888b76NgTenr6/M3iREySp kVcn29wBBB17+BtmNgZ8ALXSYj6int+iSvh5EC1Pe3j135IjTyN+JPyEq3M8GlX0tnp8 cPKA== X-Gm-Message-State: AOAM532jrmOo0Tr98hzLvc5zcd95kXVd+5eKlo9k4zFScOQwJFHyz1RB fe1kJzozA4iGnWyeLipQPqF88htrTxLIGQ== X-Google-Smtp-Source: ABdhPJyuHLSOlX9behXgraUi4MIt46YpL/jKd4JK37D4bOcFvNpB4ePb3h17oiB1QYTEbt2bBNvMGA== X-Received: by 2002:a17:902:9a8c:b029:113:d891:2eaf with SMTP id w12-20020a1709029a8cb0290113d8912eafmr6155745plp.61.1624044593058; Fri, 18 Jun 2021 12:29:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/23] linux-user: Add infrastructure for a signal trampoline page Date: Fri, 18 Jun 2021 12:29:29 -0700 Message-Id: <20210618192951.125651-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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: Max Filippov , alex.bennee@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) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/qemu.h | 7 +++++++ linux-user/elfload.c | 17 +++++++++++++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 3b0b6b75fe..9e5e2aa499 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -437,6 +437,13 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong = uoss_addr, int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset); abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, abi_ulong unew_ctx, abi_long ctx_size); + +/* Fallback addresses into sigtramp page. */ +extern abi_ulong default_sigreturn; +extern abi_ulong default_rt_sigreturn; + +void setup_sigtramp(abi_ulong tramp_page); + /** * block_signals: block all signals while handling this guest syscall * diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 17ab06f612..7bc67ac9cb 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -14,6 +14,7 @@ #include "qemu/units.h" #include "qemu/selfmap.h" #include "qapi/error.h" +#include "target_signal.h" =20 #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -25,6 +26,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 */ @@ -3232,6 +3237,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 9016896dcd..2f19cc0bf6 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -30,6 +30,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 Thu May 2 02:40:52 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 1624045066298833.4617699112664; Fri, 18 Jun 2021 12:37:46 -0700 (PDT) Received: from localhost ([::1]:49556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKJF-0007xU-3L for importer@patchew.org; Fri, 18 Jun 2021 15:37:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001TQ-AL for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:37756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBf-0001Pl-H7 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so8692543pjs.2 for ; Fri, 18 Jun 2021 12:29:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:53 -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=d9tona3FrkUxASE7ND04pERUPgqb3UguvkZrVQbmfTs=; b=XGhyRH02Fyr4/voCKwCAPEr0B4x8vc3L2NbBDdzNQsnHxPxANwVl8h5L50DOc8i55e bk0OmD06VXOypemhj2suNsbaVy7qjQ697b+RC4+YR3B+4K4Xk8M5gUsh4tLJudADHeTv yhOwKr/vAg38gCqGksA03Zj8FcGuKaF3IDZXcCeVjYmn+QaCvpHHtBsedEwAuwcMu3nq fweYBRTpvmim2QmTotKfFPeH5llUAeJjdCh4Z+8j7Y56AqjdUtzkpFG0vLNk7GBmD1VM Y+koyFj40SWI3zJJDdn3yAccCIBTNI+LPGEpmUVQOoq9pNv15eekpIMPUebNTPflj5o7 DGyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d9tona3FrkUxASE7ND04pERUPgqb3UguvkZrVQbmfTs=; b=kAplMkpPY2E9RlD0STrhCsZPk2Kw2bITQZv33QwG9M8D5PC8Gj6Pti/cDIdxQX5Mnq NuKb+uVDALHm7I71Y9oITxcQkAiUgIZfcTgq2/hu/6SCl6Gt4f8QqNyHw1L5Yf589fLS 9Z4sWVD9OP+aaOHz5gbvldt1oVGIrlgf/DncF5eLp/LtAPDmDZBWYmM4uCwhInNZOL90 ZwwSYbUsRFgKZ7S9L2XH+89vD0jB7iLJlrjWQcBa5IeX+qUJKJr5HF/tKMX+0F065vFJ NbCyWcLRiMNRK6RzRRbbJ5xoar5pIKTu0+qAMB3lzLDY/Wqg5mEuUxc2A4145D/rFKbi z0kQ== X-Gm-Message-State: AOAM532CXUvoIKgx/u68ATJWOe5sda2m0e40Fv8gdAkJqG4LPaM9PRkp 2NdSwwfADgLdAzggMs2/GZ3xEaVeq/HISw== X-Google-Smtp-Source: ABdhPJzJufPgqfIgvKOVF7cL0CRM36A6/sUC56obCxvRpklek7Pm7gkPCs8WqjpKoGhXatvJa050iw== X-Received: by 2002:a17:90a:4311:: with SMTP id q17mr22724216pjg.204.1624044593605; Fri, 18 Jun 2021 12:29:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:30 -0700 Message-Id: <20210618192951.125651-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: qemu-arm@nongnu.org, alex.bennee@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) Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Cc: qemu-arm@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 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 662bcd1c4e..65b84eb04e 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -108,7 +108,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, @@ -495,15 +494,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; @@ -576,3 +567,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 Thu May 2 02:40:52 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 1624044731419908.8648432007324; Fri, 18 Jun 2021 12:32:11 -0700 (PDT) Received: from localhost ([::1]:59730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKDq-0004Ms-2x for importer@patchew.org; Fri, 18 Jun 2021 15:32:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBj-0001QI-Uk for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:59 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:36808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBf-0001Q9-Gj for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:59 -0400 Received: by mail-pl1-x636.google.com with SMTP id x10so5207468plg.3 for ; Fri, 18 Jun 2021 12:29:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:53 -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=vF/Dv3hdb1vnrzJPeq46hpO+A1VIsu9mSs+eyoe3lIs=; b=RbVyyHno/O+Shg0lvjANiqAKI+ptVlioZ0YFEbbi6mV7m4f0Jpo9nY9DVu83OFdkCz 0EFEW2+PQBZDeNYfDlJNQOamB403QuqpSQ3bsIhhd5cBYDhtSES6kl0oiGab/FfhPWKr /xvEJYareZ/5DRQ9N4Y6OlBbTYwKle45983NV0EOpXeK4XBvhMYZeI4UQgfcV1YuSQG3 N7WWr/EXtmpcBsBtsNhySRSqCmkFMnhoMKfdueAZttGeu5IJiUGr9eqQnoMIhNLNA+YC q4TYvUd9rNmtte3A26Y82v6CDhJ15H61p28phbNolHaHIXB2HFJMT7F/e9MNqMX3wHT3 Of4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vF/Dv3hdb1vnrzJPeq46hpO+A1VIsu9mSs+eyoe3lIs=; b=acX/PszOdwuo4ucuNvAy0tgG+NlMR8ZGEe1QwU40CGsXz53pRetQJQzcRUQP+uS3CI EDTALydU7CU968aRjg7s3zNfS8YdkGWHcIEkJxltUp/EACtDP3T0oQvsU5OHtXSkjkkh p+wmTBgYmsoyf4BCSYn4VfXeHIeZis//R0G9tpotg3j2MjU4JWgaG160axg0T3TAQzw6 tJXjgG/Sf0yFmxWhvQEmL2hoLv7kXe/Th7TncIuo/Fk3IcqiFzK8HzWRYCvgoE0fBsSC afvXLU17myaNf6FdTSGavfMicQJXtSLYCcdJOBRjmpjoVa/TjbWRpKKqG5SA0eWJvyHa qyXw== X-Gm-Message-State: AOAM5309OQQ/BOSD47y2mezJP7onq8fHlebPNNUlDnHHqKDdZQtV78W2 rLMlqRpGu2+eWXwYFSx3cb5ivuTDgyhbMA== X-Google-Smtp-Source: ABdhPJzM7TbizGuojneKZmJl+RlBw/cUTJ9UxKZi1IIQ5Q9GshINiIYI5QGfKuVdJOTVQM5wH0hlIw== X-Received: by 2002:a17:902:9a01:b029:11a:d4e:8f4 with SMTP id v1-20020a1709029a01b029011a0d4e08f4mr6140345plp.52.1624044594110; Fri, 18 Jun 2021 12:29:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/23] linux-user/arm: Split out v2_frame Date: Fri, 18 Jun 2021 12:29:31 -0700 Message-Id: <20210618192951.125651-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: qemu-arm@nongnu.org, alex.bennee@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) Content-Type: text/plain; charset="utf-8" Split out a helper function to test for a v2 signal frame. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/arm/signal.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index 32b68ee302..cb65623965 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -165,6 +165,11 @@ static inline int valid_user_regs(CPUARMState *regs) return 1; } =20 +static bool v2_frame(void) +{ + return get_osversion() >=3D 0x020612; +} + static void setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,= */ CPUARMState *env, abi_ulong mask) @@ -422,7 +427,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >=3D 0x020612) { + if (v2_frame()) { setup_frame_v2(usig, ka, set, regs); } else { setup_frame_v1(usig, ka, set, regs); @@ -516,7 +521,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) { + if (v2_frame()) { setup_rt_frame_v2(usig, ka, info, set, env); } else { setup_rt_frame_v1(usig, ka, info, set, env); @@ -734,7 +739,7 @@ badframe: =20 long do_sigreturn(CPUARMState *env) { - if (get_osversion() >=3D 0x020612) { + if (v2_frame()) { return do_sigreturn_v2(env); } else { return do_sigreturn_v1(env); @@ -823,7 +828,7 @@ badframe: =20 long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >=3D 0x020612) { + if (v2_frame()) { return do_rt_sigreturn_v2(env); } else { return do_rt_sigreturn_v1(env); --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624044732711499.49031207882194; Fri, 18 Jun 2021 12:32:12 -0700 (PDT) Received: from localhost ([::1]:59844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKDr-0004RG-LW for importer@patchew.org; Fri, 18 Jun 2021 15:32:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBm-0001WY-Ik for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:43859) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBf-0001Qa-Sc for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: by mail-pl1-x632.google.com with SMTP id v12so5196280plo.10 for ; Fri, 18 Jun 2021 12:29:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:54 -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=xc89iOQ6Z9A7jmI+2EVW1gXxkL96LTZi3hKVzfLFP0A=; b=PmixQGL27Pxfz3A6w5dAYzho9T5gEWLniESYkDMaxFolfWLUDVGboa5mn0NuCZBSk7 yYhM+Cf08JMP+4SqQdyLIoqERrYSENEZYmpPZDAMcAeFp6Ca2WJPpe6GT+xtlIjXGBx5 bIeAKiQPIiEFSjfLpilGpc7SrBe7lz/Wn9stiQrdVXHaC1J5uXrtlVLzmdWf6fQ3MPov y40gKs2IZovY93iqFEzxLJk4fnY17Fr5AfPK6tVkjeE2Ns7QET4MlZjFjSPnWYGQ4H+T f7Vopma8RPtaFxuuDMJuwWHTQDlW6sczI2UJ0A5jOobZ90r+fMdfF8A/rWC59IQ9y/iB kt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xc89iOQ6Z9A7jmI+2EVW1gXxkL96LTZi3hKVzfLFP0A=; b=qti8bhiEaTaUOGCBSfMgkHV0VvvGeDc4widOPY1ybo5ss6huSJ7XSO/pbKyYW/CuI/ +6LFXg9ysot/JG+2c00dB6g4yAGyMc98JtRdzUCqDKkyrGveABQey3KsbytQI8vpva/y WHwPBG7uby0Gx6cRCxs2YV3jNDwZuxn287e66BEb5qc7C+yl7POt5OnPYVsch8VHFmZm dkT6W9CDQvuE9dPOg0KFqjQ9n6UCCJnTCqZe14y+o734Tm/r8nGvczeF2bWpko3qjIRX AA5VhLam7y1uDkdbwADQX8TyngLaVga5kPFhlxzNMKFRb/xNvEoLJQ1iQpPB1WJkuuDN qfqg== X-Gm-Message-State: AOAM533deGsPZVGbFmS3Zc9o8n2O78Z1IFroFLcIi2I51A79mhiOElrn bGqrXMOBGVu4JZmHu7L554VkIqXvAhT0Yw== X-Google-Smtp-Source: ABdhPJwzgCU0eb6qiL8x/wJBYfMVU6g/VQDpTlJlJ5hGV576UARtXC55f079tApajlq1uPHU0h99FA== X-Received: by 2002:a17:90b:1bc6:: with SMTP id oa6mr6085300pjb.36.1624044594623; Fri, 18 Jun 2021 12:29:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Date: Fri, 18 Jun 2021 12:29:32 -0700 Message-Id: <20210618192951.125651-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SPF_TEMPERROR=0.01 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: qemu-arm@nongnu.org, alex.bennee@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) Content-Type: text/plain; charset="utf-8" The value of get_os_release may be controlled by a command line option. Since fdpic was added in v4.14, and v2 frame were added in v2.6.12, this makes no change under normal conditions. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/arm/signal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index cb65623965..2d30345fc2 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -167,7 +167,14 @@ static inline int valid_user_regs(CPUARMState *regs) =20 static bool v2_frame(void) { - return get_osversion() >=3D 0x020612; + /* + * We do not create fdpic trampolines for v1 frames. + * Thus we force v2 frames, regardless of what uname says. + * Support for fdpic dates from Linux 4.14, so this is not + * really a behaviour change. + */ + int is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->info= ); + return is_fdpic || get_osversion() >=3D 0x020612; } =20 static void --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624044878869597.0540260228693; Fri, 18 Jun 2021 12:34:38 -0700 (PDT) Received: from localhost ([::1]:40948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKGD-00029q-PU for importer@patchew.org; Fri, 18 Jun 2021 15:34:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001Sl-0m for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:41734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBg-0001Qu-Ja for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:00 -0400 Received: by mail-pj1-x102c.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so3651954pji.0 for ; Fri, 18 Jun 2021 12:29:56 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:55 -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=BNQDUVyR3ttAl/s4i0xlO2IvPvq1tkDghI/KxgsvylI=; b=AC1CWAdQvfJEvLg1Akyz7PpKMSo5AtgvImyYJq9b8w9PNfynfZJnTqke3HXHaRPrhm HNM9VOzfKu7/ZkIYCb0VQDNnbCuKEtbgxZqbrCDvTOaXNDAmAeyEhasYaGvZaKYPAMYa DXMl+NdhCPqP3pKl4HhzBhIyj3aCfKVeRhQMYKAv+vjKNtO9IfVfoocSAqQTg3PnK6h6 Rom33ECpxZW8e9N9XVxFFzjYMtSvQN/bj8JXfR3fzAxZQS0YNy6e3t8/cBL8ZJdInTkV vOgvmtMsYw3sgB4X0rOxRt81GCtmb7Cxq8HNv2qNBp4XR7txBM45nPRmXPhQ9a/c2AjO sIMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BNQDUVyR3ttAl/s4i0xlO2IvPvq1tkDghI/KxgsvylI=; b=kCq3Q4hEFaYn5k4T4Y05GVETXfca0tS9Vb5CqPPol7OaX7mEqcPWg0lVgixsFV994B kQOABkLAgrIchxXeOX3DP54wQqVGi/K+xD8A62I3ZOsTp1rWRBtQbbVx5waRfLu6bSE9 joh7oSK2aSKKBcXR2KNeVFn2KuvZQDtBv6EewEw26SbzO1QIBqLfhuHlXixfZlQR/pvf YMEV7qFW3F/74RBEGRpdPtbG0usLhXw6S4XHn6CUXpxuvtsTHhyNVI9WdpKqAaE8Ton8 ItOCCMJ+FGsgmV34vbKO01pBOfxVCNas4MoJx64DwLXluay7IgX6JP6tE2J3mFG+0iGE lIgw== X-Gm-Message-State: AOAM530RHR9zQpEzUwQFrs/4eSbOwALBEzaDhv+wqRYbFVYvGIQDFDaK CIXUhIzxM3WYW5wqomsffjVky41Z4vNXgw== X-Google-Smtp-Source: ABdhPJx4EZCjuWDopqawF6ieZS7OMH1OO355kYq36I4GWGQatiDkEQDynD29XHD++yTJ6o2q7m/yQQ== X-Received: by 2002:a17:902:788d:b029:11f:6a5d:d5e2 with SMTP id q13-20020a170902788db029011f6a5dd5e2mr6264138pll.16.1624044595256; Fri, 18 Jun 2021 12:29:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:33 -0700 Message-Id: <20210618192951.125651-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, alex.bennee@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) Content-Type: text/plain; charset="utf-8" ARM is more complicated than the others, in that we also have trampolines for using SA_RESTORER with FDPIC, and we need to create trampolines for both ARM and Thumb modes. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/arm/target_signal.h | 2 + linux-user/arm/signal.c | 170 +++++++++++++++++++-------------- 2 files changed, 100 insertions(+), 72 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 2d30345fc2..63bdd59ab9 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -101,13 +101,12 @@ struct sigframe_v1 { struct target_sigcontext sc; abi_ulong extramask[TARGET_NSIG_WORDS-1]; - abi_ulong retcode[4]; }; =20 struct sigframe_v2 { struct target_ucontext_v2 uc; - abi_ulong retcode[4]; + abi_ulong fdpic_ret; }; =20 struct rt_sigframe_v1 @@ -116,49 +115,20 @@ struct rt_sigframe_v1 abi_ulong puc; struct target_siginfo info; struct target_ucontext_v1 uc; - abi_ulong retcode[4]; }; =20 struct rt_sigframe_v2 { struct target_siginfo info; struct target_ucontext_v2 uc; - abi_ulong retcode[4]; + abi_ulong fdpic_ret; }; =20 /* - * For ARM syscalls, we encode the syscall number into the instruction. + * Stubs needed to make sure the FD register (r9) contains the right value. + * There are 4 of them, each consuming 8 bytes. */ -#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)) - -/* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ -#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigret= urn)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sig= return)) - -static const abi_ulong retcodes[4] =3D { - SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN -}; - -/* - * Stub needed to make sure the FD register (r9) contains the right - * value. - */ -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 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 abi_ulong sigreturn_fdpic_tramp; =20 static inline int valid_user_regs(CPUARMState *regs) { @@ -219,13 +189,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 frame_addr, int usig) { 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) { @@ -243,6 +212,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 @@ -260,37 +230,24 @@ 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 use a special trampoline + * that reads the function descriptor from the frame, + * sets r9 and jumps back to restorer value. */ - if (thumb) { - __put_user(sigreturn_fdpic_thumb_codes[0], rc); - __put_user(sigreturn_fdpic_thumb_codes[1], rc + 1); - __put_user(sigreturn_fdpic_thumb_codes[2], rc + 2); - __put_user((abi_ulong)ka->sa_restorer, rc + 3); - } else { - __put_user(sigreturn_fdpic_codes[0], rc); - __put_user(sigreturn_fdpic_codes[1], rc + 1); - __put_user(sigreturn_fdpic_codes[2], rc + 2); - __put_user((abi_ulong)ka->sa_restorer, rc + 3); - } - - retcode =3D rc_addr + thumb; + abi_ulong fd_ofs =3D (retcode_idx & 2 + ? offsetof(struct rt_sigframe_v2, fdpic_re= t) + : offsetof(struct sigframe_v2, fdpic_ret)); + put_user_ual(ka->sa_restorer, frame_addr + fd_ofs); + /* Each trampoline variant consumes 8-byte slot. */ + retcode =3D sigreturn_fdpic_tramp + retcode_idx * 8 + thumb; } else { retcode =3D ka->sa_restorer; } } else { - unsigned int idx =3D thumb; - - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx +=3D 2; - } - - __put_user(retcodes[idx], rc); - - retcode =3D rc_addr + thumb; + /* Each trampoline variant consumes one 4-byte slot. */ + retcode =3D default_sigreturn + retcode_idx * 4 + thumb; } =20 env->regs[0] =3D usig; @@ -394,8 +351,7 @@ static void setup_frame_v1(int usig, struct target_siga= ction *ka, __put_user(set->sig[i], &frame->extramask[i - 1]); } =20 - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v1, retcode))) { + if (setup_return(regs, ka, frame_addr, usig)) { goto sigsegv; } =20 @@ -419,8 +375,7 @@ static void setup_frame_v2(int usig, struct target_siga= ction *ka, =20 setup_sigframe_v2(&frame->uc, set, regs); =20 - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v2, retcode))) { + if (setup_return(regs, ka, frame_addr, usig)) { goto sigsegv; } =20 @@ -475,8 +430,7 @@ static void setup_rt_frame_v1(int usig, struct target_s= igaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } =20 - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v1, retcode)= )) { + if (setup_return(env, ka, frame_addr, usig)) { goto sigsegv; } =20 @@ -509,8 +463,7 @@ static void setup_rt_frame_v2(int usig, struct target_s= igaction *ka, =20 setup_sigframe_v2(&frame->uc, set, env); =20 - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v2, retcode)= )) { + if (setup_return(env, ka, frame_addr, usig)) { goto sigsegv; } =20 @@ -841,3 +794,76 @@ long do_rt_sigreturn(CPUARMState *env) return do_rt_sigreturn_v1(env); } } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + enum { + /* For ARM, we encode the syscall number into the instruction. */ + SWI_SYS_SIGRETURN =3D + 0xef000000 | (TARGET_NR_sigreturn + ARM_SYSCALL_BASE), + SWI_SYS_RT_SIGRETURN =3D + 0xef000000 | (TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE), + + /* + * For Thumb , we pass the syscall number via r7. + * We therefore need two 16-bit instructions. + */ + SWI_THUMB_SIGRETURN =3D + 0xdf00 << 16 | 0x2700 | TARGET_NR_sigreturn, + SWI_THUMB_RT_SIGRETURN =3D + 0xdf00 << 16 | 0x2700 | TARGET_NR_rt_sigreturn, + + SIGFRAME_FDPIC_OFS =3D offsetof(struct sigframe_v2, fdpic_ret), + RT_SIGFRAME_FDPIC_OFS =3D offsetof(struct rt_sigframe_v2, fdpic_re= t), + }; + + uint32_t total_size =3D 4 * 4 + 2 * 8; + 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; + __put_user(SWI_SYS_SIGRETURN, &tramp[i++]); + __put_user(SWI_THUMB_SIGRETURN, &tramp[i++]); + __put_user(SWI_SYS_RT_SIGRETURN, &tramp[i++]); + __put_user(SWI_THUMB_RT_SIGRETURN, &tramp[i++]); + + /* + * FDPIC require trampolines to call sa_restorer. + * + * ARM versions use: + * ldr r9, [sp, #ofs] + * ldmia r9, {r9, pc} + * + * Thumb versions use: + * ldrd r9, r10, [sp, #ofs] + * bx r10 + * nop + */ + sigreturn_fdpic_tramp =3D sigtramp_page + i * 4; + + /* ARM sigframe */ + QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS > 0xfff); + __put_user(0xe59d9000 | SIGFRAME_FDPIC_OFS, &tramp[i++]); + __put_user(0xe8998200, &tramp[i++]); + + /* Thumb sigframe */ + QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS > 0xff << 2); + QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS & 3); + __put_user(0x9a00e9dd | (SIGFRAME_FDPIC_OFS << 14), &tramp[i++]); + __put_user(0x46c04750, &tramp[i++]); + + /* ARM rt_sigframe */ + QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS > 0xfff); + __put_user(0xe59d9000 | RT_SIGFRAME_FDPIC_OFS, &tramp[i++]); + __put_user(0xe8998200, &tramp[i++]); + + /* Thumb rt_sigframe */ + QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS > 0xff << 2); + QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS & 3); + __put_user(0x9a00e9dd | (RT_SIGFRAME_FDPIC_OFS << 14), &tramp[i++]); + __put_user(0x46c04750, &tramp[i++]); + + unlock_user(tramp, sigtramp_page, total_size); +} --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624044921178250.42272926318287; Fri, 18 Jun 2021 12:35:21 -0700 (PDT) Received: from localhost ([::1]:42134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKGu-0002wI-5Q for importer@patchew.org; Fri, 18 Jun 2021 15:35:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBm-0001Va-9z for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:43850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBh-0001Re-50 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: by mail-pj1-x102d.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso6480166pjp.2 for ; Fri, 18 Jun 2021 12:29:56 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:55 -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=Jv0AKUAYCfq8gx2BZJi7SVG0aTCPQkqBNcO1pY7PIho=; b=DMSP6sPk2LlhG7ZPOxmaRMZ8QYXDW4fuDe9mT5oDb3nNFC71lkvdhnXGwgoTMZAVy/ 7VgDBU1mEO07RXb/XmtO+0bFlda2rdVgErZFFrFy3EP773mjyeX7fNh5YYdEQsoULa4I r/pNv5jMNeof16H8V4OTRd4YpheGjV3CoMUhWhZGlwsqgqWzaIjQj9QWSlKez2tgipCi UywmUgE3KTgIz3dAuX4iW3TVppfwWKM6r410kmJraOoFRRnBPM6MsG1XEG7j0dbLWS3Z iOYJ9aAQiGZmKhu3PZe8OegHICj7mKnTZ6YSe0oOXBMZH/uB9r6LD1LS2/wzTVo/dhKp CGHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jv0AKUAYCfq8gx2BZJi7SVG0aTCPQkqBNcO1pY7PIho=; b=ovPrmJIxG7gDcfwWrZkivmDeHh1fgfT9x7stfz0+kUFWvs0yySvfqmDJ7tExC1bBK1 MXEs+yStGn7jbE1ArB0UWLOerePDeGlX97nTDrnID5K9tJGu7dXaYNJ216//1cJ157j6 jy1h/hA/fOyzvdo93iXEtzcXVeXHNfsRvGE8k3u2iCEY26bNqg0HTql+YtIVShwpjpGW Ml5SOkNRH8Kn+2TrvlrBON01CCYY0VJQCNQX9imOeJ9Tp69VYIJzL6uvKwuNHeBPrA81 +n/Z7FcJbvrqSSQPhRIVs/e48TkrwEpCDzPZp7xgJFuSvzlqzhfakTW6mXfEgqbK2s9Q 6WWw== X-Gm-Message-State: AOAM532BTNCPyfBYMQ6Jkg9RV47Q2vlHTALyQ1J98XadyEcN13me5GND b6XTS7rALzXJJ1qSHygawK9pK38/xYrj7g== X-Google-Smtp-Source: ABdhPJyrThsp3uSW9cTg2rRq1AcVJLV7Sv8fkFOQ3orcGuwaGaTKA8rs4SOOWRRxQnqjDN9LA3yTJg== X-Received: by 2002:a17:902:da84:b029:10e:fafc:b29b with SMTP id j4-20020a170902da84b029010efafcb29bmr6169516plx.35.1624044595845; Fri, 18 Jun 2021 12:29:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 06/23] linux-user/alpha: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:34 -0700 Message-Id: <20210618192951.125651-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: alex.bennee@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) 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 1129ffeea1..e15f5438c3 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -54,13 +54,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 @@ -141,12 +139,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); @@ -195,12 +188,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) { @@ -268,3 +256,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 Thu May 2 02:40:52 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 1624045113623950.7813870616343; Fri, 18 Jun 2021 12:38:33 -0700 (PDT) Received: from localhost ([::1]:52962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKK0-0001mg-K8 for importer@patchew.org; Fri, 18 Jun 2021 15:38:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001aL-Hc for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:40769) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBh-0001SJ-GI for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: by mail-pj1-x102c.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so8302007pjb.5 for ; Fri, 18 Jun 2021 12:29:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:56 -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=8EdJTWq8OgKipxSBNkme0TC2fL2bX66wTjLIFL0IsAQ=; b=eN2E6Xp0HrS7LanIyGtL4QBnH66ramgehpLPHNNXPJvR4ofQ+pgRPK5MNSIvTnaZCu SNPzy7ld8WpsrsepnHEkrbr/UWZpq2l0BD9bjw+SgpC9jhWz2BRn5P0FgTIS6N94f8w2 MRENw/Z5X0zfjPwRVxO0XE9TMHcDwNa4tvrPUcPNimlx+ZSBMFwQ3WN8HYvzyQ2UCpb2 YoOz0jjLI7jWcAkP9tQNmUckWeqdam8ncj0NQrCcD5hf/eEPSdz/E5L3JhGPvVeRdEkH uuyD2WS4V2ljMJy6FxxtLNXdJ5mIrpyQOKx5OIAOc6DHJxaGMFd0N6yakD2C5cqx8Qy3 cv8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8EdJTWq8OgKipxSBNkme0TC2fL2bX66wTjLIFL0IsAQ=; b=XWGq6FRHTghASgyWRRYDbPm6pAnNxDsOLS/goLG2tkA3e5RTscCv+AHAkGexjihT4W vVLOWzOoL0g5y/iseTfGQ35ga5tQRxzR47oBT6XODL2nUKQege6rJLEONb0xJC78MCRX XOay4sZJbEYk+2d10qD3ymXJOltIeYLV+2+uL49rll7mYA5unyZH8ECbQOLg55qd5yoW 4JUTJtpZNbvmA0uNYx5a2c8r0O+9EpJa0fxG2N+8CVLzsmpfkpiFclXXptm/rEYX/JTI fqBUc8l8tSZJF2vgbMtyfpQKDBkY5Q4g9/v3sgj8boliGBhvz14chrhC3sfXGupOMF7A bFgA== X-Gm-Message-State: AOAM5334XqwssAZIq2+wLTZ6FlmNQFHpGXKw89bt8hIg7A8qHOIiLVvh PICvKPaU0ugDecpDMCe47fjOXZIJixwvSA== X-Google-Smtp-Source: ABdhPJyVdKyP2Il8KJ7Z69TuSCYTJdyKwKyUhRf6hnVNiGgLppx47W03tYBonnNSEu98Jum3R5H0Qw== X-Received: by 2002:a17:902:7442:b029:11e:4b18:daf5 with SMTP id e2-20020a1709027442b029011e4b18daf5mr6113783plt.47.1624044596341; Fri, 18 Jun 2021 12:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 07/23] linux-user/cris: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:35 -0700 Message-Id: <20210618192951.125651-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , alex.bennee@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) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 1e02194377..9dad50f31f 100644 --- a/linux-user/cris/signal.c +++ b/linux-user/cris/signal.c @@ -96,6 +96,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) { @@ -111,14 +119,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); @@ -134,7 +136,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; @@ -186,3 +188,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 Thu May 2 02:40:52 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 1624045186518269.76674634763924; Fri, 18 Jun 2021 12:39:46 -0700 (PDT) Received: from localhost ([::1]:57960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKLB-000593-Ad for importer@patchew.org; Fri, 18 Jun 2021 15:39:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBn-0001Xs-6S for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:03 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:34341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBi-0001SV-3Q for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: by mail-pg1-x52f.google.com with SMTP id g22so8603786pgk.1 for ; Fri, 18 Jun 2021 12:29:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:56 -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=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=J7PPF48+lDRnKZZfvhzHBxl8eM9yzfps7HPpimKJUmOs5s/jkVZQeJTPOn1paYNf0O WMeyAMQOO/GETptn5sIEqono3A/KvqGpNh6NE+2KgbsA724adlTwZ2gkC3VOv7yRUyWn eL/bNC3bdTYvESGmCviG/XY/xeGjlFEh6gZ3Fh7rcdVIvppxp+8C9wEuaIkeaQzWvE+x Aju0CD/7UC5ig5DociR+z8fzLm/jFm6od9N8uxS7hdWZWJ7Qbci/a6iz2/72qfE7j5wL EUGz98dBStqc57DZeUvrtMF96nwTaiTVJ/1KLwT2bh3OFIzOO8rBRrvAj4F+axdIdkqB h3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=Cit3wuwRo5N16s3hIayCSKaB8fy4DX0X2SfoLrf7tHtK6a/KK/DL+7PGepwjrAQ8YJ 4cTXUODJeEBokQ0UHhH2tBf7DzM55gqQtdn7sJc8XxVHEVpLwp1nsvrfR4WLXCgu4KFK 8lFdE7ibuEwlP+o961HfzyVzZ302bEBVCmG1wRXw6ZkXkPMlWLujpHAQ4Z3dT2jiGKt6 Q1xrVSHSiLXeTK5xJc64J5s/E67SuktAU8loqaZWWuLW/BhoCd08CFhPWTK7kO+1H6eq tepAvLnEdpx4k56IR6SJ2zVIezq4mahzoptfvlmJqQxoMELXf/YoUM//K2GI+ZQuSd9w 3xtw== X-Gm-Message-State: AOAM5301TQKFtNlTgkgUtJIbwPCLEEhy+f4Zk9wL+PIDlPpQhmR/tnqZ N8H/xVjh6Hg0iYaKr2VYFghoje89tYT0Bg== X-Google-Smtp-Source: ABdhPJxh/mN846w1eN20LgDPUeGxA8AdXfd47xfps5L6EcRvc7F0ORNTHctAAT204G5i2dHeF9SuWw== X-Received: by 2002:a05:6a00:844:b029:2f8:5436:dc39 with SMTP id q4-20020a056a000844b02902f85436dc39mr6709786pfk.10.1624044596872; Fri, 18 Jun 2021 12:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/23] linux-user/hexagon: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:36 -0700 Message-Id: <20210618192951.125651-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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: Taylor Simpson , alex.bennee@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) Content-Type: text/plain; charset="utf-8" Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Taylor Simpson Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 85eab5e943..bd0f9b1c85 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -161,6 +161,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; @@ -170,8 +175,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 @@ -270,3 +274,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 Thu May 2 02:40:52 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 1624044961192735.8066318643034; Fri, 18 Jun 2021 12:36:01 -0700 (PDT) Received: from localhost ([::1]:44430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKHY-0004U7-6P for importer@patchew.org; Fri, 18 Jun 2021 15:36:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBn-0001ZN-Tr for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:38639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBi-0001Sj-MV for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:03 -0400 Received: by mail-pf1-x42a.google.com with SMTP id z26so8438737pfj.5 for ; Fri, 18 Jun 2021 12:29:58 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:57 -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=ulS4pyoB01ZaWpSAAqvb0/v1/U+/UDZcRnwG2IUgbYQ1Eio4F3ASbQIWDQxCNN1bAG T15drD+tdC5b9aUjLpyHwPLvxuvhq4wWb+CkRbYn0J6eirmNDkXHnxGOJvwPdYHao1wT kz+L1qMSdJN4EAYlwP4iHUvMsUWKKnoDUGvpSb4Coj1pEL8LsOEuIGgIp+rFPbpa3Mh+ NzGaiNAvbouQ4qnA53fWdQXq7ypBewhgc2Zcbvrin1pdWmhv5PlRg5qpQGsnofsjpL9e jAU9GuLbNcoqhsanq1KFLkli8lVDbJf3GlEZmrDh1df7FyXsGBL2IKaem4qGDFeKRv5f 8GYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=RgNqvpDfMdbI2E5fedY1LdmV6QMI0FeSYyvzRf75AbKxX+cr1YbMecdnMO45XqO7N2 EubrtylsquodzvmU40n2x4JE0eKAzbUsXNj73cdMcKs22iP99ksgRjd8CXFN7hvSAa6W Nlyt5Z/tOFFs5LV/3dDlSZxG4aD1IGT/xxCyaq6Djklznemtvyiy4sTorG13nURXqy7B qM/rXxsg87q0GuSXDpVKzWpNXidCTS7oKdZC34Ph5igbsHIX24Pd9rU29wsN57Vw4o3W b4wQoHN7lKIsxFWqYyY32EQrhCZJ1j6VVEMQwrc5Bo7t9xAYBneOdlm/VXldASS7p7YQ 76hw== X-Gm-Message-State: AOAM533k6fY7NBNlKkariZc4uyPUs+P5rtm1SBtk1ib+p9KG9jUG8weU eypVsdBJPnLfGnodkjkR9CB0mH9k89rW6w== X-Google-Smtp-Source: ABdhPJyXQO6912kWASFYxVohBqw2UV3HyIKM0oAZmDDnIiVAd+P7mexJq8KamP4RJdDrQLWv7U9wSQ== X-Received: by 2002:a65:6a12:: with SMTP id m18mr11450996pgu.229.1624044597375; Fri, 18 Jun 2021 12:29:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/23] linux-user/hppa: Document non-use of setup_sigtramp Date: Fri, 18 Jun 2021 12:29:37 -0700 Message-Id: <20210618192951.125651-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: alex.bennee@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) 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 Thu May 2 02:40:52 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 1624045084341164.38867796008412; Fri, 18 Jun 2021 12:38:04 -0700 (PDT) Received: from localhost ([::1]:50866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKJX-0000Nt-9S for importer@patchew.org; Fri, 18 Jun 2021 15:38:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001bU-Ua for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:05 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:37471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBj-0001So-1j for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: by mail-pf1-x42e.google.com with SMTP id y15so2618818pfl.4 for ; Fri, 18 Jun 2021 12:29:58 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:57 -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=Kmu7xnRVWsU3eWGJbPPKgl5+mSDH//+NJHn4m15m2Pw=; b=dxDQX56mM5aVhbrjiqVUUXkb6eNqKNlJBK+/HRkmsWFO8tLP4HuGULYH65nB79Z2De /0C7UlRBE6OeFS4XflOiOdklQKzTrH2l9AJslJU2MBN3g9qJ1gaZx3u9Lha4HoBKZ4f5 Qnm5mTXnSsZ3xNymQgkc7JtP5ZwZ7zhOl2cVaB34MkAjPfyJKTVtnvbrSi+aOWtcOzLx UjP4mejf9JeLreo+8DE/LgpKBjhYNiZUWa+wvpRy8Bo/gHrXjEUT+JumcGJ458n24SN+ IWFab3XYB+4ODWTXqYqPV/soF7SUAUEa/8cmO3YVugfrEk7P90oUDUk2duZel92j9910 vWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kmu7xnRVWsU3eWGJbPPKgl5+mSDH//+NJHn4m15m2Pw=; b=elE4tsTopswm4euNgv30P73eESAfyHu8vTgLOBIm1/ZSUbunf38RDuLs+3Iltx+YhR 5drFneqdxjEGf9MWDg8TRTOPB3BZhBBxA6KTc9Yg3bRVstuCx9tR985AD7sAJSEkojpj CH8tkWjAIPwdfQfEmFquPLHfFf1NnUTIUQ+xP+1fbx0VYXEE0I2fa/wkxa+etSAZeGGQ 3ImTqIixiOkJ8q2MNmX9cv/sWDafBfyIi4HypRaLWcluMRA8qEMLFV7uXe74PthlJ0bq tXjmSR6JxNjB3BCtlE99R4SB5ll96zIsSnkWhGlgx+Bj6ACJgAEdxGwANKCYhtcjKKpb Tuiw== X-Gm-Message-State: AOAM5305+w2vAWVVe7yOwuEHEzAbagK7AU6yL15sJqehA0dMsL2ZLns/ PgDX4uSeBBwsenf2Zn8dz7UH6cxclh/gzA== X-Google-Smtp-Source: ABdhPJySJB2NWa+GnD7MJjv0RANhrpFtbSVIahYRmz5DIZRdtwlF0Umh5FPnnMZro5uPqp+TinNqKg== X-Received: by 2002:a65:610c:: with SMTP id z12mr11670328pgu.453.1624044597869; Fri, 18 Jun 2021 12:29:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/23] linux-user/i386: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:38 -0700 Message-Id: <20210618192951.125651-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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: alex.bennee@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) 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 | 42 ++++++++++++++++++------------- 3 files changed, 29 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 8701774e37..a83ecba54f 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -337,16 +337,7 @@ 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)); + __put_user(default_sigreturn, &frame->pretcode); } =20 /* Set up registers for signal handler */ @@ -415,14 +406,7 @@ 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)); + __put_user(default_rt_sigreturn, &frame->pretcode); } #else /* XXX: Would be slightly better to return -EFAULT here if test fails @@ -591,3 +575,25 @@ 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; + /* This is popl %eax ; movl $,%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)); + + default_rt_sigreturn =3D sigtramp_page + 8; + /* This is movl $,%eax ; int $0x80 */ + __put_user(0xb8, (char *)(tramp + 8)); + __put_user(TARGET_NR_rt_sigreturn, (int *)(tramp + 9)); + __put_user(0x80cd, (uint16_t *)(tramp + 13)); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624045215835469.92025125510816; Fri, 18 Jun 2021 12:40:15 -0700 (PDT) Received: from localhost ([::1]:59430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKLe-00067t-Sg for importer@patchew.org; Fri, 18 Jun 2021 15:40:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001gx-Jh for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:08 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:45738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBj-0001T6-Nq for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: by mail-pf1-x434.google.com with SMTP id k6so8420080pfk.12 for ; Fri, 18 Jun 2021 12:29:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:58 -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=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=w/8jmxyBSKlvXRwDrwQgpovS6jdC54Ol5itVKLEOrJ3pdVj9Xyzqo9NjU1wkuiQlKq 0gxhhGClhOl950E/flYjrAnYb3zkYcEiLqcGyBTSVyJiOgz3ga/9maTlGwurmDmnVrVl 0hxoOb2j7Sff9T4vhZ76gRRB/lGELv2E93CXBCU0zXCrvhw/W0kJEqDliFA/6fRByb31 8+m5kjaBayrCXjr5f8RQYIfvx9PMbB71UlxLil9EzaxIMXcM3fZL6BaunP6SKsHuZaoe rMv00ojo/EOHMZhZEvFIY+5j5e4GOZJfkQ5gA9VyMlWo/YsTjpiPk9DWViVzVzgU3vJJ Lwsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=CVWnzKyB46jUCSm4fyMs5odknbkUJ2B/+E6CUkpIshZGstGbpqRCXO8B+IMAAYPotI BHha2JVtTPZJoI0WDilCdMQ/49oh8Yw3blM9J5GMkD2Nmmr5RPCBlJM5Wk7AI5cH+IDA GBeWe7RQowWCpBT0EhRZXcQFUIIfaqVgZLuZ18hFh5JnmlenCVdNzabdi1PxIFT8qvBl vkHbAhLrsBQXYKbCAcjD0bh+xFw1LyR76edRry6mah1e/N5ZOH2shXXyU8r9ptvcgNh8 Oc2PBcbmU+GyBujxpbs8ZMzN87TIADxe3pJZtt413zShQh4NxwF2LEKq2ovFFgP8h024 ZyrQ== X-Gm-Message-State: AOAM5305Najp5LU5a/NYVDgigVTfdG4H3rh3vJ5eFcTDQihNrVxcmz48 QmEPz1WqXpGPoLQiOJiw9DoUbR5Myxp6KQ== X-Google-Smtp-Source: ABdhPJza+epWZI6KmSqgvlpo/vVJSkgn86poDdwFaWTR3WxX1CW2mIIxBu2UIc2d2q8ML3SMrws9oQ== X-Received: by 2002:a05:6a00:1344:b029:2f6:5ce3:218e with SMTP id k4-20020a056a001344b02902f65ce3218emr6600467pfu.80.1624044598536; Fri, 18 Jun 2021 12:29:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/23] linux-user/m68k: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:39 -0700 Message-Id: <20210618192951.125651-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: alex.bennee@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) 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 d06230655e..b4fade1ed6 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -38,7 +38,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; }; @@ -75,7 +74,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -129,7 +127,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 @@ -151,16 +148,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; @@ -287,7 +275,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; @@ -324,17 +311,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; @@ -410,3 +387,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 Thu May 2 02:40:52 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 1624045365097328.98590404852905; Fri, 18 Jun 2021 12:42:45 -0700 (PDT) Received: from localhost ([::1]:37698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKO3-0002Ku-8d for importer@patchew.org; Fri, 18 Jun 2021 15:42:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001bV-Ud for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:05 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:38642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBk-0001Tx-C6 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: by mail-pg1-x52f.google.com with SMTP id t17so8594240pga.5 for ; Fri, 18 Jun 2021 12:29:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:58 -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=TA71KdY0ADT8/xQwWyVtukyaxSrQMBNG8W0Sl0VZeBM=; b=WCgmp3xtNOWyJCeVKGGBOhtZ2erCff7jAAGZlHCJ8unArE1RjHmrV69RNVbIBNSeHR vHLbrlKE9lfBqsghv9OZqXccqaglsmJPDChnldYDYELnzNafPLG1wyZByH/p1hnGUe2A Gkqp0eUc1zhqusZMyIqgeaA+0+NwdVoYYisYhKP+PrySF6i0UEb8z8tCw8sgdvv9geA9 WB43tRLRE4uTURIcGHaJktz4/Im5UGtpvlYnbB7yHaoRy9VmKTMQ7O5RV4noFDSpl38j kgTMFBXTFxM/66TrGuYkiSYF0HUIDmLKr2Hhkd7t8D9IgVPvmFipIGo0fFakxnPy7cF2 2bDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TA71KdY0ADT8/xQwWyVtukyaxSrQMBNG8W0Sl0VZeBM=; b=gGdt3C3znC+/C4E3jauB0QSe+uqF4FfSilk4oo79VxduiktUoteh7ZDeEL9l+G4LHJ AOtwxP+IqL3cDaqS+BoOzz9dBE/9kYKUWxplBJS4wPF8ScjA5k6gJInU0tenzl+3+UlT gS4PdtG0GTLHP/HztHCBbHpzVosAJo+MXxhL8EZ0NPVgVW54WqjpQpMe7b99Z+C5hXru tvPRdME/UMr4aNif/j9+rhHc8fkQCRypJOQZSHwe2lAuWKYFJAljAyDV9xdwdf3gv+RT VoVm1N5XfArWpVsg8NAc5awjnG/QhOaUa/ISKSomL+kjpa6sLSks5zTeflTndS3eeVkB LVNw== X-Gm-Message-State: AOAM533ij5yZDalQl6TbLIHvbjKKHBikF9+h6kAkWYRb/W4kSvEjIwyr auwR8hNSugmfnrJzLq2gKTHSu2tFHLA7bw== X-Google-Smtp-Source: ABdhPJxaS8D1CvsFaIoqFNRQLFBwugD169UajCuaVToqCItugqcADgEVlop6T4+tbgMF60oU8FpxKw== X-Received: by 2002:aa7:9912:0:b029:2e9:c61d:2f27 with SMTP id z18-20020aa799120000b02902e9c61d2f27mr6651823pff.60.1624044599173; Fri, 18 Jun 2021 12:29:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/23] linux-user/microblaze: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:40 -0700 Message-Id: <20210618192951.125651-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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: "Edgar E . Iglesias" , alex.bennee@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) 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 4c483bd8c6..aa27454931 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -160,17 +160,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; @@ -219,3 +213,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 Thu May 2 02:40:52 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 1624045584604656.3075575485908; Fri, 18 Jun 2021 12:46:24 -0700 (PDT) Received: from localhost ([::1]:47280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKRb-0000Xh-LQ for importer@patchew.org; Fri, 18 Jun 2021 15:46:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001gS-9r for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:37773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001UP-2w for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: by mail-pg1-x533.google.com with SMTP id t9so8580996pgn.4 for ; Fri, 18 Jun 2021 12:30:00 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:59 -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=aQk6J+grHW9DaaqkgSJkr7zW933EyDuzJBNH6gtlGcs=; b=suSbYMs7yIp+guc3RNSDsMT3zXQeM5yYei1ZLqLw8UlSgGOvym49StfFS12quacRut 53edUfRYfgc2wGVUVnMx/rMefXGHtS/tbF07ugPWG/REw/CzwCvpIxK0wZqZWQ7zDVoW qvGurPO+mfoBvqVe3KXjUyrA38s15fOrBLd51DkdkRHJbA1kS9TNtWCFex13wcl+mc+S BXe0YjDZuK2vf0+/giapqtgHuKDRUgbzCdOJio54UWHWADR0nmLuunHIXMfoaF3Tp/aM xs/37Zc+qG0MlvDRyEzkr/09iZVLdP9v16nLvOK1MTCw8Yir9cNrlRpoetFrQbQLwkeZ c3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQk6J+grHW9DaaqkgSJkr7zW933EyDuzJBNH6gtlGcs=; b=Oxxw2pkut+rmbHinXyWnWuinSDNjHbkKdp3axcb5do/Ru5KNZ26hDfa8bodkgWNXSU ZO6csdCQ4mB9eOQD5WjFZ4mYqXV6eACd9d3/H8rDtgNt10y+95bfnlzX/rcpuK9Xusv6 9CvMlvMvyltkvHLIiMhOwiaDeKznBQ0Ay6RCosJ5CxgIYVz2CnOiWa6lIRrBVvdCjo7u JWP/bXFuwjjLiPGq08gp2oTs3y2gAL1ecEraFn2aQaZXVKZ9KABV14ASp+R1cogAOt6m nfFYYwOLg1q5I75ThiA1FbIYaLLZi8RgqGhn74v6sGuog9dDR3fPkP7dLu9Lf1b/7otN j93A== X-Gm-Message-State: AOAM530y00x+RjYLc4zFe0LVsXIPaYOInE+DudzGc0sO5TxZHYATezRb HyfraTWW8GXPoLYUsKx6bE9YcBIeL0ljdg== X-Google-Smtp-Source: ABdhPJzmwcBLjatH3ChxNGxRs9unke3l1itxrtgFG43DoMAv3s1j7tq5PVpvgK8ehmqpwLhHpvIqUw== X-Received: by 2002:a63:6642:: with SMTP id a63mr11399854pgc.241.1624044599822; Fri, 18 Jun 2021 12:29:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/23] linux-user/mips: Tidy install_sigtramp Date: Fri, 18 Jun 2021 12:29:41 -0700 Message-Id: <20210618192951.125651-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: alex.bennee@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) Content-Type: text/plain; charset="utf-8" The return value is constant 0, and unused as well -- change to void. Drop inline marker. Change tramp type to uint32_t* for clarity. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 e6be807a81..7cad7526ea 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -86,10 +86,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 ... * @@ -99,7 +97,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 Thu May 2 02:40:52 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 1624045054912397.66665085530315; Fri, 18 Jun 2021 12:37:34 -0700 (PDT) Received: from localhost ([::1]:48752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKJ3-0007OT-Cq for importer@patchew.org; Fri, 18 Jun 2021 15:37:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBq-0001ft-S9 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:36375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001Uj-Ta for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: by mail-pg1-x532.google.com with SMTP id e33so8601786pgm.3 for ; Fri, 18 Jun 2021 12:30:01 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:00 -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=fJ2heq9/ybEPRov+oRcE6gMbBb+FglnKkmzlhd1SVGQ=; b=LnRmyAURUgstMs0u6vFLf8pOF4ImJsOJVCdptoR6PQTaDAmTGV7ncGfPRKn3qZdiRy 4aZXJyULOaQGJF27u06N2zasbJeolcS+U5PaanD8twwLI4BQkAM6242NeF/91awL3Wli 15wL7FYBGMc2nPbsX8Yx8mWc11JSmbvAH5XUdtDMgK+Zz1I3Qaj0OMxOMZVx33MObR1N H7cveWFE4tvzo/twU6nVgp2Dq+voquJXiuJ5eTeXn1AO9nIY7eXvi8Jjp9S9kV8rNNCw uCgRRvwhzmD6Gwk+il1wZ3dHNomezY/xjU4RnREHf5MMyzp0Mh9wdAe8I5n34iBz+47/ uBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fJ2heq9/ybEPRov+oRcE6gMbBb+FglnKkmzlhd1SVGQ=; b=SxhGiH0sXxFLFuFJ2AZQYEKsM7iTYeY2MXn0MhFvI0alXq3GZs7wezqhrvDbHl3Cug g2cocxVy8xEtmgP9bGl4OZh55ytdZV+k0jusLL2f/y97b9w9RE+sJ6HN2+TBlBgEljRf eTiQJLZ2kJn1ruH8AtbnfAEoCYjeALT7tSXwFG7uaxMaKANevAoTFnG93QSRM70KnB6Z 5CyLqg4XpAyEBnYFVeBnLhxQLyGY2MWhFi1W8V79144E6Xa1mG/dlvm+bkPSHCMuOvPT XOV9kGawWeVFy/VIdI7COl43biGaRTszyx2uveZGeq4/64b5JVxWL2jew/ZrLjBLcexS PhnQ== X-Gm-Message-State: AOAM531k8O+sTxqWxLVrIRTLHLWVk3ZtKhs4Ed/S7Y1ng+54ORcHggdq Uj3DvVam3V3ycqxHofxPad7tQ0FHtSZoKw== X-Google-Smtp-Source: ABdhPJyUSddRGIZrrv+MBm7EhvJZGH7+DbkID+B3LcJafHYa0cUaitKAOwlI7OUwonFYVb5W2Ii3Ag== X-Received: by 2002:aa7:808b:0:b029:2ef:cdd4:8297 with SMTP id v11-20020aa7808b0000b02902efcdd48297mr6748058pff.27.1624044600621; Fri, 18 Jun 2021 12:30:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/23] linux-user/mips: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:42 -0700 Message-Id: <20210618192951.125651-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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: alex.bennee@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) 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 7cad7526ea..a3db08bfec 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -208,8 +208,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++) { @@ -230,7 +228,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 */ @@ -304,8 +302,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); @@ -334,11 +330,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); @@ -378,3 +376,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 Thu May 2 02:40:52 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 1624044870148354.22418156085166; Fri, 18 Jun 2021 12:34:30 -0700 (PDT) Received: from localhost ([::1]:40212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKG5-0001gW-3o for importer@patchew.org; Fri, 18 Jun 2021 15:34:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBq-0001dw-62 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:35345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBm-0001Uz-Is for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:05 -0400 Received: by mail-pf1-x431.google.com with SMTP id h12so8466039pfe.2 for ; Fri, 18 Jun 2021 12:30:02 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:00 -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=ZrJxA2097dXMmX/dlQGDy3yrhTNOTODlU+a5YheuYl4=; b=r4F0vv0K7h++rrjBcH4YVyP/irWyfQUiSAelLjujini/dwT8FILiWlr5gCB+Pt3W/7 KyloRbt2sf7Dy34s95pn3jNrN/iF0Y6rozt9incqTi/CU1Y0bL5FMTpEsxxaYTMgpxrg SF6iYpwgJSW5XbJpJPcqU8T6LlqHuCj6cvJX+gU0CimfC0PdbKZBz6cmmo6l5b9EEC9Q 24iOGk0hp1SYvyG5bK6dU6C1Vh2S+Sh8m1Ry5hJYvdPOt3foaZMSWWxXJQ47tJnmkY2G ePz2MvGa6rgm1xnYw+v66kKRTyM7OadrHRvQKimEku2hFgMcGA/V5WpJLMVhFHxJ4LTg 4hUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZrJxA2097dXMmX/dlQGDy3yrhTNOTODlU+a5YheuYl4=; b=aTd6UnFL1bf8osBl+PIh2H+Jj3Ca/kxiokmseoNvoUcUmNEp7iljkUvol8sFRBh+FY Z6lV+FwiM9S2zP+lyc8hmqPY28khHff6tLUMw/KPo8iw0tr8wAjeyJ9mUfbOjixbBLoD J9UJq7FF0PMdE9EYbbfXsfDl3OuFc1ss+CCuuxfbpGJmdx7tPaoFiO8l1p/o1BnKrlrm wjzbuPgGEVn8rNG8XzlAojM0bvRo8rqOVYFkdipK6x17jTC6WQamP7dUVGeY2G6mgtcV +bk8vSozMOYBUoDuB9HzPr45oR95bcqnL+3DZ5kHMX8Wk3KdoeeLKqEO0RWjx+SbEPBf +hTg== X-Gm-Message-State: AOAM533cfzXmTgSZH/ZcRehxi9hF/TtiJuXuIALEeh6O7CFGAdBDJ8Pa zzWUlPefeVxxK1XnCKbRFbfcn/1+k2dKag== X-Google-Smtp-Source: ABdhPJwQdw9Z2mQJsTOHEWqtzZTzYA5c9UMd2yihPKHQoJ4BY/gVs+qcKBR1X+nSf4jgIzyNr5FNaQ== X-Received: by 2002:a63:586:: with SMTP id 128mr3674093pgf.366.1624044601203; Fri, 18 Jun 2021 12:30:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/23] linux-user/nios2: Document non-use of setup_sigtramp Date: Fri, 18 Jun 2021 12:29:43 -0700 Message-Id: <20210618192951.125651-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: Marek Vasut , Chris Wulff , alex.bennee@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) Content-Type: text/plain; charset="utf-8" Cc: Chris Wulff Cc: Marek Vasut Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/nios2/target_signal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/nios2/target_signal.h b/linux-user/nios2/target_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 */ --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624045488212950.2396656573078; Fri, 18 Jun 2021 12:44:48 -0700 (PDT) Received: from localhost ([::1]:43810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKQ3-0006VO-6i for importer@patchew.org; Fri, 18 Jun 2021 15:44:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001g3-3s for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:41740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBn-0001Wh-6l for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: by mail-pj1-x1032.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so3652236pji.0 for ; Fri, 18 Jun 2021 12:30:02 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:01 -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=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=MXBJO8WrC0oYtShlpSZiimCAk3xfBhYK4sfAhbkPuU9rCjqhNCRpcaaBNgPaIksRpP 4dpAFHlwGl8nDk8JKf/oWoKIeCioB2aebw0p2NHEu4iZK4csDLFUXv/IOa9YJ8B4OIf1 5WN0Wr3qdM0CXDTeioptOnjP0QlA3Of/ai1f8CN79zvRMVXx30ZKnKXqgpA7/R6yUJAY FgX5AZ1WqOn3DIgEwcIO11CGuBU70wC0rGam19cKZxyUmKibK2GfFGR+2bDuMmHt6Wct NUyfi+4qyVcNlNQQb9R3F8IgjYWpaonmBotCPeGtAMPDL/DT3soTmIenpGmlu//lCUZN nl3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=k3YQt1kb2ylsC6CidRGsC8iH5riF7/5vEyL8G9l80fRY+opdaMIoUS898bPeTCUt+A U2FaNHeeBhbqW8airPmCVaIEEbcbQUz8rJZIyeZR+9KgXxk/gX3gdqnw5dc9VL9Vs6en Y42NQcQIF4qPS8iAqVjKTG0c4htlS5spF9LQvKakrSHMYfueVRJD1RrYGWZ6+1GBJbYu rgjRJ0h9YcY+rC6FcIP+9AVKZYDpsSUl2cfi2ynKiJUieK6+3052pSsuAawln8s5fw8k 0YDGALQOVx9X63N7mCvdFLirjRD2xxtxosrKHYAi19dgbDi5jYThwLwwscxKD0o/FBH+ 4u0w== X-Gm-Message-State: AOAM532cz14FRluBBuXT2mnTu2IddOPcMu/CzDPMASz6Q9fUWG9cGCpl 0+rKPoyPYkYOGU83bt9oNLLkRP2ujO4ZAw== X-Google-Smtp-Source: ABdhPJyoJelGpa0dZtPRe0DOHqkt7zUoeZ3FbHo03ycpEiHpx0uh2crTINJJX1M26mIDV/QOf4kzmA== X-Received: by 2002:a17:902:7d8a:b029:115:77ae:e1dd with SMTP id a10-20020a1709027d8ab029011577aee1ddmr6170543plm.50.1624044601823; Fri, 18 Jun 2021 12:30:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/23] linux-user/openrisc: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:44 -0700 Message-Id: <20210618192951.125651-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: Stafford Horne , alex.bennee@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) 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 | 24 ++++++++++++++++-------- 2 files changed, 18 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 5c5640a284..b411b01864 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -37,7 +37,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) @@ -115,14 +114,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)); @@ -168,3 +161,18 @@ 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, 4 * 4, 0); + assert(tramp !=3D NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + __put_user(0x15000000, tramp + 2); + __put_user(0x15000000, tramp + 3); + + default_rt_sigreturn =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 4 * 4); +} --=20 2.25.1 From nobody Thu May 2 02:40:52 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 162404565508993.33026604195766; Fri, 18 Jun 2021 12:47:35 -0700 (PDT) Received: from localhost ([::1]:49376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKSk-0001yI-1t for importer@patchew.org; Fri, 18 Jun 2021 15:47:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBs-0001h6-6v for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:09 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:39767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001Xx-7g for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: by mail-pl1-x631.google.com with SMTP id o21so5193480pll.6 for ; Fri, 18 Jun 2021 12:30:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:02 -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=Zh9h+PmWbwWPB35P4oSzNT2+LT+dobQgpXEUdOMWBj8=; b=dvxTx89lOsQh5ke2jZafIY2SdwMOM0OI16qYjtPzNYj1tZF6lCtpuTfVeaLSR/w45f YQO6Nx5rvN1C7r+UjdLXJMKdi13Jw6AhPKxBKVWsZ2hR9B9xd06mYB73b9EGdLmRkgbp 0fu8WQSc5kwpKZVcQTcMK5kwh1P76gJ+Xt76mYtmRWYjz8ho5pKTi/YB5mVC34uvqJ6B MMnyLvVTOrgwJg63AnkhhDanazygsbNQj58uQTUw5XjwxJ/lkDI+/TURTU7n7HgJnn8f Toe4h1klP3HU4ErMiWCYTH3GcYbRtH1u0GcxOxsyNGcpAm9OX0iXWushAp5Ps2LJs+uT vtOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zh9h+PmWbwWPB35P4oSzNT2+LT+dobQgpXEUdOMWBj8=; b=E8az78/QIR1ojn15hz4tbfUFmZ/5zFb1rPIquIA0WCDvakuUiHgh23HxaXuUriIu4v Qdrmu28z+XipfBwqKw6Zo8jixkI/aJ0Y1/XD9p5AJ4qXvihd6+IaPvCRf/z3Zl+NXold EJkeD+d168St53PF+mtctBq+vD++BHwRhE95wgdBSQGGlojrDr+NBlo9uRX511McHL08 GV0n3o7bKsbdWwXxPI2E1cQmrBwhGDn+j1kQ9Kwixy1L59g/uMR0vMbzzP9tTt5UadZV 1G9KWmOhowsKxFqHbseZXYkCr5icYsRz5Y5FpSNQTh/N2u4GgosgurfJlqfMSzNRUHLe u7DA== X-Gm-Message-State: AOAM531Gii3yC5fNw8HbY0MiN4DSJniuaEEwArW4ilQ3UYd+gUG2P/NX VkkLPVGiF6Y7ntCosW0KCOokttl61JTP+g== X-Google-Smtp-Source: ABdhPJyFohmLd/HKZHlyOFRErzz/FjSxtZwgWJ2Xb6olm71IVYN5uXvcusOBTELdkBB72/AcsdMiAA== X-Received: by 2002:a17:90a:390d:: with SMTP id y13mr12789089pjb.52.1624044602466; Fri, 18 Jun 2021 12:30:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/23] linux-user/ppc: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:45 -0700 Message-Id: <20210618192951.125651-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: qemu-ppc@nongnu.org, alex.bennee@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) 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 edfad28a37..4ae35aaf6d 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -202,9 +202,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, @@ -437,12 +434,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; @@ -478,7 +470,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; @@ -508,22 +499,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; @@ -721,3 +707,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 Thu May 2 02:40:52 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 1624045755926218.95060890675813; Fri, 18 Jun 2021 12:49:15 -0700 (PDT) Received: from localhost ([::1]:52728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKUM-0004Cf-Kc for importer@patchew.org; Fri, 18 Jun 2021 15:49:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKC1-0001jb-Cz for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:19 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:33679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001Z0-9s for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:16 -0400 Received: by mail-pl1-x636.google.com with SMTP id f10so3071784plg.0 for ; Fri, 18 Jun 2021 12:30:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:02 -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=MOtcx8UXoEPFGOBT2e/rKGCkRm/dpzMLp9SnX27LvpM=; b=mcv4VK8fN8UZJ7lFtjj5B8HbT/akpiVAya9R9vyr5G1Xw0Md17FvMBF8mFcUox2lwc jPgun0nlsWZ7FUWhjrvPYrfxkNJ9pUG+1QJUawjHBA9PaGKdV3jfuFgQ1OD2w3w+rDD7 kSWxi2NgzF+K+ruUv8sItoBBE6KtA8FahQe9uEGEifLNnn9WVf5wRb/u61F8gCy5/gbq QhCyGEvXOflGGQ9rvPrcqinhEyrSLtE0+wrkm5AKLeYZNLhUE3EBMuli2ywiVrggZ+xv yJrxrl8UqgW5o3yQh+co+DezTeVacWQhwxPRgwE/pk1qxyvYApGrMeRvS0Rd9jbOQ/uK s46g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MOtcx8UXoEPFGOBT2e/rKGCkRm/dpzMLp9SnX27LvpM=; b=TgQPXiQfWHZuUpr84HoBqpJ76P2qRkIDm/W/R/YsptTBB4NPIqLRe3F9m6MVLQp2gY oOm7vJghbEIEbhLwpTdu368JvCFEpBSG7IayyAvPWjG/p9WVmlsSK0HTcTT2C7nRj3wH a+FBhqlHoHMdDS8YegQHHdGs6btaPTv1HmjMGfeVE37CqaJRMwk46yOeTmifbbB7be+B Xogh+lAH3V2xvc8bOAvkvamJLu7BOPVFQrHELaBuPCmkXnpXehCv080jMTOrBluSSFye BARjieQ29jp1gCmjWBnjw7MmruAKCW5DVRooiDn8zKh3R10iPhmggEcBEkFn3EZmBiao F+Kg== X-Gm-Message-State: AOAM5317N6kzAU3GTCTScj++lNwluVmrq/4SnrhpUngz2nsxO1/5chj2 nVxbfylAkE+6QVs2QLs/OQSjVd3g/aBQQQ== X-Google-Smtp-Source: ABdhPJyEY9DlckdGVjSvpF5ErF9bbGgK+4kwn3d0fUxivLHVptmY5HWIxXEX8AYLhe164nGZ6mZD1Q== X-Received: by 2002:a17:902:d4c8:b029:102:715b:e3a5 with SMTP id o8-20020a170902d4c8b0290102715be3a5mr6103064plg.83.1624044603042; Fri, 18 Jun 2021 12:30:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 18/23] linux-user/riscv: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:46 -0700 Message-Id: <20210618192951.125651-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: Alistair Francis , alex.bennee@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) 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 9405c7fd9a..4086dfa5d5 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -46,7 +46,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; }; @@ -104,12 +103,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) @@ -126,14 +119,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 @@ -202,3 +194,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 Thu May 2 02:40:52 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 1624045264388856.7619935042826; Fri, 18 Jun 2021 12:41:04 -0700 (PDT) Received: from localhost ([::1]:33180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKMR-0007Wx-AP for importer@patchew.org; Fri, 18 Jun 2021 15:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBu-0001iz-4x for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:14 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:39768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001ZW-PG for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:09 -0400 Received: by mail-pl1-x632.google.com with SMTP id o21so5193506pll.6 for ; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:03 -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=NC4wjKEI8ei8zXE+8oh5v+0BndNCvCJb6FftDxcNOnE=; b=T4b3zjm0jvUgmrtHPiEx74l1HZZC6n7bYilccyY3ECmRzfdVL+oGYlndRJCa5P5jeB uJS/6R519bzMeuU+ALMMGUecghY8xsopn83C8EEOUJBHYHucbWgT2RXZIQT8sbW5Az+u FECcffJnwW+3f89wJRjujB/UKIceweW7xxTO8KA6vGNMb2zUIybWGI4kBTUb2qLvCF8w H1BcBO/mj/r1MXvI/Ktovo0A3482XGm0/GMZAo4YlFYvNnnY1lUI0qUPWYUiRHsuNgNj FAlUHU3HXZLAeVaeIA4qn15ipn55Oc/YviLnDXEcfgfYYBoL5ymwvVknd5ejxMhQUqYB y6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NC4wjKEI8ei8zXE+8oh5v+0BndNCvCJb6FftDxcNOnE=; b=ayuFdT0KIyU+1QoRCyDvSNqGIkZsIhLjLZt0nbNjbAZjFx7AZtVHNd0F0BsGFn7eHa 72oT7wPFTcqHYiIYvQb9Nyzs06DPsYvAG1F5hprq0nejB2Q3RIw2D3M+nF5baMv4Z1zp mYiJwRecFgefv78vh4YIrdpIxfEO9SLCGqP8HEwYQl8Y4Xn5MH7ydeUXaj4PD5AUkxKv HspJpEdbb9ZMNbcI1coi/uCTmOX1nHE1Pvatlu6ek/HIxSScyufGX99tdAqbzpXXloSi RUDFX5XGbNmIG5QNmonOjI5Eu7NWdskQdiu/ki0LbsGStemQaSjj1soh3AM/r8KyDHzO ijyg== X-Gm-Message-State: AOAM532VqKUOC7MxLw+aDY1Tf2LaHqvuPNvC8B9TPQ/dpyXtOauOtAC5 uaQUmkWebz1JjrdTkJcJzUJFBKbqfTpjQA== X-Google-Smtp-Source: ABdhPJwn+IAI2hY1PjFvy8oMMSUEJgP4X7nIWI8sav7It6g/wak85VVNBUEUkusHp9xH4Vn3ltUnWw== X-Received: by 2002:a17:90a:ce8b:: with SMTP id g11mr11728706pju.170.1624044603556; Fri, 18 Jun 2021 12:30:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/23] linux-user/s390x: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:47 -0700 Message-Id: <20210618192951.125651-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: qemu-s390x@nongnu.org, alex.bennee@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) 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 ef136dae33..372861d6d8 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -67,7 +67,6 @@ typedef struct { target_sigregs sregs; int signo; target_sigregs_ext sregs_ext; - uint16_t retcode; } sigframe; =20 #define TARGET_UC_VXRS 2 @@ -84,7 +83,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; @@ -200,9 +198,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 */ @@ -253,9 +249,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. */ @@ -377,3 +371,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 Thu May 2 02:40:52 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 1624045860005364.84740870703286; Fri, 18 Jun 2021 12:51:00 -0700 (PDT) Received: from localhost ([::1]:56026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKW2-0006Ou-VD for importer@patchew.org; Fri, 18 Jun 2021 15:50:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBz-0001jP-SW for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:17 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:35368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBp-0001Zl-Bb for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:15 -0400 Received: by mail-pj1-x102a.google.com with SMTP id pf4-20020a17090b1d84b029016f6699c3f2so1351219pjb.0 for ; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:03 -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=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=VWn+KDWHp8gxLLDPUeSGh+anMq5EevRP427IpnAXrbv6BYCLLO70cts+v1rRdpYRrw oyBrHD8Ao1FrAOx2aJ8ESpq8noVlCFh9bdvIRmdLLuXbrYZUxpwbbhtGxrB3dZy5woes t1fux8l7fx+N2aVqVJLtUPDx9/KAsyi4rogmqqxB6Un6zHf9iTG/q0p9ZyLTxUfLCWcP H7/6/Ek/nqGRi6uuKMz+oT1Z5IBJbxuI/Zlry9Yp13TrQTeGT+bsr0nynDVkYU8CUTn4 QYZfUNEoAmt7g6oXc7CeoSPkT6MOx1oNx3BgQ2ro8qfq76cQ9v/piXPzauEtieNdzMgv MfAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=QZqhhsIaZwuosw2QCawNJB1Cz1Tp7KWEzeSdpvIU9ukqAcrI6xj2CkQS7WBgwJxGXu BODVuXfUhlnkuSrTS+oLv06McqJuipg+YQvClJubH9U8lxYiBmJ2Oo+6MPJW1nGqUoyD V7wlLCuk0rApPX5KeGiHCOlSUmpK95HReBzdxCI0faoVAj4sOCY2ZMWdExZXq/r4SsWS CVNSJ8vxAN7akjftZ0b1afhYtAFR0fjUF3sIC22xhl55zawmIQX1y4asGKRCrQcYYsU4 /JD4qCpL2Vj+dTETf4IfYbC2inOkqe8xjc4scL9FrvibL+uijHF74ZByhWrDgJrn/VLO XFQA== X-Gm-Message-State: AOAM531yiwj9PJECbod2iX61m4JQkR9/GYYdH2maOdKGYXYz57Az3MGh x60PrvBO+ucaYmpic/PvYbwPIv7uQwC57A== X-Google-Smtp-Source: ABdhPJztAofWtjSGBas7fBdFJX3iaIPIsPfewWK0D94xd/mPJepykLjwNiSmNx2LWRMeoOzgX/HZNw== X-Received: by 2002:a17:90b:1e09:: with SMTP id pg9mr23720337pjb.208.1624044604071; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/23] linux-user/sh4: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:48 -0700 Message-Id: <20210618192951.125651-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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: alex.bennee@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) 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 0451e65806..5a5ae69785 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -51,7 +51,6 @@ struct target_sigframe { struct target_sigcontext sc; target_ulong extramask[TARGET_NSIG_WORDS-1]; - uint16_t retcode[3]; }; =20 =20 @@ -67,7 +66,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; =20 =20 @@ -189,15 +187,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 */ @@ -247,15 +239,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 */ @@ -333,3 +319,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 Thu May 2 02:40:52 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 1624045392795483.8785262111269; Fri, 18 Jun 2021 12:43:12 -0700 (PDT) Received: from localhost ([::1]:38478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKOV-0002rY-LA for importer@patchew.org; Fri, 18 Jun 2021 15:43:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBt-0001iv-Mz for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:14 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:43849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBp-0001a0-Tf for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:09 -0400 Received: by mail-pj1-x102b.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso6480535pjp.2 for ; Fri, 18 Jun 2021 12:30:05 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=XiP20hLYh78l9XbpOtPsEORO3CXi/DD39o8DfjPNLzM6uUdIRI6MB+yV/zkXVCo5tb GkVRz9yfyiV5tIZIqIxCIE4v9Rxnc9QKpOYqE0X8n+aTAddqrwAX+4gbV4ThW3Wt2TMn IPwXKhOdfDhEuY/geiZB27n25VlLKuKA0w2s8J2WZ6dmeUoxdQpX5OHFK/m2keCZFC9i k89R1OU10QlV6VJ1julayM8o5Dfoyiqc2WLaIwSz7COj/FziujZg+ELGWsb+nrqhLMfW BL/9TlSPRGZoWqiPa/LM/v3h+MAjDB5T7uUudYxy3So4N3UoJ956J4ylDUXAoGrYOf/A Dk0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=G0JwMCqkYJFRJPD8vusAaEzNQNiBp3W0kGpqhP2mY/zAuPJFF93u8kYk4t1E/OMJl3 kb96Iwfjtv+TEv6CWO2j9DzarTM5gjRbcVAg7QcMk1mqzli/PbjslwmgWm2k9i8orBMa 1W0rmXDNA2VXWF/2jsjm0DGLcwu+qHE9x/LKZjf0QxvdH35k5/LOuMc9F5HjZRFgJv/P egg+EYv3HL9/wAs/bVQXO3DyfdOU7dPOek03b3XS61k3ED96hroU3Y3mcTRZQXEZR92y pgHxfh6trhQTzZiaGpps7gaB3cfpjTTI4KM7rM7mCXt0X4dgJ9jXlOayaIwP7hIsxjrR 9n2g== X-Gm-Message-State: AOAM532t7ZL4ij8s3r6JdbACRYpBFS/o9SdN7wyPezptFVPweewaIsH3 Qf/2scepTLLOD3GHNAdIWnKfmaod6PH+jQ== X-Google-Smtp-Source: ABdhPJz543DaW2Hp/9Ru/jjK5+8Ujlqs5VFyRXCq4p/5iW26PtllmHntnA9YaVwTzn4KQ0xbfaxgdA== X-Received: by 2002:a17:902:694b:b029:118:b8b1:1e23 with SMTP id k11-20020a170902694bb0290118b8b11e23mr6084076plt.31.1624044604671; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 21/23] linux-user/sparc: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:49 -0700 Message-Id: <20210618192951.125651-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: Mark Cave-Ayland , alex.bennee@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) 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: Philippe Mathieu-Daud=C3=A9 --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 32 ++++++++++++++++++-------------- 2 files changed, 22 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 0cc3db5570..65e9b7f8b4 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -290,13 +290,7 @@ 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]); + env->regwptr[WREG_O7] =3D default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -357,13 +351,7 @@ 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]); + env->regwptr[WREG_O7] =3D default_rt_sigreturn; } #else env->regwptr[WREG_O7] =3D ka->ka_restorer; @@ -774,4 +762,20 @@ 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; + __put_user(0x821020d8u, &tramp[0]); /* mov __NR_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ + + default_rt_sigreturn =3D sigtramp_page + 8; + __put_user(0x82102065u, &tramp[2]); /* mov __NR_rt_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[3]); /* t 0x10 */ + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624045193918425.38619963324686; Fri, 18 Jun 2021 12:39:53 -0700 (PDT) Received: from localhost ([::1]:58108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKLI-0005Ex-LI for importer@patchew.org; Fri, 18 Jun 2021 15:39:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBw-0001j4-KF for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:16 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:34446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBq-0001aR-Hm for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:12 -0400 Received: by mail-pj1-x1034.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso7650131pjx.1 for ; Fri, 18 Jun 2021 12:30:06 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:05 -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=r1aOR56lJG8Y7fzXfcIBZhWpAZ7tMlA6NQMa73cEU+c=; b=KyNN2hn0k/oADtZ0Dg6venc869M7WJ253Wrdjs4oCRqYIkOfTAAn+imn4oQcpcKicq FvHVSWdj2ZXwFk0UxoCiq3+/X3axylJdBf7+Lq6lmAAilI1a2jl2aWPZHv6LgIX1oojx xuGiFsHt2LnsfJj/2XAowfNoVc3LDoz7786sSbviedJsEFv5Wf6SJKXdjUuFHRNH1j39 gZZfY22OnrftUN91wjuj1IZSZKkVywxSx4EtJuwZbLm6ElHKrgtfNHMgNAtzrPblTq2t XLltc/tgXPnuz6PuDbVI6R6Tyfhd8Ybf1dMFq0t/s1nckyYx4uQHJUKPuAFz8u+wMq5X tARw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r1aOR56lJG8Y7fzXfcIBZhWpAZ7tMlA6NQMa73cEU+c=; b=rJ1t3pRtAtyUcPC9ROZg1z3vY8gEwLjkOH42C7O7NQrrhpf7LCLttRZtGHSg/D49Bt 5lArllWGjmi/VRsISzIHoWrdAoC8nuWCBnSJyF9d4OzCAgf7eyUGKFc7uh/q4zJ5Eje1 nKA8BfgGz/pbEUsFdAVmRDuVOrH/00qZeYNYzFJT+QdORGiA1IbZdzkfLytK8aeSopp7 jkjVDzgsury9AmDz+cgN6JA9k2VtHRfZWq21rJtr7jPCazOM6GYwF+q0crOt7VDyvG3Y xzSIkoFY8k6902wPpUyPdUoN5fNLY58u1svD2M4R2A5+MeSf9rOlIoV20CLRDglnQBMP Yt9A== X-Gm-Message-State: AOAM532BlGze669zOe8+UKy+X3/1KlJFaj/lmvvnPtslfceAipK2zN7D ba28zclJrjoIDczlSbRAVRpUV9l7Bx2WcA== X-Google-Smtp-Source: ABdhPJyaRT0PNC4bKtbAWy2F5dKj8mQ9+DIktm49dvcD7du5cHxLhmdgIsGLZvtM3QhtOuI+Yg7CZQ== X-Received: by 2002:a17:90b:3253:: with SMTP id jy19mr21824466pjb.196.1624044605273; Fri, 18 Jun 2021 12:30:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/23] linux-user/xtensa: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:50 -0700 Message-Id: <20210618192951.125651-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: Max Filippov , alex.bennee@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) 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 --- linux-user/xtensa/target_signal.h | 2 ++ linux-user/xtensa/signal.c | 50 ++++++++++++++++++------------- 2 files changed, 32 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 72771e1294..fd57481bf5 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -163,26 +163,7 @@ 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 + ra =3D default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc =3D ka->_sa_handler; @@ -263,3 +244,32 @@ 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); + +#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 + + default_rt_sigreturn =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 6); +} --=20 2.25.1 From nobody Thu May 2 02:40:52 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 1624045439321626.0783777301942; Fri, 18 Jun 2021 12:43:59 -0700 (PDT) Received: from localhost ([::1]:40042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKPG-0003xS-8h for importer@patchew.org; Fri, 18 Jun 2021 15:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBw-0001j5-Vt for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:17 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:45981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001b9-4I for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:12 -0400 Received: by mail-pj1-x102b.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso6470950pjb.4 for ; Fri, 18 Jun 2021 12:30:06 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:05 -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=i6vIvt0pneZSp74FyENOB1Pe/9xAPO7tymkBwoPywig=; b=fAU6NcImZsmPlk0eKq/ocCWdcsrk+Jdv6eaN5UgT/fMvaeCHA6vXmn69zfsaLlFax/ vuiu/PAqzK1HgifYpQd82T03KW5PpxRmi8bBXzzdAGz8yDnXYq2JbVK4kDsXILjUacxP 5SFw0BXomsF3tpTb1O7eDQ11lAOms+UAlreFyQkxaH9NfuVSqXQPtpSBKgw7Uc4joDlK oXD7JWpZDD0TRvDbq1l+uYUtgr6bB3OzFCyLALC9NC19WM9a2YqkK3YDiximxUFa9Fzz IyyI4oXSS4p+mWlEhDCy+sDf3UtGeXPzzyMZXQx4Qap7wrMKOn2pYXrBOQFEAw4WP40j 0nyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i6vIvt0pneZSp74FyENOB1Pe/9xAPO7tymkBwoPywig=; b=e6Ywlqw/4Zms5nH7lVmUpWhA44x0QVDUioxn8RtrNXyK9da2aTsr2/1Mc2LhfPV00d MyTZL6qtyD/YTKSatlI4nVCr5EbU+hNllIn5Qf1vxVJ3EHDTAuQ4PeJjGEFDJfMtQ4ew fpteJHxnc/TPTWdNgeI3ud9xSDm9LBnGQoLh+Qde5HFny/pIUJAC4sj9QBrKRcNe//cr 4g7Vfr07mxBGyHtuskaOaTAV7duXAQIFcCIOuNLa6IMKoQLbZ4bBHnAV4FaKlMOXa66X 40rWbJmYTy3ImgNzCqDp1SJmNhKLMeVf0xuqaXzS7jYNe+baP2Cz46mAm6P/dfbpVtnO Syog== X-Gm-Message-State: AOAM531jxa9vZ00X3Iyhi8N+A5v4gb9mlIYda5s8y6wVnMCGsIPQEo/K ipq72Lw9/grD3tPWq9SXhtSeD0hEdNgk1A== X-Google-Smtp-Source: ABdhPJyEd1fjDwI6xa59YRosEOXN2OEe50jyFi51VD/PHbMmUlDrLRQEhZlHddPwPkoSNCIYij0shw== X-Received: by 2002:a17:90a:6304:: with SMTP id e4mr12749821pjj.222.1624044605899; Fri, 18 Jun 2021 12:30:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/23] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Fri, 18 Jun 2021 12:29:51 -0700 Message-Id: <20210618192951.125651-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: alex.bennee@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) 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 7bc67ac9cb..c0236a0b09 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -26,10 +26,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