aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Hansen <dave.hansen@linux.intel.com>2014-12-12 13:38:35 -0500
committerThomas Gleixner <tglx@linutronix.de>2014-12-15 09:58:57 -0500
commit010e593b140decdc16bb0c1c754b07b1fccb6999 (patch)
tree960306184273c7ffd4480548b7631fa95e940b5d
parente10abb2f770eeb673d23c19980216b0fb62b4f50 (diff)
x86, mpx: Update documentation
I was writing some MPX test programs and realized that the current design makes it tricky. I did something like: bndcfgu |= bnd_dir | BNDCFGU_ENABLE; xrstor(); printf("xrstor done"); // #BR bounds exception here prctl(MPX_ENABLE_MANAGEMENT); and then compiled the app with "-fcheck-pointer-bounds -mmpx" to enable MPX instrumentation. The problem is that there is MPX instrumentation inserted in to the area of the printf(). The kernel gets a bounds exception and since management isn't yet enabled, it SIGSEGV's. Add a bit to the documentation to explain a way around this and where apps need to be careful. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: Dave Hansen <dave@sr71.net> Link: http://lkml.kernel.org/r/20141212183835.8C581B3E@viggo.jf.intel.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--Documentation/x86/intel_mpx.txt12
1 files changed, 9 insertions, 3 deletions
diff --git a/Documentation/x86/intel_mpx.txt b/Documentation/x86/intel_mpx.txt
index 4472ed2ad921..6ca6e2bd9ae9 100644
--- a/Documentation/x86/intel_mpx.txt
+++ b/Documentation/x86/intel_mpx.txt
@@ -30,9 +30,15 @@ is how we expect the compiler, application and kernel to work together.
30 instrumentation as well as some setup code called early after the app 30 instrumentation as well as some setup code called early after the app
31 starts. New instruction prefixes are noops for old CPUs. 31 starts. New instruction prefixes are noops for old CPUs.
322) That setup code allocates (virtual) space for the "bounds directory", 322) That setup code allocates (virtual) space for the "bounds directory",
33 points the "bndcfgu" register to the directory and notifies the kernel 33 points the "bndcfgu" register to the directory (must also set the valid
34 (via the new prctl(PR_MPX_ENABLE_MANAGEMENT)) that the app will be using 34 bit) and notifies the kernel (via the new prctl(PR_MPX_ENABLE_MANAGEMENT))
35 MPX. 35 that the app will be using MPX. The app must be careful not to access
36 the bounds tables between the time when it populates "bndcfgu" and
37 when it calls the prctl(). This might be hard to guarantee if the app
38 is compiled with MPX. You can add "__attribute__((bnd_legacy))" to
39 the function to disable MPX instrumentation to help guarantee this.
40 Also be careful not to call out to any other code which might be
41 MPX-instrumented.
363) The kernel detects that the CPU has MPX, allows the new prctl() to 423) The kernel detects that the CPU has MPX, allows the new prctl() to
37 succeed, and notes the location of the bounds directory. Userspace is 43 succeed, and notes the location of the bounds directory. Userspace is
38 expected to keep the bounds directory at that locationWe note it 44 expected to keep the bounds directory at that locationWe note it