Skip to contentSkip to conversation

x86: remove Intel MPX

RFC New Dave Hansen 2 participants 7 messages Jan 4, 2019

Subsystems (8)
Memory management x86 VFS Kselftest +4 more subsystems
lore
Share & tools
lore

Dave Hansen

author maintainer
#0 lore raw

Here's a second attempt at MPX removal. The first one was not friendly to KVM live migration. We should probably apply the first two patches (at least) for 4.20+1.

--

Unfortunately, GCC 9.1 is expected to be be released without support for MPX. This means that there was only a relatively small window where folks could have ever used MPX. It failed to gain wide adoption in the industry, and Linux was the only mainstream OS to ever support it widely.

Support for the feature may also disappear on future processors.

The benefits of keeping the feature in the tree is not worth the ongoing maintenance cost. This is an incremental, bisectable, set that removes MPX bit by bit. The only MPX code left in the kernel is the XSAVE state management which is currently still needed for guests that might use MPX. Keeping this code prevents breaking live migration between kernels which have MPX removed versus present.

It was a fun run, but it's time for it to go. Adios, MPX!

Cc Dave Hansen <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Andrew Morton <[email protected]>
author maintainer
#1 lore raw

PATCH 1/5 x86/mpx: remove MPX APIs

From: Dave Hansen <[email protected]>

MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).

The first thing we need to do is remove the userspace-visible ABIs so that applications will stop using it. The most visible one are the enable/disable prctl()s. Remove them first.

This is the most minimal and least invasive patch needed to start removing MPX.

---
 include/uapi/linux/prctl.h |  2 +-
 kernel/sys.c               | 16 ++--------------
 2 files changed, 3 insertions(+), 15 deletions(-)
include/uapi/linux/prctl.h +1 -1
index b4875a9..78fcee3 100644
@@ -181,7 +181,7 @@ struct prctl_mm_map {
 #define PR_GET_THP_DISABLE	42
 
 /*
- * Tell the kernel to start/stop helping userspace manage bounds tables.
+ * No longer implemented, but left here to ensure the numbers stay reserved:
  */
 #define PR_MPX_ENABLE_MANAGEMENT  43
 #define PR_MPX_DISABLE_MANAGEMENT 44
kernel/sys.c +2 -14
index a48cbf1..5fd7991 100644
@@ -103,12 +103,6 @@
 #ifndef SET_TSC_CTL
 # define SET_TSC_CTL(a)		(-EINVAL)
 #endif
-#ifndef MPX_ENABLE_MANAGEMENT
-# define MPX_ENABLE_MANAGEMENT()	(-EINVAL)
-#endif
-#ifndef MPX_DISABLE_MANAGEMENT
-# define MPX_DISABLE_MANAGEMENT()	(-EINVAL)
-#endif
 #ifndef GET_FP_MODE
 # define GET_FP_MODE(a)		(-EINVAL)
 #endif
@@ -2448,15 +2442,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		up_write(&me->mm->mmap_sem);
 		break;
 	case PR_MPX_ENABLE_MANAGEMENT:
-		if (arg2 || arg3 || arg4 || arg5)
-			return -EINVAL;
-		error = MPX_ENABLE_MANAGEMENT();
-		break;
 	case PR_MPX_DISABLE_MANAGEMENT:
-		if (arg2 || arg3 || arg4 || arg5)
-			return -EINVAL;
-		error = MPX_DISABLE_MANAGEMENT();
-		break;
+		/* No longer implemented: */
+		return -EINVAL;
 	case PR_SET_FP_MODE:
 		error = SET_FP_MODE(me, arg2);
 		break;
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH 2/5 x86/mpx: remove bounds exception code

In reply to Dave Hansen

From: Dave Hansen <[email protected]>

MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).

Remove the other user-visible ABI: signal handling. This code should basically have been inactive after the prctl()s were removed, but there may be some small ABI remnants from this code. Remove it.

This, along with the prctl() removal is probably what we should apply first.

---
 arch/x86/kernel/traps.c | 74 -------------------------------------------------
 1 file changed, 74 deletions(-)
arch/x86/kernel/traps.c +0 -74
index 9b7c4ca..85cccad 100644
@@ -57,8 +57,6 @@
 #include <asm/mach_traps.h>
 #include <asm/alternative.h>
 #include <asm/fpu/xstate.h>
