linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] x86: MPX fixes for tip
@ 2014-11-18 18:23 Dave Hansen
  2014-11-18 18:23 ` [PATCH 1/3] x86 mpx: change return type of get_reg_offset() Dave Hansen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dave Hansen @ 2014-11-18 18:23 UTC (permalink / raw)
  To: tglx; +Cc: x86, linux-kernel, Dave Hansen

This fixes up an issue turned up by smatch as well as
some build issues on non-x86 architectures with the
new hooks we added for MPX.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] x86 mpx: change return type of get_reg_offset()
  2014-11-18 18:23 [PATCH 0/3] x86: MPX fixes for tip Dave Hansen
@ 2014-11-18 18:23 ` Dave Hansen
  2014-11-19 10:57   ` [tip:x86/mpx] x86 mpx: Change " tip-bot for Dave Hansen
  2014-11-18 18:23 ` [PATCH 2/3] x86: cleanly separate use of asm-generic/mm_hooks.h Dave Hansen
  2014-11-18 18:23 ` [PATCH 3/3] make arch_unmap()/etc... available to all architectures Dave Hansen
  2 siblings, 1 reply; 7+ messages in thread
From: Dave Hansen @ 2014-11-18 18:23 UTC (permalink / raw)
  To: tglx; +Cc: x86, linux-kernel, Dave Hansen, dave.hansen


From: Dave Hansen <dave.hansen@linux.intel.com>

get_reg_offset() used to return the register contents themselves
instead of the register offset.  When it did that, it was an
unsigned long.  I changed it to return an integer _offset_
instead of the register.  But, I neglected to change the return
type of the function or the variables in which we store the
result of the call.

This fixes up the code to clear up the warnings from the smatch
bot:

New smatch warnings:
arch/x86/mm/mpx.c:178 mpx_get_addr_ref() warn: unsigned 'addr_offset' is never less than zero.
arch/x86/mm/mpx.c:184 mpx_get_addr_ref() warn: unsigned 'base_offset' is never less than zero.
arch/x86/mm/mpx.c:188 mpx_get_addr_ref() warn: unsigned 'indx_offset' is never less than zero.
arch/x86/mm/mpx.c:196 mpx_get_addr_ref() warn: unsigned 'addr_offset' is never less than zero.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
---

 b/arch/x86/mm/mpx.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff -puN arch/x86/mm/mpx.c~mpx_get_addr_ref-as-int arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~mpx_get_addr_ref-as-int	2014-11-18 09:14:18.630053592 -0800
+++ b/arch/x86/mm/mpx.c	2014-11-18 09:14:18.633053728 -0800
@@ -102,8 +102,8 @@ enum reg_type {
 	REG_TYPE_BASE,
 };
 
-static unsigned long get_reg_offset(struct insn *insn, struct pt_regs *regs,
-				    enum reg_type type)
+static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
+			  enum reg_type type)
 {
 	int regno = 0;
 
@@ -174,9 +174,8 @@ static unsigned long get_reg_offset(stru
  */
 static void __user *mpx_get_addr_ref(struct insn *insn, struct pt_regs *regs)
 {
-	unsigned long addr, addr_offset;
-	unsigned long base, base_offset;
-	unsigned long indx, indx_offset;
+	unsigned long addr, base, indx;
+	int addr_offset, base_offset, indx_offset;
 	insn_byte_t sib;
 
 	insn_get_modrm(insn);
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] x86: cleanly separate use of asm-generic/mm_hooks.h
  2014-11-18 18:23 [PATCH 0/3] x86: MPX fixes for tip Dave Hansen
  2014-11-18 18:23 ` [PATCH 1/3] x86 mpx: change return type of get_reg_offset() Dave Hansen
