[tip:x86/urgent] x86/alternatives: Fix alt_max_short macro to really be a max()

2017-10-09 Thread tip-bot for Mathias Krause
Commit-ID:  6b32c126d33d5cb379bca280ab8acedc1ca978ff
Gitweb: https://git.kernel.org/tip/6b32c126d33d5cb379bca280ab8acedc1ca978ff
Author: Mathias Krause 
AuthorDate: Thu, 5 Oct 2017 20:30:12 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 9 Oct 2017 13:35:17 +0200

x86/alternatives: Fix alt_max_short macro to really be a max()

The alt_max_short() macro in asm/alternative.h does not work as
intended, leading to nasty bugs. E.g. alt_max_short("1", "3")
evaluates to 3, but alt_max_short("3", "1") evaluates to 1 -- not
exactly the maximum of 1 and 3.

In fact, I had to learn it the hard way by crashing my kernel in not
so funny ways by attempting to make use of the ALTENATIVE_2 macro
with alternatives where the first one was larger than the second
one.

According to [1] and commit dbe4058a6a44 ("x86/alternatives: Fix
ALTERNATIVE_2 padding generation properly") the right handed side
should read "-(-(a < b))" not "-(-(a - b))". Fix that, to make the
macro work as intended.

While at it, fix up the comments regarding the additional "-", too.
It's not about gas' usage of s32 but brain dead logic of having a
"true" value of -1 for the < operator ... *sigh*

Btw., the one in asm/alternative-asm.h is correct. And, apparently,
all current users of ALTERNATIVE_2() pass same sized alternatives,
avoiding to hit the bug.

[1] http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax

Reviewed-and-tested-by: Borislav Petkov 
Fixes: dbe4058a6a44 ("x86/alternatives: Fix ALTERNATIVE_2 padding generation 
properly")
Signed-off-by: Mathias Krause 
Signed-off-by: Thomas Gleixner 
Cc: Borislav Petkov 
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/1507228213-13095-1-git-send-email-mini...@googlemail.com

---
 arch/x86/include/asm/alternative-asm.h | 4 +++-
 arch/x86/include/asm/alternative.h | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/alternative-asm.h 
b/arch/x86/include/asm/alternative-asm.h
index e7636ba..6c98821 100644
--- a/arch/x86/include/asm/alternative-asm.h
+++ b/arch/x86/include/asm/alternative-asm.h
@@ -62,8 +62,10 @@
 #define new_len2   145f-144f
 
 /*
- * max without conditionals. Idea adapted from:
+ * gas compatible max based on the idea from:
  * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
+ *
+ * The additional "-" is needed because gas uses a "true" value of -1.
  */
 #define alt_max_short(a, b)((a) ^ (((a) ^ (b)) & -(-((a) < (b)
 
diff --git a/arch/x86/include/asm/alternative.h 
b/arch/x86/include/asm/alternative.h
index c096624..ccbe24e 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -103,12 +103,12 @@ static inline int alternatives_text_reserved(void *start, 
void *end)
alt_end_marker ":\n"
 
 /*
- * max without conditionals. Idea adapted from:
+ * gas compatible max based on the idea from:
  * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
  *
- * The additional "-" is needed because gas works with s32s.
+ * The additional "-" is needed because gas uses a "true" value of -1.
  */
-#define alt_max_short(a, b)"((" a ") ^ (((" a ") ^ (" b ")) & -(-((" a ") 
- (" b ")"
+#define alt_max_short(a, b)"((" a ") ^ (((" a ") ^ (" b ")) & -(-((" a ") 
< (" b ")"
 
 /*
  * Pad the second replacement alternative with additional NOPs if it is


[tip:x86/urgent] x86/alternatives: Fix alt_max_short macro to really be a max()

2017-10-09 Thread tip-bot for Mathias Krause
Commit-ID:  6b32c126d33d5cb379bca280ab8acedc1ca978ff
Gitweb: https://git.kernel.org/tip/6b32c126d33d5cb379bca280ab8acedc1ca978ff
Author: Mathias Krause 
AuthorDate: Thu, 5 Oct 2017 20:30:12 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 9 Oct 2017 13:35:17 +0200

x86/alternatives: Fix alt_max_short macro to really be a max()

The alt_max_short() macro in asm/alternative.h does not work as
intended, leading to nasty bugs. E.g. alt_max_short("1", "3")
evaluates to 3, but alt_max_short("3", "1") evaluates to 1 -- not
exactly the maximum of 1 and 3.

In fact, I had to learn it the hard way by crashing my kernel in not
so funny ways by attempting to make use of the ALTENATIVE_2 macro
with alternatives where the first one was larger than the second
one.

According to [1] and commit dbe4058a6a44 ("x86/alternatives: Fix
ALTERNATIVE_2 padding generation properly") the right handed side
should read "-(-(a < b))" not "-(-(a - b))". Fix that, to make the
macro work as intended.

While at it, fix up the comments regarding the additional "-", too.
It's not about gas' usage of s32 but brain dead logic of having a
"true" value of -1 for the < operator ... *sigh*

Btw., the one in asm/alternative-asm.h is correct. And, apparently,
all current users of ALTERNATIVE_2() pass same sized alternatives,
avoiding to hit the bug.

[1] http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax

Reviewed-and-tested-by: Borislav Petkov 
Fixes: dbe4058a6a44 ("x86/alternatives: Fix ALTERNATIVE_2 padding generation 
properly")
Signed-off-by: Mathias Krause 
Signed-off-by: Thomas Gleixner 
Cc: Borislav Petkov 
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/1507228213-13095-1-git-send-email-mini...@googlemail.com

---
 arch/x86/include/asm/alternative-asm.h | 4 +++-
 arch/x86/include/asm/alternative.h | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/alternative-asm.h 
b/arch/x86/include/asm/alternative-asm.h
index e7636ba..6c98821 100644
--- a/arch/x86/include/asm/alternative-asm.h
+++ b/arch/x86/include/asm/alternative-asm.h
@@ -62,8 +62,10 @@
 #define new_len2   145f-144f
 
 /*
- * max without conditionals. Idea adapted from:
+ * gas compatible max based on the idea from:
  * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
+ *
+ * The additional "-" is needed because gas uses a "true" value of -1.
  */
 #define alt_max_short(a, b)((a) ^ (((a) ^ (b)) & -(-((a) < (b)
 
diff --git a/arch/x86/include/asm/alternative.h 
b/arch/x86/include/asm/alternative.h
index c096624..ccbe24e 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -103,12 +103,12 @@ static inline int alternatives_text_reserved(void *start, 
void *end)
alt_end_marker ":\n"
 
 /*
- * max without conditionals. Idea adapted from:
+ * gas compatible max based on the idea from:
  * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
  *
- * The additional "-" is needed because gas works with s32s.
+ * The additional "-" is needed because gas uses a "true" value of -1.
  */
-#define alt_max_short(a, b)"((" a ") ^ (((" a ") ^ (" b ")) & -(-((" a ") 
- (" b ")"
+#define alt_max_short(a, b)"((" a ") ^ (((" a ") ^ (" b ")) & -(-((" a ") 
< (" b ")"
 
 /*
  * Pad the second replacement alternative with additional NOPs if it is


[tip:x86/urgent] x86/vdso: Ensure vdso32_enabled gets set to valid values only

2017-04-10 Thread tip-bot for Mathias Krause
Commit-ID:  c06989da39cdb10604d572c8c7ea8c8c97f3c483
Gitweb: http://git.kernel.org/tip/c06989da39cdb10604d572c8c7ea8c8c97f3c483
Author: Mathias Krause 
AuthorDate: Mon, 10 Apr 2017 17:14:27 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 10 Apr 2017 18:31:41 +0200

x86/vdso: Ensure vdso32_enabled gets set to valid values only

vdso_enabled can be set to arbitrary integer values via the kernel command
line 'vdso32=' parameter or via 'sysctl abi.vsyscall32'.

load_vdso32() only maps VDSO if vdso_enabled == 1, but ARCH_DLINFO_IA32
merily checks for vdso_enabled != 0. As a consequence the AT_SYSINFO_EHDR
auxiliary vector for the VDSO_ENTRY is emitted with a NULL pointer which
causes a segfault when the application tries to use the VDSO.

Restrict the valid arguments on the command line and the sysctl to 0 and 1.

Fixes: b0b49f2673f0 ("x86, vdso: Remove compat vdso support")
Signed-off-by: Mathias Krause 
Acked-by: Andy Lutomirski 
Cc: Peter Zijlstra 
Cc: sta...@vger.kernel.org
Cc: Roland McGrath 
Link: 
http://lkml.kernel.org/r/1491424561-7187-1-git-send-email-mini...@googlemail.com
Link: http://lkml.kernel.org/r/20170410151723.518412...@linutronix.de
Signed-off-by: Thomas Gleixner 

---
 arch/x86/entry/vdso/vdso32-setup.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso32-setup.c 
b/arch/x86/entry/vdso/vdso32-setup.c
index 7853b53..3f9d1a8 100644
--- a/arch/x86/entry/vdso/vdso32-setup.c
+++ b/arch/x86/entry/vdso/vdso32-setup.c
@@ -30,8 +30,10 @@ static int __init vdso32_setup(char *s)
 {
vdso32_enabled = simple_strtoul(s, NULL, 0);
 
-   if (vdso32_enabled > 1)
+   if (vdso32_enabled > 1) {
pr_warn("vdso32 values other than 0 and 1 are no longer 
allowed; vdso disabled\n");
+   vdso32_enabled = 0;
+   }
 
return 1;
 }
@@ -62,13 +64,18 @@ subsys_initcall(sysenter_setup);
 /* Register vsyscall32 into the ABI table */
 #include 
 
+static const int zero;
+static const int one = 1;
+
 static struct ctl_table abi_table2[] = {
{
.procname   = "vsyscall32",
.data   = _enabled,
.maxlen = sizeof(int),
.mode   = 0644,
-   .proc_handler   = proc_dointvec
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = (int *),
+   .extra2 = (int *),
},
{}
 };


[tip:x86/urgent] x86/vdso: Ensure vdso32_enabled gets set to valid values only

2017-04-10 Thread tip-bot for Mathias Krause
Commit-ID:  c06989da39cdb10604d572c8c7ea8c8c97f3c483
Gitweb: http://git.kernel.org/tip/c06989da39cdb10604d572c8c7ea8c8c97f3c483
Author: Mathias Krause 
AuthorDate: Mon, 10 Apr 2017 17:14:27 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 10 Apr 2017 18:31:41 +0200

x86/vdso: Ensure vdso32_enabled gets set to valid values only

vdso_enabled can be set to arbitrary integer values via the kernel command
line 'vdso32=' parameter or via 'sysctl abi.vsyscall32'.

load_vdso32() only maps VDSO if vdso_enabled == 1, but ARCH_DLINFO_IA32
merily checks for vdso_enabled != 0. As a consequence the AT_SYSINFO_EHDR
auxiliary vector for the VDSO_ENTRY is emitted with a NULL pointer which
causes a segfault when the application tries to use the VDSO.

Restrict the valid arguments on the command line and the sysctl to 0 and 1.

Fixes: b0b49f2673f0 ("x86, vdso: Remove compat vdso support")
Signed-off-by: Mathias Krause 
Acked-by: Andy Lutomirski 
Cc: Peter Zijlstra 
Cc: sta...@vger.kernel.org
Cc: Roland McGrath 
Link: 
http://lkml.kernel.org/r/1491424561-7187-1-git-send-email-mini...@googlemail.com
Link: http://lkml.kernel.org/r/20170410151723.518412...@linutronix.de
Signed-off-by: Thomas Gleixner 

---
 arch/x86/entry/vdso/vdso32-setup.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso32-setup.c 
b/arch/x86/entry/vdso/vdso32-setup.c
index 7853b53..3f9d1a8 100644
--- a/arch/x86/entry/vdso/vdso32-setup.c
+++ b/arch/x86/entry/vdso/vdso32-setup.c
@@ -30,8 +30,10 @@ static int __init vdso32_setup(char *s)
 {
vdso32_enabled = simple_strtoul(s, NULL, 0);
 
-   if (vdso32_enabled > 1)
+   if (vdso32_enabled > 1) {
pr_warn("vdso32 values other than 0 and 1 are no longer 
allowed; vdso disabled\n");
+   vdso32_enabled = 0;
+   }
 
return 1;
 }
@@ -62,13 +64,18 @@ subsys_initcall(sysenter_setup);
 /* Register vsyscall32 into the ABI table */
 #include 
 
+static const int zero;
+static const int one = 1;
+
 static struct ctl_table abi_table2[] = {
{
.procname   = "vsyscall32",
.data   = _enabled,
.maxlen = sizeof(int),
.mode   = 0644,
-   .proc_handler   = proc_dointvec
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = (int *),
+   .extra2 = (int *),
},
{}
 };


[tip:x86/cpu] x86/cpu: Drop wp_works_ok member of struct cpuinfo_x86

2017-03-11 Thread tip-bot for Mathias Krause
Commit-ID:  6415813bae75feba10b8ca3ed6634a72c2a4d313
Gitweb: http://git.kernel.org/tip/6415813bae75feba10b8ca3ed6634a72c2a4d313
Author: Mathias Krause 
AuthorDate: Sun, 12 Feb 2017 22:12:08 +0100
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:30:24 +0100

x86/cpu: Drop wp_works_ok member of struct cpuinfo_x86

Remove the wp_works_ok member of struct cpuinfo_x86. It's an
optimization back from Linux v0.99 times where we had no fixup support
yet and did the CR0.WP test via special code in the page fault handler.
The < 0 test was an optimization to not do the special casing for each
NULL ptr access violation but just for the first one doing the WP test.
Today it serves no real purpose as the test no longer needs special code
in the page fault handler and the only call side -- mem_init() -- calls
it just once, anyway. However, Xen pre-initializes it to 1, to skip the
test.

Doing the test again for Xen should be no issue at all, as even the
commit introducing skipping the test (commit d560bc61575e ("x86, xen:
Suppress WP test on Xen")) mentioned it being ban aid only. And, in
fact, testing the patch on Xen showed nothing breaks.

The pre-fixup times are long gone and with the removal of the fallback
handling code in commit a5c2a893dbd4 ("x86, 386 removal: Remove
CONFIG_X86_WP_WORKS_OK") the kernel requires a working CR0.WP anyway.
So just get rid of the "optimization" and do the test unconditionally.

Signed-off-by: Mathias Krause 
Acked-by: Borislav Petkov 
Cc: Jesper Nilsson 
Cc: Jeremy Fitzhardinge 
Cc: Arnd Hannemann 
Cc: Mikael Starvik 
Cc: Geert Uytterhoeven 
Cc: Andrew Morton 
Cc: "David S. Miller" 
Link: 
http://lkml.kernel.org/r/1486933932-585-3-git-send-email-mini...@googlemail.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/processor.h |  4 +---
 arch/x86/kernel/cpu/proc.c   |  5 ++---
 arch/x86/kernel/setup.c  | 11 ---
 arch/x86/mm/init_32.c|  9 +
 arch/x86/xen/enlighten.c |  1 -
 5 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 893f80e..4aa93b5 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -89,9 +89,7 @@ struct cpuinfo_x86 {
__u8x86_vendor; /* CPU vendor */
__u8x86_model;
__u8x86_mask;
-#ifdef CONFIG_X86_32
-   charwp_works_ok;/* It doesn't on 386's */
-#else
+#ifdef CONFIG_X86_64
/* Number of 4K pages in DTLB/ITLB combined(in pages): */
int x86_tlbsize;
 #endif
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 18ca99f..6df621a 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -31,14 +31,13 @@ static void show_cpuinfo_misc(struct seq_file *m, struct 
cpuinfo_x86 *c)
   "fpu\t\t: %s\n"
   "fpu_exception\t: %s\n"
   "cpuid level\t: %d\n"
-  "wp\t\t: %s\n",
+  "wp\t\t: yes\n",
   static_cpu_has_bug(X86_BUG_FDIV) ? "yes" : "no",
   static_cpu_has_bug(X86_BUG_F00F) ? "yes" : "no",
   static_cpu_has_bug(X86_BUG_COMA) ? "yes" : "no",
   static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
   static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
-  c->cpuid_level,
-  c->wp_works_ok ? "yes" : "no");
+  c->cpuid_level);
 }
 #else
 static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 4bf0c89..7cd7bbe 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -173,14 +173,11 @@ static struct resource bss_resource = {
 
 
 #ifdef CONFIG_X86_32
-/* cpu data as detected by the assembly code in head.S */
-struct cpuinfo_x86 new_cpu_data = {
-   .wp_works_ok = -1,
-};
+/* cpu data as detected by the assembly code in head_32.S */
+struct cpuinfo_x86 new_cpu_data;
+
 /* common cpu data for all cpus */
-struct cpuinfo_x86 boot_cpu_data __read_mostly = {
-   .wp_works_ok = -1,
-};
+struct cpuinfo_x86 boot_cpu_data __read_mostly;
 EXPORT_SYMBOL(boot_cpu_data);
 
 unsigned int def_to_bigsmp;
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 2b4b53e..4dddfaf 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -716,15 +716,17 @@ void __init paging_init(void)
  */
 static void __init test_wp_bit(void)
 {
+   int wp_works_ok;
+
printk(KERN_INFO
   "Checking if this processor honours the WP bit 

[tip:x86/cpu] x86/cpu: Drop wp_works_ok member of struct cpuinfo_x86

2017-03-11 Thread tip-bot for Mathias Krause
Commit-ID:  6415813bae75feba10b8ca3ed6634a72c2a4d313
Gitweb: http://git.kernel.org/tip/6415813bae75feba10b8ca3ed6634a72c2a4d313
Author: Mathias Krause 
AuthorDate: Sun, 12 Feb 2017 22:12:08 +0100
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:30:24 +0100

x86/cpu: Drop wp_works_ok member of struct cpuinfo_x86

Remove the wp_works_ok member of struct cpuinfo_x86. It's an
optimization back from Linux v0.99 times where we had no fixup support
yet and did the CR0.WP test via special code in the page fault handler.
The < 0 test was an optimization to not do the special casing for each
NULL ptr access violation but just for the first one doing the WP test.
Today it serves no real purpose as the test no longer needs special code
in the page fault handler and the only call side -- mem_init() -- calls
it just once, anyway. However, Xen pre-initializes it to 1, to skip the
test.

Doing the test again for Xen should be no issue at all, as even the
commit introducing skipping the test (commit d560bc61575e ("x86, xen:
Suppress WP test on Xen")) mentioned it being ban aid only. And, in
fact, testing the patch on Xen showed nothing breaks.

The pre-fixup times are long gone and with the removal of the fallback
handling code in commit a5c2a893dbd4 ("x86, 386 removal: Remove
CONFIG_X86_WP_WORKS_OK") the kernel requires a working CR0.WP anyway.
So just get rid of the "optimization" and do the test unconditionally.

Signed-off-by: Mathias Krause 
Acked-by: Borislav Petkov 
Cc: Jesper Nilsson 
Cc: Jeremy Fitzhardinge 
Cc: Arnd Hannemann 
Cc: Mikael Starvik 
Cc: Geert Uytterhoeven 
Cc: Andrew Morton 
Cc: "David S. Miller" 
Link: 
http://lkml.kernel.org/r/1486933932-585-3-git-send-email-mini...@googlemail.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/processor.h |  4 +---
 arch/x86/kernel/cpu/proc.c   |  5 ++---
 arch/x86/kernel/setup.c  | 11 ---
 arch/x86/mm/init_32.c|  9 +
 arch/x86/xen/enlighten.c |  1 -
 5 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 893f80e..4aa93b5 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -89,9 +89,7 @@ struct cpuinfo_x86 {
__u8x86_vendor; /* CPU vendor */
__u8x86_model;
__u8x86_mask;
-#ifdef CONFIG_X86_32
-   charwp_works_ok;/* It doesn't on 386's */
-#else
+#ifdef CONFIG_X86_64
/* Number of 4K pages in DTLB/ITLB combined(in pages): */
int x86_tlbsize;
 #endif
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 18ca99f..6df621a 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -31,14 +31,13 @@ static void show_cpuinfo_misc(struct seq_file *m, struct 
cpuinfo_x86 *c)
   "fpu\t\t: %s\n"
   "fpu_exception\t: %s\n"
   "cpuid level\t: %d\n"
-  "wp\t\t: %s\n",
+  "wp\t\t: yes\n",
   static_cpu_has_bug(X86_BUG_FDIV) ? "yes" : "no",
   static_cpu_has_bug(X86_BUG_F00F) ? "yes" : "no",
   static_cpu_has_bug(X86_BUG_COMA) ? "yes" : "no",
   static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
   static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
-  c->cpuid_level,
-  c->wp_works_ok ? "yes" : "no");
+  c->cpuid_level);
 }
 #else
 static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 4bf0c89..7cd7bbe 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -173,14 +173,11 @@ static struct resource bss_resource = {
 
 
 #ifdef CONFIG_X86_32
-/* cpu data as detected by the assembly code in head.S */
-struct cpuinfo_x86 new_cpu_data = {
-   .wp_works_ok = -1,
-};
+/* cpu data as detected by the assembly code in head_32.S */
+struct cpuinfo_x86 new_cpu_data;
+
 /* common cpu data for all cpus */
-struct cpuinfo_x86 boot_cpu_data __read_mostly = {
-   .wp_works_ok = -1,
-};
+struct cpuinfo_x86 boot_cpu_data __read_mostly;
 EXPORT_SYMBOL(boot_cpu_data);
 
 unsigned int def_to_bigsmp;
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 2b4b53e..4dddfaf 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -716,15 +716,17 @@ void __init paging_init(void)
  */
 static void __init test_wp_bit(void)
 {
+   int wp_works_ok;
+
printk(KERN_INFO
   "Checking if this processor honours the WP bit even in supervisor mode...");
 
/* Any page-aligned address will do, the test is non-destructive */
__set_fixmap(FIX_WP_TEST, __pa(_pg_dir), PAGE_KERNEL_RO);
-   boot_cpu_data.wp_works_ok = do_test_wp_bit();
+   wp_works_ok = do_test_wp_bit();

[tip:x86/cpu] x86/cpu: Drop unneded members of struct cpuinfo_x86

2017-03-11 Thread tip-bot for Mathias Krause
Commit-ID:  04402116846f36adea9503d7cd5104a7ed27a1a6
Gitweb: http://git.kernel.org/tip/04402116846f36adea9503d7cd5104a7ed27a1a6
Author: Mathias Krause 
AuthorDate: Sun, 12 Feb 2017 22:12:07 +0100
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:30:23 +0100

x86/cpu: Drop unneded members of struct cpuinfo_x86

Those member serve no purpose -- not even fill padding for alignment or
such. So just get rid of them.

Signed-off-by: Mathias Krause 
Acked-by: Borislav Petkov 
Cc: Jesper Nilsson 
Cc: Mikael Starvik 
Cc: Geert Uytterhoeven 
Cc: Andrew Morton 
Cc: "David S. Miller" 
Link: 
http://lkml.kernel.org/r/1486933932-585-2-git-send-email-mini...@googlemail.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/processor.h | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index f385eca..893f80e 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -80,7 +80,7 @@ extern u16 __read_mostly tlb_lld_1g[NR_INFO];
 
 /*
  *  CPU type and hardware bug flags. Kept separately for each CPU.
- *  Members of this structure are referenced in head.S, so think twice
+ *  Members of this structure are referenced in head_32.S, so think twice
  *  before touching them. [mj]
  */
 
@@ -91,11 +91,6 @@ struct cpuinfo_x86 {
__u8x86_mask;
 #ifdef CONFIG_X86_32
charwp_works_ok;/* It doesn't on 386's */
-
-   /* Problems on some 486Dx4's and old 386's: */
-   charrfu;
-   charpad0;
-   charpad1;
 #else
/* Number of 4K pages in DTLB/ITLB combined(in pages): */
int x86_tlbsize;


[tip:x86/cpu] x86/cpu: Drop unneded members of struct cpuinfo_x86

2017-03-11 Thread tip-bot for Mathias Krause
Commit-ID:  04402116846f36adea9503d7cd5104a7ed27a1a6
Gitweb: http://git.kernel.org/tip/04402116846f36adea9503d7cd5104a7ed27a1a6
Author: Mathias Krause 
AuthorDate: Sun, 12 Feb 2017 22:12:07 +0100
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:30:23 +0100

x86/cpu: Drop unneded members of struct cpuinfo_x86

Those member serve no purpose -- not even fill padding for alignment or
such. So just get rid of them.

Signed-off-by: Mathias Krause 
Acked-by: Borislav Petkov 
Cc: Jesper Nilsson 
Cc: Mikael Starvik 
Cc: Geert Uytterhoeven 
Cc: Andrew Morton 
Cc: "David S. Miller" 
Link: 
http://lkml.kernel.org/r/1486933932-585-2-git-send-email-mini...@googlemail.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/processor.h | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index f385eca..893f80e 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -80,7 +80,7 @@ extern u16 __read_mostly tlb_lld_1g[NR_INFO];
 
 /*
  *  CPU type and hardware bug flags. Kept separately for each CPU.
- *  Members of this structure are referenced in head.S, so think twice
+ *  Members of this structure are referenced in head_32.S, so think twice
  *  before touching them. [mj]
  */
 
@@ -91,11 +91,6 @@ struct cpuinfo_x86 {
__u8x86_mask;
 #ifdef CONFIG_X86_32
charwp_works_ok;/* It doesn't on 386's */
-
-   /* Problems on some 486Dx4's and old 386's: */
-   charrfu;
-   charpad0;
-   charpad1;
 #else
/* Number of 4K pages in DTLB/ITLB combined(in pages): */
int x86_tlbsize;


[tip:x86/mm] x86/extable: Ensure entries are swapped completely when sorting

2016-05-11 Thread tip-bot for Mathias Krause
Commit-ID:  67d7a982bab6702d84415ea889996fae72a7d3b2
Gitweb: http://git.kernel.org/tip/67d7a982bab6702d84415ea889996fae72a7d3b2
Author: Mathias Krause 
AuthorDate: Tue, 10 May 2016 23:07:02 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 11 May 2016 11:14:06 +0200

x86/extable: Ensure entries are swapped completely when sorting

The x86 exception table sorting was changed in this recent commit:

  29934b0fb8ff ("x86/extable: use generic search and sort routines")

... to use the arch independent code in lib/extable.c. However, the
patch was mangled somehow on its way into the kernel from the last
version posted at:

  https://lkml.org/lkml/2016/1/27/232

The committed version kind of attempted to incorporate the changes of
contemporary commit done in the x86 tree:

  548acf19234d ("x86/mm: Expand the exception table logic to allow new handling 
options")

... as in _completely_ _ignoring_ the x86 specific 'handler' member of
struct exception_table_entry. This effectively broke the sorting as
entries will only be partly swapped now.

Fortunately, the x86 Kconfig selects BUILDTIME_EXTABLE_SORT, so the
exception table doesn't need to be sorted at runtime. However, in case
that ever changes, we better not break the exception table sorting just
because of that.

Fix this by providing a swap_ex_entry_fixup() macro that takes care of
the 'handler' member.

Signed-off-by: Mathias Krause 
Reviewed-by: Ard Biesheuvel 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Tony Luck 
Link: 
http://lkml.kernel.org/r/1462914422-2911-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/uaccess.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 8b3fb76..86c48f3 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -108,6 +108,14 @@ struct exception_table_entry {
 
 #define ARCH_HAS_RELATIVE_EXTABLE
 
+#define swap_ex_entry_fixup(a, b, tmp, delta)  \
+   do {\
+   (a)->fixup = (b)->fixup + (delta);  \
+   (b)->fixup = (tmp).fixup - (delta); \
+   (a)->handler = (b)->handler + (delta);  \
+   (b)->handler = (tmp).handler - (delta); \
+   } while (0)
+
 extern int fixup_exception(struct pt_regs *regs, int trapnr);
 extern bool ex_has_fault_handler(unsigned long ip);
 extern int early_fixup_exception(unsigned long *ip);


[tip:x86/mm] x86/extable: Ensure entries are swapped completely when sorting

2016-05-11 Thread tip-bot for Mathias Krause
Commit-ID:  67d7a982bab6702d84415ea889996fae72a7d3b2
Gitweb: http://git.kernel.org/tip/67d7a982bab6702d84415ea889996fae72a7d3b2
Author: Mathias Krause 
AuthorDate: Tue, 10 May 2016 23:07:02 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 11 May 2016 11:14:06 +0200

x86/extable: Ensure entries are swapped completely when sorting

The x86 exception table sorting was changed in this recent commit:

  29934b0fb8ff ("x86/extable: use generic search and sort routines")

... to use the arch independent code in lib/extable.c. However, the
patch was mangled somehow on its way into the kernel from the last
version posted at:

  https://lkml.org/lkml/2016/1/27/232

The committed version kind of attempted to incorporate the changes of
contemporary commit done in the x86 tree:

  548acf19234d ("x86/mm: Expand the exception table logic to allow new handling 
options")

... as in _completely_ _ignoring_ the x86 specific 'handler' member of
struct exception_table_entry. This effectively broke the sorting as
entries will only be partly swapped now.

Fortunately, the x86 Kconfig selects BUILDTIME_EXTABLE_SORT, so the
exception table doesn't need to be sorted at runtime. However, in case
that ever changes, we better not break the exception table sorting just
because of that.

Fix this by providing a swap_ex_entry_fixup() macro that takes care of
the 'handler' member.

Signed-off-by: Mathias Krause 
Reviewed-by: Ard Biesheuvel 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Tony Luck 
Link: 
http://lkml.kernel.org/r/1462914422-2911-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/uaccess.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 8b3fb76..86c48f3 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -108,6 +108,14 @@ struct exception_table_entry {
 
 #define ARCH_HAS_RELATIVE_EXTABLE
 
+#define swap_ex_entry_fixup(a, b, tmp, delta)  \
+   do {\
+   (a)->fixup = (b)->fixup + (delta);  \
+   (b)->fixup = (tmp).fixup - (delta); \
+   (a)->handler = (b)->handler + (delta);  \
+   (b)->handler = (tmp).handler - (delta); \
+   } while (0)
+
 extern int fixup_exception(struct pt_regs *regs, int trapnr);
 extern bool ex_has_fault_handler(unsigned long ip);
 extern int early_fixup_exception(unsigned long *ip);


[tip:x86/cpu] x86/cpufeature: Add feature bit for Intel' s Silicon Debug CPUID bit

2015-07-31 Thread tip-bot for Mathias Krause
Commit-ID:  b1c599b8ff80ea79b9f8277a3f9f36a7b0cfedce
Gitweb: http://git.kernel.org/tip/b1c599b8ff80ea79b9f8277a3f9f36a7b0cfedce
Author: Mathias Krause 
AuthorDate: Fri, 24 Jul 2015 09:15:11 +0200
Committer:  Ingo Molnar 
CommitDate: Fri, 31 Jul 2015 10:34:07 +0200

x86/cpufeature: Add feature bit for Intel's Silicon Debug CPUID bit

Add a CPUID feature bit for the SDBG (Silicon Debug) CPU feature
found on recent Intel systems starting with Haswell.

Using the IA32_DEBUG_INTERFACE MSR (index C80H) one can at least
detect if SDBG has been enabled by the firmware and if it has
been used or not.

Signed-off-by: Mathias Krause 
Signed-off-by: Borislav Petkov 
Cc: Aaron Lu 
Cc: Dave Hansen 
Cc: Dirk Brandewie 
Cc: H. Peter Anvin 
Cc: Josh Triplett 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Ross Zwisler 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1437330403-12102-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/cpufeature.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 3d6606f..4b11974 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -119,6 +119,7 @@
 #define X86_FEATURE_TM2( 4*32+ 8) /* Thermal Monitor 2 */
 #define X86_FEATURE_SSSE3  ( 4*32+ 9) /* Supplemental SSE-3 */
 #define X86_FEATURE_CID( 4*32+10) /* Context ID */
+#define X86_FEATURE_SDBG   ( 4*32+11) /* Silicon Debug */
 #define X86_FEATURE_FMA( 4*32+12) /* Fused multiply-add */
 #define X86_FEATURE_CX16   ( 4*32+13) /* CMPXCHG16B */
 #define X86_FEATURE_XTPR   ( 4*32+14) /* Send Task Priority Messages */
--
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/


[tip:x86/cpu] x86/cpufeature: Add feature bit for Intel' s Silicon Debug CPUID bit

2015-07-31 Thread tip-bot for Mathias Krause
Commit-ID:  b1c599b8ff80ea79b9f8277a3f9f36a7b0cfedce
Gitweb: http://git.kernel.org/tip/b1c599b8ff80ea79b9f8277a3f9f36a7b0cfedce
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Fri, 24 Jul 2015 09:15:11 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Fri, 31 Jul 2015 10:34:07 +0200

x86/cpufeature: Add feature bit for Intel's Silicon Debug CPUID bit

Add a CPUID feature bit for the SDBG (Silicon Debug) CPU feature
found on recent Intel systems starting with Haswell.

Using the IA32_DEBUG_INTERFACE MSR (index C80H) one can at least
detect if SDBG has been enabled by the firmware and if it has
been used or not.

Signed-off-by: Mathias Krause mini...@googlemail.com
Signed-off-by: Borislav Petkov b...@suse.de
Cc: Aaron Lu aaron...@intel.com
Cc: Dave Hansen dave.han...@linux.intel.com
Cc: Dirk Brandewie dirk.j.brande...@intel.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Josh Triplett j...@joshtriplett.org
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Ross Zwisler ross.zwis...@linux.intel.com
Cc: Thomas Gleixner t...@linutronix.de
Link: 
http://lkml.kernel.org/r/1437330403-12102-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/cpufeature.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 3d6606f..4b11974 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -119,6 +119,7 @@
 #define X86_FEATURE_TM2( 4*32+ 8) /* Thermal Monitor 2 */
 #define X86_FEATURE_SSSE3  ( 4*32+ 9) /* Supplemental SSE-3 */
 #define X86_FEATURE_CID( 4*32+10) /* Context ID */
+#define X86_FEATURE_SDBG   ( 4*32+11) /* Silicon Debug */
 #define X86_FEATURE_FMA( 4*32+12) /* Fused multiply-add */
 #define X86_FEATURE_CX16   ( 4*32+13) /* CMPXCHG16B */
 #define X86_FEATURE_XTPR   ( 4*32+14) /* Send Task Priority Messages */
--
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/


[tip:x86/cleanups] x86: Drop bogus __ref / __refdata annotations

2015-07-20 Thread tip-bot for Mathias Krause
Commit-ID:  4daa832d99871356f5fdc52372c975e40f73a15e
Gitweb: http://git.kernel.org/tip/4daa832d99871356f5fdc52372c975e40f73a15e
Author: Mathias Krause 
AuthorDate: Mon, 20 Jul 2015 18:32:53 +0200
Committer:  Ingo Molnar 
CommitDate: Mon, 20 Jul 2015 18:57:20 +0200

x86: Drop bogus __ref / __refdata annotations

The __ref / __refdata annotations used to be needed because of
referencing functions / variables annotated __cpuinit /
__cpuinitdata.

But those annotations vanished during the development of v3.11.

Therefore most of the __ref / __refdata annotations are not needed
anymore. As they may hide legitimate sections mismatches, we
better get rid of them.

Signed-off-by: Mathias Krause 
Cc: Borislav Petkov 
Cc: Paul Gortmaker 
Cc: Peter Zijlstra 
Cc: Rafael J. Wysocki 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1437409973-8927-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/acpi/boot.c | 8 +---
 arch/x86/kernel/apic/x2apic_cluster.c   | 2 +-
 arch/x86/kernel/cpu/microcode/core.c| 2 +-
 arch/x86/kernel/cpu/microcode/intel_early.c | 2 +-
 arch/x86/kernel/cpuid.c | 2 +-
 arch/x86/kernel/smpboot.c   | 2 +-
 arch/x86/kernel/topology.c  | 4 ++--
 7 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e49ee24..75e8bad 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -710,7 +710,7 @@ static void acpi_map_cpu2node(acpi_handle handle, int cpu, 
int physid)
 #endif
 }
 
-static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
+int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
 {
int cpu;
 
@@ -726,12 +726,6 @@ static int _acpi_map_lsapic(acpi_handle handle, int 
physid, int *pcpu)
*pcpu = cpu;
return 0;
 }
-
-/* wrapper to silence section mismatch warning */
-int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
-{
-   return _acpi_map_lsapic(handle, physid, pcpu);
-}
 EXPORT_SYMBOL(acpi_map_cpu);
 
 int acpi_unmap_cpu(int cpu)
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c 
b/arch/x86/kernel/apic/x2apic_cluster.c
index ab3219b..e709bc2 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned 
long action, void *hcpu)
return notifier_from_errno(err);
 }
 
-static struct notifier_block __refdata x2apic_cpu_notifier = {
+static struct notifier_block x2apic_cpu_notifier = {
.notifier_call = update_clusterinfo,
 };
 
diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index 6236a54..532026d 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -460,7 +460,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long 
action, void *hcpu)
return NOTIFY_OK;
 }
 
-static struct notifier_block __refdata mc_cpu_notifier = {
+static struct notifier_block mc_cpu_notifier = {
.notifier_call  = mc_cpu_callback,
 };
 
diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c 
b/arch/x86/kernel/cpu/microcode/intel_early.c
index 8187b72..37ea89c 100644
--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -390,7 +390,7 @@ static int collect_cpu_info_early(struct ucode_cpu_info 
*uci)
 }
 
 #ifdef DEBUG
-static void __ref show_saved_mc(void)
+static void show_saved_mc(void)
 {
int i, j;
unsigned int sig, pf, rev, total_size, data_size, date;
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 83741a7..bd3507d 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block 
*nfb,
return notifier_from_errno(err);
 }
 
-static struct notifier_block __refdata cpuid_class_cpu_notifier =
+static struct notifier_block cpuid_class_cpu_notifier =
 {
.notifier_call = cpuid_class_cpu_callback,
 };
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index b1f3ed9c..1d06cf8 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1358,7 +1358,7 @@ static void remove_siblinginfo(int cpu)
cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
 }
 
-static void __ref remove_cpu_from_maps(int cpu)
+static void remove_cpu_from_maps(int cpu)
 {
set_cpu_online(cpu, false);
cpumask_clear_cpu(cpu, cpu_callout_mask);
diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c
index 649b010..12cbe2b 100644
--- a/arch/x86/kernel/topology.c
+++ b/arch/x86/kernel/topology.c
@@ -57,7 +57,7 @@ __setup("cpu0_hotplug", enable_cpu0_hotplug);
  *
  * This is only called for debugging CPU offline/online feature.
  */
-int __ref _debug_hotplug_cpu(int cpu, int action)
+int 

[tip:x86/cleanups] x86: Drop bogus __ref / __refdata annotations

2015-07-20 Thread tip-bot for Mathias Krause
Commit-ID:  4daa832d99871356f5fdc52372c975e40f73a15e
Gitweb: http://git.kernel.org/tip/4daa832d99871356f5fdc52372c975e40f73a15e
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Mon, 20 Jul 2015 18:32:53 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Mon, 20 Jul 2015 18:57:20 +0200

x86: Drop bogus __ref / __refdata annotations

The __ref / __refdata annotations used to be needed because of
referencing functions / variables annotated __cpuinit /
__cpuinitdata.

But those annotations vanished during the development of v3.11.

Therefore most of the __ref / __refdata annotations are not needed
anymore. As they may hide legitimate sections mismatches, we
better get rid of them.

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Borislav Petkov b...@alien8.de
Cc: Paul Gortmaker paul.gortma...@windriver.com
Cc: Peter Zijlstra pet...@infradead.org
Cc: Rafael J. Wysocki rafael.j.wyso...@intel.com
Cc: Thomas Gleixner t...@linutronix.de
Link: 
http://lkml.kernel.org/r/1437409973-8927-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/acpi/boot.c | 8 +---
 arch/x86/kernel/apic/x2apic_cluster.c   | 2 +-
 arch/x86/kernel/cpu/microcode/core.c| 2 +-
 arch/x86/kernel/cpu/microcode/intel_early.c | 2 +-
 arch/x86/kernel/cpuid.c | 2 +-
 arch/x86/kernel/smpboot.c   | 2 +-
 arch/x86/kernel/topology.c  | 4 ++--
 7 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e49ee24..75e8bad 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -710,7 +710,7 @@ static void acpi_map_cpu2node(acpi_handle handle, int cpu, 
int physid)
 #endif
 }
 
-static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
+int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
 {
int cpu;
 
@@ -726,12 +726,6 @@ static int _acpi_map_lsapic(acpi_handle handle, int 
physid, int *pcpu)
*pcpu = cpu;
return 0;
 }
-
-/* wrapper to silence section mismatch warning */
-int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
-{
-   return _acpi_map_lsapic(handle, physid, pcpu);
-}
 EXPORT_SYMBOL(acpi_map_cpu);
 
 int acpi_unmap_cpu(int cpu)
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c 
b/arch/x86/kernel/apic/x2apic_cluster.c
index ab3219b..e709bc2 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned 
long action, void *hcpu)
return notifier_from_errno(err);
 }
 
-static struct notifier_block __refdata x2apic_cpu_notifier = {
+static struct notifier_block x2apic_cpu_notifier = {
.notifier_call = update_clusterinfo,
 };
 
diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index 6236a54..532026d 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -460,7 +460,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long 
action, void *hcpu)
return NOTIFY_OK;
 }
 
-static struct notifier_block __refdata mc_cpu_notifier = {
+static struct notifier_block mc_cpu_notifier = {
.notifier_call  = mc_cpu_callback,
 };
 
diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c 
b/arch/x86/kernel/cpu/microcode/intel_early.c
index 8187b72..37ea89c 100644
--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -390,7 +390,7 @@ static int collect_cpu_info_early(struct ucode_cpu_info 
*uci)
 }
 
 #ifdef DEBUG
-static void __ref show_saved_mc(void)
+static void show_saved_mc(void)
 {
int i, j;
unsigned int sig, pf, rev, total_size, data_size, date;
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 83741a7..bd3507d 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block 
*nfb,
return notifier_from_errno(err);
 }
 
-static struct notifier_block __refdata cpuid_class_cpu_notifier =
+static struct notifier_block cpuid_class_cpu_notifier =
 {
.notifier_call = cpuid_class_cpu_callback,
 };
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index b1f3ed9c..1d06cf8 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1358,7 +1358,7 @@ static void remove_siblinginfo(int cpu)
cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
 }
 
-static void __ref remove_cpu_from_maps(int cpu)
+static void remove_cpu_from_maps(int cpu)
 {
set_cpu_online(cpu, false);
cpumask_clear_cpu(cpu, cpu_callout_mask);
diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c
index 649b010..12cbe2b 100644
--- a/arch/x86/kernel/topology.c
+++ b/arch/x86/kernel/topology.c
@@ -57,7 +57,7 @@ 

[tip:timers/urgent] posix-timers: Fix stack info leak in timer_create()

2014-10-25 Thread tip-bot for Mathias Krause
Commit-ID:  6891c4509c792209c44ced55a60f13954cb50ef4
Gitweb: http://git.kernel.org/tip/6891c4509c792209c44ced55a60f13954cb50ef4
Author: Mathias Krause 
AuthorDate: Sat, 4 Oct 2014 23:06:39 +0200
Committer:  Thomas Gleixner 
CommitDate: Sat, 25 Oct 2014 10:43:15 +0200

posix-timers: Fix stack info leak in timer_create()

If userland creates a timer without specifying a sigevent info, we'll
create one ourself, using a stack local variable. Particularly will we
use the timer ID as sival_int. But as sigev_value is a union containing
a pointer and an int, that assignment will only partially initialize
sigev_value on systems where the size of a pointer is bigger than the
size of an int. On such systems we'll copy the uninitialized stack bytes
from the timer_create() call to userland when the timer actually fires
and we're going to deliver the signal.

Initialize sigev_value with 0 to plug the stack info leak.

Found in the PaX patch, written by the PaX Team.

Fixes: 5a9fa7307285 ("posix-timers: kill ->it_sigev_signo and...")
Signed-off-by: Mathias Krause 
Cc: Oleg Nesterov 
Cc: Brad Spengler 
Cc: PaX Team 
Cc: # v2.6.28+
Link: 
http://lkml.kernel.org/r/1412456799-32339-1-git-send-email-mini...@googlemail.com
Signed-off-by: Thomas Gleixner 
---
 kernel/time/posix-timers.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 42b463a..31ea01f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -636,6 +636,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
goto out;
}
} else {
+   memset(_value, 0, sizeof(event.sigev_value));
event.sigev_notify = SIGEV_SIGNAL;
event.sigev_signo = SIGALRM;
event.sigev_value.sival_int = new_timer->it_id;
--
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/


[tip:timers/urgent] posix-timers: Fix stack info leak in timer_create()

2014-10-25 Thread tip-bot for Mathias Krause
Commit-ID:  6891c4509c792209c44ced55a60f13954cb50ef4
Gitweb: http://git.kernel.org/tip/6891c4509c792209c44ced55a60f13954cb50ef4
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sat, 4 Oct 2014 23:06:39 +0200
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Sat, 25 Oct 2014 10:43:15 +0200

posix-timers: Fix stack info leak in timer_create()

If userland creates a timer without specifying a sigevent info, we'll
create one ourself, using a stack local variable. Particularly will we
use the timer ID as sival_int. But as sigev_value is a union containing
a pointer and an int, that assignment will only partially initialize
sigev_value on systems where the size of a pointer is bigger than the
size of an int. On such systems we'll copy the uninitialized stack bytes
from the timer_create() call to userland when the timer actually fires
and we're going to deliver the signal.

Initialize sigev_value with 0 to plug the stack info leak.

Found in the PaX patch, written by the PaX Team.

Fixes: 5a9fa7307285 (posix-timers: kill -it_sigev_signo and...)
Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Oleg Nesterov o...@redhat.com
Cc: Brad Spengler spen...@grsecurity.net
Cc: PaX Team pagee...@freemail.hu
Cc: sta...@vger.kernel.org# v2.6.28+
Link: 
http://lkml.kernel.org/r/1412456799-32339-1-git-send-email-mini...@googlemail.com
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 kernel/time/posix-timers.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 42b463a..31ea01f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -636,6 +636,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
goto out;
}
} else {
+   memset(event.sigev_value, 0, sizeof(event.sigev_value));
event.sigev_notify = SIGEV_SIGNAL;
event.sigev_signo = SIGALRM;
event.sigev_value.sival_int = new_timer-it_id;
--
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/


[tip:perf/core] perf/x86/intel: Mark initialization code as such

2014-09-09 Thread tip-bot for Mathias Krause
Commit-ID:  066ce64c7e867e95e5fee7c5f6b852710486392a
Gitweb: http://git.kernel.org/tip/066ce64c7e867e95e5fee7c5f6b852710486392a
Author: Mathias Krause 
AuthorDate: Tue, 26 Aug 2014 18:49:45 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 9 Sep 2014 06:53:06 +0200

perf/x86/intel: Mark initialization code as such

A few of the initialization functions are missing the __init annotation.
Fix this and thereby allow ~680 additional bytes of code to be released
after initialization.

Signed-off-by: Mathias Krause 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Arnaldo Carvalho de Melo 
Cc: x...@kernel.org
Link: 
http://lkml.kernel.org/r/1409071785-26015-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c  | 2 +-
 arch/x86/kernel/cpu/perf_event_intel_lbr.c | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c 
b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 9dc4199..b1553d0 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -1014,7 +1014,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs 
*iregs)
  * BTS, PEBS probe and setup
  */
 
-void intel_ds_init(void)
+void __init intel_ds_init(void)
 {
/*
 * No support for 32bit formats
diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c 
b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index 9dd2459..4af1061 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -697,7 +697,7 @@ static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
 };
 
 /* core */
-void intel_pmu_lbr_init_core(void)
+void __init intel_pmu_lbr_init_core(void)
 {
x86_pmu.lbr_nr = 4;
x86_pmu.lbr_tos= MSR_LBR_TOS;
@@ -712,7 +712,7 @@ void intel_pmu_lbr_init_core(void)
 }
 
 /* nehalem/westmere */
-void intel_pmu_lbr_init_nhm(void)
+void __init intel_pmu_lbr_init_nhm(void)
 {
x86_pmu.lbr_nr = 16;
x86_pmu.lbr_tos= MSR_LBR_TOS;
@@ -733,7 +733,7 @@ void intel_pmu_lbr_init_nhm(void)
 }
 
 /* sandy bridge */
-void intel_pmu_lbr_init_snb(void)
+void __init intel_pmu_lbr_init_snb(void)
 {
x86_pmu.lbr_nr   = 16;
x86_pmu.lbr_tos  = MSR_LBR_TOS;
@@ -753,7 +753,7 @@ void intel_pmu_lbr_init_snb(void)
 }
 
 /* atom */
-void intel_pmu_lbr_init_atom(void)
+void __init intel_pmu_lbr_init_atom(void)
 {
/*
 * only models starting at stepping 10 seems
--
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/


[tip:perf/core] perf/x86/intel: Mark initialization code as such

2014-09-09 Thread tip-bot for Mathias Krause
Commit-ID:  066ce64c7e867e95e5fee7c5f6b852710486392a
Gitweb: http://git.kernel.org/tip/066ce64c7e867e95e5fee7c5f6b852710486392a
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Tue, 26 Aug 2014 18:49:45 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 9 Sep 2014 06:53:06 +0200

perf/x86/intel: Mark initialization code as such

A few of the initialization functions are missing the __init annotation.
Fix this and thereby allow ~680 additional bytes of code to be released
after initialization.

Signed-off-by: Mathias Krause mini...@googlemail.com
Signed-off-by: Peter Zijlstra (Intel) pet...@infradead.org
Cc: Arnaldo Carvalho de Melo a...@kernel.org
Cc: x...@kernel.org
Link: 
http://lkml.kernel.org/r/1409071785-26015-1-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c  | 2 +-
 arch/x86/kernel/cpu/perf_event_intel_lbr.c | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c 
b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 9dc4199..b1553d0 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -1014,7 +1014,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs 
*iregs)
  * BTS, PEBS probe and setup
  */
 
-void intel_ds_init(void)
+void __init intel_ds_init(void)
 {
/*
 * No support for 32bit formats
diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c 
b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index 9dd2459..4af1061 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -697,7 +697,7 @@ static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
 };
 
 /* core */
-void intel_pmu_lbr_init_core(void)
+void __init intel_pmu_lbr_init_core(void)
 {
x86_pmu.lbr_nr = 4;
x86_pmu.lbr_tos= MSR_LBR_TOS;
@@ -712,7 +712,7 @@ void intel_pmu_lbr_init_core(void)
 }
 
 /* nehalem/westmere */
-void intel_pmu_lbr_init_nhm(void)
+void __init intel_pmu_lbr_init_nhm(void)
 {
x86_pmu.lbr_nr = 16;
x86_pmu.lbr_tos= MSR_LBR_TOS;
@@ -733,7 +733,7 @@ void intel_pmu_lbr_init_nhm(void)
 }
 
 /* sandy bridge */
-void intel_pmu_lbr_init_snb(void)
+void __init intel_pmu_lbr_init_snb(void)
 {
x86_pmu.lbr_nr   = 16;
x86_pmu.lbr_tos  = MSR_LBR_TOS;
@@ -753,7 +753,7 @@ void intel_pmu_lbr_init_snb(void)
 }
 
 /* atom */
-void intel_pmu_lbr_init_atom(void)
+void __init intel_pmu_lbr_init_atom(void)
 {
/*
 * only models starting at stepping 10 seems
--
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/


[tip:x86/urgent] x86-64, ptdump: Mark espfix area only if existent

2014-09-08 Thread tip-bot for Mathias Krause
Commit-ID:  8a5a5d1530d55e367ef29c80946d0274717617bb
Gitweb: http://git.kernel.org/tip/8a5a5d1530d55e367ef29c80946d0274717617bb
Author: Mathias Krause 
AuthorDate: Sun, 7 Sep 2014 20:30:29 +0200
Committer:  H. Peter Anvin 
CommitDate: Mon, 8 Sep 2014 11:57:34 -0700

x86-64, ptdump: Mark espfix area only if existent

We should classify the espfix area as such only if we actually have
enabled the corresponding option. Otherwise the page table dump might
look confusing.

Signed-off-by: Mathias Krause 
Link: 
http://lkml.kernel.org/r/1410114629-24523-1-git-send-email-mini...@googlemail.com
Cc: Arjan van de Ven 
Cc: H. Peter Anvin 
Signed-off-by: H. Peter Anvin 
---
 arch/x86/mm/dump_pagetables.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 167ffca..95a427e 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -48,7 +48,9 @@ enum address_markers_idx {
LOW_KERNEL_NR,
VMALLOC_START_NR,
VMEMMAP_START_NR,
+# ifdef CONFIG_X86_ESPFIX64
ESPFIX_START_NR,
+# endif
HIGH_KERNEL_NR,
MODULES_VADDR_NR,
MODULES_END_NR,
@@ -71,7 +73,9 @@ static struct addr_marker address_markers[] = {
{ PAGE_OFFSET,  "Low Kernel Mapping" },
{ VMALLOC_START,"vmalloc() Area" },
{ VMEMMAP_START,"Vmemmap" },
+# ifdef CONFIG_X86_ESPFIX64
{ ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
+# endif
{ __START_KERNEL_map,   "High Kernel Mapping" },
{ MODULES_VADDR,"Modules" },
{ MODULES_END,  "End Modules" },
--
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/


[tip:x86/urgent] x86-64, ptdump: Mark espfix area only if existent

2014-09-08 Thread tip-bot for Mathias Krause
Commit-ID:  8a5a5d1530d55e367ef29c80946d0274717617bb
Gitweb: http://git.kernel.org/tip/8a5a5d1530d55e367ef29c80946d0274717617bb
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 7 Sep 2014 20:30:29 +0200
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Mon, 8 Sep 2014 11:57:34 -0700

x86-64, ptdump: Mark espfix area only if existent

We should classify the espfix area as such only if we actually have
enabled the corresponding option. Otherwise the page table dump might
look confusing.

Signed-off-by: Mathias Krause mini...@googlemail.com
Link: 
http://lkml.kernel.org/r/1410114629-24523-1-git-send-email-mini...@googlemail.com
Cc: Arjan van de Ven arjan.van.de@intel.com
Cc: H. Peter Anvin h...@zytor.com
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/mm/dump_pagetables.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 167ffca..95a427e 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -48,7 +48,9 @@ enum address_markers_idx {
LOW_KERNEL_NR,
VMALLOC_START_NR,
VMEMMAP_START_NR,
+# ifdef CONFIG_X86_ESPFIX64
ESPFIX_START_NR,
+# endif
HIGH_KERNEL_NR,
MODULES_VADDR_NR,
MODULES_END_NR,
@@ -71,7 +73,9 @@ static struct addr_marker address_markers[] = {
{ PAGE_OFFSET,  Low Kernel Mapping },
{ VMALLOC_START,vmalloc() Area },
{ VMEMMAP_START,Vmemmap },
+# ifdef CONFIG_X86_ESPFIX64
{ ESPFIX_BASE_ADDR, ESPfix Area, 16 },
+# endif
{ __START_KERNEL_map,   High Kernel Mapping },
{ MODULES_VADDR,Modules },
{ MODULES_END,  End Modules },
--
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/


[tip:perf/core] perf x86: Fix perf to use non-executable stack, again

2014-05-01 Thread tip-bot for Mathias Krause
Commit-ID:  6392b4ebdc1acfbed605d68c437ff5597d0a8d95
Gitweb: http://git.kernel.org/tip/6392b4ebdc1acfbed605d68c437ff5597d0a8d95
Author: Mathias Krause 
AuthorDate: Sun, 27 Apr 2014 18:51:05 +0200
Committer:  Jiri Olsa 
CommitDate: Wed, 30 Apr 2014 17:02:30 +0200

perf x86: Fix perf to use non-executable stack, again

arch/x86/tests/regs_load.S is missing the linker note about the stack
requirements, therefore making the linker fall back to an executable
stack. As this object gets linked against the final perf binary, it'll
needlessly end up with an executable stack. Fix this by adding the
appropriate linker note.

Also add a global linker flag to prevent future regressions, as
suggested by Jiri. This way perf won't get an executable stack even if
we fail to add the .GNU-stack linker note to future assembler files.
Though, doing so might create regressions the other way around, when
(statically) linking against libraries needing an executable stack.
But, apparently, regressing in that direction is wanted as it is an
indicator of poor code quality -- or just missing linker notes.

Fixes: 3c8b06f981 ("perf tests x86: Introduce perf_regs_load function")

Signed-off-by: Mathias Krause 
Acked-by: Ingo Molnar 
Cc: Arnaldo Carvalho de Melo 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1398617466-22749-1-git-send-email-mini...@googlemail.com
Signed-off-by: Jiri Olsa 
---
 tools/perf/arch/x86/tests/regs_load.S | 8 +++-
 tools/perf/config/Makefile| 4 
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/arch/x86/tests/regs_load.S 
b/tools/perf/arch/x86/tests/regs_load.S
index 99167bf..60875d5 100644
--- a/tools/perf/arch/x86/tests/regs_load.S
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -1,4 +1,3 @@
-
 #include 
 
 #define AX  0
@@ -90,3 +89,10 @@ ENTRY(perf_regs_load)
ret
 ENDPROC(perf_regs_load)
 #endif
+
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,"",@progbits
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index a57d59e..802cf54 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -117,6 +117,10 @@ CFLAGS += -Wall
 CFLAGS += -Wextra
 CFLAGS += -std=gnu99
 
+# Enforce a non-executable stack, as we may regress (again) in the future by
+# adding assembler files missing the .GNU-stack linker note.
+LDFLAGS += -Wl,-z,noexecstack
+
 EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
 ifneq ($(OUTPUT),)
--
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/


[tip:perf/core] perf x86: Fix perf to use non-executable stack, again

2014-05-01 Thread tip-bot for Mathias Krause
Commit-ID:  6392b4ebdc1acfbed605d68c437ff5597d0a8d95
Gitweb: http://git.kernel.org/tip/6392b4ebdc1acfbed605d68c437ff5597d0a8d95
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 27 Apr 2014 18:51:05 +0200
Committer:  Jiri Olsa jo...@kernel.org
CommitDate: Wed, 30 Apr 2014 17:02:30 +0200

perf x86: Fix perf to use non-executable stack, again

arch/x86/tests/regs_load.S is missing the linker note about the stack
requirements, therefore making the linker fall back to an executable
stack. As this object gets linked against the final perf binary, it'll
needlessly end up with an executable stack. Fix this by adding the
appropriate linker note.

Also add a global linker flag to prevent future regressions, as
suggested by Jiri. This way perf won't get an executable stack even if
we fail to add the .GNU-stack linker note to future assembler files.
Though, doing so might create regressions the other way around, when
(statically) linking against libraries needing an executable stack.
But, apparently, regressing in that direction is wanted as it is an
indicator of poor code quality -- or just missing linker notes.

Fixes: 3c8b06f981 (perf tests x86: Introduce perf_regs_load function)

Signed-off-by: Mathias Krause mini...@googlemail.com
Acked-by: Ingo Molnar mi...@kernel.org
Cc: Arnaldo Carvalho de Melo a...@kernel.org
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Link: 
http://lkml.kernel.org/r/1398617466-22749-1-git-send-email-mini...@googlemail.com
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 tools/perf/arch/x86/tests/regs_load.S | 8 +++-
 tools/perf/config/Makefile| 4 
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/arch/x86/tests/regs_load.S 
b/tools/perf/arch/x86/tests/regs_load.S
index 99167bf..60875d5 100644
--- a/tools/perf/arch/x86/tests/regs_load.S
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -1,4 +1,3 @@
-
 #include linux/linkage.h
 
 #define AX  0
@@ -90,3 +89,10 @@ ENTRY(perf_regs_load)
ret
 ENDPROC(perf_regs_load)
 #endif
+
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,,@progbits
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index a57d59e..802cf54 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -117,6 +117,10 @@ CFLAGS += -Wall
 CFLAGS += -Wextra
 CFLAGS += -std=gnu99
 
+# Enforce a non-executable stack, as we may regress (again) in the future by
+# adding assembler files missing the .GNU-stack linker note.
+LDFLAGS += -Wl,-z,noexecstack
+
 EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
 ifneq ($(OUTPUT),)
--
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/


[tip:x86/threadinfo] x86, threadinfo: Redo "x86: Use inline assembler to get sp"

2014-03-10 Thread tip-bot for Mathias Krause
Commit-ID:  6cce16f99d7be23cec7cabdf32a8166eec6e5393
Gitweb: http://git.kernel.org/tip/6cce16f99d7be23cec7cabdf32a8166eec6e5393
Author: Mathias Krause 
AuthorDate: Fri, 7 Mar 2014 08:52:32 +0100
Committer:  H. Peter Anvin 
CommitDate: Mon, 10 Mar 2014 17:32:01 -0700

x86, threadinfo: Redo "x86: Use inline assembler to get sp"

This patch restores the changes of commit dff38e3e93 "x86: Use inline
assembler instead of global register variable to get sp". They got lost
in commit 198d208df4 "x86: Keep thread_info on thread stack in x86_32"
while moving the code to arch/x86/kernel/irq_32.c.

Quoting Andi from commit dff38e3e93:

"""
LTO in gcc 4.6/47. has trouble with global register variables. They were
used to read the stack pointer. Use a simple inline assembler statement
with a mov instead.

This also helps LLVM/clang, which does not support global register
variables.
"""

Cc: Steven Rostedt 
Cc: Andrew Morton 
Cc: Peter Zijlstra 
Cc: Brian Gerst 
Cc: Andi Kleen 
Signed-off-by: Mathias Krause 
Link: 
http://lkml.kernel.org/r/1394178752-18047-1-git-send-email-mini...@googlemail.com
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/irq_32.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 988dc8b..63ce838 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -70,7 +70,11 @@ static void call_on_stack(void *func, void *stack)
 }
 
 /* how to get the current stack pointer from C */
-register unsigned long current_stack_pointer asm("esp") __used;
+#define current_stack_pointer ({   \
+   unsigned long sp;   \
+   asm("mov %%esp,%0" : "=g" (sp));\
+   sp; \
+})
 
 static inline void *current_stack(void)
 {
--
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/


[tip:x86/threadinfo] x86, threadinfo: Redo x86: Use inline assembler to get sp

2014-03-10 Thread tip-bot for Mathias Krause
Commit-ID:  6cce16f99d7be23cec7cabdf32a8166eec6e5393
Gitweb: http://git.kernel.org/tip/6cce16f99d7be23cec7cabdf32a8166eec6e5393
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Fri, 7 Mar 2014 08:52:32 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Mon, 10 Mar 2014 17:32:01 -0700

x86, threadinfo: Redo x86: Use inline assembler to get sp

This patch restores the changes of commit dff38e3e93 x86: Use inline
assembler instead of global register variable to get sp. They got lost
in commit 198d208df4 x86: Keep thread_info on thread stack in x86_32
while moving the code to arch/x86/kernel/irq_32.c.

Quoting Andi from commit dff38e3e93:


LTO in gcc 4.6/47. has trouble with global register variables. They were
used to read the stack pointer. Use a simple inline assembler statement
with a mov instead.

This also helps LLVM/clang, which does not support global register
variables.


Cc: Steven Rostedt rost...@goodmis.org
Cc: Andrew Morton a...@linux-foundation.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Brian Gerst brge...@gmail.com
Cc: Andi Kleen a...@linux.intel.com
Signed-off-by: Mathias Krause mini...@googlemail.com
Link: 
http://lkml.kernel.org/r/1394178752-18047-1-git-send-email-mini...@googlemail.com
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/kernel/irq_32.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 988dc8b..63ce838 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -70,7 +70,11 @@ static void call_on_stack(void *func, void *stack)
 }
 
 /* how to get the current stack pointer from C */
-register unsigned long current_stack_pointer asm(esp) __used;
+#define current_stack_pointer ({   \
+   unsigned long sp;   \
+   asm(mov %%esp,%0 : =g (sp));\
+   sp; \
+})
 
 static inline void *current_stack(void)
 {
--
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/


[tip:x86/debug] x86/iommu: Use NULL instead of plain 0 for __IOMMU_INIT

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  ae13b7b4e041eccf34fa4dd58581fe1441375578
Gitweb: http://git.kernel.org/tip/ae13b7b4e041eccf34fa4dd58581fe1441375578
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:46 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:26 +0200

x86/iommu: Use NULL instead of plain 0 for __IOMMU_INIT

IOMMU_INIT_POST and IOMMU_INIT_POST_FINISH pass the plain value
0 instead of NULL to __IOMMU_INIT. Fix this and make sparse
happy by doing so.

Signed-off-by: Mathias Krause 
Cc: Joerg Roedel 
Link: 
http://lkml.kernel.org/r/1346621506-30857-8-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/iommu_table.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/iommu_table.h 
b/arch/x86/include/asm/iommu_table.h
index bbf8fb2..f42a047 100644
--- a/arch/x86/include/asm/iommu_table.h
+++ b/arch/x86/include/asm/iommu_table.h
@@ -63,10 +63,10 @@ struct iommu_table_entry {
  * to stop detecting the other IOMMUs after yours has been detected.
  */
 #define IOMMU_INIT_POST(_detect)   \
-   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  0, 0, 0)
+   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  NULL, NULL, 0)
 
 #define IOMMU_INIT_POST_FINISH(detect) \
-   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  0, 0, 1)
+   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  NULL, NULL, 1)
 
 /*
  * A more sophisticated version of IOMMU_INIT. This variant requires:
--
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/


[tip:x86/debug] x86/iommu: Drop duplicate const in __IOMMU_INIT

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  2b11afd1ab502d959ae8d6d5812923151b5bc505
Gitweb: http://git.kernel.org/tip/2b11afd1ab502d959ae8d6d5812923151b5bc505
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:45 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:26 +0200

x86/iommu: Drop duplicate const in __IOMMU_INIT

It's redundant and makes sparse complain about it.

Signed-off-by: Mathias Krause 
Cc: Joerg Roedel 
Link: 
http://lkml.kernel.org/r/1346621506-30857-7-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/iommu_table.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/iommu_table.h 
b/arch/x86/include/asm/iommu_table.h
index f229b13..bbf8fb2 100644
--- a/arch/x86/include/asm/iommu_table.h
+++ b/arch/x86/include/asm/iommu_table.h
@@ -48,7 +48,7 @@ struct iommu_table_entry {
 
 
 #define __IOMMU_INIT(_detect, _depend, _early_init, _late_init, _finish)\
-   static const struct iommu_table_entry const \
+   static const struct iommu_table_entry   \
__iommu_entry_##_detect __used  \
__attribute__ ((unused, __section__(".iommu_table"),\
aligned((sizeof(void *) \
--
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/


[tip:x86/debug] x86/fpu/xsave: Keep __user annotation in casts

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  5c7d03e99cb1ed449328ed9fba0c632944d39e7e
Gitweb: http://git.kernel.org/tip/5c7d03e99cb1ed449328ed9fba0c632944d39e7e
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:44 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:25 +0200

x86/fpu/xsave: Keep __user annotation in casts

Don't remove the __user annotation of the fpstate pointer, but
drop the superfluous void * cast instead.

This fixes the following sparse warnings:

  xsave.c:135:15: warning: cast removes address space of expression
  xsave.c:135:15: warning: incorrect type in argument 1 (different address 
spaces)
  xsave.c:135:15:expected void const volatile [noderef] *
  [...]

Signed-off-by: Mathias Krause 
Cc: Suresh Siddha 
Link: 
http://lkml.kernel.org/r/1346621506-30857-6-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/xsave.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 3d3e207..9e1a8a7 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -132,9 +132,9 @@ int check_for_xstate(struct i387_fxsave_struct __user *buf,
fx_sw_user->xstate_size > fx_sw_user->extended_size)
return -EINVAL;
 
-   err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
-   fx_sw_user->extended_size -
-   FP_XSTATE_MAGIC2_SIZE));
+   err = __get_user(magic2, (__u32 __user *) (fpstate +
+  fx_sw_user->extended_size -
+  FP_XSTATE_MAGIC2_SIZE));
if (err)
return err;
/*
--
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/


[tip:x86/debug] x86/pci/probe_roms: Add missing __iomem annotation to pci_map_biosrom()

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  04d695a6828bca54d53305246545cd1f8a841ac6
Gitweb: http://git.kernel.org/tip/04d695a6828bca54d53305246545cd1f8a841ac6
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:43 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:25 +0200

x86/pci/probe_roms: Add missing __iomem annotation to pci_map_biosrom()

Stay in sync with the declaration and fix the corresponding
sparse warnings.

Signed-off-by: Mathias Krause 
Cc: Dan Williams 
Link: 
http://lkml.kernel.org/r/1346621506-30857-5-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/probe_roms.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/probe_roms.c b/arch/x86/kernel/probe_roms.c
index 0bc72e2..d5f15c3 100644
--- a/arch/x86/kernel/probe_roms.c
+++ b/arch/x86/kernel/probe_roms.c
@@ -150,7 +150,7 @@ static struct resource *find_oprom(struct pci_dev *pdev)
return oprom;
 }
 
-void *pci_map_biosrom(struct pci_dev *pdev)
+void __iomem *pci_map_biosrom(struct pci_dev *pdev)
 {
struct resource *oprom = find_oprom(pdev);
 
--
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/


[tip:x86/debug] x86/signals: ia32_signal.c: add __user casts to fix sparse warnings

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  0ff8fef4eaf252ee13a2d0b175a8c876415bd62a
Gitweb: http://git.kernel.org/tip/0ff8fef4eaf252ee13a2d0b175a8c876415bd62a
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:42 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:24 +0200

x86/signals: ia32_signal.c: add __user casts to fix sparse warnings

Fix the following sparse warnings by adding appropriate __user
casts and annotations:

  ia32_signal.c:165:38: warning: incorrect type in argument 1 (different 
address spaces)
   ia32_signal.c:165:38:expected struct sigaltstack const [noderef] 
[usertype] *
  ia32_signal.c:165:38:got struct sigaltstack *
  [...]

Signed-off-by: Mathias Krause 
Cc: Oleg Nesterov 
Link: 
http://lkml.kernel.org/r/1346621506-30857-4-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/ia32/ia32_signal.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 673ac9b..452d4dd 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -162,7 +162,8 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user 
*uss_ptr,
}
seg = get_fs();
set_fs(KERNEL_DS);
-   ret = do_sigaltstack(uss_ptr ?  : NULL, , regs->sp);
+   ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ?  : NULL),
+(stack_t __force __user *) , regs->sp);
set_fs(seg);
if (ret >= 0 && uoss_ptr)  {
if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t)))
@@ -361,7 +362,7 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 
__user *sc,
  */
 static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
 size_t frame_size,
-void **fpstate)
+void __user **fpstate)
 {
unsigned long sp;
 
@@ -382,7 +383,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, 
struct pt_regs *regs,
 
if (used_math()) {
sp = sp - sig_xstate_ia32_size;
-   *fpstate = (struct _fpstate_ia32 *) sp;
+   *fpstate = (struct _fpstate_ia32 __user *) sp;
if (save_i387_xstate_ia32(*fpstate) < 0)
return (void __user *) -1L;
}
@@ -448,7 +449,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
 * These are actually not used anymore, but left because some
 * gdb versions depend on them as a marker.
 */
-   put_user_ex(*((u64 *)), (u64 *)frame->retcode);
+   put_user_ex(*((u64 *)), (u64 __user *)frame->retcode);
} put_user_catch(err);
 