-#include <asm/trace/mpx.h>
-#include <asm/mpx.h>
 #include <asm/vm86.h>
 #include <asm/umip.h>
 
@@ -433,8 +431,6 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
 
 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 {
-	const struct mpx_bndcsr *bndcsr;
-
 	RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
 	if (notify_die(DIE_TRAP, "bounds", regs, error_code,
 			X86_TRAP_BR, SIGSEGV) == NOTIFY_STOP)
@@ -444,76 +440,6 @@ dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 	if (!user_mode(regs))
 		die("bounds", regs, error_code);
 
-	if (!cpu_feature_enabled(X86_FEATURE_MPX)) {
-		/* The exception is not from Intel MPX */
-		goto exit_trap;
-	}
-
-	/*
-	 * We need to look at BNDSTATUS to resolve this exception.
-	 * A NULL here might mean that it is in its 'init state',
-	 * which is all zeros which indicates MPX was not
-	 * responsible for the exception.
-	 */
-	bndcsr = get_xsave_field_ptr(XFEATURE_MASK_BNDCSR);
-	if (!bndcsr)
-		goto exit_trap;
-
-	trace_bounds_exception_mpx(bndcsr);
-	/*
-	 * The error code field of the BNDSTATUS register communicates status
-	 * information of a bound range exception #BR or operation involving
-	 * bound directory.
-	 */
-	switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
-	case 2:	/* Bound directory has invalid entry. */
-		if (mpx_handle_bd_fault())
-			goto exit_trap;
-		break; /* Success, it was handled */
-	case 1: /* Bound violation. */
-	{
-		struct task_struct *tsk = current;
-		struct mpx_fault_info mpx;
-
-		if (mpx_fault_info(&mpx, regs)) {
-			/*
-			 * We failed to decode the MPX instruction.  Act as if
-			 * the exception was not caused by MPX.
-			 */
-			goto exit_trap;
-		}
-		/*
-		 * Success, we decoded the instruction and retrieved
-		 * an 'mpx' containing the address being accessed
-		 * which caused the exception.  This information
-		 * allows and application to possibly handle the
-		 * #BR exception itself.
-		 */
-		if (!do_trap_no_signal(tsk, X86_TRAP_BR, "bounds", regs,
-				       error_code))
-			break;
-
-		show_signal(tsk, SIGSEGV, "trap ", "bounds", regs, error_code);
-
-		force_sig_bnderr(mpx.addr, mpx.lower, mpx.upper);
-		break;
-	}
-	case 0: /* No exception caused by Intel MPX operations. */
-		goto exit_trap;
-	default:
-		die("bounds", regs, error_code);
-	}
-
-	return;
-
-exit_trap:
-	/*
-	 * This path out is for all the cases where we could not
-	 * handle the exception in some way (like allocating a
-	 * table or telling userspace about it.  We will also end
-	 * up here if the kernel has MPX turned off at compile
-	 * time..
-	 */
 	do_trap(X86_TRAP_BR, SIGSEGV, "bounds", regs, error_code, 0, NULL);
 }
 
Signature · 1 line
2.7.4
author maintainer
#3 lore raw

PATCH 3/5 mm: remove MPX hooks from generic code

In reply to Dave Hansen

From: Dave Hansen <[email protected]>

MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).

There are two hooks into the generic mm code that MPX uses: one for ~munmap() and the other at execve() time. Remove them, eliminating MPX from generic mm code.

---
 arch/x86/include/asm/mmu_context.h | 31 -------------------------------
 fs/exec.c                          |  1 -
 include/asm-generic/mm_hooks.h     | 11 -----------
 mm/mmap.c                          |  6 ------
 4 files changed, 49 deletions(-)
arch/x86/include/asm/mmu_context.h +0 -31
index 0ca5061..61363e7 100644
@@ -12,7 +12,6 @@
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/paravirt.h>
-#include <asm/mpx.h>
 
 extern atomic64_t last_mm_ctx_id;
 
@@ -253,36 +252,6 @@ static inline bool is_64bit_mm(struct mm_struct *mm)
 }
 #endif
 