@ 2014-11-18 18:23 ` Dave Hansen
  2014-11-19 10:57   ` [tip:x86/mpx] x86: Cleanly " tip-bot for Dave Hansen
  2014-11-18 18:23 ` [PATCH 3/3] make arch_unmap()/etc... available to all architectures Dave Hansen
  2 siblings, 1 reply; 7+ messages in thread
From: Dave Hansen @ 2014-11-18 18:23 UTC (permalink / raw)
  To: tglx; +Cc: x86, linux-kernel, Dave Hansen, dave.hansen


From: Dave Hansen <dave.hansen@linux.intel.com>

asm-generic/mm_hooks.h provides some generic fillers for the 90%
of architectures that do not need to hook some mmap-mainipulation
functions.  A comment inside says:

> Define generic no-op hooks for arch_dup_mmap and
> arch_exit_mmap, to be included in asm-FOO/mmu_context.h
> for any arch FOO which doesn't need to hook these.

So, does x86 need to hook these?  It depends on CONFIG_PARAVIRT.
We *conditionally* include this generic header if we have
CONFIG_PARAVIRT=n.  That's madness.

With this patch, x86 stops using asm-generic/mmu_hooks.h entirely.
We use our own copies of the functions.  The paravirt code
provides some stubs if it is disabled, and we always call those
stubs in our x86-private versions of arch_exit_mmap() and
arch_dup_mmap().

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
---

 b/arch/x86/include/asm/mmu_context.h |   13 +++++++++++--
 b/arch/x86/include/asm/paravirt.h    |   16 +++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diff -puN arch/x86/include/asm/mmu_context.h~dmess-x86-mmu_hooks arch/x86/include/asm/mmu_context.h
--- a/arch/x86/include/asm/mmu_context.h~dmess-x86-mmu_hooks	2014-11-18 09:14:18.998070191 -0800
+++ b/arch/x86/include/asm/mmu_context.h	2014-11-18 09:14:19.002070371 -0800
@@ -12,8 +12,6 @@
 #include <asm/paravirt.h>
 #include <asm/mpx.h>
 #ifndef CONFIG_PARAVIRT
-#include <asm-generic/mm_hooks.h>
-
 static inline void paravirt_activate_mm(struct mm_struct *prev,
 					struct mm_struct *next)
 {
@@ -103,6 +101,17 @@ do {						\
 } while (0)
 #endif
 
+static inline void arch_dup_mmap(struct mm_struct *oldmm,
+				 struct mm_struct *mm)
+{
+	paravirt_arch_dup_mmap(oldmm, mm);
+}
+
+static inline void arch_exit_mmap(struct mm_struct *mm)
+{
+	paravirt_arch_exit_mmap(mm);
+}
+
 static inline void arch_bprm_mm_init(struct mm_struct *mm,
 		struct vm_area_struct *vma)
 {
diff -puN arch/x86/include/asm/paravirt.h~dmess-x86-mmu_hooks arch/x86/include/asm/paravirt.h
--- a/arch/x86/include/asm/paravirt.h~dmess-x86-mmu_hooks	2014-11-18 09:14:18.999070236 -0800
+++ b/arch/x86/include/asm/paravirt.h	2014-11-18 09:14:19.003070416 -0800
@@ -330,13 +330,13 @@ static inline void paravirt_activate_mm(
 	PVOP_VCALL2(pv_mmu_ops.activate_mm, prev, next);
 }
 
-static inline void arch_dup_mmap(struct mm_struct *oldmm,
-				 struct mm_struct *mm)
+static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
+					  struct mm_struct *mm)
 {
 	PVOP_VCALL2(pv_mmu_ops.dup_mmap, oldmm, mm);
 }
 
-static inline void arch_exit_mmap(struct mm_struct *mm)
+static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
 {
 	PVOP_VCALL1(pv_mmu_ops.exit_mmap, mm);
 }
@@ -986,5 +986,15 @@ extern void default_banner(void);
 #endif /* __ASSEMBLY__ */
 #else  /* CONFIG_PARAVIRT */
 # define default_banner x86_init_noop
+#ifndef __ASSEMBLY__
+static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
+					  struct mm_struct *mm)
+{
+}
+
+static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
+{
+}
+#endif /* __ASSEMBLY__ */
 #endif /* !CONFIG_PARAVIRT */
 #endif /* _ASM_X86_PARAVIRT_H */
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] make arch_unmap()/etc... available to all architectures.
  2014-11-18 18:23 [PATCH 0/3] x86: MPX fixes for tip Dave Hansen
  2014-11-18 18:23 ` [PATCH 1/3] x86 mpx: change return type of get_reg_offset() Dave Hansen
  2014-11-18 18:23 ` [PATCH 2/3] x86: cleanly separate use of asm-generic/mm_hooks.h Dave Hansen
@ 2014-11-18 18:23 ` Dave Hansen
  2014-11-19 10:58   ` [tip:x86/mpx] mm: Make arch_unmap()/bprm_mm_init() " tip-bot for Dave Hansen
  2 siblings, 1 reply; 7+ messages in thread
From: Dave Hansen @ 2014-11-18 18:23 UTC (permalink / raw)
  To: tglx; +Cc: x86, linux-kernel, Dave Hansen, dave.hansen, linux-arch


From: Dave Hansen <dave.hansen@linux.intel.com>

The x86 MPX patch set calls arch_unmap() and arch_bprm_mm_init()
from fs/exec.c, so we need at least a stub for them in all
architectures.  They are only called under an #ifdef for
CONFIG_MMU=y, so we can at least restict this to architectures
with MMU support.

blackfin/c6x have no MMU support, so do not call arch_unmap().
They also do not include mm_hooks.h or mmu_context.h at all and
do not need to be touched.

s390, um and unicore32 do not use asm-generic/mm_hooks.h, so got
their own arch_unmap() versions.  (I also moved um's
arch_dup_mmap() to be closer to the other mm_hooks.h functions).

xtensa only includs mm_hooks when MMU=y, which should be fine
since arch_unmap() is called only from MMU=y code.

For the rest, we use the stub copies of these functions in
asm-generic/mm_hook.h.

I cross compiled defconfigs for cris (to check NOMMU) and s390
to make sure that this works.  I also checked a 64-bit build
of UML and all my normal x86 builds including PARAVIRT on and
off.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-arch@vger.kernel.org
Cc: x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
---

 b/arch/s390/include/asm/mmu_context.h      |   11 +++++++++++
 b/arch/um/include/asm/mmu_context.h        |   24 +++++++++++++++++++-----
 b/arch/unicore32/include/asm/mmu_context.h |   11 +++++++++++
 b/include/asm-generic/mm_hooks.h           |   17 ++++++++++++++---
 b/include/asm-generic/mmu_context.h        |    6 ------
 5 files changed, 55 insertions(+), 14 deletions(-)

diff -puN arch/s390/include/asm/mmu_context.h~mm_hooks arch/s390/include/asm/mmu_context.h
--- a/arch/s390/include/asm/mmu_context.h~mm_hooks	2014-11-18 09:14:19.914111506 -0800
+++ b/arch/s390/include/asm/mmu_context.h	2014-11-18 09:14:19.924111957 -0800
@@ -120,4 +120,15 @@ static inline void arch_exit_mmap(struct
 {
 }
 
+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)
+{
+}
+
 #endif /* __S390_MMU_CONTEXT_H */
diff -puN arch/um/include/asm/mmu_context.h~mm_hooks arch/um/include/asm/mmu_context.h
--- a/arch/um/include/asm/mmu_context.h~mm_hooks	2014-11-18 09:14:19.916111596 -0800
+++ b/arch/um/include/asm/mmu_context.h	2014-11-18 09:14:19.924111957 -0800
@@ -10,7 +10,26 @@
 #include <asm/mmu.h>
 
 extern void uml_setup_stubs(struct mm_struct *mm);
+/*
+ * Needed since we do not use the asm-generic/mm_hooks.h:
+ */
+static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
+{
+	uml_setup_stubs(mm);
+}
 extern 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)
+{
+}
+/*
+ * end asm-generic/mm_hooks.h functions
+ */
 
 #define deactivate_mm(tsk,mm)	do { } while (0)
 
@@ -41,11 +60,6 @@ static inline void switch_mm(struct mm_s
 	}
 }
 
-static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
-{
-	uml_setup_stubs(mm);
-}
-
 static inline void enter_lazy_tlb(struct mm_struct *mm, 
 				  struct task_struct *tsk)
 {
diff -puN arch/unicore32/include/asm/mmu_context.h~mm_hooks arch/unicore32/include/asm/mmu_context.h
--- a/arch/unicore32/include/asm/mmu_context.h~mm_hooks	2014-11-18 09:14:19.918111686 -0800
+++ b/arch/unicore32/include/asm/mmu_context.h	2014-11-18 09:14:19.924111957 -0800
@@ -86,4 +86,15 @@ static inline void arch_dup_mmap(struct
 {
 }
 
+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)
+{
+}
+
 #endif
diff -puN include/asm-generic/mm_hooks.h~mm_hooks include/asm-generic/mm_hooks.h
--- a/include/asm-generic/mm_hooks.h~mm_hooks	2014-11-18 09:14:19.919111732 -0800
+++ b/include/asm-generic/mm_hooks.h	2014-11-18 09:14:19.925112002 -0800
@@ -1,7 +1,7 @@
 /*
- * Define generic no-op hooks for arch_dup_mmap and arch_exit_mmap, to
- * be included in asm-FOO/mmu_context.h for any arch FOO which doesn't
- * need to hook these.
+ * Define generic no-op hooks for arch_dup_mmap, arch_exit_mmap
+ * and arch_unmap to be included in asm-FOO/mmu_context.h for any
+ * arch FOO which doesn't need to hook these.
  */
 #ifndef _ASM_GENERIC_MM_HOOKS_H
 #define _ASM_GENERIC_MM_HOOKS_H
@@ -15,4 +15,15 @@ static inline void arch_exit_mmap(struct
 {
 }
 
+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)
+{
+}
+
 #endif	/* _ASM_GENERIC_MM_HOOKS_H */
diff -puN include/asm-generic/mmu_context.h~mm_hooks include/asm-generic/mmu_context.h
--- a/include/asm-generic/mmu_context.h~mm_hooks	2014-11-18 09:14:19.921111822 -0800
+++ b/include/asm-generic/mmu_context.h	2014-11-18 09:14:19.925112002 -0800
@@ -47,10 +47,4 @@ static inline void arch_bprm_mm_init(str
 {
 }
 
-static inline void arch_unmap(struct mm_struct *mm,
-			struct vm_area_struct *vma,
-			unsigned long start, unsigned long end)
-{
-}
-
 #endif /* __ASM_GENERIC_MMU_CONTEXT_H */
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:x86/mpx] x86 mpx: Change return type of get_reg_offset()
  2014-11-18 18:23 ` [PATCH 1/3] x86 mpx: change return type of get_reg_offset() Dave Hansen
@ 2014-11-19 10:57   ` tip-bot for Dave Hansen
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Dave Hansen @ 2014-11-19 10:57 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: dave, dave.hansen, tglx, hpa, mingo, linux-kernel

Commit-ID:  68c009c4137927fd4ffd3e653bb5209d752c1d42
Gitweb:     http://git.kernel.org/tip/68c009c4137927fd4ffd3e653bb5209d752c1d42
Author:     Dave Hansen <dave.hansen@linux.intel.com>
AuthorDate: Tue, 18 Nov 2014 10:23:43 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 19 Nov 2014 11:54:12 +0100

x86 mpx: Change return type of get_reg_offset()

get_reg_offset() used to return the register contents themselves
instead of the register offset.  When it did that, it was an
unsigned long.  I changed it to return an integer _offset_
instead of the register.  But, I neglected to change the return
type of the function or the variables in which we store the
result of the call.

This fixes up the code to clear up the warnings from the smatch
bot:

New smatch warnings:
arch/x86/mm/mpx.c:178 mpx_get_addr_ref() warn: unsigned 'addr_offset' is never less than zero.
arch/x86/mm/mpx.c:184 mpx_get_addr_ref() warn: unsigned 'base_offset' is never less than zero.
arch/x86/mm/mpx.c:188 mpx_get_addr_ref() warn: unsigned 'indx_offset' is never less than zero.
arch/x86/mm/mpx.c:196 mpx_get_addr_ref() warn: unsigned 'addr_offset' is never less than zero.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Hansen <dave@sr71.net>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20141118182343.C3E0C629@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/mm/mpx.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index f30b48e..67ebf57 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -102,8 +102,8 @@ enum reg_type {
 	REG_TYPE_BASE,
 };
 
-static unsigned long get_reg_offset(struct insn *insn, struct pt_regs *regs,
-				    enum reg_type type)
+static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
+			  enum reg_type type)
 {
 	int regno = 0;
 
@@ -174,9 +174,8 @@ static unsigned long get_reg_offset(struct insn *insn, struct pt_regs *regs,
  */
 static void __user *mpx_get_addr_ref(struct insn *insn, struct pt_regs *regs)
 {
-	unsigned long addr, addr_offset;
-	unsigned long base, base_offset;
-	unsigned long indx, indx_offset;
+	unsigned long addr, base, indx;
+	int addr_offset, base_offset, indx_offset;
 	insn_byte_t sib;
 
 	insn_get_modrm(insn);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [tip:x86/mpx] x86: Cleanly separate use of asm-generic/mm_hooks.h
  2014-11-18 18:23 ` [PATCH 2/3] x86: cleanly separate use of asm-generic/mm_hooks.h Dave Hansen
@ 2014-11-19 10:57   ` tip-bot for Dave Hansen
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Dave Hansen @ 2014-11-19 10:57 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, linux-kernel, dave.hansen, dave, mingo, tglx

Commit-ID:  a1ea1c032b8f8c23d86ef4db6d061527e9417f19
Gitweb:     http://git.kernel.org/tip/a1ea1c032b8f8c23d86ef4db6d061527e9417f19
Author:     Dave Hansen <dave.hansen@linux.intel.com>
AuthorDate: Tue, 18 Nov 2014 10:23:49 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 19 Nov 2014 11:54:13 +0100

x86: Cleanly separate use of asm-generic/mm_hooks.h

asm-generic/mm_hooks.h provides some generic fillers for the 90%
of architectures that do not need to hook some mmap-manipulation
functions.  A comment inside says:

> Define generic no-op hooks for arch_dup_mmap and
> arch_exit_mmap, to be included in asm-FOO/mmu_context.h
> for any arch FOO which doesn't need to hook these.

So, does x86 need to hook these?  It depends on CONFIG_PARAVIRT.
We *conditionally* include this generic header if we have
CONFIG_PARAVIRT=n.  That's madness.

With this patch, x86 stops using asm-generic/mmu_hooks.h entirely.
We use our own copies of the functions.  The paravirt code
provides some stubs if it is disabled, and we always call those
stubs in our x86-private versions of arch_exit_mmap() and
arch_dup_mmap().

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Hansen <dave@sr71.net>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20141118182349.14567FA5@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/mmu_context.h | 13 +++++++++++--
 arch/x86/include/asm/paravirt.h    | 16 +++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 00d4575..be91d57 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -12,8 +12,6 @@
 #include <asm/paravirt.h>
 #include <asm/mpx.h>
 #ifndef CONFIG_PARAVIRT
-#include <asm-generic/mm_hooks.h>
-
 static inline void paravirt_activate_mm(struct mm_struct *prev,
 					struct mm_struct *next)
 {
@@ -103,6 +101,17 @@ do {						\
 } while (0)
 #endif
 
+static inline void arch_dup_mmap(struct mm_struct *oldmm,
+				 struct mm_struct *mm)
+{
+	paravirt_arch_dup_mmap(oldmm, mm);
+}
+
+static inline void arch_exit_mmap(struct mm_struct *mm)
+{
+	paravirt_arch_exit_mmap(mm);
+}
+
 static inline void arch_bprm_mm_init(struct mm_struct *mm,
 		struct vm_area_struct *vma)
 {
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index cd6e161..32444ae 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -330,13 +330,13 @@ static inline void paravirt_activate_mm(struct mm_struct *prev,
 	PVOP_VCALL2(pv_mmu_ops.activate_mm, prev, next);
 }
 
-static inline void arch_dup_mmap(struct mm_struct *oldmm,
-				 struct mm_struct *mm)
+static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
+					  struct mm_struct *mm)
 {
 	PVOP_VCALL2(pv_mmu_ops.dup_mmap, oldmm, mm);
 }
 
-static inline void arch_exit_mmap(struct mm_struct *mm)
+static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
 {
 	PVOP_VCALL1(pv_mmu_ops.exit_mmap, mm);
 }
@@ -986,5 +986,15 @@ extern void default_banner(void);
 #endif /* __ASSEMBLY__ */
 #else  /* CONFIG_PARAVIRT */
 # define default_banner x86_init_noop
+#ifndef __ASSEMBLY__
+static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
+					  struct mm_struct *mm)
+{
+}
+
+static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
+{
+}
+#endif /* __ASSEMBLY__ */
 #endif /* !CONFIG_PARAVIRT */
 #endif /* _ASM_X86_PARAVIRT_H */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [tip:x86/mpx] mm: Make arch_unmap()/bprm_mm_init() available to all architectures
  2014-11-18 18:23 ` [PATCH 3/3] make arch_unmap()/etc... available to all architectures Dave Hansen