if (err)
@@ -529,7 +530,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, 
siginfo_t *info,
 * Not actually used anymore, but left because some gdb
 * versions need it.
 */
-   put_user_ex(*((u64 *)), (u64 *)frame->retcode);
+   put_user_ex(*((u64 *)), (u64 __user *)frame->retcode);
} put_user_catch(err);
 
if (err)
--
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/


[tip:x86/debug] x86/vdso: Add __user annotation to VDSO32_SYMBOL

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  3d1334064fb365ea8f299874c2b4c46de2bee74d
Gitweb: http://git.kernel.org/tip/3d1334064fb365ea8f299874c2b4c46de2bee74d
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:41 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:23 +0200

x86/vdso: Add __user annotation to VDSO32_SYMBOL

The address calculated by VDSO32_SYMBOL() is a pointer into
userland. Add the __user annotation to fix related sparse
warnings in its users.

Signed-off-by: Mathias Krause 
Cc: Andy Lutomirski 
Link: 
http://lkml.kernel.org/r/1346621506-30857-3-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/vdso.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index bb05228..fddb53d 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -11,7 +11,8 @@ extern const char VDSO32_PRELINK[];
 #define VDSO32_SYMBOL(base, name)  \
 ({ \
extern const char VDSO32_##name[];  \
-   (void *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
+   (void __user *)(VDSO32_##name - VDSO32_PRELINK +\
+   (unsigned long)(base)); \
 })
 #endif
 
--
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/


[tip:x86/debug] x86: Fix __user annotations in asm/sys_ia32.h

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  f00026276ace77dcad1cdf17f696ae4e56e12ee6
Gitweb: http://git.kernel.org/tip/f00026276ace77dcad1cdf17f696ae4e56e12ee6
Author: Mathias Krause 
AuthorDate: Sun, 2 Sep 2012 23:31:40 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 5 Sep 2012 10:52:23 +0200

x86: Fix __user annotations in asm/sys_ia32.h

Fix the following sparse warnings:

  sys_ia32.c:293:38: warning: incorrect type in argument 2 (different address 
spaces)
  sys_ia32.c:293:38:expected unsigned int [noderef] [usertype] 
*stat_addr
  sys_ia32.c:293:38:got unsigned int *stat_addr

Ironically, sys_ia32.h was introduced to fix sparse warnings but
missed that one.

Signed-off-by: Mathias Krause 
Link: 
http://lkml.kernel.org/r/1346621506-30857-2-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/ia32/sys_ia32.c|2 +-
 arch/x86/include/asm/sys_ia32.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index 4540bec..c5b938d 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -287,7 +287,7 @@ asmlinkage long sys32_sigaction(int sig, struct 
old_sigaction32 __user *act,
return ret;
 }
 
-asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
+asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int __user *stat_addr,
  int options)
 {
return compat_sys_wait4(pid, stat_addr, options, NULL);
diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
index 3fda9db4..4ca1c61 100644
--- a/arch/x86/include/asm/sys_ia32.h
+++ b/arch/x86/include/asm/sys_ia32.h
@@ -40,7 +40,7 @@ asmlinkage long sys32_sigaction(int, struct old_sigaction32 
__user *,
struct old_sigaction32 __user *);
 asmlinkage long sys32_alarm(unsigned int);
 
-asmlinkage long sys32_waitpid(compat_pid_t, unsigned int *, int);
+asmlinkage long sys32_waitpid(compat_pid_t, unsigned int __user *, int);
 asmlinkage long sys32_sysfs(int, u32, u32);
 
 asmlinkage long sys32_sched_rr_get_interval(compat_pid_t,
--
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/


[tip:x86/debug] x86: Fix __user annotations in asm/sys_ia32.h

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  f00026276ace77dcad1cdf17f696ae4e56e12ee6
Gitweb: http://git.kernel.org/tip/f00026276ace77dcad1cdf17f696ae4e56e12ee6
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:40 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:23 +0200

x86: Fix __user annotations in asm/sys_ia32.h

Fix the following sparse warnings:

  sys_ia32.c:293:38: warning: incorrect type in argument 2 (different address 
spaces)
  sys_ia32.c:293:38:expected unsigned int [noderef] [usertype] 
asn:1*stat_addr
  sys_ia32.c:293:38:got unsigned int *stat_addr

Ironically, sys_ia32.h was introduced to fix sparse warnings but
missed that one.

Signed-off-by: Mathias Krause mini...@googlemail.com
Link: 
http://lkml.kernel.org/r/1346621506-30857-2-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/ia32/sys_ia32.c|2 +-
 arch/x86/include/asm/sys_ia32.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index 4540bec..c5b938d 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -287,7 +287,7 @@ asmlinkage long sys32_sigaction(int sig, struct 
old_sigaction32 __user *act,
return ret;
 }
 
-asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
+asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int __user *stat_addr,
  int options)
 {
return compat_sys_wait4(pid, stat_addr, options, NULL);
diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
index 3fda9db4..4ca1c61 100644
--- a/arch/x86/include/asm/sys_ia32.h
+++ b/arch/x86/include/asm/sys_ia32.h
@@ -40,7 +40,7 @@ asmlinkage long sys32_sigaction(int, struct old_sigaction32 
__user *,
struct old_sigaction32 __user *);
 asmlinkage long sys32_alarm(unsigned int);
 
-asmlinkage long sys32_waitpid(compat_pid_t, unsigned int *, int);
+asmlinkage long sys32_waitpid(compat_pid_t, unsigned int __user *, int);
 asmlinkage long sys32_sysfs(int, u32, u32);
 
 asmlinkage long sys32_sched_rr_get_interval(compat_pid_t,
--
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/


[tip:x86/debug] x86/vdso: Add __user annotation to VDSO32_SYMBOL

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  3d1334064fb365ea8f299874c2b4c46de2bee74d
Gitweb: http://git.kernel.org/tip/3d1334064fb365ea8f299874c2b4c46de2bee74d
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:41 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:23 +0200

x86/vdso: Add __user annotation to VDSO32_SYMBOL

The address calculated by VDSO32_SYMBOL() is a pointer into
userland. Add the __user annotation to fix related sparse
warnings in its users.

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Andy Lutomirski l...@mit.edu
Link: 
http://lkml.kernel.org/r/1346621506-30857-3-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/vdso.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index bb05228..fddb53d 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -11,7 +11,8 @@ extern const char VDSO32_PRELINK[];
 #define VDSO32_SYMBOL(base, name)  \
 ({ \
extern const char VDSO32_##name[];  \
-   (void *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
+   (void __user *)(VDSO32_##name - VDSO32_PRELINK +\
+   (unsigned long)(base)); \
 })
 #endif
 
--
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/


[tip:x86/debug] x86/signals: ia32_signal.c: add __user casts to fix sparse warnings

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  0ff8fef4eaf252ee13a2d0b175a8c876415bd62a
Gitweb: http://git.kernel.org/tip/0ff8fef4eaf252ee13a2d0b175a8c876415bd62a
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:42 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:24 +0200

x86/signals: ia32_signal.c: add __user casts to fix sparse warnings

Fix the following sparse warnings by adding appropriate __user
casts and annotations:

  ia32_signal.c:165:38: warning: incorrect type in argument 1 (different 
address spaces)
   ia32_signal.c:165:38:expected struct sigaltstack const [noderef] 
[usertype] asn:1*noident
  ia32_signal.c:165:38:got struct sigaltstack *
  [...]

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Oleg Nesterov o...@redhat.com
Link: 
http://lkml.kernel.org/r/1346621506-30857-4-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/ia32/ia32_signal.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 673ac9b..452d4dd 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -162,7 +162,8 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user 
*uss_ptr,
}
seg = get_fs();
set_fs(KERNEL_DS);
-   ret = do_sigaltstack(uss_ptr ? uss : NULL, uoss, regs-sp);
+   ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? uss : NULL),
+(stack_t __force __user *) uoss, regs-sp);
set_fs(seg);
if (ret = 0  uoss_ptr)  {
if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t)))
@@ -361,7 +362,7 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 
__user *sc,
  */
 static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
 size_t frame_size,
