]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Mask AT_HWCAPS on arm64 to those instructions VEX implements.
authorMark Wielaard <mark@klomp.org>
Tue, 19 Jun 2018 16:00:45 +0000 (18:00 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 21 Jun 2018 06:17:11 +0000 (08:17 +0200)
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

NEWS
coregrind/m_initimg/initimg-linux.c
include/vki/vki-arm64-linux.h

diff --git a/NEWS b/NEWS
index 004497199cdf92df4c05cdb538f7f8ec4c207c41..4fe7522bb40cf76c3df2fc50d1faf9b5b433f871 100644 (file)
--- 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
index 14b48dca85ac15e37c9dd7cb0b44ea504bbd7339..61cc458bcfd53d91a96c01e7320ab1c5472fcffd 100644 (file)
@@ -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;
index af6b43572451b02338f53b25e664c7fa76eb3e71..54b0428d938976d68fbe593b39114d9ddd9583ce 100644 (file)
@@ -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!
 //----------------------------------------------------------------------