[PATCH 04/19] x86, mpx: Cleanup: Do not pass task around when unnecessary

2015-06-07 Thread Dave Hansen

From: Dave Hansen 

The MPX code can only work on the current task.  You can not, for
instance, enable MPX management in another process or thread.
You can also not handle a fault for another process or thread.

Despite this, we pass a task_struct around prolifically.  This
patch removes all of the task struct passing for code paths where
the code can not deal with another task (which turns out to be
all of them).

This has no functional changes.  It's just a cleanup.

Signed-off-by: Dave Hansen 
Reviewed-by: Thomas Gleixner 
Cc: Oleg Nesterov 
Cc: b...@alien8.de
Cc: the arch/x86 maintainers 
Cc: linux-kernel 
---

 b/arch/x86/include/asm/mpx.h   |   10 --
 b/arch/x86/include/asm/processor.h |   12 ++--
 b/arch/x86/kernel/traps.c  |5 ++---
 b/arch/x86/mm/mpx.c|   19 +--
 b/kernel/sys.c |8 
 5 files changed, 25 insertions(+), 29 deletions(-)

diff -puN arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/mpx.h
--- a/arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around   
2015-06-01 10:24:04.227730914 -0700
+++ b/arch/x86/include/asm/mpx.h2015-06-01 10:24:04.238731410 -0700
@@ -59,9 +59,8 @@
MPX_BT_ENTRY_MASK) << MPX_BT_ENTRY_SHIFT)
 
 #ifdef CONFIG_X86_INTEL_MPX
-siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
-   struct task_struct *tsk);
-int mpx_handle_bd_fault(struct task_struct *tsk);
+siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
+int mpx_handle_bd_fault(void);
 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
 {
return (mm->bd_addr != MPX_INVALID_BOUNDS_DIR);
@@ -77,12 +76,11 @@ static inline void mpx_mm_init(struct mm
 void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
  unsigned long start, unsigned long end);
 #else
-static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
- struct task_struct *tsk)
+static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
 {
return NULL;
 }
