diff options
author | Andi Kleen <ak@linux.intel.com> | 2016-07-06 02:38:49 +0000 |
---|---|---|
committer | Andi Kleen <ak@gcc.gnu.org> | 2016-07-06 02:38:49 +0000 |
commit | 8070763a2cd6d84f8614890a9a7bfae57b44c047 (patch) | |
tree | c126d32aab7e0abd395b031752d1798dceeb508e /gcc | |
parent | 8217ad204feff459bdf3f0eb1e99a02ab6fba9a3 (diff) | |
download | gcc-8070763a2cd6d84f8614890a9a7bfae57b44c047.zip gcc-8070763a2cd6d84f8614890a9a7bfae57b44c047.tar.gz gcc-8070763a2cd6d84f8614890a9a7bfae57b44c047.tar.bz2 |
Fix MPX tests on systems with MPX disabled
I have a Skylake system with MPX in the CPU, but MPX is disabled
in the kernel configuration.
This makes all the MPX tests fail because they assume if MPX
is in CPUID it works
Check the output of XGETBV too to detect non MPX kernels.
gcc/testsuite/:
2016-07-05 Andi Kleen <ak@linux.intel.com>
* gcc.target/i386/mpx/mpx-check.h: Check XGETBV output
if kernel supports MPX.
From-SVN: r238031
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/mpx/mpx-check.h | 12 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b2fda8..15231dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-05 Andi Kleen <ak@linux.intel.com> + + * gcc.target/i386/mpx/mpx-check.h: Check XGETBV output + if kernel supports MPX. + 2016-07-05 Kito Cheng <kito.cheng@gmail.com> * gcc.c-torture/compile/pr69102.c: Require fpic support. diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h index 3afa460..73aa01f 100644 --- a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h +++ b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h @@ -16,6 +16,16 @@ mpx_test (int, const char **); #define DEBUG +#define XSTATE_BNDREGS (1 << 3) + +/* This should be an intrinsic, but isn't. */ +static int xgetbv (unsigned x) +{ + unsigned eax, edx; + asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (x)); + return eax; +} + int main (int argc, const char **argv) { @@ -27,7 +37,7 @@ main (int argc, const char **argv) __cpuid_count (7, 0, eax, ebx, ecx, edx); /* Run MPX test only if host has MPX support. */ - if (ebx & bit_MPX) + if ((ebx & bit_MPX) && (xgetbv (0) & XSTATE_BNDREGS)) mpx_test (argc, argv); else { |