From patchwork Wed Sep 29 13:05:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514830 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:4087:0:0:0:0 with SMTP id m7csp10559jam; Wed, 29 Sep 2021 06:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylYsllIuugw82ND7A6NHpPsDo1nv3dpr+RLHyk9yr45jwSmv53KsmA+yK0k/DOZIba47IR X-Received: by 2002:a5d:6b89:: with SMTP id n9mr6656623wrx.372.1632921084895; Wed, 29 Sep 2021 06:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632921084; cv=none; d=google.com; s=arc-20160816; b=rdrkeTMp/w4TpKyI1GGEC4bVvk5PQiAgMcnt1smZ3IN3lt5U4om3fU0OU7J5HEVbeV Kl9UNGud+pYaua6BzFNLRYoDKxT3LMTY9MtaSTAAYo7X1VUeGACCr1r4jYaZzFrnzRt1 /YV1ADJgWTnvpWgWfqcHHbbSbInYRAPfuwbkvk+37RwrIEACwpGeOTX4z33ksCpnnCby hd8j8HODV9lxmbxuUVuAgDAkKsIGNT8C0IahTNxHcfvjZ1dulRebvSqzGC8d4wDvCBk6 ZEFw/pmVUWhUPYZZjiFMsh3ZTs/vHsJ/XaKIVKasHPn1GFnXw3lf4uQv+kMe5s4kJqFx SDuw== 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=1f4aYpKsB+ja4QJ7hAEtER7A5IlRmh/mgnhLrHPEyy0=; b=V0lpVFGFsnU0XfdiimJoLhDxlK/vIdY6OHyS0E7S1KJeHPcMfUcCJGBqsW6DebP5Sa 66+CGQS1EV1CmeWyrJdB1WP+lRFNhz178+8A10+IOyZ4h5VQATxJuD/0ANW5+e1VO7ce 168uvrIhkSVIXRnFGswhaxIiLCXt4vFjrI6BqGD6Ika9CdcdrOdpg1ZyW64hTbNIgc9z VricbjrjXFYdM4M/yIDTY4yi9NrwQyhD7BF8jilIX9W/wQTmnfY3Vx801fnQmvV0QHpQ z0NTjxAWAItu9K3u+n6iftXuGXqESP30qjh1mXg55iJga4QPtnLYZy74iWUjedIA5ffC TB0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lKMEdvbv; 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 2si3744992wrz.407.2021.09.29.06.11.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Sep 2021 06:11:24 -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=lKMEdvbv; 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]:40378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVZMp-0004CH-Mi for patch@linaro.org; Wed, 29 Sep 2021 09:11:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVZHw-0006aw-1m for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:20 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:40659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVZHt-0006A2-NK for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:19 -0400 Received: by mail-ot1-x334.google.com with SMTP id l16-20020a9d6a90000000b0053b71f7dc83so2750115otq.7 for ; Wed, 29 Sep 2021 06:06:17 -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=1f4aYpKsB+ja4QJ7hAEtER7A5IlRmh/mgnhLrHPEyy0=; b=lKMEdvbvcFY/uSD1n4udJCgXqKjbImCTqkQ3svlZ40/BBqDWTqUyu6CyhL7cFi2xdd +Ga1IgBS8ck9SIP38aqwwlxTycZjxp+J6rWNgGGYnoKYufF/OSE8bpkmay4Hn6qf1/Sj tDyXlihSXbbAluIM4aLxFRqi+HyNkvsH1vE9w3J8l1wd+y1N3aW9yQVJuNYGPUoYMTc6 Pu/sLfV7x6Avn1B2INlsANK6gxIEzv2PBrcGUo5nzwW+By9lmK50ljumLoCBWBtzuGP9 ascmM6ghKYGY55hwZVTllnPDD2pYwVNsYJq3a9aLfE6NW8UNoQf3Oldh3awGpvuKqQry L72A== 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=1f4aYpKsB+ja4QJ7hAEtER7A5IlRmh/mgnhLrHPEyy0=; b=o+3ayP/TfxxFx8kowtk3UmAwtYsCZ5x8jrhyBKr0Tgv7RA/W1Fe0Bm2C2iUM2Blhez /jkwj4D54DNktYlggHUAsfe0Acstml30xI/8aboKwsrJVJkFZ+YcWcIi9ZEuNN0QQX4v UPWSJHso9xTRcZDsrrs39ruEgjlquJUWE+Ve7EtCwoWnfizD0GQvogxUiGjYnuI17axa F5eHk+Qbuxmug2dXLK2GJvOZJEUVuj/E0SUtbrwitse/hLljG7s/kPCztAbXviqLKsq9 4Y+J3KzPg8wqoxTbmvI6FjY6+El6i4Yfr8xZzYJ8q561nerCjhGp+GRVSEYgPTmu2q3A oXWw== X-Gm-Message-State: AOAM532nzv/M0TGgA722RXSMtKG1w/RK11bKyHOeqJJTjvlZF+TRKq1v KuNg+WSONUti3yVryYUu36zdi8lid0lwAg== X-Received: by 2002:a05:6830:31b8:: with SMTP id q24mr10117464ots.275.1632920776534; Wed, 29 Sep 2021 06:06:16 -0700 (PDT) Received: from localhost.localdomain ([172.58.171.248]) by smtp.gmail.com with ESMTPSA id w1sm442823ote.41.2021.09.29.06.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:06:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 08/26] linux-user/hexagon: Implement setup_sigtramp Date: Wed, 29 Sep 2021 09:05:35 -0400 Message-Id: <20210929130553.121567-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210929130553.121567-1-richard.henderson@linaro.org> References: <20210929130553.121567-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x334.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. Reviewed-by: 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 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); +}