From nobody Sat May 4 11:00:46 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=1594066047; cv=none; d=zohomail.com; s=zohoarc; b=jYSJncMB+csD5ndhmZhLVjZc4WjlYW0MpecZS2BU+RUT4Pg0GYcZ52Dbd5Zj3613cemAVzwNAp3SX3jZaqKf8Lm9WbqupkNWnUCz5gKaHVCsFV5MFKLhhgJVHzrh79OhfsWTcN+N6a2mzwi7Dcu4pFMVQXKwRV9I331Dxgq2TCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594066047; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UyszGmR4tqIrsbGGoaDXWWKokaZe2oJJkXp9Uw1e+zE=; b=Mdr2/YcYahJ5eKiiQp3uP7tjGD3ON2TFpvnUkP8rainMQaImeWErpYuI7v2zXSYxEXR9nDunNDre6B17I1OCe8OFByzB6iC50Rv7nVekZm9bdGnMmZNco/rK7+FejjP8SAFim6L4zdzeS9/E8JS2PdmrutWuXPEf39dm/nI7eqo= 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 1594066047321287.1246702220616; Mon, 6 Jul 2020 13:07:27 -0700 (PDT) Received: from localhost ([::1]:57334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsXOf-0003Ga-Vo for importer@patchew.org; Mon, 06 Jul 2020 16:07:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsXNe-0001c3-OV for qemu-devel@nongnu.org; Mon, 06 Jul 2020 16:06:22 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:53427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsXNc-0004sq-Dy for qemu-devel@nongnu.org; Mon, 06 Jul 2020 16:06:22 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MsI4Q-1kkvVm0EIs-00thKT; Mon, 06 Jul 2020 22:06:04 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 1/3] target/m68k: fix physical address translation in m68k_cpu_get_phys_page_debug() Date: Mon, 6 Jul 2020 22:05:57 +0200 Message-Id: <20200706200559.160209-2-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200706200559.160209-1-laurent@vivier.eu> References: <20200706200559.160209-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:cKeJsdyi0MwlEnEzFBeJKdeh6bhOx7DNo8NUVe7tPVWhxaXPVAA ZOpevYKNDAItU8uOSKc1+bJFv9Le75ay0Y8auuSja9+HWjBxEbNdGpEgFXRUO7Rcg7n4LNa 5PswsWwcxFFYT00hf0cfPgJhmkQmW4HbnxQNKt6glGvkGxmZpiCIcMuC8XJbbaJXYBCuuVu IPajnI6sTjsjEwlEU6PGQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:cNZt1kfyLoo=:JFZLyMm/iFn47s+QxZKSHw BgFmGNZHgXUqQg4WEJ0T/ZE6ydeWlo+cAC4/vQcWGw6Cf5gu5ghTxoD2TJVjWyL53DrP/ikmJ 0K0obObZE5uF2idT58f3bM1Q59WvWYcU3a2iB7UvChBWIEc5T/j6v70YVDRQ+5EEKN5tCsxmC vGmZARYugVhDSrqdBWEF+CS4VHrNL5FehFhe9XEZQMLCPR6yyDzv5oQFAPNDn9xZqwdr9Dal4 7g3ABCGb1zXrzk7vF3kz3ipIkaC0Y0Fkc6U8gIzel9UVptwOXZttqrdtfTZAgudDniQmsC7iG Y+HmbB49XUV482y1DlUtgEuLXyKcc6YspMDQhAEVEq9ffQEme5AhctXt5Dv/aufygjSLuB3dP OZoT81Pz+64ciyFf7GAdfyEPg+FQqaNfrOK7l2Bo8GKvn+1fVqZ8ttYr9KZKVcmCh8ZRXWAXB wm5kcD32uMHDDP40D4YSDrQPAkwajd3VR6tJ23X0jpY2+jXWkMjuAer4Br2r/oGgHMzV1dkX4 lg+zuQxfkPLbiMKVhGwmE6O2Np1nekvRunnjOdc9ju9bk0tSONkDH3SksatX8Q20ZQxZaiWHP 99/LItbrtHKiwy8U0pXhzzzrsnxLpmrD/EcvsMObW9P669pOacrQq+7dwd9iYZPSIOhMDRnWb t6joT6kB0Gqv05IrkgH0EjsXMPKZzIWcV4/eLMGMh3M8blkpm5AhmdKk6fak2Bit674NEXOeb 5ykwHYE/YVTuWPRr7WW8hMmnW1Wo4Siz0Rwmt8zh5+Xo2Pa5Ag0A8HjOM3+pI1QWUcJKO42Oe JsOYio7jn+IyRMMtGqZCkLSyAnhMREkMZlIqgKxkGfMpKuzZNL8acBo9MtMB3FvP+Ao/c34 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: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 15:30:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Mark Cave-Ayland , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland The result of the get_physical_address() function should be combined with t= he offset of the original page access before being returned. Otherwise the m68k_cpu_get_phys_page_debug() function can round to the wrong page causing incorrect lookups in gdbstub and various "Disassembler disagrees with translator over instruction decoding" warnings to appear at translation tim= e. Fixes: 88b2fef6c3 ("target/m68k: add MC68040 MMU") Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier Message-Id: <20200701201531.13828-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 79b0b10ea9bc..631eab777494 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -820,10 +820,14 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vad= dr addr) if (env->sr & SR_S) { access_type |=3D ACCESS_SUPER; } + if (get_physical_address(env, &phys_addr, &prot, addr, access_type, &page_size) !=3D 0) { return -1; } + + addr &=3D TARGET_PAGE_MASK; + phys_addr +=3D addr & (page_size - 1); return phys_addr; } =20 --=20 2.26.2 From nobody Sat May 4 11:00:46 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=1594066076; cv=none; d=zohomail.com; s=zohoarc; b=SN0tHgZSU1hqYxB2AGBtuG4M73n84txYqNGTiplM3DCQrM0YXZIT1CMpmnHFIwrr53Rf2vmoziaky6357UjIdvNHARbvLqxIJH93Da59iLojyA1vDX0bBGL1NIAQCCOK9lJyd3Dx9jPlqtXD2/hKQB03DaHyAjGot5dAGqgUDSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594066076; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I9P7S9X0WES40sIneZu3ZhQUCJhr5rxalUdEv3w8ADk=; b=SH1r6WC6isyCYIanPot+BV4/Wgx08KIRmirFWIWnqNWiQH2xg+Yfxbl5Ev1B+e5YBLDRGirzUgyNPoRpXwLBnavHZXV0W6RPNM2PB2srR2W7dLNs557oxxnz+xL0PTLr8WsxOWUxG9OMD9xPdUL0SWBLJPRuIVhNRwgRtxUe4lI= 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 1594066076160184.82163502277865; Mon, 6 Jul 2020 13:07:56 -0700 (PDT) Received: from localhost ([::1]:60540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsXP8-0004cA-1a for importer@patchew.org; Mon, 06 Jul 2020 16:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsXNf-0001cV-Ge for qemu-devel@nongnu.org; Mon, 06 Jul 2020 16:06:23 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:44951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsXNd-0004sz-Fy for qemu-devel@nongnu.org; Mon, 06 Jul 2020 16:06:23 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MirSu-1kX6vQ3PLo-00evKx; Mon, 06 Jul 2020 22:06:05 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/3] target/m68k: consolidate physical translation offset into get_physical_address() Date: Mon, 6 Jul 2020 22:05:58 +0200 Message-Id: <20200706200559.160209-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200706200559.160209-1-laurent@vivier.eu> References: <20200706200559.160209-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:6ByfCQdS36HnRHicBYjzL4lbMjnxZSZ4ub5HbgTD6hI+ZAOAReI A1EG33JFp3hN7BIzVZR5RqT3iiI+ZhzCQP1yZqcWi7OabOkb2yPXUQ71Jjbc5uGFP2ZvyJj ePwjlbBzxMJ88sXHzIMl+059ERuHVe9/AVOEkZCM6qGMd7E3idsSxao6M1yvo/044rXjPvk +pwmoNQRGU87NWww9T6vg== X-UI-Out-Filterresults: notjunk:1;V03:K0:sspCEf3us1c=:RKzRNrR17UetWFa+R4STeM RZ2YVBe4ITGFzrQzjo+F3Kd63OtBoK7K5cbknfKvrWyYLrzJQSTDpB0UpSAD448rgV2CWPGJy kb593GwOrNLAS5AyrPlcdpoa1Pml83ZC5lMA2xr3I/r2IpVmnq+++JibGS1vWQyJCtLw6DQrx B9d0LmnVkSz0EP7pC0tVKwyJ23MI91hcrpGCD1FocRk7c0y7kFSIaInWI9NTkF+sP8OO7KqgJ 0+1TQlzCUqq9YDTWIzIbA+lxyrE9Gbpcz44HNOL6sKj7LZig8A9v0CC7d7sZucSWzUhskEyh6 nBdpsMXN3aOWIrQunqxvnedCCphBDQ8TusBKAESKY6Yc50YRoDGP5mWbVa8C52Uc+WsCMiK3D iYn0uszYebyYxbpJjYOJsGFkRiCmZjQ8P/69P+DVGt1fI6ttmjH3VwRJwO0g/kyM8Ipfmevt+ Delt5Z8rQ9nZS0ou0N5tmiUIzfKm6Z4tOrBWu4s/RroaoV1BoE3KC/dGzV92Mj4PRDZ9H2ojw gP5cqroNNTAbYWU/C4uuaLQuiFoYtoQgRqT+yS/ESpavXcn/Kc8nij4NNQmbGS5oz0CT8pp63 nL7fG+kq20fWltupojZF6ZC/+qNeVY9p6Rytp1DNO+6LOMcNCU5lQIP3rUNga5jLLce8xaj0m IQVhOr74X4CLWLAcR09+yvR1+Ql+7Y03jJrTr1zYLiVzesgQ6ES2XV2CkMrAEn9UYb0NA+q3j T6R+56IaVBPKgH/ODAQTKduciLxz9BrsVMVxnEa4Lr4c/DM9ImQHfxZETozjSkNx5ksgfi1wz JTDpzU7Z5Fc8EoZ5g2Xgbp2juB2pM1ndXlEflKD2iTmh7SPamx/+4zZ0oZBrCe9peNbjKFq 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: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 16:06:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Mark Cave-Ayland , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Since all callers to get_physical_address() now apply the same page offset = to the translation result, move the logic into get_physical_address() itself to avoid duplication. Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20200701201531.13828-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/helper.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 631eab777494..3ff57657958c 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -643,7 +643,7 @@ static int get_physical_address(CPUM68KState *env, hwad= dr *physical, /* Transparent Translation Register bit */ env->mmu.mmusr =3D M68K_MMU_T_040 | M68K_MMU_R_040; } - *physical =3D address & TARGET_PAGE_MASK; + *physical =3D address; *page_size =3D TARGET_PAGE_SIZE; return 0; } @@ -771,7 +771,7 @@ static int get_physical_address(CPUM68KState *env, hwad= dr *physical, } *page_size =3D 1 << page_bits; page_mask =3D ~(*page_size - 1); - *physical =3D next & page_mask; + *physical =3D (next & page_mask) + (address & (*page_size - 1)); =20 if (access_type & ACCESS_PTEST) { env->mmu.mmusr |=3D next & M68K_MMU_SR_MASK_040; @@ -826,8 +826,6 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr= addr) return -1; } =20 - addr &=3D TARGET_PAGE_MASK; - phys_addr +=3D addr & (page_size - 1); return phys_addr; } =20 @@ -891,10 +889,8 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, in= t size, ret =3D get_physical_address(&cpu->env, &physical, &prot, address, access_type, &page_size); if (likely(ret =3D=3D 0)) { - address &=3D TARGET_PAGE_MASK; - physical +=3D address & (page_size - 1); - tlb_set_page(cs, address, physical, - prot, mmu_idx, TARGET_PAGE_SIZE); + tlb_set_page(cs, address & TARGET_PAGE_MASK, + physical & TARGET_PAGE_MASK, prot, mmu_idx, page_size= ); return true; } =20 @@ -1383,9 +1379,8 @@ void HELPER(ptest)(CPUM68KState *env, uint32_t addr, = uint32_t is_read) ret =3D get_physical_address(env, &physical, &prot, addr, access_type, &page_size); if (ret =3D=3D 0) { - addr &=3D TARGET_PAGE_MASK; - physical +=3D addr & (page_size - 1); - tlb_set_page(env_cpu(env), addr, physical, + tlb_set_page(env_cpu(env), addr & TARGET_PAGE_MASK, + physical & TARGET_PAGE_MASK, prot, access_type & ACCESS_SUPER ? MMU_KERNEL_IDX : MMU_USER_IDX, page_size); } --=20 2.26.2 From nobody Sat May 4 11:00:46 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=1594066048; cv=none; d=zohomail.com; s=zohoarc; b=SF3R0vcjbLUPQ7lDT2qCZ73FuQKcWfd3C7Wen7KCufKDtOGhPe/z55JaBPAvHVmY3RwG6SrTNBmr+8qwmqrDDFjnGtE104FRA2VnhUnlPhy1jtH/V4RLyNp0WstHQTycdIODRD+6xtBxTSSMff02bM4on3Kc4fkMo0FJ68B9s9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594066048; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f11zOwSjp1DnFWM+EmiOPfQ2Y9trTw+nJfzHiynPXOw=; b=Ihfwi26muaRGCFkY/ErN2q0N/gml8qNk17deqDgIB9Vo57atKVpbidmt6Jd7LM2cCGBh/PISBRkmWDneOOcSau/oRXFUX0XMnwzKByssRuimm/BvkZiHG/Uxl+nSeGpEi1y3Izk9i7FKkh0bVKLJ1xdnXVJ3s2sVo97UMZsx570= 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 1594066048360156.5859064072714; Mon, 6 Jul 2020 13:07:28 -0700 (PDT) Received: from localhost ([::1]:57420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsXOg-0003IV-Th for importer@patchew.org; Mon, 06 Jul 2020 16:07:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsXNe-0001bj-4C for qemu-devel@nongnu.org; Mon, 06 Jul 2020 16:06:22 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:44911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsXNc-0004sn-DS for qemu-devel@nongnu.org; Mon, 06 Jul 2020 16:06:21 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mrh9Y-1kfwc51uWS-00nl1b; Mon, 06 Jul 2020 22:06:05 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 3/3] softfloat, m68k: disable floatx80_invalid_encoding() for m68k Date: Mon, 6 Jul 2020 22:05:59 +0200 Message-Id: <20200706200559.160209-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200706200559.160209-1-laurent@vivier.eu> References: <20200706200559.160209-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:hQ7+V73jS8osY4BZP51pZsm/CritqkcXleC1/1o3Xwq5vssvZZX 6/hO8faAlvKOQXTvOx4+1R4p0xypYk3Rz/6gySKrueYVbexmw4Du2SNeGH8WBiscCmeBU1p JlGGFpmV+E8SRJ5Ivf9UjfQWr1ZgLOglD7+V69CiwIDFxKtPhVRz2cQger6KU6dxkZKZgmS 6fHXr7FFTC4j9Uv/AMCYQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:jRjAnRCLjns=:6Z4QqL4mMD9xrLJOumVLo4 kyOmk2oRI2HZQcdHVg3qmsgLaJzzc5HBM5oZO3IgGWMYHIka/HmpgUxOglxwnso4yWutNuFYh RqGUhm0CPJtt2ncWpccAShHyd5hgPEFWSQWoye+g4jWvI821melSNrcsOFWr1xsIaWLPNCUzX VbnIyntCME3Dmab7J8qNaV5i5UPcXAV6pmVWtoL9MlKZH92AutC3VP3p01rCftaZrRKgVv+zR hANv23a+LWTvc15kOD0S3xlwdOCWT0W3Ktjqfv2PT0uD6bTToT+0DD8dtm5e4ITo76JAoI8Zj F1pFJLtykpudry8fPiqWYSnwsYmfnGeAxem9VmBcPd7twPxdYEt8nAqHrwtQTVdWyVufFtNhy FcO+6DQ0HNm/6xcvoIiyLJAudLcwHt+Y3AyN5pbTI5dLz5YemtKWFmVkKnmlqh/aCYM+FdbdY yVpsvNANIaJTj7waV1MNW+4BFo7bqnvFrDd1y3DGx57IMw4xX9yCNnBXRcFNBnrG0rSQ+PajC SKafVBAeq4sAzf7YDFQTD+frQe/RJ41t/ZSbMD8Nr+64mpyiIM3Tz5joNBRgTognWXc/UpAKF ZVJ1hOQm8Q1USZdpYsF4LHNYB7mbVDsXIQwYPwXRhqVnY3xHyOVl0MADctwPAp8vRWDS5Z4iV LCIfdJRBQE9rKXXMOAX62O+nrlyVW0aOT97qREXt3HNlBdLkHOS/TA09LDMWl5dlgk5+8d7xd wHQPVG40QfbwsQ8jI2SnFsCainFc+OddaJTZd5vakoQXso8xjFjqicX7Usp4ZSuGS9OskaPQM /4zY0ljmioNwaCJP0J9bylsvV/hgZP7EIR2NQhxiodzxsPZ+X9EgULuhYTUExWJURnbZfHV 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: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 15:40:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" According to the comment, this definition of invalid encoding is given by intel developer's manual, and doesn't comply with 680x0 FPU. With m68k, the explicit integer bit can be zero in the case of: - zeros (exp =3D=3D 0, mantissa =3D=3D 0) - denormalized numbers (exp =3D=3D 0, mantissa !=3D 0) - unnormalized numbers (exp !=3D 0, exp < 0x7FFF) - infinities (exp =3D=3D 0x7FFF, mantissa =3D=3D 0) - not-a-numbers (exp =3D=3D 0x7FFF, mantissa !=3D 0) For infinities and NaNs, the explicit integer bit can be either one or zero. The IEEE 754 standard does not define a zero integer bit. Such a number is an unnormalized number. Hardware does not directly support denormalized and unnormalized numbers, but implicitly supports them by trapping them as unimplemented data types, allowing efficient conversion in software. See "M68000 FAMILY PROGRAMMER=E2=80=99S REFERENCE MANUAL", "1.6 FLOATING-POINT DATA TYPES" We will implement in the m68k TCG emulator the FP_UNIMP exception to trap into the kernel to normalize the number. In case of linux-user, the number will be normalized by QEMU. Signed-off-by: Laurent Vivier Reviewed-by: Alex Benn=C3=A9e Message-Id: <20200612140400.2130118-1-laurent@vivier.eu> --- include/fpu/softfloat.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index ff4e2605b16d..f1a19df066b7 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -794,7 +794,31 @@ static inline bool floatx80_unordered_quiet(floatx80 a= , floatx80 b, *-------------------------------------------------------------------------= ---*/ static inline bool floatx80_invalid_encoding(floatx80 a) { +#if defined(TARGET_M68K) + /*--------------------------------------------------------------------= ----- + | With m68k, the explicit integer bit can be zero in the case of: + | - zeros (exp =3D=3D 0, mantissa =3D=3D 0) + | - denormalized numbers (exp =3D=3D 0, mantissa !=3D 0) + | - unnormalized numbers (exp !=3D 0, exp < 0x7FFF) + | - infinities (exp =3D=3D 0x7FFF, mantissa =3D=3D 0) + | - not-a-numbers (exp =3D=3D 0x7FFF, mantissa !=3D 0) + | + | For infinities and NaNs, the explicit integer bit can be either one = or + | zero. + | + | The IEEE 754 standard does not define a zero integer bit. Such a num= ber + | is an unnormalized number. Hardware does not directly support + | denormalized and unnormalized numbers, but implicitly supports them = by + | trapping them as unimplemented data types, allowing efficient conver= sion + | in software. + | + | See "M68000 FAMILY PROGRAMMER=E2=80=99S REFERENCE MANUAL", + | "1.6 FLOATING-POINT DATA TYPES" + *---------------------------------------------------------------------= ---*/ + return false; +#else return (a.low & (1ULL << 63)) =3D=3D 0 && (a.high & 0x7FFF) !=3D 0; +#endif } =20 #define floatx80_zero make_floatx80(0x0000, 0x0000000000000000LL) --=20 2.26.2