-static inline void arch_bprm_mm_init(struct mm_struct *mm,
-		struct vm_area_struct *vma)
-{
-	mpx_mm_init(mm);
-}
-
-static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
-			      unsigned long start, unsigned long end)
-{
-	/*
-	 * mpx_notify_unmap() goes and reads a rarely-hot
-	 * cacheline in the mm_struct.  That can be expensive
-	 * enough to be seen in profiles.
-	 *
-	 * The mpx_notify_unmap() call and its contents have been
-	 * observed to affect munmap() performance on hardware
-	 * where MPX is not present.
-	 *
-	 * The unlikely() optimizes for the fast case: no MPX
-	 * in the CPU, or no MPX use in the process.  Even if
-	 * we get this wrong (in the unlikely event that MPX
-	 * is widely enabled on some system) the overhead of
-	 * MPX itself (reading bounds tables) is expected to
-	 * overwhelm the overhead of getting this unlikely()
-	 * consistently wrong.
-	 */
-	if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX)))
-		mpx_notify_unmap(mm, vma, start, end);
-}
-
 /*
  * We only want to enforce protection keys on the current process
  * because we effectively have no access to PKRU for other
fs/exec.c +0 -1
index fc281b7..cb99ea5 100644
@@ -317,7 +317,6 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
 		goto err;
 
 	mm->stack_vm = mm->total_vm = 1;
-	arch_bprm_mm_init(mm, vma);
 	up_write(&mm->mmap_sem);
 	bprm->p = vma->vm_end - sizeof(void *);
 	return 0;
include/asm-generic/mm_hooks.h +0 -11
index 8ac4e68..40038d0 100644
@@ -17,17 +17,6 @@ static inline void arch_exit_mmap(struct mm_struct *mm)
 {
 }
 
-static inline void arch_unmap(struct mm_struct *mm,
-			struct vm_area_struct *vma,
-			unsigned long start, unsigned long end)
-{
-}
-
-static inline void arch_bprm_mm_init(struct mm_struct *mm,
-				     struct vm_area_struct *vma)
-{
-}
-
 static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
 		bool write, bool execute, bool foreign)
 {
mm/mmap.c +0 -6
index f901065..ca9f43c 100644
@@ -2813,12 +2813,6 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
 	/* Detach vmas from rbtree */
 	detach_vmas_to_be_unmapped(mm, vma, prev, end);
 
-	/*
-	 * mpx unmap needs to be called with mmap_sem held for write.
-	 * It is safe to call it before unmap_region().
-	 */
-	arch_unmap(mm, vma, start, end);
-
 	if (downgrade)
 		downgrade_write(&mm->mmap_sem);
 
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH 3/5] mm: remove MPX hooks from generic code

I love your patch! Yet something to improve:

Hi Dave,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20 next-20190103]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Dave-Hansen/x86-mpx-remove-MPX-APIs/20190105-051028
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

Note: the linux-review/Dave-Hansen/x86-mpx-remove-MPX-APIs/20190105-051028 HEAD 34ce15ccc190201bc8c062e1559df2c1864902ef builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

arch/x86/kernel/setup.c: In function 'setup_arch':

>> arch/x86/kernel/setup.c:927:2: error: implicit declaration of function 'mpx_mm_init'; did you mean 'mem_init'? [-Werror=implicit-function-declaration]
     mpx_mm_init(&init_mm);
     ^~~~~~~~~~~
     mem_init

cc1: some warnings being treated as errors

vim +927 arch/x86/kernel/setup.c