-static inline int mpx_handle_bd_fault(struct task_struct *tsk)
+static inline int mpx_handle_bd_fault(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
2015-06-01 10:24:04.229731004 -0700
+++ b/arch/x86/include/asm/processor.h  2015-06-01 10:24:04.239731455 -0700
@@ -802,18 +802,18 @@ extern int get_tsc_mode(unsigned long ad
 extern int set_tsc_mode(unsigned int val);
 
 /* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT(tsk) mpx_enable_management((tsk))
-#define MPX_DISABLE_MANAGEMENT(tsk)mpx_disable_management((tsk))
+#define MPX_ENABLE_MANAGEMENT()mpx_enable_management()
+#define MPX_DISABLE_MANAGEMENT()   mpx_disable_management()
 
 #ifdef CONFIG_X86_INTEL_MPX
-extern int mpx_enable_management(struct task_struct *tsk);
-extern int mpx_disable_management(struct task_struct *tsk);
+extern int mpx_enable_management(void);
+extern int mpx_disable_management(void);
 #else
-static inline int mpx_enable_management(struct task_struct *tsk)
+static inline int mpx_enable_management(void)
 {
return -EINVAL;
 }
-static inline int mpx_disable_management(struct task_struct *tsk)
+static inline int mpx_disable_management(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around 
arch/x86/kernel/traps.c
--- a/arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around  2015-06-01 
10:24:04.231731095 -0700
+++ b/arch/x86/kernel/traps.c   2015-06-01 10:24:04.239731455 -0700
@@ -371,7 +371,6 @@ dotraplinkage void do_double_fault(struc
 
 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 {
-   struct task_struct *tsk = current;
enum ctx_state prev_state;
const struct bndcsr *bndcsr;
siginfo_t *info;
@@ -407,11 +406,11 @@ dotraplinkage void do_bounds(struct pt_r
 */
switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
case 2: /* Bound directory has invalid entry. */
-   if (mpx_handle_bd_fault(tsk))
+   if (mpx_handle_bd_fault())
goto exit_trap;
break; /* Success, it was handled */
case 1: /* Bound violation. */
-   info = mpx_generate_siginfo(regs, tsk);
+   info = mpx_generate_siginfo(regs);
if (IS_ERR(info)) {
/*
 * We failed to decode the MPX instruction.  Act as if
diff -puN arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around2015-06-01 
10:24:04.233731185 -0700
+++ b/arch/x86/mm/mpx.c 2015-06-01 10:24:04.240731501 -0700

[PATCH 04/19] x86, mpx: Cleanup: Do not pass task around when unnecessary

2015-05-29 Thread Dave Hansen

From: Dave Hansen 

The MPX code can only work on the current task.  You can not, for
instance, enable MPX management in another process or thread.
You can also not handle a fault for another process or thread.

Despite this, we pass a task_struct around prolifically.  This
patch removes all of the task struct passing for code paths where
the code can not deal with another task (which turns out to be
all of them).

This has no functional changes.  It's just a cleanup.

Signed-off-by: Dave Hansen 
Reviewed-by: Thomas Gleixner 
Cc: Oleg Nesterov 
Cc: b...@alien8.de
Cc: the arch/x86 maintainers 
Cc: linux-kernel 
---

 b/arch/x86/include/asm/mpx.h   |   10 --
 b/arch/x86/include/asm/processor.h |   12 ++--
 b/arch/x86/kernel/traps.c  |5 ++---
 b/arch/x86/mm/mpx.c|   19 +--
 b/kernel/sys.c |8 
 5 files changed, 25 insertions(+), 29 deletions(-)

diff -puN arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/mpx.h
--- a/arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around   
2015-05-27 09:32:15.793502086 -0700
+++ b/arch/x86/include/asm/mpx.h2015-05-27 09:32:15.804502582 -0700
@@ -59,9 +59,8 @@
MPX_BT_ENTRY_MASK) << MPX_BT_ENTRY_SHIFT)
 
 #ifdef CONFIG_X86_INTEL_MPX
-siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
-   struct task_struct *tsk);
-int mpx_handle_bd_fault(struct task_struct *tsk);
+siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
+int mpx_handle_bd_fault(void);
 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
 {
return (mm->bd_addr != MPX_INVALID_BOUNDS_DIR);
@@ -77,12 +76,11 @@ static inline void mpx_mm_init(struct mm
 void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
  unsigned long start, unsigned long end);
 #else
-static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
- struct task_struct *tsk)
+static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
 {
return NULL;
 }
-static inline int mpx_handle_bd_fault(struct task_struct *tsk)
+static inline int mpx_handle_bd_fault(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
2015-05-27 09:32:15.795502176 -0700
+++ b/arch/x86/include/asm/processor.h  2015-05-27 09:32:15.804502582 -0700
@@ -802,18 +802,18 @@ extern int get_tsc_mode(unsigned long ad
 extern int set_tsc_mode(unsigned int val);
 
 /* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT(tsk) mpx_enable_management((tsk))
-#define MPX_DISABLE_MANAGEMENT(tsk)mpx_disable_management((tsk))
+#define MPX_ENABLE_MANAGEMENT()mpx_enable_management()
+#define MPX_DISABLE_MANAGEMENT()   mpx_disable_management()
 
 #ifdef CONFIG_X86_INTEL_MPX
-extern int mpx_enable_management(struct task_struct *tsk);
-extern int mpx_disable_management(struct task_struct *tsk);
+extern int mpx_enable_management(void);
+extern int mpx_disable_management(void);
 #else
-static inline int mpx_enable_management(struct task_struct *tsk)
+static inline int mpx_enable_management(void)
 {
return -EINVAL;
 }
-static inline int mpx_disable_management(struct task_struct *tsk)
+static inline int mpx_disable_management(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around 
arch/x86/kernel/traps.c
--- a/arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around  2015-05-27 
09:32:15.797502266 -0700
+++ b/arch/x86/kernel/traps.c   2015-05-27 09:32:15.805502627 -0700
@@ -371,7 +371,6 @@ dotraplinkage void do_double_fault(struc
 
 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 {
-   struct task_struct *tsk = current;
enum ctx_state prev_state;
struct bndcsr *bndcsr;
siginfo_t *info;
@@ -407,11 +406,11 @@ dotraplinkage void do_bounds(struct pt_r
 */
switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
case 2: /* Bound directory has invalid entry. */
-   if (mpx_handle_bd_fault(tsk))
+   if (mpx_handle_bd_fault())
goto exit_trap;
break; /* Success, it was handled */
case 1: /* Bound violation. */
-   info = mpx_generate_siginfo(regs, tsk);
+   info = mpx_generate_siginfo(regs);
if (IS_ERR(info)) {
/*
 * We failed to decode the MPX instruction.  Act as if
diff -puN arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around2015-05-27 
09:32:15.799502356 -0700
+++ b/arch/x86/mm/mpx.c 2015-05-27 09:32:15.806502672 -0700
@@ -27

[PATCH 04/19] x86, mpx: Cleanup: Do not pass task around when unnecessary

2015-05-27 Thread Dave Hansen

From: Dave Hansen 

The MPX code can only work on the current task.  You can not, for
instance, enable MPX management in another process or thread.
You can also not handle a fault for another process or thread.

Despite this, we pass a task_struct around prolifically.  This
patch removes all of the task struct passing for code paths where
the code can not deal with another task (which turns out to be
all of them).

This has no functional changes.  It's just a cleanup.

Signed-off-by: Dave Hansen 
Reviewed-by: Thomas Gleixner 
Cc: Oleg Nesterov 
Cc: b...@alien8.de
Cc: the arch/x86 maintainers 
Cc: linux-kernel 
---

 b/arch/x86/include/asm/mpx.h   |   10 --
 b/arch/x86/include/asm/processor.h |   12 ++--
 b/arch/x86/kernel/traps.c  |5 ++---
 b/arch/x86/mm/mpx.c|   19 +--
 b/kernel/sys.c |8 
 5 files changed, 25 insertions(+), 29 deletions(-)

diff -puN arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/mpx.h
--- a/arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around   
2015-05-27 09:32:15.793502086 -0700
+++ b/arch/x86/include/asm/mpx.h2015-05-27 09:32:15.804502582 -0700
@@ -59,9 +59,8 @@
MPX_BT_ENTRY_MASK) << MPX_BT_ENTRY_SHIFT)
 
 #ifdef CONFIG_X86_INTEL_MPX
-siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
-   struct task_struct *tsk);
-int mpx_handle_bd_fault(struct task_struct *tsk);
+siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
+int mpx_handle_bd_fault(void);
 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
 {
return (mm->bd_addr != MPX_INVALID_BOUNDS_DIR);
@@ -77,12 +76,11 @@ static inline void mpx_mm_init(struct mm
 void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
  unsigned long start, unsigned long end);
 #else
-static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
- struct task_struct *tsk)
+static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
 {
return NULL;
 }
-static inline int mpx_handle_bd_fault(struct task_struct *tsk)
+static inline int mpx_handle_bd_fault(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
2015-05-27 09:32:15.795502176 -0700
+++ b/arch/x86/include/asm/processor.h  2015-05-27 09:32:15.804502582 -0700
@@ -802,18 +802,18 @@ extern int get_tsc_mode(unsigned long ad
 extern int set_tsc_mode(unsigned int val);
 
 /* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT(tsk) mpx_enable_management((tsk))
-#define MPX_DISABLE_MANAGEMENT(tsk)mpx_disable_management((tsk))
+#define MPX_ENABLE_MANAGEMENT()mpx_enable_management()
+#define MPX_DISABLE_MANAGEMENT()   mpx_disable_management()
 
 #ifdef CONFIG_X86_INTEL_MPX
-extern int mpx_enable_management(struct task_struct *tsk);
-extern int mpx_disable_management(struct task_struct *tsk);
+extern int mpx_enable_management(void);
+extern int mpx_disable_management(void);
 #else
-static inline int mpx_enable_management(struct task_struct *tsk)
+static inline int mpx_enable_management(void)
 {
return -EINVAL;
 }
-static inline int mpx_disable_management(struct task_struct *tsk)
+static inline int mpx_disable_management(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around 
arch/x86/kernel/traps.c
--- a/arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around  2015-05-27 
09:32:15.797502266 -0700
+++ b/arch/x86/kernel/traps.c   2015-05-27 09:32:15.805502627 -0700
@@ -371,7 +371,6 @@ dotraplinkage void do_double_fault(struc
 
 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 {
-   struct task_struct *tsk = current;
enum ctx_state prev_state;
struct bndcsr *bndcsr;
siginfo_t *info;
@@ -407,11 +406,11 @@ dotraplinkage void do_bounds(struct pt_r
 */
switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
case 2: /* Bound directory has invalid entry. */
-   if (mpx_handle_bd_fault(tsk))
+   if (mpx_handle_bd_fault())
goto exit_trap;
break; /* Success, it was handled */
case 1: /* Bound violation. */
-   info = mpx_generate_siginfo(regs, tsk);
+   info = mpx_generate_siginfo(regs);
if (IS_ERR(info)) {
/*
 * We failed to decode the MPX instruction.  Act as if
diff -puN arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around2015-05-27 
09:32:15.799502356 -0700
+++ b/arch/x86/mm/mpx.c 2015-05-27 09:32:15.806502672 -0700
@@ -27

Re: [PATCH 04/19] x86, mpx: Cleanup: Do not pass task around when unnecessary

2015-05-19 Thread Thomas Gleixner
On Mon, 18 May 2015, Dave Hansen wrote:
> From: Dave Hansen 
> 
> The MPX code can only work on the current task.  You can not, for
> instance, enable MPX management in another process or thread.
> You can also not handle a fault for another process or thread.
> 
> Despite this, we pass a task_struct around prolifically.  This
> patch removes all of the task struct passing for code paths where
> the code can not deal with another task (which turns out to be
> all of them).
> 
> This has no functional changes.  It's just a cleanup.
> 
> Signed-off-by: Dave Hansen 

Reviewed-by: Thomas Gleixner 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/19] x86, mpx: Cleanup: Do not pass task around when unnecessary

2015-05-18 Thread Dave Hansen

From: Dave Hansen 

The MPX code can only work on the current task.  You can not, for
instance, enable MPX management in another process or thread.
You can also not handle a fault for another process or thread.

Despite this, we pass a task_struct around prolifically.  This
patch removes all of the task struct passing for code paths where
the code can not deal with another task (which turns out to be
all of them).

This has no functional changes.  It's just a cleanup.

Signed-off-by: Dave Hansen 
Cc: Oleg Nesterov 
Cc: b...@alien8.de
Cc: Thomas Gleixner 
Cc: the arch/x86 maintainers 
Cc: linux-kernel 
---

 b/arch/x86/include/asm/mpx.h   |   10 --
 b/arch/x86/include/asm/processor.h |   12 ++--
 b/arch/x86/kernel/traps.c  |5 ++---
 b/arch/x86/mm/mpx.c|   19 +--
 b/kernel/sys.c |8 
 5 files changed, 25 insertions(+), 29 deletions(-)

diff -puN arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/mpx.h
--- a/arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around   
2015-05-18 17:48:59.071428932 -0700
+++ b/arch/x86/include/asm/mpx.h2015-05-18 17:48:59.081429383 -0700
@@ -59,9 +59,8 @@
MPX_BT_ENTRY_MASK) << MPX_BT_ENTRY_SHIFT)
 
 #ifdef CONFIG_X86_INTEL_MPX
-siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
-   struct task_struct *tsk);
-int mpx_handle_bd_fault(struct task_struct *tsk);
+siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
+int mpx_handle_bd_fault(void);
 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
 {
return (mm->bd_addr != MPX_INVALID_BOUNDS_DIR);
@@ -77,12 +76,11 @@ static inline void mpx_mm_init(struct mm
 void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
  unsigned long start, unsigned long end);
 #else
-static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
- struct task_struct *tsk)
+static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
 {
return NULL;
 }
-static inline int mpx_handle_bd_fault(struct task_struct *tsk)
+static inline int mpx_handle_bd_fault(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
2015-05-18 17:48:59.073429023 -0700
+++ b/arch/x86/include/asm/processor.h  2015-05-18 17:48:59.082429428 -0700
@@ -928,18 +928,18 @@ extern int get_tsc_mode(unsigned long ad
 extern int set_tsc_mode(unsigned int val);
 
 /* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT(tsk) mpx_enable_management((tsk))
-#define MPX_DISABLE_MANAGEMENT(tsk)mpx_disable_management((tsk))
+#define MPX_ENABLE_MANAGEMENT()mpx_enable_management()
+#define MPX_DISABLE_MANAGEMENT()   mpx_disable_management()
 
 #ifdef CONFIG_X86_INTEL_MPX
-extern int mpx_enable_management(struct task_struct *tsk);
-extern int mpx_disable_management(struct task_struct *tsk);
+extern int mpx_enable_management(void);
+extern int mpx_disable_management(void);
 #else
-static inline int mpx_enable_management(struct task_struct *tsk)
+static inline int mpx_enable_management(void)
 {
return -EINVAL;
 }
-static inline int mpx_disable_management(struct task_struct *tsk)
+static inline int mpx_disable_management(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around 
arch/x86/kernel/traps.c
--- a/arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around  2015-05-18 
17:48:59.074429068 -0700
+++ b/arch/x86/kernel/traps.c   2015-05-18 17:48:59.082429428 -0700
@@ -372,7 +372,6 @@ dotraplinkage void do_double_fault(struc
 
 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 {
-   struct task_struct *tsk = current;
enum ctx_state prev_state;
struct bndcsr *bndcsr;
siginfo_t *info;
@@ -408,11 +407,11 @@ dotraplinkage void do_bounds(struct pt_r
 */
switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
case 2: /* Bound directory has invalid entry. */
-   if (mpx_handle_bd_fault(tsk))
+   if (mpx_handle_bd_fault())
goto exit_trap;
break; /* Success, it was handled */
case 1: /* Bound violation. */
-   info = mpx_generate_siginfo(regs, tsk);
+   info = mpx_generate_siginfo(regs);
if (IS_ERR(info)) {
/*
 * We failed to decode the MPX instruction.  Act as if
diff -puN arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around2015-05-18 
17:48:59.076429158 -0700
+++ b/arch/x86/mm/mpx.c 2015-05-18 17:48:59.083429473 -0700
@@ -272,8 +272,

Re: [PATCH 04/19] x86, mpx: cleanup: do not pass task around when unnecessary

2015-05-18 Thread Thomas Gleixner
On Fri, 8 May 2015, Dave Hansen wrote:
> The MPX code can largely only work on the current task.  You can

s/largely// ?

> not, for instance, enable MPX management in another process or
> thread.  You can also not handle a fault for another process
> or thread.
> 
> Despite this, we pass a task_struct around prolifically.  This
> patch removes all of the task struct passing for code paths
> where the code can not deal with another task (which turns out
> to be all of them).
> 
> This has no functional changes.  It's just a cleanup.

See also reply to previous patch.

Thanks,

tglx

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/19] x86, mpx: cleanup: do not pass task around when unnecessary

2015-05-08 Thread Dave Hansen

From: Dave Hansen 

The MPX code can largely only work on the current task.  You can
not, for instance, enable MPX management in another process or
thread.  You can also not handle a fault for another process
or thread.

Despite this, we pass a task_struct around prolifically.  This
patch removes all of the task struct passing for code paths
where the code can not deal with another task (which turns out
to be all of them).

This has no functional changes.  It's just a cleanup.

Signed-off-by: Dave Hansen 
Cc: Oleg Nesterov 
Cc: b...@alien8.de
Cc: Thomas Gleixner 
Cc: the arch/x86 maintainers 
Cc: linux-kernel 
---

 b/arch/x86/include/asm/mpx.h   |   10 --
 b/arch/x86/include/asm/processor.h |   12 ++--
 b/arch/x86/kernel/traps.c  |5 ++---
 b/arch/x86/mm/mpx.c|   19 +--
 b/kernel/sys.c |8 
 5 files changed, 25 insertions(+), 29 deletions(-)

diff -puN arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/mpx.h
--- a/arch/x86/include/asm/mpx.h~x86-mpx-dont-pass-current-around   
2015-05-08 11:46:11.822619156 -0700
+++ b/arch/x86/include/asm/mpx.h2015-05-08 11:46:11.833619653 -0700
@@ -59,9 +59,8 @@
MPX_BT_ENTRY_MASK) << MPX_BT_ENTRY_SHIFT)
 
 #ifdef CONFIG_X86_INTEL_MPX
-siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
-   struct task_struct *tsk);
-int mpx_handle_bd_fault(struct task_struct *tsk);
+siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
+int mpx_handle_bd_fault(void);
 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
 {
return (mm->bd_addr != MPX_INVALID_BOUNDS_DIR);
@@ -77,12 +76,11 @@ static inline void mpx_mm_init(struct mm
 void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
  unsigned long start, unsigned long end);
 #else
-static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs,
- struct task_struct *tsk)
+static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
 {
return NULL;
 }
-static inline int mpx_handle_bd_fault(struct task_struct *tsk)
+static inline int mpx_handle_bd_fault(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~x86-mpx-dont-pass-current-around 
2015-05-08 11:46:11.823619202 -0700
+++ b/arch/x86/include/asm/processor.h  2015-05-08 11:46:11.833619653 -0700
@@ -928,18 +928,18 @@ extern int get_tsc_mode(unsigned long ad
 extern int set_tsc_mode(unsigned int val);
 
 /* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT(tsk) mpx_enable_management((tsk))
-#define MPX_DISABLE_MANAGEMENT(tsk)mpx_disable_management((tsk))
+#define MPX_ENABLE_MANAGEMENT()mpx_enable_management()
+#define MPX_DISABLE_MANAGEMENT()   mpx_disable_management()
 
 #ifdef CONFIG_X86_INTEL_MPX
-extern int mpx_enable_management(struct task_struct *tsk);
-extern int mpx_disable_management(struct task_struct *tsk);
+extern int mpx_enable_management(void);
+extern int mpx_disable_management(void);
 #else
-static inline int mpx_enable_management(struct task_struct *tsk)
+static inline int mpx_enable_management(void)
 {
return -EINVAL;
 }
-static inline int mpx_disable_management(struct task_struct *tsk)
+static inline int mpx_disable_management(void)
 {
return -EINVAL;
 }
diff -puN arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around 
arch/x86/kernel/traps.c
--- a/arch/x86/kernel/traps.c~x86-mpx-dont-pass-current-around  2015-05-08 
11:46:11.825619292 -0700
+++ b/arch/x86/kernel/traps.c   2015-05-08 11:46:11.834619698 -0700
@@ -372,7 +372,6 @@ dotraplinkage void do_double_fault(struc
 
 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
 {
-   struct task_struct *tsk = current;
enum ctx_state prev_state;
struct bndcsr *bndcsr;
siginfo_t *info;
@@ -408,11 +407,11 @@ dotraplinkage void do_bounds(struct pt_r
 */
switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
case 2: /* Bound directory has invalid entry. */
-   if (mpx_handle_bd_fault(tsk))
+   if (mpx_handle_bd_fault())
goto exit_trap;
break; /* Success, it was handled */
case 1: /* Bound violation. */
-   info = mpx_generate_siginfo(regs, tsk);
+   info = mpx_generate_siginfo(regs);
if (IS_ERR(info)) {
/*
 * We failed to decode the MPX instruction.  Act as if
diff -puN arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~x86-mpx-dont-pass-current-around2015-05-08 
11:46:11.827619382 -0700
+++ b/arch/x86/mm/mpx.c 2015-05-08 11:46:11.834619698 -0700
@@ -27