Don't attempt to use mpx registers on unsupported platforms
authorFrancis Ricci <francisjricci@gmail.com>
Wed, 3 May 2017 15:00:04 +0000 (15:00 +0000)
committerFrancis Ricci <francisjricci@gmail.com>
Wed, 3 May 2017 15:00:04 +0000 (15:00 +0000)
Summary:
The existing cpp-level checks using PR_MPX_ENABLE_MANAGEMENT aren't sufficient,
as this isn't defined for linux kernel versions below 3.19.

Reviewers: valentinagiusti, zturner, labath

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D32719

llvm-svn: 302027

lldb/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp
lldb/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/main.cpp

index d9adb55..3e528d2 100644 (file)
 int
 main(int argc, char const *argv[])
 {
+// PR_MPX_ENABLE_MANAGEMENT won't be defined on linux kernel versions below 3.19
+#ifndef PR_MPX_ENABLE_MANAGEMENT
+    return -1;
+#endif
+
     // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
     if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
         return -1;
index 9c445aa..b78eb9e 100644 (file)
@@ -29,6 +29,11 @@ main(int argc, char const *argv[])
   unsigned int rax, rbx, rcx, rdx;
   int array[5];
 
+// PR_MPX_ENABLE_MANAGEMENT won't be defined on linux kernel versions below 3.19
+#ifndef PR_MPX_ENABLE_MANAGEMENT
+    return -1;
+#endif
+
   // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
   if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
     return -1;