7465252ea arch/x86/kernel/setup_32.c Yinghai Lu          2008-06-23  911  
42bbdb43b arch/x86/kernel/setup.c    Thomas Gleixner     2009-08-20  912  	x86_init.oem.arch_setup();
2215e69d2 arch/x86/kernel/setup_32.c Huang, Ying         2008-01-30  913  
419afdf53 arch/x86/kernel/setup.c    Bjorn Helgaas       2010-10-26  914  	iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
103e20630 arch/x86/kernel/setup.c    Ingo Molnar         2017-01-28  915  	e820__memory_setup();
28bb22379 arch/x86/kernel/setup.c    Yinghai Lu          2008-06-30  916  	parse_setup_data();
28bb22379 arch/x86/kernel/setup.c    Yinghai Lu          2008-06-30  917  
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  918  	copy_edd();
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  919  
30c826451 arch/x86/kernel/setup_32.c H. Peter Anvin      2007-10-15  920  	if (!boot_params.hdr.root_flags)
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  921  		root_mountflags &= ~MS_RDONLY;
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  922  	init_mm.start_code = (unsigned long) _text;
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  923  	init_mm.end_code = (unsigned long) _etext;
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  924  	init_mm.end_data = (unsigned long) _edata;
93dbda7cb arch/x86/kernel/setup.c    Jeremy Fitzhardinge 2009-02-26  925  	init_mm.brk = _brk_end;
fe3d197f8 arch/x86/kernel/setup.c    Dave Hansen         2014-11-14  926  
fe3d197f8 arch/x86/kernel/setup.c    Dave Hansen         2014-11-14 @927  	mpx_mm_init(&init_mm);
^1da177e4 arch/i386/kernel/setup.c   Linus Torvalds      2005-04-16  928  
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  929  	code_resource.start = __pa_symbol(_text);
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  930  	code_resource.end = __pa_symbol(_etext)-1;
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  931  	data_resource.start = __pa_symbol(_etext);
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  932  	data_resource.end = __pa_symbol(_edata)-1;
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  933  	bss_resource.start = __pa_symbol(__bss_start);
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  934  	bss_resource.end = __pa_symbol(__bss_stop)-1;
4046d6e81 arch/x86/kernel/setup.c    Linus Torvalds      2016-04-14  935  

:::::: The code at line 927 was first introduced by commit
:::::: fe3d197f84319d3bce379a9c0dc17b1f48ad358c x86, mpx: On-demand kernel allocation of bounds tables

:::::: TO: Dave Hansen <[email protected]> :::::: CC: Thomas Gleixner <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#5 lore raw

PATCH 4/5 x86/mpx: remove build infratsructure

In reply to Dave Hansen

From: Dave Hansen <[email protected]>

MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).

Remove the Kconfig option and the Makefile line. This makes arch/x86/mm/mpx.c and anything under an #ifdef for X86_INTEL_MPX dead code.

---
 arch/x86/Kconfig     | 28 ----------------------------
 arch/x86/mm/Makefile |  1 -
 2 files changed, 29 deletions(-)
arch/x86/Kconfig +0 -28
index e260460..b668833 100644
@@ -1880,34 +1880,6 @@ config X86_INTEL_UMIP
 	  specific cases in protected and virtual-8086 modes. Emulated
 	  results are dummy.
 
-config X86_INTEL_MPX
-	prompt "Intel MPX (Memory Protection Extensions)"
-	def_bool n
-	# Note: only available in 64-bit mode due to VMA flags shortage
-	depends on CPU_SUP_INTEL && X86_64
-	select ARCH_USES_HIGH_VMA_FLAGS
-	---help---
-	  MPX provides hardware features that can be used in
-	  conjunction with compiler-instrumented code to check
-	  memory references.  It is designed to detect buffer
-	  overflow or underflow bugs.
-
-	  This option enables running applications which are
-	  instrumented or otherwise use MPX.  It does not use MPX
-	  itself inside the kernel or to protect the kernel
-	  against bad memory references.
-
-	  Enabling this option will make the kernel larger:
-	  ~8k of kernel text and 36 bytes of data on a 64-bit
-	  defconfig.  It adds a long to the 'mm_struct' which
-	  will increase the kernel memory overhead of each
-	  process and adds some branches to paths used during
-	  exec() and munmap().
-
-	  For details, see Documentation/x86/intel_mpx.txt
-
-	  If unsure, say N.
-
 config X86_INTEL_MEMORY_PROTECTION_KEYS
 	prompt "Intel Memory Protection Keys"
 	def_bool y
arch/x86/mm/Makefile +0 -1
index 4b101dd..8cc3639 100644
@@ -45,7 +45,6 @@ obj-$(CONFIG_AMD_NUMA)		+= amdtopology.o
 obj-$(CONFIG_ACPI_NUMA)		+= srat.o
 obj-$(CONFIG_NUMA_EMU)		+= numa_emulation.o
 