-void **fpstate)
+void __user **fpstate)
 {
unsigned long sp;
 
@@ -382,7 +383,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, 
struct pt_regs *regs,
 
if (used_math()) {
sp = sp - sig_xstate_ia32_size;
-   *fpstate = (struct _fpstate_ia32 *) sp;
+   *fpstate = (struct _fpstate_ia32 __user *) sp;
if (save_i387_xstate_ia32(*fpstate)  0)
return (void __user *) -1L;
}
@@ -448,7 +449,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
 * These are actually not used anymore, but left because some
 * gdb versions depend on them as a marker.
 */
-   put_user_ex(*((u64 *)code), (u64 *)frame-retcode);
+   put_user_ex(*((u64 *)code), (u64 __user *)frame-retcode);
} put_user_catch(err);
 
if (err)
@@ -529,7 +530,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, 
siginfo_t *info,
 * Not actually used anymore, but left because some gdb
 * versions need it.
 */
-   put_user_ex(*((u64 *)code), (u64 *)frame-retcode);
+   put_user_ex(*((u64 *)code), (u64 __user *)frame-retcode);
} put_user_catch(err);
 
if (err)
--
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/


[tip:x86/debug] x86/pci/probe_roms: Add missing __iomem annotation to pci_map_biosrom()

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  04d695a6828bca54d53305246545cd1f8a841ac6
Gitweb: http://git.kernel.org/tip/04d695a6828bca54d53305246545cd1f8a841ac6
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:43 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:25 +0200

