From patchwork Wed Jun 16 01:11:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461312 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp98434jae; Tue, 15 Jun 2021 18:18:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLPnt7oKHm/BrlPQZNlPOXX0uG9QG0ZVzGOtxwJuGDr/JfxhKRHo6KLoY/mRh4N+tgp/tI X-Received: by 2002:a37:9606:: with SMTP id y6mr2585585qkd.13.1623806282230; Tue, 15 Jun 2021 18:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806282; cv=none; d=google.com; s=arc-20160816; b=FEDFvXB9RRJpYChM0oVeTA1PPAY+vArnCVLVjyOsjkNpFp84kut9XghfXmWRxmBZJS yC66B9H+N5qW/E//s1JgRuNhlRdIH5z9/11g0XRbacNaKiSabCnFGb0AJl9GRTgAO7Jq ZUeHpwG//jHDExhu9YduI8ILRyWFk4cgAeiP2FbWh+0uSdG0XtRQ1yPhUB4bcvxF/B/7 kP74tPiRyiL4eMvSs6/PNr2g2KjJmgqGzr4idCQmkaF3HjFC5FSxB67zVZvLMHmGosDa m5e0TSlOvU4j+Q7U1Uy2ZS07pJUwAMFa/m8h//7l4WNktlKXpVbs0xsgwb27K2bRw99S NWMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Co+NBcn5XBK+DAK9xxSpgD2XDizycUSYP6OtApqx62Q=; b=z/fSauP2Wq3q533NiLAuuKYFlUOrr8nJPaQwWzIjn8/7AZarr78vC/3FilrQZ6g8qR gU0VJPPsPCxK/A7SRqd7Hj+3HAjdfWkWEQMoIyilBHWVye0m2ZrGg85qCUy8IjtHnnXl wiEHgpJulN5myijuXyXkf8RB/J9zOWuqgMiCLPe54UzieUPOuU+Jike/I3C3XL1TMNzF 6EEq+H4Xl3K9jTtDsy30E9y5kFmiEzAdeEAGxhbgDOXha0kbZCvjrIycHV29QRxdaI4Q u8HoeQFIq632K4PMuV5oaMY1u9cTtxXrh4AJeU5afjrXQ6Y+fHXNmEC33zdIJnW3YQ41 F79Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pw51J59m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h187si469031qkf.261.2021.06.15.18.18.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pw51J59m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKBt-0006Dj-KN for patch@linaro.org; Tue, 15 Jun 2021 21:18:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6L-0005FK-88 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:18 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:43695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6H-0008Kj-4O for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:17 -0400 Received: by mail-pf1-x435.google.com with SMTP id a127so811809pfa.10 for ; Tue, 15 Jun 2021 18:12:12 -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=Co+NBcn5XBK+DAK9xxSpgD2XDizycUSYP6OtApqx62Q=; b=Pw51J59mq5JRdg9bnCvPTQZYKrPezZDqcSHo1q1pQ8ScRJw3GaukrPvVgqcE+gsnF7 LBUscSJc7VSox3lGwWQq9JLOBIyyoNId93K8FGt8VgERv2P+dOh8b57/TvIveQ83Jwxt CHlAzZtuBvsdDYv0ZbK0LqguZuuxjxUoIKRr9K79AGD2dxpDfT5IsxOKjjLELhmAq2z3 txAE56yqjyeSfWX5uJVjtbiOt/8dHMAsRPrtzRNry31+Kqe6RFLeEaF3gShN3wwNO3nq zqqH9ZXu/9HEVNyhrK0NYsX7xANDqMs0HcYDpCrpEDTNTpuRlFL1tJK+O9aZfmwOjZYb CVcQ== 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=Co+NBcn5XBK+DAK9xxSpgD2XDizycUSYP6OtApqx62Q=; b=XBFyNENFrMOoe2obsAObxnONmssMahGN08SQf4GBkd+B73axXj4udrOULVbsRYdCvG F4/uqcM288t8N56JrcarQNeiEtueERCxco4M8fpWfxtj8ByNtsATIEKyb3rnwRc/AZ4c 2fbfxl0AChNGJfr70ocHpKCduclecm20Cc/fGeo9DFxIm4Jm5rRDItCb7gcb04aL3xlV T1KkQUQEx6978nHUjjtYvNIr3Coi3gYphPwbzo4fhg1j+/EoNVa9gj2ga5ogTn645U7E udtBUG2QO1ndev8lpR7348zM8UR+qoLaiaDLe4Nm6vf2gRIEIZLjy5yz6IqAPMVTkSrx UAnQ== X-Gm-Message-State: AOAM532pF4AFNVvXKzTDdVK2mCgxeAbJyanjCtjId78VjER4C/lV9PJn Qm7FHJnuCTifjDy0vUNG3WqNyV24Xtd4Fw== X-Received: by 2002:a63:1163:: with SMTP id 35mr2394155pgr.400.1623805931284; Tue, 15 Jun 2021 18:12:11 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/21] linux-user: Add infrastructure for a signal trampoline page Date: Tue, 15 Jun 2021 18:11:49 -0700 Message-Id: <20210616011209.1446045-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Richard Henderson --- linux-user/qemu.h | 7 +++++++ linux-user/elfload.c | 17 +++++++++++++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) -- 2.25.1 Reviewed-by: Max Filippov 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" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -25,6 +26,10 @@ #undef ELF_ARCH #endif +#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 +#endif + #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */ @@ -3232,6 +3237,18 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) #endif } + /* + * TODO: load a vdso, which would also contain the signal trampolines. + * Otherwise, allocate a private page to hold them. + */ + if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) { + abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + setup_sigtramp(tramp_page); + target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC); + } + bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, info, (elf_interpreter ? &interp_info : NULL)); info->start_stack = bprm->p; diff --git a/linux-user/signal.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); +/* Fallback addresses into sigtramp page. */ +abi_ulong default_sigreturn; +abi_ulong default_rt_sigreturn; /* * System includes define _NSIG as SIGRTMAX + 1, From patchwork Wed Jun 16 01:11:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461310 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp96615jae; Tue, 15 Jun 2021 18:14:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykV2QR9fbUdbOPRSKgFA4Zg3tjuMDOlJfKj2m+uYEbh0nWM2tBCs+9bzZRhIDoXwOtmhvn X-Received: by 2002:a05:622a:10e:: with SMTP id u14mr2534675qtw.85.1623806076958; Tue, 15 Jun 2021 18:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806076; cv=none; d=google.com; s=arc-20160816; b=Ps1G45ahWu3zJFaBJv6a/Si93IFci+lzJVn9YIxUImhW/f7kDFtaBVoUjyAXO3pHSY 3nB5PTLCHxj1WteqTMBr/6w4anHTazZSaTcDhuDBT5H4LVZ7dvqyF/qesHwj7Dl3Q3XL ybYljvyufthGOGgCdPytHWUmsl/tyJGwR8h7sdesbtdgDAtFCl/0oFDchy+VF/dBWN/2 99MQpe5aAJMF59K/5G4a5AVh3sS4uhgjHdQgifkMVgxKZJSXICxamr1s/KZmF9iy9cWB HTP5eSTWc3owpBHLnb79v2lhxcP5xmAoScbByjaZa+Pp0wUS/l5uGvI1tmJXTUvr0Amp 9RoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=pYIekZ7E/4IYX4eiK6xNe4M6uHE016F0haAs2Oq20xQ=; b=EGROXlsULfM7sUfWvr23dxkiEoQ0hQKvNPNhQt3+pqTjC5GyXj+1l7AMZDwbmir3yR HibqW2tjZnD/Dr/ShVTAguFbIeNm+Ab2QWwR7Ohj5lVDmceHmygLi/e7JJiVkWqjZN7I adCujLOGWO+zN+4naa3erdOvoz/el6+54BYGoo085j54dfhtuawpd5O8X6B4kUt3T0ps 6uF/1eFl+3Othtz6iLFz9XHbmVWw2nSNOjuf5bQg1oGHRZl4DCmB6e6cA/A8ZtUHqdF+ fRI6COx3F9HaZI5RXByPV28v/epCk5wc9XugAIIopbZJjFUiMzSbNJTeT4tvVDtuy+yD oAcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cop90s9p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o1si547248qkp.24.2021.06.15.18.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:14:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cop90s9p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltK8a-0000EG-Di for patch@linaro.org; Tue, 15 Jun 2021 21:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6J-0005BF-Ms for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:15 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:46874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6H-0008Kw-3p for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:15 -0400 Received: by mail-pg1-x533.google.com with SMTP id n12so550380pgs.13 for ; Tue, 15 Jun 2021 18:12:12 -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=pYIekZ7E/4IYX4eiK6xNe4M6uHE016F0haAs2Oq20xQ=; b=Cop90s9pWYpPLPVIBKugKe96uw6O0INI6O5CcP/EL2iTFNKsBstuetvJG4dR1F73gu P9vVyf47OGlWh35TZBk9/TRzOtmGCMFbw6wLsMUl50/hNRGCZZ5RdNWtkuz0S3MJxzPK PeAfdwOsbrNJ6sDsk/3xiJA2wtVcmylFVQKSfxM3KHJz1jipMDMayX4qvad58ThzWYXR poKRmOheb5gC3LdjCZq/nutiv6uGIeJjKdpWeSXT0NcFodWw5/6PWznK/3GLOek6CDRn gzjAvtEFrL5u3zYzzAYw/3JDGVkCRGno4R0k96V/k/80fLI9tzU65I5gpgfZYW8s2zr2 sKdQ== 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=pYIekZ7E/4IYX4eiK6xNe4M6uHE016F0haAs2Oq20xQ=; b=TL+/YN3uqopAVMv5GnYUBEmffIkY94aFXOrIMNfDxQ+HlTXDJw7zsY5/HH69OL7fbG UGXYc/pGSpqv2ec3mixELQSaeJbzAxHuEgxXxJxZs4wvZgOWu44atly5lBjGxowqhllx k7GaF6X95qiCwOQxIlEPLIYS0B9UJ45dLh1aQkT35HSGe7QkJn20lfM/FuU0W0P/YVRU 7CRQud2UdHHYA7rXnQ9zfo+pu+2ncfoCQ/94JuLeDHd12oZA2cJ7uAFdWM+oPS3XXd1h rUne0W1pCkj27MsVfCRpGVn4dGxhYt0zn9ybQ4zhDRL8uTnVbjHydFfCGx8wUuT2MlE/ Ri6w== X-Gm-Message-State: AOAM530FvSvhj2rPMTbTFmxvcX4JMSGhX1xsoC0N3lmakCQpAMdx3/sw JVntDeraECF0tjNkPdThrbRIeOc6paB1fQ== X-Received: by 2002:a62:e307:0:b029:2f8:d49:7b65 with SMTP id g7-20020a62e3070000b02902f80d497b65mr6998165pfh.48.1623805931806; Tue, 15 Jun 2021 18:12:11 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 02/21] linux-user/aarch64: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:50 -0700 Message-Id: <20210616011209.1446045-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: qemu-arm@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 */ #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]; }; 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 = ka->sa_restorer; } else { - /* - * mov x8,#__NR_rt_sigreturn; svc #0 - * Since these are instructions they need to be put as little-endian - * regardless of target default or current CPU endianness. - */ - __put_user_e(0xd2801168, &fr->tramp[0], le); - __put_user_e(0xd4000001, &fr->tramp[1], le); - return_addr = frame_addr + fr_ofs - + offsetof(struct target_rt_frame_record, tramp); + return_addr = default_rt_sigreturn; } env->xregs[0] = usig; env->xregs[29] = frame_addr + fr_ofs; @@ -576,3 +567,20 @@ long do_sigreturn(CPUARMState *env) { return do_rt_sigreturn(env); } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * mov x8,#__NR_rt_sigreturn; svc #0 + * Since these are instructions they need to be put as little-endian + * regardless of target default or current CPU endianness. + */ + __put_user_e(0xd2801168, &tramp[0], le); + __put_user_e(0xd4000001, &tramp[1], le); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Wed Jun 16 01:11:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461308 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp96422jae; Tue, 15 Jun 2021 18:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeFZz/8Yyl6Wtl44DuWTRi6x/PtIJ89EIaWzzmhGBMuu3JEL6ynQxQH33ExujmoIlUuxts X-Received: by 2002:a37:b143:: with SMTP id a64mr2632823qkf.492.1623806058385; Tue, 15 Jun 2021 18:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806058; cv=none; d=google.com; s=arc-20160816; b=m3CIcAV0aW47K9o8Duau90gSn0v0e0kVJnVSXScRnhvxaf4s+j/5r2+BLHCdrykcm3 VAAp4ZWt9JGq4GfbyZFUCJ/ITLNaKew9BJMz0WCjnj6XE9UEqL0p7lvSEdGEMO34Mm9H ft/sEnBEq9X2JbZdGtWRjkaLFP1+3PEWKvrmlyd6mXadiX1XF9btPRGQBB/aYIXBHTMQ RBtsjxYPlZT2p2bNCiXsTBbKSqB4LcnlCg/Xx4BVg5RC5K/Hs6br1YZLCwFg+LF45dFc T67TKe99gE5iFxsuXSTih86uOnAr1h00+ph9yPqwTTIIcGUXs0+JDq8BtnESr6gHzhZ0 G5wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ll4cjliMp/QpwwT+A7QYxtz3tMdXsCsrcywGN6UTaqo=; b=SNMD7vYmxwosbNWgo4t3LS8viJoLd26qtjpdyJmIhgVMDoiyMAfQ/oxO/2cYDTPICd NaiBsucVO410qNmJJ/Hk9E87tmFUEqoopBh8j2a2+PNTGqOTAnSNRP1dUM1Bmo0gbBu2 zxiVn9c1QocWQsnTyi8hYAtfQwf89rUk+dDIOqcC5IplIvdwsw+wCa2ajOmk9w8Ge95L QvFA9BjUtYuPbfFylwUohBSnR1BomFD96A6GseNxKgYcVeKufomwvi+NT2pDFiPVW5qh TBr4VgGSaVXrNXOKHiVwiQaiZ2B4MLsjyeWCEGsIVui6vMASrOmv8aFBJyNNB/0hDCig KIdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XasN7Ker; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f8si489826qtp.164.2021.06.15.18.14.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XasN7Ker; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltK8H-0006K2-PD for patch@linaro.org; Tue, 15 Jun 2021 21:14:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6N-0005GE-9B for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:19 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:56182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6H-0008LK-KN for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:18 -0400 Received: by mail-pj1-x1036.google.com with SMTP id k7so708605pjf.5 for ; Tue, 15 Jun 2021 18:12:13 -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=ll4cjliMp/QpwwT+A7QYxtz3tMdXsCsrcywGN6UTaqo=; b=XasN7KerkAux5h/jqkF/x0qQLCMBrL+BnCwPXIvknphiqrpc1TCbj2pTT0ycnJ7pKk tU4upxoBSfv5BacrpoBM+ckumBy3TKbVdJPwQ36Ffg+lztYZx8X1YG+xi/C4E+bPibHP LFjV8lryc7brQdUBqHn+uPnDIZr9WqSWy5WtNfDM65XuzoQyJB90LN2Vvs8g4FunR2ey 9rnmx7gffIhpHNX16OOQivjGlkLsdU47j33Oj1uO3GrIKXBdzYGqp8CQ7hanFlRg2rKx pzSp3DBKnZKhBSfsmIt5kvqUwHNX9HOozcqaOYwjyhsbnERLmbSM2slaISTF507rSySO 8XOQ== 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=ll4cjliMp/QpwwT+A7QYxtz3tMdXsCsrcywGN6UTaqo=; b=fLhQRRbZ8vf6dj8cWxACTZlKM5DiTB88QBuF3yxuh7nE51XAN/6NgIO60FzFVsvF+K j/sorAfriNOxuw/SpC0m2wtVusvqtvuFszNjcxgKps724AftISTRqVJ7C4H/MnozfbYF 1OF7YNI2kcVmeyS9Mpg9/uXWWThAsfO3i8xJ+pJXMHbB6pBPdd8pmXfYfe+CSTRF6qAa cl5fcnX5OaBEIByOLGcrZdIKhXMwsUBJ0WnZIxI8XBScOjkULngYGvVF2Y2DeozUFkoQ ZkKk6i/BIthUFmE8rsVaHX17TDeBe3YPZcUNoUtX3i+GjVrL/OxYk/t2QTtIrcGqUalH IGFg== X-Gm-Message-State: AOAM530z95OEaxTPN/+HZqHRL+uLDbtEznB6WHzVS4OgT5zlJu0SL2Q7 pDXne6FznoSql7pN3iPb3LPRvbuGJBWAjg== X-Received: by 2002:a17:902:562:b029:10e:eadc:41a4 with SMTP id 89-20020a1709020562b029010eeadc41a4mr6737245plf.45.1623805932310; Tue, 15 Jun 2021 18:12:12 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 03/21] linux-user/arm: Force v2 frames for fdpic Date: Tue, 15 Jun 2021 18:11:51 -0700 Message-Id: <20210616011209.1446045-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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-arm@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. Split out a helper function to perform the test. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index 32b68ee302..2d30345fc2 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -165,6 +165,18 @@ static inline int valid_user_regs(CPUARMState *regs) return 1; } +static bool v2_frame(void) +{ + /* + * 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 = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info); + return is_fdpic || get_osversion() >= 0x020612; +} + static void setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/ CPUARMState *env, abi_ulong mask) @@ -422,7 +434,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { setup_frame_v2(usig, ka, set, regs); } else { setup_frame_v1(usig, ka, set, regs); @@ -516,7 +528,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { setup_rt_frame_v2(usig, ka, info, set, env); } else { setup_rt_frame_v1(usig, ka, info, set, env); @@ -734,7 +746,7 @@ badframe: long do_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { return do_sigreturn_v2(env); } else { return do_sigreturn_v1(env); @@ -823,7 +835,7 @@ badframe: long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { return do_rt_sigreturn_v2(env); } else { return do_rt_sigreturn_v1(env); From patchwork Wed Jun 16 01:11:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461309 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp96502jae; Tue, 15 Jun 2021 18:14:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE4oZwABa63fRtrP/r/rzSniv8FE4B8L0pSMGcCzPEe74tESv+8p9/nHSLh4FEr6ZJf3Z+ X-Received: by 2002:ac8:6686:: with SMTP id d6mr2561761qtp.51.1623806066777; Tue, 15 Jun 2021 18:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806066; cv=none; d=google.com; s=arc-20160816; b=CYf/ZAdWrmhWtp2fB4xnNCL3qBA7I0Xvs7c0u5aMyQKiWYG7LKMS4s9KO2cG2dswwu jc/uyM/C51kGaYLojYibOllM3IdpmrjtC3xQgBPdxxq53TVcR/SRLw3tCkF864MTZIT6 itqQntW27A7bWp9gMP4ZTD8rKoXNElT8KhDSNPGA4s5nXAZrqMgO8BVbrVm5LEBrsloT +crUqHn7QI8uO7y2ne1IllSNmDdtAy6ZqzxetdGwig8TB8tnJ9rRlUC4CjWqNp3Lj6Iz pXXC//MKZbvggM5OSM7zrvJn5V7HbyJEDRwUP1RSMJccAUIfPuLopLXcJyqcdkwlr5l+ GK1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8Y7lnR+2rZo6JZgZkMGROv3kdJ+G1tzBBjEC9+c66tY=; b=EBvjwmHyw5fdm7IqoKBrjMgTzf8a2OIMnkHKLUzNNdTD3RcX+i9t1ykUgiLE9cmtiC qTZEK/+kwvLfhJz01Dhwkk/2eEbnd/xM9DSZyZFwWgS8PJCICIAhbS7xujaSsQ3HAY/M JyW/6mHqi51U/2pM/cUoUmBneVBcdL8/9sloV6tyDyKwtDnKWMtgo2FIOeRsJTqD9Pvj TRehQFXijo54JQOgPl5hbdJjw4polppbDOs+xAK4uSkhtLKsS2U4/88r3+Xj8VMH+z0J KzzCOehQVGQAKmih6fDjSSB8WCRNFeOhvAzeWN01/qXNUbz3sIxYAuM2eNE1hD8IWbMf /S3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WJ04eVRg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o5si468670qkh.44.2021.06.15.18.14.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:14:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WJ04eVRg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltK8Q-0006pR-49 for patch@linaro.org; Tue, 15 Jun 2021 21:14:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6O-0005J9-C1 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:20 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:50693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6J-0008MB-1I for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:20 -0400 Received: by mail-pj1-x102e.google.com with SMTP id g4so749949pjk.0 for ; Tue, 15 Jun 2021 18:12:14 -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=8Y7lnR+2rZo6JZgZkMGROv3kdJ+G1tzBBjEC9+c66tY=; b=WJ04eVRgJbe6eHsz+zN8rb7NX4EueSbMvAB0XRmNm6CtVyWf4HbEhSoyR7wUk1+bgJ QJSUqSwFR0x+bO34knLs/pUeM/3Z3mspgY6QHpie6m1OivwKTBPdCZSgohd0ERUZWNM0 1cW7UZdzHyvstc4+5nzo6ERhGdpDVgwnOyL3vHFTnZZAduK6wvWpXAaaDqLq0GL+m3AU UPoP37wfkO3pYQwrk+xinxGX07DYfPYHp7t+lJAQo97ISilUMW7l0Kk/Dfs+GA3tkRK7 mts6ZXREhRg6NtgvR6hbbeocUtlKiAL9pplTGlJBCD/Aj/1DKr9vwbb+yPus1rWkGkq+ BwVg== 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=8Y7lnR+2rZo6JZgZkMGROv3kdJ+G1tzBBjEC9+c66tY=; b=J+Nx7iiKVTVaD5hxDoz1U4VCSxQAZyDha3o8AgNdJh+upUxD8n5yMXQkcl/PDOBV+S UAFuaM4Gno7aTdBonFwyAcUs2hL5//p9BpqtOUgGO+bwJGuG4y2j1FMbh35tFvwRZd76 5YZoAAbF9shbZkKcBDbqNNgbarD6F8kcIzfDrFMVOTvpaShCa0QuBUZtXX1Ho4y6gWSb 8YyWEBDI42+bJMHTR1E1Ut4QXGLrwWYgojElNTbeXP+il3chpV3rMjygOHrgct+BizU7 7kwy/fy+mhPug+ArK+yqyVG1qYVWIVQEXuUrN/0lY+48zSX14icRmkIITOq+7/NfEAcu ytKA== X-Gm-Message-State: AOAM532Z7wDZGu4FMpRcgQX86vOOFdToiA9Tt1vv/PoEpS1E6z6JT5gp ZMEyM/GTBVxQNIUUhwYPuNUltH0JHP8iwA== X-Received: by 2002:a17:902:a981:b029:116:a139:6054 with SMTP id bh1-20020a170902a981b0290116a1396054mr6498117plb.60.1623805933175; Tue, 15 Jun 2021 18:12:13 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 04/21] linux-user/arm: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:52 -0700 Message-Id: <20210616011209.1446045-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/arm/target_signal.h | 2 + linux-user/arm/signal.c | 170 +++++++++++++++++++-------------- 2 files changed, 100 insertions(+), 72 deletions(-) -- 2.25.1 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" #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..b7c3c80c75 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]; }; struct sigframe_v2 { struct target_ucontext_v2 uc; - abi_ulong retcode[4]; + abi_ulong fdpic_ret; }; 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]; }; struct rt_sigframe_v2 { struct target_siginfo info; struct target_ucontext_v2 uc; - abi_ulong retcode[4]; + abi_ulong fdpic_ret; }; /* - * 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_SYSCALL_BASE)) -#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE)) - -/* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ -#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigreturn)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn)) - -static const abi_ulong retcodes[4] = { - SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN -}; - -/* - * Stub needed to make sure the FD register (r9) contains the right - * value. - */ -static const unsigned long sigreturn_fdpic_codes[3] = { - 0xe59fc004, /* ldr r12, [pc, #4] to read function descriptor */ - 0xe59c9004, /* ldr r9, [r12, #4] to setup GOT */ - 0xe59cf000 /* ldr pc, [r12] to jump into restorer */ -}; - -static const unsigned long sigreturn_fdpic_thumb_codes[3] = { - 0xc008f8df, /* ldr r12, [pc, #8] to read function descriptor */ - 0x9004f8dc, /* ldr r9, [r12, #4] to setup GOT */ - 0xf000f8dc /* ldr pc, [r12] to jump into restorer */ -}; +static abi_ulong sigreturn_fdpic_tramp; static inline int valid_user_regs(CPUARMState *regs) { @@ -219,13 +189,12 @@ get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize) static int setup_return(CPUARMState *env, struct target_sigaction *ka, - abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr) + abi_ulong frame_addr, int usig) { abi_ulong handler = 0; abi_ulong handler_fdpic_GOT = 0; abi_ulong retcode; - - int thumb; + int thumb, retcode_idx; int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info); if (is_fdpic) { @@ -243,6 +212,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, } thumb = handler & 1; + retcode_idx = thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0); uint32_t cpsr = cpsr_read(env); @@ -260,37 +230,24 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { if (is_fdpic) { - /* For FDPIC we ensure that the restorer is called with a - * correct r9 value. For that we need to write code on - * the stack that sets r9 and jumps back to restorer - * value. + /* + * 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 = rc_addr + thumb; + abi_ulong fd_ofs = (retcode_idx & 2 + ? offsetof(struct rt_sigframe_v2, fdpic_ret) + : offsetof(struct sigframe_v2, fdpic_ret)); + put_user_ual(ka->sa_restorer, frame_addr + fd_ofs); + /* Each trampoline variant consumes 8-byte slot. */ + retcode = sigreturn_fdpic_tramp + retcode_idx * 8 + thumb; } else { retcode = ka->sa_restorer; } } else { - unsigned int idx = thumb; - - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx += 2; - } - - __put_user(retcodes[idx], rc); - - retcode = rc_addr + thumb; + /* Each trampoline variant consumes one 4-byte slot. */ + retcode = default_sigreturn + retcode_idx * 4 + thumb; } env->regs[0] = usig; @@ -394,8 +351,7 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->extramask[i - 1]); } - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v1, retcode))) { + if (setup_return(regs, ka, frame_addr, usig)) { goto sigsegv; } @@ -419,8 +375,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, setup_sigframe_v2(&frame->uc, set, regs); - 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; } @@ -475,8 +430,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v1, retcode))) { + if (setup_return(env, ka, frame_addr, usig)) { goto sigsegv; } @@ -509,8 +463,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, setup_sigframe_v2(&frame->uc, set, env); - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v2, retcode))) { + if (setup_return(env, ka, frame_addr, usig)) { goto sigsegv; } @@ -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 = + 0xef000000 | (TARGET_NR_sigreturn + ARM_SYSCALL_BASE), + SWI_SYS_RT_SIGRETURN = + 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 = + 0xdf00 << 16 | 0x2700 | TARGET_NR_sigreturn, + SWI_THUMB_RT_SIGRETURN = + 0xdf00 << 16 | 0x2700 | TARGET_NR_rt_sigreturn, + + SIGFRAME_FDPIC_OFS = offsetof(struct sigframe_v2, fdpic_ret), + RT_SIGFRAME_FDPIC_OFS = offsetof(struct rt_sigframe_v2, fdpic_ret), + }; + + uint32_t total_size = 4 * 4 + 2 * 8; + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0); + uint32_t i = 0; + + assert(tramp != NULL); + + default_sigreturn = 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 = sigtramp_page + i * 4; + + /* ARM sigframe */ + _Static_assert(SIGFRAME_FDPIC_OFS <= 0xfff); + __put_user(0xe59d9000 | SIGFRAME_FDPIC_OFS, &tramp[i++]); + __put_user(0xe8998200, &tramp[i++]); + + /* Thumb sigframe */ + _Static_assert(SIGFRAME_FDPIC_OFS <= 0xff << 2); + _Static_assert((SIGFRAME_FDPIC_OFS & 3) == 0); + __put_user(0x9a00e9dd | (SIGFRAME_FDPIC_OFS << 14), &tramp[i++]); + __put_user(0x46c04750, &tramp[i++]); + + /* ARM rt_sigframe */ + _Static_assert(RT_SIGFRAME_FDPIC_OFS <= 0xfff); + __put_user(0xe59d9000 | RT_SIGFRAME_FDPIC_OFS, &tramp[i++]); + __put_user(0xe8998200, &tramp[i++]); + + /* Thumb rt_sigframe */ + _Static_assert(RT_SIGFRAME_FDPIC_OFS <= 0xff << 2); + _Static_assert((RT_SIGFRAME_FDPIC_OFS & 3) == 0); + __put_user(0x9a00e9dd | (RT_SIGFRAME_FDPIC_OFS << 14), &tramp[i++]); + __put_user(0x46c04750, &tramp[i++]); + + unlock_user(tramp, sigtramp_page, total_size); +} From patchwork Wed Jun 16 01:11:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461316 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp99911jae; Tue, 15 Jun 2021 18:20:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF+ptob/8gWo9LIYjW5e+oJBc0Bpc5ogUYUFZPjU05QXEScv8fTjyB+i913JqmMOapP5sU X-Received: by 2002:a05:620a:1182:: with SMTP id b2mr2544353qkk.408.1623806437084; Tue, 15 Jun 2021 18:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806437; cv=none; d=google.com; s=arc-20160816; b=b0rZPNfqYlucDvXydctheJL04kTSur5GUW9xVYqGKbOLwGwvhlMYMzNndj0cXJw1JV bPRkKaXQldO/FgeSW+GZFz5p77R7HcgBHmbmgQAS0oeIaY2gBSkmaBLrZl5kKtugewZN sSqFxQMFteMQk/Bw8pjrr5rNWhyXXzoWZoSLzBUs3+j749nPtzaX0SLXZt7wu07he7jo kWdUttc1ijTk8D8ZqJ8BEOOQFit6yv0e6YeHZh2jlKOdhK3TdGUAFuOnT5oAcK6gfnao 3G2ovIJloM53k8uUYHqyU5l4HemwwDs/xTJKvJu77FrSVY6JWV5+j5Y5BGWKkMPIL+hG nZqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KFW3jyEgxroFTOmj54q2vXSb8LZmHdRxtn8eHcREl60=; b=TBe6JominJzdxtt8cv0H9WbmNExa4BHa0RgMxk8rG/YbfdVSnvqj0X+0/aY+GYCFtq hJwk/rnQc0XsHvtxJH+eszOcIZAHMkB6Mn7M5e80x9LZTmYzL9NMZm1DZoef6LVkJxyX uZOQjHINfE1n+D0Aa829ffJyicfYZOWp/76Y0Bk2GjMRPZMamEbl44CDGY/7LBy3S5bT TOonXLgdg6obRQzTNBaJh5y0+QSP+cQxg5qndmdOmGF7d10Hq8t2NBVn7bzH71Tt6DJ1 8dKYmSK3KuQZnSqJGMkZK+gWmNMqI0IUhVUQR+AIL1FwkxP61A0LWDnyZ2rhYTfXKVOC dzsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vxLryv0K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h19si506247qtn.294.2021.06.15.18.20.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:20:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vxLryv0K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKEO-0003hO-6t for patch@linaro.org; Tue, 15 Jun 2021 21:20:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6O-0005KC-V3 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:20 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:40541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6J-0008NE-6l for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:20 -0400 Received: by mail-pg1-x52c.google.com with SMTP id m2so573569pgk.7 for ; Tue, 15 Jun 2021 18:12:14 -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=KFW3jyEgxroFTOmj54q2vXSb8LZmHdRxtn8eHcREl60=; b=vxLryv0Kz9lxKcRRqFSZry7VfZ6qXzuAkq3pZWl4QDFJdeASI8S44E3Ay3bsOD+ezz KpOzVz49ldM9WFfJwo1/PtXdoSNOpndVw6w3ydBB+YYU2iIyBMNbmaIw2jalzJURCTPh 64KlpEDwJlIFSER6M6RhsCcaTZJuSDzc4OFXfNoneGI0yyiGSmw17cv1au/RjZcSYRqe dmafpt2XPhr2u/6083d7zJINMae0g8YZnyqXXK9j6waNZxzaqU4z/zZM0uINffFqDLHn 8xXfonZjMB1dTMlxiaNI8tpndQXyFgu3Rw++NdjjOtNkEnPRaMFhXE9eMwtNZ7Tzq5cR /4DA== 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=KFW3jyEgxroFTOmj54q2vXSb8LZmHdRxtn8eHcREl60=; b=T3IqCnk5YX9unKVVIy2igPuXSmYuy8QOxdhvpTUnYcHnM3tNJYpl3llFB1yLxBv5Wi qBNjr4pZ6f9WBCfqHqjY65bhJ49nO4GR6ChUseLJICEEtnKr4usmxJbZtVGxRSx1jA6X SPNOzRUyf4cJZ6DJo05UmT5mDVccurUwn1zuQX5lhQcnnhMefuIN9KOyQh7oS2yy0gcG Tl7EL5KH0I3UVNfBQfuSFH4E0eabGjQ3pTWB5peGRuS4+f9hQU8vr323CRrGEk95v1Qk EWi78Dkzlo8bU2EGglATThGGNa1auKZDBjiyX3ME4WnGMxliMGvz4RFS42zyo4hQWPwI OoNQ== X-Gm-Message-State: AOAM530bM6AJ8D/zLRP3Ly+C5zFwJoCryg8gm4taPcqUd+e9OmR2eQHY q7UXJQMYHGqLjofe2j9d5xNoc8QSYae4dg== X-Received: by 2002:a63:514f:: with SMTP id r15mr2293061pgl.374.1623805933892; Tue, 15 Jun 2021 18:12:13 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/21] linux-user/alpha: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:53 -0700 Message-Id: <20210616011209.1446045-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use ka_restorer. 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.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 { #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_KA_RESTORER +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ 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 { struct target_sigframe { struct target_sigcontext sc; - unsigned int retcode[3]; }; struct target_rt_sigframe { target_siginfo_t info; struct target_ucontext uc; - unsigned int retcode[3]; }; #define INSN_MOV_R30_R16 0x47fe0410 @@ -141,12 +139,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb() */ - r26 = frame_addr + offsetof(struct target_sigframe, retcode); + r26 = default_sigreturn; } unlock_user_struct(frame, frame_addr, 1); @@ -195,12 +188,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb(); */ - r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode); + r26 = default_rt_sigreturn; } if (err) { @@ -268,3 +256,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6 * 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(INSN_MOV_R30_R16, &tramp[0]); + __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, &tramp[1]); + __put_user(INSN_CALLSYS, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 3 * 4; + __put_user(INSN_MOV_R30_R16, &tramp[3]); + __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, &tramp[4]); + __put_user(INSN_CALLSYS, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 6 * 4); +} From patchwork Wed Jun 16 01:11:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461322 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp102599jae; Tue, 15 Jun 2021 18:25:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd2jgTE+rG2wZev3GeKq4mm5C2Hq0LCuPcowdiIW5ofazgOM204dTnM5Z/pAw2lO8XwFSX X-Received: by 2002:a05:6214:19e5:: with SMTP id q5mr8141038qvc.56.1623806735639; Tue, 15 Jun 2021 18:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806735; cv=none; d=google.com; s=arc-20160816; b=xzLpBWCI4CMqqxNKWm94BdAxRG80nnul3PpS4m31L1klOP8jZkpAs/fL00LITV6+Qj 4dlBaEyXF7iuJqBI6yDvKCapp0wk8EZ8ASA5UOO/LHjQrPuUDLC1WNE8ZaOI/Gs9YzaO nk2yak92jxnkEZ+kubtAXOaeMVlPEby6O3IuM4OvJcFxY5Jdchwqtev+KO8LePD3UopD X8U/fHLMpLsajUzGi4QX8j4HbrIyqlpo3TJmbfJRcXzhSJKaKMHECMzjo0FCBei0A2H7 vsz5OfALdBG08yCnK8bf3ljLVa0TkAgJiod7nY9imMC2anU7YEahGZ/NkY1+S0iLXRka FHEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mIx7PGhhOXR4M9l6QkZ85W49ZDY3JRjmGJKFwi0FD6o=; b=NFdjgHxlCWhYzoPt22UfgTSsyKNgFpQukn6N6n1k29UKRxFYTbfP8szafwfCtnP3XE +0aWqNhen6UxnVP+RzbMsxtAuZ5fQci/AqX712KP2w2bOK2rTZ3QACc41Mp392F+O6Z3 rBkBri/I5NsGH0Z3mtgbiNt4sCIYYU5VaOTMi3CQecrygNMUDu2b4kLlCjZZQprK8tOX Uxbxx0csZ3WDJIMSuQj8aU/kSbzJ1EaRX1TceFASQhwNzoLj6ZlEvrdR9uXh0VWQeX6x AYxR04oyk0xKX88CXri/KAM9XFUEZZz2DdFar44W3sDjNElOu/0TatH2TuhQ6M9qE37u 7Bsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xICkW3lh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 22si510531qtp.131.2021.06.15.18.25.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xICkW3lh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKJC-0007DN-WF for patch@linaro.org; Tue, 15 Jun 2021 21:25:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6T-0005XE-KJ for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:25 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:39571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6J-0008NP-Q4 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:25 -0400 Received: by mail-pj1-x1032.google.com with SMTP id o88-20020a17090a0a61b029016eeb2adf66so2769756pjo.4 for ; Tue, 15 Jun 2021 18:12:15 -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=mIx7PGhhOXR4M9l6QkZ85W49ZDY3JRjmGJKFwi0FD6o=; b=xICkW3lhruXZwAVX2FhH1X8qnoSV6M6NPRL/LJ3tEQaNpVnf49UZ1jE7jsqIi61H28 13HgeQSs1LXsMGmW7rdyXizOrz7rXRoI10SRGuS5dDqaEy6IyPCzUt9oMVYR550Km0Ri LqCIpDpjYDYvE5hrjdIBvBpNjNwFnAkdODOmPVLV58WV4LcmlBi+khuO7LuHHiBp+ygR CJdzbYg0cJlobVR7g5F/KJqyBc1QProQSKQkh7CrzHzI4BBcq1yQVjllWW67oHEF2oOV AVDV4HlAsyOkEgA2gEKcP2X3exJqJdEwf7ico/7G+k0y1kgKfL+ThLNfZRgPmtmKD6Ya 8IRQ== 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=mIx7PGhhOXR4M9l6QkZ85W49ZDY3JRjmGJKFwi0FD6o=; b=GP4rSXLQ+ww1TTBnP5MiaQu477kGWtp+rxytLM4ThnHF5lYzbPEWq35MmIspLDCyAR P9/jdfJJ1g2jzt3yo58ujGyy1L+wEnR+gM6oDIoK9awLhE9QY4pWxxMoq3vTULVHnv6x 6UrORa1ZRnykU3UMCMGxMWFiwx/nxFNogGVYvLWzfVeyKdcizR20iAS67aOn9oeBbuOh uLQARTA3+8d25y5DB1Z7+qDWY0qbheVEDiXcYYcVmmV4VKn+ZeLyt7vezIcYATCk0jxj EU2iYjm69DvUUdRMxzCfEAZnNC3ZT8rTEUWyfiqOEcn9aQribmFuZVfM0OuoO1aO8cz0 0ymQ== X-Gm-Message-State: AOAM532330xi/ijvR0MzmkdWT8RgnWoZy4O4/a84VkS+mUSjWD9OLySV fYoNqjTVITHJpxjKw2PRM9sgBzt1H3w1vg== X-Received: by 2002:a17:902:bf02:b029:11e:89a0:8694 with SMTP id bi2-20020a170902bf02b029011e89a08694mr1342546plb.83.1623805934539; Tue, 15 Jun 2021 18:12:14 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 06/21] linux-user/cris: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:54 -0700 Message-Id: <20210616011209.1446045-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: "Edgar E . Iglesias" , alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/cris/target_signal.h | 2 ++ linux-user/cris/signal.c | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signal.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" #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..51d1ee877f 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 framesize) return sp - framesize; } +static void setup_sigreturn(uint16_t *retcode) +{ + /* This is movu.w __NR_sigreturn, r9; break 13; */ + __put_user(0x9c5f, retcode + 0); + __put_user(TARGET_NR_sigreturn, retcode + 1); + __put_user(0xe93d, retcode + 2); +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUCRISState *env) { @@ -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); /* 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] = sig; env->pc = (unsigned long) ka->_sa_handler; /* Link SRP so the guest returns through the trampoline. */ - env->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode); + env->pregs[PR_SRP] = default_sigreturn; unlock_user_struct(frame, frame_addr, 1); return; @@ -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 = lock_user(VERIFY_WRITE, sigtramp_page, 4 * 2, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + setup_sigreturn(tramp); + + unlock_user(tramp, sigtramp_page, 4 * 2); +} From patchwork Wed Jun 16 01:11:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461315 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp99889jae; Tue, 15 Jun 2021 18:20:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwZc2+i7hHTb5CsdHlVf1VBeAtfmhw0t08/PzGYLG8pC4qY279UmDLs4mp/fRgxWsNE/lX X-Received: by 2002:a6b:d115:: with SMTP id l21mr1652716iob.130.1623806435764; Tue, 15 Jun 2021 18:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806435; cv=none; d=google.com; s=arc-20160816; b=BqvjyaVL5HT5rVnXueEg/CPv+jHkN8OepD1cwuk+K0F61UiQuwYldF29VcraSw2oxi 1f7M3abx76Gl8HRPM7PyXwmWhvVygx+3OhOkrGudCDGLZF4v6a4+pRwO2yhPIDvijPwi yqfKd4w/SVTzZqmDTEBo3i16hpnViqutC1iNiJe5K19fzz7CZeU452Q33jYbPHY1bnIG DQucr/LSDYLTGM+svPwaAV0VstYGQcXXRMgUOw8JvRg5k+P4TXMwWmZc+MYpR9LYdnlJ 2X8f6JeslsoYFJWlU00J7+UfuftTvAo6Lp7u7ovOvgPgnXodmr3J4dWv7SECoFrp3w3A ghkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=CaFcABB83tFu8+iwl8UtDBKV5pVEqrR30J/1S3zCb3hEdLrKTlC9WwKkjV9hjrhe23 /QuH1GZH8Uqw838XmJ7oX2p5lIkDMhxTohTtjhB6KaUHY2ynVGXnZWh6iayREusSPrUO pKp+kLtVnwKiAIQj9w6UvofKXKX2vDdXBW/Ori4sodyBa3WvpphA5My8gafIP2FziaJQ rMbSMOiguu5CrGnDiA5Cis6p+OU/g12IwdGI1Jf08gLpEmrjuA0eY0gWqNEfeJdulokG LP7fsix0f3Jkw6rxOyikYnj6qtjRmoc/1xakMvjeUAF3T7owJYlH+io38i7NtUhW1pXN dNhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fKfiqrpq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g23si626342ioh.72.2021.06.15.18.20.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:20:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fKfiqrpq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKEN-0003cS-5I for patch@linaro.org; Tue, 15 Jun 2021 21:20:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6Q-0005Oh-Hk for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:22 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:33605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6K-0008Nc-FU for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:21 -0400 Received: by mail-pg1-x535.google.com with SMTP id e20so624147pgg.0 for ; Tue, 15 Jun 2021 18:12:16 -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=fKfiqrpqv6eaRUENCso0hwzDHWHXnovlxlYOBG056sc/2KqU+sb5lVJxWCW3gTB/NS aJeK4GH7QNKp4LV4p3R50SdFGDZYzFUw4ApZVabGp0byBdPugRcqbw+qEnCW2fIaOSAA keCZRf7cNzsuAnyiiy7dJ3OWRXMcmTpvJO3s+cSUVv+iYfcQpUD5CEa+fOBZ73ut142z fwtDtsyIis6YnYHZ4V4s132bHpnGkE6tXGZ/G0KrCsa9k9ES/olpa8Rb3tl1JZSDsFF3 hhhDbJuiBxtmhgw2K/ky7JdPcEKdqcXsRtnX3MaF2mwBy5wpheDiE99xi95uMA51Ums6 k/Cw== 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=h9BlryBX3QuAvo202rIySgcC5DDhE2iyEwos6egY+NoTpjiOHG1yYvLqwIcSFzoieO NwUyfbyw8w/tC9ra0k/ZwPMtM88vJyNFzI95osS55fbHRWiNN1Be1cKhTflRrRyli0ZZ QfaMQSZBn4tdzdCHZfSvWsIY9Ust8OigP+YVgkN2Ahr538BEz2P+/9gSICi2P4vPwVsp 1qPagJ1Uma3Exzi6M+7ElKi+LZ0jU0YpBLBzuq+5yVLbyl5Xvtg66Hz+pOoEev+V2glF xzknAj66urQ+dj/lwjLeltmZAcYK/fnV4uHW64habJ7Kn/lLSSYvD1GfcI5ie1/4OlB6 FzPw== X-Gm-Message-State: AOAM533QOz1wb+LrErA+8GtFolFEria3yDE3PkLp7i84NLQPU7IueJiw k+/9NFiwlMjbXHc9Zrxuklb4lrCZ5RLqpQ== X-Received: by 2002:aa7:9581:0:b029:2ea:39e:2224 with SMTP id z1-20020aa795810000b02902ea039e2224mr7180170pfj.32.1623805935172; Tue, 15 Jun 2021 18:12:15 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/21] linux-user/hexagon: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:55 -0700 Message-Id: <20210616011209.1446045-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Taylor Simpson Signed-off-by: Richard Henderson --- linux-user/hexagon/target_signal.h | 2 ++ linux-user/hexagon/signal.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.25.1 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 { #include "../generic/signal.h" +#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, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); + /* + * The on-stack signal trampoline is no longer executed; + * however, the libgcc signal frame unwinding code checks + * for the presence of these two numeric magic values. + */ install_sigtramp(frame->tramp); env->gpr[HEX_REG_PC] = ka->_sa_handler; @@ -170,8 +175,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[HEX_REG_R02] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[HEX_REG_LR] = - frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[HEX_REG_LR] = default_rt_sigreturn; return; @@ -270,3 +274,14 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 * 2, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + unlock_user(tramp, sigtramp_page, 4 * 2); +} From patchwork Wed Jun 16 01:11:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461319 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp101033jae; Tue, 15 Jun 2021 18:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOs/hsL8+hnb+lESeOdeGGLrFrGoPMq8EF5hYpKMUaZX2v1+jT4EmRn16A8Wjr9LLlby13 X-Received: by 2002:a05:622a:1046:: with SMTP id f6mr2479064qte.237.1623806569683; Tue, 15 Jun 2021 18:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806569; cv=none; d=google.com; s=arc-20160816; b=rI+DCqBu/znZXyek2sm2hgqXFqTBcTUK3sBAgC2f72YIbefbwiCEOGs5L4lgF0bw2G 75gsAc5AUCbmX4NFgOjkkRbkD0GlQrk8WwSmStURgQlj0a8Yxa69lByRX0D630OFQTAe VP0MKd8iNGZ+59QWIpUK8G2FkFzPEHekH5nkkbaCMLi58N2GhuqLOC6orWN8Lvf7bPhc xMNTNJwDI7OuHkl3+dm7zNTB6PqfINs2qrVMjbW8j5uv2VQMOlXQZRJR6MA1GGVNk0yD 4U+8UbKDj+LHvZ4h0m1SxVioWXHZs2USJl5Gc1QQ4F7NY929Rfvr9IHbu719QvZNN3ej IInA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FJ88hjzMPCGkvsQLrCHEXf9qcVpoODBdkqIpV1aB2qU=; b=wNMSs/B0ujxfGMM5Cc8hl2iAjBzu8UicsMxyWFCcljHd2YkyC8YHQHelWKS/tuB6y2 idm9y8HwxOE6tbJ5SCgSnV1Do+BBpFy77IH5WFrpmICWdtc8kn+eL2g1rm4Q2UQhmghe aPpqMJX3gMr5r/FGj6jRiZI9TV2DVsG+AnHIHNjvgCnr+aQwhIJQdONFJ2qxRbjXfBR6 1MzEAERG6jkyJoQ9vCd81PIDEHJOB0iyI8Bo93AnocI6WHWkul5vbEmu+Li5JTqgR7Va giY+WhHSXUgezmMRJ54nJRb7Xd4CA8tVc0WcC/x+pBNmzSGHorS69VNok6TxKouKtNLG m9lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QGFgaaDc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l23si406902qkk.182.2021.06.15.18.22.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QGFgaaDc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKGX-000183-03 for patch@linaro.org; Tue, 15 Jun 2021 21:22:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6Q-0005PC-NE for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:22 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:35693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6L-0008Nx-01 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:22 -0400 Received: by mail-pg1-x532.google.com with SMTP id v7so593949pgl.2 for ; Tue, 15 Jun 2021 18:12:16 -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=FJ88hjzMPCGkvsQLrCHEXf9qcVpoODBdkqIpV1aB2qU=; b=QGFgaaDcyTvM1hVoJGpb7bJ2+HaGfWLBYjhelO9M0wKD3OCtpEs8mnZANdkFVYsZZT I6/x2CsNq2nyX17DzaEjOKdy5oLvUeEHbOks6sC4MpLcs13y9xLYBTNN1n2gcU+XTId2 Tx73gHVaGPpidUA7UhHgv9g9HmWxQ7TAtaw/QVdzY9zUhSQa4yi8665rlFv3yzvz5fMm KXQ5zGKtO2v+1prBRm+lJSUx4Bw4heZKgFEEKmYDPCDi+YM1PN25au8qELaG9cgByasl dY6el2ir2402rkvSlcSmlQvhe9aeVCwQY/PYSnmf7faxk1cOyNko1llcqYaK2Ys7FLhr Xm2A== 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=FJ88hjzMPCGkvsQLrCHEXf9qcVpoODBdkqIpV1aB2qU=; b=XZmNunCgYsmhI83XLyE9MB6GfCxlmWqbElfk4NhPlhlXahk72nkscRMPLpUPCd71i4 4lU4eCZEovMU8K+1u8h+Pig/xzZvsk984uwUzG0jtrTWfYPmYCgw+DOcwNC6XYtOsqtB c0+e0QHT/pkbwvdR+nmxSNTH1ebaI2Mt+33xM2EjPXZTDRedtrHFxxppT9CyB56ciGG5 ZiWW+TK6HzpaGEb4jBxooRACLzm7sjq4k6fIcC/reAYY4mvWkOyFzRiI1KhDqKtgGtzu XiB8SYDk3y8fPxs9K5GNqFApC2h8CBQcKsOWJiEb5yaguh5e9xfHEUt5JKPpzEx5+Ljh yXIg== X-Gm-Message-State: AOAM53150dONjROBDSEVBtQhDjJfoTh/IokOYleHPcplomd2yR68YgqH Db5QN16LjMthpillauw50yIJlnwBzYpY9w== X-Received: by 2002:a63:6884:: with SMTP id d126mr2381817pgc.368.1623805935732; Tue, 15 Jun 2021 18:12:15 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 08/21] linux-user/hppa: Document non-use of setup_sigtramp Date: Tue, 15 Jun 2021 18:11:56 -0700 Message-Id: <20210616011209.1446045-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We cannot use a raw sigtramp page for hppa, but must wait for full vdso support. Signed-off-by: Richard Henderson --- linux-user/hppa/target_signal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.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 +/* + * We cannot use a bare sigtramp page for hppa-linux. + * + * Unlike other guests where we use the instructions at PC to validate + * an offset from SP, the hppa libgcc signal frame fallback unwinding uses + * the PC address itself to find the frame. This is due to the fact that + * the hppa grows the stack upward, and the frame is of unknown size. + * + * TODO: We should be able to use a VDSO to address this, by providing + * proper unwind info for the sigtramp code, at which point the fallback + * unwinder will not be used. + */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* HPPA_TARGET_SIGNAL_H */ From patchwork Wed Jun 16 01:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461320 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp101508jae; Tue, 15 Jun 2021 18:23:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQEm42Y+lIBMs0uYmmWUsrA3W78unq5hxZ/+Udi1EQnxh0UHzLB55SWcqbygxPHxA0WbN4 X-Received: by 2002:a0c:f652:: with SMTP id s18mr8428611qvm.18.1623806619502; Tue, 15 Jun 2021 18:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806619; cv=none; d=google.com; s=arc-20160816; b=M4ojgCIMz/lQCdV9a7r2QKc7u2RmnArF1wybg5uT99YupBEIoapO1IriSASwAOaT/Y td7oUQec6XMhnLxS8HnpLFvYGLVaok/d+ABnhGKIxESkV5P55BaTv8FqzqQP2kqFjMP3 G/Gpfbl5dobVL0o6nvBH2S1u/LwBFTOIFk3pQZEpCLJ5BjYpvDDpP46TB/0IrzJbzh5K 2KF4x3/azx4Ztsro1DMEIvPpADkUzfNnXFZZ3KKuh5c1WRSGdFAdRph/vTfC+MNpf32Z AW0w9iqQRZArfiazy/UDx1H3zGa5nWTUN2U4jTuHZ8opG/XY+0crZnO2+TYyT76iqVKL MlFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Kmu7xnRVWsU3eWGJbPPKgl5+mSDH//+NJHn4m15m2Pw=; b=lBesYoeP0EUQZuAfosvoNG2z2JWvfnS2MAZikyeykvdOkIQ97Oak/eFCzGxP/NmLXq onjUt2otPkBWKlBLouktPTd6EHe4DB4EyM44tlVHKnM9S8U2WAHF9FIddS4Fq5tlBt4v vjwZtrw8KgW40ASYlT00sbPEJJJEh7fHyGS3N2EMwPGm4cZw6HleK2tCTRWaBrM1u7+2 CMDgePW2ub6xjhyN0W/+cGnEMCCFeoayr3qP202AqoYhBU5VJUh9jC/+v3vfDqpo5Biw /IGUT+nMLin3rAexO8Oo8Np77P8L/HHhruqrCDjMEBswHDEok1Zg2XRuMB1HxVmSbVyQ 6sVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ed4VtKxf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k3si487384qkg.368.2021.06.15.18.23.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:23:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ed4VtKxf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKHK-0001T1-Qc for patch@linaro.org; Tue, 15 Jun 2021 21:23:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6R-0005Sl-Ru for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:23 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:36383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6M-0008Pe-Rb for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:23 -0400 Received: by mail-pg1-x535.google.com with SMTP id e33so591010pgm.3 for ; Tue, 15 Jun 2021 18:12:17 -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=Ed4VtKxfh0RwqQObFFYEWcwtQraF0e+poohIOqVoKTseRN+B8jGbE6vYMrw8sgI+rU /5k9C404YTQ+7UT7pS0NhbRO/rAN6nUM7Fg/+TDAVSTH/ocH1Rzf01Y7fvGnYIPoB9DD PvnIURqL4Ylij0xeMJ8PcimDvwExgo4PdJ5XTFIa7jaXG/0GX7MKKtN/NtwnjZdaNBOF R6Hp6FKCs999vmwrj0HENOlNZwW7GZH2PFWtLqTm1uP0JmBYpgQjJlzqlCrmG5e9VtND CIMmBHHmYUj/QR4nLZFrrj+6OLpr9tf/IY/jPzarPbCg1+Y4GSYeRWTGbzB383+5mcF9 ju7A== 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=jFkXR5ZV942zDZ8xGSmlyGyNAF9TuRDUzYyyU4shiBS67Sw432Ov0cvtSA2MIIJu1+ sBYJKxPwWemYjbkSx1WqdAvUachkJgExbDckvox01pg4Tm7A4VcIkT9kNzSaKDT40WlL ARMYjz6JtMiPwvfUtMJudzJs0sCi76vm3j+qT4kgf6unF9R92SAMINCHCVpi0HKxG6oU WyVBu/qOHBpy3f5nc1/lkyevSyyMbvaWj9GA86qlt4fubdOs7quEhW9aY7wuUVDVNWUR Ne3Z7iKqA/je9ls2eHVruekB8xgrdD+h5yNVnKDN+i/65ImtMjiJB0R8Sq+vERTm67U2 /QBA== X-Gm-Message-State: AOAM533ZEO6MbzxyQ8OQJXhx+6fkpt446Wt/Az727aock/xGZ+vvqiIS RjTKyawjZxnU/IEWoYmLCwJYePNEJ1gTEw== X-Received: by 2002:aa7:9706:0:b029:2f2:4481:1e17 with SMTP id a6-20020aa797060000b02902f244811e17mr7224895pfg.53.1623805936370; Tue, 15 Jun 2021 18:12:16 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 09/21] linux-user/i386: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:57 -0700 Message-Id: <20210616011209.1446045-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signal.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" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* I386_TARGET_SIGNAL_H */ diff --git a/linux-user/x86_64/target_signal.h b/linux-user/x86_64/target_signal.h index 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 { #include "../generic/signal.h" +/* For x86_64, use of SA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* X86_64_TARGET_SIGNAL_H */ 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 = frame_addr + offsetof(struct sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - /* This is popl %eax ; movl $,%eax ; int $0x80 */ - val16 = 0xb858; - __put_user(val16, (uint16_t *)(frame->retcode+0)); - __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+6)); + __put_user(default_sigreturn, &frame->pretcode); } /* 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 = frame_addr + offsetof(struct rt_sigframe, retcode); - __put_user(addr, &frame->pretcode); - /* This is movl $,%eax ; int $0x80 */ - __put_user(0xb8, (char *)(frame->retcode+0)); - __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+5)); + __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 = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = 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 = 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 From patchwork Wed Jun 16 01:11:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461317 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp100540jae; Tue, 15 Jun 2021 18:21:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+pHKPdIIPCKUQdEip1K1rkTo5v0dS8EpeksXQUfhGF94NfBamZpOFbs0t/i+TlfBlyWKq X-Received: by 2002:a05:6602:2048:: with SMTP id z8mr1572482iod.91.1623806514941; Tue, 15 Jun 2021 18:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806514; cv=none; d=google.com; s=arc-20160816; b=sh5sIQRZlkNHLf6HyD42f0csitC8oVCgoPxo4r9LFIfg9QD68QOYK0s9bbhlatFznR rWm9Ty4eDTqbcK0POEjVCZjpc1faUKIlfsu8plKfYsit2C8dP0LqEIdKP3N07zdhIB2+ rDTvt0Pnnzjk+qHrsQc9tJCx19XfXoiRMRldFNZyQDNE1c5o4Ic5Xd0R0H3n7iu5WpzA DhsWKRBCILkJOmIMAxaph8Wx5xSNn4zjLRe/emmomtU0X0/psear7/0zMG8vas1KWJ6e Sqy+jZPHy0+7M8S553sMjsAQwJK8mmNaj5JH/YN/TJX4ZHmc7JyHBWaCB4lKe/C/ZrE7 5kRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=aMCRIj/ZF7W7IY6XN/z2aOBiqinNjqax8uyGzovEstg=; b=RO9FBbbC7iErZH6ATFBxMAp3CTJIwXZ96vYKLJXQIopbnwuWlHopffI9TQPENulVfw PV43inrOCqSSfv89M91aGPCNRyK5HegWZubvSuIAWSEciHLAeJvYI6rbkDn2lnRE3tTx LwIq8sJ8kz/Kn3s/epNFkcIBYaaU4Y5B9mDEaMesO1zTQFdnYNEB2ml/ujGcwURfu0Wr ixlLtUmaQY2tNySGqC5DC70ITf38+oJp/5X87pMwwO7ZNzQl6ZLK/uLagz3aVaLr0Jtc WjAj+Avv7nHsm9+wk2OKtmnkqkQ5ke9sCt/R9wMV8xkgQvrcBpNwFR5uLHUAF6/MCrsu rtow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aDyr0uvS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13si648937ill.54.2021.06.15.18.21.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aDyr0uvS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKFe-0004jj-Bt for patch@linaro.org; Tue, 15 Jun 2021 21:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6S-0005TQ-6M for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:24 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:41768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6M-0008Qr-Sc for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:23 -0400 Received: by mail-pg1-x536.google.com with SMTP id l184so569732pgd.8 for ; Tue, 15 Jun 2021 18:12:17 -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=aMCRIj/ZF7W7IY6XN/z2aOBiqinNjqax8uyGzovEstg=; b=aDyr0uvSKgUvQDjvSKK2PwlhN3l3HMuJx6LYZnoy37fTwnS6vkK8I+4Jo6NmmbTHx9 nqmmnuLFpB0oj/cK5Hegmx/n1uZ15J633Xkr2ueQeP0FmPkWWs7cKeGsVOzlfVqA5Q8q V9ymmCVqjPUsKFfsVMpUsGtRw3s4d2+nCiT4PmjhWrAAh3Jh9e1a8B+1PILzOjI88RPe 76iICcguFYvgBWxjcd9lPqqftSkXy558ev5wCslhW4AAxRq76f34IT++yPrelHru39rQ spf5gZ8QU/o8yOgb6RdbtgtxPmb3v8WpNXLiHx5I1PWk5wPIVpUFmQlLEonViQEj+Hw4 BgcA== 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=aMCRIj/ZF7W7IY6XN/z2aOBiqinNjqax8uyGzovEstg=; b=Kn7P0YsiQvPDw7ZAO/scpUEgId3aPKiszyh6j5pFDZzjOTtv8JdY27Oi4uoXu6NSYn d1OpgvU2Okluu9FWd9xpCsRPIv6cc9qC7AFlF4ivzpa2SoOvHGOyuM08cq3iphbSYvv3 r5w/BwjU19SBKohuRTINcvYvFBNmhvbwUTbXVg+zxgFrOmDU34OndbJ9bFPQ+zNlmXee o69uDv1zZspQIcz9a76k+vELEbTfkG77uPcCm79Nm2BM50Q9w0dLL6YPDRFTL4wj9ngj 5l2nbuT91n+iEkOeDBUgXtc6yQ4HGWb9aeXiXjNQTW1pQDmqQc5J34Ws7dbgfgLs1lY2 2Zeg== X-Gm-Message-State: AOAM533v0KyWtz0zQ0BwxiGNcWi+QNKz+GLniZp8MLTKovGvPmiz8zH5 BMO1tltwkgrqMl6jbgkiLayF7Et7RvAPrg== X-Received: by 2002:a63:2114:: with SMTP id h20mr2383686pgh.16.1623805937004; Tue, 15 Jun 2021 18:12:17 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 10/21] linux-user/m68k: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:58 -0700 Message-Id: <20210616011209.1446045-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.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" #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; @@ -151,16 +148,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; trap #0 */ - - __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), - (uint32_t *)(frame->retcode)); - - /* Set up to return from userspace */ + __put_user(default_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -287,7 +275,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err = 0; @@ -324,17 +311,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; notb d0; trap #0 */ - - __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), - (uint32_t *)(frame->retcode + 0)); - __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); - - /* Set up to return from userspace */ + __put_user(default_rt_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -410,3 +387,23 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp); + + default_rt_sigreturn = sigtramp_page + 4; + + /* moveq #,d0; notb d0; trap #0 */ + __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), + (uint32_t *)(tramp + 4)); + __put_user(0x4e40, (uint16_t *)(tramp + 8)); + + unlock_user(tramp, sigtramp_page, 4 + 6); +} From patchwork Wed Jun 16 01:11:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461321 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp101635jae; Tue, 15 Jun 2021 18:23:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxURvjb7Yut6yeRoeiowdR/rDmeMXijEFZYq8YR4Di1NHJxT8UVGCCErsW0+h5WRGrW+4CK X-Received: by 2002:a05:620a:1424:: with SMTP id k4mr2534357qkj.299.1623806631465; Tue, 15 Jun 2021 18:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806631; cv=none; d=google.com; s=arc-20160816; b=NMqBxdr8/IlW0J3CNi7+gYKNCZS2YRBTaQC3cwEXXhJ3+FDanFXST3aCvJnxSYA39x RicdDHO740qWvXqN3U03D6HVL3P9RheuA7Jj2LkbGFEZh40VJpEPO19vNa0HeNCmNGOR w9sGuNaoZNYX5SPuvKn5/vCXvO6EJnKOwgu1Mx0/CcKufhKJpU8OhywgvZuB/iGgJko7 Yp491McyqI22Gwd48XfSKFV0jgwDy8YorubAIxra7Fhi66w0ou13du26gsYJMRcssT/1 G98qpeIDNB3iaik4Nwjm4SC8KWKYViZ03h0D6Q36JmYwP+1buADB2k3qjDSnj81ogdVH udEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9nbSdV/mD1SXmQjAVp8s+mtCkOW7kXOYfRwNUm5mNPg=; b=tHDV+HvBuaAfVV89MDufj9NAMj7DY+1m+DHfElB6s08FqiBsGjar2Zver7g41+bKlQ BegMP58S62y1+ix2sGP4JnM6IomL3hXsHovGF2IRncTgVMZV0VB66eboV+sUiDLcHzt0 Is4ilgZrc1BHTyhA2zTFt7jMoxqORG9c2NXD8Vx4SbywLUvarTF4+QIsY8Lckjkaf4k8 S3OUaNPC3BnNeObAjJ138KlVIbXD42XYMpc600shBPgzZRiG0pyK01fvzijL3VTM3Tvt /EsK4d0kyr81hARcmv95SK6XWxdtq6kFjiwz7jkAEdoK7DyCi225AHkpgxuQ8/6mh+XG ZFOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="e5/vIn2s"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s11si493973qkp.244.2021.06.15.18.23.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:23:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="e5/vIn2s"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKHW-00022R-SR for patch@linaro.org; Tue, 15 Jun 2021 21:23:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6T-0005Wn-IX for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:25 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:40543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6M-0008Qv-T5 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:25 -0400 Received: by mail-pg1-x52e.google.com with SMTP id m2so573653pgk.7 for ; Tue, 15 Jun 2021 18:12:18 -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=9nbSdV/mD1SXmQjAVp8s+mtCkOW7kXOYfRwNUm5mNPg=; b=e5/vIn2su3+gLCLIJpe0NCHvkWkgi7pgf+12oJ/0O0AzmLIgRoLjgPknrwRhaKYqzD ogqjDisC9VjAH6K7t7yN3+AOx+/M4cm5RAiiiUOWUwDjOj+IA44oQQBso9i58w+Edxhy zbnEL1KMLz690WDVAYKWus4TUkudIXc4SwPbumLgxNuXGemiDjUTpiLfdldX1WI0UTCE lwQi9WK1fmrInSGi1KQajI5KeL7yE14PgEfhiwKiSX90I1EkwXQ7v2xbTSymy+mAVq57 enqPqJdPqfgACiKikQw6e8d8458archYR/3yF6DWNrMtwmWPXuHgV/bP2DkJWnVnWKof rWGg== 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=9nbSdV/mD1SXmQjAVp8s+mtCkOW7kXOYfRwNUm5mNPg=; b=kApfI8OpvmI2tfTYA/gbcVuLeY5b1ZMMxr3jvFMGtuWosJe9YZCmWNNBH4K2OyslPQ xe1/qy7udMkqDcsa6c7AAx/ecIxFu+bduUUL3FFPvYS+87SEumx2g2/bu/6J3ihZiA8r Gnh1KYGeroCieCZur8xOK2u0WvT+2VV+4b0e1fQMjKOFy5sLC18VTC9RUrxHu+cBFHKj vnBVT4TzxsiX8GSqVX8iCG2pXIGcKGA8meN2sF3cxUdXTlmS4EMgKstNoddPhtuINrta ps/DOI03EO8YzfoE2CjHtw8nOaAx4mwBrdH7PfCCwmRVIfz2UhOBWm8tc8Zq/trjzTf9 ZjHw== X-Gm-Message-State: AOAM531r8obNUEinpHrPYDij//LZRkW9yko+4O6kGo8aIR5SrO0jeKKp 9FKqKHb5LLL10LtmB8CKXN2LbJUU4bXsqA== X-Received: by 2002:a05:6a00:7ca:b029:2fc:daf6:d0f0 with SMTP id n10-20020a056a0007cab02902fcdaf6d0f0mr1943820pfu.15.1623805937523; Tue, 15 Jun 2021 18:12:17 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 11/21] linux-user/microblaze: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:59 -0700 Message-Id: <20210616011209.1446045-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Cc: Edgar E. Iglesias 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 { #include "../generic/signal.h" +#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, /* Kernel does not use SA_RESTORER. */ - /* addi r12, r0, __NR_sigreturn */ - __put_user(0x31800000U | TARGET_NR_rt_sigreturn, frame->tramp + 0); - /* brki r14, 0x8 */ - __put_user(0xb9cc0008U, frame->tramp + 1); - /* * Return from sighandler will jump to the tramp. * Negative 8 offset because return is rtsd r15, 8 */ - env->regs[15] = - frame_addr + offsetof(struct target_rt_sigframe, tramp) - 8; + env->regs[15] = default_rt_sigreturn - 8; /* Set up registers for signal handler */ env->regs[1] = frame_addr; @@ -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 = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * addi r12, r0, __NR_rt_sigreturn + * brki r14, 0x8 + */ + __put_user(0x31800000U | TARGET_NR_rt_sigreturn, tramp); + __put_user(0xb9cc0008U, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Wed Jun 16 01:12:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461313 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp98440jae; Tue, 15 Jun 2021 18:18:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXkwwmMJ3tNbNlRJfXH2/fdIwWBxvS4PamGNHztzrBvdRbXH8Rj+sKeFrDqVz+OAhreZtd X-Received: by 2002:a37:947:: with SMTP id 68mr2582147qkj.364.1623806282707; Tue, 15 Jun 2021 18:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806282; cv=none; d=google.com; s=arc-20160816; b=BDnpA1bQ/vkLqR1VyYDk9S4yMK2PJK9MDGv8KmiSN8GBgxzkif4cYELMeJ36Xu9kEP 8d2GGTzHXPDkJH4D0vL1gIB2ScaWfLPdVCGezbhE+0LQVPMBDEumZY8ykXW764hefR53 DNEjhjUbhMg5FZ9PVvI6rZ10qKH58lClWDaAF2/D0exGtyV9NU8/Q/jlFCDv0ufN0KoZ vrs41eNIGDUFB2UYSyiM6Ev9bf68k1Js+NcGmo+UwujiGZKVVEdbQq750Y7mY4EuGu7D aZ5dccWMJp72B0Xja025rRkelKgVVPEFB2pJIBUXg2JJ1ET49XR+Hg93qMvX+joNbE+o 6NLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=k8sLhy8Tk3/Nh9HPVnNqGAmDJY+BNsPgHKn8Ir5zPqA=; b=pu96tFtZ5orwnEUMH5ZA56DWUbVlzlG+ZOPon+I4NX0EsLXvzQcdOH2t6VJmDiOo/i g9dAmUGtNj1cf/d0c6pXty2HdTQmzXMm/I+hV5jQO8DlBur1Nb7KJP386PXbwavSwOAW VgmaU4k2FL+NVBHmcHYk3P89lHLYVyKFeT5cae1A08NuIWNJFv/sID08RDQkCpUBBfTJ 0OCAGeYLIhC5VSeYOgbMBt7N6WPhfDcyXqerCDG9eAWH9mnzK8idSqrIHXaq+51s2Q3n YieT7+ju0Hog4jn9hGlztM+A/TSk9zv25hXdbUtU8vIMCVhlet+15kuZmPrnIpZeaopB Ms4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="JTSRT/y+"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f19si562917qtx.264.2021.06.15.18.18.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="JTSRT/y+"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKBu-0004Wq-1l for patch@linaro.org; Tue, 15 Jun 2021 21:18:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6U-0005YP-1j for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:26 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:33633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6N-0008R2-LT for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:25 -0400 Received: by mail-pf1-x430.google.com with SMTP id p13so887563pfw.0 for ; Tue, 15 Jun 2021 18:12:19 -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=k8sLhy8Tk3/Nh9HPVnNqGAmDJY+BNsPgHKn8Ir5zPqA=; b=JTSRT/y++EdE06ADyMXo2HKU5arSf2ZhwAvCoVsYp0OuYb3WQ7My3gLumUuGb5SvW/ ToHhzhE6cXG8cQHaCoIqthGa01fDUeUAEKiedg6h05rUllYecWrrBkUnicmRxwqde5RL L3zq47jkpeHBLtD1NaJMOgR1cM6RC5hwga+SP865c7jaGGKIGde+JPe8PaNUmGRhcjg1 lJKANw0wxIn8AS1HNimjsTkOvn3M+cHJWg4/8cYSvj1ZuXMiuBAlkLwPZxypfXSRECbW EQ8AOjJJzza1hagt3D6AFdp6acPG4PgpiJuzBgOkQeGP26PSjYsIzX2+bQG0Tp9Kmc8Y tifw== 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=k8sLhy8Tk3/Nh9HPVnNqGAmDJY+BNsPgHKn8Ir5zPqA=; b=G2qx978XRNvdkajgdHKVioP1JLRydhtSbtMZp4pES1ypjyVafbb7aiEKxiCz/vkvfn CEOxPplHvVHsS4Mr+EjotCDEJSDLoNRR5D1SaHpCH47sXL+gSCd6CKX2dtlyqxS4tk4R 4b/w9tsyYUHTKk+TGktabLhdWb5bY8P44zQVb9nkIwlp93mMb/MjfTlG/eNLVjUw/bMp lpGuW2eq/AVh4i4HqCxPY7sbbbFn+3eC45SmQ6NTXOeNhVMK6/2oevbxY2s9a+S4ZAwW dR8d1EgplYX115CoRrmZ2RgyOingSfW3yb4ll/6+f5zfL0X5XSyR8A+TipVeFP/CQzPf 41vw== X-Gm-Message-State: AOAM530q7PxZ/Sbk5pOOXC/4ogsuUwDNqBxNLVbLuxy0sqIHpQ/sgdTv sCYygm2oQs3+JF+79GsPTnfU4UWMqt7AXg== X-Received: by 2002:aa7:9ecd:0:b029:2fc:779:b187 with SMTP id r13-20020aa79ecd0000b02902fc0779b187mr5214378pfq.28.1623805938372; Tue, 15 Jun 2021 18:12:18 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 12/21] linux-user/mips: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:00 -0700 Message-Id: <20210616011209.1446045-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Cc: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mips/target_signal.h | 1 + linux-user/mips64/target_signal.h | 2 ++ linux-user/mips/signal.c | 39 ++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.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 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index 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 e6be807a81..234f85905b 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -86,10 +86,8 @@ struct target_rt_sigframe { }; /* Install trampoline to jump back from signal handler */ -static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) +static void install_sigtramp(unsigned int *tramp, unsigned int syscall) { - int err = 0; - /* * Set up the return code ... * @@ -99,7 +97,6 @@ static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) __put_user(0x24020000 + syscall, tramp + 0); __put_user(0x0000000c , tramp + 1); - return err; } static inline void setup_sigcontext(CPUMIPSState *regs, @@ -211,8 +208,6 @@ void setup_frame(int sig, struct target_sigaction * ka, goto give_sigsegv; } - install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); - setup_sigcontext(regs, &frame->sf_sc); for(i = 0; i < TARGET_NSIG_WORDS; i++) { @@ -233,7 +228,7 @@ void setup_frame(int sig, struct target_sigaction * ka, regs->active_tc.gpr[ 5] = 0; regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc); regs->active_tc.gpr[29] = frame_addr; - regs->active_tc.gpr[31] = frame_addr + offsetof(struct sigframe, sf_code); + regs->active_tc.gpr[31] = default_sigreturn; /* The original kernel code sets CP0_EPC to the handler * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ @@ -307,8 +302,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn); - tswap_siginfo(&frame->rs_info, info); __put_user(0, &frame->rs_uc.tuc_flags); @@ -337,11 +330,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->active_tc.gpr[ 6] = frame_addr + offsetof(struct target_rt_sigframe, rs_uc); env->active_tc.gpr[29] = frame_addr; - env->active_tc.gpr[31] = frame_addr - + offsetof(struct target_rt_sigframe, rs_code); - /* The original kernel code sets CP0_EPC to the handler - * since it returns to userland using eret - * we cannot do this here, and we must set PC directly */ + env->active_tc.gpr[31] = default_rt_sigreturn; + + /* + * The original kernel code sets CP0_EPC to the handler + * since it returns to userland using eret + * we cannot do this here, and we must set PC directly + */ env->active_tc.PC = env->active_tc.gpr[25] = ka->_sa_handler; mips_set_hflags_isa_mode_from_pc(env); unlock_user_struct(frame, frame_addr, 1); @@ -381,3 +376,19 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} From patchwork Wed Jun 16 01:12:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461323 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp102823jae; Tue, 15 Jun 2021 18:25:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+dH026GGCuwWwaOB33/SQH+KCTdlam+YUgMl0J7pTCgnzMAGsxKbRGVepTWagOOW8z7UK X-Received: by 2002:a5d:904c:: with SMTP id v12mr1539538ioq.95.1623806758504; Tue, 15 Jun 2021 18:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806758; cv=none; d=google.com; s=arc-20160816; b=UdunJsUgRdJ8S7+Xx6RqcLpY5NyTIglqRLE5vgCsDQuv2VUPjQJFNqYsVgWrQEH1j2 Byi2aBJgLtnSJmlAp6atXadNpMThT4b6EbqCwUBcPfcqo5GOHtcBr6vsUVujl+Ty6Eyj l22C3epTZ80OLw8z5LopzgVAfevguk6QvadlNiigcUkqgyW24w37ucE8a3w/hjYuDhpp 5YHkYn1lIfXlou49d94epfzAn039j2vJA06a45/R6mssjxzSLgmbAkwO5iiAALdwCTob PMgREs7lD6UT5ocwl6W7NEi9y78jLyixzaDCMjBYFD9p91SjJBjYIyH80IlnoX5PtacG 369g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZrJxA2097dXMmX/dlQGDy3yrhTNOTODlU+a5YheuYl4=; b=0XtmfwOdwa+Eni6r3Mmo10q59mJ9H4pqMaqR67ybt5yGA9LQbGgHvZnOCGq7gMCBTA 9Hjuj/xFdy0CqwJWw+1nsZfiVcVy3lKct3U6zpjy9VdXJ2K4ZK3ioOSN2owkup5JJ2h3 iNz1j3a0BCEfEceBJdg98xVcZAdgDm65m4L6Qy+4DANuLkGfcrwaucHRpH1fS7Fkzbzm 7EoJToip8efJd9ZGEn/gZhW4hzIRI3oNLbjsapNiXvQKV2NrHvPR9j4/QXf9ybicfCns Mn/bMaC4OHMm0tU9uq2Dr6s9Sk1VWYdCCIcdUhCvhdCoHwBIcM9ey9u4lXY3cVCsAjjI 728A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="whuPN/gx"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i9si606629ila.58.2021.06.15.18.25.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="whuPN/gx"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKJZ-0006q3-UO for patch@linaro.org; Tue, 15 Jun 2021 21:25:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6U-0005a1-LO for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:26 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:35447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6O-0008RM-Al for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:26 -0400 Received: by mail-pf1-x433.google.com with SMTP id h12so853373pfe.2 for ; Tue, 15 Jun 2021 18:12:19 -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=whuPN/gxnPpK8Xg/Pfy3idA0ly0cbX4Ah8ZmduHy8Ic2BDj/+P7Uqr+4tW3WgGDYzs HOPFj5uspoBZMLlpAjh3vlC1vs4mlz+UycH3h4Cx9ObwKviVfP3LeQrHRtSztN5KVq3a 65/Q7DV2DVyAvF86Hq81QkbYdbzuXGOEg9FT15cTxxR4b7HrmwPXSOA9IwSOoCIthe0D ft6ELlZU6Y75/42k/liyn0s+QA4yXaf6cVIimVlbW864gLWUb/3Avr59SxfGxa3XvlDe 51PWaeR/trhPcRykstCJnbvpHHmzd67o3YeUrG6Y4XQ0bfN3Ac6p91ZfJzY1/ah4wz/p KqHw== 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=TQ1ywvFfwZS8IgqrVvYAKj6nWwFDXHuigf7NsS4aejalgwOlvmTCtozJ/0spHxc5oF qeo5vtnxZX/2DCy2r7MVuwCrRaIPGKRiqW/wXAMJThksaDHLg7HSg+X3ZG8cvanxg15g NoKUtgbvMom/Y3D89waV8n8sZSe57f1KoG2GGQ80ubs2bGPjvbMZk51+JTBdhM2fnjTj OTzye9PpCkwPHtM7jTV2oP/WIsJvxW/RbRV3h6cTVkvAB19CHBekAPDZooJmmo9/scse 418qOWPV5+zH4q2wk6/FGhKnubPY9EPyJ/cvJ7x25tFxDml53UFEZhD+V8ik1WQZi8lm olgw== X-Gm-Message-State: AOAM532UDc/Zf0lfw3Erv6fNhyDdY5A8zjYgxj7+HPGjQLf6Nu2RYX0X MOApXLOYxz9IFi2Yo3WPGMX0Z0IZF8uUEA== X-Received: by 2002:a63:ef4c:: with SMTP id c12mr2338905pgk.441.1623805939065; Tue, 15 Jun 2021 18:12:19 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 13/21] linux-user/nios2: Document non-use of setup_sigtramp Date: Tue, 15 Jun 2021 18:12:01 -0700 Message-Id: <20210616011209.1446045-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Chris Wulff Cc: Marek Vasut Signed-off-by: Richard Henderson --- linux-user/nios2/target_signal.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/linux-user/nios2/target_signal.h b/linux-user/nios2/target_signal.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 { #include "../generic/signal.h" +/* Nios2 uses a fixed address on the kuser page for sigreturn. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* NIOS2_TARGET_SIGNAL_H */ From patchwork Wed Jun 16 01:12:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461314 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp99371jae; Tue, 15 Jun 2021 18:19:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/GS3iFS8F8Ul0xY5L9qmhc5WiYNceAD4OhIHmC5dx2j3ymGV2kau+w95+NY1cLMI2srYk X-Received: by 2002:ac8:5ec3:: with SMTP id s3mr2606780qtx.312.1623806379559; Tue, 15 Jun 2021 18:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806379; cv=none; d=google.com; s=arc-20160816; b=Y/xsgSO9yqbyFMfKuzAfXF1xM6mRczI2twizNNGDOB2xwCt/2yKh1tZjAt5I3GpnRU 8IvPD4bsQzzA/NmLwL+F7LD84JyniPqyyfp5ivepSmcQl/6J/R2OXkNy3/wzVZv81EKh s3+AhZGG4TqrShABNnLC7KQhGWbe5sQw/05yshy4CWyZ7CzwuRxGTfSYxcdCgo8iXzX7 C4KSV+LLg3Mo+dMibQmV5RY1rdTc7fk8IHY5A4sr6WSUoZdyxs2En9PKEwQQz+Bn+lcF 0gbaYRFVRlE/NOfYewhiryqPlw7ownl83KSysHNTwjMXYCY3o/gjC3+Ehf20SLNtVelS OujQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PxD3kImzZTzoHPM9GMiHPmLRd+HKsnHLojrn5hai3Qk=; b=ob/AqHEQuQMh2nG7SQQgxZfebg7hJlXCq+yRpUUA0CFsmqswDO7LJkypAm+sHBUgZC IKs2NR2Tp2gGxEbwb0zyzL8rHVToVE7lWn0pOjpNNky9qSC3brciNL+5IfiT33Xcn3J+ +5RPJqrQdiAVC3ev8JuAFb5p3mJwsXewLP7+jAiQa7m+Y6dWcVlZajY+QaaTlN/jke+D hwqpGHcyoN+xm2TOTYjq2hhyQ4EGKIkf8i1eqb1fgg83XgCMADtcgDykIMN1F6jOGiwa B655HVhBe9MP85RI0ahRQuYw3mtEnesc8x74EiLb6/m8jIL3eHKeppwiCqezGzNbt7Zm x0vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aOQuwuQL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p16si376497qvt.89.2021.06.15.18.19.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aOQuwuQL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKDS-0001vE-Uw for patch@linaro.org; Tue, 15 Jun 2021 21:19:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6U-0005ZD-DU for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:26 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:46874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6O-0008Ro-Ra for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:26 -0400 Received: by mail-pg1-x532.google.com with SMTP id n12so550602pgs.13 for ; Tue, 15 Jun 2021 18:12:20 -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=PxD3kImzZTzoHPM9GMiHPmLRd+HKsnHLojrn5hai3Qk=; b=aOQuwuQL8kpqTLCKNO0+VxCtz6OnYin3YdNyb6G+E3/wvXS9i93YEUrrw4VRyzticr cHhZDZptkyWgmWkvUnlw18SD9V+MIGIr5N6h8HGeXAnxP/frwfYT0e4f6QGU2qxhgOaF JxbekotCcrAFm8qb4QDsxMtgW7Xt5+hBdXk5DgSwyAd3J+eBxMv0o3APOwTQFOdBWSor JXrMbk6Kg3Nsd102S0OHiMfZNc46qcABOgDgXDrs5RIqzCqSCwvsyTTg7hr69BpHDfRO qU40/Jz3JwWU5rSsyC2a4p0bgyOwlkNdpCgwnGkDQu3VVW1FZ3gQMnyIy5QG39M/px/v guHg== 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=PxD3kImzZTzoHPM9GMiHPmLRd+HKsnHLojrn5hai3Qk=; b=L8T3/s3NiHLkMOeNJqaOksswS/C8QysX9cicrwqQTl/CHWiK61dO2Xda+g/WejVAuC qHUy68ZVEx0c6CQXP8FISUo9dqbj69SLlep1JGb9vETqK9oGiSyR63M30hJ+M9pRgY3X 0uyEs/OvPMmcl4HRwdYp4wpf6TMLbobguWZRAaggqXgS+xpCEmskzlUgXCGsv1a77gaf Ss/1H5SdRZzynDjRmM9VTtUjjFe8whsFDxMUjesClo5IOIe+7erNvHG8HcIzRoAPfCJ5 m3baPRr34Z/SQoZ9hne8Q2u8TPfEhQ81e5CE/Zfr/yh8ND8TlCsKAmXaLBU3z1KZFPeV P93g== X-Gm-Message-State: AOAM530JvCulX8oVInVDktQS+peA+TNxaR/gsv4oWeJPERLKmi3yBUVY VRq1CA2Rh6Jy2iiDJm5Vxe64qvkiRUwIhg== X-Received: by 2002:a63:9515:: with SMTP id p21mr2321596pgd.333.1623805939666; Tue, 15 Jun 2021 18:12:19 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 14/21] linux-user/openrisc: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:02 -0700 Message-Id: <20210616011209.1446045-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Stafford Horne , alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Cc: Stafford Horne 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stafford Horne diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_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 { #include "../generic/signal.h" +#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; static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *sc) @@ -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]); } - /* 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 = lock_user(VERIFY_WRITE, sigtramp_page, 4 * 4, 0); + assert(tramp != 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 = sigtramp_page; + unlock_user(tramp, sigtramp_page, 4 * 4); +} From patchwork Wed Jun 16 01:12:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461326 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp104323jae; Tue, 15 Jun 2021 18:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrhznY6lLXi37mmtu8djN9teONr8rQfKEaHU9MdRUBJwEd5bIM06Q8BrD3R5rK8yb1SmZf X-Received: by 2002:a05:6214:f0d:: with SMTP id gw13mr8503733qvb.34.1623806893895; Tue, 15 Jun 2021 18:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806893; cv=none; d=google.com; s=arc-20160816; b=HnCQDZrsuhSFvmfxBHM7DvUs4lTtM/GP+37ZXbSjSTnRQD5WE8CqUzScKtgO4vx4dp onSL2ckL/pqsIVaIJk5J+voIEIVcYYzX0De2cD4P9A/YJfvfsqF8CvEPLxFVEjtohEWa 498zS0rHweuAWVUBdPCFUmqqgMkxws3TDw6am7zcNcEqY3Gt8OJTBGcGbvM4YJAlKsl7 k60Oi7g5eJTcYykXBWZu4mKqN9XpTyBrxhrozQzv2x4CPHHr9wuH8b75wBnXNoyugtc/ kJ3bYDA0IGLA35AyZleoMWb83q+l30l/Uhlq+ya7uONvC6y/JfN3SLdgvyFBWOxQHJKX umhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Zh9h+PmWbwWPB35P4oSzNT2+LT+dobQgpXEUdOMWBj8=; b=Y/TwReUets9Bj4kZxr1hd9nfU9O+j1XWywW/1fQYcypywqjelU2a9cTVfmCaynq1au s0RR7JX7P45o7SnRcCLihH7bAmDtE1QhKQJjWzCEA7AbYwt7zCQGZIZefDSADhVni3JB VFTtbSU5Ms1hUge5efl8EvmLAhEZjqECE8BkJKITCUMLeE+SpOzXdcomDfY5JZ1dnDpN /Ndp5YbUUPrEJm9ZcLsVf2qQkVPpzjBnBwJNMh40Arf+HTAeXUPgCrVtPUuIO7e6qDvG XVS9wWq3+N/k/WRJ+cv1D+TqBy4Yj1gNW+tVhGqZvA6Qt6Rz0pWhNTelZ/nd9/wN7H+/ bJNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eYBq9tca; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e19si627097qtm.337.2021.06.15.18.28.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:28:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eYBq9tca; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKLl-00048B-A5 for patch@linaro.org; Tue, 15 Jun 2021 21:28:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6V-0005cW-PK for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:28 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:37708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6P-0008St-L7 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:27 -0400 Received: by mail-pf1-x42c.google.com with SMTP id y15so842094pfl.4 for ; Tue, 15 Jun 2021 18:12:21 -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=eYBq9tcap6+l+m0tmt9Bm3C2Y/mI+KJpi6p8YQaiDNu2xct70XEHwBU6ZFYf3cRxC/ DC4T+g/Gm3g5mebzeH8W/REhgxvSomXpV6U8MJ8268mbKR4Q/FWorsX5lU1BGkb+RVxF clmtGctLgu9AloO0xjDxUu3b5tWDw2BmUtnMnZN6N1DFU7R+lEyjBHzdUz9r0nX53wrp yTereT4wNKNOv5H+TM3YbIEFCp3XLbL74uh17yusw43sR2mVGIJ8LAG3DLCIoWoB3XwU 8eBxCxiGmDhCby+9ZvW7Sld8kIxsxoYn7mcWmv7KV1upxKBuGdIBjeOeuSsFdvtABCAX YQKg== 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=HEUajRwBBcWbODU/cTvyAN4nzM9Lf+XaVO+kRiFbIghdBdoLGXjdCz/VSxMiJhNcka KH0xfwLWFCFMc0MXEQAgqAcw3TrwMcGC3q/xNzvIQFm7NoE1kDCvPXpg+F6aVaf0wnMa pLb4P3Cfz497cFzwSEEKIB/k3tBpMraYFVPqlw+LZtaD4tSgyx8Ge1EK2i5tglMtnVgo Y0+Ri79wAUqFGrxE9rpD70L1ceUzXbFKDvBctg6PzahiboYgXaODcoco7aRRS/QlCBHy rGvjOb6ue8oH7xtTD+cstetowbBQvFoXbN3bppGQSRvMPiUZUFcPsW3xgDFXSlZiiyQs Q7iw== X-Gm-Message-State: AOAM530wEqqedqqBfkbI6Vpx/MQHtrXnyicI8cTDKoZG6dBnGg8Kqpt/ ggJlU2fQcVM8pmL3QMtJsDhPtA+nf0GfSg== X-Received: by 2002:a63:1324:: with SMTP id i36mr2384226pgl.44.1623805940255; Tue, 15 Jun 2021 18:12:20 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 15/21] linux-user/ppc: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:03 -0700 Message-Id: <20210616011209.1446045-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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-ppc@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org Signed-off-by: Richard Henderson --- linux-user/ppc/target_signal.h | 2 ++ linux-user/ppc/signal.c | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) -- 2.25.1 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 { #endif -/* We use the mc_pad field for the signal return trampoline. */ -#define tramp mc_pad - /* See arch/powerpc/kernel/signal.c. */ static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, @@ -437,12 +434,7 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Save user regs. */ save_user_regs(env, &frame->mctx); - /* Construct the trampoline code on the stack. */ - encode_trampoline(TARGET_NR_sigreturn, (uint32_t *)&frame->mctx.tramp); - - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(frame->mctx.tramp); + env->lr = default_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -478,7 +470,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_rt_sigframe *rt_sf; - uint32_t *trampptr = 0; struct target_mcontext *mctx = 0; target_ulong rt_sf_addr, newsp = 0; int i, err = 0; @@ -508,22 +499,17 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, #if defined(TARGET_PPC64) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; - trampptr = &rt_sf->trampoline[0]; sc = &rt_sf->uc.tuc_sigcontext; __put_user(h2g(mctx), &sc->regs); __put_user(sig, &sc->signal); #else mctx = &rt_sf->uc.tuc_mcontext; - trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp; #endif save_user_regs(env, mctx); - encode_trampoline(TARGET_NR_rt_sigreturn, trampptr); - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(trampptr); + env->lr = default_rt_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -721,3 +707,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + encode_trampoline(TARGET_NR_sigreturn, tramp + 0); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} From patchwork Wed Jun 16 01:12:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461318 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp100743jae; Tue, 15 Jun 2021 18:22:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA2634VOaR5tcYyr2rWXgxhtGw75hen6R0by4eXGY3sdO88UUWPK3p3dvj3+3Z1VhV7XaK X-Received: by 2002:ac8:7768:: with SMTP id h8mr2516300qtu.235.1623806538703; Tue, 15 Jun 2021 18:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806538; cv=none; d=google.com; s=arc-20160816; b=dRC0Gy6otOAeeEJUawpBVpKWxmbLRoMelrNlgi5zzcQjhCE/V9S+cXJybgX68rQSLO mEFZztdcgd4lH/jopSXshzBFh3+vVvTB2Loa7vWiYFS9qMzMg3enxkI5lBmYnIi/PeF+ vgjlmIXbj4qS8TaaQ7Jc/P6peBC2nUK4e4MKwHNtGJQE0Lru70j8U2iI2Z7mgi/8HZj/ S/BXLwjrd0izEftc7J6RVeYjfaciOX3rS+m5B/pp0GBH4kwyypqN9Lvo3G/Pkgbnoy7t 8xw2t6L/T11xkMQWtADj6iKJSkouLzy0TZYLQrc08arSN28GR8DQkBtILW6z9g9cq81p D6TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7P6aK0Xlt7Wqq1Vaq4hTczk8Q+yU+JFeTGVvn77Fon4=; b=TVqdQe+uuxGOuTRGQ7BPCTOkShBdhkN+Z2e/tnKkXr8jTXGGpOQO0pCnN0Z50aLuou o8kWAlGvGjADfzdQBqgBTl/wqmvdVKoXTR2GW5sDOcwxkDc9q04+QUG9vcv13rKP4Z/d 7xbycEjwKwRLYSZvDP7VqRM8i5cZJ/NRXrTttq7nZfEW2PpLrlSLnBOGIqdrlVu/t/je VIl5RONDgviPT0RE+Ad4RxQzEvgLwEV9fz0IshUqOpTIB/QQFEfj3ysCms+sKx/q/M1W VDPN0ZPPFDbr0VbPZo7St1KwPI6JZ12vahaoLc1Kcn73WKIJ7+BEdLxSvOgNg6j3F++c 9wBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jfvOgkml; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ey1si473832qvb.213.2021.06.15.18.22.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:22:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jfvOgkml; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKG1-0007tf-VT for patch@linaro.org; Tue, 15 Jun 2021 21:22:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6a-0005fi-MZ for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:34 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:46009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6Q-0008TR-Ac for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:32 -0400 Received: by mail-pj1-x102d.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso748667pjb.4 for ; Tue, 15 Jun 2021 18:12:21 -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=7P6aK0Xlt7Wqq1Vaq4hTczk8Q+yU+JFeTGVvn77Fon4=; b=jfvOgkmlTDRzoViZrZSiMCHBd/PCUZMjWLXHppbBIDAP8JsUvQyTN5q0yqGlvsKeJ7 88z2ViNQ9EBMDGT3Gv68KBnmyjmSVCem/JMJFQpsyuoWORqsLOdZ5P27U5LQH4kgPyDJ AkR1uVKqhifFD+mIlADbQkcXZoZ6Ktv9IuJhnucddp6wux3yQU9hQFwN2UwKy8RyWHoO XZeMhf4sjervF9v2dtA/1HXV9/9vkzd02SYp7qv6FkY5owYOdgwHP9gO8g2wfu5Aqr9h ExdmaMDuczlnoK7IpfBLYO9rwewxZ5d9rjGXkz0RlzBI7H7TBO8PwHLl6lVNHA3QJSEP /MRg== 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=7P6aK0Xlt7Wqq1Vaq4hTczk8Q+yU+JFeTGVvn77Fon4=; b=gF8UNzvseuBUp1MR8xpaWYwvGpJi5DmlJpfgZ+CVkdZHUokc0+U4ME442w76zC+wE/ is7c5Y32KlT4DiCeg5lwB1jEY2jl9I80NdsUaXQjcjLWwLqCmUSitOpIYTLLIut3BksI bFfgFnK/+LbIJsdzYKFAv/SzoR9vdRPEUnCupmJ9vVt4YUvflczv5KSjmyuRNdXVYJBa gUNEwVOE8XmtVofBH2iau0GvjW446K6KzXuCmrfofMbtSmAANIZFf27CgKgLlGXpGFFn SoowmBrf8dWvVrmRTPmnmknOLi3xpUGhaP2qYOJz1jKkgqVMxQND8V3kvKxpT7OqYiPs MnHg== X-Gm-Message-State: AOAM530jZowUiy4czQegGxo4yvxsfMcCXdZIYs/f6uIWRo744X3diyT3 qEM92BYu+sIEcdnLLUQhiZdAExlHiwGcWA== X-Received: by 2002:a17:902:d701:b029:115:d3d8:94d2 with SMTP id w1-20020a170902d701b0290115d3d894d2mr6634336ply.23.1623805941084; Tue, 15 Jun 2021 18:12:21 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 16/21] linux-user/riscv: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:04 -0700 Message-Id: <20210616011209.1446045-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: qemu-riscv@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. Cc: qemu-riscv@nongnu.org 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis diff --git a/linux-user/riscv/target_signal.h b/linux-user/riscv/target_signal.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 { #include "../generic/signal.h" +#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 { }; 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); } -static inline void install_sigtramp(uint32_t *tramp) -{ - __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ - __put_user(0x00000073, tramp + 1); /* ecall */ -} - void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPURISCVState *env) @@ -126,14 +119,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); - install_sigtramp(frame->tramp); env->pc = ka->_sa_handler; env->gpr[xSP] = frame_addr; env->gpr[xA0] = sig; env->gpr[xA1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[xA2] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[xRA] = frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[xRA] = default_rt_sigreturn; return; @@ -202,3 +194,15 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ + __put_user(0x00000073, tramp + 1); /* ecall */ + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Wed Jun 16 01:12:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461325 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp103838jae; Tue, 15 Jun 2021 18:27:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxftbho28TPCnYAv2KKkkLbPZA5HPUqr6L2h2Ss04Y5CCPn5GirGa/i4u6rqxTIp6Hwdpdo X-Received: by 2002:ac8:5d87:: with SMTP id d7mr2546669qtx.172.1623806843347; Tue, 15 Jun 2021 18:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806843; cv=none; d=google.com; s=arc-20160816; b=gbB5s6zul9v74wxHg7zOKmQiKGf5GQCwsquQ6iE+qkSi//l2ylsN2KlqSpELbgx207 NdOWRkpcdpXQW8BKK7CeAuSlhlfFn9mjXfbOxJmsJ0jdNwYq/thDPmwyqZWXRSJM9NUD vNsJjML8dhV3HsXPYCSSBKK8Ne+/Qjitob6e14HlWTDinVKDgbFhM4pyvnKQYSrgF6SE 1y15/Z+im5RfhxjzvpxiJY83pYus/wbHbB5WkuTVQ/2HpJTWyuGEoqOCDL1aKBuYWKip zigsp3xqUTzfXO1v/aa1anYoXM4nQAbFOk+uoYZRM6BW6LpLNZpKMYTczbLhTGk4asyr TOfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=otFWOjo25PTZrmQ0CApLXIVYdTYiSF7ILSCJjVsE2Vk=; b=mFu/uIzyvFQ5jHVd4Ks/dMMZ58vFrWCFd0AYPO8b8wDqUU7ggisknLJpfz3z0EzCFI Q6FASxYyXdkKuGW8KNbagikRkw2uOTXfvlD3noEK9MZyFrQ6s54FnVKPnPu73yy5HHzu T+hTI3CPDN5QYQpKNSub9EXWgJRYrqDunhBlWivFbnLV3r4dxq+a5egrgf9FFJmHgWTU NhNzfVCzNWezz/5IpJUUjvCtpax0FMddQXaB9Z3/BQnzfE8H8iQ0ztJOgmVz57OhC3fX tWnYpdoshjn+30Z+s4MC8Gq1K5FxPVNZpa7mFt6yLBQXHXPcLWipOI2qT3TGPMbkN9te mdbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xIho14J9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q7si533873qtr.101.2021.06.15.18.27.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:27:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xIho14J9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKKw-0004W4-Oz for patch@linaro.org; Tue, 15 Jun 2021 21:27:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6Y-0005eY-MH for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:31 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:56178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6Q-0008Tw-Tu for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:28 -0400 Received: by mail-pj1-x1031.google.com with SMTP id k7so708770pjf.5 for ; Tue, 15 Jun 2021 18:12:22 -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=otFWOjo25PTZrmQ0CApLXIVYdTYiSF7ILSCJjVsE2Vk=; b=xIho14J9VZccF0xdHT0ReBhRINvgIEW8gbG06REgcdgBcmlXtBECTT/OvCS56DsKvT xlFC3Nlrh3rxB70ojUTr1m9mcNXEqKFNIRUeeUZfyriIPv9BkS5BgWcYHUmDwSF0y6mV 3m1iHnhlH1Dz0S7ThASFke1yb+KLKMOzSb1HqTKqaDzbVRO12MpCWuFwgBp3s+3Pxd+4 cnTlhgvccA4bgzsz+SrHgcIrgf+YAsJBR3HFPtJkd3TN8K4fmEj5NtPZa5VcB/Ygr5UV JOuYqfRJW+UwNswS0tev6W3kITjkNA54HNf/5L+8MTIFdRN9uZWzh86HK7Xa0ixP5S7O cwhg== 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=otFWOjo25PTZrmQ0CApLXIVYdTYiSF7ILSCJjVsE2Vk=; b=uadCWGheuJ8IXubte+h2hxzvQDF1zgX9JTt2nGygrrQYmuOwgd1okLBCbuObsiix69 /SWAGy3ElxhM6l9YS4OmUCGqN/vCnUT1X505uO/lJf80KGXKv7idIqQJuyALFgJIUncF CLKfXpevSaVY+Ojmt6MgoIoqPdNJ7oOKDjQfgBTRCXOYslv6/oCftA6y6KnubuAbgztI ECPa8G0Hhylg+Qycr8AJDq4zmtwp5H/9Q47M63Q2xQUTCJzfQiMkbpUeYpil/HSYfNE8 VCNhlwLjUwYJ1p5p7IL4UgLvJlkJeZeu9YqVyQhg5JymDinomllk0X7BZrG+PBqBWy/Z r3EA== X-Gm-Message-State: AOAM530EWDyFZ/WH+DeYOKBIiXAoiDQtK+4cmWYnwso1d94qcsJ5khpr B2Y7b8pFeFXfH+GRFAn55BJtbDavGtxDRA== X-Received: by 2002:a17:90b:305:: with SMTP id ay5mr7819478pjb.0.1623805941588; Tue, 15 Jun 2021 18:12:21 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 17/21] linux-user/s390x: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:05 -0700 Message-Id: <20210616011209.1446045-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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-s390x@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: qemu-s390x@nongnu.org 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.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" #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..806c09f921 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; #define TARGET_UC_VXRS 2 @@ -84,7 +83,6 @@ struct target_ucontext { typedef struct { uint8_t callee_used_stack[__SIGNAL_FRAMESIZE]; - uint16_t retcode; struct target_siginfo info; struct target_ucontext uc; } rt_sigframe; @@ -200,9 +198,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(sigframe, retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - &frame->retcode); + restorer = default_sigreturn; } /* Set up registers for signal handler */ @@ -253,9 +249,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(typeof(*frame), retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - &frame->retcode); + restorer = default_rt_sigreturn; } /* Create siginfo on the signal stack. */ @@ -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 = lock_user(VERIFY_WRITE, sigtramp_page, 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]); + + default_rt_sigreturn = sigtramp_page + 2; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]); + + unlock_user(tramp, sigtramp_page, 4); +} From patchwork Wed Jun 16 01:12:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461327 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp105804jae; Tue, 15 Jun 2021 18:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeMiPO65lHleKgM5Oqoj1AiwqcuFmn/D/ddIu+USjga8AhmUSX+9FN2Il0qkbb8toae6PC X-Received: by 2002:a37:b6c4:: with SMTP id g187mr2642842qkf.491.1623807059646; Tue, 15 Jun 2021 18:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623807059; cv=none; d=google.com; s=arc-20160816; b=Cp23roKbgPp3QWik0yONCD0tLPLR5WmDW1eXvWwbkCVq5co7Mfk5wM7McrVmh6v7nV PA5f4ZZzqUDwzGfATbZOHW6HOGm3CE2sk9nJF6b1jTaR58qXjBXd52Gv+8KjPamJCCi5 i7FLqYYb1BcFXqxNHK4l7Gh9/Dj9EhMwf0pM/ev8FPRPTLBJ5k4gLMSbsB1HEoCmG/f2 sq5Ou6PUh0TvcEpG85mSShH3MyFzUbR3x2BshQ9LKdawo55gfgx5NONHAJDeP8BQYYM4 fNoOIsQ0CX/tCAc2xtnDKPzVBLWQ0+wYn/ItrYGp225y3M8oyu7xDFf+oxbDMdAKEEOw qDYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gmXhcVzm0Mn9qra3UUrV4KJ0gXBFFg35s1ELoxfM9Zo=; b=VmY3hSlDqGIWvulOqHd/vaYmRamutrElh0ANecpMNvvBU9yLYK+a9+qHzfeuMpWpK5 //82YClT6YoYL9QIxgzxeNKnJdzdpgf2zZLvG+YuDnkZ5ecnBh0ydD9+THy/tx8H+Eb7 sNVej18ZoakH5HVQ31D8lafxJxldIYaRwAGTm4TP1N/Ffte5hGaa/0R6WyekpBAWIe8Y qToECMjWTsfOq0xSYJjom0qCuZsDWI+EISB8N57lSd9/iSwQ9v/eMcjGQj8kxGDT1OPo F+vY+AA9vg6iSuLbUQtP4D931txbtH2M4uu2J/Ye9EEyWQVz/0A9KiGJlbCd43nnGTtW Df6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bg5J7xyu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w23si555597qto.128.2021.06.15.18.30.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bg5J7xyu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKOQ-0001ro-Vx for patch@linaro.org; Tue, 15 Jun 2021 21:30:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6e-0005fu-4c for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:36 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:40949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6R-0008UD-Hu for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:33 -0400 Received: by mail-pl1-x636.google.com with SMTP id e7so259813plj.7 for ; Tue, 15 Jun 2021 18:12:23 -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=gmXhcVzm0Mn9qra3UUrV4KJ0gXBFFg35s1ELoxfM9Zo=; b=Bg5J7xyu7UhebMUdPbm+bab9HhIKGCcokiHNF4HgWZpVmus1tvnWxma6kUaIHATmlx k3cRyTUG+ATTxla+uP7yT/ljqcuvjXArtEyq6ngwxboe1LH8wum7jrguUzmgMseBrqvb 8wW4jGcLivVUOXTD5cLT9KYIDo5Uus/I1c9+wGWK5hKYgAvd/NGlQw7KJWHPLY2XAwWQ oWXwGxoim91l16XAVoZcKUn1+LP0/b9S1rHiIQ3bo8pktFm4+k5M6+pVKYxiHomMtW9L If8sqVPz/y0hHET11CeNVwQVjSeGuoY6LTYhnuwycqVlaDjAAoHBcwXso5h/a4gRzzkq yjIg== 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=gmXhcVzm0Mn9qra3UUrV4KJ0gXBFFg35s1ELoxfM9Zo=; b=qMPy02IR+RbZI8vwq681g4quGqNEZPMlK8EQtpogCejJMMrbmtYsDbsemh3njAB3Gt A4kO7FsQCoFTn3zSCBGBY3B8+eh8jhay0uhDxKmnjBlSNfT68OO31u3/1Po9+um56pNw QNSloBqqtZ2+u1m7HRoA7/W5ByyY9/jbnshlz6yalQ5lgNS6yfQQVLVQxmH+AaqAI6jT iKMpB/Yg9GvD7pqDu2U/S6vaCsGtPdNMKHmycSssFzpR+qU2AYWeLOqgxkGvhqI9kbfY 9LXzanGUVNpwAXKTxFv2AuQdzAEbu6LEjq1g+GctlToE+tRVL0RrecxcMhWiOhaRjR1L waYg== X-Gm-Message-State: AOAM531MCtv10/Bi9ScjzyufYq6s+b89V+F1AmVLhd+AuVole4fWUkfV j8DSoV2bOVK+9tfqUFogzchQbpRT9VnC6A== X-Received: by 2002:a17:902:8bca:b029:11d:b5c0:5677 with SMTP id r10-20020a1709028bcab029011db5c05677mr4826490plo.11.1623805942138; Tue, 15 Jun 2021 18:12:22 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/21] linux-user/sh4: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:06 -0700 Message-Id: <20210616011209.1446045-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: alex.bennee@linaro.org, laurent@vivier.eu, Yoshinori Sato Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Yoshinori Sato 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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" #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]; }; @@ -67,7 +66,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; @@ -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 = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_sigreturn; } /* Set up registers for signal handler */ @@ -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 = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_rt_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_rt_sigreturn; } /* Set up registers for signal handler */ @@ -333,3 +319,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(MOVW(2), &tramp[0]); + __put_user(TRAP_NOARG, &tramp[1]); + __put_user(TARGET_NR_sigreturn, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 6; + __put_user(MOVW(2), &tramp[3]); + __put_user(TRAP_NOARG, &tramp[4]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 2 * 6); +} From patchwork Wed Jun 16 01:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461324 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp102965jae; Tue, 15 Jun 2021 18:26:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYLeX2EU6GOIMQdqHI/twdmfB4y44Uv5qQRb+u/KYJRIh3/Jamt9ii3wnxz0s/FNNt5I7y X-Received: by 2002:a05:6638:60b:: with SMTP id g11mr1742155jar.88.1623806772359; Tue, 15 Jun 2021 18:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806772; cv=none; d=google.com; s=arc-20160816; b=XVTxMT/S4laszAhUOtzTTIQIG3e6nZBDkUT0RRHKbKBaXqfrLpSY9LJBZMbJ3QE4Sg GVXdGeNMa04PALdNKVjZngZXiSrsnxKGuMxQvG/2XLs5bjS67b7VuFjeQgz8SmqEIP22 JoABXAJNm7AEhQdoyfDvNQqKjlptB9smtE2URtdfLd12N8jfrApmPpA/oRQJdsKjJSvL K2S6jG9CqKkGRAqLOx+MQNIydSl/Fk1E4d8vXQNnI4A1MGLOoYT7mhJuf+SJaxXzBJih RSx90J6s8ba5Ww/J+pYS4uTRLrNK3j2/Hkz1dPLsenLc5xVxP+wAAHLL6XBXu+EhFLob vfFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=V1ouGQPBc6XKYt56S4nm4ci+qA1UFjFhIv98Fi35UMjD4CZa6KqiBc20nz2agL/zGh o6HM/cws1yzW7Ct0hu+4cme9ThZ5+OIu/K5LP7XW4h4m1v6r+20c/63TZTX1tSCZ8hdZ RtJWJEUpKO1Ii/V9wfic3D+wexRuNcz8BW856n3gS/wqHPGI6E14FwpByEM4TTsTQXSO 8MNFyrvtGETFGxBcTe2Ikuv2kPRGd5lURcKV95MC1KhFiK2xOcOWsYcpZoL211/g7Fim r1bJvyM83B4aKyyczfnVGfw+izQ/VC+cY6DVwk0KBNilHoOSOtilvS5YIP7iETEz82gq g97Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="aMkJ4w/Y"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h23si868843jar.116.2021.06.15.18.26.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:26:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="aMkJ4w/Y"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKJn-0007mQ-Pd for patch@linaro.org; Tue, 15 Jun 2021 21:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6n-0005lA-Ur for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:45 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:50701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6R-0008UX-Uq for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:42 -0400 Received: by mail-pj1-x1036.google.com with SMTP id g4so750120pjk.0 for ; Tue, 15 Jun 2021 18:12:23 -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=aMkJ4w/Yny6+pdVD3hYHRBvqRE/lqIl3BBbUEd3d1QYWLir1opI0DYlnvy8Eh27RB3 AoQQBvLHLsRDQFRifL59EabzRchHKSoGd/VFWH+Ycw/AZtw5sqG+X1NU3xuMJA2qdk2h czZUQ7rNOHm3T5vMiAzT0gUDLCe8mIDZ+BCeg9MMP+qJX3fAcHxn+PD8y5vUwqzXKXnb 6rwX1wDNTk+eoFtGyEuhIuiC4WbjOianqTmWCRrLxmEZQMHPY1BuJZ7HwM3iDZOu4Fzb QW9Egqhmh3S2dJ6JQIapv7AhImMszNNT9NXFaRV6Zk1MMqhLYlNB6Tt6jRn8tJyzocnE 8LoA== 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=MhTSrfesRob+lTa5etzWAqJYspf9WMQQ3JgA9cXOCC8e3hID6gmKeEfWR5D1eyNGy+ 75SISw/UqK6g1/9Ogf0joyN8g1zWXEkWFxbZYL5LzI3UBttE7zKo1aYPCE1ym4AwGr1p gTkjp/Fu8x622rL5zJjKJKw9S/Ux+0N3u7xtRKBK4/8/W/M5qj9PQYdZf0mKS2sBB5md HxgWk+WYtKaHs06M6auS6lWQCPf8wWMptEzzbURfeNgeXGPMRNXdAKuTRnoa1z1qtcPb 8Qb18j24o/1YbNojzxX9IngLZ62FuzqMhHWjk+uTRiAo3hsI4ss+Wv7Vcra126lxQVGh L8kw== X-Gm-Message-State: AOAM533Y7CuYwpRmlBhtsS9V4hsxDJZpe21MYAhFLlMtQ3mIrxcEXR4/ KSJ0AJTVYRupZO/U5tyfG7JLllbG2MUrwg== X-Received: by 2002:a17:902:9049:b029:116:e060:c464 with SMTP id w9-20020a1709029049b0290116e060c464mr6815773plz.1.1623805942712; Tue, 15 Jun 2021 18:12:22 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 19/21] linux-user/sparc: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:07 -0700 Message-Id: <20210616011209.1446045-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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: Mark Cave-Ayland , alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.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 { #ifdef TARGET_ABI32 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 +#else +/* For sparc64, use of KA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 #endif /* bit-flags */ 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] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = sf_addr + - offsetof(struct target_signal_frame, insns) - 2 * 4; - - /* mov __NR_sigreturn, %g1 */ - __put_user(0x821020d8u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + env->regwptr[WREG_O7] = 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] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = - sf_addr + offsetof(struct target_rt_signal_frame, insns) - 2 * 4; - - /* mov __NR_rt_sigreturn, %g1 */ - __put_user(0x82102065u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = 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 = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(0x821020d8u, &tramp[0]); /* mov __NR_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ + + default_rt_sigreturn = 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 From patchwork Wed Jun 16 01:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461328 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp106774jae; Tue, 15 Jun 2021 18:32:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8+yftEKYXl9yDEiotoGVOdvvVHptTDc/MnnOLhj7HX2NZ4CwU6LgZjVUM37pffXGLax0e X-Received: by 2002:a37:9c88:: with SMTP id f130mr2634013qke.368.1623807159266; Tue, 15 Jun 2021 18:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623807159; cv=none; d=google.com; s=arc-20160816; b=tSaSGKyp7t+b1UANtQ1+yD7n+vJTWIr+14La936ErR6VHvuhnEPZois5ATtnCtXfkm xNRO/ZnST+0UkceG333Rnyve9bgt4tryTjwUvooiDJK/Z2Fs1mQziORTnjADZkLMoTq2 ly4nVpujp3S9iXZXmCfLA4QPW6DQ3xA2/WsRlFqJSBMkp3Yyspsqg/fqS0x2bGk/om+Y eIICN82QpeO2R8M+NnsL0UM4Xb7+9PvPMkP2n/Zo7q8/TG5w3yz+xk4ABu1MG8RZv11Y syg3Nsz8P4hvpJnDsxc4M6QIbV0HyHWi3OKD3fV4KEzrVBwdxPbRBaCNGteP+pkxPPRl B9Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=COVeNQV9BBulXNDLKWwOqJGZ7zBHmRTYrf/xguIv+OU=; b=QBJfLFL2Ax43TxswUxc92GzQsOE0JkXHr/8fXHHNYK6crECaFVz5InZvSQg/PK5OSu 4C9b5oG6NysMl42LEWuf/qFdFegSKT6027SX97oPUIdNuK2uhtASn5c8xBpEXKuAKq4Q +LdH4tQNrmHuLgspXROqaquQ1rR8CnVp+bqSbVYxaYO5eWgir7TnVdhMp0YwWLah4ioe Iu6ox1LYxRWQIMIhgA6zd10yCnSnGxVET7wLWPDzS4ooJqGq/dyUuvJO2iKZDf91dqLE aS8pJeRO+Sa0E2U5T4qYjZzy06a9mQTFpllzKoaQvGtWyUmByIyaiEqYtOe8x+1+gh66 XrFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="qD7/36kF"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p207si448737qke.143.2021.06.15.18.32.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:32:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="qD7/36kF"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKQ2-0006gt-Mb for patch@linaro.org; Tue, 15 Jun 2021 21:32:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6h-0005hH-UC for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:39 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:40738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6S-0008VC-EZ for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:39 -0400 Received: by mail-pj1-x1029.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so2573754pjb.5 for ; Tue, 15 Jun 2021 18:12:24 -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=COVeNQV9BBulXNDLKWwOqJGZ7zBHmRTYrf/xguIv+OU=; b=qD7/36kFVmvwhUT7pFuHSEzVsphnUjzB8+KlfN7GwYW+PoDmk0NuN+doPjauZa5+2E tMbBGqi9duoqV+NsMNdkHMHK/vbNEfSxuT1cl4253++DoAPcg4wHOJxOEgGinqZkXMP8 fkJK3I06POcVj1xa6UYhluQDsHeETYgOBj3XUHnaobJv6TxoVC4DukQj1l9Z5muKifC0 dYmT5q8lHXtLi0jIIs/LF4lKkI5o6ZP7MDxgrDy/tsL9vOPkonMTLUwCEp41Zyzkl/kE I/GuxJB95HXKjVDux+LKZOtGx64IWc2j2T5ACDm02Ly0vRttWG1i8eqIlYoWSTcgIi0A zMtQ== 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=COVeNQV9BBulXNDLKWwOqJGZ7zBHmRTYrf/xguIv+OU=; b=cMJjvih0BSJK2mivOMsXW/hmRG/NlBzJxBPqoknvVDfrlgzcjQsvVxWmuMvAhgysip j9pmH9Kf9e+99IU40dUvRvxtIKGKxozyGth5Kdo8/iY+Zxo/PO+OC/LrbvCz7NkkfVne iF19tGk/qKuHfioTVi5Fv2qUu1YXLhYs4P7RCnyCtzj9TwgyUt3+g0YHVWkX7PodHLDn DepXNGyImJqSZ9twz87M7GsTxXa461X6YVT3vKW3ADvxx9869lpHq/RkQxt9jfgM2oB/ BkeFgVBd74PEOuWBLxMsEjAPi3YI+W4vz0hKjhT2c39grHSq3CBGa8QqF7INkeYrfVW6 //Ng== X-Gm-Message-State: AOAM532lsw53Amc9xkbxL7x+Tey592MkEM0UDJcre7OOkXZnMk2G1b3a vovYgz9E84270AGfrfAs/bRq/XQmzqBngw== X-Received: by 2002:a17:90a:e2d4:: with SMTP id fr20mr8036923pjb.92.1623805943265; Tue, 15 Jun 2021 18:12:23 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 20/21] linux-user/xtensa: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:08 -0700 Message-Id: <20210616011209.1446045-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Cc: 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(-) -- 2.25.1 Reviewed-by: Max Filippov diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_signal.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 { #include "../generic/signal.h" +#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 = ka->sa_restorer; } else { - ra = frame_addr + offsetof(struct target_rt_sigframe, retcode); -#ifdef TARGET_WORDS_BIGENDIAN - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0x0a, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x05, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#else - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0xa0, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x50, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#endif + ra = default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc = 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 = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != 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 = sigtramp_page; + unlock_user(tramp, sigtramp_page, 6); +} From patchwork Wed Jun 16 01:12:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461329 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp107977jae; Tue, 15 Jun 2021 18:34:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztLI2WELip9GRsgU6uwGmknmzrtue52s+WGj5dJ7lvOd7n82Hl2m8p/vzXEDPOcA0n+7ZX X-Received: by 2002:a05:6e02:2188:: with SMTP id j8mr1736414ila.87.1623807297839; Tue, 15 Jun 2021 18:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623807297; cv=none; d=google.com; s=arc-20160816; b=TlS6kEKJcsalLcr4vhddlH20O+ZKzbldv5DtBFWdG2hStNxaCS2wSZSoQ2fu54k9Wb AIHbWv5T/xlwqTVmEQ7tQ/dkemqCLNJSfAoCEzHOHJ4+i2jsXTCsscmHPYrLeU83k8XV VlfCTF24zkECwbkEzVnfEIxHluBRui7aQ6oJIdIsfaRwLQTwBceV5rH+bZceLZBfqhXM feiJH1wFIWCQ2p6rDeXE20eMbYLZeTUwoP/nZACtIsmy+ZzqrqYQfPwR2rcnbLgfFqYV I6ndZ8Z1KSKQJugeFciGzpnh8j39D/sXaNFVPSvrwLv88VwL1gM59g09YhWUvXwd8578 6LNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=C5fvMl6g5lyKr/RZPA4w0LgiP0MNwve4euP98chYQf4=; b=rKX9dbwzYutz75IGSoYL6uJr81FVcXHDPi1f/3qhO2QsTJPArViAF3ogIZSAQTHEbQ K1X3P3ngW5y5NItpuhevAD6oLs5ODj/7JFpaLQ1Xu0aWlKie9jzZZWSFTm5IyD/y+7/f eQv/dSwjoBuDe6sFmRrxvoDaBKxe1dSe+0QVpSbw/PsElTFWcDo3nd/0sKxO9myAHD0B nb5aszLBeyQtrrRB9M6yoVkGC+tsVqK10on7xRz6XapE9w118OCo0okt6XORSQ4lTIEy 3bU8rRy86ZKDdDX/Oi0TtE4uVIqgNDlmb/Hw9ankzJaXCoeEyhEgZcUH9i3HOj6X5W8I PnAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Wv5QKd4Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v12si625088ilg.36.2021.06.15.18.34.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Wv5QKd4Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKSH-0002Vq-AX for patch@linaro.org; Tue, 15 Jun 2021 21:34:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6n-0005lK-W4 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:46 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:36854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6T-0008VZ-7s for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:42 -0400 Received: by mail-pj1-x102d.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so2964350pjn.1 for ; Tue, 15 Jun 2021 18:12:24 -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=C5fvMl6g5lyKr/RZPA4w0LgiP0MNwve4euP98chYQf4=; b=Wv5QKd4YmUcJS/CcEKS8WAVXMZuaiyqUG9GJix5FcqCbHVQOwW9BRgBRoIeAyc/A8E eafhse2ZymP9V3UVXDpIHXa5PLa2hQj70hLdPZ1VbJvMd4o9h3BgS7cJOz3286Q3H5Ow fGBYh/1kjz3kXcawF2I69E3f4NGrrMFGTk1HiuezR3GJEZbg1/AL4KyVHq4LDFlMUc3o jXklID1gf9FSqbBwRjxO+tExWuIAeikM6wEW+yl9/nlU+3cMq1xlLhkTkTxtomKkp35/ E0memNhEkxAchdZHjfkdjPkjH4ZqcoBewBcbq/35Bwgsa/EwnvcG0TKBIWiAlgaWvvPI 9fqA== 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=C5fvMl6g5lyKr/RZPA4w0LgiP0MNwve4euP98chYQf4=; b=l8+PoYwUWbH4xhGh1+CMvMvZIJNXKqPG66weR/jC+CH32tKxrtGO/i5mRrZI64Jgav gHH57Hm1hyrvLnchFxquJ7QBVOEnez7OI9FENRvnLVpG9Y698ZZHXk1lqYj+1TScDyeD fiUwMUFFvIzSmsSXUbkc0JQOauJItN09UzJTeFDZDZXdWi+/6tdz0iOriK6R5b/ZrI2/ zPfjQffKoml4QsmBESQsxOYxRvl5w4KtqPqqWRYot1nSSp/h989l3qY68uurZ3eYcpmN SXrYoaUhLTI61K3ujenGEHt93JNhcvRChDUs2kG6WBtvnxX2ZP+SopjkueX9jLWz/m9v 0Iag== X-Gm-Message-State: AOAM531sqaolcrhsdWK7qWBn5oNTE1cUlU93EN1ToRoExMdnuCO3E4yE PJ2DGyxnBJ358QVFujqomVIi3BaW+cGjGQ== X-Received: by 2002:a17:902:9b87:b029:11b:e66e:a1b3 with SMTP id y7-20020a1709029b87b029011be66ea1b3mr6824171plp.33.1623805943944; Tue, 15 Jun 2021 18:12:23 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 21/21] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Tue, 15 Jun 2021 18:12:09 -0700 Message-Id: <20210616011209.1446045-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=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: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets now define TARGET_ARCH_HAS_SIGTRAMP_PAGE. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 -#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE -#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 -#endif - #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */