|
From: <sv...@va...> - 2010-09-09 07:26:06
|
Author: sewardj
Date: 2010-09-09 08:25:58 +0100 (Thu, 09 Sep 2010)
New Revision: 11347
Log:
arm-linux: determine whether the host supports Neon by looking at our
AUXV at startup, rather than by trying to execute a Neon instruction
and seeing whether it SIGILLs. Apparently the latter is not a
reliable way to ascertain the presence of usable Neon support. Fixes
#249775.
Modified:
trunk/coregrind/m_initimg/initimg-linux.c
trunk/coregrind/m_machine.c
trunk/coregrind/pub_core_machine.h
trunk/include/vki/vki-arm-linux.h
Modified: trunk/coregrind/m_initimg/initimg-linux.c
===================================================================
--- trunk/coregrind/m_initimg/initimg-linux.c 2010-09-08 16:29:17 UTC (rev 11346)
+++ trunk/coregrind/m_initimg/initimg-linux.c 2010-09-09 07:25:58 UTC (rev 11347)
@@ -672,6 +672,14 @@
break;
case AT_HWCAP:
+# if defined(VGP_arm_linux)
+ { Bool has_neon = (auxv->u.a_val & VKI_HWCAP_NEON) > 0;
+ VG_(debugLog)(2, "initimg",
+ "ARM has-neon from-auxv: %s\n",
+ has_neon ? "YES" : "NO");
+ VG_(machine_arm_set_has_NEON)( has_neon );
+ }
+# endif
break;
case AT_DCACHEBSIZE:
Modified: trunk/coregrind/m_machine.c
===================================================================
--- trunk/coregrind/m_machine.c 2010-09-08 16:29:17 UTC (rev 11346)
+++ trunk/coregrind/m_machine.c 2010-09-09 07:25:58 UTC (rev 11347)
@@ -983,6 +983,22 @@
#endif
+/* Notify host's ability to handle NEON instructions. */
+#if defined(VGA_arm)
+void VG_(machine_arm_set_has_NEON)( Bool has_neon )
+{
+ vg_assert(hwcaps_done);
+ /* There's nothing else we can sanity check. */
+
+ if (has_neon) {
+ vai.hwcaps |= VEX_HWCAPS_ARM_NEON;
+ } else {
+ vai.hwcaps &= ~VEX_HWCAPS_ARM_NEON;
+ }
+}
+#endif
+
+
/* Fetch host cpu info, once established. */
void VG_(machine_get_VexArchInfo)( /*OUT*/VexArch* pVa,
/*OUT*/VexArchInfo* pVai )
Modified: trunk/coregrind/pub_core_machine.h
===================================================================
--- trunk/coregrind/pub_core_machine.h 2010-09-08 16:29:17 UTC (rev 11346)
+++ trunk/coregrind/pub_core_machine.h 2010-09-09 07:25:58 UTC (rev 11347)
@@ -158,7 +158,12 @@
then safe to use VG_(machine_get_VexArchInfo)
and VG_(machine_ppc64_has_VMX)
+ -------------
+ arm: initially: call VG_(machine_get_hwcaps)
+ call VG_(machine_arm_set_has_NEON)
+ then safe to use VG_(machine_get_VexArchInfo)
+
VG_(machine_get_hwcaps) may use signals (although it attempts to
leave signal state unchanged) and therefore should only be
called before m_main sets up the client's signal state.
@@ -182,6 +187,10 @@
extern void VG_(machine_ppc64_set_clszB)( Int );
#endif
+#if defined(VGA_arm)
+extern void VG_(machine_arm_set_has_NEON)( Bool );
+#endif
+
/* X86: set to 1 if the host is able to do {ld,st}mxcsr (load/store
the SSE control/status register), else zero. Is referenced from
assembly code, so do not change from a 32-bit int. */
Modified: trunk/include/vki/vki-arm-linux.h
===================================================================
--- trunk/include/vki/vki-arm-linux.h 2010-09-08 16:29:17 UTC (rev 11346)
+++ trunk/include/vki/vki-arm-linux.h 2010-09-09 07:25:58 UTC (rev 11347)
@@ -872,6 +872,12 @@
};
//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/arm/include/asm/hwcap.h
+//----------------------------------------------------------------------
+
+#define VKI_HWCAP_NEON 4096
+
+//----------------------------------------------------------------------
// And that's it!
//----------------------------------------------------------------------
|