From patchwork Fri Sep 24 16:59:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514607 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1695199jao; Fri, 24 Sep 2021 10:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC7KXZPbY5ClzqNizJ5I4UIosncdjAhKC72r2OW+r2psUnIsuFpYwpoPxOTH2rtGUn15fo X-Received: by 2002:a05:622a:45:: with SMTP id y5mr5239311qtw.145.1632504162052; Fri, 24 Sep 2021 10:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632504162; cv=none; d=google.com; s=arc-20160816; b=FHq1EcADOVlQ8iWdjeKVtkELmvdLjccwJSuD6WfRl18j2WwkWP2Knk/OnqX07AQ/0/ iB2A2pir0Cxw0GoZmSKThxNIZsffnp0JhO8mhjrNfZO/htGDehJDC8AkxMPpzJ13pueu bn7ncRb0XiElyP1dGW6mIXU2NnPEU+p62RATXVIJomRlPoMKZyZ2+oVyGLuxBGpbw90K QffTpruoPZFlA+KddSWEN6onu3XEgHuIJNS85Yt+gIf67q4i5VAikjbd7qYl1aKqWEo+ riCvoe2F40c4WPdXRoLXyZfU1M8DjUCP5VfyyYDqsW7/jsfgmrIJe8G4RBtdSDy22qvq mn5w== 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=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=hzP1HFUKfYafkNLk9PeO10xWn7NJXp1sEFmhtfwoMxcnBaqOxmLXeND6zRUn4TUcY3 SAgfB1gkdeaAVaJhl5qR7s9HzoF3wPwmwSAetoHuakFASkBFjGNRtLRTgsqRN3c9118l Qmty6HUcWS5CQHYPlBhZjuey4kMEFr5/u0Lyt3Noz0X6DxpvcA1RVvd7yRlH/04+Z7rB yvxN3382iLc8Qje8Aw/+yIah4LtjI88k2cFg3G/WqZD/hHHDmS4QPBf8zpw14IbucY8n yoCRdY3VBoTYCjvcZ/g5sccb/evd8Cq1mWjw0o6c9aAaZ4bppmPFPKiotJsV93PYoM4q zsoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nvb6X7Ig; 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 d2si5682282qvx.151.2021.09.24.10.22.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:22:42 -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=nvb6X7Ig; 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]:55356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTouH-0007Y7-Ic for patch@linaro.org; Fri, 24 Sep 2021 13:22:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY8-0002qi-1r for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:48 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:41546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY4-00072x-Oy for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: by mail-qk1-x732.google.com with SMTP id m7so11926007qke.8 for ; Fri, 24 Sep 2021 09:59:44 -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=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=nvb6X7IgiG4QCH5gBpebZZBVwD0cHgiVSvGUIt3D1q2xOX9C4n11QpThSMrdAjDkPS p8zJdtsIM6H0OnRTenjURypWvqDEAs1Qam7HnngzsT5EPG2b/Nhl6Sv6s+l58SQLMUiJ vgHxcJYQ1rg5ZEeWDLxU6npoh/y+E31kueAmAJpfqnMef8EM8I2/SErBwFNIfNTeasiZ HBQUgw4IILUkzflpG7lQk8rhvCTQOGXzHuciOnJaoA5HeAi310tW0VsNkPMH/SB+2gNn tG6xGpUDFct/reIyhz7YEuL/FAmqwSAhFq87l9RNscJr4rWYOdPOqJJlE1vPw9FTm1hE icjg== 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=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=Robhj/2FEjwhBdpYkpeRqdGhbXZJBpGyV6V65avN8mn9YubWnmBoU9T5l7JpyF25Jk HZ5k5oXu1ewYMVSUNOBpYoZfcyIM5Mn9k4m6cINYZZcUJvAXjnoxocSj5t6l4aNSaPPz w7TEUCz+U9Hxs5D/ZerlEjeA29WWgXFBipKIxyjvR8KweLzu8b7gMiY4JQ08r/IFW3V3 1FW+hDr5nPAOdT7q79qeYeaQbLsETsdM0xAQWvuyQvnjAopyDhB/1v1HolxouLTtVFSk OWSAVlxRuC8XbfB/B6sQ9WlkJyasIlrJ2HGQWYe+5pw1nGRLevkoBGQVSMKlO/G63cIL JKSg== X-Gm-Message-State: AOAM532qr8y4Qzoyi79/nTsygW22+56mZY9tsuOtrsj+1t7Jlv6Jugi4 MHEYZYAy9tqk3eBicOqpshDQhiqfsBTxQw== X-Received: by 2002:a37:64cc:: with SMTP id y195mr11351439qkb.97.1632502783932; Fri, 24 Sep 2021 09:59:43 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/27] linux-user/ppc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:20 -0400 Message-Id: <20210924165926.752809-22-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::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.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, qemu-ppc@nongnu.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org Signed-off-by: Richard Henderson --- linux-user/ppc/target_signal.h | 2 ++ linux-user/ppc/signal.c | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/ppc/target_signal.h b/linux-user/ppc/target_signal.h index 72fcdd9bfa..82184ab8f2 100644 --- a/linux-user/ppc/target_signal.h +++ b/linux-user/ppc/target_signal.h @@ -24,4 +24,6 @@ typedef struct target_sigaltstack { #if !defined(TARGET_PPC64) #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* PPC_TARGET_SIGNAL_H */ diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 77f37b9f01..c37744c8fc 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -203,9 +203,6 @@ struct target_func_ptr { #endif -/* We use the mc_pad field for the signal return trampoline. */ -#define tramp mc_pad - /* See arch/powerpc/kernel/signal.c. */ static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, @@ -436,12 +433,7 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Save user regs. */ save_user_regs(env, &frame->mctx); - /* Construct the trampoline code on the stack. */ - encode_trampoline(TARGET_NR_sigreturn, (uint32_t *)&frame->mctx.tramp); - - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(frame->mctx.tramp); + env->lr = default_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -477,7 +469,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_rt_sigframe *rt_sf; - uint32_t *trampptr = 0; struct target_mcontext *mctx = 0; target_ulong rt_sf_addr, newsp = 0; int i, err = 0; @@ -507,22 +498,17 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, #if defined(TARGET_PPC64) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; - trampptr = &rt_sf->trampoline[0]; sc = &rt_sf->uc.tuc_sigcontext; __put_user(h2g(mctx), &sc->regs); __put_user(sig, &sc->signal); #else mctx = &rt_sf->uc.tuc_mcontext; - trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp; #endif save_user_regs(env, mctx); - encode_trampoline(TARGET_NR_rt_sigreturn, trampptr); - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(trampptr); + env->lr = default_rt_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -720,3 +706,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + encode_trampoline(TARGET_NR_sigreturn, tramp + 0); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2); + + unlock_user(tramp, sigtramp_page, 2 * 8); +}