]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Filter out unsupported instructions from HWCAP2 on powerpc.
authorMark Wielaard <mark@klomp.org>
Tue, 23 Feb 2021 15:19:26 +0000 (16:19 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 23 Feb 2021 15:19:26 +0000 (16:19 +0100)
Valgrind currently doesn't support the DARN random number instruction
and the SCV syscall instruction. Filter them out of HWCAP2 so glibc
and applications don't try to use them when running under valgrind.

Also suppress printing a log message for scv instructions in the
instruction stream.

Reported by: Florian Weimer <fweimer@redhat.com>

DARN bug: https://bugs.kde.org/show_bug.cgi?id=411189
SCV bug: https://bugs.kde.org/show_bug.cgi?id=431157

VEX/priv/guest_ppc_toIR.c
coregrind/m_initimg/initimg-linux.c

index 880a47ebb215c0df6752648b738dd6318fd601c1..308c2fe7624435bb2d2e63e9101d2c7fdb6a0152 100644 (file)
@@ -10878,8 +10878,9 @@ static Bool dis_syslink ( UInt prefix, UInt theInstr,
    /* There is no prefixed version of these instructions.  */
    PREFIX_CHECK
 
-   if (theInstr != 0x44000002) {
-      vex_printf("dis_syslink(ppc)(theInstr)\n");
+   if (theInstr != 0x44000002) { // sc
+      if (theInstr != 0x44000001) // scv
+         vex_printf("dis_syslink(ppc)(theInstr)\n");
       return False;
    }
 
index ba84fa6e9dd159782c4c4178aebda98b45650c6d..cb7902446a584a05f29f8898e0533110c140c31d 100644 (file)
@@ -750,6 +750,14 @@ Addr setup_client_stack( void*  init_sp,
                 PPC_FEATURE2_HAS_ISEL         0x08000000
                 PPC_FEATURE2_HAS_TAR          0x04000000
                 PPC_FEATURE2_HAS_VCRYPTO      0x02000000
+                PPC_FEATURE2_HTM_NOSC         0x01000000
+                PPC_FEATURE2_ARCH_3_00        0x00800000
+                PPC_FEATURE2_HAS_IEEE128      0x00400000
+                PPC_FEATURE2_DARN             0x00200000
+                PPC_FEATURE2_SCV              0x00100000
+                PPC_FEATURE2_HTM_NO_SUSPEND   0x00080000
+                PPC_FEATURE2_ARCH_3_1         0x00040000
+                PPC_FEATURE2_MMA              0x00020000
             */
             auxv_2_07 = (auxv->u.a_val & 0x80000000ULL) == 0x80000000ULL;
             hw_caps_2_07 = (vex_archinfo->hwcaps & VEX_HWCAPS_PPC64_ISA2_07)
@@ -797,6 +805,23 @@ Addr setup_client_stack( void*  init_sp,
              * matches the setting in VEX HWCAPS.
              */
             vg_assert(auxv_3_1 == hw_caps_3_1);
+
+            /* Mask unrecognized HWCAP bits.  Only keep the bits that have
+             * explicit support in VEX. Filter out HTM bits since the
+             * transaction begin instruction (tbegin) is always failed in
+             * Valgrind causing the code to execute the failure path.
+             * Also filter out the DARN random number (bug #411189).
+             * And the SCV syscall (bug #431157).
+             */
+            auxv->u.a_val &= (0x80000000ULL     /* ARCH_2_07 */
+                              | 0x20000000ULL   /* DSCR */
+                              | 0x10000000ULL   /* EBB */
+                              | 0x08000000ULL   /* ISEL */
+                              | 0x04000000ULL   /* TAR */
+                              | 0x04000000ULL   /* VEC_CRYPTO */
+                              | 0x00800000ULL   /* ARCH_3_00 */
+                              | 0x00400000ULL   /* HAS_IEEE128 */
+                              | 0x00040000ULL); /* ARCH_3_1 */
          }
 
             break;