From patchwork Wed Jun 16 01:11:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12323631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFB16C48BE5 for ; Wed, 16 Jun 2021 01:21:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8EB306100A for ; Wed, 16 Jun 2021 01:21:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EB306100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKFi-0006VF-K0 for qemu-devel@archiver.kernel.org; Tue, 15 Jun 2021 21:21:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6Q-0005Oh-Hk for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:22 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:33605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6K-0008Nc-FU for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:21 -0400 Received: by mail-pg1-x535.google.com with SMTP id e20so624147pgg.0 for ; Tue, 15 Jun 2021 18:12:16 -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=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=fKfiqrpqv6eaRUENCso0hwzDHWHXnovlxlYOBG056sc/2KqU+sb5lVJxWCW3gTB/NS aJeK4GH7QNKp4LV4p3R50SdFGDZYzFUw4ApZVabGp0byBdPugRcqbw+qEnCW2fIaOSAA keCZRf7cNzsuAnyiiy7dJ3OWRXMcmTpvJO3s+cSUVv+iYfcQpUD5CEa+fOBZ73ut142z fwtDtsyIis6YnYHZ4V4s132bHpnGkE6tXGZ/G0KrCsa9k9ES/olpa8Rb3tl1JZSDsFF3 hhhDbJuiBxtmhgw2K/ky7JdPcEKdqcXsRtnX3MaF2mwBy5wpheDiE99xi95uMA51Ums6 k/Cw== 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=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=h9BlryBX3QuAvo202rIySgcC5DDhE2iyEwos6egY+NoTpjiOHG1yYvLqwIcSFzoieO NwUyfbyw8w/tC9ra0k/ZwPMtM88vJyNFzI95osS55fbHRWiNN1Be1cKhTflRrRyli0ZZ QfaMQSZBn4tdzdCHZfSvWsIY9Ust8OigP+YVgkN2Ahr538BEz2P+/9gSICi2P4vPwVsp 1qPagJ1Uma3Exzi6M+7ElKi+LZ0jU0YpBLBzuq+5yVLbyl5Xvtg66Hz+pOoEev+V2glF xzknAj66urQ+dj/lwjLeltmZAcYK/fnV4uHW64habJ7Kn/lLSSYvD1GfcI5ie1/4OlB6 FzPw== X-Gm-Message-State: AOAM533QOz1wb+LrErA+8GtFolFEria3yDE3PkLp7i84NLQPU7IueJiw k+/9NFiwlMjbXHc9Zrxuklb4lrCZ5RLqpQ== X-Google-Smtp-Source: ABdhPJwpCJFvgbVonPuvZcvcFpvKKSNcyeVEvbaiI6/XezNGrdPEwrOA3APb8ycuLBRoiHFQXT97rA== X-Received: by 2002:aa7:9581:0:b029:2ea:39e:2224 with SMTP id z1-20020aa795810000b02902ea039e2224mr7180170pfj.32.1623805935172; Tue, 15 Jun 2021 18:12:15 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/21] linux-user/hexagon: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:55 -0700 Message-Id: <20210616011209.1446045-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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 Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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 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(-) 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); +}