From patchwork Mon Oct 4 07:44:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 515176 Delivered-To: patch@linaro.org Received: by 2002:ac0:890a:0:0:0:0:0 with SMTP id 10csp1160907imy; Mon, 4 Oct 2021 01:21:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/scJfKoaETqmc5kaDKCCrZFsFoHf7axqXXYlabB0thkSUCv2u6V0uXQCNl5FtsT6zXX7g X-Received: by 2002:a25:5954:: with SMTP id n81mr13275545ybb.435.1633335678866; Mon, 04 Oct 2021 01:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633335678; cv=none; d=google.com; s=arc-20160816; b=lKzaUBmJJ3s68k1zuQdIwgQpk2am5uEahu5qDZa07O+tExFa46wtvlKQJtDZoVXENk RNDFl9vf1hu/kIIXxsiDJa0Bgz7CI2zhD9W1UogftAxuj5buASDtAhuz+EcKQm+2SZpw bekqpPSKbdEp6k0BOXlqNF27YXFo6RcZdXfe8vJuaKLpzFiowudKmZHd/MM5pqdFPeMG v+RpaK5dlQiJD2kyv/4PkurvAGV40ovZ+RMJHPiF+bRR1NIi/PamN1YLy+d4hwPpNeZh FpZ2gFLQ/EXexMQQCNHH2TwR5V94B6/BJXNWxvQ2vK0zX40hlkxk8eUIrjzJQLqXR4er 6JVA== 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; bh=AG78bHynUdYCUuR/uObyTj6XZBdXeAmCPnFQPc/ETv0=; b=jyBVa7ICYHcWjmbdWMJsSEAkvH+Opq2ieO09+t8fkseZwv71iaCPaC9XtBOVdmat5N hxYAdWs1pzWbIF81g4KeuZh/3LpotJo5pAZU45K3hTrzR+Z7AS+q98JXW2PWFzlcCzPv Kf+kK3VuRyLZS0FnQ9bbTsuR6OIbgdNekYBN6dMLzsRWY6gDwcG5Q5mJQKFBZZnag7Yh z/rFhWKv8cpGjBgq15NyGYeX+6MRMMjaEpzN7Ri1OJsEn/zNKaa3knj8g0qpkrsnGv1b suK3p1Taha+vNJBuKMgCdiAxCrSzb4G1aKjIBTVaYKnVQ0zNXpmA5uy+E9ySmjgMhnmE jY/w== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p13si26692066ybu.80.2021.10.04.01.21.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Oct 2021 01:21:18 -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; 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" Received: from localhost ([::1]:46290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXJDp-0007oa-Ld for patch@linaro.org; Mon, 04 Oct 2021 04:21:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIed-0004Qq-0x for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:56 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:51971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXIeX-000520-Sx for qemu-devel@nongnu.org; Mon, 04 Oct 2021 03:44:52 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MiuGK-1n32xU10lw-00exUa; Mon, 04 Oct 2021 09:44:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/26] linux-user/hexagon: Implement setup_sigtramp Date: Mon, 4 Oct 2021 09:44:03 +0200 Message-Id: <20211004074421.3141222-9-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004074421.3141222-1-laurent@vivier.eu> References: <20211004074421.3141222-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:LoLYmLm85yRnkWD0guv+MYG5Mcs+tcLyixwGFhU7m6rwv2S8ZMN 0Ax2KYBH5XlCMsvEqFoGxka0AfraBjIJj212vX1QqC4NxC+bcDviT12QeO/1S4o5NT0BpUA /qC6LtbCDaYhFpgKnh8DkoHzx7A4jn+gr3zGGlgGZHqoeTSpgSLRk2BiiPvodJ6KchvRnzx am8bFvFuFZnNH3ial25Uw== X-UI-Out-Filterresults: notjunk:1; V03:K0:LKZZj7ZF/a8=:3fQoV7qT7bdH0SF+Pm9AzP v2qAa8+dq+fSIdm4PvKna/1d65B6cQJvf2+Tcg/UaY+u7x0aiXD7XP7LXf3wrPUGqboJSFDau 1a7sOnl9YOiWhaxz0XwYxRunyei/FVz0z3S6Rg7jdb6+n9LtAIRke8qaXsl0w6FGY+AzOAQwP aGT1PeOXENTWmRygf4dqZbr9J0Fev9MEW4TBP2Dct2T9rKc4Ospc4xcHrp6iPH5//3+6c/2TI mCbzwm4HUKPL4cJLBL1/0xXOIJKbuXQnazRGZyMuzPgdXfCoLUVGLjq++/zo2wiSdb4RCdz8K TJYwe1xMOURPrhRFcygcgwhPyiphY7X5zkz8B5N7ue7Bczw9gdS6M+ml8Cbt7D64FBniN87sz MuGEKnc1lSRPTlUjIn2vVVpcHjR3N8yjJO81bba2MeqzQFpASFvxUN2tKm764o0RpD3RUGICg L4rjwUMrsKJ2j/zuGXTfI3fLYGKVbm/VCur20d6t2p5RlCIg4pXt1dbcYE+csNDD59smsLjZY BlOiomyMEuoG767IW6fP0UdqJCCOabhBIoqpZqvzzEBt/dvWXdP4B0m8fGM9m+X3sv4Psu0J6 wt1758RrX3N+hHZaezmERXQfli2FxSnDElyNofg5pBOP0Ea81QVK7r/ltoJFQ69q2TfgRrBQS W1GE6XP72+g5yKIXEh+I+/HP4DP0F2+/TVYTnTqzW7EUGxMn0uhwgeV610iyORljRLx27AOMy cblmdt59zekE7qDqcw2LIaXHNgEIDj6DVM/UHQ== Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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 , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Reviewed-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20210929130553.121567-9-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/hexagon/signal.c | 19 +++++++++++++++++-- linux-user/hexagon/target_signal.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.31.1 diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index c7f0bf6b9283..74e61739a0ab 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); +} diff --git a/linux-user/hexagon/target_signal.h b/linux-user/hexagon/target_signal.h index 345cf1cbb843..9e0223d32225 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 */