forked from OSchip/llvm-project
Improve test for Intel(R) MPX registers.
Summary: Let the inferior test code determine if CPU and kernel support Intel(R) MPX and cleanup test script. Differential Revision: https://reviews.llvm.org/D25328 llvm-svn: 283461
This commit is contained in:
parent
d03c85c02e
commit
0670ad14f8
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Test the MPX registers.
|
||||
Test the Intel(R) MPX registers.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
@ -21,23 +21,18 @@ class RegisterCommandsTestCase(TestBase):
|
|||
|
||||
def setUp(self):
|
||||
TestBase.setUp(self)
|
||||
self.has_teardown = False
|
||||
|
||||
def tearDown(self):
|
||||
self.dbg.GetSelectedTarget().GetProcess().Destroy()
|
||||
TestBase.tearDown(self)
|
||||
|
||||
@skipIf(compiler="clang")
|
||||
@skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports MPX.
|
||||
@skipIf(oslist=no_match(['linux']))
|
||||
@skipIf(archs=no_match(['i386', 'x86_64']))
|
||||
@skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports Intel(R) MPX.
|
||||
def test_mpx_registers_with_example_code(self):
|
||||
"""Test MPX registers with example code."""
|
||||
"""Test Intel(R) MPX registers with example code."""
|
||||
self.build()
|
||||
self.mpx_registers_with_example_code()
|
||||
|
||||
def mpx_registers_with_example_code(self):
|
||||
"""Test MPX registers after running example code."""
|
||||
"""Test Intel(R) MPX registers after running example code."""
|
||||
self.line = line_number('main.cpp', '// Set a break point here.')
|
||||
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
@ -50,7 +45,7 @@ class RegisterCommandsTestCase(TestBase):
|
|||
process = target.GetProcess()
|
||||
|
||||
if (process.GetState() == lldb.eStateExited):
|
||||
self.skipTest("HW doesn't support MPX feature.")
|
||||
self.skipTest("Intel(R) MPX is not supported.")
|
||||
else:
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 1."])
|
||||
|
|
|
@ -14,23 +14,11 @@
|
|||
int
|
||||
main(int argc, char const *argv[])
|
||||
{
|
||||
unsigned int rax, rbx, rcx, rdx;
|
||||
|
||||
// Check if XSAVE is enabled.
|
||||
if (!__get_cpuid(1, &rax, &rbx, &rcx, &rdx) || (rcx & bit_OSXSAVE) != bit_OSXSAVE)
|
||||
// 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;
|
||||
|
||||
// Check if MPX is enabled.
|
||||
if (__get_cpuid_max(0, NULL) > 7)
|
||||
{
|
||||
__cpuid_count(7, 0, rax, rbx, rcx, rdx);
|
||||
if ((rbx & bit_MPX) != bit_MPX)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
// Run MPX test code.
|
||||
// Run Intel(R) MPX test code.
|
||||
#if defined(__x86_64__)
|
||||
asm("mov $16, %rax\n\t"
|
||||
"mov $9, %rdx\n\t"
|
||||
|
|
Loading…
Reference in New Issue