From patchwork Fri Jun 18 19:29:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463091 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp183093jao; Fri, 18 Jun 2021 12:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEiEAx68QH346NR0oC/z60ZI72UyA3LceyQV8N/q+xB0L7gZNgkWdznDUaWkXiwmbBYiPH X-Received: by 2002:a1f:1846:: with SMTP id 67mr7969864vky.24.1624045823219; Fri, 18 Jun 2021 12:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045823; cv=none; d=google.com; s=arc-20160816; b=fNxBWPzPRbuTS2pcAiH9B+ttzX/zVsnsL2ocMak/hubKYPt6ZWGnidWiqzPBLdRGCA YGQPSdFaTzBuRpsTpPB7BYzPLcPdq/zieEdPSywzXAO7oHzX/f0Oj3mlLnD+oAhgse96 RqfVgyreu970YyuuXxd+ZrH3+un3iMc5oNXt46lQxpvfbfnBt9sam6HbhrFtk7CSBrT4 xCKLSpl17TV5rwV0Bwn0wS73nxT82LtOyrWOdA09OSYIljhnq27UeaXJvb3MyBAyernv 2r/v9QZFqrtOtx2ErEgN+YHqczHAZ5cQMogthgw9w0XDJXz+hbxW5NeSITlR3kFVh1Ws bSog== 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=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=GHFKmL+vCSJ0PBkvbC0SvfF9k/lFLpJC4QoEBBMe7/kNBD151xYMKq+XBNySyai+WH YG3DEkAojfSHHHNxwtlBuXWCARfa/s4GvS9u5MsvDC8YoMnB7aQajbcXGfz0EEBWYh6/ TJMGKoEYPs4Wb25EmPCNrIXrlokrKdjHOWAz0xCBggyLlR8dn0Va020AOhDr1TVDFR05 cNJmODXmMQHeYSSO0uJpjCR5P+zYRyCvcwV3svL/OVIobhcZj3tk06QNhT6o44cbX8YD iuVqUtcBFvca5algfYP/fLTZADgZkQImyNH76ZjLayG6L6m74CgKkxA/K/t9Av1oChuq UfeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VWn+KDWH; 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 v18si4531181uak.48.2021.06.18.12.50.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:50: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=VWn+KDWH; 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]:55004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKVS-0005hK-Ag for patch@linaro.org; Fri, 18 Jun 2021 15:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBz-0001jP-SW for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:17 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:35368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBp-0001Zl-Bb for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:15 -0400 Received: by mail-pj1-x102a.google.com with SMTP id pf4-20020a17090b1d84b029016f6699c3f2so1351219pjb.0 for ; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=VWn+KDWHp8gxLLDPUeSGh+anMq5EevRP427IpnAXrbv6BYCLLO70cts+v1rRdpYRrw oyBrHD8Ao1FrAOx2aJ8ESpq8noVlCFh9bdvIRmdLLuXbrYZUxpwbbhtGxrB3dZy5woes t1fux8l7fx+N2aVqVJLtUPDx9/KAsyi4rogmqqxB6Un6zHf9iTG/q0p9ZyLTxUfLCWcP H7/6/Ek/nqGRi6uuKMz+oT1Z5IBJbxuI/Zlry9Yp13TrQTeGT+bsr0nynDVkYU8CUTn4 QYZfUNEoAmt7g6oXc7CeoSPkT6MOx1oNx3BgQ2ro8qfq76cQ9v/piXPzauEtieNdzMgv MfAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=QZqhhsIaZwuosw2QCawNJB1Cz1Tp7KWEzeSdpvIU9ukqAcrI6xj2CkQS7WBgwJxGXu BODVuXfUhlnkuSrTS+oLv06McqJuipg+YQvClJubH9U8lxYiBmJ2Oo+6MPJW1nGqUoyD V7wlLCuk0rApPX5KeGiHCOlSUmpK95HReBzdxCI0faoVAj4sOCY2ZMWdExZXq/r4SsWS CVNSJ8vxAN7akjftZ0b1afhYtAFR0fjUF3sIC22xhl55zawmIQX1y4asGKRCrQcYYsU4 /JD4qCpL2Vj+dTETf4IfYbC2inOkqe8xjc4scL9FrvibL+uijHF74ZByhWrDgJrn/VLO XFQA== X-Gm-Message-State: AOAM531yiwj9PJECbod2iX61m4JQkR9/GYYdH2maOdKGYXYz57Az3MGh x60PrvBO+ucaYmpic/PvYbwPIv7uQwC57A== X-Received: by 2002:a17:90b:1e09:: with SMTP id pg9mr23720337pjb.208.1624044604071; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/23] linux-user/sh4: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:48 -0700 Message-Id: <20210618192951.125651-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, Yoshinori Sato , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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 Reviewed-by: Philippe Mathieu-Daudé 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 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); +}