From patchwork Fri Sep 24 16:59:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514588 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1677040jao; Fri, 24 Sep 2021 10:04:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3yCmOVdiPkDTz97qvBx07QEHFWF+2F2iQznIhmpwYHwWWy1qJIWW3HhHV40d7QS+LHSJZ X-Received: by 2002:ac8:151:: with SMTP id f17mr1477808qtg.313.1632503079271; Fri, 24 Sep 2021 10:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503079; cv=none; d=google.com; s=arc-20160816; b=rRf7XcxgqMfYRHQwWoXn9JXTZkkiniF+Qrmz4zpMd2SGRw1tvDXxLkoeTOsRTjh7f6 T+PlLHoxQckmhXLBB3dB5qOenhIXwkzFGfERfDFk4a5YmknV8yJShTaRDR90baSO0e8L EfXZ3a7Jqx9CQsfrE+tTtnMUda03btFpz3xglMnJRfKRmwbzvsgZeedz2iVq22thFQzF KmWn0EQ+aMv+WOBlZqZhNnqUjP5zDoPGBVsmBV3jQsM5C4l4ho8Uc0jukezg78CQGQPf /92SC+sB3AhNoNttuanx78ViXCDhagenyxjeCLgYhHqwsGTrll1to6FHSnsibKB73Z5H ZEkA== 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=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=xAfd1jv3RRYDF8kxagPLTl8H2e9QYgMY3h1n7is5LtGLc68BTPgPXI0Kshf9pY39rQ AGN8cXAjO4qnwNN9ecXjSNH5lmbjBvRul6h98oMisTOf5DcGoHHbnoAHlhbEkkFFO7HJ ZRhcb0QiqaF+xHTUXcIqI521iZst35gHAQL0K6Iz9NBClOIjaNIbgsOpREr/Xag9n5Mo V/LlPs1aDCo1wFnRI6xAswAMF818DhY5cGKjKOdsY5Koja3UepQ5YTka9vvYhuFzGLdb lrZwhwY07nVZA+0sMVxIBGaFTPG13lcytdaQ6KTSxSzqanaJmWwZel39vjxKVSnxjkzD 7V2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dISEU4PH; 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 q3si5705185qvd.48.2021.09.24.10.04.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04: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=dISEU4PH; 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]:35788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToco-0000iJ-LF for patch@linaro.org; Fri, 24 Sep 2021 13:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002g7-Uu for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:33763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXy-0006yk-5O for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: by mail-qk1-x72d.google.com with SMTP id d207so29102448qkg.0 for ; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=dISEU4PH/27FdDhhEsf1d0QKp+BVBsRGrWbc3P7OWRVlryT8cR5Omcl6DCRfebKmVj NL1UJin65msHDdhmyGVFQRqHVcLqvydNF/pR9BYZaC/P7VdyhfViWPdnnfR+BBBs8VbQ yb6/3bKx2Frk/f+b7jd4yFDhdI1+7vECVls1ChFvfPvHY01+QlhHvFOBLvbW6NbE4bT0 7cZxHP6p8ThR1+knIxiDx5yL3XG4GlZYcproKjGSzqk9gQAzLuYKD+z5cVEZqIzJlRYe N2uTocIJPjP+kBkX759yS6K7bl8qzkj+rGS4/0QMSoTCB/Cgr4PKBoDVaZIOSt3pEQtg i4aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=pFiSt0Fbfbp6yvehJMot6YE/FzgSk8P1uebQr2HPJ6W3jZcg4iD33ylOQJS5FCaBIq EcXH7UoAWKrYxIzUehVGSViQ+br8VqDy+iunxEoykbtEroIAzAVihDC89AYcO2wgnnDo thEpaqhl/yNcjcmP/u2G6MtcFOswmDwSyCXVb6hbMpDFlb3LiJ8CQnWRdcmAWZCjXce9 yAy+FW+/egkWZ1OPoP6nyMwnC+05yqxGiOD1aPOjiOcCdFKkJGc+nARHRUjyEJzqqu73 4umLPhRtLGfH54ifYHSiYGqxa1M77czJmU5Qn5yHTmONI7jlBiBvbX4tU1ZpqS6JinFU SlBA== X-Gm-Message-State: AOAM530bIIv7QVfSeJ5gm1ct6AJCkrfezreq7tjAy43jTrlPAJ+AitxM nTfuU377l9DWFnInVltcc7Us8yBdr76W6Q== X-Received: by 2002:a37:a495:: with SMTP id n143mr11406693qke.339.1632502777017; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/27] linux-user/m68k: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:11 -0400 Message-Id: <20210924165926.752809-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé 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 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 4f8eb6f727..ec33482e14 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -39,7 +39,6 @@ struct target_sigframe int sig; int code; abi_ulong psc; - char retcode[8]; abi_ulong extramask[TARGET_NSIG_WORDS-1]; struct target_sigcontext sc; }; @@ -76,7 +75,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -130,7 +128,6 @@ void setup_frame(int sig, struct target_sigaction *ka, { struct target_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong sc_addr; int i; @@ -152,16 +149,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; trap #0 */ - - __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), - (uint32_t *)(frame->retcode)); - - /* Set up to return from userspace */ + __put_user(default_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -288,7 +276,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err = 0; @@ -325,17 +312,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; notb d0; trap #0 */ - - __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), - (uint32_t *)(frame->retcode + 0)); - __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); - - /* Set up to return from userspace */ + __put_user(default_rt_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -411,3 +388,23 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp); + + default_rt_sigreturn = sigtramp_page + 4; + + /* moveq #,d0; notb d0; trap #0 */ + __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), + (uint32_t *)(tramp + 4)); + __put_user(0x4e40, (uint16_t *)(tramp + 8)); + + unlock_user(tramp, sigtramp_page, 4 + 6); +}