From nobody Thu Nov 6 10:26:55 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 1540821642158265.7482259718572; Mon, 29 Oct 2018 07:00:42 -0700 (PDT) Received: from localhost ([::1]:45788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH85w-0006wD-LJ for importer@patchew.org; Mon, 29 Oct 2018 10:00:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH81u-0003B0-Od for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH81f-0002wk-EB for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:22 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:44849 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 1gH81e-0002vZ-VZ for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:15 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 3E1781A239C; Mon, 29 Oct 2018 14:55:47 +0100 (CET) Received: from smarkovic.domain.local (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 228A41A22BB; Mon, 29 Oct 2018 14:55:47 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Stefan Markovic To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2018 14:55:14 +0100 Message-Id: <1540821315-28346-6-git-send-email-stefan.markovic@rt-rk.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1540821315-28346-1-git-send-email-stefan.markovic@rt-rk.com> References: <1540821315-28346-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 v2 5/6] Determine the desired FPU mode 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: smarkovic@wavecomp.com, riku.voipio@iki.fi, laurent@vivier.eu, amarkovic@wavecomp.com, pjovanovic@wavecomp.com, aurelien@aurel32.net 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 Floating-point mode is calculated from MIPS.abiflags FP ABI value (based on kernel implementation). Illegal combinations are rejected. Reviewed-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- linux-user/mips/cpu_loop.c | 75 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 75 insertions(+) diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index c9c20cf..97e4957 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -740,6 +740,34 @@ void target_cpu_copy_regs(CPUArchState *env, struct ta= rget_pt_regs *regs) struct image_info *info =3D ts->info; int i; =20 + struct mode_req { + bool single; + bool soft; + bool fr1; + bool frdefault; + bool fre; + }; + + static const struct mode_req fpu_reqs[] =3D { + [MIPS_ABI_FP_ANY] =3D { true, true, true, true, true }, + [MIPS_ABI_FP_DOUBLE] =3D { false, false, false, true, true }, + [MIPS_ABI_FP_SINGLE] =3D { true, false, false, false, false }, + [MIPS_ABI_FP_SOFT] =3D { false, true, false, false, false }, + [MIPS_ABI_FP_OLD_64] =3D { false, false, false, false, false }, + [MIPS_ABI_FP_XX] =3D { false, false, true, true, true }, + [MIPS_ABI_FP_64] =3D { false, false, true, false, false }, + [MIPS_ABI_FP_64A] =3D { false, false, true, false, true } + }; + + /* + * Mode requirements when .MIPS.abiflags is not present in the ELF. + * Not present means that everything is acceptable except FR1. + */ + static struct mode_req none_req =3D { true, true, false, true, true }; + + struct mode_req prog_req; + struct mode_req interp_req; + for(i =3D 0; i < 32; i++) { env->active_tc.gpr[i] =3D regs->regs[i]; } @@ -747,6 +775,53 @@ void target_cpu_copy_regs(CPUArchState *env, struct ta= rget_pt_regs *regs) if (regs->cp0_epc & 1) { env->hflags |=3D MIPS_HFLAG_M16; } + +#ifdef TARGET_ABI_MIPSO32 +# define MAX_FP_ABI MIPS_ABI_FP_64A +#else +# define MAX_FP_ABI MIPS_ABI_FP_SOFT +#endif + if ((info->fp_abi > MAX_FP_ABI && info->fp_abi !=3D MIPS_ABI_FP_UNKNO= WN) + || (info->interp_fp_abi > MAX_FP_ABI && + info->interp_fp_abi !=3D MIPS_ABI_FP_UNKNOWN)) { + fprintf(stderr, "qemu: Unexpected FPU mode\n"); + exit(1); + } + + prog_req =3D (info->fp_abi =3D=3D MIPS_ABI_FP_UNKNOWN) ? none_req + : fpu_reqs[info->fp_abi]; + interp_req =3D (info->interp_fp_abi =3D=3D MIPS_ABI_FP_UNKNOWN) ? none= _req + : fpu_reqs[info->interp_fp_abi= ]; + + prog_req.single &=3D interp_req.single; + prog_req.soft &=3D interp_req.soft; + prog_req.fr1 &=3D interp_req.fr1; + prog_req.frdefault &=3D interp_req.frdefault; + prog_req.fre &=3D interp_req.fre; + + bool cpu_has_mips_r2_r6 =3D env->insn_flags & ISA_MIPS32R2 || + env->insn_flags & ISA_MIPS64R2 || + env->insn_flags & ISA_MIPS32R6 || + env->insn_flags & ISA_MIPS64R6; + + if (prog_req.fre && !prog_req.frdefault && !prog_req.fr1) { + env->CP0_Config5 |=3D (1 << CP0C5_FRE); + if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) { + env->hflags |=3D MIPS_HFLAG_FRE; + } + } else if ((prog_req.fr1 && prog_req.frdefault) || + (prog_req.single && !prog_req.frdefault)) { + if ((env->active_fpu.fcr0 & (1 << FCR0_F64) + && cpu_has_mips_r2_r6) || prog_req.fr1) { + env->CP0_Status |=3D (1 << CP0St_FR); + env->hflags |=3D MIPS_HFLAG_F64; + } + } else if (!prog_req.fre && !prog_req.frdefault && + !prog_req.fr1 && !prog_req.single && !prog_req.soft) { + fprintf(stderr, "qemu: Can't find a matching FPU mode\n"); + exit(1); + } + if (env->insn_flags & ISA_NANOMIPS32) { return; } --=20 1.9.1