All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org,
	clg@kaod.org, lvivier@redhat.com, spopovyc@redhat.com,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Richard Henderson <richard.henderson@linaro.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 32/37] target/ppc: remove ROTRu32 and ROTRu64 macros from int_helper.c
Date: Mon,  4 Feb 2019 20:01:19 +1100	[thread overview]
Message-ID: <20190204090124.26191-33-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20190204090124.26191-1-david@gibson.dropbear.id.au>

From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Richard points out that these macros suffer from a -fsanitize=shift bug in that
they improperly handle n == 0 turning it into a shift by 32/64 respectively.
Replace them with QEMU's existing ror32() and ror64() functions instead.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 = result;
 }
 
-#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 = (st_six & 0x10) != 0;
@@ -3317,32 +3315,28 @@ void helper_vshasigmaw(ppc_avr_t *r,  ppc_avr_t *a, uint32_t st_six)
     for (i = 0; i < ARRAY_SIZE(r->u32); i++) {
         if (st == 0) {
             if ((six & (0x8 >> i)) == 0) {
-                r->VsrW(i) = ROTRu32(a->VsrW(i), 7) ^
-                             ROTRu32(a->VsrW(i), 18) ^
+                r->VsrW(i) = ror32(a->VsrW(i), 7) ^
+                             ror32(a->VsrW(i), 18) ^
                              (a->VsrW(i) >> 3);
             } else { /* six.bit[i] == 1 */
-                r->VsrW(i) = ROTRu32(a->VsrW(i), 17) ^
-                             ROTRu32(a->VsrW(i), 19) ^
+                r->VsrW(i) = ror32(a->VsrW(i), 17) ^
+                             ror32(a->VsrW(i), 19) ^
                              (a->VsrW(i) >> 10);
             }
         } else { /* st == 1 */
             if ((six & (0x8 >> i)) == 0) {
-                r->VsrW(i) = ROTRu32(a->VsrW(i), 2) ^
-                             ROTRu32(a->VsrW(i), 13) ^
-                             ROTRu32(a->VsrW(i), 22);
+                r->VsrW(i) = ror32(a->VsrW(i), 2) ^
+                             ror32(a->VsrW(i), 13) ^
+                             ror32(a->VsrW(i), 22);
             } else { /* six.bit[i] == 1 */
-                r->VsrW(i) = ROTRu32(a->VsrW(i), 6) ^
-                             ROTRu32(a->VsrW(i), 11) ^
-                             ROTRu32(a->VsrW(i), 25);
+                r->VsrW(i) = ror32(a->VsrW(i), 6) ^
+                             ror32(a->VsrW(i), 11) ^
+                             ror32(a->VsrW(i), 25);
             }
         }
     }
 }
 
-#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 = (st_six & 0x10) != 0;
@@ -3352,30 +3346,28 @@ void helper_vshasigmad(ppc_avr_t *r,  ppc_avr_t *a, uint32_t st_six)
     for (i = 0; i < ARRAY_SIZE(r->u64); i++) {
         if (st == 0) {
             if ((six & (0x8 >> (2*i))) == 0) {
-                r->VsrD(i) = ROTRu64(a->VsrD(i), 1) ^
-                             ROTRu64(a->VsrD(i), 8) ^
+                r->VsrD(i) = ror64(a->VsrD(i), 1) ^
+                             ror64(a->VsrD(i), 8) ^
                              (a->VsrD(i) >> 7);
             } else { /* six.bit[2*i] == 1 */
-                r->VsrD(i) = ROTRu64(a->VsrD(i), 19) ^
-                             ROTRu64(a->VsrD(i), 61) ^
+                r->VsrD(i) = ror64(a->VsrD(i), 19) ^
+                             ror64(a->VsrD(i), 61) ^
                              (a->VsrD(i) >> 6);
             }
         } else { /* st == 1 */
             if ((six & (0x8 >> (2*i))) == 0) {
-                r->VsrD(i) = ROTRu64(a->VsrD(i), 28) ^
-                             ROTRu64(a->VsrD(i), 34) ^
-                             ROTRu64(a->VsrD(i), 39);
+                r->VsrD(i) = ror64(a->VsrD(i), 28) ^
+                             ror64(a->VsrD(i), 34) ^
+                             ror64(a->VsrD(i), 39);
             } else { /* six.bit[2*i] == 1 */
-                r->VsrD(i) = ROTRu64(a->VsrD(i), 14) ^
-                             ROTRu64(a->VsrD(i), 18) ^
-                             ROTRu64(a->VsrD(i), 41);
+                r->VsrD(i) = ror64(a->VsrD(i), 14) ^
+                             ror64(a->VsrD(i), 18) ^
+                             ror64(a->VsrD(i), 41);
             }
         }
     }
 }
 
-#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;
-- 
2.20.1

  parent reply	other threads:[~2019-02-04  9:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04  9:00 [Qemu-devel] [PULL 00/37] ppc-for-4.0 queue 20190204 David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 01/37] pseries: Update SLOF firmware image David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 02/37] smbus: Add a helper to generate SPD EEPROM data David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 03/37] sam460ex: Clean up SPD EEPROM creation David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 04/37] ppc4xx: Use ram_addr_t in ppc4xx_sdram_adjust() David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 05/37] ppc4xx: Rename ppc4xx_sdram_t in ppc440_uc.c to ppc440_sdram_t David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 06/37] ppc4xx: Pass array index to function instead of pointer into the array David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 07/37] sam460ex: Fix support for memory larger than 1GB David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 08/37] ppc/xive: fix remaining XiveFabric names David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 09/37] target/ppc/kvm: Drop useless include directive David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 10/37] ppc440: Avoid reporting error when reading non-existent RAM slot David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 11/37] spapr/vio: remove the "irq" property" David Gibson
2019-02-04  9:00 ` [Qemu-devel] [PULL 12/37] hw/ppc/spapr: Encode the SCSI channel (bus) in the SRP LUNs David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 13/37] spapr: Forbid setting ic-mode for old machine types David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 14/37] spapr/pci: Fix primary bus number for PCI bridges David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 15/37] xive: add a get_tctx() method to the XiveRouter David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 16/37] ppc/pnv: introduce a CPU machine_data David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 17/37] spapr: move the interrupt presenters under machine_data David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 18/37] target/ppc: implement complete set of Vsr* macros David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 19/37] ppc: remove the interrupt presenters from under PowerPCCPU David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 20/37] hw/ppc: Move ppc40x_*reset() functions from ppc405_uc.c to ppc.c David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 21/37] MAINTAINERS: XIVE is an interrupt controller, not a machine David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 22/37] MAINTAINERS: Merge the two e500 sections David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 23/37] spapr: Drop unused parameters from fdt building helper David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 24/37] MAINTAINERS: add myself as maintainer for Mac Old World and New World machines David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 25/37] QemuMacDrivers: update qemu_vga.ndrv to 90c488d built from submodule David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 26/37] hw/ppc/spapr: Add support for "-vga cirrus" David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 27/37] target/ppc: rework vmrg{l, h}{b, h, w} instructions to use Vsr* macros David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 28/37] target/ppc: rework vmul{e, o}{s, u}{b, " David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 29/37] target/ppc: eliminate use of HI_IDX and LO_IDX macros from int_helper.c David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 30/37] target/ppc: eliminate use of EL_IDX " David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 31/37] target/ppc: simplify VEXT_SIGNED macro in int_helper.c David Gibson
2019-02-04  9:01 ` David Gibson [this message]
2019-02-04  9:01 ` [Qemu-devel] [PULL 33/37] target/ppc: remove various HOST_WORDS_BIGENDIAN hacks " David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 34/37] spapr_pci: Fix endianness in assigned-addresses property David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 35/37] hw/ppc: Don't include m48t59.h if it is not necessary David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 36/37] mmap-alloc: unfold qemu_ram_mmap() David Gibson
2019-02-04  9:01 ` [Qemu-devel] [PULL 37/37] mmap-alloc: fix hugetlbfs misaligned length in ppc64 David Gibson
2019-02-04 12:56 ` [Qemu-devel] [PULL 00/37] ppc-for-4.0 queue 20190204 Peter Maydell
2019-02-05 11:46   ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
2019-02-05 12:24     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190204090124.26191-33-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=spopovyc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.