x86/pci/probe_roms: Add missing __iomem annotation to pci_map_biosrom()

Stay in sync with the declaration and fix the corresponding
sparse warnings.

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Dan Williams dan.j.willi...@intel.com
Link: 
http://lkml.kernel.org/r/1346621506-30857-5-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/probe_roms.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/probe_roms.c b/arch/x86/kernel/probe_roms.c
index 0bc72e2..d5f15c3 100644
--- a/arch/x86/kernel/probe_roms.c
+++ b/arch/x86/kernel/probe_roms.c
@@ -150,7 +150,7 @@ static struct resource *find_oprom(struct pci_dev *pdev)
return oprom;
 }
 
-void *pci_map_biosrom(struct pci_dev *pdev)
+void __iomem *pci_map_biosrom(struct pci_dev *pdev)
 {
struct resource *oprom = find_oprom(pdev);
 
--
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/


[tip:x86/debug] x86/fpu/xsave: Keep __user annotation in casts

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  5c7d03e99cb1ed449328ed9fba0c632944d39e7e
Gitweb: http://git.kernel.org/tip/5c7d03e99cb1ed449328ed9fba0c632944d39e7e
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:44 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:25 +0200

x86/fpu/xsave: Keep __user annotation in casts

Don't remove the __user annotation of the fpstate pointer, but
drop the superfluous void * cast instead.

This fixes the following sparse warnings:

  xsave.c:135:15: warning: cast removes address space of expression
  xsave.c:135:15: warning: incorrect type in argument 1 (different address 
spaces)
  xsave.c:135:15:expected void const volatile [noderef] asn:1*noident
  [...]

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Suresh Siddha suresh.b.sid...@intel.com
Link: 
http://lkml.kernel.org/r/1346621506-30857-6-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/xsave.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 3d3e207..9e1a8a7 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -132,9 +132,9 @@ int check_for_xstate(struct i387_fxsave_struct __user *buf,
fx_sw_user-xstate_size  fx_sw_user-extended_size)
return -EINVAL;
 
