From nobody Thu Sep 19 01:49:51 2024 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; dkim=fail; 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549272463721475.244190336075; Mon, 4 Feb 2019 01:27:43 -0800 (PST) Received: from localhost ([127.0.0.1]:39319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqaXR-0004xo-If for importer@patchew.org; Mon, 04 Feb 2019 04:27:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqa9V-0001FB-OO for qemu-devel@nongnu.org; Mon, 04 Feb 2019 04:02:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqa9N-0000H7-IY for qemu-devel@nongnu.org; Mon, 04 Feb 2019 04:02:47 -0500 Received: from ozlabs.org ([203.11.71.1]:48981) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqa9F-0007t7-FD; Mon, 04 Feb 2019 04:02:39 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 43tMCB4414z9sPj; Mon, 4 Feb 2019 20:01:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1549270902; bh=aQ9tmLis09qtLwYEzFHs7bgRStjXpNdn0SsBR09fn3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EExBZLYSgQ4ujfPZHa8C1tCLVkIsq0Dkj2imcSo1yxEejp4mWwpvOBLDIo5nnOKJk 2wi0U1E35A3pCJwtWI/HJSLK3/wyB1DjrQDOkv9J4/yqi0mboCxuF3JFitLH0stVj2 ONhbCWpBOD6yS3AeELfLp3RVGium7tmlZ5/5blnc= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 4 Feb 2019 20:01:19 +1100 Message-Id: <20190204090124.26191-33-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204090124.26191-1-david@gibson.dropbear.id.au> References: <20190204090124.26191-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 32/37] 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: , Cc: lvivier@redhat.com, Richard Henderson , Mark Cave-Ayland , qemu-devel@nongnu.org, groug@kaod.org, spopovyc@redhat.com, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland 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 Signed-off-by: David Gibson --- 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 ffc9cbc4ed..916d10c25b 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -3306,8 +3306,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; @@ -3317,32 +3315,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; @@ -3352,30 +3346,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.20.1