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); +}