From nobody Thu Nov 6 08:24:36 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 1540821744874287.6710899102583; Mon, 29 Oct 2018 07:02:24 -0700 (PDT) Received: from localhost ([::1]:45803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH87b-0008Ch-QS for importer@patchew.org; Mon, 29 Oct 2018 10:02:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH81z-0003DC-Dw for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH81u-000397-Oo for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:32 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:43669 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 1gH81k-0002GS-0E for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:22 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id B1AAA1A22D2; Mon, 29 Oct 2018 14:55:16 +0100 (CET) Received: from smarkovic.domain.local (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 95FF21A225A; Mon, 29 Oct 2018 14:55:16 +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:10 +0100 Message-Id: <1540821315-28346-2-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 1/6] Define MIPS_ABI_FP_UNKNOWN macro 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 Add MIPS_ABI_FP_UNKNOWN as QEMU internal value to represent unknown fp_abi (based on kernel mips/include/asm/elf.h definition) Reviewed-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- include/elf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/elf.h b/include/elf.h index 5f45f9b..c151164 100644 --- a/include/elf.h +++ b/include/elf.h @@ -87,6 +87,8 @@ typedef int64_t Elf64_Sxword; #define EF_MIPS_MACH_LS3A 0x00a20000 /* ST Microelectronics Loongson = 3A */ #define EF_MIPS_MACH 0x00ff0000 /* EF_MIPS_MACH_xxx selection ma= sk */ =20 +#define MIPS_ABI_FP_UNKNOWN (-1) /* Unknown FP ABI (internal) = */ + #define MIPS_ABI_FP_ANY 0x0 /* FP ABI doesn't matter = */ #define MIPS_ABI_FP_DOUBLE 0x1 /* -mdouble-float = */ #define MIPS_ABI_FP_SINGLE 0x2 /* -msingle-float = */ --=20 1.9.1 From nobody Thu Nov 6 08:24:36 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 1540821797649902.2946470802755; Mon, 29 Oct 2018 07:03:17 -0700 (PDT) Received: from localhost ([::1]:45806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH88S-0000MI-KH for importer@patchew.org; Mon, 29 Oct 2018 10:03:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH825-0003I8-13 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH823-0003Em-4q for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:40 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:43869 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 1gH81z-0002Td-Dq for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:37 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id E8AD51A225A; Mon, 29 Oct 2018 14:55:24 +0100 (CET) Received: from smarkovic.domain.local (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id CE7C11A1E50; Mon, 29 Oct 2018 14:55:24 +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:11 +0100 Message-Id: <1540821315-28346-3-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 2/6] Extend image_info struct with MIPS specific fp_abi and interp_fp_abi fields 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 Add MIPS specific image_info struct fields fp_abi and interp_fp_abi to store executable and interpreter fp_abi values (based on kernel struct arch_elf_state in mips/include/asm/elf.h). Reviewed-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- linux-user/qemu.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 1beb6a2..a752c1c 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -61,6 +61,10 @@ struct image_info { abi_ulong interpreter_loadmap_addr; abi_ulong interpreter_pt_dynamic_addr; struct image_info *other_info; +#ifdef TARGET_MIPS + int fp_abi; + int interp_fp_abi; +#endif }; =20 #ifdef TARGET_I386 --=20 1.9.1 From nobody Thu Nov 6 08:24:36 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540821916241806.3916696571073; Mon, 29 Oct 2018 07:05:16 -0700 (PDT) Received: from localhost ([::1]:45814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH8AH-0001Zw-S6 for importer@patchew.org; Mon, 29 Oct 2018 10:05:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH825-0003J7-RV for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH825-0003Fv-02 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:41 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:44016 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 1gH823-0002aC-04 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:40 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 8010F1A2399; Mon, 29 Oct 2018 14:55:33 +0100 (CET) Received: from smarkovic.domain.local (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 651441A21F0; Mon, 29 Oct 2018 14:55:33 +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:12 +0100 Message-Id: <1540821315-28346-4-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 3/6] Extract MIPS abiflags from ELF file 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 Read MIPS.abiflags section from ELF file into Mips_elf_abiflags_v0 struct. Reviewed-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- linux-user/elfload.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 055f6a9..5881233 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1517,11 +1517,25 @@ static void bswap_sym(struct elf_sym *sym) bswaptls(&sym->st_size); bswap16s(&sym->st_shndx); } + +#ifdef TARGET_MIPS +static void bswap_mips_abiflags(Mips_elf_abiflags_v0 *abiflags) +{ + bswap16s(&abiflags->version); + bswap32s(&abiflags->ases); + bswap32s(&abiflags->isa_ext); + bswap32s(&abiflags->flags1); + bswap32s(&abiflags->flags2); +} +#endif #else static inline void bswap_ehdr(struct elfhdr *ehdr) { } static inline void bswap_phdr(struct elf_phdr *phdr, int phnum) { } static inline void bswap_shdr(struct elf_shdr *shdr, int shnum) { } static inline void bswap_sym(struct elf_sym *sym) { } +#ifdef TARGET_MIPS +static inline void bswap_mips_abiflags(Mips_elf_abiflags_v0 *abiflags) { } +#endif #endif =20 #ifdef USE_ELF_CORE_DUMP @@ -2364,6 +2378,25 @@ static void load_elf_image(const char *image_name, i= nt image_fd, goto exit_errmsg; } *pinterp_name =3D interp_name; +#ifdef TARGET_MIPS + } else if (eppnt->p_type =3D=3D PT_MIPS_ABIFLAGS) { + Mips_elf_abiflags_v0 abiflags; + if (eppnt->p_filesz < sizeof(Mips_elf_abiflags_v0)) { + errmsg =3D "Invalid PT_MIPS_ABIFLAGS entry"; + goto exit_errmsg; + } + if (eppnt->p_offset + eppnt->p_filesz <=3D BPRM_BUF_SIZE) { + memcpy(&abiflags, bprm_buf + eppnt->p_offset, + sizeof(Mips_elf_abiflags_v0)); + } else { + retval =3D pread(image_fd, &abiflags, sizeof(Mips_elf_abif= lags_v0), + eppnt->p_offset); + if (retval !=3D sizeof(Mips_elf_abiflags_v0)) { + goto exit_perror; + } + } + bswap_mips_abiflags(&abiflags); +#endif } } =20 --=20 1.9.1 From nobody Thu Nov 6 08:24:36 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 1540822128625563.3534843510962; Mon, 29 Oct 2018 07:08:48 -0700 (PDT) Received: from localhost ([::1]:45833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH8Dn-0004D6-6P for importer@patchew.org; Mon, 29 Oct 2018 10:08:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH82B-0003UH-Ed for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH828-0003IN-1A for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:47 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:44218 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 1gH827-0002gQ-Pb for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:43 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 88BF51A22A7; Mon, 29 Oct 2018 14:55:41 +0100 (CET) Received: from smarkovic.domain.local (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 6CE331A1E50; Mon, 29 Oct 2018 14:55:41 +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:13 +0100 Message-Id: <1540821315-28346-5-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 4/6] Read and set FP ABI value from MIPS abiflags 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 Set fp_abi and interp_fp_abi values to current fp_abi value read from MIPS.abiflags. Reviewed-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- linux-user/elfload.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 5881233..5bccd2e 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2396,6 +2396,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, } } bswap_mips_abiflags(&abiflags); + info->fp_abi =3D abiflags.fp_abi; #endif } } @@ -2708,6 +2709,9 @@ int load_elf_binary(struct linux_binprm *bprm, struct= image_info *info) target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); } +#ifdef TARGET_MIPS + info->interp_fp_abi =3D interp_info.fp_abi; +#endif } =20 bprm->p =3D create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, --=20 1.9.1 From nobody Thu Nov 6 08:24:36 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 From nobody Thu Nov 6 08:24:36 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 1540821599567865.8539819869623; Mon, 29 Oct 2018 06:59:59 -0700 (PDT) Received: from localhost ([::1]:45781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH85G-0006LM-Ap for importer@patchew.org; Mon, 29 Oct 2018 09:59:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gH81o-00032I-3t for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gH81f-0002ww-F5 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 09:56:19 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:44850 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-0002vb-W9 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 907331A23A8; Mon, 29 Oct 2018 14:55:54 +0100 (CET) Received: from smarkovic.domain.local (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 690991A4139; Mon, 29 Oct 2018 14:55:54 +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:15 +0100 Message-Id: <1540821315-28346-7-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 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: 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 Implement MIPS specific prctl() PR_SET_FP_MODE and PR_GET_FP_MODE emulation. Reviewed-by: Aleksandar Markovic Signed-off-by: Stefan 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..d5509a3 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..8ccc468 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