From patchwork Mon May 17 18:13:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 440182 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1336350jac; Mon, 17 May 2021 11:28:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhk96P+oEJ9KnLOsfiAl0NzQ/Une0pl9Cm1OBDghX0/TrjcXW31jrkc0mBFNHKdROI3101 X-Received: by 2002:a9d:7987:: with SMTP id h7mr787830otm.70.1621276133062; Mon, 17 May 2021 11:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621276133; cv=none; d=google.com; s=arc-20160816; b=iMIctbqh+faPywokDAgGPkwIEAKU2Y8OXsnKVEGDbN8G9nUWMiQoPEqxZzxcCPfykh PuVd/H+kDPc4BSWWxqi7W4dll2+iGkYc4itXCgyHB+zhD8SPiiZf1M1fMQKdreUNL0vt aQWSr4YBXXMhnqKBtEJ+js/3m0pbeXrYRUzWRhEANSQUjqIxAgP3KKsDKTwvhbL9g2WW 9Ik3hWlrrtH43PkQ5rhwqFkQ72GuIO7rqExJWyXO8gvnapbj66reKNjUUsNdlQfTNj54 A+O5bIt2q25+QRQMAxmQHTLtE8764QPSCQ2zmcBbmow5tMd3Gl03FOx8q8PEOAaJWl8l Bbdw== 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; bh=A2nc0rX1Iqy4HRlYvwf20T8jLafbFovSTexElWk5DLg=; b=dUL+JUrmur77ZytghbfAoovXvTHjzlvAUqZZKPCS9AM2vMk7AA1w2VVZSWKqJQGL2P 42p9TeCnXvIXhLwYjJ0U1ye2a35zJaa7b/iccgNAS7Jy6pXl9oS+tBxdYnbjMbd20lQe 53cmVoCDtfmGHd0CN/VKOP4NLdKCgg5VfnHA+8tNNVP0NBzYOf5FDUuEJCKR/D4tiAqk FIqZHrphOpsBdcbjMJU2ulAx9TrbjZxE4RpriUkHmGcm+FuJTPHIFj7Q/4j6ucxK/DwN JXoUlJNDZNGaHH/UItvAdMaXBOytn6/+Blhtdscn9obiNT/wSe2y2AMpotBy0cziJYwK IyUw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v2si14940510otn.224.2021.05.17.11.28.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 May 2021 11:28:53 -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; 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" Received: from localhost ([::1]:58540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihz2-0004GC-An for patch@linaro.org; Mon, 17 May 2021 14:28:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihlU-0006E0-F1 for qemu-devel@nongnu.org; Mon, 17 May 2021 14:14:52 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:34435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihlM-0004Rz-Ng for qemu-devel@nongnu.org; Mon, 17 May 2021 14:14:52 -0400 Received: from quad ([82.142.31.78]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MBV2f-1lcuLe1YVj-00Cz6X; Mon, 17 May 2021 20:14:41 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 29/59] linux-user/sparc: Add 64-bit support to fpu save/restore Date: Mon, 17 May 2021 20:13:54 +0200 Message-Id: <20210517181424.8093-30-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517181424.8093-1-laurent@vivier.eu> References: <20210517181424.8093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:KXJ/0d5omk5Juih4Xw2n9mycDavHf0bPOWrPEy2XQBy/XbYJNnk Bk+ZBDNoqaZog5NG3Vnqu9BRfSjnoplTin1vUwYwcRKcN2vdsVPIT7t0uHmZxyvUK22nSi2 b0tpKdlUftOq2LhbkLgQ5gFxfjBUlONe+URRLNTC1laqTRJSgxwWco+XhawLiDGfLpHnaeo p/1IETYDZ5uWjO11YXz8g== X-UI-Out-Filterresults: notjunk:1; V03:K0:htoltKhZhEY=:KQkyuhBW6okJSLniV2A2p5 IFZi+dEz+4UeoB5N4itTrVoP3fnpDoPtvT0f7wYU7z0Jq9YLnFIIoK2uFknbxdsQmfjv+jg9k twsL7EO+9uFKw4vhJ4dp8FbIzKHuKCsa7t6FPY2NI7Q+wzmo+zpozsxxWeTEzf1eMiG5hTT8f Ulq68VQBKG3tzg9//vzJtKmr6v2aH8f01i3oFL7VLFCkPTbGp7TYclyyvF20hPI4GRXZWCHZj /XOChRhbyzjEb7XhRmK61AOMdaea3WdgyTPlEakuZtiOMBjfxfkNSUqOzsV/EyA6zC8gtiQ2n Nt/rlsvp8s8cbNEgspNYLZrSh7LTFAX4BNURhS13EEs4O6sglfJ9rvH+akgcnTT9j+38GM72j 0I8MnzFfwDSIRTX3wjURqXI0RumbNDM0hgw2ZYGrT7kD1ADbfQniU9WcKGY3zH5PpOfw8Lzzf Mt+hyZK5cTukonHPxSRCh8lTHFTMC6PGTVPoa68ZSg4DduLyfYMUHpOx9Wt2xhcMuV0R6RZkG WHnyIjfgu0BpC2RGF/dNnU= Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The shape of the kernel's __siginfo_fpu_t is dependent on the cpu type, not the abi. Which is weird, but there ya go. Signed-off-by: Richard Henderson Message-Id: <20210426025334.1168495-23-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/signal.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) -- 2.31.1 diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 0ff57af43d1e..41a8b33bac3c 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -44,6 +44,12 @@ struct target_stackf { }; struct target_siginfo_fpu { +#ifdef TARGET_SPARC64 + uint64_t si_double_regs[32]; + uint64_t si_fsr; + uint64_t si_gsr; + uint64_t si_fprs; +#else /* It is more convenient for qemu to move doubles, not singles. */ uint64_t si_double_regs[16]; uint32_t si_fsr; @@ -52,6 +58,7 @@ struct target_siginfo_fpu { uint32_t insn_addr; uint32_t insn; } si_fpqueue [16]; +#endif }; struct target_signal_frame { @@ -167,21 +174,50 @@ static void save_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env) { int i; +#ifdef TARGET_SPARC64 + for (i = 0; i < 32; ++i) { + __put_user(env->fpr[i].ll, &fpu->si_double_regs[i]); + } + __put_user(env->fsr, &fpu->si_fsr); + __put_user(env->gsr, &fpu->si_gsr); + __put_user(env->fprs, &fpu->si_fprs); +#else for (i = 0; i < 16; ++i) { __put_user(env->fpr[i].ll, &fpu->si_double_regs[i]); } __put_user(env->fsr, &fpu->si_fsr); __put_user(0, &fpu->si_fpqdepth); +#endif } static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env) { int i; +#ifdef TARGET_SPARC64 + uint64_t fprs; + __get_user(fprs, &fpu->si_fprs); + + /* In case the user mucks about with FPRS, restore as directed. */ + if (fprs & FPRS_DL) { + for (i = 0; i < 16; ++i) { + __get_user(env->fpr[i].ll, &fpu->si_double_regs[i]); + } + } + if (fprs & FPRS_DU) { + for (i = 16; i < 32; ++i) { + __get_user(env->fpr[i].ll, &fpu->si_double_regs[i]); + } + } + __get_user(env->fsr, &fpu->si_fsr); + __get_user(env->gsr, &fpu->si_gsr); + env->fprs |= fprs; +#else for (i = 0; i < 16; ++i) { __get_user(env->fpr[i].ll, &fpu->si_double_regs[i]); } __get_user(env->fsr, &fpu->si_fsr); +#endif } void setup_frame(int sig, struct target_sigaction *ka,