Blame SOURCES/valgrind-3.14.0-ppc64-unaligned-words.patch

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