1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 //// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 //// See https://llvm.org/LICENSE.txt for license information.
5 //// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 ////===----------------------------------------------------------------------===//
14 main(int argc, char const *argv[])
16 // PR_MPX_ENABLE_MANAGEMENT won't be defined on linux kernel versions below 3.19
17 #ifndef PR_MPX_ENABLE_MANAGEMENT
21 // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
22 if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
25 // Run Intel(R) MPX test code.
26 #if defined(__x86_64__)
27 asm("mov $16, %rax\n\t"
29 "bndmk (%rax,%rdx), %bnd0\n\t"
32 "bndmk (%rax,%rdx), %bnd1\n\t"
35 "bndmk (%rax,%rdx), %bnd2\n\t"
38 "bndmk (%rax,%rdx), %bnd3\n\t"
39 "bndstx %bnd3, (%rax) \n\t"
43 asm("mov $16, %eax\n\t"
45 "bndmk (%eax,%edx), %bnd0\n\t"
48 "bndmk (%eax,%edx), %bnd1\n\t"
51 "bndmk (%eax,%edx), %bnd2\n\t"
54 "bndmk (%eax,%edx), %bnd3\n\t"
55 "bndstx %bnd3, (%eax)\n\t"
58 asm("nop\n\t"); // Set a break point here.