Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for rL280668, Intel(R) Memory Protection Extensions (Intel(R) MPX…
…) support. Summary: Signed-off-by: Valentina Giusti <valentina.giusti@intel.com> Reviewers: dvlahovski, granata.enrico, clayborg, labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D24255 llvm-svn: 280942
- Loading branch information
Valentina Giusti
committed
Sep 8, 2016
1 parent
4d1e4d7
commit cda0ae4
Showing
17 changed files
with
639 additions
and
21 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.../packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
LEVEL = ../../../make | ||
|
||
CXX_SOURCES := main.cpp | ||
|
||
CFLAGS_EXTRAS += -mmpx -fcheck-pointer-bounds -fuse-ld=bfd | ||
|
||
include $(LEVEL)/Makefile.rules |
74 changes: 74 additions & 0 deletions
74
...ython/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
""" | ||
Test the MPX registers. | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
|
||
import os | ||
import sys | ||
import time | ||
import re | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class RegisterCommandsTestCase(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
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'])) | ||
def test_mpx_registers_with_example_code(self): | ||
"""Test 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.""" | ||
self.line = line_number('main.cpp', '// Set a break point here.') | ||
|
||
exe = os.path.join(os.getcwd(), "a.out") | ||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) | ||
|
||
lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line, num_expected_locations=1) | ||
self.runCmd("run", RUN_SUCCEEDED) | ||
|
||
target = self.dbg.GetSelectedTarget() | ||
process = target.GetProcess() | ||
|
||
if (process.GetState() == lldb.eStateExited): | ||
self.skipTest("HW doesn't support MPX feature.") | ||
else: | ||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, | ||
substrs = ["stop reason = breakpoint 1."]) | ||
|
||
if self.getArchitecture() == 'x86_64': | ||
self.expect("register read -s 3", | ||
substrs = ['bnd0 = {0x0000000000000010 0xffffffffffffffe6}', | ||
'bnd1 = {0x0000000000000020 0xffffffffffffffd6}', | ||
'bnd2 = {0x0000000000000030 0xffffffffffffffc6}', | ||
'bnd3 = {0x0000000000000040 0xffffffffffffffb6}', | ||
'bndcfgu = {0x01 0x80 0xb5 0x76 0xff 0x7f 0x00 0x00}', | ||
'bndstatus = {0x02 0x80 0xb5 0x76 0xff 0x7f 0x00 0x00}']) | ||
if self.getArchitecture() == 'i386': | ||
self.expect("register read -s 3", | ||
substrs = ['bnd0 = {0x0000000000000010 0x00000000ffffffe6}', | ||
'bnd1 = {0x0000000000000020 0x00000000ffffffd6}', | ||
'bnd2 = {0x0000000000000030 0x00000000ffffffc6}', | ||
'bnd3 = {0x0000000000000040 0x00000000ffffffb6}', | ||
'bndcfgu = {0x01 0xd0 0x7d 0xf7 0x00 0x00 0x00 0x00}', | ||
'bndstatus = {0x02 0xd0 0x7d 0xf7 0x00 0x00 0x00 0x00}']) | ||
|
69 changes: 69 additions & 0 deletions
69
.../packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//===-- main.cpp ------------------------------------------------*- C++ -*-===// | ||
//// | ||
//// The LLVM Compiler Infrastructure | ||
//// | ||
//// This file is distributed under the University of Illinois Open Source | ||
//// License. See LICENSE.TXT for details. | ||
//// | ||
////===----------------------------------------------------------------------===// | ||
// | ||
|
||
#include <cpuid.h> | ||
#include <cstddef> | ||
|
||
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) | ||
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. | ||
#if defined(__x86_64__) | ||
asm("mov $16, %rax\n\t" | ||
"mov $9, %rdx\n\t" | ||
"bndmk (%rax,%rdx), %bnd0\n\t" | ||
"mov $32, %rax\n\t" | ||
"mov $9, %rdx\n\t" | ||
"bndmk (%rax,%rdx), %bnd1\n\t" | ||
"mov $48, %rax\n\t" | ||
"mov $9, %rdx\n\t" | ||
"bndmk (%rax,%rdx), %bnd2\n\t" | ||
"mov $64, %rax\n\t" | ||
"mov $9, %rdx\n\t" | ||
"bndmk (%rax,%rdx), %bnd3\n\t" | ||
"bndstx %bnd3, (%rax) \n\t" | ||
"nop\n\t"); | ||
#endif | ||
#if defined(__i386__) | ||
asm("mov $16, %eax\n\t" | ||
"mov $9, %edx\n\t" | ||
"bndmk (%eax,%edx), %bnd0\n\t" | ||
"mov $32, %eax\n\t" | ||
"mov $9, %edx\n\t" | ||
"bndmk (%eax,%edx), %bnd1\n\t" | ||
"mov $48, %eax\n\t" | ||
"mov $9, %edx\n\t" | ||
"bndmk (%eax,%edx), %bnd2\n\t" | ||
"mov $64, %eax\n\t" | ||
"mov $9, %edx\n\t" | ||
"bndmk (%eax,%edx), %bnd3\n\t" | ||
"bndstx %bnd3, (%eax)\n\t" | ||
"nop\n\t"); | ||
#endif | ||
asm("nop\n\t"); // Set a break point here. | ||
|
||
return 0; | ||
} |
2 changes: 1 addition & 1 deletion
2
...te/test/functionalities/register/Makefile → ...lities/register/register_command/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
LEVEL = ../../make | ||
LEVEL = ../../../make | ||
|
||
CXX_SOURCES := main.cpp a.cpp | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.