@ 2014-11-19 10:58   ` tip-bot for Dave Hansen
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Dave Hansen @ 2014-11-19 10:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, dave, hpa, dave.hansen, tglx, mingo

Commit-ID:  62e88b1c00de9cb30d937841ed5debed871070b8
Gitweb:     http://git.kernel.org/tip/62e88b1c00de9cb30d937841ed5debed871070b8
Author:     Dave Hansen <dave.hansen@linux.intel.com>
AuthorDate: Tue, 18 Nov 2014 10:23:50 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 19 Nov 2014 11:54:13 +0100

mm: Make arch_unmap()/bprm_mm_init() available to all architectures

The x86 MPX patch set calls arch_unmap() and arch_bprm_mm_init()
from fs/exec.c, so we need at least a stub for them in all
architectures.  They are only called under an #ifdef for
CONFIG_MMU=y, so we can at least restict this to architectures
with MMU support.

blackfin/c6x have no MMU support, so do not call arch_unmap().
They also do not include mm_hooks.h or mmu_context.h at all and
do not need to be touched.

s390, um and unicore32 do not use asm-generic/mm_hooks.h, so got
their own arch_unmap() versions.  (I also moved um's
arch_dup_mmap() to be closer to the other mm_hooks.h functions).

xtensa only includes mm_hooks when MMU=y, which should be fine
since arch_unmap() is called only from MMU=y code.

For the rest, we use the stub copies of these functions in
asm-generic/mm_hook.h.

I cross compiled defconfigs for cris (to check NOMMU) and s390
to make sure that this works.  I also checked a 64-bit build
of UML and all my normal x86 builds including PARAVIRT on and
off.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Hansen <dave@sr71.net>
Cc: linux-arch@vger.kernel.org
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20141118182350.8B4AA2C2@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/s390/include/asm/mmu_context.h      | 11 +++++++++++
 arch/um/include/asm/mmu_context.h        | 24 +++++++++++++++++++-----
 arch/unicore32/include/asm/mmu_context.h | 11 +++++++++++
 include/asm-generic/mm_hooks.h           | 17 ++++++++++++++---
 include/asm-generic/mmu_context.h        |  6 ------
 5 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
index 3815bfe..f49b719 100644
--- a/arch/s390/include/asm/mmu_context.h
+++ b/arch/s390/include/asm/mmu_context.h
@@ -120,4 +120,15 @@ 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)
+{
+}
+
 #endif /* __S390_MMU_CONTEXT_H */
diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h
index aa4a743..941527e 100644
--- a/arch/um/include/asm/mmu_context.h
+++ b/arch/um/include/asm/mmu_context.h
@@ -10,7 +10,26 @@
 #include <asm/mmu.h>
 
 extern void uml_setup_stubs(struct mm_struct *mm);
+/*
+ * Needed since we do not use the asm-generic/mm_hooks.h:
+ */
+static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
+{
+	uml_setup_stubs(mm);
+}
 extern 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)
+{
+}
+/*
+ * end asm-generic/mm_hooks.h functions
+ */
 
 #define deactivate_mm(tsk,mm)	do { } while (0)
 
@@ -41,11 +60,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	}
 }
 
-static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
-{
-	uml_setup_stubs(mm);
-}
-
 static inline void enter_lazy_tlb(struct mm_struct *mm, 
 				  struct task_struct *tsk)
 {
diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h
index ef470a7..1cb5220 100644
--- a/arch/unicore32/include/asm/mmu_context.h
+++ b/arch/unicore32/include/asm/mmu_context.h
@@ -86,4 +86,15 @@ static inline void arch_dup_mmap(struct mm_struct *oldmm,
 {
 }
 
+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)
+{
+}
+
 #endif
diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h
index 67dea81..866aa46 100644
--- a/include/asm-generic/mm_hooks.h
+++ b/include/asm-generic/mm_hooks.h
@@ -1,7 +1,7 @@
 /*
- * Define generic no-op hooks for arch_dup_mmap and arch_exit_mmap, to
- * be included in asm-FOO/mmu_context.h for any arch FOO which doesn't
- * need to hook these.
+ * Define generic no-op hooks for arch_dup_mmap, arch_exit_mmap
+ * and arch_unmap to be included in asm-FOO/mmu_context.h for any
+ * arch FOO which doesn't need to hook these.
  */
 #ifndef _ASM_GENERIC_MM_HOOKS_H
 #define _ASM_GENERIC_MM_HOOKS_H
@@ -15,4 +15,15 @@ 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)
+{
+}
+
 #endif	/* _ASM_GENERIC_MM_HOOKS_H */
diff --git a/include/asm-generic/mmu_context.h b/include/asm-generic/mmu_context.h
index aa2d8ba..1f2a8f9 100644
--- a/include/asm-generic/mmu_context.h
+++ b/include/asm-generic/mmu_context.h
@@ -47,10 +47,4 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm,
 {
 }
 
-static inline void arch_unmap(struct mm_struct *mm,
-			struct vm_area_struct *vma,
-			unsigned long start, unsigned long end)
-{
-}
-
 #endif /* __ASM_GENERIC_MMU_CONTEXT_H */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-19 10:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 18:23 [PATCH 0/3] x86: MPX fixes for tip Dave Hansen
2014-11-18 18:23 ` [PATCH 1/3] x86 mpx: change return type of get_reg_offset() Dave Hansen
2014-11-19 10:57   ` [tip:x86/mpx] x86 mpx: Change " tip-bot for Dave Hansen
2014-11-18 18:23 ` [PATCH 2/3] x86: cleanly separate use of asm-generic/mm_hooks.h Dave Hansen
2014-11-19 10:57   ` [tip:x86/mpx] x86: Cleanly " tip-bot for Dave Hansen
2014-11-18 18:23 ` [PATCH 3/3] make arch_unmap()/etc... available to all architectures Dave Hansen
2014-11-19 10:58   ` [tip:x86/mpx] mm: Make arch_unmap()/bprm_mm_init() " tip-bot for Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).