-   err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
-   fx_sw_user-extended_size -
-   FP_XSTATE_MAGIC2_SIZE));
+   err = __get_user(magic2, (__u32 __user *) (fpstate +
+  fx_sw_user-extended_size -
+  FP_XSTATE_MAGIC2_SIZE));
if (err)
return err;
/*
--
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/


[tip:x86/debug] x86/iommu: Drop duplicate const in __IOMMU_INIT

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  2b11afd1ab502d959ae8d6d5812923151b5bc505
Gitweb: http://git.kernel.org/tip/2b11afd1ab502d959ae8d6d5812923151b5bc505
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:45 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:26 +0200

x86/iommu: Drop duplicate const in __IOMMU_INIT

It's redundant and makes sparse complain about it.

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Joerg Roedel joerg.roe...@amd.com
Link: 
http://lkml.kernel.org/r/1346621506-30857-7-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/iommu_table.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/iommu_table.h 
b/arch/x86/include/asm/iommu_table.h
index f229b13..bbf8fb2 100644
--- a/arch/x86/include/asm/iommu_table.h
+++ b/arch/x86/include/asm/iommu_table.h
@@ -48,7 +48,7 @@ struct iommu_table_entry {
 
 
 #define __IOMMU_INIT(_detect, _depend, _early_init, _late_init, _finish)\
-   static const struct iommu_table_entry const \
+   static const struct iommu_table_entry   \
__iommu_entry_##_detect __used  \
__attribute__ ((unused, __section__(.iommu_table),\
aligned((sizeof(void *) \
--
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/


[tip:x86/debug] x86/iommu: Use NULL instead of plain 0 for __IOMMU_INIT

2012-09-05 Thread tip-bot for Mathias Krause
Commit-ID:  ae13b7b4e041eccf34fa4dd58581fe1441375578
Gitweb: http://git.kernel.org/tip/ae13b7b4e041eccf34fa4dd58581fe1441375578
Author: Mathias Krause mini...@googlemail.com
AuthorDate: Sun, 2 Sep 2012 23:31:46 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 5 Sep 2012 10:52:26 +0200

x86/iommu: Use NULL instead of plain 0 for __IOMMU_INIT

IOMMU_INIT_POST and IOMMU_INIT_POST_FINISH pass the plain value
0 instead of NULL to __IOMMU_INIT. Fix this and make sparse
happy by doing so.

Signed-off-by: Mathias Krause mini...@googlemail.com
Cc: Joerg Roedel joerg.roe...@amd.com
Link: 
http://lkml.kernel.org/r/1346621506-30857-8-git-send-email-mini...@googlemail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/iommu_table.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/iommu_table.h 
b/arch/x86/include/asm/iommu_table.h
index bbf8fb2..f42a047 100644
--- a/arch/x86/include/asm/iommu_table.h
+++ b/arch/x86/include/asm/iommu_table.h
@@ -63,10 +63,10 @@ struct iommu_table_entry {
  * to stop detecting the other IOMMUs after yours has been detected.
  */
 #define IOMMU_INIT_POST(_detect)   \
-   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  0, 0, 0)
+   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  NULL, NULL, 0)
 
 #define IOMMU_INIT_POST_FINISH(detect) \
-   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  0, 0, 1)
+   __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb,  NULL, NULL, 1)
 
 /*
  * A more sophisticated version of IOMMU_INIT. This variant requires:
--
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/