-obj-$(CONFIG_X86_INTEL_MPX)			+= mpx.o
 obj-$(CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS)	+= pkeys.o
 obj-$(CONFIG_RANDOMIZE_MEMORY)			+= kaslr.o
 obj-$(CONFIG_PAGE_TABLE_ISOLATION)		+= pti.o
Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH 5/5 x86/mpx: remove MPX from arch/x86

In reply to Dave Hansen

From: Dave Hansen <[email protected]>

MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).

This removes all the remaining (dead at this point) MPX handling code remaining in the tree. The only remaining code is the XSAVE support for MPX state which is currently needd for KVM to handle VMs which might use MPX.

---
 arch/x86/include/asm/bugs.h                 |    6 -
 arch/x86/include/asm/disabled-features.h    |    8 +-
 arch/x86/include/asm/mmu.h                  |    4 -
 arch/x86/include/asm/mpx.h                  |  115 --
 arch/x86/include/asm/processor.h            |   18 -
 arch/x86/include/asm/trace/mpx.h            |  134 ---
 arch/x86/kernel/cpu/common.c                |   18 -
 arch/x86/kernel/cpu/intel.c                 |   37 -
 arch/x86/kernel/setup.c                     |    2 -
 arch/x86/kernel/sys_x86_64.c                |    9 -
 arch/x86/mm/hugetlbpage.c                   |    5 -
 arch/x86/mm/mpx.c                           |  936 ----------------
 tools/testing/selftests/x86/Makefile        |    2 +-
 tools/testing/selftests/x86/mpx-debug.h     |   15 -
 tools/testing/selftests/x86/mpx-dig.c       |  499 ---------
 tools/testing/selftests/x86/mpx-hw.h        |  124 --
 tools/testing/selftests/x86/mpx-mini-test.c | 1616 ---------------------------
 tools/testing/selftests/x86/mpx-mm.h        |   10 -
 18 files changed, 2 insertions(+), 3556 deletions(-)
 delete mode 100644 arch/x86/include/asm/mpx.h
 delete mode 100644 arch/x86/include/asm/trace/mpx.h
 delete mode 100644 arch/x86/mm/mpx.c
 delete mode 100644 tools/testing/selftests/x86/mpx-debug.h
 delete mode 100644 tools/testing/selftests/x86/mpx-dig.c
 delete mode 100644 tools/testing/selftests/x86/mpx-hw.h
 delete mode 100644 tools/testing/selftests/x86/mpx-mini-test.c
 delete mode 100644 tools/testing/selftests/x86/mpx-mm.h
arch/x86/include/asm/bugs.h +0 -6
index 542509b..9fa43ab 100644
@@ -6,12 +6,6 @@
 
 extern void check_bugs(void);
 
-#if defined(CONFIG_CPU_SUP_INTEL)
-void check_mpx_erratum(struct cpuinfo_x86 *c);
-#else
-static inline void check_mpx_erratum(struct cpuinfo_x86 *c) {}
-#endif
-
 #if defined(CONFIG_CPU_SUP_INTEL) && defined(CONFIG_X86_32)
 int ppro_with_ram_bug(void);
 #else
arch/x86/include/asm/disabled-features.h +1 -7
index a5ea841..41d069f 100644
@@ -10,12 +10,6 @@
  * cpu_feature_enabled().
  */
 
-#ifdef CONFIG_X86_INTEL_MPX
-# define DISABLE_MPX	0
-#else
-# define DISABLE_MPX	(1<<(X86_FEATURE_MPX & 31))
-#endif
-
 #ifdef CONFIG_X86_SMAP
 # define DISABLE_SMAP	0
 #else
@@ -74,7 +68,7 @@
 #define DISABLED_MASK6	0
 #define DISABLED_MASK7	(DISABLE_PTI)
 #define DISABLED_MASK8	0
-#define DISABLED_MASK9	(DISABLE_MPX|DISABLE_SMAP)
+#define DISABLED_MASK9	(DISABLE_SMAP)
 #define DISABLED_MASK10	0
 #define DISABLED_MASK11	0
 #define DISABLED_MASK12	0
