From patchwork Tue Jul 6 23:49:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 470655 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5472692jao; Tue, 6 Jul 2021 17:08:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbN5ub9Kq5d0pq6wSTG+sktGu8zaVX4Zw1WEy3Bup8chry71zi4s9xG/j6NSMGU9KtJX6Y X-Received: by 2002:a05:6402:1655:: with SMTP id s21mr26542857edx.295.1625616505039; Tue, 06 Jul 2021 17:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625616505; cv=none; d=google.com; s=arc-20160816; b=Nxvsmt8uvILnelUBI3XngnkRlvxR49Ab2l45YCkLFS5xPhgw/Cs/o1HNf9L21WjLxB 7t4pAOf2WfqHYw3SX9IQKR0VN8AqMDzzQg7RdvXnr22hX+VKyePSNMK1tlaK5IfQa60L Ad2z8p6oPXoanAvi0tQQT2N+YRppKxpPbzcIxV6YHjrivZDS9ZKsgCJIy/jQWBNwfHJR anTsDDAK7c7KBGuMfk+jg7lpH5APOOrdePGYGUvhSXmgaIVsVO0VPrYLbkFk29ismZI0 WpTQob5s9xsw8ohimHLmvvORXIMX3loKFdFQifE0D5LKbxYr+VhwVTIi+mgKLtYLUNsH +EWg== 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=fM4gXsn+1azg0N7aKG1RgGgXofpXEZEL88nXdO/LS1Y=; b=I90Rqs3dhSwDhFxzUon1tQwbCfmFqwvmAAkS5q/k9kkAFuKtqLiwcUBUiW2FWw4F/e X0AYzgqcTfXZJlh2pQT+lAinLEb9e+OCUzX5rdjX1G62X3QMjKHt2dHBkOduW+YDahyC UxLeFFFlUwhWhld9Fv6dxBz9vdowNnBzZOrIKhyqZSJJ2UztC3izqOm7O+R7br7r4Rcd HWwWIWz9MuIhNkTGq4k4NpICSOq0T1hnmeU+P4GXBAAlQ5868+F4pEOHNZO8jM0eGiRX zsrZdze2FJlKxLo1DM+XBZ30uijAF42CAqmo8vVceOby9tfkT/XYxxLbcMiFyaVCY1fU NnNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="hj/w0S+I"; 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 a17si15371498edx.349.2021.07.06.17.08.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jul 2021 17:08:25 -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="hj/w0S+I"; 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]:43114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0v71-0000w7-9z for patch@linaro.org; Tue, 06 Jul 2021 20:08:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0upM-0001qB-KI for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:50:08 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:33502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0up8-0006gk-BU for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:50:08 -0400 Received: by mail-pg1-x533.google.com with SMTP id 37so447479pgq.0 for ; Tue, 06 Jul 2021 16:49:53 -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=fM4gXsn+1azg0N7aKG1RgGgXofpXEZEL88nXdO/LS1Y=; b=hj/w0S+I9lgJlo7FAMiA1O44Ti/8/Av8uutaVQlUwv9hsd8jSPS1IiT96Sk8hwnzXk is0byr8QzrlbwVml5dkXoohq/CFe5c7WJS8YAKOV3fQGDvF56QlkNHJqqrRb/U5z+IQ0 pJj4hecn9pfNrDTtv3Vj2NDLuRzVpsRwAmMD8DBmPeN64paUwc9bVc+QKPLwvuDPLVMZ DvSSmJ/mF2Og+ir9+xiyyhhW2f5msxaEc45lJRwERtTVRUKT8ThAcn/gverCXl903bBU pQQZrFejBCF4OmqeJt4VbHs0zTPt/Ech1FND5mCf2W07+sIYEApoc9lbDwJTILburRJQ BpdQ== 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=fM4gXsn+1azg0N7aKG1RgGgXofpXEZEL88nXdO/LS1Y=; b=oNMERN0v7k3jZuykHrcpnAtReEyiyiOceDOYa7cBimypan80u0u2RMnJci3BqfsxjB AfKDEv3zGwSCkET9ISolDYhSCizmQEN117r08jz0zw4OXr2aM9E4r+h6996LWXlast/m XvGEAuMBlbVa2YRmcRiQGFBC/0bHpq3Is/0uAAzGNPhGBZ2lP4ddXWFzYOJhNR2Ozbs/ XUpbXa9KJt8wgXy099Z92NUQhPxEL0gPIsjIUPL/7GN+pL/2NibRSIYXj+0SBmXam71/ FjWPQe0TFsbIsn6I8IjZ5hT7mjMkuCX6lzBcpf6FgiNcG6tLHGQAeW8FXMyIUwa3Kx1y fuoA== X-Gm-Message-State: AOAM530BudGXJaU+dh/0eCcDxP9KvPDD1gmGLlTiOdNu+S+6AfOmzNbM K8Y+TerZMxTzoI7EdmC8lmoNVNV3mZnozw== X-Received: by 2002:a65:6443:: with SMTP id s3mr11400259pgv.72.1625615393141; Tue, 06 Jul 2021 16:49:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id b3sm18058114pfi.179.2021.07.06.16.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 16:49:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 31/36] linux-user/ppc: Implement setup_sigtramp Date: Tue, 6 Jul 2021 16:49:27 -0700 Message-Id: <20210706234932.356913-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210706234932.356913-1-richard.henderson@linaro.org> References: <20210706234932.356913-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: qemu-ppc@nongnu.org, alex.bennee@linaro.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 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 70cc27b0f6..2124eef932 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -202,9 +202,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, @@ -435,12 +432,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; @@ -476,7 +468,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; @@ -506,22 +497,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; @@ -719,3 +705,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); +}