Skip to contentSkip to conversation

x86: finish the MPX removal process

PATCH In review Dave Hansen 4 participants 10 messages Jan 23, 2020 – Jan 24, 2020

Subsystems (8)
Documentation x86 VFS PowerPC +4 more subsystems
lore
Share & tools
lore

Dave Hansen

author maintainer
#0 lore raw

cover x86: finish the MPX removal process

MPX requires recompiling applications, which requires compiler support. 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.

This set completes the process that we started during the 5.4 merge window.

I'd _rather_ this go in via the x86 tree, but I'm not picky. I could also send a pull request directly to Linus. This series is also available here (mostly for 0day to chew on):

	https://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-mpx.git/log/?h=mpx-remove-20200123

This posting is mostly an FYI in case any affected maintainers have any concerns.

 Documentation/x86/intel_mpx.rst            |  252 -------
 arch/x86/include/asm/mpx.h                 |  116 ---
 arch/x86/include/asm/trace/mpx.h           |  134 ----
 arch/x86/mm/mpx.c                          |  938 -----------------------------
 b/arch/powerpc/include/asm/mmu_context.h   |    5 
 b/arch/um/include/asm/mmu_context.h        |    5 
 b/arch/unicore32/include/asm/mmu_context.h |    5 
 b/arch/x86/Kconfig                         |   28 
 b/arch/x86/include/asm/bugs.h              |    6 
 b/arch/x86/include/asm/disabled-features.h |    8 
 b/arch/x86/include/asm/mmu.h               |    4 
 b/arch/x86/include/asm/mmu_context.h       |   26 
 b/arch/x86/include/asm/processor.h         |   18 
 b/arch/x86/kernel/alternative.c            |    1 
 b/arch/x86/kernel/cpu/common.c             |   18 
 b/arch/x86/kernel/cpu/intel.c              |   36 -
 b/arch/x86/kernel/setup.c                  |    2 
 b/arch/x86/kernel/sys_x86_64.c             |    9 
 b/arch/x86/kernel/traps.c                  |   74 --
 b/arch/x86/mm/Makefile                     |    1 
 b/arch/x86/mm/hugetlbpage.c                |    5 
 b/arch/x86/mm/mmap.c                       |    2 
 b/fs/exec.c                                |    1 
 b/include/asm-generic/mm_hooks.h           |    5 
 24 files changed, 2 insertions(+), 1697 deletions(-)
Cc Peter Zijlstra (Intel) <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Jeff Dike <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Anton Ivanov <[email protected]>
Cc Guan Xuetao <[email protected]>
author maintainer
#1 lore raw

PATCH 1/5 x86/alternatives: add missing insn.h include

From: Dave Hansen <[email protected]>

While testing my MPX removal series, Borislav noted compilation failure with an allnoconfig build.

Turned out to be a missing include of insn.h in alternative.c. With MPX, it got it implicitly from:

	asm/mmu_context.h -> asm/mpx.h -> asm/insn.h
Fixes c3d6324f841b ("x86/alternatives: Teach text_poke_bp() to emulate instructions")
Cc Peter Zijlstra (Intel) <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>

---

 b/arch/x86/kernel/alternative.c |    1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/alternative.c renamed from arch/x86/kernel/alternative.c~x86-alternatives-include +1 -0
diff -puN arch/x86/kernel/alternative.c~x86-alternatives-include arch/x86/kernel/alternative.c
@@ -23,6 +23,7 @@
 #include <asm/nmi.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
+#include <asm/insn.h>
 #include <asm/io.h>
 #include <asm/fixmap.h>
 

_

author maintainer
#2 lore raw

PATCH 2/5 x86/mpx: remove build infrastructure

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.

Cc Peter Zijlstra (Intel) <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>

---

 b/arch/x86/Kconfig     |   28 ----------------------------
 b/arch/x86/mm/Makefile |    1 -
 2 files changed, 29 deletions(-)
arch/x86/Kconfig renamed from arch/x86/Kconfig~mpx-remove-build +0 -28
diff -puN arch/x86/Kconfig~mpx-remove-build arch/x86/Kconfig
@@ -1896,34 +1896,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.rst
-
-	  If unsure, say N.
-
 config X86_INTEL_MEMORY_PROTECTION_KEYS
 	prompt "Intel Memory Protection Keys"
 	def_bool y
