From patchwork Wed Sep 29 13:05:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514852 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:4087:0:0:0:0 with SMTP id m7csp34848jam; Wed, 29 Sep 2021 06:38:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8myV+F5Xc8RztjalSuInLyozVWjuGy75H4MTzGrNMKWvvSEKFSy9Fhu1jnBVujjANUv16 X-Received: by 2002:ae9:eb58:: with SMTP id b85mr5030802qkg.323.1632922686817; Wed, 29 Sep 2021 06:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632922686; cv=none; d=google.com; s=arc-20160816; b=X+pO9DbFnU6JilEQiHGcAxL/Cc5y8fP0Unz1F/xkAQlO/VfJeXrxkQzqmg3aoXjoon acZ/cqwwd9X8w01pRnSiUc+yEw3WfE4dpCeEbOB1c5DWn+IGUi21VRklp7HLGWcVdYbS LKqWYRfyEnNsh2P9bh6GQLNf60gmV7Tu6WSCF53wJdQ36E7vQX3YR4neCz/D0Xdr4Ly6 qt+GlHxzFEyTXa71uNRxjUMOxQkB/BXb58L06Pqbmq6F0Zr4WtD+Z1UYCdgm2xHqfPx4 PP+KnBCeLhmo8rVoeRIy1EIGzCo8kkLC8mwJtUqXeiO0GBLa/3UTehop5m1iVTi/SKQS fYBQ== 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=em63mRXCyLKKFcAEyKw3h3vHxVxde+27GcHsVAZyLao=; b=BaoYyZQzcBqvTDG8F9eKzbO0fHltkWvFDvY7xy+x0DVRwee3AqzTSYScys6D10UK80 +dFcw11M49n7J5c2D6GXpYNdA5AMPfDra6bTSPGNOw+qfSF5Hnr99OkdPtgsd76sXmqQ C9kyVBTBOKf+Vf+/wXnmWIRTwvpeG1JGdNkMaQPs0jxRC9V/FkarqZr+AJynt+R5pn4K A5TDzYsjcZCBunBSX9AjIp8d1TvPvnIFF/AQhzcsEc8smHrxhDcXa0G4sHwIWnFuPIvJ Mz6DsKcgGZAqW/79/FNtMo6bqV1TiUTdtytDoFKwkPS/f883aIP/prQbMd5xFicIMTuc Tewg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CqHXmF4c; 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 w12si2548813vsa.281.2021.09.29.06.38.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Sep 2021 06:38:06 -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=CqHXmF4c; 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]:45742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVZmc-0004tG-Ef for patch@linaro.org; Wed, 29 Sep 2021 09:38:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVZIV-0007hw-M8 for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:56 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:35580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVZIS-0006T1-Sw for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:55 -0400 Received: by mail-ot1-x331.google.com with SMTP id 77-20020a9d0ed3000000b00546e10e6699so2771225otj.2 for ; Wed, 29 Sep 2021 06:06:49 -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=em63mRXCyLKKFcAEyKw3h3vHxVxde+27GcHsVAZyLao=; b=CqHXmF4cer/jDGT/G6BeNp6ohx1YjS26WNnexhRj1NQsR2LxUe60F7sZForfRfAKCE Z6tgaBgQ6n8hI/utoPZEGxX+zcsEmmB89VDcMLbmRVqLenONeZPX2M3pm8mJYi+vJKcY nJPp+WbysYdbTgzPNbf+QNh0WnhGCFtTSPfk++7YXmwBlPwlUk3UcZdb4qIPYkbEr6hB ISBgIyZW1fGRsaVGBU7ZrRJZgiEsiG2VdcbbO158cgtWdYDMGVeQXzEiSPbJIwP5E6Wo HGq4ZCCi43LvRXmctg2UZqplNrhOflGTQVrptRV0sUJ024XnGpfp8QMD26HdlmXMbnV7 /pnA== 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=em63mRXCyLKKFcAEyKw3h3vHxVxde+27GcHsVAZyLao=; b=dR6Ndv+i85/CEEO0hhx20ZDGMyqK/KjYNqucK1fMv5cnIF95teQywj1+Aq1cIPJ2YL AFgC0e/ECkGkkcjj4ZKPgL+VagsR2TPh8+tfBsoNP+DRkRwYzrSik0lpYZUma8QCV1sY FvlptLA2mqUIQGeQUs1Gvx4kJsoZuxTprnxBwNQRXrJmus+AI///SPzNJe8jzXNVvH3d Ytvuhl9WD2gAsEk0fvoLyKf5A9bcaubeqnM2pW1mMbRb/+Rvxyr7nwm1p4gYKGIC5hkZ qU1c4TPHW8CYRFD+WlsTwB6llBgSX/NioKAzz2WlFzByUpmLsPU2eQBVlVel/CsnJ4jF HxMA== X-Gm-Message-State: AOAM532qlU1mcWLwCOr1mcdcAl0AIKwleTCvN9Rh3uSHHJUDVowEP3lE KSnspfaAkaMH7hWF+CHGUsE6eY/4neRN0g== X-Received: by 2002:a9d:7d8c:: with SMTP id j12mr9858821otn.135.1632920808784; Wed, 29 Sep 2021 06:06:48 -0700 (PDT) Received: from localhost.localdomain ([172.58.171.248]) by smtp.gmail.com with ESMTPSA id w1sm442823ote.41.2021.09.29.06.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:06:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 23/26] linux-user/sparc: Implement setup_sigtramp Date: Wed, 29 Sep 2021 09:05:50 -0400 Message-Id: <20210929130553.121567-24-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::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: Mark Cave-Ayland , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , alex.bennee@linaro.org, laurent@vivier.eu, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Acked-by: Mark Cave-Ayland Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 40 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h index 34f9a12519..e661ddd6ab 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -69,6 +69,10 @@ typedef struct target_sigaltstack { #ifdef TARGET_ABI32 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 +#else +/* For sparc64, use of KA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 #endif /* bit-flags */ diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 3bc023d281..23e1e761de 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -242,6 +242,12 @@ static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env) } #ifdef TARGET_ARCH_HAS_SETUP_FRAME +static void install_sigtramp(uint32_t *tramp, int syscall) +{ + __put_user(0x82102000u + syscall, &tramp[0]); /* mov syscall, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUSPARCState *env) { @@ -291,13 +297,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = sf_addr + - offsetof(struct target_signal_frame, insns) - 2 * 4; - - /* mov __NR_sigreturn, %g1 */ - __put_user(0x821020d8u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_sigreturn); + env->regwptr[WREG_O7] = default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -358,13 +360,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = - sf_addr + offsetof(struct target_rt_signal_frame, insns) - 2 * 4; - - /* mov __NR_rt_sigreturn, %g1 */ - __put_user(0x82102065u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_rt_sigreturn); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = ka->ka_restorer; @@ -775,4 +773,18 @@ do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); } +#else +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif