]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
memcheck: Allow unaligned loads of words on ppc64[le].
authorMark Wielaard <mark@klomp.org>
Sat, 8 Dec 2018 18:47:43 +0000 (13:47 -0500)
committerMark Wielaard <mark@klomp.org>
Thu, 20 Dec 2018 21:46:59 +0000 (22:46 +0100)
On powerpc partial unaligned loads of words from partially invalid
addresses are OK and could be generated by our translation of ldbrx.

Adjust partial_load memcheck tests to allow partial loads of words
on powerpc64.

Part of resolving bug #386945.

memcheck/mc_main.c
memcheck/tests/Makefile.am
memcheck/tests/partial_load.c
memcheck/tests/partial_load_dflt.stderr.exp-ppc64 [new file with mode: 0644]
memcheck/tests/partial_load_ok.stderr.exp-ppc64 [new file with mode: 0644]

index 3ef7cb913803b2e165faf3f405dea24dd19052fd..737f79d76a1a6f46c5db529392f9a84f41479d82 100644 (file)
@@ -1508,6 +1508,9 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian )
 #  if defined(VGA_mips64) && defined(VGABI_N32)
    if (szB == VG_WORDSIZE * 2 && VG_IS_WORD_ALIGNED(a)
        && n_addrs_bad < VG_WORDSIZE * 2)
+#  elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
+   /* On power unaligned loads of words are OK. */
+   if (szB == VG_WORDSIZE && n_addrs_bad < VG_WORDSIZE)
 #  else
    if (szB == VG_WORDSIZE && VG_IS_WORD_ALIGNED(a)
        && n_addrs_bad < VG_WORDSIZE)
index 2af4dd185aa33209a20a0a13d88b03352b726166..70b8adaf6575ccd5656aae845345a027d5ba068a 100644 (file)
@@ -235,8 +235,10 @@ EXTRA_DIST = \
        partiallydefinedeq.stdout.exp \
        partial_load_ok.vgtest partial_load_ok.stderr.exp \
                partial_load_ok.stderr.exp64 \
+               partial_load_ok.stderr.exp-ppc64 \
        partial_load_dflt.vgtest partial_load_dflt.stderr.exp \
                partial_load_dflt.stderr.exp64 \
+               partial_load_dflt.stderr.exp-ppc64 \
        partial_load_dflt.stderr.expr-s390x-mvc \
        pdb-realloc.stderr.exp pdb-realloc.vgtest \
        pdb-realloc2.stderr.exp pdb-realloc2.stdout.exp pdb-realloc2.vgtest \
index 0b2f10b6f4963323b5529fd66d2e4ef3127169e2..685ca8d23e8a5d0577d34220d644abc171f95930 100644 (file)
@@ -1,14 +1,14 @@
-
+#include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
 
 int main ( void )
 {
-  long  w;
-  int   i;
-  char* p;
-
+  long  w; int   i; char* p;
   assert(sizeof(long) == sizeof(void*));
+#if defined(__powerpc64__)
+  fprintf (stderr, "powerpc64\n"); /* Used to select correct .exp file.  */
+#endif
 
   /* partial load, which --partial-loads-ok=yes should suppress */
   p = calloc( sizeof(long)-1, 1 );
@@ -16,7 +16,7 @@ int main ( void )
   w = *(long*)p;
   free(p);
 
-  /* partial but misaligned, cannot be suppressed */
+  /* partial but misaligned, ppc64[le] ok, but otherwise cannot be suppressed */
   p = calloc( sizeof(long), 1 );
   assert(p);
   p++;
diff --git a/memcheck/tests/partial_load_dflt.stderr.exp-ppc64 b/memcheck/tests/partial_load_dflt.stderr.exp-ppc64
new file mode 100644 (file)
index 0000000..cf32bcf
--- /dev/null
@@ -0,0 +1,23 @@
+
+powerpc64
+Invalid read of size 2
+   at 0x........: main (partial_load.c:30)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+   at 0x........: calloc (vg_replace_malloc.c:...)
+   by 0x........: main (partial_load.c:28)
+
+Invalid read of size 8
+   at 0x........: main (partial_load.c:37)
+ Address 0x........ is 0 bytes inside a block of size 8 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: main (partial_load.c:36)
+
+
+HEAP SUMMARY:
+    in use at exit: ... bytes in ... blocks
+  total heap usage: ... allocs, ... frees, ... bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+For counts of detected and suppressed errors, rerun with: -v
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/partial_load_ok.stderr.exp-ppc64 b/memcheck/tests/partial_load_ok.stderr.exp-ppc64
new file mode 100644 (file)
index 0000000..cf32bcf
--- /dev/null
@@ -0,0 +1,23 @@
+
+powerpc64
+Invalid read of size 2
+   at 0x........: main (partial_load.c:30)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+   at 0x........: calloc (vg_replace_malloc.c:...)
+   by 0x........: main (partial_load.c:28)
+
+Invalid read of size 8
+   at 0x........: main (partial_load.c:37)
+ Address 0x........ is 0 bytes inside a block of size 8 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: main (partial_load.c:36)
+
+
+HEAP SUMMARY:
+    in use at exit: ... bytes in ... blocks
+  total heap usage: ... allocs, ... frees, ... bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+For counts of detected and suppressed errors, rerun with: -v
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)