arch/x86/mm/Makefile renamed from arch/x86/mm/Makefile~mpx-remove-build +0 -1
diff -puN arch/x86/mm/Makefile~mpx-remove-build arch/x86/mm/Makefile
@@ -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

_

author maintainer
#3 lore raw

PATCH 3/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.

Cc Peter Zijlstra (Intel) <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>

---

 b/arch/x86/kernel/traps.c |   74 ----------------------------------------------
 1 file changed, 74 deletions(-)
arch/x86/kernel/traps.c renamed from arch/x86/kernel/traps.c~mpx-remove-do_bounds +0 -74
diff -puN arch/x86/kernel/traps.c~mpx-remove-do_bounds arch/x86/kernel/traps.c
@@ -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>
 
@@ -430,8 +428,6 @@ dotraplinkage void do_double_fault(struc
 
 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)
@@ -441,76 +437,6 @@ dotraplinkage void do_bounds(struct pt_r
 	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_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);
 }
 

_

author maintainer
#4 lore raw

PATCH 4/5 mm: remove arch_bprm_mm_init() hook

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).

arch_bprm_mm_init() is used at execve() time. The only non-stub implementation is on x86 for MPX. Remove the hook entirely from all architectures and generic code.

Cc Peter Zijlstra (Intel) <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Jeff Dike <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Anton Ivanov <[email protected]>
Cc Guan Xuetao <[email protected]>
Cc Andrew Morton <[email protected]>

---

 b/arch/powerpc/include/asm/mmu_context.h   |    5 -----
 b/arch/um/include/asm/mmu_context.h        |    5 -----
 b/arch/unicore32/include/asm/mmu_context.h |    5 -----
 b/arch/x86/include/asm/mmu_context.h       |    6 ------
 b/fs/exec.c                                |    1 -
 b/include/asm-generic/mm_hooks.h           |    5 -----
 6 files changed, 27 deletions(-)
arch/powerpc/include/asm/mmu_context.h renamed from arch/powerpc/include/asm/mmu_context.h~mpx-remove-generic-mm +0 -5
diff -puN arch/powerpc/include/asm/mmu_context.h~mpx-remove-generic-mm arch/powerpc/include/asm/mmu_context.h
@@ -238,11 +238,6 @@ static inline void arch_unmap(struct mm_
 		mm->context.vdso_base = 0;
 }
 
-static inline void arch_bprm_mm_init(struct mm_struct *mm,
-				     struct vm_area_struct *vma)
-{
-}
-
 #ifdef CONFIG_PPC_MEM_KEYS
 bool arch_vma_access_permitted(struct vm_area_struct *vma, bool write,
 			       bool execute, bool foreign);
arch/um/include/asm/mmu_context.h renamed from arch/um/include/asm/mmu_context.h~mpx-remove-generic-mm +0 -5
diff -puN arch/um/include/asm/mmu_context.h~mpx-remove-generic-mm arch/um/include/asm/mmu_context.h
@@ -25,11 +25,6 @@ static inline void arch_unmap(struct mm_
 			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)
 {
arch/unicore32/include/asm/mmu_context.h renamed from arch/unicore32/include/asm/mmu_context.h~mpx-remove-generic-mm +0 -5
diff -puN arch/unicore32/include/asm/mmu_context.h~mpx-remove-generic-mm arch/unicore32/include/asm/mmu_context.h
@@ -89,11 +89,6 @@ static inline void arch_unmap(struct mm_
 {
 }
 
-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)
 {
arch/x86/include/asm/mmu_context.h renamed from arch/x86/include/asm/mmu_context.h~mpx-remove-generic-mm +0 -6
diff -puN arch/x86/include/asm/mmu_context.h~mpx-remove-generic-mm arch/x86/include/asm/mmu_context.h
@@ -272,12 +272,6 @@ static inline bool is_64bit_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, unsigned long start,
 			      unsigned long end)
 {
fs/exec.c renamed from fs/exec.c~mpx-remove-generic-mm +0 -1
diff -puN fs/exec.c~mpx-remove-generic-mm fs/exec.c
@@ -273,7 +273,6 @@ static int __bprm_mm_init(struct linux_b
 		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 renamed from include/asm-generic/mm_hooks.h~mpx-remove-generic-mm +0 -5
diff -puN include/asm-generic/mm_hooks.h~mpx-remove-generic-mm include/asm-generic/mm_hooks.h
@@ -22,11 +22,6 @@ static inline void arch_unmap(struct mm_
 {
 }
 
-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)
 {

_

author maintainer
#5 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.

Cc Peter Zijlstra (Intel) <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>

---

 a/Documentation/x86/intel_mpx.rst          |  252 -------
 a/arch/x86/include/asm/mpx.h               |  116 ---
 a/arch/x86/include/asm/trace/mpx.h         |  134 ----
 a/arch/x86/mm/mpx.c                        |  938 -----------------------------
 b/arch/x86/include/asm/bugs.h              |    6 
 b/arch/x86/include/asm/disabled-features.h |    8 
 b/arch/x86/include/asm/mmu.h               |    4 
 b/arch/x86/include/asm/mmu_context.h       |   20 
 b/arch/x86/include/asm/processor.h         |   18 
 b/arch/x86/kernel/cpu/common.c             |   18 
 b/arch/x86/kernel/cpu/intel.c              |   36 -
 b/arch/x86/kernel/setup.c                  |    2 
 b/arch/x86/kernel/sys_x86_64.c             |    9 
 b/arch/x86/mm/hugetlbpage.c                |    5 
 b/arch/x86/mm/mmap.c                       |    2 
 15 files changed, 1 insertion(+), 1567 deletions(-)
arch/x86/include/asm/bugs.h renamed from arch/x86/include/asm/bugs.h~mpx-remove-x86 +0 -6
diff -puN arch/x86/include/asm/bugs.h~mpx-remove-x86 arch/x86/include/asm/bugs.h
@@ -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 renamed from arch/x86/include/asm/disabled-features.h~mpx-remove-x86 +1 -7
diff -puN arch/x86/include/asm/disabled-features.h~mpx-remove-x86 arch/x86/include/asm/disabled-features.h
@@ -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_context.h renamed from arch/x86/include/asm/mmu_context.h~mpx-remove-x86 +0 -20
diff -puN arch/x86/include/asm/mmu_context.h~mpx-remove-x86 arch/x86/include/asm/mmu_context.h
@@ -12,7 +12,6 @@
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/paravirt.h>
-#include <asm/mpx.h>
 #include <asm/debugreg.h>
 
 extern atomic64_t last_mm_ctx_id;
@@ -275,25 +274,6 @@ static inline bool is_64bit_mm(struct mm
 static inline void arch_unmap(struct mm_struct *mm, 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, start, end);
 }
 
 /*
arch/x86/include/asm/mmu.h renamed from arch/x86/include/asm/mmu.h~mpx-remove-x86 +0 -4
diff -puN arch/x86/include/asm/mmu.h~mpx-remove-x86 arch/x86/include/asm/mmu.h
@@ -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 -116

116 lines not on this page · raw message

arch/x86/include/asm/processor.h renamed from arch/x86/include/asm/processor.h~mpx-remove-x86 +0 -18
diff -puN arch/x86/include/asm/processor.h~mpx-remove-x86 arch/x86/include/asm/processor.h
@@ -915,24 +915,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 renamed from arch/x86/kernel/cpu/common.c~mpx-remove-x86 +0 -18
diff -puN arch/x86/kernel/cpu/common.c~mpx-remove-x86 arch/x86/kernel/cpu/common.c
@@ -165,22 +165,6 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_p
 } };
 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)
 {
@@ -307,8 +291,6 @@ static inline void squash_the_stupid_ser
 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 renamed from arch/x86/kernel/cpu/intel.c~mpx-remove-x86 +0 -36
diff -puN arch/x86/kernel/cpu/intel.c~mpx-remove-x86 arch/x86/kernel/cpu/intel.c
@@ -32,41 +32,6 @@
 #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");
-	}
-}
-
-/*
  * Processors which have self-snooping capability can handle conflicting
  * memory type across CPUs by snooping its own cache. However, there exists
  * CPU models in which having conflicting memory types still leads to
@@ -330,7 +295,6 @@ static void early_init_intel(struct cpui
 			c->x86_coreid_bits = get_count_order((ebx >> 16) & 0xff);
 	}
 
-	check_mpx_erratum(c);
 	check_memory_type_self_snoop_errata(c);
 
 	/*
arch/x86/kernel/setup.c renamed from arch/x86/kernel/setup.c~mpx-remove-x86 +0 -2
diff -puN arch/x86/kernel/setup.c~mpx-remove-x86 arch/x86/kernel/setup.c
@@ -947,8 +947,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 renamed from arch/x86/kernel/sys_x86_64.c~mpx-remove-x86 +0 -9
diff -puN arch/x86/kernel/sys_x86_64.c~mpx-remove-x86 arch/x86/kernel/sys_x86_64.c
@@ -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
 	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 fi
 	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 renamed from arch/x86/mm/hugetlbpage.c~mpx-remove-x86 +0 -5
diff -puN arch/x86/mm/hugetlbpage.c~mpx-remove-x86 arch/x86/mm/hugetlbpage.c
@@ -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 *f
 	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/mmap.c renamed from arch/x86/mm/mmap.c~mpx-remove-x86 +0 -2
diff -puN arch/x86/mm/mmap.c~mpx-remove-x86 arch/x86/mm/mmap.c
@@ -163,8 +163,6 @@ unsigned long get_mmap_base(int is_legac
 
 const char *arch_vma_name(struct vm_area_struct *vma)
 {
-	if (vma->vm_flags & VM_MPX)
-		return "[mpx]";
 	return NULL;
 }
 
arch/x86/mm/mpx.c deleted +0 -938

938 lines not on this page · raw message

Documentation/x86/intel_mpx.rst deleted +0 -252

252 lines not on this page · raw message

_

#6 lore raw
In reply to Dave Hansen

Lovely. Thanks. Patches obviously all look fine.

Quoted 3 lines · Dave Hansen

I'd _rather_ this go in via the x86 tree, but I'm not picky. I could also send a pull request directly to Linus.

I have no strong feelings either way. I'll happily pull this tree for the 5.6 merge window directly from you, or get it as part of one of the x86 -tip pull requests.

Up to you and the -tip maintainers, really. Thomas/Ingo/Borislav?

Linus

maintainer
#7 lore raw
Quoted 4 lines · Linus Torvalds
Quoted 2 lines · Dave Hansen

I'd _rather_ this go in via the x86 tree, but I'm not picky.

Any particular reason why?

I mean, I don't care a whole lot either - I just don't see the point, see below.

Quoted 5 lines

I have no strong feelings either way. I'll happily pull this tree for the 5.6 merge window directly from you, or get it as part of one of the x86 -tip pull requests.

Up to you and the -tip maintainers, really. Thomas/Ingo/Borislav?

My reasoning to suggest to go directly to you is that there's practically not a whole lotta sense to add a separate branch to tip, merge Dave's tree and have a merge commit of the mpx branch only which you then merge into your master.

Or I can apply each patch separately and then send you that branch so that there's no pointless merge commit in the history before you merge it but we get the same if you merge Dave's branch directly...

Oh and btw: I ran a bunch of build smoke tests today of the mpx removal branch with tip/master merged in and except for a trivial include fix, there were no issues.

But if someone points out a valid argument why it should go through tip, I'll gladly do it.

Thx guys.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#8 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Linus Torvalds
Quoted 1 line · Dave Hansen

I'd _rather_ this go in via the x86 tree, but I'm not picky.

Any particular reason why?

I'm confident I can send patches to the x86 maintainers and not make them too angry. Sending pull requests to Linus, not so much. :)

I'll just plan to send it to Linus directly.

#9 lore raw
Quoted 3 lines · Dave Hansen

I'm confident I can send patches to the x86 maintainers and not make them too angry. Sending pull requests to Linus, not so much. :)

With a diffstat summary like

 24 files changed, 2 insertions(+), 1697 deletions(-)

there's not a lot I could complain about ;l)

Quoted 1 line

I'll just plan to send it to Linus directly.

I do note that while I've merged patch series from you before, I don't seem to have done a git pull from you.

But since you already have a git tree, and the tree looks fine, it really is just a git request-pull, and you basically already have the cover-letter to add to the email.

In fact, you don't even have to use a signed tag since it's on kernel.org - but it's always nice to see, and you can put the cover letter explanation into the tag.

Linus