From: Julian Seward Date: Tue, 26 Mar 2013 13:57:48 +0000 (+0000) Subject: Add hwcaps checking on amd64 for RDTSCP. Part of the fix for #251569 X-Git-Tag: svn/VALGRIND_3_9_0~346 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ebe62078c975701b7484dc9cb7cff0dea3816cb;p=thirdparty%2Fvalgrind.git Add hwcaps checking on amd64 for RDTSCP. Part of the fix for #251569 and its dups. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13337 --- diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index b40cb28196..dce7ee6f86 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -768,6 +768,7 @@ Bool VG_(machine_get_hwcaps)( void ) #elif defined(VGA_amd64) { Bool have_sse3, have_cx8, have_cx16; Bool have_lzcnt, have_avx /*, have_fma*/; + Bool have_rdtscp; UInt eax, ebx, ecx, edx, max_extended; HChar vstr[13]; vstr[0] = 0; @@ -841,12 +842,19 @@ Bool VG_(machine_get_hwcaps)( void ) VG_(cpuid)(0x80000001, 0, &eax, &ebx, &ecx, &edx); have_lzcnt = (ecx & (1<<5)) != 0; /* True => have LZCNT */ } + /* Can we do RDTSCP? */ + have_rdtscp = False; + if (max_extended >= 0x80000001) { + VG_(cpuid)(0x80000001, 0, &eax, &ebx, &ecx, &edx); + have_rdtscp = (edx & (1<<27)) != 0; /* True => have RDTSVCP */ + } va = VexArchAMD64; - vai.hwcaps = (have_sse3 ? VEX_HWCAPS_AMD64_SSE3 : 0) - | (have_cx16 ? VEX_HWCAPS_AMD64_CX16 : 0) - | (have_lzcnt ? VEX_HWCAPS_AMD64_LZCNT : 0) - | (have_avx ? VEX_HWCAPS_AMD64_AVX : 0); + vai.hwcaps = (have_sse3 ? VEX_HWCAPS_AMD64_SSE3 : 0) + | (have_cx16 ? VEX_HWCAPS_AMD64_CX16 : 0) + | (have_lzcnt ? VEX_HWCAPS_AMD64_LZCNT : 0) + | (have_avx ? VEX_HWCAPS_AMD64_AVX : 0) + | (have_rdtscp ? VEX_HWCAPS_AMD64_RDTSCP : 0); VG_(machine_get_cache_info)(&vai);