[lldb][test] Remove Intel MPX tests
Intel MPX failed to gain wide adoption and has been deprecated for a while. GCC 9.1 removed Intel MPX support. Linux kernel removed MPX in 2019. glibc 2.35 will remove the support.
This commit is contained in:
parent
aa71f487f3
commit
1b81581fee
|
@ -1,5 +0,0 @@
|
||||||
CXX_SOURCES := main.cpp
|
|
||||||
|
|
||||||
CFLAGS_EXTRAS := -mmpx -fcheck-pointer-bounds -fuse-ld=bfd
|
|
||||||
|
|
||||||
include Makefile.rules
|
|
|
@ -1,61 +0,0 @@
|
||||||
"""
|
|
||||||
Test the Intel(R) MPX registers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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__)
|
|
||||||
|
|
||||||
@skipIf(compiler="clang")
|
|
||||||
@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 Intel(R) MPX registers with example code."""
|
|
||||||
self.build()
|
|
||||||
self.mpx_registers_with_example_code()
|
|
||||||
|
|
||||||
def mpx_registers_with_example_code(self):
|
|
||||||
"""Test Intel(R) MPX registers after running example code."""
|
|
||||||
self.line = line_number('main.cpp', '// Set a break point here.')
|
|
||||||
|
|
||||||
exe = self.getBuildArtifact("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("Intel(R) MPX is not supported.")
|
|
||||||
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}'])
|
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
//
|
|
||||||
|
|
||||||
#include <cpuid.h>
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// Run Intel(R) 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;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
CXX_SOURCES := main.cpp
|
|
||||||
|
|
||||||
CFLAGS_EXTRAS := -mmpx -fcheck-pointer-bounds -fuse-ld=bfd
|
|
||||||
|
|
||||||
include Makefile.rules
|
|
|
@ -1,52 +0,0 @@
|
||||||
"""
|
|
||||||
Test the Intel(R) MPX bound violation signal.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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__)
|
|
||||||
|
|
||||||
@skipIf(compiler="clang")
|
|
||||||
@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_boundary_violation(self):
|
|
||||||
"""Test Intel(R) MPX bound violation signal."""
|
|
||||||
self.build()
|
|
||||||
self.mpx_boundary_violation()
|
|
||||||
|
|
||||||
def mpx_boundary_violation(self):
|
|
||||||
exe = self.getBuildArtifact("a.out")
|
|
||||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
|
||||||
|
|
||||||
self.runCmd("run", RUN_SUCCEEDED)
|
|
||||||
|
|
||||||
target = self.dbg.GetSelectedTarget()
|
|
||||||
process = target.GetProcess()
|
|
||||||
|
|
||||||
if (process.GetState() == lldb.eStateExited):
|
|
||||||
self.skipTest("Intel(R) MPX is not supported.")
|
|
||||||
|
|
||||||
if (process.GetState() == lldb.eStateStopped):
|
|
||||||
self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
|
|
||||||
substrs = ['stop reason = signal SIGSEGV: upper bound violation',
|
|
||||||
'fault address:', 'lower bound:', 'upper bound:'])
|
|
||||||
|
|
||||||
self.runCmd("continue")
|
|
||||||
|
|
||||||
if (process.GetState() == lldb.eStateStopped):
|
|
||||||
self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
|
|
||||||
substrs = ['stop reason = signal SIGSEGV: lower bound violation',
|
|
||||||
'fault address:', 'lower bound:', 'upper bound:'])
|
|
||||||
|
|
||||||
self.runCmd("continue")
|
|
||||||
self.assertEquals(process.GetState(), lldb.eStateExited,
|
|
||||||
PROCESS_EXITED)
|
|
|
@ -1,37 +0,0 @@
|
||||||
//
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <sys/prctl.h>
|
|
||||||
|
|
||||||
static void violate_upper_bound(int *ptr, int size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
i = *(ptr + size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void violate_lower_bound (int *ptr, int size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
i = *(ptr - size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
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;
|
|
||||||
|
|
||||||
violate_upper_bound(array, 5);
|
|
||||||
violate_lower_bound(array, 5);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
CXX_SOURCES := main.cpp
|
|
||||||
|
|
||||||
include Makefile.rules
|
|
|
@ -1,69 +0,0 @@
|
||||||
"""
|
|
||||||
Test Intel(R) MPX registers do not get overwritten by AVX data.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import lldb
|
|
||||||
from lldbsuite.test.decorators import *
|
|
||||||
from lldbsuite.test.lldbtest import *
|
|
||||||
from lldbsuite.test import lldbutil
|
|
||||||
|
|
||||||
|
|
||||||
class MPXOffsetIntersectionTestCase(TestBase):
|
|
||||||
|
|
||||||
mydir = TestBase.compute_mydir(__file__)
|
|
||||||
|
|
||||||
AVX_REGS = ('ymm' + str(i) for i in range(16))
|
|
||||||
YMM_VALUE = '{' + ' '.join(('0x00' for _ in range(32))) + '}'
|
|
||||||
|
|
||||||
MPX_REGULAR_REGS = ('bnd0', 'bnd1', 'bnd2', 'bnd3')
|
|
||||||
MPX_CONFIG_REGS = ('bndcfgu', 'bndstatus')
|
|
||||||
BND_VALUE = '{' + ' '.join(('0xff' for _ in range(16))) + '}'
|
|
||||||
|
|
||||||
@skipIf(oslist=no_match(['linux']))
|
|
||||||
@skipIf(archs=no_match(['x86_64']))
|
|
||||||
def test_mpx_registers_offset_intersection(self):
|
|
||||||
"""Test if AVX data does not overwrite MPX values."""
|
|
||||||
self.build()
|
|
||||||
self.mpx_registers_offset_intersection()
|
|
||||||
|
|
||||||
def mpx_registers_offset_intersection(self):
|
|
||||||
exe = self.getBuildArtifact('a.out')
|
|
||||||
self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)
|
|
||||||
self.runCmd('run', RUN_SUCCEEDED)
|
|
||||||
target = self.dbg.GetSelectedTarget()
|
|
||||||
process = target.GetProcess()
|
|
||||||
thread = process.GetThreadAtIndex(0)
|
|
||||||
currentFrame = thread.GetFrameAtIndex(0)
|
|
||||||
|
|
||||||
has_avx = False
|
|
||||||
has_mpx = False
|
|
||||||
for registerSet in currentFrame.GetRegisters():
|
|
||||||
if 'advanced vector extensions' in registerSet.GetName().lower():
|
|
||||||
has_avx = True
|
|
||||||
if 'memory protection extension' in registerSet.GetName().lower():
|
|
||||||
has_mpx = True
|
|
||||||
if not (has_avx and has_mpx):
|
|
||||||
self.skipTest('Both AVX and MPX registers must be supported.')
|
|
||||||
|
|
||||||
for reg in self.AVX_REGS:
|
|
||||||
self.runCmd('register write ' + reg + " '" + self.YMM_VALUE + " '")
|
|
||||||
for reg in self.MPX_REGULAR_REGS + self.MPX_CONFIG_REGS:
|
|
||||||
self.runCmd('register write ' + reg + " '" + self.BND_VALUE + " '")
|
|
||||||
|
|
||||||
self.verify_mpx()
|
|
||||||
self.verify_avx()
|
|
||||||
self.verify_mpx()
|
|
||||||
|
|
||||||
def verify_mpx(self):
|
|
||||||
for reg in self.MPX_REGULAR_REGS:
|
|
||||||
self.expect('register read ' + reg,
|
|
||||||
substrs = [reg + ' = {0xffffffffffffffff 0xffffffffffffffff}'])
|
|
||||||
for reg in self.MPX_CONFIG_REGS:
|
|
||||||
self.expect('register read ' + reg,
|
|
||||||
substrs = [reg + ' = {0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'])
|
|
||||||
|
|
||||||
def verify_avx(self):
|
|
||||||
for reg in self.AVX_REGS:
|
|
||||||
self.expect('register read ' + reg, substrs = [reg + ' = ' + self.YMM_VALUE])
|
|
|
@ -1,6 +0,0 @@
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
asm volatile("int3");
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue