From: Mark Wielaard Date: Tue, 19 Jun 2018 16:00:45 +0000 (+0200) Subject: Mask AT_HWCAPS on arm64 to those instructions VEX implements. X-Git-Tag: VALGRIND_3_14_0~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbbb696c5d1e93d4ac6cb548c68bb3f443ceef42;p=thirdparty%2Fvalgrind.git Mask AT_HWCAPS on arm64 to those instructions VEX implements. This patch makes sure that the process running under valgrind only sees the AES, PMULL, SHA1, SHA2, CRC32, FP, and ASIMD features in auxv AT_HWCAPS. https://bugs.kde.org/show_bug.cgi?id=381556 --- diff --git a/NEWS b/NEWS index 004497199c..4fe7522bb4 100644 --- a/NEWS +++ b/NEWS @@ -71,6 +71,7 @@ where XXXXXX is the bug number as listed below. 381289 epoll_pwait can have a NULL sigmask 381274 powerpc too chatty even with --sigill-diagnostics=no 381553 VEX register allocator v3 +381556 arm64: Handle feature registers access on 4.11 Linux kernel or later 381769 Use ucontext_t instead of struct ucontext 381805 arm32 needs ld.so index hardwire for new glibc security fixes 382256 gz compiler flag test doesn't work for gold diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c index 14b48dca85..61cc458bcf 100644 --- a/coregrind/m_initimg/initimg-linux.c +++ b/coregrind/m_initimg/initimg-linux.c @@ -705,9 +705,16 @@ Addr setup_client_stack( void* init_sp, } # elif defined(VGP_arm64_linux) { - /* Linux 4.11 started pupulating this for arm64, but we - currently don't support any. Bug KDE#381556. */ - auxv->u.a_val = 0; + /* Limit the AT_HWCAP to just those features we explicitly + support in VEX. */ +#define ARM64_SUPPORTED_HWCAP (VKI_HWCAP_AES \ + | VKI_HWCAP_PMULL \ + | VKI_HWCAP_SHA1 \ + | VKI_HWCAP_SHA2 \ + | VKI_HWCAP_CRC32 \ + | VKI_HWCAP_FP \ + | VKI_HWCAP_ASIMD) + auxv->u.a_val &= ARM64_SUPPORTED_HWCAP; } # endif break; diff --git a/include/vki/vki-arm64-linux.h b/include/vki/vki-arm64-linux.h index af6b435724..54b0428d93 100644 --- a/include/vki/vki-arm64-linux.h +++ b/include/vki/vki-arm64-linux.h @@ -691,6 +691,39 @@ struct vki_shminfo64 { #define VKI_TIOCGSERIAL 0x541E #define VKI_TIOCSSERIAL 0x541F +//---------------------------------------------------------------------- +// From linux-4.17/include/uapi/asm-generic/ioctls.h +//---------------------------------------------------------------------- + +#define VKI_HWCAP_FP (1 << 0) +#define VKI_HWCAP_ASIMD (1 << 1) +#define VKI_HWCAP_EVTSTRM (1 << 2) +#define VKI_HWCAP_AES (1 << 3) +#define VKI_HWCAP_PMULL (1 << 4) +#define VKI_HWCAP_SHA1 (1 << 5) +#define VKI_HWCAP_SHA2 (1 << 6) +#define VKI_HWCAP_CRC32 (1 << 7) +#define VKI_HWCAP_ATOMICS (1 << 8) +#define VKI_HWCAP_FPHP (1 << 9) +#define VKI_HWCAP_ASIMDHP (1 << 10) +#define VKI_HWCAP_CPUID (1 << 11) +#define VKI_HWCAP_ASIMDRDM (1 << 12) +#define VKI_HWCAP_JSCVT (1 << 13) +#define VKI_HWCAP_FCMA (1 << 14) +#define VKI_HWCAP_LRCPC (1 << 15) +#define VKI_HWCAP_DCPOP (1 << 16) +#define VKI_HWCAP_SHA3 (1 << 17) +#define VKI_HWCAP_SM3 (1 << 18) +#define VKI_HWCAP_SM4 (1 << 19) +#define VKI_HWCAP_ASIMDDP (1 << 20) +#define VKI_HWCAP_SHA512 (1 << 21) +#define VKI_HWCAP_SVE (1 << 22) +#define VKI_HWCAP_ASIMDFHM (1 << 23) +#define VKI_HWCAP_DIT (1 << 24) +#define VKI_HWCAP_USCAT (1 << 25) +#define VKI_HWCAP_ILRCPC (1 << 26) +#define VKI_HWCAP_FLAGM (1 << 27) + //---------------------------------------------------------------------- // And that's it! //----------------------------------------------------------------------