From nobody Thu Nov 6 10:20:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540564462870667.7747033423888; Fri, 26 Oct 2018 07:34:22 -0700 (PDT) Received: from localhost ([::1]:60420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG3Bt-00015Z-Si for importer@patchew.org; Fri, 26 Oct 2018 10:34:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG30e-0007Sr-Kd for qemu-devel@nongnu.org; Fri, 26 Oct 2018 10:22:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG30d-0002Tv-M5 for qemu-devel@nongnu.org; Fri, 26 Oct 2018 10:22:44 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:54406 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gG30d-0002TS-92 for qemu-devel@nongnu.org; Fri, 26 Oct 2018 10:22:43 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 2FB651A23A4; Fri, 26 Oct 2018 16:22:42 +0200 (CEST) Received: from smarkovic.mipstec.com (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 166FE1A21EF; Fri, 26 Oct 2018 16:22:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Stefan Markovic To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2018 16:21:07 +0200 Message-Id: <1540563667-23300-7-git-send-email-stefan.markovic@rt-rk.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1540563667-23300-1-git-send-email-stefan.markovic@rt-rk.com> References: <1540563667-23300-1-git-send-email-stefan.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH 6/6] Add prctl() PR_SET_FP_MODE and PR_GET_FP_MODE implementations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pjovanovic@wavecomp.com, riku.voipio@iki.fi, amarkovic@wavecomp.com, aurelien@aurel32.net, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Markovic Signed-off-by: Stefan Markovic Reviewed-by: Aleksandar Markovic --- linux-user/mips/target_syscall.h | 2 ++ linux-user/mips64/target_syscall.h | 2 ++ linux-user/syscall.c | 62 ++++++++++++++++++++++++++++++++++= +--- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/linux-user/mips/target_syscall.h b/linux-user/mips/target_sysc= all.h index 33177af..fa075c9 100644 --- a/linux-user/mips/target_syscall.h +++ b/linux-user/mips/target_syscall.h @@ -247,5 +247,7 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env) /* MIPS-specific prctl() options */ #define TARGET_PR_SET_FP_MODE 45 #define TARGET_PR_GET_FP_MODE 46 +#define TARGET_PR_FP_MODE_FR (1 << 0) +#define TARGET_PR_FP_MODE_FRE (1 << 1) =20 #endif /* MIPS_TARGET_SYSCALL_H */ diff --git a/linux-user/mips64/target_syscall.h b/linux-user/mips64/target_= syscall.h index c1160e6..c8a9027 100644 --- a/linux-user/mips64/target_syscall.h +++ b/linux-user/mips64/target_syscall.h @@ -244,5 +244,7 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env) /* MIPS-specific prctl() options */ #define TARGET_PR_SET_FP_MODE 45 #define TARGET_PR_GET_FP_MODE 46 +#define TARGET_PR_FP_MODE_FR (1 << 0) +#define TARGET_PR_FP_MODE_FRE (1 << 1) =20 #endif /* MIPS64_TARGET_SYSCALL_H */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 15b03e1..810a58b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9529,11 +9529,65 @@ static abi_long do_syscall1(void *cpu_env, int num,= abi_long arg1, #endif #ifdef TARGET_MIPS case TARGET_PR_GET_FP_MODE: - /* TODO: Implement TARGET_PR_SET_FP_MODE handling.*/ - return -TARGET_EINVAL; + { + CPUMIPSState *env =3D ((CPUMIPSState *)cpu_env); + ret =3D 0; + if (env->CP0_Status & (1 << CP0St_FR)) { + ret |=3D TARGET_PR_FP_MODE_FR; + } + if (env->CP0_Config5 & (1 << CP0C5_FRE)) { + ret |=3D TARGET_PR_FP_MODE_FRE; + } + return ret; + } case TARGET_PR_SET_FP_MODE: - /* TODO: Implement TARGET_PR_GET_FP_MODE handling.*/ - return -TARGET_EINVAL; + { + CPUMIPSState *env =3D ((CPUMIPSState *)cpu_env); + bool old_fr =3D env->CP0_Status & (1 << CP0St_FR); + bool new_fr =3D arg2 & TARGET_PR_FP_MODE_FR; + bool new_fre =3D arg2 & TARGET_PR_FP_MODE_FRE; + + if (new_fr && !(env->active_fpu.fcr0 & (1 << FCR0_F64))) { + /* FR1 is not supported */ + return -TARGET_EOPNOTSUPP; + } + if (!new_fr && (env->active_fpu.fcr0 & (1 << FCR0_F64)) + && !(env->CP0_Status_rw_bitmask & (1 << CP0St_FR))) { + /* cannot set FR=3D0 */ + return -TARGET_EOPNOTSUPP; + } + if (new_fre && !(env->active_fpu.fcr0 & (1 << FCR0_FREP))) { + /* Cannot set FRE=3D1 */ + return -TARGET_EOPNOTSUPP; + } + + int i; + fpr_t *fpr =3D env->active_fpu.fpr; + for (i =3D 0; i < 32 ; i +=3D 2) { + if (!old_fr && new_fr) { + fpr[i].w[!FP_ENDIAN_IDX] =3D fpr[i + 1].w[FP_ENDIAN_ID= X]; + } else if (old_fr && !new_fr) { + fpr[i + 1].w[FP_ENDIAN_IDX] =3D fpr[i].w[!FP_ENDIAN_ID= X]; + } + } + + if (new_fr) { + env->CP0_Status |=3D (1 << CP0St_FR); + env->hflags |=3D MIPS_HFLAG_F64; + } else { + env->CP0_Status &=3D ~(1 << CP0St_FR); + } + if (new_fre) { + env->CP0_Config5 |=3D (1 << CP0C5_FRE); + if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) { + env->hflags |=3D MIPS_HFLAG_FRE; + } + } else { + env->CP0_Config5 &=3D ~(1 << CP0C5_FRE); + } + + return 0; + } #endif /* MIPS */ #ifdef TARGET_AARCH64 case TARGET_PR_SVE_SET_VL: --=20 1.9.1