arch/x86/include/asm/mmu.h +0 -4
index 5ff3e8a..beb8aa5 100644
@@ -50,10 +50,6 @@ typedef struct {
 	u16 pkey_allocation_map;
 	s16 execute_only_pkey;
 #endif
-#ifdef CONFIG_X86_INTEL_MPX
-	/* address of the bounds directory */
-	void __user *bd_addr;
-#endif
 } mm_context_t;
 
 #define INIT_MM_CONTEXT(mm)						\
arch/x86/include/asm/mpx.h deleted +0 -115

115 lines not on this page · raw message

arch/x86/include/asm/processor.h +0 -18
index 3305143..32a68aa 100644
@@ -925,24 +925,6 @@ extern int set_tsc_mode(unsigned int val);
 
 DECLARE_PER_CPU(u64, msr_misc_features_shadow);
 
-/* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT()	mpx_enable_management()
-#define MPX_DISABLE_MANAGEMENT()	mpx_disable_management()
-
-#ifdef CONFIG_X86_INTEL_MPX
-extern int mpx_enable_management(void);
-extern int mpx_disable_management(void);
-#else
-static inline int mpx_enable_management(void)
-{
-	return -EINVAL;
-}
-static inline int mpx_disable_management(void)
-{
-	return -EINVAL;
-}
-#endif /* CONFIG_X86_INTEL_MPX */
-
 #ifdef CONFIG_CPU_SUP_AMD
 extern u16 amd_get_nb_id(int cpu);
 extern u32 amd_get_nodes_per_socket(void);
arch/x86/include/asm/trace/mpx.h deleted +0 -134

134 lines not on this page · raw message

arch/x86/kernel/cpu/common.c +0 -18
index cb28e98..98032ab 100644
@@ -164,22 +164,6 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
 } };
 EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
 
-static int __init x86_mpx_setup(char *s)
-{
-	/* require an exact match without trailing characters */
-	if (strlen(s))
-		return 0;
-
-	/* do not emit a message if the feature is not present */
-	if (!boot_cpu_has(X86_FEATURE_MPX))
-		return 1;
-
-	setup_clear_cpu_cap(X86_FEATURE_MPX);
-	pr_info("nompx: Intel Memory Protection Extensions (MPX) disabled\n");
-	return 1;
-}
-__setup("nompx", x86_mpx_setup);
-
 #ifdef CONFIG_X86_64
 static int __init x86_nopcid_setup(char *s)
 {
@@ -306,8 +290,6 @@ static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
 static __init int setup_disable_smep(char *arg)
 {
 	setup_clear_cpu_cap(X86_FEATURE_SMEP);
-	/* Check for things that depend on SMEP being enabled: */
-	check_mpx_erratum(&boot_cpu_data);
 	return 1;
 }
 __setup("nosmep", setup_disable_smep);
arch/x86/kernel/cpu/intel.c +0 -37
index fc3c07f..057a8d6 100644
@@ -31,41 +31,6 @@
 #include <asm/apic.h>
 #endif
 
-/*
- * Just in case our CPU detection goes bad, or you have a weird system,
- * allow a way to override the automatic disabling of MPX.
- */
-static int forcempx;
-
-static int __init forcempx_setup(char *__unused)
-{
-	forcempx = 1;
-
-	return 1;
-}
-__setup("intel-skd-046-workaround=disable", forcempx_setup);
-
-void check_mpx_erratum(struct cpuinfo_x86 *c)
-{
-	if (forcempx)
-		return;
-	/*
-	 * Turn off the MPX feature on CPUs where SMEP is not
-	 * available or disabled.
-	 *
-	 * Works around Intel Erratum SKD046: "Branch Instructions
-	 * May Initialize MPX Bound Registers Incorrectly".
-	 *
-	 * This might falsely disable MPX on systems without
-	 * SMEP, like Atom processors without SMEP.  But there
-	 * is no such hardware known at the moment.
-	 */
-	if (cpu_has(c, X86_FEATURE_MPX) && !cpu_has(c, X86_FEATURE_SMEP)) {
-		setup_clear_cpu_cap(X86_FEATURE_MPX);
-		pr_warn("x86/mpx: Disabling MPX since SMEP not present\n");
-	}
-}
-
 static bool ring3mwait_disabled __read_mostly;
 
 static int __init ring3mwait_disable(char *__unused)
@@ -303,8 +268,6 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 			c->x86_coreid_bits = get_count_order((ebx >> 16) & 0xff);
 	}
 
