|
From: Carl E. L. <ce...@us...> - 2015-03-23 22:19:37
|
Julian:
Thanks for the pointers on how to get to the VEX hw caps variable for the sanity check.
I have implemented the change and the check. Since I am touching code outside of PPC, I
would appreciate a quick review before I commit it. Let me know if you see anything that
needs fixing. Thanks.
Carl Love
------------------------------------------------
Index: coregrind/m_initimg/initimg-linux.c
===================================================================
--- coregrind/m_initimg/initimg-linux.c (revision 15017)
+++ coregrind/m_initimg/initimg-linux.c (working copy)
@@ -246,6 +246,10 @@
/*=== Setting up the client's stack ===*/
/*====================================================================*/
+#ifndef AT_DCACHEBSIZE
+#define AT_DCACHEBSIZE 19
+#endif /* AT_DCACHEBSIZE */
+
#ifndef AT_ICACHEBSIZE
#define AT_ICACHEBSIZE 20
#endif /* AT_ICACHEBSIZE */
@@ -262,6 +266,10 @@
#define AT_RANDOM 25
#endif /* AT_RANDOM */
+#ifndef AT_HWCAP2
+#define AT_HWCAP2 26
+#endif /* AT_HWCAP2 */
+
#ifndef AT_EXECFN
#define AT_EXECFN 31
#endif /* AT_EXECFN */
@@ -377,8 +385,14 @@
const ExeInfo* info,
UInt** client_auxv,
Addr clstack_end,
- SizeT clstack_max_size )
+ SizeT clstack_max_size,
+ VexArchInfo vex_archinfo )
{
+ /* The HW configuration setting (hwcaps) of the target can be
+ * checked against the Vex settings of the host platform as given
+ * by the values in vex_archinfo.
+ */
+
SysRes res;
HChar **cpp;
HChar *strtab; /* string table */
@@ -690,8 +704,44 @@
}
# endif
break;
+# if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
+ case AT_HWCAP2:
+ /* The HWCAP2 value has the entry arch_2_07 which indicates the
+ * processor is a Power 8 or beyond. The Valgrind vai.hwcaps
+ * value (coregrind/m_machine.c) has the VEX_HWCAPS_PPC64_ISA2_07
+ * flag set so Valgrind knows about Power8. Need to pass the
+ * HWCAP2 value along so the user level programs can detect that
+ * the processor supports ISA 2.07 and beyond.
+ */
+ /* Power Architecture 64-Bit ELF V2 ABI Specification
+ July 21, 2014, version 1.0, Page 124
+ www-03.ibm.com/technologyconnect/tgcm/TGCMServlet.wss?alias=OpenPOWER&linkid=1n0000
+ AT_HWCAP2
+ The a_val member of this entry is a bit map of hardware
+ capabilities. Some bit mask values include:
+
+ PPC_FEATURE2_ARCH_2_07 0x80000000
+ PPC_FEATURE2_HAS_HTM 0x40000000
+ PPC_FEATURE2_HAS_DSCR 0x20000000
+ PPC_FEATURE2_HAS_EBB 0x10000000
+ PPC_FEATURE2_HAS_ISEL 0x08000000
+ PPC_FEATURE2_HAS_TAR 0x04000000
+ PPC_FEATURE2_HAS_VCRYPTO 0x02000000
+ */
+
+ if ((auxv->u.a_val & ~(0x80000000ULL)) != 0) {
+ /* Verify if PPC_FEATURE2_ARCH_2_07 is set in HWCAP2
+ * that arch_2_07 is also set in VEX HWCAPS
+ */
+ vg_assert((vex_archinfo.hwcaps & VEX_HWCAPS_PPC64_ISA2_07) == VEX_HWCAPS_PPC64_ISA2_07);
+ }
+
+ break;
+# endif
+
case AT_ICACHEBSIZE:
+ case AT_DCACHEBSIZE:
case AT_UCACHEBSIZE:
# if defined(VGP_ppc32_linux)
/* acquire cache info */
@@ -852,7 +902,8 @@
/*====================================================================*/
/* Create the client's initial memory image. */
-IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii )
+IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii,
+ VexArchInfo vex_archinfo )
{
ExeInfo info;
HChar** env = NULL;
@@ -913,7 +964,8 @@
iifii.initial_client_SP
= setup_client_stack( init_sp, env,
&info, &iifii.client_auxv,
- iicii.clstack_end, iifii.clstack_max_size );
+ iicii.clstack_end, iifii.clstack_max_size,
+ vex_archinfo );
VG_(free)(env);
Index: coregrind/pub_core_initimg.h
===================================================================
--- coregrind/pub_core_initimg.h (revision 15017)
+++ coregrind/pub_core_initimg.h (working copy)
@@ -33,6 +33,7 @@
#define __PUB_CORE_INITIMG_H
#include "pub_core_basics.h" // Addr
+#include "libvex.h"
//--------------------------------------------------------------------
// PURPOSE: Map the client executable into memory, then set up its
@@ -50,7 +51,8 @@
structure, which is gathered in an OS-specific way at startup.
This returns an IIFinaliseImageInfo structure: */
extern
-IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo );
+IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo,
+ VexArchInfo vex_archinfo );
/* Just before starting the client, we may need to make final
adjustments to its initial image. Also we need to set up the VEX
Index: coregrind/m_main.c
===================================================================
--- coregrind/m_main.c (revision 15017)
+++ coregrind/m_main.c (working copy)
@@ -1815,9 +1815,12 @@
//--------------------------------------------------------------
// Figure out what sort of CPU we're on, and whether it is
// able to run V.
+ /* The vex_archinfo structure is passed down later to the client
+ * to verify the HW info settings are consistent.
+ */
+ VexArchInfo vex_archinfo;
VG_(debugLog)(1, "main", "Get hardware capabilities ...\n");
{ VexArch vex_arch;
- VexArchInfo vex_archinfo;
Bool ok = VG_(machine_get_hwcaps)();
if (!ok) {
VG_(printf)("\n");
@@ -1945,7 +1948,7 @@
# endif
/* NOTE: this call reads VG_(clo_main_stacksize). */
- the_iifii = VG_(ii_create_image)( the_iicii );
+ the_iifii = VG_(ii_create_image)( the_iicii, vex_archinfo );
}
//==============================================================
|