diff mbox series

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

Message ID 1546624183-26543-4-git-send-email-dave.hansen@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/5] x86/mpx: remove MPX APIs | expand

Commit Message

Dave Hansen Jan. 4, 2019, 5:49 p.m. UTC
From: Dave Hansen <dave.hansen@linux.intel.com>

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.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
---
 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(-)

Comments

kernel test robot Jan. 4, 2019, 10:33 p.m. UTC | #1
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 <dave.hansen@linux.intel.com>
:::::: CC: Thomas Gleixner <tglx@linutronix.de>

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

Patch

diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 0ca5061..61363e7 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/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>
 
 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
diff --git a/fs/exec.c b/fs/exec.c
index fc281b7..cb99ea5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -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;
diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h
index 8ac4e68..40038d0 100644
--- a/include/asm-generic/mm_hooks.h
+++ b/include/asm-generic/mm_hooks.h
@@ -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)
 {
diff --git a/mm/mmap.c b/mm/mmap.c
index f901065..ca9f43c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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);