From patchwork Tue Jul 6 23:49:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 470600 Delivered-To: patch@linaro.org Received: by 2002:a17:906:971a:0:0:0:0 with SMTP id k26csp5548802ejx; Tue, 6 Jul 2021 16:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6oNjj3yS99dft1IXrc4hbcyxsk6fH+UQxayrITpx6BTSrnSvz7TM5Ix0ZGGGmVUn92ufI X-Received: by 2002:a37:a2c4:: with SMTP id l187mr10991523qke.261.1625615902511; Tue, 06 Jul 2021 16:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625615902; cv=none; d=google.com; s=arc-20160816; b=lcyubZbYnSTewc53OrnlF+jer4zTvVhc2MvRnQL5L6A5TbxHGGT/EOHg4jPBilgNcH JQSlhLNO17lOM6UGyAY2c3tEtZElJ4a4dMc1O2GHbh8860OEw8QmqkdUCXiESe6+OaOZ GmPVnQmMCawsmSssjoqLTPZWoqr9sy6gISIhgMyrqEscEL87ke+TnXXjWYD76Ln9lfhr QIyC1Z+C4a3cxmuleFCgOZ435pv2iGsqFPdhzM2S0Ok4SjVVTVkTXFrvlmCkwES4KtFV a+dnWgK3kKTKhEupXs1z3LbBnBYFAe6Ge1RJGXJN5jmpWKfK6GQ6XzUrIB3ebxVB/9jL El5w== 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=9iNrkNfNiht6gNc7s+Sfth7iEg29J37zPd797X3OxQE=; b=u9ipYFXrV6n7cZysJKiCNg71R30dnRGS1wL+Py7QmXD/AQcIDADizCk1Jb64psZin4 iVEdbwq775n9E2mk1ryj7lUkuHM+Ffm4xXdemqsoWHUl1vAGxYRd/PMbwrHF8BNo9cyh nt//+BUqe0VeZtOAxnCqBc/I++k8MqYnqpoPA8MmUWBcehWha8BXt4vE26puBjCP2boC 7q6dQ/uA2DXMtLAZoSPTFQwxVR57M/9CmR3nlvD6TMygzUXT9smSH7VeYeCbPevyMYMs CtwcwInX7J/VpNEnQ3M60Tqa0mJXmS5bUqcyiSiqlW92Xo4x6y2hUMu6zX6K4YpltUrB TWeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i5JUERA2; 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 m1si13707263qtn.263.2021.07.06.16.58.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jul 2021 16:58:22 -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=i5JUERA2; 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]:35608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0uxJ-0002G3-RY for patch@linaro.org; Tue, 06 Jul 2021 19:58:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0up8-0001Rz-JY for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:49:54 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:46026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0up1-0006ee-II for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:49:54 -0400 Received: by mail-pl1-x634.google.com with SMTP id s13so41736plg.12 for ; Tue, 06 Jul 2021 16:49:46 -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=9iNrkNfNiht6gNc7s+Sfth7iEg29J37zPd797X3OxQE=; b=i5JUERA2/P2iYZkHrcjPM2IRemKJ5K1KdtgYYi03sONM+hSiyLpaqK0LzBP7ORIEZ3 GbVgwwdj7KgFH5N+rxO71klw3sXEkYMCYv+boyhfUOCO4t5LoHo/DEjVCvzho7xUZaNc gjJZETrLTeYORoivRka+TyZpArsaOHxdzQeCkjya9Z4Ygb3GgPnvPaVIGFyUe9vS/+PU h1jmZDceyz+K9LyB6NXhfo57/AgM1brySZjRiGmR7r8Vvtz3SykqYXklOKQIz6LDQ55D ZmrOWUbZth/KAi1MDOTKUuHuEK1nw0dsfYU0X+Z8B3tCUYh0RYjrmrWOoBSSwtVHFiYZ H01w== 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=9iNrkNfNiht6gNc7s+Sfth7iEg29J37zPd797X3OxQE=; b=HgZ2kAlphNYMLJewMMgr+wSnkvK7gSlywHz1M1DNuiHvpaHrtpNlku1XfzF6IIOTCE 91maqZ6V0SewrR90PIFgzlUSDQaFopHExD1oNmuDotPn7TnIjrpvv/lr+tnoCh+WRsby Zlaby93nDoiEQMMKJSNhU5o8w2qt1/dk8+x51q4oVkSLGj9br27YZVvJKPiBAzC8g2eR TETxwzkmQouWpuPPyei+JWBuez5P8eOBMVC/HcM0FfGr+9CeQOaVW1AHnEo96dHK+oxG 1WeWGWquLG/b7p0Xmsu5O98TPrvHAX0IGKCF7H+pPtOobz6XIJstNtsASGxTYz+RVpPa +B+A== X-Gm-Message-State: AOAM531EaQengkm05BfE/TIqaqms1MiShRsb1BnDF6h3yAiEMZ8O/gVT 7ZEMIbAQIO71nL7Xf3UBjAm6KcqJlJgVTA== X-Received: by 2002:a17:902:8d82:b029:120:4377:8e0e with SMTP id v2-20020a1709028d82b029012043778e0emr18967194plo.32.1625615385958; Tue, 06 Jul 2021 16:49:45 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id b3sm18058114pfi.179.2021.07.06.16.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 16:49:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/36] linux-user/hexagon: Implement setup_sigtramp Date: Tue, 6 Jul 2021 16:49:15 -0700 Message-Id: <20210706234932.356913-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210706234932.356913-1-richard.henderson@linaro.org> References: <20210706234932.356913-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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 Reviewed-by: Philippe Mathieu-Daudé 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 Reviewed-by: Taylor Simpson Tested-by: Taylor Simpson 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); +}