Blame SOURCES/valgrind-3.18.1-ppc64-lxsibzx-lxsihzx.patch

6e98bf
commit 6e08ee95f7f1b1c3fd434fa380cc5b2cc3e3f7c7
6e98bf
Author: Carl Love <cel@us.ibm.com>
6e98bf
Date:   Fri Oct 29 16:30:33 2021 -0500
6e98bf
6e98bf
    Bug 444571 - PPC, fix the lxsibzx and lxsihzx so they only load their respective sized data.
6e98bf
    
6e98bf
    The lxsibzx was doing a 64-bit load.  The result was initializing
6e98bf
    additional bytes in the register that should not have been initialized.
6e98bf
    The memcheck/tests/linux/dlclose_leak test detected the issue.  The
6e98bf
    code generation uses lxsibzx and stxsibx with -mcpu=power9.  Previously
6e98bf
    the lbz and stb instructions were generated.
6e98bf
    
6e98bf
    The same issue was noted and fixed with the lxsihzx instruction.  The
6e98bf
    memcheck/tests/linux/badrw test now passes as well.
6e98bf
    
6e98bf
    https://bugs.kde.org/show_bug.cgi?id=444571
6e98bf
6e98bf
diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c
6e98bf
index d90d566ed..8afd77490 100644
6e98bf
--- a/VEX/priv/guest_ppc_toIR.c
6e98bf
+++ b/VEX/priv/guest_ppc_toIR.c
6e98bf
@@ -25359,19 +25359,17 @@ dis_vx_load ( UInt prefix, UInt theInstr )
6e98bf
 
6e98bf
       else
6e98bf
          irx_addr = mkexpr( EA );
6e98bf
-
6e98bf
-      byte = load( Ity_I64, irx_addr );
6e98bf
+      /* byte load */
6e98bf
+      byte = load( Ity_I8, irx_addr );
6e98bf
       putVSReg( XT, binop( Iop_64HLtoV128,
6e98bf
-                            binop( Iop_And64,
6e98bf
-                                   byte,
6e98bf
-                                   mkU64( 0xFF ) ),
6e98bf
+                           unop( Iop_8Uto64, byte ),
6e98bf
                            mkU64( 0 ) ) );
6e98bf
       break;
6e98bf
    }
6e98bf
 
6e98bf
    case 0x32D: // lxsihzx
6e98bf
    {
6e98bf
-      IRExpr *byte;
6e98bf
+      IRExpr *hword;
6e98bf
       IRExpr* irx_addr;
6e98bf
 
6e98bf
       DIP("lxsihzx %u,r%u,r%u\n", (UInt)XT, rA_addr, rB_addr);
6e98bf
@@ -25382,11 +25380,10 @@ dis_vx_load ( UInt prefix, UInt theInstr )
6e98bf
       else
6e98bf
          irx_addr = mkexpr( EA );
6e98bf
 
6e98bf
-      byte = load( Ity_I64, irx_addr );
6e98bf
+      hword = load( Ity_I16, irx_addr );
6e98bf
       putVSReg( XT, binop( Iop_64HLtoV128,
6e98bf
-                            binop( Iop_And64,
6e98bf
-                                   byte,
6e98bf
-                                   mkU64( 0xFFFF ) ),
6e98bf
+                            unop( Iop_16Uto64,
6e98bf
+                                  hword ),
6e98bf
                            mkU64( 0 ) ) );
6e98bf
       break;
6e98bf
    }