From nobody Sat May 18 21:16:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588094545; cv=none; d=zohomail.com; s=zohoarc; b=DPyxlB2KVkCfaSFoHXSdzjNmFLCnZgUxT1HuLxoAbMQybPph+gvXQY/mMKjnapbYXq+uMyTduZAexOdHzIERfu5aKOK2IWKYPiXHNaR1V3EB/bGVm4VYibjTgM377V/5+NUZydLv3uINLvl/UVzQaYG0cmkF7ItHds+Q6WpOy3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588094545; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=V2EEff4iEt2IpN7kycTMIDWpvPTjsyL3RgOXFRGrDQE=; b=ggoJAZNPXCSaHc/fxB/9j46xa8X3iL2VhYcNHluBJd3z7mBMppY5U5jhqhPqoNK7y9dwz4GxQ2WL5g3jcZMYGWbfvXCQ5W5d0+3hInCdmMZpOnfs7mgYz7VtdrRwQSLDai2gD2u0QRFYnod/Gnuw8g+KUbzidWgbwd3n/Pe/LyM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588094545812957.1176929423651; Tue, 28 Apr 2020 10:22:25 -0700 (PDT) Received: from localhost ([::1]:41046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTTw8-0008MO-CI for importer@patchew.org; Tue, 28 Apr 2020 13:22:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40292) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTTt4-00043T-4H for qemu-devel@nongnu.org; Tue, 28 Apr 2020 13:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTTt2-0003ae-Lf for qemu-devel@nongnu.org; Tue, 28 Apr 2020 13:19:13 -0400 Received: from mel.act-europe.fr ([2a02:2ab8:224:1::a0a:d2]:45742 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jTTt2-0003a8-5h for qemu-devel@nongnu.org; Tue, 28 Apr 2020 13:19:12 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4797581343; Tue, 28 Apr 2020 19:19:10 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7n_DhTv0SgVL; Tue, 28 Apr 2020 19:19:10 +0200 (CEST) Received: from localhost.localdomain.localdomain (lfbn-tou-1-1471-22.w90-89.abo.wanadoo.fr [90.89.4.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 0107B8137A; Tue, 28 Apr 2020 19:19:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at eu.adacore.com From: KONRAD Frederic To: qemu-devel@nongnu.org Subject: [PATCH 1/2] softfloat: m68k: infinity is a valid encoding Date: Tue, 28 Apr 2020 19:17:57 +0200 Message-Id: <1588094279-17913-2-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1588094279-17913-1-git-send-email-frederic.konrad@adacore.com> References: <1588094279-17913-1-git-send-email-frederic.konrad@adacore.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:2ab8:224:1::a0a:d2; envelope-from=frederic.konrad@adacore.com; helo=smtp.eu.adacore.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a02:2ab8:224:1::a0a:d2 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: Peter Maydell , alex.bennee@linaro.org, laurent@vivier.eu, frederic.konrad@adacore.com, philmd@redhat.com, Aurelien Jarno 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" The MC68881 say about infinities (3.2.4): "*For the extended precision format, the most significant bit of the mantissa (the integer bit) is a don't care." https://www.nxp.com/docs/en/reference-manual/MC68881UM.pdf The m68k extended format is implemented with the floatx80 and floatx80_invalid_encoding currently treats 0x7fff00000000000000000000 as an invalid encoding. This patch fixes floatx80_invalid_encoding so it accepts that the most significant bit of the mantissa can be 0. This bug can be revealed with the following code which pushes extended infinity on the stack as a double and then reloads it as a double. It should normally be converted and read back as infinity and is currently read back as nan: .global _start .text _start: lea val, %a0 lea fp, %fp fmovex (%a0), %fp0 fmoved %fp0, %fp@(-8) fmoved %fp@(-8), %fp0 end: bra end .align 0x4 val: .fill 1, 4, 0x7fff0000 .fill 1, 4, 0x00000000 .fill 1, 4, 0x00000000 .align 0x4 .fill 0x100, 1, 0 fp: ------------- (gdb) tar rem :1234 Remote debugging using :1234 _start () at main.S:5 5 lea val, %a0 (gdb) display $fp0 1: $fp0 =3D nan(0xffffffffffffffff) (gdb) si 6 lea fp, %fp 1: $fp0 =3D nan(0xffffffffffffffff) (gdb) si _start () at main.S:7 7 fmovex (%a0), %fp0 1: $fp0 =3D nan(0xffffffffffffffff) (gdb) si 8 fmoved %fp0, %fp@(-8) 1: $fp0 =3D inf (gdb) si 9 fmoved %fp@(-8), %fp0 1: $fp0 =3D inf (gdb) si end () at main.S:12 12 bra end 1: $fp0 =3D nan(0xfffffffffffff800) (gdb) x/1xg $fp-8 0x40000120 : 0x7fffffffffffffff Signed-off-by: KONRAD Frederic --- include/fpu/softfloat.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index ecb8ba0..dc80298 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -688,7 +688,12 @@ static inline int floatx80_is_any_nan(floatx80 a) *-------------------------------------------------------------------------= ---*/ static inline bool floatx80_invalid_encoding(floatx80 a) { +#if defined(TARGET_M68K) + return (a.low & (1ULL << 63)) =3D=3D 0 && (((a.high & 0x7FFF) !=3D 0) + && (a.high !=3D 0x7FFF)); +#else return (a.low & (1ULL << 63)) =3D=3D 0 && (a.high & 0x7FFF) !=3D 0; +#endif } =20 #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL) --=20 1.8.3.1 From nobody Sat May 18 21:16:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588094437; cv=none; d=zohomail.com; s=zohoarc; b=aUHx/kVk2tzT86nImAfLa6RxX555wLJIcQ9gnaN6ndYqslkfJT88d73m77XXHjqskxuvPYU0/iBEU0yQz9mZ49TZ+/mJenoqnvFgZnQKFcaQANdi17JUwEymOB2qHcpBxThfeC5QhiHxDKcbmvYfkv1Oien7X1TRq0SnKU2N6vM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588094437; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=DXW36rJ8TMYqpYxbxxCEvOL+VOERKgGqFmBDDEQhr9c=; b=hZUUlCUrCLRLONDoTnFl+P4c+ozFgnVh2dVSl+zgvHEJjq2ZmwGdjN/bFqTHMtMG9uf+ipPdZkPY5fHB1dTDishJHMcmOHf8hRgphAO2wMhC9C7ajRjnHeyfBcuy9csl+xr5+4fLnWX+BjRJwhgjgH2yOBll5/EPOKd0VfXm67o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588094437394802.0516137136241; Tue, 28 Apr 2020 10:20:37 -0700 (PDT) Received: from localhost ([::1]:40918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTTuO-0005lo-35 for importer@patchew.org; Tue, 28 Apr 2020 13:20:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40288) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTTt3-000430-JF for qemu-devel@nongnu.org; Tue, 28 Apr 2020 13:19:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTTt2-0003aY-JM for qemu-devel@nongnu.org; Tue, 28 Apr 2020 13:19:13 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:37241 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jTTt2-0003aB-18 for qemu-devel@nongnu.org; Tue, 28 Apr 2020 13:19:12 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 870218137A; Tue, 28 Apr 2020 19:19:10 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bN-fJuC4b0b8; Tue, 28 Apr 2020 19:19:10 +0200 (CEST) Received: from localhost.localdomain.localdomain (lfbn-tou-1-1471-22.w90-89.abo.wanadoo.fr [90.89.4.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 525EF81353; Tue, 28 Apr 2020 19:19:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at eu.adacore.com From: KONRAD Frederic To: qemu-devel@nongnu.org Subject: [PATCH 2/2] target/m68k: fix gdb for m68xxx Date: Tue, 28 Apr 2020 19:17:58 +0200 Message-Id: <1588094279-17913-3-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1588094279-17913-1-git-send-email-frederic.konrad@adacore.com> References: <1588094279-17913-1-git-send-email-frederic.konrad@adacore.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=194.98.77.210; envelope-from=frederic.konrad@adacore.com; helo=smtp.eu.adacore.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/28 12:46:33 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Received-From: 194.98.77.210 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: philmd@redhat.com, frederic.konrad@adacore.com, alex.bennee@linaro.org, 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" Currently "cf-core.xml" is sent to GDB when using any m68k flavor. Thing is it uses the "org.gnu.gdb.coldfire.core" feature name and gdb 8.3 then expec= ts a coldfire FPU instead of the default m68881 FPU. This is not OK because the m68881 floats registers are 96 bits wide so it crashes GDB with the following error message: (gdb) target remote localhost:7960 Remote debugging using localhost:7960 warning: Register "fp0" has an unsupported size (96 bits) warning: Register "fp1" has an unsupported size (96 bits) ... Remote 'g' packet reply is too long (expected 148 bytes, got 180 bytes): = \ 00000000000[...]0000 With this patch: qemu-system-m68k -M none -cpu m68020 -s -S (gdb) tar rem :1234 Remote debugging using :1234 warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. 0x00000000 in ?? () (gdb) p $fp0 $1 =3D nan(0xffffffffffffffff) Signed-off-by: KONRAD Frederic Reviewed-by: Laurent Vivier --- configure | 2 +- gdb-xml/m68k-core.xml | 29 ++++++++++++++++++++++++++++ target/m68k/cpu.c | 52 ++++++++++++++++++++++++++++++++++++-----------= ---- 3 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 gdb-xml/m68k-core.xml diff --git a/configure b/configure index 23b5e93..2b07b85 100755 --- a/configure +++ b/configure @@ -7825,7 +7825,7 @@ case "$target_name" in ;; m68k) bflt=3D"yes" - gdb_xml_files=3D"cf-core.xml cf-fp.xml m68k-fp.xml" + gdb_xml_files=3D"cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml" TARGET_SYSTBL_ABI=3Dcommon ;; microblaze|microblazeel) diff --git a/gdb-xml/m68k-core.xml b/gdb-xml/m68k-core.xml new file mode 100644 index 0000000..5b092d2 --- /dev/null +++ b/gdb-xml/m68k-core.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 9445fcd..72c5451 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -292,16 +292,38 @@ static void m68k_cpu_class_init(ObjectClass *c, void = *data) cc->tcg_initialize =3D m68k_tcg_init; =20 cc->gdb_num_core_regs =3D 18; - cc->gdb_core_xml_file =3D "cf-core.xml"; =20 dc->vmsd =3D &vmstate_m68k_cpu; } =20 -#define DEFINE_M68K_CPU_TYPE(cpu_model, initfn) \ - { \ - .name =3D M68K_CPU_TYPE_NAME(cpu_model), \ - .instance_init =3D initfn, \ - .parent =3D TYPE_M68K_CPU, \ +static void m68k_cpu_class_init_cf_core(ObjectClass *c, void *data) +{ + CPUClass *cc =3D CPU_CLASS(c); + + cc->gdb_core_xml_file =3D "cf-core.xml"; +} + +#define DEFINE_M68K_CPU_TYPE_CF(model) \ + { \ + .name =3D M68K_CPU_TYPE_NAME(#model), \ + .instance_init =3D model##_cpu_initfn, \ + .parent =3D TYPE_M68K_CPU, \ + .class_init =3D m68k_cpu_class_init_cf_core \ + } + +static void m68k_cpu_class_init_m68k_core(ObjectClass *c, void *data) +{ + CPUClass *cc =3D CPU_CLASS(c); + + cc->gdb_core_xml_file =3D "m68k-core.xml"; +} + +#define DEFINE_M68K_CPU_TYPE_M68K(model) \ + { \ + .name =3D M68K_CPU_TYPE_NAME(#model), \ + .instance_init =3D model##_cpu_initfn, \ + .parent =3D TYPE_M68K_CPU, \ + .class_init =3D m68k_cpu_class_init_m68k_core \ } =20 static const TypeInfo m68k_cpus_type_infos[] =3D { @@ -314,15 +336,15 @@ static const TypeInfo m68k_cpus_type_infos[] =3D { .class_size =3D sizeof(M68kCPUClass), .class_init =3D m68k_cpu_class_init, }, - DEFINE_M68K_CPU_TYPE("m68000", m68000_cpu_initfn), - DEFINE_M68K_CPU_TYPE("m68020", m68020_cpu_initfn), - DEFINE_M68K_CPU_TYPE("m68030", m68030_cpu_initfn), - DEFINE_M68K_CPU_TYPE("m68040", m68040_cpu_initfn), - DEFINE_M68K_CPU_TYPE("m68060", m68060_cpu_initfn), - DEFINE_M68K_CPU_TYPE("m5206", m5206_cpu_initfn), - DEFINE_M68K_CPU_TYPE("m5208", m5208_cpu_initfn), - DEFINE_M68K_CPU_TYPE("cfv4e", cfv4e_cpu_initfn), - DEFINE_M68K_CPU_TYPE("any", any_cpu_initfn), + DEFINE_M68K_CPU_TYPE_M68K(m68000), + DEFINE_M68K_CPU_TYPE_M68K(m68020), + DEFINE_M68K_CPU_TYPE_M68K(m68030), + DEFINE_M68K_CPU_TYPE_M68K(m68040), + DEFINE_M68K_CPU_TYPE_M68K(m68060), + DEFINE_M68K_CPU_TYPE_CF(m5206), + DEFINE_M68K_CPU_TYPE_CF(m5208), + DEFINE_M68K_CPU_TYPE_CF(cfv4e), + DEFINE_M68K_CPU_TYPE_CF(any), }; =20 DEFINE_TYPES(m68k_cpus_type_infos) --=20 1.8.3.1