From patchwork Fri Sep 24 16:59:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514597 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1686636jao; Fri, 24 Sep 2021 10:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh/az1XggzlNAauv4jB8zIWgRczy+SlB2ib7OTI5Kg+uCOW3f4YARV/JsQVXqk/9BWDQhH X-Received: by 2002:ac8:42c5:: with SMTP id g5mr5194389qtm.224.1632503611206; Fri, 24 Sep 2021 10:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503611; cv=none; d=google.com; s=arc-20160816; b=DNWvfIWZRUeva5A5/pGAHjzLCsqVewzrvEoUp71eob7mS2x4NEinyJn9Gxg8soQxqa laX6fswk3VBvGsk9tnbtQDma6gfmue8vjHSGj6IB129KMxZkqY6ydomRFOmhRDmdtYT3 DZBjX0RNX358uHFVKPdCoiyUuTIGgKeAu7gr0zhC3LBOzoqvhu6Yj3NqQFYdsisFyQK2 gJrQWsBXvxdhJDlvlbNpC0hBGGl2LQctupwxu9jMJVafg82HIvYAqrk/Un6HkhxsMXT/ dNTufv+EqGeqEwBrQne9rltUpVn4mpnNcpNL3ehjZd2XR+NRIKqycXzjxzgqgCC6goJx rr+w== 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=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=kj8cImUFZagJOgCQTzJQVzzLhe4FMMwfLurfRTrg5kXkw3XNhthelLIJEzs3dWakjg GAoVhNpFWxb5X4b+cKb24pEV+PYHq8Ltmjtth09so/CmYaqgbjep5moKEwQOr2vXOOZL 8Jp4RSWONsPV2g5euFm6W4KQqM996rLI4xsyU20FCX6uTIzcrA9mNkmY9aCFXGVnkHt8 nLJgKeQ1I9n24Uwhtw09/qaumMXtHUAxZmK/82c9xsCDor5DZRNcOqqTDNvaNdNTOeg+ pdr7YQckffkP6eyO0E/wKnqNbmVOPn77J+WqQjllM0qiyR587TM50To/bnLEtGLMnEkD aCIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=daLEaNGm; 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 l10si2654010qkp.104.2021.09.24.10.13.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:13:31 -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=daLEaNGm; 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]:60980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTolO-0000sR-Iy for patch@linaro.org; Fri, 24 Sep 2021 13:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-00030P-Gw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:39702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY8-000763-2M for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qt1-x82f.google.com with SMTP id j13so10053206qtq.6 for ; Fri, 24 Sep 2021 09:59:47 -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=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=daLEaNGm2JcBkU6qTxW3+UqnC899+eVTOSVIn7EyU8Dk7RAlC4wGj2VFQlN80RsthD Rh2nmyERAt9nxhAQZ3n4IuQx35c9YR+7/WqRDfIHLSfhzVrZzc3EGOg8ozQSk3IArTQv peUJS/lV92BSFaP39eKF/xeJkKpLf12PmQTshsPzRu+RyDLJkk39rJdSSW9pXfscX+0J ExbMQoTLMQ7HjM9fDGnabNmmvrYjXy2bByeyTxkUN2pe0skvRCfFKG/8RhsyUWX1Uw86 G8OG/dVvk/eKJsVdO48WF5ZJpNwD3os3+wvOpPugzbb0y4mLK5GMiAok472xRwzCTjOm pDrA== 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=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=50GanN+GF0i3mj5z8DjyLfDD9Soc0QUHLxcAJ3TSB11YanC2wrMBwSK+nzhe8vOPIh VxelASetu9oEhR1aaxVLEvLifGwNOcVHhu4GspjJdBNOvLSsTNcO3saFJM8oMh5aebmc QcOd5tN0RU7LteT+msUflJBLHI4GGs2dDyIQGCmHV6cEh1oyLoLrKi59tW8EGvLFJ2Ja MKRujY7IeOYbjinJMGRNztWLoV24zMROxSpsA04p55k6GODKNKqzjR95DR/C73DwXbQs 3DPq7Q3lvSNVfkIJVIu2E6g6yKJiZqg4WL4NVzEoKnQaK6XDPXlpzm/FVWvljTl5sIBF leEg== X-Gm-Message-State: AOAM531fvwpNFlpRzInYn0M0U6n/mK5FMAklkWmcIUmqaWMyvcqZkMo0 ZQ8RIb79mS/+WK3RXbCOOvYRU5E/agzJog== X-Received: by 2002:ac8:5290:: with SMTP id s16mr5162195qtn.412.1632502787172; Fri, 24 Sep 2021 09:59:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 25/27] linux-user/sparc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:24 -0400 Message-Id: <20210924165926.752809-26-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::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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, Mark Cave-Ayland , 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 | 40 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell 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