From nobody Fri Nov 7 17:09:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 1548580301391453.83476524799164; Sun, 27 Jan 2019 01:11:41 -0800 (PST) Received: from localhost ([127.0.0.1]:42978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gngTc-0001ze-FT for importer@patchew.org; Sun, 27 Jan 2019 04:11:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gngLq-0004RH-UZ for qemu-devel@nongnu.org; Sun, 27 Jan 2019 04:03:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gngLo-0008Fm-SD for qemu-devel@nongnu.org; Sun, 27 Jan 2019 04:03:38 -0500 Received: from chuckie.co.uk ([82.165.15.123]:33146 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gngLm-0008BI-QA; Sun, 27 Jan 2019 04:03:34 -0500 Received: from host86-147-134-102.range86-147.btcentralplus.com ([86.147.134.102] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gngLv-0006xH-C8; Sun, 27 Jan 2019 09:03:44 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, richard.henderson@linaro.org, david@gibson.dropbear.id.au Date: Sun, 27 Jan 2019 09:03:05 +0000 Message-Id: <20190127090306.30826-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190127090306.30826-1-mark.cave-ayland@ilande.co.uk> References: <20190127090306.30826-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.147.134.102 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH v3 7/8] target/ppc: remove ROTRu32 and ROTRu64 macros from int_helper.c 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: , 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" Richard points out that these macros suffer from a -fsanitize=3Dshift bug i= n that they improperly handle n =3D=3D 0 turning it into a shift by 32/64 respecti= vely. Replace them with QEMU's existing ror32() and ror64() functions instead. Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- target/ppc/int_helper.c | 48 ++++++++++++++++++++-------------------------= --- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 39f6c96543..c3eba9ed41 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -3320,8 +3320,6 @@ void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, = ppc_avr_t *b) *r =3D result; } =20 -#define ROTRu32(v, n) (((v) >> (n)) | ((v) << (32 - n))) - void helper_vshasigmaw(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six) { int st =3D (st_six & 0x10) !=3D 0; @@ -3331,32 +3329,28 @@ void helper_vshasigmaw(ppc_avr_t *r, ppc_avr_t *a,= uint32_t st_six) for (i =3D 0; i < ARRAY_SIZE(r->u32); i++) { if (st =3D=3D 0) { if ((six & (0x8 >> i)) =3D=3D 0) { - r->VsrW(i) =3D ROTRu32(a->VsrW(i), 7) ^ - ROTRu32(a->VsrW(i), 18) ^ + r->VsrW(i) =3D ror32(a->VsrW(i), 7) ^ + ror32(a->VsrW(i), 18) ^ (a->VsrW(i) >> 3); } else { /* six.bit[i] =3D=3D 1 */ - r->VsrW(i) =3D ROTRu32(a->VsrW(i), 17) ^ - ROTRu32(a->VsrW(i), 19) ^ + r->VsrW(i) =3D ror32(a->VsrW(i), 17) ^ + ror32(a->VsrW(i), 19) ^ (a->VsrW(i) >> 10); } } else { /* st =3D=3D 1 */ if ((six & (0x8 >> i)) =3D=3D 0) { - r->VsrW(i) =3D ROTRu32(a->VsrW(i), 2) ^ - ROTRu32(a->VsrW(i), 13) ^ - ROTRu32(a->VsrW(i), 22); + r->VsrW(i) =3D ror32(a->VsrW(i), 2) ^ + ror32(a->VsrW(i), 13) ^ + ror32(a->VsrW(i), 22); } else { /* six.bit[i] =3D=3D 1 */ - r->VsrW(i) =3D ROTRu32(a->VsrW(i), 6) ^ - ROTRu32(a->VsrW(i), 11) ^ - ROTRu32(a->VsrW(i), 25); + r->VsrW(i) =3D ror32(a->VsrW(i), 6) ^ + ror32(a->VsrW(i), 11) ^ + ror32(a->VsrW(i), 25); } } } } =20 -#undef ROTRu32 - -#define ROTRu64(v, n) (((v) >> (n)) | ((v) << (64-n))) - void helper_vshasigmad(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six) { int st =3D (st_six & 0x10) !=3D 0; @@ -3366,30 +3360,28 @@ void helper_vshasigmad(ppc_avr_t *r, ppc_avr_t *a,= uint32_t st_six) for (i =3D 0; i < ARRAY_SIZE(r->u64); i++) { if (st =3D=3D 0) { if ((six & (0x8 >> (2*i))) =3D=3D 0) { - r->VsrD(i) =3D ROTRu64(a->VsrD(i), 1) ^ - ROTRu64(a->VsrD(i), 8) ^ + r->VsrD(i) =3D ror64(a->VsrD(i), 1) ^ + ror64(a->VsrD(i), 8) ^ (a->VsrD(i) >> 7); } else { /* six.bit[2*i] =3D=3D 1 */ - r->VsrD(i) =3D ROTRu64(a->VsrD(i), 19) ^ - ROTRu64(a->VsrD(i), 61) ^ + r->VsrD(i) =3D ror64(a->VsrD(i), 19) ^ + ror64(a->VsrD(i), 61) ^ (a->VsrD(i) >> 6); } } else { /* st =3D=3D 1 */ if ((six & (0x8 >> (2*i))) =3D=3D 0) { - r->VsrD(i) =3D ROTRu64(a->VsrD(i), 28) ^ - ROTRu64(a->VsrD(i), 34) ^ - ROTRu64(a->VsrD(i), 39); + r->VsrD(i) =3D ror64(a->VsrD(i), 28) ^ + ror64(a->VsrD(i), 34) ^ + ror64(a->VsrD(i), 39); } else { /* six.bit[2*i] =3D=3D 1 */ - r->VsrD(i) =3D ROTRu64(a->VsrD(i), 14) ^ - ROTRu64(a->VsrD(i), 18) ^ - ROTRu64(a->VsrD(i), 41); + r->VsrD(i) =3D ror64(a->VsrD(i), 14) ^ + ror64(a->VsrD(i), 18) ^ + ror64(a->VsrD(i), 41); } } } } =20 -#undef ROTRu64 - void helper_vpermxor(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t = *c) { ppc_avr_t result; --=20 2.11.0