-	check_mpx_erratum(c);
-
 	/*
 	 * Get the number of SMT siblings early from the extended topology
 	 * leaf, if available. Otherwise try the legacy SMT detection.
arch/x86/kernel/setup.c +0 -2
index d494b9b..16d6ae8 100644
@@ -924,8 +924,6 @@ void __init setup_arch(char **cmdline_p)
 	init_mm.end_data = (unsigned long) _edata;
 	init_mm.brk = _brk_end;
 
-	mpx_mm_init(&init_mm);
-
 	code_resource.start = __pa_symbol(_text);
 	code_resource.end = __pa_symbol(_etext)-1;
 	data_resource.start = __pa_symbol(_etext);
arch/x86/kernel/sys_x86_64.c +0 -9
index f7476ce..ca3c11a 100644
@@ -22,7 +22,6 @@
 #include <asm/elf.h>
 #include <asm/ia32.h>
 #include <asm/syscalls.h>
-#include <asm/mpx.h>
 
 /*
  * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
@@ -137,10 +136,6 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	struct vm_unmapped_area_info info;
 	unsigned long begin, end;
 
-	addr = mpx_unmapped_area_check(addr, len, flags);
-	if (IS_ERR_VALUE(addr))
-		return addr;
-
 	if (flags & MAP_FIXED)
 		return addr;
 
@@ -180,10 +175,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	unsigned long addr = addr0;
 	struct vm_unmapped_area_info info;
 
-	addr = mpx_unmapped_area_check(addr, len, flags);
-	if (IS_ERR_VALUE(addr))
-		return addr;
-
 	/* requested length too big for entire address space */
 	if (len > TASK_SIZE)
 		return -ENOMEM;
arch/x86/mm/hugetlbpage.c +0 -5
index 92e4c4b8..3948640 100644
@@ -19,7 +19,6 @@
 #include <asm/tlbflush.h>
 #include <asm/pgalloc.h>
 #include <asm/elf.h>
-#include <asm/mpx.h>
 
 #if 0	/* This is just for testing */
 struct page *
@@ -151,10 +150,6 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
 	if (len & ~huge_page_mask(h))
 		return -EINVAL;
 
-	addr = mpx_unmapped_area_check(addr, len, flags);
-	if (IS_ERR_VALUE(addr))
-		return addr;
-
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
arch/x86/mm/mpx.c deleted +0 -936

936 lines not on this page · raw message

tools/testing/selftests/x86/Makefile +1 -1
index 1865201..20fd613 100644
@@ -11,7 +11,7 @@ CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
 CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie)
 
 TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \
-			check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \
+			check_initial_reg_state sigreturn iopl ioperm \
 			protection_keys test_vdso test_vsyscall mov_ss_trap
 TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \
 			test_FCMOV test_FCOMI test_FISTTP \
tools/testing/selftests/x86/mpx-debug.h deleted +0 -15
deleted file mode 100644
index 7546eba..0000000
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _MPX_DEBUG_H
-#define _MPX_DEBUG_H
-
-#ifndef DEBUG_LEVEL
-#define DEBUG_LEVEL 0
-#endif
-#define dprintf_level(level, args...) do { if(level <= DEBUG_LEVEL) printf(args); } while(0)
-#define dprintf1(args...) dprintf_level(1, args)
-#define dprintf2(args...) dprintf_level(2, args)
-#define dprintf3(args...) dprintf_level(3, args)
-#define dprintf4(args...) dprintf_level(4, args)
-#define dprintf5(args...) dprintf_level(5, args)
-
-#endif /* _MPX_DEBUG_H */
tools/testing/selftests/x86/mpx-dig.c deleted +0 -499

499 lines not on this page · raw message

tools/testing/selftests/x86/mpx-hw.h deleted +0 -124

124 lines not on this page · raw message

tools/testing/selftests/x86/mpx-mini-test.c deleted +0 -1616

972 lines not on this page · raw message

tools/testing/selftests/x86/mpx-mm.h deleted +0 -10
deleted file mode 100644
index 6dbdd66..0000000

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.