From patchwork Fri Sep 24 16:59:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514592 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1681216jao; Fri, 24 Sep 2021 10:08:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9eN6Yx5e/OR+wPveaRXEN9eQ623sP0sjxZ9Eg/dX17dPLW6opjDeASfVpRC4PaMfa3lva X-Received: by 2002:a37:9d96:: with SMTP id g144mr11216134qke.23.1632503296797; Fri, 24 Sep 2021 10:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503296; cv=none; d=google.com; s=arc-20160816; b=ZE7EaJpq+9vOhrwM4RQZI9HpxU9rn1+RjSMvRtI84cxRRppd7/lc9XAwYMgirrR+9y AS6OO9WgjnJ8eqSNtJmlg9ssdo+wm8ZL9IKenNyAdrGKCQEWvq1fJg3GbokOsxxJsKxg pifiFR7TU/DXXxSKTaqj2i27WqIIq5Kld/nZbQDe3TbbgiI5S4RGtquwa1clhXgnYDFF L+ODZE7zoRs8PLTEjQjt0m0uUpIaHPlDO7W/PFnfDMZK0icS3+jWPUA7PRiLMNZndfFu xpbVr1wtwlmklcOpDNP5IV7lVsaVj4AOpakO4kJgGDCnQelhxROUBSWvCoN519Gfho0T pUvQ== 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=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=gf2UJ4Mb06RWnh/cILyYg1tjCadCg87PlzSDvxrUKwYM9hv8jM/pNLm+BsRSerASQf xFhHP9lqpqwQ5W8M9BV3oMmoLd7IGfjuU7QE0BXkws5PCVeRhDNTvGmiCVMAPq0wkib1 o/YG39mcdOM7+ZqCD5EoFlX+iz1ytFSxDzZV12zNyeSqYqx4RylOohMst1GXu1YQDd4R kDZ3Rsi/FCie9oUKNIuWD6GshHiOE5aZ8NQt0ou5zIEtkEjufW+sw+hwh6nZ3vkjBQds Fo6f/KxBM37r3VNkeQ+b1va6dTZI+2LBN6m5iffJpPLKogxs/+aGsyCuo7SMU2KhSuOe DHBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jbqpXiP2; 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 u5si7022936qvc.72.2021.09.24.10.08.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:08:16 -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=jbqpXiP2; 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]:44214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogK-0006Qp-98 for patch@linaro.org; Fri, 24 Sep 2021 13:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXz-0002ej-4N for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:39 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:35522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXu-0006wI-Ur for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: by mail-qk1-x72a.google.com with SMTP id c7so29003543qka.2 for ; Fri, 24 Sep 2021 09:59:34 -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=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=jbqpXiP227iB56KT34GI22QoNKWUmiAL5m0c+fZrYQg9FlTNcu4p5uznvNQNmGexYW aqn7/0JXtTqFHPjdthtVhhyHZ3CWwEPE+cKlfOCaOhh2jyjMKG55xq+uc8YiU/derCI6 U1uhgkf/r1E4r7ZlJdDavHUGL8JwAs6jKdBYxAzSH0x/QtXKLtrIuuc3NdBDw0hnPGBM hEg/I+492spSjz6JKJ7SdW4cd1+U5KOl18jhnaAgE09qnjjXpG4FhGoErpDk4rmIWT2B nFvs1kesh+8vNiN8thn0+hHTcHfDKVyTAfdOk0Z8YigkMtwS5R5zlAZ9S6H7lAfBhLEs esxw== 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=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=t21JrUq9u7Uofb1gNE//cBbBeS7bfiwxQdBps/suAKsniVz/DIeEzoozMHclFOkcMG zdIsRKAtAm15tZ98f9NG+2eHmEN5rTTZ0SAZdlCPUz61n9DgM1p/PyKTWpqeS7eAmuUa RWVdtfl7tkSmCSfQBU3xO4bxFfdosDK/qds/dqDbD4xN3Yg6pdJK4r6pF51OsA89dr02 bRYuG1HX3rYRlM33DcqiTIWgxNJBG7Qs+p+pwamwiz7rdlhPGcPXsdV7xShyq8JPuHvP FwH34+796NoqXx4L1yGOXFQRyUkn2niP08Bt8FOLdVchVB0v6FBAD5S/DeV+6sCIILq+ OO+Q== X-Gm-Message-State: AOAM532etQCQzCJ8DIaNJHR4fn/Bk9YkZzliEHzu00YvtFpMLFFQnVPj wzN0wBREjBaTL9uWOPguREQ0FKVBaIkfVg== X-Received: by 2002:a37:9606:: with SMTP id y6mr11326294qkd.13.1632502774021; Fri, 24 Sep 2021 09:59:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/27] linux-user/hexagon: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:07 -0400 Message-Id: <20210924165926.752809-9-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::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.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, Taylor Simpson , 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 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 c7f0bf6b92..74e61739a0 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -162,6 +162,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; @@ -171,8 +176,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; @@ -271,3 +275,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); +}