From patchwork Fri Sep 24 16:59: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: 514585 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1676961jao; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd+FrTgbFV7gdQmm/Xq7tEW2Ld/zbsBWaL2Veky8na3cJ6daqADhGJXhgsNYUrObkNmHL+ X-Received: by 2002:ac8:5e0d:: with SMTP id h13mr5363525qtx.403.1632503076532; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503076; cv=none; d=google.com; s=arc-20160816; b=SXVvtbus0A/ZFOfVZD6SkyXVaIaDO/DnkDL4wIQq/sffBZLpJBmfOeiXrN8LFSM2uz lF/PdR/1eadbbRdWmEmxVgKTh/IAMctQoS1RAFhq9pZnEIYz1KOnM1ihghZaudXTbYPU 968YAnc2gmBiytKHrAEK4vPdRjOJ4YpeHuD221uOjrbocdskwf7ggOASaVkmwqd/N1Ol Nw8YeGp/BgvRo+8F8zEpjrfQg7X9MvPeyCOdiF++qKndqiWqFIGmpXKpip4DjKorREff kFtYoNZEQ2bwLKv2kL88lK0X+Y+Yo6+BheSnec3X8TDGoummWYFkXi1jjJh8W4a3sdyC nHKQ== 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=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=CbHXPrAD32ELq5r5ihCevy9di5uJmn8/HLdyBS8r2g1pdnRmwj+IG9HPhmJvdPgvjs 5gi3HOCVfAokn+vt8pf+YQI5QebZPSiArcLkNQJlMe4MKhWB9pypiUteMx60sEbqQge6 Cwe3+j6JUJQDhKmQEd2FJr+4NXr3qQmqsq9Urlvjf/DRyaHznWyAUKIXD7nXW/jeE9Hv 5kMIXlOL9iDIkCpTmZthkP/FqBGNRaJby+pWZ5NJYDEimYsf8vB4oZaj7ssM+TPA5FfJ Cm1ZPbqzkEi+uBXF0ErWhhY92Ph9MFQg1oShTylAT3jjdjwlxB+TVuEgxgp10Q6thgIk XkXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ud9lf2mY; 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 v9si6851195qkp.410.2021.09.24.10.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04: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=ud9lf2mY; 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]:35436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTocm-0000UA-1Q for patch@linaro.org; Fri, 24 Sep 2021 13:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXy-0002eH-Dp for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:39697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006uP-GB for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: by mail-qt1-x82b.google.com with SMTP id j13so10052488qtq.6 for ; Fri, 24 Sep 2021 09:59:33 -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=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=ud9lf2mY1kqgyV1OUwTUDcnBBvctQRisFqCtOvkpLfvkZuAFZyOT0ocd6QCPyB/d5z BqEyBG7l7VGVeIwexC5E7oP5JLMrEez13+7nhB9ciddNS0dwTh/P9JatLwaCuV9I6pLS 1+1FftaAZDdeqRlKXGMhnIUCygfUYW65vcj/pDIHLU0KHwfX67Qn7oEzhbF3I8EdUeuB EEKBhtm2yMGIZmRChWlr31hccJ0yIneMaNI9A82OGGJl8wuJE6yTznl4PAui1REJTace BGHThyj9pX3eCm0S93+8u+zJOZxjXrWswnG4uBUe80BXLJO778aC2pLb02BQ4iAEIMmz u8Vw== 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=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=Xs8Wg49WJHE5FM9c/oXmYZrZLIsg0q/mBFCjBudvxJInV55VYMkBOuT7ADT7Nbv3HJ 5CEhJllcde8ovl+zVGgEysDTWivnLmtI3HQmhBKlGdoNLZnk4YmvV8GEPuaDySnI7lTa yN51hLSt1CvIjUQoezEUXr2REPlr6HiTIfUviZG9qnWD6Mou404f/e2ce8ftXrHA5cr9 I62p45NeyA/q41uWm5NAShNpC0e6SdkDfv9yubzjK42Jh0yYbrYI+rXBQYUVg1ftW3t2 ynXyEKN2Chz4gB6a532I8PeRGOTxm6xeb4fWYqO3WPPbUZ0Re6mteX7R1WgbjNkpHrsX QxYg== X-Gm-Message-State: AOAM530D6W7rrk9cCtyWiI19MJhc8w1JVFNNf6+gw7U8WsLe+yubSNAe /55wVAbUXqAw9UHzuCDbmhngixsElM8Xeg== X-Received: by 2002:ac8:7741:: with SMTP id g1mr5283788qtu.366.1632502772511; Fri, 24 Sep 2021 09:59:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/27] linux-user/alpha: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:05 -0400 Message-Id: <20210924165926.752809-7-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::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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. Use them when the guest does not use ka_restorer. Reviewed-by: Philippe Mathieu-Daudé 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 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 3a820f616b..bbe3dd175a 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -55,13 +55,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 @@ -142,12 +140,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); @@ -196,12 +189,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) { @@ -269,3 +257,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); +}