From patchwork Wed Jun 16 01:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461324 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp102965jae; Tue, 15 Jun 2021 18:26:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYLeX2EU6GOIMQdqHI/twdmfB4y44Uv5qQRb+u/KYJRIh3/Jamt9ii3wnxz0s/FNNt5I7y X-Received: by 2002:a05:6638:60b:: with SMTP id g11mr1742155jar.88.1623806772359; Tue, 15 Jun 2021 18:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806772; cv=none; d=google.com; s=arc-20160816; b=XVTxMT/S4laszAhUOtzTTIQIG3e6nZBDkUT0RRHKbKBaXqfrLpSY9LJBZMbJ3QE4Sg GVXdGeNMa04PALdNKVjZngZXiSrsnxKGuMxQvG/2XLs5bjS67b7VuFjeQgz8SmqEIP22 JoABXAJNm7AEhQdoyfDvNQqKjlptB9smtE2URtdfLd12N8jfrApmPpA/oRQJdsKjJSvL K2S6jG9CqKkGRAqLOx+MQNIydSl/Fk1E4d8vXQNnI4A1MGLOoYT7mhJuf+SJaxXzBJih RSx90J6s8ba5Ww/J+pYS4uTRLrNK3j2/Hkz1dPLsenLc5xVxP+wAAHLL6XBXu+EhFLob vfFQ== 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=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=V1ouGQPBc6XKYt56S4nm4ci+qA1UFjFhIv98Fi35UMjD4CZa6KqiBc20nz2agL/zGh o6HM/cws1yzW7Ct0hu+4cme9ThZ5+OIu/K5LP7XW4h4m1v6r+20c/63TZTX1tSCZ8hdZ RtJWJEUpKO1Ii/V9wfic3D+wexRuNcz8BW856n3gS/wqHPGI6E14FwpByEM4TTsTQXSO 8MNFyrvtGETFGxBcTe2Ikuv2kPRGd5lURcKV95MC1KhFiK2xOcOWsYcpZoL211/g7Fim r1bJvyM83B4aKyyczfnVGfw+izQ/VC+cY6DVwk0KBNilHoOSOtilvS5YIP7iETEz82gq g97Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="aMkJ4w/Y"; 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 h23si868843jar.116.2021.06.15.18.26.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:26:12 -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="aMkJ4w/Y"; 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]:45970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKJn-0007mQ-Pd for patch@linaro.org; Tue, 15 Jun 2021 21:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6n-0005lA-Ur for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:45 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:50701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6R-0008UX-Uq for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:42 -0400 Received: by mail-pj1-x1036.google.com with SMTP id g4so750120pjk.0 for ; Tue, 15 Jun 2021 18:12:23 -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=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=aMkJ4w/Yny6+pdVD3hYHRBvqRE/lqIl3BBbUEd3d1QYWLir1opI0DYlnvy8Eh27RB3 AoQQBvLHLsRDQFRifL59EabzRchHKSoGd/VFWH+Ycw/AZtw5sqG+X1NU3xuMJA2qdk2h czZUQ7rNOHm3T5vMiAzT0gUDLCe8mIDZ+BCeg9MMP+qJX3fAcHxn+PD8y5vUwqzXKXnb 6rwX1wDNTk+eoFtGyEuhIuiC4WbjOianqTmWCRrLxmEZQMHPY1BuJZ7HwM3iDZOu4Fzb QW9Egqhmh3S2dJ6JQIapv7AhImMszNNT9NXFaRV6Zk1MMqhLYlNB6Tt6jRn8tJyzocnE 8LoA== 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=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=MhTSrfesRob+lTa5etzWAqJYspf9WMQQ3JgA9cXOCC8e3hID6gmKeEfWR5D1eyNGy+ 75SISw/UqK6g1/9Ogf0joyN8g1zWXEkWFxbZYL5LzI3UBttE7zKo1aYPCE1ym4AwGr1p gTkjp/Fu8x622rL5zJjKJKw9S/Ux+0N3u7xtRKBK4/8/W/M5qj9PQYdZf0mKS2sBB5md HxgWk+WYtKaHs06M6auS6lWQCPf8wWMptEzzbURfeNgeXGPMRNXdAKuTRnoa1z1qtcPb 8Qb18j24o/1YbNojzxX9IngLZ62FuzqMhHWjk+uTRiAo3hsI4ss+Wv7Vcra126lxQVGh L8kw== X-Gm-Message-State: AOAM533Y7CuYwpRmlBhtsS9V4hsxDJZpe21MYAhFLlMtQ3mIrxcEXR4/ KSJ0AJTVYRupZO/U5tyfG7JLllbG2MUrwg== X-Received: by 2002:a17:902:9049:b029:116:e060:c464 with SMTP id w9-20020a1709029049b0290116e060c464mr6815773plz.1.1623805942712; Tue, 15 Jun 2021 18:12:22 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 19/21] linux-user/sparc: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:07 -0700 Message-Id: <20210616011209.1446045-20-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::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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=unavailable 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 , 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. Use them when the guest does not use SA_RESTORER. Cc: Mark Cave-Ayland Signed-off-by: Richard Henderson --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 32 ++++++++++++++++++-------------- 2 files changed, 22 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 0cc3db5570..65e9b7f8b4 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -290,13 +290,7 @@ 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]); + env->regwptr[WREG_O7] = default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -357,13 +351,7 @@ 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]); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = ka->ka_restorer; @@ -774,4 +762,20 @@ 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; + __put_user(0x821020d8u, &tramp[0]); /* mov __NR_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ + + default_rt_sigreturn = sigtramp_page + 8; + __put_user(0x82102065u, &tramp[2]); /* mov __NR_rt_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[3]); /* t 0x10 */ + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif