4483169
commit c5a5bea00af75f6ac50da10967d956f117b956f1
4483169
Author: Mark Wielaard <mark@klomp.org>
4483169
Date:   Sat Dec 8 13:47:43 2018 -0500
4483169
4483169
    memcheck: Allow unaligned loads of words on ppc64[le].
4483169
    
4483169
    On powerpc partial unaligned loads of words from partially invalid
4483169
    addresses are OK and could be generated by our translation of ldbrx.
4483169
    
4483169
    Adjust partial_load memcheck tests to allow partial loads of words
4483169
    on powerpc64.
4483169
    
4483169
    Part of resolving bug #386945.
4483169
4483169
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
4483169
index 3ef7cb9..737f79d 100644
4483169
--- a/memcheck/mc_main.c
4483169
+++ b/memcheck/mc_main.c
4483169
@@ -1508,6 +1508,9 @@ ULong mc_LOADVn_slow ( Addr a, SizeT nBits, Bool bigendian )
4483169
 #  if defined(VGA_mips64) && defined(VGABI_N32)
4483169
    if (szB == VG_WORDSIZE * 2 && VG_IS_WORD_ALIGNED(a)
4483169
        && n_addrs_bad < VG_WORDSIZE * 2)
4483169
+#  elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
4483169
+   /* On power unaligned loads of words are OK. */
4483169
+   if (szB == VG_WORDSIZE && n_addrs_bad < VG_WORDSIZE)
4483169
 #  else
4483169
    if (szB == VG_WORDSIZE && VG_IS_WORD_ALIGNED(a)
4483169
        && n_addrs_bad < VG_WORDSIZE)
4483169
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
4483169
index 2af4dd1..70b8ada 100644
4483169
--- a/memcheck/tests/Makefile.am
4483169
+++ b/memcheck/tests/Makefile.am
4483169
@@ -235,8 +235,10 @@ EXTRA_DIST = \
4483169
 	partiallydefinedeq.stdout.exp \
4483169
 	partial_load_ok.vgtest partial_load_ok.stderr.exp \
4483169
 		partial_load_ok.stderr.exp64 \
4483169
+		partial_load_ok.stderr.exp-ppc64 \
4483169
 	partial_load_dflt.vgtest partial_load_dflt.stderr.exp \
4483169
 		partial_load_dflt.stderr.exp64 \
4483169
+		partial_load_dflt.stderr.exp-ppc64 \
4483169
 	partial_load_dflt.stderr.expr-s390x-mvc \
4483169
 	pdb-realloc.stderr.exp pdb-realloc.vgtest \
4483169
 	pdb-realloc2.stderr.exp pdb-realloc2.stdout.exp pdb-realloc2.vgtest \
4483169
diff --git a/memcheck/tests/partial_load.c b/memcheck/tests/partial_load.c
4483169
index 0b2f10b..685ca8d 100644
4483169
--- a/memcheck/tests/partial_load.c
4483169
+++ b/memcheck/tests/partial_load.c
4483169
@@ -1,14 +1,14 @@
4483169
-
4483169
+#include <stdio.h>
4483169
 #include <stdlib.h>
4483169
 #include <assert.h>
4483169
 
4483169
 int main ( void )
4483169
 {
4483169
-  long  w;
4483169
-  int   i;
4483169
-  char* p;
4483169
-
4483169
+  long  w; int   i; char* p;
4483169
   assert(sizeof(long) == sizeof(void*));
4483169
+#if defined(__powerpc64__)
4483169
+  fprintf (stderr, "powerpc64\n"); /* Used to select correct .exp file.  */
4483169
+#endif
4483169
 
4483169
   /* partial load, which --partial-loads-ok=yes should suppress */
4483169
   p = calloc( sizeof(long)-1, 1 );
4483169
@@ -16,7 +16,7 @@ int main ( void )
4483169
   w = *(long*)p;
4483169
   free(p);
4483169
 
4483169
-  /* partial but misaligned, cannot be suppressed */
4483169
+  /* partial but misaligned, ppc64[le] ok, but otherwise cannot be suppressed */
4483169
   p = calloc( sizeof(long), 1 );
4483169
   assert(p);
4483169
   p++;
4483169
diff --git a/memcheck/tests/partial_load_dflt.stderr.exp-ppc64 b/memcheck/tests/partial_load_dflt.stderr.exp-ppc64
4483169
new file mode 100644
4483169
index 0000000..cf32bcf
4483169
--- /dev/null
4483169
+++ b/memcheck/tests/partial_load_dflt.stderr.exp-ppc64
4483169
@@ -0,0 +1,23 @@
4483169
+
4483169
+powerpc64
4483169
+Invalid read of size 2
4483169
+   at 0x........: main (partial_load.c:30)
4483169
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
4483169
+   at 0x........: calloc (vg_replace_malloc.c:...)
4483169
+   by 0x........: main (partial_load.c:28)
4483169
+
4483169
+Invalid read of size 8
4483169
+   at 0x........: main (partial_load.c:37)
4483169
+ Address 0x........ is 0 bytes inside a block of size 8 free'd
4483169
+   at 0x........: free (vg_replace_malloc.c:...)
4483169
+   by 0x........: main (partial_load.c:36)
4483169
+
4483169
+
4483169
+HEAP SUMMARY:
4483169
+    in use at exit: ... bytes in ... blocks
4483169
+  total heap usage: ... allocs, ... frees, ... bytes allocated
4483169
+
4483169
+For a detailed leak analysis, rerun with: --leak-check=full
4483169
+
4483169
+For counts of detected and suppressed errors, rerun with: -v
4483169
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
4483169
diff --git a/memcheck/tests/partial_load_ok.stderr.exp-ppc64 b/memcheck/tests/partial_load_ok.stderr.exp-ppc64
4483169
new file mode 100644
4483169
index 0000000..cf32bcf
4483169
--- /dev/null
4483169
+++ b/memcheck/tests/partial_load_ok.stderr.exp-ppc64
4483169
@@ -0,0 +1,23 @@
4483169
+
4483169
+powerpc64
4483169
+Invalid read of size 2
4483169
+   at 0x........: main (partial_load.c:30)
4483169
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
4483169
+   at 0x........: calloc (vg_replace_malloc.c:...)
4483169
+   by 0x........: main (partial_load.c:28)
4483169
+
4483169
+Invalid read of size 8
4483169
+   at 0x........: main (partial_load.c:37)
4483169
+ Address 0x........ is 0 bytes inside a block of size 8 free'd
4483169
+   at 0x........: free (vg_replace_malloc.c:...)
4483169
+   by 0x........: main (partial_load.c:36)
4483169
+
4483169
+
4483169
+HEAP SUMMARY:
4483169
+    in use at exit: ... bytes in ... blocks
4483169
+  total heap usage: ... allocs, ... frees, ... bytes allocated
4483169
+
4483169
+For a detailed leak analysis, rerun with: --leak-check=full
4483169
+
4483169
+For counts of detected and suppressed errors, rerun with: -v
4483169
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
4483169
diff -ur valgrind-3.14.0.orig/memcheck/tests/Makefile.in valgrind-3.14.0/memcheck/tests/Makefile.in
4483169
--- valgrind-3.14.0.orig/memcheck/tests/Makefile.in	2018-12-12 23:17:07.525501080 +0100
4483169
+++ valgrind-3.14.0/memcheck/tests/Makefile.in	2018-12-12 23:18:13.404014757 +0100
4483169
@@ -1546,8 +1546,10 @@
4483169
 	partiallydefinedeq.stdout.exp \
4483169
 	partial_load_ok.vgtest partial_load_ok.stderr.exp \
4483169
 		partial_load_ok.stderr.exp64 \
4483169
+		partial_load_ok.stderr.exp-ppc64 \
4483169
 	partial_load_dflt.vgtest partial_load_dflt.stderr.exp \
4483169
 		partial_load_dflt.stderr.exp64 \
4483169
+		partial_load_dflt.stderr.exp-ppc64 \
4483169
 	partial_load_dflt.stderr.expr-s390x-mvc \
4483169
 	pdb-realloc.stderr.exp pdb-realloc.vgtest \
4483169
 	pdb-realloc2.stderr.exp pdb-realloc2.stdout.exp pdb-realloc2.vgtest \