From nobody Wed May 8 01:37:18 2024 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 1541702824665509.05690020307566; Thu, 8 Nov 2018 10:47:04 -0800 (PST) Received: from localhost ([::1]:58546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKpKU-0007wb-Bb for importer@patchew.org; Thu, 08 Nov 2018 13:46:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKpHo-0006JZ-Ld for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:44:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKpHj-0002Z6-2y for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:44:12 -0500 Received: from ste-pvt-msa1.bahnhof.se ([213.80.101.70]:23188) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKpHi-00020z-DR for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:44:06 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id C00373F7D4; Thu, 8 Nov 2018 19:43:13 +0100 (CET) Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZWXvNxKYjlpm; Thu, 8 Nov 2018 19:43:07 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 38F1D3F671; Thu, 8 Nov 2018 19:43:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Thu, 8 Nov 2018 19:43:07 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: <5bea109f0c140da6a821aa7f9705d4b3717e86dc.1541701393.git.noring@nocrew.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.70 Subject: [Qemu-devel] [PATCH 1/2] linux-user/mips: Support the n32 ABI for the R5900 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: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Recognise the R5900, which reports itself as MIPS III, as a 64-bit CPU supporting the n32 ABI. Signed-off-by: Fredrik Noring Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/mips64/target_elf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h index ec55d8542a..5f2f2df29f 100644 --- a/linux-user/mips64/target_elf.h +++ b/linux-user/mips64/target_elf.h @@ -12,6 +12,9 @@ static inline const char *cpu_get_model(uint32_t eflags) if ((eflags & EF_MIPS_ARCH) =3D=3D EF_MIPS_ARCH_64R6) { return "I6400"; } + if ((eflags & EF_MIPS_MACH) =3D=3D EF_MIPS_MACH_5900) { + return "R5900"; + } return "5KEf"; } #endif --=20 2.18.1 From nobody Wed May 8 01:37:18 2024 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 1541702824912262.76557702165667; Thu, 8 Nov 2018 10:47:04 -0800 (PST) Received: from localhost ([::1]:58547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKpKU-0007xU-QD for importer@patchew.org; Thu, 08 Nov 2018 13:46:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKpIc-0006ye-Hx for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:45:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKpIW-0003B6-Cy for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:45:02 -0500 Received: from ste-pvt-msa1.bahnhof.se ([213.80.101.70]:30573) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKpIV-0002PI-R6 for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:44:56 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id BEDBB3F7AA; Thu, 8 Nov 2018 19:43:48 +0100 (CET) Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iRYpDMhthPjl; Thu, 8 Nov 2018 19:43:40 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 399C23F671; Thu, 8 Nov 2018 19:43:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Date: Thu, 8 Nov 2018 19:43:40 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.70 Subject: [Qemu-devel] [PATCH 2/2] tests/tcg/mips: Test user mode DMULT for the R5900 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: =?utf-8?Q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The R5900 reports itself as MIPS III but does not implement DMULT. Verify that DMULT is emulated properly in user mode by multiplying two 64-bit numbers to produce a 128-bit number. Signed-off-by: Fredrik Noring --- tests/tcg/mips/mipsn32r5900/Makefile | 25 +++++++++++++++++ tests/tcg/mips/mipsn32r5900/dmult.c | 40 ++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile create mode 100644 tests/tcg/mips/mipsn32r5900/dmult.c diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r= 5900/Makefile new file mode 100644 index 0000000000..7dd16723fe --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/Makefile @@ -0,0 +1,25 @@ +-include ../../config-host.mak + +CROSS=3Dmips64r5900el-unknown-linux-gnu- + +SIM=3Dqemu-mipsn32el +SIM_FLAGS=3D-cpu R5900 + +CC =3D $(CROSS)gcc +CFLAGS =3D -Wall -mabi=3Dn32 -march=3Dr5900 -static + +TESTCASES =3D dmult.tst + +all: $(TESTCASES) + +%.tst: %.c + $(CC) $(CFLAGS) $< -o $@ + +check: $(TESTCASES) + @for case in $(TESTCASES); do \ + echo $(SIM) $(SIM_FLAGS) ./$$case;\ + $(SIM) $(SIM_FLAGS) ./$$case; \ + done + +clean: + $(RM) -rf $(TESTCASES) diff --git a/tests/tcg/mips/mipsn32r5900/dmult.c b/tests/tcg/mips/mipsn32r5= 900/dmult.c new file mode 100644 index 0000000000..2827ab5358 --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/dmult.c @@ -0,0 +1,40 @@ +/* + * Test DMULT. + */ + +#include +#include +#include + +struct hi_lo { int64_t hi; uint64_t lo; }; + +static struct hi_lo dmult(int64_t rs, int64_t rt) +{ + int64_t hi; + uint64_t lo; + + /* + * The R5900 reports itself as MIPS III but does not implement DMULT. + * Verify that DMULT is emulated properly in user mode. + */ + __asm__ __volatile__ ( + " .set mips3\n" + " dmult %2, %3\n" + " mfhi %0\n" + " mflo %1\n" + : "=3Dr" (hi), "=3Dr" (lo) + : "r" (rs), "r" (rt)); + + return (struct hi_lo) { .hi =3D hi, .lo =3D lo }; +} + +int main() +{ + /* Verify that multiplying two 64-bit numbers yields a 128-bit number.= */ + struct hi_lo r =3D dmult(2760727302517, 5665449960167); + + assert(r.hi =3D=3D 847887); + assert(r.lo =3D=3D 7893651516417804947); + + return 0; +} --=20 2.18.1