[tip:x86/cpufeature] x86, cpufeature: Convert more "features" to bugs

2014-06-18 Thread tip-bot for Borislav Petkov
Commit-ID:  9b13a93df267af681a66a6a738bf1af10102da7d
Gitweb: http://git.kernel.org/tip/9b13a93df267af681a66a6a738bf1af10102da7d
Author: Borislav Petkov 
AuthorDate: Wed, 18 Jun 2014 00:06:23 +0200
Committer:  H. Peter Anvin 
CommitDate: Wed, 18 Jun 2014 15:27:04 -0700

x86, cpufeature: Convert more "features" to bugs

X86_FEATURE_FXSAVE_LEAK, X86_FEATURE_11AP and
X86_FEATURE_CLFLUSH_MONITOR are not really features but synthetic bits
we use for applying different bug workarounds. Call them what they
really are, and make sure they get the proper cross-CPU behavior (OR
rather than AND).

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1403042783-23278-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/apic.h |  2 +-
 arch/x86/include/asm/cpufeature.h   | 31 +--
 arch/x86/include/asm/fpu-internal.h |  2 +-
 arch/x86/include/asm/mwait.h|  2 +-
 arch/x86/kernel/cpu/amd.c   |  2 +-
 arch/x86/kernel/cpu/intel.c |  4 ++--
 6 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 19b0eba..79752f2 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -99,7 +99,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v)
 {
volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
 
-   alternative_io("movl %0, %1", "xchgl %0, %1", X86_FEATURE_11AP,
+   alternative_io("movl %0, %1", "xchgl %0, %1", X86_BUG_11AP,
   ASM_OUTPUT2("=r" (v), "=m" (*addr)),
   ASM_OUTPUT2("0" (v), "m" (*addr)));
 }
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index b82f951..52df22b 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -81,7 +81,7 @@
 #define X86_FEATURE_P4 ( 3*32+ 7) /* "" P4 */
 #define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* TSC ticks at a constant rate */
 #define X86_FEATURE_UP ( 3*32+ 9) /* smp kernel running on up */
-#define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) /* "" FXSAVE leaks FOP/FIP/FOP */
+/* free, was #define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) * "" FXSAVE leaks 
FOP/FIP/FOP */
 #define X86_FEATURE_ARCH_PERFMON ( 3*32+11) /* Intel Architectural PerfMon */
 #define X86_FEATURE_PEBS   ( 3*32+12) /* Precise-Event Based Sampling */
 #define X86_FEATURE_BTS( 3*32+13) /* Branch Trace Store */
@@ -90,13 +90,13 @@
 #define X86_FEATURE_REP_GOOD   ( 3*32+16) /* rep microcode works well */
 #define X86_FEATURE_MFENCE_RDTSC ( 3*32+17) /* "" Mfence synchronizes RDTSC */
 #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" Lfence synchronizes RDTSC */
-#define X86_FEATURE_11AP   ( 3*32+19) /* "" Bad local APIC aka 11AP */
+/* free, was #define X86_FEATURE_11AP  ( 3*32+19) * "" Bad local APIC aka 11AP 
*/
 #define X86_FEATURE_NOPL   ( 3*32+20) /* The NOPL (0F 1F) instructions */
 #define X86_FEATURE_ALWAYS ( 3*32+21) /* "" Always-present feature */
 #define X86_FEATURE_XTOPOLOGY  ( 3*32+22) /* cpu topology enum extensions */
 #define X86_FEATURE_TSC_RELIABLE ( 3*32+23) /* TSC is known to be reliable */
 #define X86_FEATURE_NONSTOP_TSC( 3*32+24) /* TSC does not stop in C 
states */
-#define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) /* "" clflush reqd with monitor 
*/
+/* free, was #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) * "" clflush reqd 
with monitor */
 #define X86_FEATURE_EXTD_APICID( 3*32+26) /* has extended APICID (8 
bits) */
 #define X86_FEATURE_AMD_DCM ( 3*32+27) /* multi-node processor */
 #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */
@@ -241,6 +241,9 @@
 #define X86_BUG_COMA   X86_BUG(2) /* Cyrix 6x86 coma */
 #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3) /* AMD Erratum 383 */
 #define X86_BUG_AMD_APIC_C1E   X86_BUG(4) /* AMD Erratum 400 */
+#define X86_BUG_11AP   X86_BUG(5) /* Bad local APIC aka 11AP */
+#define X86_BUG_FXSAVE_LEAKX86_BUG(6) /* FXSAVE leaks FOP/FIP/FOP */
+#define X86_BUG_CLFLUSH_MONITORX86_BUG(7) /* AAI65, CLFLUSH required 
before MONITOR */
 
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 
@@ -545,20 +548,20 @@ static __always_inline __pure bool 
_static_cpu_has_safe(u16 bit)
 #define static_cpu_has_safe(bit)   boot_cpu_has(bit)
 #endif
 
-#define cpu_has_bug(c, bit)cpu_has(c, (bit))
-#define set_cpu_bug(c, bit)set_cpu_cap(c, (bit))
-#define clear_cpu_bug(c, bit)  clear_cpu_cap(c, (bit));
+#define cpu_has_bug(c, bit)cpu_has(c, (bit))
+#define set_cpu_bug(c, bit)set_cpu_cap(c, (bit))
+#define clear_cpu_bug(c, bit)  clear_cpu_cap(c, (bit))
 
-#define static_cpu_has_bug(bit)static_cpu_has((bit))
-#define boot_cpu_has_bug(bit)  cpu_has_bug(_cpu_data, (bit))
+#define static_cpu_has_bug(bit)static_cpu_has((bit))
+#define static_cpu_has_bug_safe(bit)   static_cpu_has_safe((bit))
+#define 

[tip:x86/xsave] x86, xsave: Add forgotten inline annotation

2014-06-18 Thread tip-bot for Borislav Petkov
Commit-ID:  d0f2dd186133a0241a2ccefb188a0e49e8187859
Gitweb: http://git.kernel.org/tip/d0f2dd186133a0241a2ccefb188a0e49e8187859
Author: Borislav Petkov 
AuthorDate: Tue, 17 Jun 2014 12:21:08 +0200
Committer:  H. Peter Anvin 
CommitDate: Wed, 18 Jun 2014 15:19:59 -0700

x86, xsave: Add forgotten inline annotation

Add a missing inline annotation on a static function, in order to shut
up a bunch of warnings like:

In file included from arch/x86/crypto/camellia_aesni_avx_glue.c:23:0:
./arch/x86/include/asm/xsave.h:73:12: warning: ‘xsave_state_booting’ defined 
but not used [-Wunused-function]
 static int xsave_state_booting(struct xsave_struct *fx, u64 mask)
^
In file included from arch/x86/crypto/camellia_aesni_avx2_glue.c:23:0:
./arch/x86/include/asm/xsave.h:73:12: warning: ‘xsave_state_booting’ defined 
but not used [-Wunused-function]
 static int xsave_state_booting(struct xsave_struct *fx, u64 mask)
^
...

Cc: Fenghua Yu 
Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1403000468-30094-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/xsave.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
index bbebd6e..7e7a79a 100644
--- a/arch/x86/include/asm/xsave.h
+++ b/arch/x86/include/asm/xsave.h
@@ -70,7 +70,7 @@ extern int init_fpu(struct task_struct *child);
  * This function is called only during boot time when x86 caps are not set
  * up and alternative can not be used yet.
  */
-static int xsave_state_booting(struct xsave_struct *fx, u64 mask)
+static inline int xsave_state_booting(struct xsave_struct *fx, u64 mask)
 {
u32 lmask = mask;
u32 hmask = mask >> 32;
--
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/xsave] x86, xsave: Add forgotten inline annotation

2014-06-18 Thread tip-bot for Borislav Petkov
Commit-ID:  d0f2dd186133a0241a2ccefb188a0e49e8187859
Gitweb: http://git.kernel.org/tip/d0f2dd186133a0241a2ccefb188a0e49e8187859
Author: Borislav Petkov b...@suse.de
AuthorDate: Tue, 17 Jun 2014 12:21:08 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Wed, 18 Jun 2014 15:19:59 -0700

x86, xsave: Add forgotten inline annotation

Add a missing inline annotation on a static function, in order to shut
up a bunch of warnings like:

In file included from arch/x86/crypto/camellia_aesni_avx_glue.c:23:0:
./arch/x86/include/asm/xsave.h:73:12: warning: ‘xsave_state_booting’ defined 
but not used [-Wunused-function]
 static int xsave_state_booting(struct xsave_struct *fx, u64 mask)
^
In file included from arch/x86/crypto/camellia_aesni_avx2_glue.c:23:0:
./arch/x86/include/asm/xsave.h:73:12: warning: ‘xsave_state_booting’ defined 
but not used [-Wunused-function]
 static int xsave_state_booting(struct xsave_struct *fx, u64 mask)
^
...

Cc: Fenghua Yu fenghua...@intel.com
Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1403000468-30094-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/xsave.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
index bbebd6e..7e7a79a 100644
--- a/arch/x86/include/asm/xsave.h
+++ b/arch/x86/include/asm/xsave.h
@@ -70,7 +70,7 @@ extern int init_fpu(struct task_struct *child);
  * This function is called only during boot time when x86 caps are not set
  * up and alternative can not be used yet.
  */
-static int xsave_state_booting(struct xsave_struct *fx, u64 mask)
+static inline int xsave_state_booting(struct xsave_struct *fx, u64 mask)
 {
u32 lmask = mask;
u32 hmask = mask  32;
--
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/cpufeature] x86, cpufeature: Convert more features to bugs

2014-06-18 Thread tip-bot for Borislav Petkov
Commit-ID:  9b13a93df267af681a66a6a738bf1af10102da7d
Gitweb: http://git.kernel.org/tip/9b13a93df267af681a66a6a738bf1af10102da7d
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 18 Jun 2014 00:06:23 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Wed, 18 Jun 2014 15:27:04 -0700

x86, cpufeature: Convert more features to bugs

X86_FEATURE_FXSAVE_LEAK, X86_FEATURE_11AP and
X86_FEATURE_CLFLUSH_MONITOR are not really features but synthetic bits
we use for applying different bug workarounds. Call them what they
really are, and make sure they get the proper cross-CPU behavior (OR
rather than AND).

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1403042783-23278-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/apic.h |  2 +-
 arch/x86/include/asm/cpufeature.h   | 31 +--
 arch/x86/include/asm/fpu-internal.h |  2 +-
 arch/x86/include/asm/mwait.h|  2 +-
 arch/x86/kernel/cpu/amd.c   |  2 +-
 arch/x86/kernel/cpu/intel.c |  4 ++--
 6 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 19b0eba..79752f2 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -99,7 +99,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v)
 {
volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
 
-   alternative_io(movl %0, %1, xchgl %0, %1, X86_FEATURE_11AP,
+   alternative_io(movl %0, %1, xchgl %0, %1, X86_BUG_11AP,
   ASM_OUTPUT2(=r (v), =m (*addr)),
   ASM_OUTPUT2(0 (v), m (*addr)));
 }
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index b82f951..52df22b 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -81,7 +81,7 @@
 #define X86_FEATURE_P4 ( 3*32+ 7) /*  P4 */
 #define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* TSC ticks at a constant rate */
 #define X86_FEATURE_UP ( 3*32+ 9) /* smp kernel running on up */
-#define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) /*  FXSAVE leaks FOP/FIP/FOP */
+/* free, was #define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) *  FXSAVE leaks 
FOP/FIP/FOP */
 #define X86_FEATURE_ARCH_PERFMON ( 3*32+11) /* Intel Architectural PerfMon */
 #define X86_FEATURE_PEBS   ( 3*32+12) /* Precise-Event Based Sampling */
 #define X86_FEATURE_BTS( 3*32+13) /* Branch Trace Store */
@@ -90,13 +90,13 @@
 #define X86_FEATURE_REP_GOOD   ( 3*32+16) /* rep microcode works well */
 #define X86_FEATURE_MFENCE_RDTSC ( 3*32+17) /*  Mfence synchronizes RDTSC */
 #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /*  Lfence synchronizes RDTSC */
-#define X86_FEATURE_11AP   ( 3*32+19) /*  Bad local APIC aka 11AP */
+/* free, was #define X86_FEATURE_11AP  ( 3*32+19) *  Bad local APIC aka 11AP 
*/
 #define X86_FEATURE_NOPL   ( 3*32+20) /* The NOPL (0F 1F) instructions */
 #define X86_FEATURE_ALWAYS ( 3*32+21) /*  Always-present feature */
 #define X86_FEATURE_XTOPOLOGY  ( 3*32+22) /* cpu topology enum extensions */
 #define X86_FEATURE_TSC_RELIABLE ( 3*32+23) /* TSC is known to be reliable */
 #define X86_FEATURE_NONSTOP_TSC( 3*32+24) /* TSC does not stop in C 
states */
-#define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) /*  clflush reqd with monitor 
*/
+/* free, was #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) *  clflush reqd 
with monitor */
 #define X86_FEATURE_EXTD_APICID( 3*32+26) /* has extended APICID (8 
bits) */
 #define X86_FEATURE_AMD_DCM ( 3*32+27) /* multi-node processor */
 #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */
@@ -241,6 +241,9 @@
 #define X86_BUG_COMA   X86_BUG(2) /* Cyrix 6x86 coma */
 #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3) /* AMD Erratum 383 */
 #define X86_BUG_AMD_APIC_C1E   X86_BUG(4) /* AMD Erratum 400 */
+#define X86_BUG_11AP   X86_BUG(5) /* Bad local APIC aka 11AP */
+#define X86_BUG_FXSAVE_LEAKX86_BUG(6) /* FXSAVE leaks FOP/FIP/FOP */
+#define X86_BUG_CLFLUSH_MONITORX86_BUG(7) /* AAI65, CLFLUSH required 
before MONITOR */
 
 #if defined(__KERNEL__)  !defined(__ASSEMBLY__)
 
@@ -545,20 +548,20 @@ static __always_inline __pure bool 
_static_cpu_has_safe(u16 bit)
 #define static_cpu_has_safe(bit)   boot_cpu_has(bit)
 #endif
 
-#define cpu_has_bug(c, bit)cpu_has(c, (bit))
-#define set_cpu_bug(c, bit)set_cpu_cap(c, (bit))
-#define clear_cpu_bug(c, bit)  clear_cpu_cap(c, (bit));
+#define cpu_has_bug(c, bit)cpu_has(c, (bit))
+#define set_cpu_bug(c, bit)set_cpu_cap(c, (bit))
+#define clear_cpu_bug(c, bit)  clear_cpu_cap(c, (bit))
 
-#define static_cpu_has_bug(bit)static_cpu_has((bit))
-#define boot_cpu_has_bug(bit)  cpu_has_bug(boot_cpu_data, (bit))
+#define static_cpu_has_bug(bit)static_cpu_has((bit))
+#define static_cpu_has_bug_safe(bit)   

[tip:x86/microcode] x86, boot: Carve out early cmdline parsing function

2014-05-20 Thread tip-bot for Borislav Petkov
Commit-ID:  1b1ded57a4f2f4420b4de7c395d1b841d8b3c41a
Gitweb: http://git.kernel.org/tip/1b1ded57a4f2f4420b4de7c395d1b841d8b3c41a
Author: Borislav Petkov 
AuthorDate: Mon, 19 May 2014 20:59:16 +0200
Committer:  H. Peter Anvin 
CommitDate: Tue, 20 May 2014 20:21:24 -0700

x86, boot: Carve out early cmdline parsing function

Carve out early cmdline parsing function into .../lib/cmdline.c so it
can be used by early code in the kernel proper as well.

Adapted from arch/x86/boot/cmdline.c.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1400525957-11525-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/cmdline.h |  6 +++
 arch/x86/lib/Makefile  |  2 +-
 arch/x86/lib/cmdline.c | 84 ++
 3 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cmdline.h b/arch/x86/include/asm/cmdline.h
new file mode 100644
index 000..e01f7f7
--- /dev/null
+++ b/arch/x86/include/asm/cmdline.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_CMDLINE_H
+#define _ASM_X86_CMDLINE_H
+
+int cmdline_find_option_bool(const char *cmdline_ptr, const char *option);
+
+#endif /* _ASM_X86_CMDLINE_H */
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index eabcb6e..4d4f96a 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -16,7 +16,7 @@ clean-files := inat-tables.c
 
 obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o
 
-lib-y := delay.o misc.o
+lib-y := delay.o misc.o cmdline.o
 lib-y += thunk_$(BITS).o
 lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
 lib-y += memcpy_$(BITS).o
diff --git a/arch/x86/lib/cmdline.c b/arch/x86/lib/cmdline.c
new file mode 100644
index 000..422db00
--- /dev/null
+++ b/arch/x86/lib/cmdline.c
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the Linux kernel, and is made available under
+ * the terms of the GNU General Public License version 2.
+ *
+ * Misc librarized functions for cmdline poking.
+ */
+#include 
+#include 
+#include 
+#include 
+
+static inline int myisspace(u8 c)
+{
+   return c <= ' ';/* Close enough approximation */
+}
+
+/**
+ * Find a boolean option (like quiet,noapic,nosmp)
+ *
+ * @cmdline: the cmdline string
+ * @option: option string to look for
+ *
+ * Returns the position of that @option (starts counting with 1)
+ * or 0 on not found.
+ */
+int cmdline_find_option_bool(const char *cmdline, const char *option)
+{
+   char c;
+   int len, pos = 0, wstart = 0;
+   const char *opptr = NULL;
+   enum {
+   st_wordstart = 0,   /* Start of word/after whitespace */
+   st_wordcmp, /* Comparing this word */
+   st_wordskip,/* Miscompare, skip */
+   } state = st_wordstart;
+
+   if (!cmdline)
+   return -1;  /* No command line */
+
+   len = min_t(int, strlen(cmdline), COMMAND_LINE_SIZE);
+   if (!len)
+   return 0;
+
+   while (len--) {
+   c = *(char *)cmdline++;
+   pos++;
+
+   switch (state) {
+   case st_wordstart:
+   if (!c)
+   return 0;
+   else if (myisspace(c))
+   break;
+
+   state = st_wordcmp;
+   opptr = option;
+   wstart = pos;
+   /* fall through */
+
+   case st_wordcmp:
+   if (!*opptr)
+   if (!c || myisspace(c))
+   return wstart;
+   else
+   state = st_wordskip;
+   else if (!c)
+   return 0;
+   else if (c != *opptr++)
+   state = st_wordskip;
+   else if (!len)  /* last word and is matching */
+   return wstart;
+   break;
+
+   case st_wordskip:
+   if (!c)
+   return 0;
+   else if (myisspace(c))
+   state = st_wordstart;
+   break;
+   }
+   }
+
+   return 0;   /* Buffer overrun */
+}
--
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/microcode] x86, microcode: Add a disable chicken bit

2014-05-20 Thread tip-bot for Borislav Petkov
Commit-ID:  65cef1311d5d212fd3d48a43678536dc878ca288
Gitweb: http://git.kernel.org/tip/65cef1311d5d212fd3d48a43678536dc878ca288
Author: Borislav Petkov 
AuthorDate: Mon, 19 May 2014 20:59:17 +0200
Committer:  H. Peter Anvin 
CommitDate: Tue, 20 May 2014 20:21:27 -0700

x86, microcode: Add a disable chicken bit

Add a cmdline param which disables the microcode loader. This is useful
mostly in debugging situations where we want to turn off microcode
loading, both early from the initrd and late, as a means to be able to
rule out its influence on the machine.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1400525957-11525-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/microcode.h   |  1 +
 arch/x86/kernel/cpu/microcode/core.c   |  6 +
 arch/x86/kernel/cpu/microcode/core_early.c | 37 ++
 3 files changed, 44 insertions(+)

diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index b59827e..64dc362 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -25,6 +25,7 @@ struct cpu_signature {
 struct device;
 
 enum ucode_state { UCODE_ERROR, UCODE_OK, UCODE_NFOUND };
+extern bool dis_ucode_ldr;
 
 struct microcode_ops {
enum ucode_state (*request_microcode_user) (int cpu,
diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index 15c9876..dd9d619 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -97,6 +97,9 @@ MODULE_LICENSE("GPL");
 
 static struct microcode_ops*microcode_ops;
 
+bool dis_ucode_ldr;
+module_param(dis_ucode_ldr, bool, 0);
+
 /*
  * Synchronization.
  *
@@ -546,6 +549,9 @@ static int __init microcode_init(void)
struct cpuinfo_x86 *c = _data(0);
int error;
 
+   if (dis_ucode_ldr)
+   return 0;
+
if (c->x86_vendor == X86_VENDOR_INTEL)
microcode_ops = init_intel_microcode();
else if (c->x86_vendor == X86_VENDOR_AMD)
diff --git a/arch/x86/kernel/cpu/microcode/core_early.c 
b/arch/x86/kernel/cpu/microcode/core_early.c
index be7f851..5f28a64 100644
--- a/arch/x86/kernel/cpu/microcode/core_early.c
+++ b/arch/x86/kernel/cpu/microcode/core_early.c
@@ -17,9 +17,11 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #define QCHAR(a, b, c, d) ((a) + ((b) << 8) + ((c) << 16) + ((d) << 24))
 #define CPUID_INTEL1 QCHAR('G', 'e', 'n', 'u')
@@ -72,10 +74,33 @@ static int x86_family(void)
return x86;
 }
 
+static bool __init check_loader_disabled_bsp(void)
+{
+#ifdef CONFIG_X86_32
+   const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
+   const char *opt = "dis_ucode_ldr";
+   const char *option  = (const char *)__pa_nodebug(opt);
+   bool *res = (bool *)__pa_nodebug(_ucode_ldr);
+
+#else /* CONFIG_X86_64 */
+   const char *cmdline = boot_command_line;
+   const char *option  = "dis_ucode_ldr";
+   bool *res = _ucode_ldr;
+#endif
+
+   if (cmdline_find_option_bool(cmdline, option))
+   *res = true;
+
+   return *res;
+}
+
 void __init load_ucode_bsp(void)
 {
int vendor, x86;
 
+   if (check_loader_disabled_bsp())
+   return;
+
if (!have_cpuid_p())
return;
 
@@ -96,10 +121,22 @@ void __init load_ucode_bsp(void)
}
 }
 
+static bool check_loader_disabled_ap(void)
+{
+#ifdef CONFIG_X86_32
+   return __pa_nodebug(dis_ucode_ldr);
+#else
+   return dis_ucode_ldr;
+#endif
+}
+
 void load_ucode_ap(void)
 {
int vendor, x86;
 
+   if (check_loader_disabled_ap())
+   return;
+
if (!have_cpuid_p())
return;
 
--
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/microcode] x86, boot: Carve out early cmdline parsing function

2014-05-20 Thread tip-bot for Borislav Petkov
Commit-ID:  1b1ded57a4f2f4420b4de7c395d1b841d8b3c41a
Gitweb: http://git.kernel.org/tip/1b1ded57a4f2f4420b4de7c395d1b841d8b3c41a
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 19 May 2014 20:59:16 +0200
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Tue, 20 May 2014 20:21:24 -0700

x86, boot: Carve out early cmdline parsing function

Carve out early cmdline parsing function into .../lib/cmdline.c so it
can be used by early code in the kernel proper as well.

Adapted from arch/x86/boot/cmdline.c.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1400525957-11525-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/include/asm/cmdline.h |  6 +++
 arch/x86/lib/Makefile  |  2 +-
 arch/x86/lib/cmdline.c | 84 ++
 3 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cmdline.h b/arch/x86/include/asm/cmdline.h
new file mode 100644
index 000..e01f7f7
--- /dev/null
+++ b/arch/x86/include/asm/cmdline.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_CMDLINE_H
+#define _ASM_X86_CMDLINE_H
+
+int cmdline_find_option_bool(const char *cmdline_ptr, const char *option);
+
+#endif /* _ASM_X86_CMDLINE_H */
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index eabcb6e..4d4f96a 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -16,7 +16,7 @@ clean-files := inat-tables.c
 
 obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o
 
-lib-y := delay.o misc.o
+lib-y := delay.o misc.o cmdline.o
 lib-y += thunk_$(BITS).o
 lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
 lib-y += memcpy_$(BITS).o
diff --git a/arch/x86/lib/cmdline.c b/arch/x86/lib/cmdline.c
new file mode 100644
index 000..422db00
--- /dev/null
+++ b/arch/x86/lib/cmdline.c
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the Linux kernel, and is made available under
+ * the terms of the GNU General Public License version 2.
+ *
+ * Misc librarized functions for cmdline poking.
+ */
+#include linux/kernel.h
+#include linux/string.h
+#include linux/ctype.h
+#include asm/setup.h
+
+static inline int myisspace(u8 c)
+{
+   return c = ' ';/* Close enough approximation */
+}
+
+/**
+ * Find a boolean option (like quiet,noapic,nosmp)
+ *
+ * @cmdline: the cmdline string
+ * @option: option string to look for
+ *
+ * Returns the position of that @option (starts counting with 1)
+ * or 0 on not found.
+ */
+int cmdline_find_option_bool(const char *cmdline, const char *option)
+{
+   char c;
+   int len, pos = 0, wstart = 0;
+   const char *opptr = NULL;
+   enum {
+   st_wordstart = 0,   /* Start of word/after whitespace */
+   st_wordcmp, /* Comparing this word */
+   st_wordskip,/* Miscompare, skip */
+   } state = st_wordstart;
+
+   if (!cmdline)
+   return -1;  /* No command line */
+
+   len = min_t(int, strlen(cmdline), COMMAND_LINE_SIZE);
+   if (!len)
+   return 0;
+
+   while (len--) {
+   c = *(char *)cmdline++;
+   pos++;
+
+   switch (state) {
+   case st_wordstart:
+   if (!c)
+   return 0;
+   else if (myisspace(c))
+   break;
+
+   state = st_wordcmp;
+   opptr = option;
+   wstart = pos;
+   /* fall through */
+
+   case st_wordcmp:
+   if (!*opptr)
+   if (!c || myisspace(c))
+   return wstart;
+   else
+   state = st_wordskip;
+   else if (!c)
+   return 0;
+   else if (c != *opptr++)
+   state = st_wordskip;
+   else if (!len)  /* last word and is matching */
+   return wstart;
+   break;
+
+   case st_wordskip:
+   if (!c)
+   return 0;
+   else if (myisspace(c))
+   state = st_wordstart;
+   break;
+   }
+   }
+
+   return 0;   /* Buffer overrun */
+}
--
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/microcode] x86, microcode: Add a disable chicken bit

2014-05-20 Thread tip-bot for Borislav Petkov
Commit-ID:  65cef1311d5d212fd3d48a43678536dc878ca288
Gitweb: http://git.kernel.org/tip/65cef1311d5d212fd3d48a43678536dc878ca288
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 19 May 2014 20:59:17 +0200
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Tue, 20 May 2014 20:21:27 -0700

x86, microcode: Add a disable chicken bit

Add a cmdline param which disables the microcode loader. This is useful
mostly in debugging situations where we want to turn off microcode
loading, both early from the initrd and late, as a means to be able to
rule out its influence on the machine.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1400525957-11525-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/include/asm/microcode.h   |  1 +
 arch/x86/kernel/cpu/microcode/core.c   |  6 +
 arch/x86/kernel/cpu/microcode/core_early.c | 37 ++
 3 files changed, 44 insertions(+)

diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index b59827e..64dc362 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -25,6 +25,7 @@ struct cpu_signature {
 struct device;
 
 enum ucode_state { UCODE_ERROR, UCODE_OK, UCODE_NFOUND };
+extern bool dis_ucode_ldr;
 
 struct microcode_ops {
enum ucode_state (*request_microcode_user) (int cpu,
diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index 15c9876..dd9d619 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -97,6 +97,9 @@ MODULE_LICENSE(GPL);
 
 static struct microcode_ops*microcode_ops;
 
+bool dis_ucode_ldr;
+module_param(dis_ucode_ldr, bool, 0);
+
 /*
  * Synchronization.
  *
@@ -546,6 +549,9 @@ static int __init microcode_init(void)
struct cpuinfo_x86 *c = cpu_data(0);
int error;
 
+   if (dis_ucode_ldr)
+   return 0;
+
if (c-x86_vendor == X86_VENDOR_INTEL)
microcode_ops = init_intel_microcode();
else if (c-x86_vendor == X86_VENDOR_AMD)
diff --git a/arch/x86/kernel/cpu/microcode/core_early.c 
b/arch/x86/kernel/cpu/microcode/core_early.c
index be7f851..5f28a64 100644
--- a/arch/x86/kernel/cpu/microcode/core_early.c
+++ b/arch/x86/kernel/cpu/microcode/core_early.c
@@ -17,9 +17,11 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include linux/module.h
+#include asm/microcode.h
 #include asm/microcode_intel.h
 #include asm/microcode_amd.h
 #include asm/processor.h
+#include asm/cmdline.h
 
 #define QCHAR(a, b, c, d) ((a) + ((b)  8) + ((c)  16) + ((d)  24))
 #define CPUID_INTEL1 QCHAR('G', 'e', 'n', 'u')
@@ -72,10 +74,33 @@ static int x86_family(void)
return x86;
 }
 
+static bool __init check_loader_disabled_bsp(void)
+{
+#ifdef CONFIG_X86_32
+   const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
+   const char *opt = dis_ucode_ldr;
+   const char *option  = (const char *)__pa_nodebug(opt);
+   bool *res = (bool *)__pa_nodebug(dis_ucode_ldr);
+
+#else /* CONFIG_X86_64 */
+   const char *cmdline = boot_command_line;
+   const char *option  = dis_ucode_ldr;
+   bool *res = dis_ucode_ldr;
+#endif
+
+   if (cmdline_find_option_bool(cmdline, option))
+   *res = true;
+
+   return *res;
+}
+
 void __init load_ucode_bsp(void)
 {
int vendor, x86;
 
+   if (check_loader_disabled_bsp())
+   return;
+
if (!have_cpuid_p())
return;
 
@@ -96,10 +121,22 @@ void __init load_ucode_bsp(void)
}
 }
 
+static bool check_loader_disabled_ap(void)
+{
+#ifdef CONFIG_X86_32
+   return __pa_nodebug(dis_ucode_ldr);
+#else
+   return dis_ucode_ldr;
+#endif
+}
+
 void load_ucode_ap(void)
 {
int vendor, x86;
 
+   if (check_loader_disabled_ap())
+   return;
+
if (!have_cpuid_p())
return;
 
--
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/events/core: Drop unused variable after cleanup

2014-05-19 Thread tip-bot for Borislav Petkov
Commit-ID:  12665b35b0b48c9583ee1b8f0a403dc708fb4a92
Gitweb: http://git.kernel.org/tip/12665b35b0b48c9583ee1b8f0a403dc708fb4a92
Author: Borislav Petkov 
AuthorDate: Sat, 10 May 2014 13:10:59 +0200
Committer:  Thomas Gleixner 
CommitDate: Mon, 19 May 2014 21:52:58 +0900

perf/events/core: Drop unused variable after cleanup

... in 3a497f48637 ("perf: Simplify perf_event_exit_task_context()")

Signed-off-by: Borislav Petkov 
Signed-off-by: Peter Zijlstra 
Link: http://lkml.kernel.org/r/1399720259-28275-1-git-send-email...@alien8.de
Signed-off-by: Thomas Gleixner 
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7ab734f..ed50b09 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7431,7 +7431,7 @@ __perf_event_exit_task(struct perf_event *child_event,
 
 static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
 {
-   struct perf_event *child_event, *tmp;
+   struct perf_event *child_event;
struct perf_event_context *child_ctx;
unsigned long flags;
 
--
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/events/core: Drop unused variable after cleanup

2014-05-19 Thread tip-bot for Borislav Petkov
Commit-ID:  12665b35b0b48c9583ee1b8f0a403dc708fb4a92
Gitweb: http://git.kernel.org/tip/12665b35b0b48c9583ee1b8f0a403dc708fb4a92
Author: Borislav Petkov b...@suse.de
AuthorDate: Sat, 10 May 2014 13:10:59 +0200
Committer:  Thomas Gleixner t...@linutronix.de
CommitDate: Mon, 19 May 2014 21:52:58 +0900

perf/events/core: Drop unused variable after cleanup

... in 3a497f48637 (perf: Simplify perf_event_exit_task_context())

Signed-off-by: Borislav Petkov b...@suse.de
Signed-off-by: Peter Zijlstra pet...@infradead.org
Link: http://lkml.kernel.org/r/1399720259-28275-1-git-send-email...@alien8.de
Signed-off-by: Thomas Gleixner t...@linutronix.de
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7ab734f..ed50b09 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7431,7 +7431,7 @@ __perf_event_exit_task(struct perf_event *child_event,
 
 static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
 {
-   struct perf_event *child_event, *tmp;
+   struct perf_event *child_event;
struct perf_event_context *child_ctx;
unsigned long flags;
 
--
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] tools: Unify export.h

2014-05-05 Thread tip-bot for Borislav Petkov
Commit-ID:  5ac3e4b6d1d8fb911bb9c497126c51b02033a412
Gitweb: http://git.kernel.org/tip/5ac3e4b6d1d8fb911bb9c497126c51b02033a412
Author: Borislav Petkov 
AuthorDate: Sun, 23 Feb 2014 12:04:53 +0100
Committer:  Jiri Olsa 
CommitDate: Thu, 1 May 2014 21:18:17 +0200

tools: Unify export.h

So tools/ has been growing three, at a different stage of their
development export.h headers and so we should unite into one. Add
tools/include/ to the include path of virtio and liblockdep to pick the
shared header now.

Signed-off-by: Borislav Petkov 
Acked-by: Rusty Russell 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Michael S. Tsirkin 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Sasha Levin 
Cc: virtio-...@lists.oasis-open.org
Cc: virtualizat...@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/1397493185-19521-2-git-send-email...@alien8.de
Signed-off-by: Jiri Olsa 
---
 tools/{virtio => include}/linux/export.h  | 5 +
 tools/lib/lockdep/Makefile| 2 +-
 tools/lib/lockdep/uinclude/linux/export.h | 7 ---
 tools/perf/MANIFEST   | 1 +
 tools/perf/Makefile.perf  | 2 +-
 tools/perf/util/include/linux/export.h| 6 --
 tools/virtio/Makefile | 2 +-
 7 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/tools/virtio/linux/export.h b/tools/include/linux/export.h
similarity index 70%
rename from tools/virtio/linux/export.h
rename to tools/include/linux/export.h
index 7311d32..d07e586 100644
--- a/tools/virtio/linux/export.h
+++ b/tools/include/linux/export.h
@@ -1,5 +1,10 @@
+#ifndef _TOOLS_LINUX_EXPORT_H_
+#define _TOOLS_LINUX_EXPORT_H_
+
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
 #define EXPORT_SYMBOL_GPL_FUTURE(sym)
 #define EXPORT_UNUSED_SYMBOL(sym)
 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
+
+#endif
diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile
index cb09d3f..85ef05d 100644
--- a/tools/lib/lockdep/Makefile
+++ b/tools/lib/lockdep/Makefile
@@ -105,7 +105,7 @@ N   =
 
 export Q VERBOSE
 
-INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include $(CONFIG_INCLUDES)
+INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include -I../../include 
$(CONFIG_INCLUDES)
 
 # Set compile option CFLAGS if not set elsewhere
 CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING 
-DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' 
-rdynamic -O0 -g
diff --git a/tools/lib/lockdep/uinclude/linux/export.h 
b/tools/lib/lockdep/uinclude/linux/export.h
deleted file mode 100644
index 6bdf349..000
--- a/tools/lib/lockdep/uinclude/linux/export.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _LIBLOCKDEP_LINUX_EXPORT_H_
-#define _LIBLOCKDEP_LINUX_EXPORT_H_
-
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
-
-#endif
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index c0c87c8..81783c2 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -7,6 +7,7 @@ tools/lib/symbol/kallsyms.h
 tools/include/asm/bug.h
 tools/include/linux/compiler.h
 tools/include/linux/hash.h
+tools/include/linux/export.h
 include/linux/const.h
 include/linux/perf_event.h
 include/linux/rbtree.h
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5e21aad..bd11e8a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -222,7 +222,7 @@ LIB_H += util/include/linux/const.h
 LIB_H += util/include/linux/ctype.h
 LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
-LIB_H += util/include/linux/export.h
+LIB_H += ../include/linux/export.h
 LIB_H += util/include/linux/poison.h
 LIB_H += util/include/linux/rbtree.h
 LIB_H += util/include/linux/rbtree_augmented.h
diff --git a/tools/perf/util/include/linux/export.h 
b/tools/perf/util/include/linux/export.h
deleted file mode 100644
index b43e2dc..000
--- a/tools/perf/util/include/linux/export.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef PERF_LINUX_MODULE_H
-#define PERF_LINUX_MODULE_H
-
-#define EXPORT_SYMBOL(name)
-
-#endif
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index 3187c62..9325f46 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -3,7 +3,7 @@ test: virtio_test vringh_test
 virtio_test: virtio_ring.o virtio_test.o
 vringh_test: vringh_test.o vringh.o virtio_ring.o
 
-CFLAGS += -g -O2 -Wall -I. -I ../../usr/include/ -Wno-pointer-sign 
-fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
+CFLAGS += -g -O2 -Wall -I. -I../include/ -I ../../usr/include/ 
-Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD 
-U_FORTIFY_SOURCE
 vpath %.c ../../drivers/virtio ../../drivers/vhost
 mod:
${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test
--
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] tools: Consolidate types.h

2014-05-05 Thread tip-bot for Borislav Petkov
Commit-ID:  d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f
Gitweb: http://git.kernel.org/tip/d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f
Author: Borislav Petkov 
AuthorDate: Fri, 25 Apr 2014 21:31:02 +0200
Committer:  Jiri Olsa 
CommitDate: Thu, 1 May 2014 21:22:39 +0200

tools: Consolidate types.h

Combine all definitions into a common tools/include/linux/types.h and
kill the wild growth elsewhere. Move DECLARE_BITMAP to its proper
bitmap.h header.

Signed-off-by: Borislav Petkov 
Acked-by: Rusty Russell 
Link: http://lkml.kernel.org/n/tip-azczs7qcv6h9xek9od10h...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 .../lockdep/uinclude => include}/linux/types.h | 29 +-
 tools/perf/MANIFEST|  1 +
 tools/perf/Makefile.perf   |  3 +--
 tools/perf/arch/x86/include/perf_regs.h|  2 +-
 tools/perf/arch/x86/util/tsc.c |  2 +-
 tools/perf/arch/x86/util/tsc.h |  2 +-
 tools/perf/perf.h  |  4 +--
 tools/perf/tests/attr.c|  7 --
 tools/perf/tests/code-reading.c|  3 +--
 tools/perf/tests/dso-data.c|  2 +-
 tools/perf/tests/dwarf-unwind.c|  2 +-
 tools/perf/tests/keep-tracking.c   |  2 +-
 tools/perf/tests/parse-no-sample-id-all.c  |  2 +-
 tools/perf/tests/perf-time-to-tsc.c|  3 +--
 tools/perf/tests/rdpmc.c   |  2 +-
 tools/perf/tests/sample-parsing.c  |  2 +-
 tools/perf/ui/browser.h|  4 +--
 tools/perf/ui/progress.h   |  2 +-
 tools/perf/util/annotate.h |  2 +-
 tools/perf/util/build-id.h |  2 +-
 tools/perf/util/dso.h  |  2 +-
 tools/perf/util/evsel.h|  4 +--
 tools/perf/util/header.h   |  4 +--
 tools/perf/util/include/linux/bitmap.h |  3 +++
 tools/perf/util/include/linux/list.h   |  1 +
 tools/perf/util/include/linux/types.h  | 29 --
 tools/perf/util/map.h  |  2 +-
 tools/perf/util/parse-events.h |  3 +--
 tools/perf/util/parse-events.y |  2 +-
 tools/perf/util/perf_regs.h|  2 +-
 tools/perf/util/pmu.h  |  2 +-
 tools/perf/util/stat.h |  2 +-
 tools/perf/util/svghelper.c|  2 +-
 tools/perf/util/svghelper.h|  2 +-
 tools/perf/util/top.h  |  2 +-
 tools/perf/util/types.h| 19 --
 tools/perf/util/unwind-libdw.c |  2 +-
 tools/perf/util/unwind.h   |  2 +-
 tools/perf/util/util.h |  2 +-
 tools/perf/util/values.h   |  2 +-
 tools/virtio/linux/kernel.h|  7 --
 tools/virtio/linux/types.h | 28 -
 42 files changed, 63 insertions(+), 139 deletions(-)

diff --git a/tools/lib/lockdep/uinclude/linux/types.h 
b/tools/include/linux/types.h
similarity index 63%
rename from tools/lib/lockdep/uinclude/linux/types.h
rename to tools/include/linux/types.h
index 929938f..b5cf25e 100644
--- a/tools/lib/lockdep/uinclude/linux/types.h
+++ b/tools/include/linux/types.h
@@ -1,8 +1,9 @@
-#ifndef _LIBLOCKDEP_LINUX_TYPES_H_
-#define _LIBLOCKDEP_LINUX_TYPES_H_
+#ifndef _TOOLS_LINUX_TYPES_H_
+#define _TOOLS_LINUX_TYPES_H_
 
 #include 
 #include 
+#include 
 
 #define __SANE_USERSPACE_TYPES__   /* For PPC64, to get LL64 types */
 #include 
@@ -10,10 +11,22 @@
 struct page;
 struct kmem_cache;
 
-typedef unsigned gfp_t;
+typedef enum {
+   GFP_KERNEL,
+   GFP_ATOMIC,
+   __GFP_HIGHMEM,
+   __GFP_HIGH
+} gfp_t;
 
-typedef __u64 u64;
-typedef __s64 s64;
+/*
+ * We define u64 as uint64_t for every architecture
+ * so that we can print it with "%"PRIx64 without getting warnings.
+ *
+ * typedef __u64 u64;
+ * typedef __s64 s64;
+ */
+typedef uint64_t u64;
+typedef int64_t s64;
 
 typedef __u32 u32;
 typedef __s32 s32;
@@ -35,6 +48,10 @@ typedef __s8  s8;
 #define __bitwise
 #endif
 
+#define __force
+#define __user
+#define __must_check
+#define __cold
 
 typedef __u16 __bitwise __le16;
 typedef __u16 __bitwise __be16;
@@ -55,4 +72,4 @@ struct hlist_node {
struct hlist_node *next, **pprev;
 };
 
-#endif
+#endif /* _TOOLS_LINUX_TYPES_H_ */
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 81783c2..45da209 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -8,6 +8,7 @@ tools/include/asm/bug.h
 tools/include/linux/compiler.h
 tools/include/linux/hash.h
 tools/include/linux/export.h
+tools/include/linux/types.h
 

[tip:perf/core] tools: Consolidate types.h

2014-05-05 Thread tip-bot for Borislav Petkov
Commit-ID:  d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f
Gitweb: http://git.kernel.org/tip/d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f
Author: Borislav Petkov b...@suse.de
AuthorDate: Fri, 25 Apr 2014 21:31:02 +0200
Committer:  Jiri Olsa jo...@kernel.org
CommitDate: Thu, 1 May 2014 21:22:39 +0200

tools: Consolidate types.h

Combine all definitions into a common tools/include/linux/types.h and
kill the wild growth elsewhere. Move DECLARE_BITMAP to its proper
bitmap.h header.

Signed-off-by: Borislav Petkov b...@suse.de
Acked-by: Rusty Russell ru...@rustcorp.com.au
Link: http://lkml.kernel.org/n/tip-azczs7qcv6h9xek9od10h...@git.kernel.org
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 .../lockdep/uinclude = include}/linux/types.h | 29 +-
 tools/perf/MANIFEST|  1 +
 tools/perf/Makefile.perf   |  3 +--
 tools/perf/arch/x86/include/perf_regs.h|  2 +-
 tools/perf/arch/x86/util/tsc.c |  2 +-
 tools/perf/arch/x86/util/tsc.h |  2 +-
 tools/perf/perf.h  |  4 +--
 tools/perf/tests/attr.c|  7 --
 tools/perf/tests/code-reading.c|  3 +--
 tools/perf/tests/dso-data.c|  2 +-
 tools/perf/tests/dwarf-unwind.c|  2 +-
 tools/perf/tests/keep-tracking.c   |  2 +-
 tools/perf/tests/parse-no-sample-id-all.c  |  2 +-
 tools/perf/tests/perf-time-to-tsc.c|  3 +--
 tools/perf/tests/rdpmc.c   |  2 +-
 tools/perf/tests/sample-parsing.c  |  2 +-
 tools/perf/ui/browser.h|  4 +--
 tools/perf/ui/progress.h   |  2 +-
 tools/perf/util/annotate.h |  2 +-
 tools/perf/util/build-id.h |  2 +-
 tools/perf/util/dso.h  |  2 +-
 tools/perf/util/evsel.h|  4 +--
 tools/perf/util/header.h   |  4 +--
 tools/perf/util/include/linux/bitmap.h |  3 +++
 tools/perf/util/include/linux/list.h   |  1 +
 tools/perf/util/include/linux/types.h  | 29 --
 tools/perf/util/map.h  |  2 +-
 tools/perf/util/parse-events.h |  3 +--
 tools/perf/util/parse-events.y |  2 +-
 tools/perf/util/perf_regs.h|  2 +-
 tools/perf/util/pmu.h  |  2 +-
 tools/perf/util/stat.h |  2 +-
 tools/perf/util/svghelper.c|  2 +-
 tools/perf/util/svghelper.h|  2 +-
 tools/perf/util/top.h  |  2 +-
 tools/perf/util/types.h| 19 --
 tools/perf/util/unwind-libdw.c |  2 +-
 tools/perf/util/unwind.h   |  2 +-
 tools/perf/util/util.h |  2 +-
 tools/perf/util/values.h   |  2 +-
 tools/virtio/linux/kernel.h|  7 --
 tools/virtio/linux/types.h | 28 -
 42 files changed, 63 insertions(+), 139 deletions(-)

diff --git a/tools/lib/lockdep/uinclude/linux/types.h 
b/tools/include/linux/types.h
similarity index 63%
rename from tools/lib/lockdep/uinclude/linux/types.h
rename to tools/include/linux/types.h
index 929938f..b5cf25e 100644
--- a/tools/lib/lockdep/uinclude/linux/types.h
+++ b/tools/include/linux/types.h
@@ -1,8 +1,9 @@
-#ifndef _LIBLOCKDEP_LINUX_TYPES_H_
-#define _LIBLOCKDEP_LINUX_TYPES_H_
+#ifndef _TOOLS_LINUX_TYPES_H_
+#define _TOOLS_LINUX_TYPES_H_
 
 #include stdbool.h
 #include stddef.h
+#include stdint.h
 
 #define __SANE_USERSPACE_TYPES__   /* For PPC64, to get LL64 types */
 #include asm/types.h
@@ -10,10 +11,22 @@
 struct page;
 struct kmem_cache;
 
-typedef unsigned gfp_t;
+typedef enum {
+   GFP_KERNEL,
+   GFP_ATOMIC,
+   __GFP_HIGHMEM,
+   __GFP_HIGH
+} gfp_t;
 
-typedef __u64 u64;
-typedef __s64 s64;
+/*
+ * We define u64 as uint64_t for every architecture
+ * so that we can print it with %PRIx64 without getting warnings.
+ *
+ * typedef __u64 u64;
+ * typedef __s64 s64;
+ */
+typedef uint64_t u64;
+typedef int64_t s64;
 
 typedef __u32 u32;
 typedef __s32 s32;
@@ -35,6 +48,10 @@ typedef __s8  s8;
 #define __bitwise
 #endif
 
+#define __force
+#define __user
+#define __must_check
+#define __cold
 
 typedef __u16 __bitwise __le16;
 typedef __u16 __bitwise __be16;
@@ -55,4 +72,4 @@ struct hlist_node {
struct hlist_node *next, **pprev;
 };
 
-#endif
+#endif /* _TOOLS_LINUX_TYPES_H_ */
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 81783c2..45da209 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -8,6 +8,7 @@ tools/include/asm/bug.h
 

[tip:perf/core] tools: Unify export.h

2014-05-05 Thread tip-bot for Borislav Petkov
Commit-ID:  5ac3e4b6d1d8fb911bb9c497126c51b02033a412
Gitweb: http://git.kernel.org/tip/5ac3e4b6d1d8fb911bb9c497126c51b02033a412
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 23 Feb 2014 12:04:53 +0100
Committer:  Jiri Olsa jo...@kernel.org
CommitDate: Thu, 1 May 2014 21:18:17 +0200

tools: Unify export.h

So tools/ has been growing three, at a different stage of their
development export.h headers and so we should unite into one. Add
tools/include/ to the include path of virtio and liblockdep to pick the
shared header now.

Signed-off-by: Borislav Petkov b...@suse.de
Acked-by: Rusty Russell ru...@rustcorp.com.au
Cc: Arnaldo Carvalho de Melo a...@kernel.org
Cc: Ingo Molnar mi...@redhat.com
Cc: Michael S. Tsirkin m...@redhat.com
Cc: Paul Mackerras pau...@samba.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Sasha Levin sasha.le...@oracle.com
Cc: virtio-...@lists.oasis-open.org
Cc: virtualizat...@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/1397493185-19521-2-git-send-email...@alien8.de
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 tools/{virtio = include}/linux/export.h  | 5 +
 tools/lib/lockdep/Makefile| 2 +-
 tools/lib/lockdep/uinclude/linux/export.h | 7 ---
 tools/perf/MANIFEST   | 1 +
 tools/perf/Makefile.perf  | 2 +-
 tools/perf/util/include/linux/export.h| 6 --
 tools/virtio/Makefile | 2 +-
 7 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/tools/virtio/linux/export.h b/tools/include/linux/export.h
similarity index 70%
rename from tools/virtio/linux/export.h
rename to tools/include/linux/export.h
index 7311d32..d07e586 100644
--- a/tools/virtio/linux/export.h
+++ b/tools/include/linux/export.h
@@ -1,5 +1,10 @@
+#ifndef _TOOLS_LINUX_EXPORT_H_
+#define _TOOLS_LINUX_EXPORT_H_
+
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
 #define EXPORT_SYMBOL_GPL_FUTURE(sym)
 #define EXPORT_UNUSED_SYMBOL(sym)
 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
+
+#endif
diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile
index cb09d3f..85ef05d 100644
--- a/tools/lib/lockdep/Makefile
+++ b/tools/lib/lockdep/Makefile
@@ -105,7 +105,7 @@ N   =
 
 export Q VERBOSE
 
-INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include $(CONFIG_INCLUDES)
+INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include -I../../include 
$(CONFIG_INCLUDES)
 
 # Set compile option CFLAGS if not set elsewhere
 CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING 
-DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='$(LIBLOCKDEP_VERSION)' 
-rdynamic -O0 -g
diff --git a/tools/lib/lockdep/uinclude/linux/export.h 
b/tools/lib/lockdep/uinclude/linux/export.h
deleted file mode 100644
index 6bdf349..000
--- a/tools/lib/lockdep/uinclude/linux/export.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _LIBLOCKDEP_LINUX_EXPORT_H_
-#define _LIBLOCKDEP_LINUX_EXPORT_H_
-
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
-
-#endif
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index c0c87c8..81783c2 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -7,6 +7,7 @@ tools/lib/symbol/kallsyms.h
 tools/include/asm/bug.h
 tools/include/linux/compiler.h
 tools/include/linux/hash.h
+tools/include/linux/export.h
 include/linux/const.h
 include/linux/perf_event.h
 include/linux/rbtree.h
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5e21aad..bd11e8a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -222,7 +222,7 @@ LIB_H += util/include/linux/const.h
 LIB_H += util/include/linux/ctype.h
 LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
-LIB_H += util/include/linux/export.h
+LIB_H += ../include/linux/export.h
 LIB_H += util/include/linux/poison.h
 LIB_H += util/include/linux/rbtree.h
 LIB_H += util/include/linux/rbtree_augmented.h
diff --git a/tools/perf/util/include/linux/export.h 
b/tools/perf/util/include/linux/export.h
deleted file mode 100644
index b43e2dc..000
--- a/tools/perf/util/include/linux/export.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef PERF_LINUX_MODULE_H
-#define PERF_LINUX_MODULE_H
-
-#define EXPORT_SYMBOL(name)
-
-#endif
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index 3187c62..9325f46 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -3,7 +3,7 @@ test: virtio_test vringh_test
 virtio_test: virtio_ring.o virtio_test.o
 vringh_test: vringh_test.o vringh.o virtio_ring.o
 
-CFLAGS += -g -O2 -Wall -I. -I ../../usr/include/ -Wno-pointer-sign 
-fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
+CFLAGS += -g -O2 -Wall -I. -I../include/ -I ../../usr/include/ 
-Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD 
-U_FORTIFY_SOURCE
 vpath %.c ../../drivers/virtio ../../drivers/vhost
 mod:
${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in

[tip:perf/core] perf tools: Move u64_swap union

2014-05-01 Thread tip-bot for Borislav Petkov
Commit-ID:  88080ce7f6af1ad99ad4b2825938411975910116
Gitweb: http://git.kernel.org/tip/88080ce7f6af1ad99ad4b2825938411975910116
Author: Borislav Petkov 
AuthorDate: Mon, 14 Apr 2014 17:38:39 +0200
Committer:  Jiri Olsa 
CommitDate: Tue, 29 Apr 2014 15:30:21 +0200

perf tools: Move u64_swap union

... to its single user's header, evsel.h.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/tip-9os1chjyz12upubfsjc71...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 tools/perf/util/evsel.h | 5 +
 tools/perf/util/types.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 0c9926c..0c581d0 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -91,6 +91,11 @@ struct perf_evsel {
char*group_name;
 };
 
+union u64_swap {
+   u64 val64;
+   u32 val32[2];
+};
+
 #define hists_to_evsel(h) container_of(h, struct perf_evsel, hists)
 
 struct cpu_map;
diff --git a/tools/perf/util/types.h b/tools/perf/util/types.h
index c51fa6b..5f3689a 100644
--- a/tools/perf/util/types.h
+++ b/tools/perf/util/types.h
@@ -16,9 +16,4 @@ typedef signed short s16;
 typedef unsigned char u8;
 typedef signed char   s8;
 
-union u64_swap {
-   u64 val64;
-   u32 val32[2];
-};
-
 #endif /* __PERF_TYPES_H */
--
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 tools: Move u64_swap union

2014-05-01 Thread tip-bot for Borislav Petkov
Commit-ID:  88080ce7f6af1ad99ad4b2825938411975910116
Gitweb: http://git.kernel.org/tip/88080ce7f6af1ad99ad4b2825938411975910116
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 14 Apr 2014 17:38:39 +0200
Committer:  Jiri Olsa jo...@kernel.org
CommitDate: Tue, 29 Apr 2014 15:30:21 +0200

perf tools: Move u64_swap union

... to its single user's header, evsel.h.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/tip-9os1chjyz12upubfsjc71...@git.kernel.org
Signed-off-by: Jiri Olsa jo...@kernel.org
---
 tools/perf/util/evsel.h | 5 +
 tools/perf/util/types.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 0c9926c..0c581d0 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -91,6 +91,11 @@ struct perf_evsel {
char*group_name;
 };
 
+union u64_swap {
+   u64 val64;
+   u32 val32[2];
+};
+
 #define hists_to_evsel(h) container_of(h, struct perf_evsel, hists)
 
 struct cpu_map;
diff --git a/tools/perf/util/types.h b/tools/perf/util/types.h
index c51fa6b..5f3689a 100644
--- a/tools/perf/util/types.h
+++ b/tools/perf/util/types.h
@@ -16,9 +16,4 @@ typedef signed short s16;
 typedef unsigned char u8;
 typedef signed char   s8;
 
-union u64_swap {
-   u64 val64;
-   u32 val32[2];
-};
-
 #endif /* __PERF_TYPES_H */
--
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, Intel: Convert to the new bit access MSR accessors

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  c0a639ad0bc6b178b46996bd1f821a04643e2bde
Gitweb: http://git.kernel.org/tip/c0a639ad0bc6b178b46996bd1f821a04643e2bde
Author: Borislav Petkov 
AuthorDate: Sun, 9 Mar 2014 18:05:25 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 13 Mar 2014 15:35:09 -0700

x86, Intel: Convert to the new bit access MSR accessors

... and save some lines of code.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1394384725-10796-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/uapi/asm/msr-index.h |  9 ++---
 arch/x86/kernel/cpu/intel.c   | 30 +++---
 2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/arch/x86/include/uapi/asm/msr-index.h 
b/arch/x86/include/uapi/asm/msr-index.h
index c19fc60..045e6db 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -368,14 +368,16 @@
 #define THERM_LOG_THRESHOLD1   (1 << 9)
 
 /* MISC_ENABLE bits: architectural */
-#define MSR_IA32_MISC_ENABLE_FAST_STRING   (1ULL << 0)
+#define MSR_BIT_FAST_STRING0
+#define MSR_IA32_MISC_ENABLE_FAST_STRING   (1ULL << MSR_BIT_FAST_STRING)
 #define MSR_IA32_MISC_ENABLE_TCC   (1ULL << 1)
 #define MSR_IA32_MISC_ENABLE_EMON  (1ULL << 7)
 #define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL   (1ULL << 11)
 #define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL  (1ULL << 12)
 #define MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP(1ULL << 16)
 #define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << 18)
-#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID   (1ULL << 22)
+#define MSR_BIT_LIMIT_CPUID22
+#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID   (1ULL << MSR_BIT_LIMIT_CPUID);
 #define MSR_IA32_MISC_ENABLE_XTPR_DISABLE  (1ULL << 23)
 #define MSR_IA32_MISC_ENABLE_XD_DISABLE(1ULL << 34)
 
@@ -385,7 +387,8 @@
 #define MSR_IA32_MISC_ENABLE_SPLIT_LOCK_DISABLE(1ULL << 4)
 #define MSR_IA32_MISC_ENABLE_L3CACHE_DISABLE   (1ULL << 6)
 #define MSR_IA32_MISC_ENABLE_SUPPRESS_LOCK (1ULL << 8)
-#define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE  (1ULL << 9)
+#define MSR_BIT_PRF_DIS9
+#define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE  (1ULL << MSR_BIT_PRF_DIS)
 #define MSR_IA32_MISC_ENABLE_FERR  (1ULL << 10)
 #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX(1ULL << 10)
 #define MSR_IA32_MISC_ENABLE_TM2   (1ULL << 13)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 5cd9bfa..44ca631 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -31,11 +31,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 
/* Unmask CPUID levels if masked: */
if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
-   rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-
-   if (misc_enable & MSR_IA32_MISC_ENABLE_LIMIT_CPUID) {
-   misc_enable &= ~MSR_IA32_MISC_ENABLE_LIMIT_CPUID;
-   wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+   if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_BIT_LIMIT_CPUID) > 
0) {
c->cpuid_level = cpuid_eax(0);
get_cpu_cap(c);
}
@@ -129,16 +125,9 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 * Ingo Molnar reported a Pentium D (model 6) and a Xeon
 * (model 2) with the same problem.
 */
-   if (c->x86 == 15) {
-   rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-
-   if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING) {
-   printk(KERN_INFO "kmemcheck: Disabling fast string 
operations\n");
-
-   misc_enable &= ~MSR_IA32_MISC_ENABLE_FAST_STRING;
-   wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-   }
-   }
+   if (c->x86 == 15)
+   if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_BIT_FAST_STRING) > 
0)
+   pr_info("kmemcheck: Disabling fast string 
operations\n");
 #endif
 
/*
@@ -197,8 +186,6 @@ static void intel_smp_check(struct cpuinfo_x86 *c)
 
 static void intel_workarounds(struct cpuinfo_x86 *c)
 {
-   unsigned long lo, hi;
-
 #ifdef CONFIG_X86_F00F_BUG
/*
 * All current models of Pentium and Pentium with MMX technology CPUs
@@ -229,12 +216,9 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 * Hardware prefetcher may cause stale data to be loaded into the cache.
 */
if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) {
-   rdmsr(MSR_IA32_MISC_ENABLE, lo, hi);
-   if ((lo & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE) == 0) {
-   printk (KERN_INFO "CPU: C0 stepping P4 Xeon 
detected.\n");
-   printk (KERN_INFO "CPU: Disabling hardware prefetching 
(Errata 037)\n");
-  

[tip:x86/cpu] x86: Add another set of MSR accessor functions

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  22085a66c2fab6cf9b9393c056a3600a6b4735de
Gitweb: http://git.kernel.org/tip/22085a66c2fab6cf9b9393c056a3600a6b4735de
Author: Borislav Petkov 
AuthorDate: Sun, 9 Mar 2014 18:05:23 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 13 Mar 2014 15:34:45 -0700

x86: Add another set of MSR accessor functions

We very often need to set or clear a bit in an MSR as a result of doing
some sort of a hardware configuration. Add generic versions of that
repeated functionality in order to save us a bunch of duplicated code in
the early CPU vendor detection/config code.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1394384725-10796-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/msr.h |  2 ++
 arch/x86/lib/msr.c | 89 +-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index e139b13..de36f22 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -214,6 +214,8 @@ do {
\
 
 struct msr *msrs_alloc(void);
 void msrs_free(struct msr *msrs);
+int msr_set_bit(u32 msr, u8 bit);
+int msr_clear_bit(u32 msr, u8 bit);
 
 #ifdef CONFIG_SMP
 int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c
index 8f8eebd..db9db44 100644
--- a/arch/x86/lib/msr.c
+++ b/arch/x86/lib/msr.c
@@ -8,7 +8,7 @@ struct msr *msrs_alloc(void)
 
msrs = alloc_percpu(struct msr);
if (!msrs) {
-   pr_warning("%s: error allocating msrs\n", __func__);
+   pr_warn("%s: error allocating msrs\n", __func__);
return NULL;
}
 
@@ -21,3 +21,90 @@ void msrs_free(struct msr *msrs)
free_percpu(msrs);
 }
 EXPORT_SYMBOL(msrs_free);
+
+/**
+ * Read an MSR with error handling
+ *
+ * @msr: MSR to read
+ * @m: value to read into
+ *
+ * It returns read data only on success, otherwise it doesn't change the output
+ * argument @m.
+ *
+ */
+int msr_read(u32 msr, struct msr *m)
+{
+   int err;
+   u64 val;
+
+   err = rdmsrl_safe(msr, );
+   if (!err)
+   m->q = val;
+
+   return err;
+}
+
+/**
+ * Write an MSR with error handling
+ *
+ * @msr: MSR to write
+ * @m: value to write
+ */
+int msr_write(u32 msr, struct msr *m)
+{
+   return wrmsrl_safe(msr, m->q);
+}
+
+static inline int __flip_bit(u32 msr, u8 bit, bool set)
+{
+   struct msr m, m1;
+   int err = -EINVAL;
+
+   if (bit > 63)
+   return err;
+
+   err = msr_read(msr, );
+   if (err)
+   return err;
+
+   m1 = m;
+   if (set)
+   m1.q |=  BIT_64(bit);
+   else
+   m1.q &= ~BIT_64(bit);
+
+   if (m1.q == m.q)
+   return 0;
+
+   err = msr_write(msr, );
+   if (err)
+   return err;
+
+   return 1;
+}
+
+/**
+ * Set @bit in a MSR @msr.
+ *
+ * Retval:
+ * < 0: An error was encountered.
+ * = 0: Bit was already set.
+ * > 0: Hardware accepted the MSR write.
+ */
+int msr_set_bit(u32 msr, u8 bit)
+{
+   return __flip_bit(msr, bit, true);
+}
+
+/**
+ * Clear @bit in a MSR @msr.
+ *
+ * Retval:
+ * < 0: An error was encountered.
+ * = 0: Bit was already cleared.
+ * > 0: Hardware accepted the MSR write.
+ */
+int msr_clear_bit(u32 msr, u8 bit)
+{
+   return __flip_bit(msr, bit, false);
+}
--
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, AMD: Convert to the new bit access MSR accessors

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  8f86a7373a1c8ee52d3cc64adf7f2ace13fd24ed
Gitweb: http://git.kernel.org/tip/8f86a7373a1c8ee52d3cc64adf7f2ace13fd24ed
Author: Borislav Petkov 
AuthorDate: Sun, 9 Mar 2014 18:05:24 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 13 Mar 2014 15:35:03 -0700

x86, AMD: Convert to the new bit access MSR accessors

... and save us a bunch of code.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1394384725-10796-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/amd.c | 48 ---
 1 file changed, 12 insertions(+), 36 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index c67ffa6..b85e43a 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -233,9 +233,7 @@ static void init_amd_k7(struct cpuinfo_x86 *c)
if (c->x86_model >= 6 && c->x86_model <= 10) {
if (!cpu_has(c, X86_FEATURE_XMM)) {
printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
-   rdmsr(MSR_K7_HWCR, l, h);
-   l &= ~0x8000;
-   wrmsr(MSR_K7_HWCR, l, h);
+   msr_clear_bit(MSR_K7_HWCR, 15);
set_cpu_cap(c, X86_FEATURE_XMM);
}
}
@@ -509,14 +507,8 @@ static void early_init_amd(struct cpuinfo_x86 *c)
 #endif
 
/* F16h erratum 793, CVE-2013-6885 */
-   if (c->x86 == 0x16 && c->x86_model <= 0xf) {
-   u64 val;
-
-   rdmsrl(MSR_AMD64_LS_CFG, val);
-   if (!(val & BIT(15)))
-   wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
-   }
-
+   if (c->x86 == 0x16 && c->x86_model <= 0xf)
+   msr_set_bit(MSR_AMD64_LS_CFG, 15);
 }
 
 static const int amd_erratum_383[];
@@ -536,11 +528,8 @@ static void init_amd(struct cpuinfo_x86 *c)
 * Errata 63 for SH-B3 steppings
 * Errata 122 for all steppings (F+ have it disabled by default)
 */
-   if (c->x86 == 0xf) {
-   rdmsrl(MSR_K7_HWCR, value);
-   value |= 1 << 6;
-   wrmsrl(MSR_K7_HWCR, value);
-   }
+   if (c->x86 == 0xf)
+   msr_set_bit(MSR_K7_HWCR, 6);
 #endif
 
early_init_amd(c);
@@ -623,14 +612,11 @@ static void init_amd(struct cpuinfo_x86 *c)
(c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
!cpu_has(c, X86_FEATURE_TOPOEXT)) {
 
-   if (!rdmsrl_safe(0xc0011005, )) {
-   value |= 1ULL << 54;
-   wrmsrl_safe(0xc0011005, value);
+   if (msr_set_bit(0xc0011005, 54) > 0) {
rdmsrl(0xc0011005, value);
-   if (value & (1ULL << 54)) {
+   if (value & BIT_64(54)) {
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
-   printk(KERN_INFO FW_INFO "CPU: Re-enabling "
- "disabled Topology Extensions Support\n");
+   pr_info(FW_INFO "CPU: Re-enabling disabled 
Topology Extensions Support.\n");
}
}
}
@@ -709,19 +695,12 @@ static void init_amd(struct cpuinfo_x86 *c)
 * Disable GART TLB Walk Errors on Fam10h. We do this here
 * because this is always needed when GART is enabled, even in a
 * kernel which has no MCE support built in.
-* BIOS should disable GartTlbWlk Errors themself. If
-* it doesn't do it here as suggested by the BKDG.
+* BIOS should disable GartTlbWlk Errors already. If
+* it doesn't, do it here as suggested by the BKDG.
 *
 * Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=33012
 */
-   u64 mask;
-   int err;
-
-   err = rdmsrl_safe(MSR_AMD64_MCx_MASK(4), );
-   if (err == 0) {
-   mask |= (1 << 10);
-   wrmsrl_safe(MSR_AMD64_MCx_MASK(4), mask);
-   }
+   msr_set_bit(MSR_AMD64_MCx_MASK(4), 10);
 
/*
 * On family 10h BIOS may not have properly enabled WC+ support,
@@ -733,10 +712,7 @@ static void init_amd(struct cpuinfo_x86 *c)
 * NOTE: we want to use the _safe accessors so as not to #GP kvm
 * guests on older kvm hosts.
 */
-
-   rdmsrl_safe(MSR_AMD64_BU_CFG2, );
-   value &= ~(1ULL << 24);
-   wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
+   msr_clear_bit(MSR_AMD64_BU_CFG2, 24);
 
if (cpu_has_amd_erratum(c, amd_erratum_383))
set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to 

[tip:x86/cleanups] x86, crash: Unify ifdef

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  5314feebabd92535a16295a8067b3fd79815cd16
Gitweb: http://git.kernel.org/tip/5314feebabd92535a16295a8067b3fd79815cd16
Author: Borislav Petkov 
AuthorDate: Wed, 12 Mar 2014 15:13:03 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 13 Mar 2014 15:32:44 -0700

x86, crash: Unify ifdef

Merge two back-to-back CONFIG_X86_32 ifdefs into one.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1394633584-5509-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/crash.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index a57902e..507de80 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -57,9 +57,7 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
 {
 #ifdef CONFIG_X86_32
struct pt_regs fixed_regs;
-#endif
 
-#ifdef CONFIG_X86_32
if (!user_mode_vm(regs)) {
crash_fixup_ss_esp(_regs, regs);
regs = _regs;
--
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, boot: Correct max ramdisk size name

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  3e920b532a0f49d05e4c0f7d1b46b0ab8f471e09
Gitweb: http://git.kernel.org/tip/3e920b532a0f49d05e4c0f7d1b46b0ab8f471e09
Author: Borislav Petkov 
AuthorDate: Wed, 12 Mar 2014 15:13:02 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 13 Mar 2014 15:32:42 -0700

x86, boot: Correct max ramdisk size name

The name in struct bootparam is ->initrd_addr_max and not ramdisk_max.
Fix that.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1394633584-5509-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 Documentation/x86/boot.txt | 4 ++--
 arch/x86/boot/header.S | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index cb81741d..a75e3ad 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -182,7 +182,7 @@ Offset  Proto   NameMeaning
 0226/1 2.02+(3 ext_loader_ver  Extended boot loader version
 0227/1 2.02+(3 ext_loader_type Extended boot loader ID
 0228/4 2.02+   cmd_line_ptr32-bit pointer to the kernel command line
-022C/4 2.03+   ramdisk_max Highest legal initrd address
+022C/4 2.03+   initrd_addr_max Highest legal initrd address
 0230/4 2.05+   kernel_alignment Physical addr alignment required for kernel
 0234/1 2.05+   relocatable_kernel Whether kernel is relocatable or not
 0235/1 2.10+   min_alignment   Minimum alignment, as a power of two
@@ -534,7 +534,7 @@ Protocol:   2.02+
   zero, the kernel will assume that your boot loader does not support
   the 2.02+ protocol.
 
-Field name:ramdisk_max
+Field name:initrd_addr_max
 Type:  read
 Offset/size:   0x22c/4
 Protocol:  2.03+
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index ec3b8ba..46f5a22 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -350,7 +350,7 @@ cmd_line_ptr:   .long   0   # (Header 
version 0x0202 or later)
# can be located anywhere in
# low memory 0x1 or higher.
 
-ramdisk_max:   .long 0x7fff
+initrd_addr_max: .long 0x7fff
# (Header version 0x0203 or later)
# The highest safe address for
# the contents of an initrd
--
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, pageattr: Correct WBINVD spelling in comment

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  b82ad3d3944193e5f95319c30fd24e39d0d7b510
Gitweb: http://git.kernel.org/tip/b82ad3d3944193e5f95319c30fd24e39d0d7b510
Author: Borislav Petkov 
AuthorDate: Wed, 12 Mar 2014 15:13:04 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 13 Mar 2014 15:32:45 -0700

x86, pageattr: Correct WBINVD spelling in comment

It is WBINVD, for INValiDate and not "wbindv". Use caps for instruction
names, while at it.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1394633584-5509-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/mm/pageattr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index b3b19f4..ba957c9 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -1377,10 +1377,10 @@ static int change_page_attr_set_clr(unsigned long 
*addr, int numpages,
cache = cache_attr(mask_set);
 
/*
-* On success we use clflush, when the CPU supports it to
-* avoid the wbindv. If the CPU does not support it and in the
+* On success we use CLFLUSH, when the CPU supports it to
+* avoid the WBINVD. If the CPU does not support it and in the
 * error case we fall back to cpa_flush_all (which uses
-* wbindv):
+* WBINVD):
 */
if (!ret && cpu_has_clflush) {
if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) {
--
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, crash: Unify ifdef

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  5314feebabd92535a16295a8067b3fd79815cd16
Gitweb: http://git.kernel.org/tip/5314feebabd92535a16295a8067b3fd79815cd16
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 12 Mar 2014 15:13:03 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 13 Mar 2014 15:32:44 -0700

x86, crash: Unify ifdef

Merge two back-to-back CONFIG_X86_32 ifdefs into one.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1394633584-5509-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/kernel/crash.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index a57902e..507de80 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -57,9 +57,7 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
 {
 #ifdef CONFIG_X86_32
struct pt_regs fixed_regs;
-#endif
 
-#ifdef CONFIG_X86_32
if (!user_mode_vm(regs)) {
crash_fixup_ss_esp(fixed_regs, regs);
regs = fixed_regs;
--
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, pageattr: Correct WBINVD spelling in comment

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  b82ad3d3944193e5f95319c30fd24e39d0d7b510
Gitweb: http://git.kernel.org/tip/b82ad3d3944193e5f95319c30fd24e39d0d7b510
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 12 Mar 2014 15:13:04 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 13 Mar 2014 15:32:45 -0700

x86, pageattr: Correct WBINVD spelling in comment

It is WBINVD, for INValiDate and not wbindv. Use caps for instruction
names, while at it.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1394633584-5509-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/mm/pageattr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index b3b19f4..ba957c9 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -1377,10 +1377,10 @@ static int change_page_attr_set_clr(unsigned long 
*addr, int numpages,
cache = cache_attr(mask_set);
 
/*
-* On success we use clflush, when the CPU supports it to
-* avoid the wbindv. If the CPU does not support it and in the
+* On success we use CLFLUSH, when the CPU supports it to
+* avoid the WBINVD. If the CPU does not support it and in the
 * error case we fall back to cpa_flush_all (which uses
-* wbindv):
+* WBINVD):
 */
if (!ret  cpu_has_clflush) {
if (cpa.flags  (CPA_PAGES_ARRAY | CPA_ARRAY)) {
--
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, boot: Correct max ramdisk size name

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  3e920b532a0f49d05e4c0f7d1b46b0ab8f471e09
Gitweb: http://git.kernel.org/tip/3e920b532a0f49d05e4c0f7d1b46b0ab8f471e09
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 12 Mar 2014 15:13:02 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 13 Mar 2014 15:32:42 -0700

x86, boot: Correct max ramdisk size name

The name in struct bootparam is -initrd_addr_max and not ramdisk_max.
Fix that.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1394633584-5509-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 Documentation/x86/boot.txt | 4 ++--
 arch/x86/boot/header.S | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index cb81741d..a75e3ad 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -182,7 +182,7 @@ Offset  Proto   NameMeaning
 0226/1 2.02+(3 ext_loader_ver  Extended boot loader version
 0227/1 2.02+(3 ext_loader_type Extended boot loader ID
 0228/4 2.02+   cmd_line_ptr32-bit pointer to the kernel command line
-022C/4 2.03+   ramdisk_max Highest legal initrd address
+022C/4 2.03+   initrd_addr_max Highest legal initrd address
 0230/4 2.05+   kernel_alignment Physical addr alignment required for kernel
 0234/1 2.05+   relocatable_kernel Whether kernel is relocatable or not
 0235/1 2.10+   min_alignment   Minimum alignment, as a power of two
@@ -534,7 +534,7 @@ Protocol:   2.02+
   zero, the kernel will assume that your boot loader does not support
   the 2.02+ protocol.
 
-Field name:ramdisk_max
+Field name:initrd_addr_max
 Type:  read
 Offset/size:   0x22c/4
 Protocol:  2.03+
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index ec3b8ba..46f5a22 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -350,7 +350,7 @@ cmd_line_ptr:   .long   0   # (Header 
version 0x0202 or later)
# can be located anywhere in
# low memory 0x1 or higher.
 
-ramdisk_max:   .long 0x7fff
+initrd_addr_max: .long 0x7fff
# (Header version 0x0203 or later)
# The highest safe address for
# the contents of an initrd
--
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: Add another set of MSR accessor functions

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  22085a66c2fab6cf9b9393c056a3600a6b4735de
Gitweb: http://git.kernel.org/tip/22085a66c2fab6cf9b9393c056a3600a6b4735de
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Mar 2014 18:05:23 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 13 Mar 2014 15:34:45 -0700

x86: Add another set of MSR accessor functions

We very often need to set or clear a bit in an MSR as a result of doing
some sort of a hardware configuration. Add generic versions of that
repeated functionality in order to save us a bunch of duplicated code in
the early CPU vendor detection/config code.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1394384725-10796-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/msr.h |  2 ++
 arch/x86/lib/msr.c | 89 +-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index e139b13..de36f22 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -214,6 +214,8 @@ do {
\
 
 struct msr *msrs_alloc(void);
 void msrs_free(struct msr *msrs);
+int msr_set_bit(u32 msr, u8 bit);
+int msr_clear_bit(u32 msr, u8 bit);
 
 #ifdef CONFIG_SMP
 int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c
index 8f8eebd..db9db44 100644
--- a/arch/x86/lib/msr.c
+++ b/arch/x86/lib/msr.c
@@ -8,7 +8,7 @@ struct msr *msrs_alloc(void)
 
msrs = alloc_percpu(struct msr);
if (!msrs) {
-   pr_warning(%s: error allocating msrs\n, __func__);
+   pr_warn(%s: error allocating msrs\n, __func__);
return NULL;
}
 
@@ -21,3 +21,90 @@ void msrs_free(struct msr *msrs)
free_percpu(msrs);
 }
 EXPORT_SYMBOL(msrs_free);
+
+/**
+ * Read an MSR with error handling
+ *
+ * @msr: MSR to read
+ * @m: value to read into
+ *
+ * It returns read data only on success, otherwise it doesn't change the output
+ * argument @m.
+ *
+ */
+int msr_read(u32 msr, struct msr *m)
+{
+   int err;
+   u64 val;
+
+   err = rdmsrl_safe(msr, val);
+   if (!err)
+   m-q = val;
+
+   return err;
+}
+
+/**
+ * Write an MSR with error handling
+ *
+ * @msr: MSR to write
+ * @m: value to write
+ */
+int msr_write(u32 msr, struct msr *m)
+{
+   return wrmsrl_safe(msr, m-q);
+}
+
+static inline int __flip_bit(u32 msr, u8 bit, bool set)
+{
+   struct msr m, m1;
+   int err = -EINVAL;
+
+   if (bit  63)
+   return err;
+
+   err = msr_read(msr, m);
+   if (err)
+   return err;
+
+   m1 = m;
+   if (set)
+   m1.q |=  BIT_64(bit);
+   else
+   m1.q = ~BIT_64(bit);
+
+   if (m1.q == m.q)
+   return 0;
+
+   err = msr_write(msr, m);
+   if (err)
+   return err;
+
+   return 1;
+}
+
+/**
+ * Set @bit in a MSR @msr.
+ *
+ * Retval:
+ *  0: An error was encountered.
+ * = 0: Bit was already set.
+ *  0: Hardware accepted the MSR write.
+ */
+int msr_set_bit(u32 msr, u8 bit)
+{
+   return __flip_bit(msr, bit, true);
+}
+
+/**
+ * Clear @bit in a MSR @msr.
+ *
+ * Retval:
+ *  0: An error was encountered.
+ * = 0: Bit was already cleared.
+ *  0: Hardware accepted the MSR write.
+ */
+int msr_clear_bit(u32 msr, u8 bit)
+{
+   return __flip_bit(msr, bit, false);
+}
--
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, AMD: Convert to the new bit access MSR accessors

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  8f86a7373a1c8ee52d3cc64adf7f2ace13fd24ed
Gitweb: http://git.kernel.org/tip/8f86a7373a1c8ee52d3cc64adf7f2ace13fd24ed
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Mar 2014 18:05:24 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 13 Mar 2014 15:35:03 -0700

x86, AMD: Convert to the new bit access MSR accessors

... and save us a bunch of code.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1394384725-10796-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/kernel/cpu/amd.c | 48 ---
 1 file changed, 12 insertions(+), 36 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index c67ffa6..b85e43a 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -233,9 +233,7 @@ static void init_amd_k7(struct cpuinfo_x86 *c)
if (c-x86_model = 6  c-x86_model = 10) {
if (!cpu_has(c, X86_FEATURE_XMM)) {
printk(KERN_INFO Enabling disabled K7/SSE Support.\n);
-   rdmsr(MSR_K7_HWCR, l, h);
-   l = ~0x8000;
-   wrmsr(MSR_K7_HWCR, l, h);
+   msr_clear_bit(MSR_K7_HWCR, 15);
set_cpu_cap(c, X86_FEATURE_XMM);
}
}
@@ -509,14 +507,8 @@ static void early_init_amd(struct cpuinfo_x86 *c)
 #endif
 
/* F16h erratum 793, CVE-2013-6885 */
-   if (c-x86 == 0x16  c-x86_model = 0xf) {
-   u64 val;
-
-   rdmsrl(MSR_AMD64_LS_CFG, val);
-   if (!(val  BIT(15)))
-   wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
-   }
-
+   if (c-x86 == 0x16  c-x86_model = 0xf)
+   msr_set_bit(MSR_AMD64_LS_CFG, 15);
 }
 
 static const int amd_erratum_383[];
@@ -536,11 +528,8 @@ static void init_amd(struct cpuinfo_x86 *c)
 * Errata 63 for SH-B3 steppings
 * Errata 122 for all steppings (F+ have it disabled by default)
 */
-   if (c-x86 == 0xf) {
-   rdmsrl(MSR_K7_HWCR, value);
-   value |= 1  6;
-   wrmsrl(MSR_K7_HWCR, value);
-   }
+   if (c-x86 == 0xf)
+   msr_set_bit(MSR_K7_HWCR, 6);
 #endif
 
early_init_amd(c);
@@ -623,14 +612,11 @@ static void init_amd(struct cpuinfo_x86 *c)
(c-x86_model = 0x10)  (c-x86_model = 0x1f) 
!cpu_has(c, X86_FEATURE_TOPOEXT)) {
 
-   if (!rdmsrl_safe(0xc0011005, value)) {
-   value |= 1ULL  54;
-   wrmsrl_safe(0xc0011005, value);
+   if (msr_set_bit(0xc0011005, 54)  0) {
rdmsrl(0xc0011005, value);
-   if (value  (1ULL  54)) {
+   if (value  BIT_64(54)) {
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
-   printk(KERN_INFO FW_INFO CPU: Re-enabling 
- disabled Topology Extensions Support\n);
+   pr_info(FW_INFO CPU: Re-enabling disabled 
Topology Extensions Support.\n);
}
}
}
@@ -709,19 +695,12 @@ static void init_amd(struct cpuinfo_x86 *c)
 * Disable GART TLB Walk Errors on Fam10h. We do this here
 * because this is always needed when GART is enabled, even in a
 * kernel which has no MCE support built in.
-* BIOS should disable GartTlbWlk Errors themself. If
-* it doesn't do it here as suggested by the BKDG.
+* BIOS should disable GartTlbWlk Errors already. If
+* it doesn't, do it here as suggested by the BKDG.
 *
 * Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=33012
 */
-   u64 mask;
-   int err;
-
-   err = rdmsrl_safe(MSR_AMD64_MCx_MASK(4), mask);
-   if (err == 0) {
-   mask |= (1  10);
-   wrmsrl_safe(MSR_AMD64_MCx_MASK(4), mask);
-   }
+   msr_set_bit(MSR_AMD64_MCx_MASK(4), 10);
 
/*
 * On family 10h BIOS may not have properly enabled WC+ support,
@@ -733,10 +712,7 @@ static void init_amd(struct cpuinfo_x86 *c)
 * NOTE: we want to use the _safe accessors so as not to #GP kvm
 * guests on older kvm hosts.
 */
-
-   rdmsrl_safe(MSR_AMD64_BU_CFG2, value);
-   value = ~(1ULL  24);
-   wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
+   msr_clear_bit(MSR_AMD64_BU_CFG2, 24);
 
if (cpu_has_amd_erratum(c, amd_erratum_383))
set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of 

[tip:x86/cpu] x86, Intel: Convert to the new bit access MSR accessors

2014-03-13 Thread tip-bot for Borislav Petkov
Commit-ID:  c0a639ad0bc6b178b46996bd1f821a04643e2bde
Gitweb: http://git.kernel.org/tip/c0a639ad0bc6b178b46996bd1f821a04643e2bde
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Mar 2014 18:05:25 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 13 Mar 2014 15:35:09 -0700

x86, Intel: Convert to the new bit access MSR accessors

... and save some lines of code.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1394384725-10796-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/uapi/asm/msr-index.h |  9 ++---
 arch/x86/kernel/cpu/intel.c   | 30 +++---
 2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/arch/x86/include/uapi/asm/msr-index.h 
b/arch/x86/include/uapi/asm/msr-index.h
index c19fc60..045e6db 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -368,14 +368,16 @@
 #define THERM_LOG_THRESHOLD1   (1  9)
 
 /* MISC_ENABLE bits: architectural */
-#define MSR_IA32_MISC_ENABLE_FAST_STRING   (1ULL  0)
+#define MSR_BIT_FAST_STRING0
+#define MSR_IA32_MISC_ENABLE_FAST_STRING   (1ULL  MSR_BIT_FAST_STRING)
 #define MSR_IA32_MISC_ENABLE_TCC   (1ULL  1)
 #define MSR_IA32_MISC_ENABLE_EMON  (1ULL  7)
 #define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL   (1ULL  11)
 #define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL  (1ULL  12)
 #define MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP(1ULL  16)
 #define MSR_IA32_MISC_ENABLE_MWAIT (1ULL  18)
-#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID   (1ULL  22)
+#define MSR_BIT_LIMIT_CPUID22
+#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID   (1ULL  MSR_BIT_LIMIT_CPUID);
 #define MSR_IA32_MISC_ENABLE_XTPR_DISABLE  (1ULL  23)
 #define MSR_IA32_MISC_ENABLE_XD_DISABLE(1ULL  34)
 
@@ -385,7 +387,8 @@
 #define MSR_IA32_MISC_ENABLE_SPLIT_LOCK_DISABLE(1ULL  4)
 #define MSR_IA32_MISC_ENABLE_L3CACHE_DISABLE   (1ULL  6)
 #define MSR_IA32_MISC_ENABLE_SUPPRESS_LOCK (1ULL  8)
-#define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE  (1ULL  9)
+#define MSR_BIT_PRF_DIS9
+#define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE  (1ULL  MSR_BIT_PRF_DIS)
 #define MSR_IA32_MISC_ENABLE_FERR  (1ULL  10)
 #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX(1ULL  10)
 #define MSR_IA32_MISC_ENABLE_TM2   (1ULL  13)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 5cd9bfa..44ca631 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -31,11 +31,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 
/* Unmask CPUID levels if masked: */
if (c-x86  6 || (c-x86 == 6  c-x86_model = 0xd)) {
-   rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-
-   if (misc_enable  MSR_IA32_MISC_ENABLE_LIMIT_CPUID) {
-   misc_enable = ~MSR_IA32_MISC_ENABLE_LIMIT_CPUID;
-   wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+   if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_BIT_LIMIT_CPUID)  
0) {
c-cpuid_level = cpuid_eax(0);
get_cpu_cap(c);
}
@@ -129,16 +125,9 @@ static void early_init_intel(struct cpuinfo_x86 *c)
 * Ingo Molnar reported a Pentium D (model 6) and a Xeon
 * (model 2) with the same problem.
 */
-   if (c-x86 == 15) {
-   rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-
-   if (misc_enable  MSR_IA32_MISC_ENABLE_FAST_STRING) {
-   printk(KERN_INFO kmemcheck: Disabling fast string 
operations\n);
-
-   misc_enable = ~MSR_IA32_MISC_ENABLE_FAST_STRING;
-   wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
-   }
-   }
+   if (c-x86 == 15)
+   if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_BIT_FAST_STRING)  
0)
+   pr_info(kmemcheck: Disabling fast string 
operations\n);
 #endif
 
/*
@@ -197,8 +186,6 @@ static void intel_smp_check(struct cpuinfo_x86 *c)
 
 static void intel_workarounds(struct cpuinfo_x86 *c)
 {
-   unsigned long lo, hi;
-
 #ifdef CONFIG_X86_F00F_BUG
/*
 * All current models of Pentium and Pentium with MMX technology CPUs
@@ -229,12 +216,9 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
 * Hardware prefetcher may cause stale data to be loaded into the cache.
 */
if ((c-x86 == 15)  (c-x86_model == 1)  (c-x86_mask == 1)) {
-   rdmsr(MSR_IA32_MISC_ENABLE, lo, hi);
-   if ((lo  MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE) == 0) {
-   printk (KERN_INFO CPU: C0 stepping P4 Xeon 
detected.\n);
-   printk (KERN_INFO CPU: Disabling hardware prefetching 
(Errata 037)\n);
-   lo 

[tip:perf/core] perf tools: Drop prefetch.h

2014-02-22 Thread tip-bot for Borislav Petkov
Commit-ID:  5072f2733afe26c354aa9d277cb1544e4b0b3846
Gitweb: http://git.kernel.org/tip/5072f2733afe26c354aa9d277cb1544e4b0b3846
Author: Borislav Petkov 
AuthorDate: Wed, 5 Feb 2014 15:51:54 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 18 Feb 2014 09:34:49 -0300

perf tools: Drop prefetch.h

This was needed at the time before e66eed651fd1 ("list: remove
prefetching from regular list iterators") where the list iterators did
prefetch elements. This turned out to be counter-productive and hurt
performance and they were removed. Which makes the prefetch.h header
unused so drop it.

Signed-off-by: Borislav Petkov 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Robert Richter 
Link: http://lkml.kernel.org/r/1391611914-26054-4-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.perf | 1 -
 tools/perf/util/include/linux/list.h | 1 -
 tools/perf/util/include/linux/prefetch.h | 6 --
 3 files changed, 8 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 496871a..77b153f 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -219,7 +219,6 @@ LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
 LIB_H += util/include/linux/export.h
 LIB_H += util/include/linux/poison.h
-LIB_H += util/include/linux/prefetch.h
 LIB_H += util/include/linux/rbtree.h
 LIB_H += util/include/linux/rbtree_augmented.h
 LIB_H += util/include/linux/string.h
diff --git a/tools/perf/util/include/linux/list.h 
b/tools/perf/util/include/linux/list.h
index 1d928a0..bfe0a2a 100644
--- a/tools/perf/util/include/linux/list.h
+++ b/tools/perf/util/include/linux/list.h
@@ -1,5 +1,4 @@
 #include 
-#include 
 
 #include "../../../../include/linux/list.h"
 
diff --git a/tools/perf/util/include/linux/prefetch.h 
b/tools/perf/util/include/linux/prefetch.h
deleted file mode 100644
index 7841e48..000
--- a/tools/perf/util/include/linux/prefetch.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef PERF_LINUX_PREFETCH_H
-#define PERF_LINUX_PREFETCH_H
-
-static inline void prefetch(void *a __attribute__((unused))) { }
-
-#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:perf/core] perf tools: Move fs.* to lib/api/fs/

2014-02-22 Thread tip-bot for Borislav Petkov
Commit-ID:  cd0cfad74eb88e54ba9d205da3ed376e48981448
Gitweb: http://git.kernel.org/tip/cd0cfad74eb88e54ba9d205da3ed376e48981448
Author: Borislav Petkov 
AuthorDate: Mon, 9 Dec 2013 17:14:24 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 18 Feb 2014 09:34:49 -0300

perf tools: Move fs.* to lib/api/fs/

Move to generic library and kill magic.h as it is needed only in fs.h.

Signed-off-by: Borislav Petkov 
Cc: Adrian Hunter 
Cc: Andi Kleen 
Cc: Arjan van de Ven 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Pekka Enberg 
Cc: Peter Zijlstra 
Cc: Robert Richter 
Cc: Stanislav Fomichev 
Cc: Stephane Eranian 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/1386605664-24041-3-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/api/Makefile |  2 ++
 tools/{perf/util => lib/api/fs}/fs.c   | 11 ---
 tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} | 12 +---
 tools/perf/Makefile.perf   |  3 ---
 tools/perf/tests/parse-events.c|  2 +-
 tools/perf/util/cpumap.c   |  2 +-
 tools/perf/util/fs.h   |  7 ---
 tools/perf/util/pmu.c  |  2 +-
 tools/perf/util/python-ext-sources |  2 +-
 tools/perf/util/record.c   |  2 +-
 tools/perf/util/util.c |  2 +-
 11 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index ed2f51e..ce00f7e 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -9,8 +9,10 @@ LIB_H=
 LIB_OBJS=
 
 LIB_H += fs/debugfs.h
+LIB_H += fs/fs.h
 
 LIB_OBJS += $(OUTPUT)fs/debugfs.o
+LIB_OBJS += $(OUTPUT)fs/fs.o
 
 LIBFILE = libapikfs.a
 
diff --git a/tools/perf/util/fs.c b/tools/lib/api/fs/fs.c
similarity index 91%
rename from tools/perf/util/fs.c
rename to tools/lib/api/fs/fs.c
index f5be1f2..5b5eb78 100644
--- a/tools/perf/util/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,13 @@
+/* TODO merge/factor in debugfs.c here */
 
-/* TODO merge/factor into tools/lib/lk/debugfs.c */
+#include 
+#include 
+#include 
+#include 
+#include 
 
-#include "util.h"
-#include "util/fs.h"
+#include "debugfs.h"
+#include "fs.h"
 
 static const char * const sysfs__fs_known_mountpoints[] = {
"/sys",
diff --git a/tools/perf/util/include/linux/magic.h b/tools/lib/api/fs/fs.h
similarity index 50%
rename from tools/perf/util/include/linux/magic.h
rename to tools/lib/api/fs/fs.h
index 07d63cf..cb70495 100644
--- a/tools/perf/util/include/linux/magic.h
+++ b/tools/lib/api/fs/fs.h
@@ -1,9 +1,5 @@
-#ifndef _PERF_LINUX_MAGIC_H_
-#define _PERF_LINUX_MAGIC_H_
-
-#ifndef DEBUGFS_MAGIC
-#define DEBUGFS_MAGIC  0x64626720
-#endif
+#ifndef __API_FS__
+#define __API_FS__
 
 #ifndef SYSFS_MAGIC
 #define SYSFS_MAGIC0x62656572
@@ -13,4 +9,6 @@
 #define PROC_SUPER_MAGIC   0x9fa0
 #endif
 
-#endif
+const char *sysfs__mountpoint(void);
+const char *procfs__mountpoint(void);
+#endif /* __API_FS__ */
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index f99a392..869b34a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -218,7 +218,6 @@ LIB_H += util/include/linux/ctype.h
 LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
 LIB_H += util/include/linux/export.h
-LIB_H += util/include/linux/magic.h
 LIB_H += util/include/linux/poison.h
 LIB_H += util/include/linux/prefetch.h
 LIB_H += util/include/linux/rbtree.h
@@ -244,7 +243,6 @@ LIB_H += util/cache.h
 LIB_H += util/callchain.h
 LIB_H += util/build-id.h
 LIB_H += util/debug.h
-LIB_H += util/fs.h
 LIB_H += util/pmu.h
 LIB_H += util/event.h
 LIB_H += util/evsel.h
@@ -306,7 +304,6 @@ LIB_OBJS += $(OUTPUT)util/annotate.o
 LIB_OBJS += $(OUTPUT)util/build-id.o
 LIB_OBJS += $(OUTPUT)util/config.o
 LIB_OBJS += $(OUTPUT)util/ctype.o
-LIB_OBJS += $(OUTPUT)util/fs.o
 LIB_OBJS += $(OUTPUT)util/pmu.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 4db0ae6..8605ff5 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -2,7 +2,7 @@
 #include "parse-events.h"
 #include "evsel.h"
 #include "evlist.h"
-#include "fs.h"
+#include 
 #include 
 #include "tests.h"
 #include 
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index a9b48c4..7fe4994 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -1,5 +1,5 @@
 #include "util.h"
-#include "fs.h"
+#include 
 #include "../perf.h"
 #include "cpumap.h"
 #include 
diff --git a/tools/perf/util/fs.h b/tools/perf/util/fs.h
deleted file mode 100644
index 5e09ce1..000
--- 

[tip:perf/core] perf tools: Move hash.h header

2014-02-22 Thread tip-bot for Borislav Petkov
Commit-ID:  0e55fa1131dcacfc8f18fabecc93643a105bdc14
Gitweb: http://git.kernel.org/tip/0e55fa1131dcacfc8f18fabecc93643a105bdc14
Author: Borislav Petkov 
AuthorDate: Wed, 5 Feb 2014 15:51:53 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 18 Feb 2014 09:34:49 -0300

perf tools: Move hash.h header

Put it into tools/include/ for general usage.

Signed-off-by: Borislav Petkov 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Robert Richter 
Link: http://lkml.kernel.org/r/1391611914-26054-3-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/linux/hash.h   | 5 +
 tools/perf/MANIFEST  | 1 +
 tools/perf/Makefile.perf | 2 +-
 tools/perf/util/include/linux/hash.h | 5 -
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/include/linux/hash.h b/tools/include/linux/hash.h
new file mode 100644
index 000..d026c65
--- /dev/null
+++ b/tools/include/linux/hash.h
@@ -0,0 +1,5 @@
+#include "../../../include/linux/hash.h"
+
+#ifndef _TOOLS_LINUX_HASH_H
+#define _TOOLS_LINUX_HASH_H
+#endif
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index f41572d..c0c87c8 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -6,6 +6,7 @@ tools/lib/symbol/kallsyms.c
 tools/lib/symbol/kallsyms.h
 tools/include/asm/bug.h
 tools/include/linux/compiler.h
+tools/include/linux/hash.h
 include/linux/const.h
 include/linux/perf_event.h
 include/linux/rbtree.h
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 869b34a..496871a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -208,7 +208,7 @@ LIB_H += ../../include/uapi/linux/perf_event.h
 LIB_H += ../../include/linux/rbtree.h
 LIB_H += ../../include/linux/list.h
 LIB_H += ../../include/uapi/linux/const.h
-LIB_H += ../../include/linux/hash.h
+LIB_H += ../include/linux/hash.h
 LIB_H += ../../include/linux/stringify.h
 LIB_H += util/include/linux/bitmap.h
 LIB_H += util/include/linux/bitops.h
diff --git a/tools/perf/util/include/linux/hash.h 
b/tools/perf/util/include/linux/hash.h
deleted file mode 100644
index 201f573..000
--- a/tools/perf/util/include/linux/hash.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "../../../../include/linux/hash.h"
-
-#ifndef PERF_HASH_H
-#define PERF_HASH_H
-#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:perf/core] perf tools: Move fs.* to lib/api/fs/

2014-02-22 Thread tip-bot for Borislav Petkov
Commit-ID:  cd0cfad74eb88e54ba9d205da3ed376e48981448
Gitweb: http://git.kernel.org/tip/cd0cfad74eb88e54ba9d205da3ed376e48981448
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 9 Dec 2013 17:14:24 +0100
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Tue, 18 Feb 2014 09:34:49 -0300

perf tools: Move fs.* to lib/api/fs/

Move to generic library and kill magic.h as it is needed only in fs.h.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Andi Kleen a...@linux.intel.com
Cc: Arjan van de Ven ar...@linux.intel.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Pekka Enberg penb...@kernel.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Robert Richter r...@kernel.org
Cc: Stanislav Fomichev stfomic...@yandex-team.ru
Cc: Stephane Eranian eran...@google.com
Cc: Steven Rostedt rost...@goodmis.org
Link: http://lkml.kernel.org/r/1386605664-24041-3-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/lib/api/Makefile |  2 ++
 tools/{perf/util = lib/api/fs}/fs.c   | 11 ---
 tools/{perf/util/include/linux/magic.h = lib/api/fs/fs.h} | 12 +---
 tools/perf/Makefile.perf   |  3 ---
 tools/perf/tests/parse-events.c|  2 +-
 tools/perf/util/cpumap.c   |  2 +-
 tools/perf/util/fs.h   |  7 ---
 tools/perf/util/pmu.c  |  2 +-
 tools/perf/util/python-ext-sources |  2 +-
 tools/perf/util/record.c   |  2 +-
 tools/perf/util/util.c |  2 +-
 11 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index ed2f51e..ce00f7e 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -9,8 +9,10 @@ LIB_H=
 LIB_OBJS=
 
 LIB_H += fs/debugfs.h
+LIB_H += fs/fs.h
 
 LIB_OBJS += $(OUTPUT)fs/debugfs.o
+LIB_OBJS += $(OUTPUT)fs/fs.o
 
 LIBFILE = libapikfs.a
 
diff --git a/tools/perf/util/fs.c b/tools/lib/api/fs/fs.c
similarity index 91%
rename from tools/perf/util/fs.c
rename to tools/lib/api/fs/fs.c
index f5be1f2..5b5eb78 100644
--- a/tools/perf/util/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,13 @@
+/* TODO merge/factor in debugfs.c here */
 
-/* TODO merge/factor into tools/lib/lk/debugfs.c */
+#include errno.h
+#include stdbool.h
+#include stdio.h
+#include string.h
+#include sys/vfs.h
 
-#include util.h
-#include util/fs.h
+#include debugfs.h
+#include fs.h
 
 static const char * const sysfs__fs_known_mountpoints[] = {
/sys,
diff --git a/tools/perf/util/include/linux/magic.h b/tools/lib/api/fs/fs.h
similarity index 50%
rename from tools/perf/util/include/linux/magic.h
rename to tools/lib/api/fs/fs.h
index 07d63cf..cb70495 100644
--- a/tools/perf/util/include/linux/magic.h
+++ b/tools/lib/api/fs/fs.h
@@ -1,9 +1,5 @@
-#ifndef _PERF_LINUX_MAGIC_H_
-#define _PERF_LINUX_MAGIC_H_
-
-#ifndef DEBUGFS_MAGIC
-#define DEBUGFS_MAGIC  0x64626720
-#endif
+#ifndef __API_FS__
+#define __API_FS__
 
 #ifndef SYSFS_MAGIC
 #define SYSFS_MAGIC0x62656572
@@ -13,4 +9,6 @@
 #define PROC_SUPER_MAGIC   0x9fa0
 #endif
 
-#endif
+const char *sysfs__mountpoint(void);
+const char *procfs__mountpoint(void);
+#endif /* __API_FS__ */
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index f99a392..869b34a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -218,7 +218,6 @@ LIB_H += util/include/linux/ctype.h
 LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
 LIB_H += util/include/linux/export.h
-LIB_H += util/include/linux/magic.h
 LIB_H += util/include/linux/poison.h
 LIB_H += util/include/linux/prefetch.h
 LIB_H += util/include/linux/rbtree.h
@@ -244,7 +243,6 @@ LIB_H += util/cache.h
 LIB_H += util/callchain.h
 LIB_H += util/build-id.h
 LIB_H += util/debug.h
-LIB_H += util/fs.h
 LIB_H += util/pmu.h
 LIB_H += util/event.h
 LIB_H += util/evsel.h
@@ -306,7 +304,6 @@ LIB_OBJS += $(OUTPUT)util/annotate.o
 LIB_OBJS += $(OUTPUT)util/build-id.o
 LIB_OBJS += $(OUTPUT)util/config.o
 LIB_OBJS += $(OUTPUT)util/ctype.o
-LIB_OBJS += $(OUTPUT)util/fs.o
 LIB_OBJS += $(OUTPUT)util/pmu.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 4db0ae6..8605ff5 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -2,7 +2,7 @@
 #include parse-events.h
 #include evsel.h
 #include evlist.h
-#include fs.h
+#include api/fs/fs.h
 #include api/fs/debugfs.h
 #include tests.h
 #include linux/hw_breakpoint.h

[tip:perf/core] perf tools: Move hash.h header

2014-02-22 Thread tip-bot for Borislav Petkov
Commit-ID:  0e55fa1131dcacfc8f18fabecc93643a105bdc14
Gitweb: http://git.kernel.org/tip/0e55fa1131dcacfc8f18fabecc93643a105bdc14
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 5 Feb 2014 15:51:53 +0100
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Tue, 18 Feb 2014 09:34:49 -0300

perf tools: Move hash.h header

Put it into tools/include/ for general usage.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: David Ahern dsah...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Namhyung Kim namhy...@gmail.com
Cc: Peter Zijlstra pet...@infradead.org
Cc: Robert Richter r...@kernel.org
Link: http://lkml.kernel.org/r/1391611914-26054-3-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/include/linux/hash.h   | 5 +
 tools/perf/MANIFEST  | 1 +
 tools/perf/Makefile.perf | 2 +-
 tools/perf/util/include/linux/hash.h | 5 -
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/include/linux/hash.h b/tools/include/linux/hash.h
new file mode 100644
index 000..d026c65
--- /dev/null
+++ b/tools/include/linux/hash.h
@@ -0,0 +1,5 @@
+#include ../../../include/linux/hash.h
+
+#ifndef _TOOLS_LINUX_HASH_H
+#define _TOOLS_LINUX_HASH_H
+#endif
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index f41572d..c0c87c8 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -6,6 +6,7 @@ tools/lib/symbol/kallsyms.c
 tools/lib/symbol/kallsyms.h
 tools/include/asm/bug.h
 tools/include/linux/compiler.h
+tools/include/linux/hash.h
 include/linux/const.h
 include/linux/perf_event.h
 include/linux/rbtree.h
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 869b34a..496871a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -208,7 +208,7 @@ LIB_H += ../../include/uapi/linux/perf_event.h
 LIB_H += ../../include/linux/rbtree.h
 LIB_H += ../../include/linux/list.h
 LIB_H += ../../include/uapi/linux/const.h
-LIB_H += ../../include/linux/hash.h
+LIB_H += ../include/linux/hash.h
 LIB_H += ../../include/linux/stringify.h
 LIB_H += util/include/linux/bitmap.h
 LIB_H += util/include/linux/bitops.h
diff --git a/tools/perf/util/include/linux/hash.h 
b/tools/perf/util/include/linux/hash.h
deleted file mode 100644
index 201f573..000
--- a/tools/perf/util/include/linux/hash.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include ../../../../include/linux/hash.h
-
-#ifndef PERF_HASH_H
-#define PERF_HASH_H
-#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:perf/core] perf tools: Drop prefetch.h

2014-02-22 Thread tip-bot for Borislav Petkov
Commit-ID:  5072f2733afe26c354aa9d277cb1544e4b0b3846
Gitweb: http://git.kernel.org/tip/5072f2733afe26c354aa9d277cb1544e4b0b3846
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 5 Feb 2014 15:51:54 +0100
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Tue, 18 Feb 2014 09:34:49 -0300

perf tools: Drop prefetch.h

This was needed at the time before e66eed651fd1 (list: remove
prefetching from regular list iterators) where the list iterators did
prefetch elements. This turned out to be counter-productive and hurt
performance and they were removed. Which makes the prefetch.h header
unused so drop it.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: David Ahern dsah...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Namhyung Kim namhy...@gmail.com
Cc: Peter Zijlstra pet...@infradead.org
Cc: Robert Richter r...@kernel.org
Link: http://lkml.kernel.org/r/1391611914-26054-4-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/perf/Makefile.perf | 1 -
 tools/perf/util/include/linux/list.h | 1 -
 tools/perf/util/include/linux/prefetch.h | 6 --
 3 files changed, 8 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 496871a..77b153f 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -219,7 +219,6 @@ LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
 LIB_H += util/include/linux/export.h
 LIB_H += util/include/linux/poison.h
-LIB_H += util/include/linux/prefetch.h
 LIB_H += util/include/linux/rbtree.h
 LIB_H += util/include/linux/rbtree_augmented.h
 LIB_H += util/include/linux/string.h
diff --git a/tools/perf/util/include/linux/list.h 
b/tools/perf/util/include/linux/list.h
index 1d928a0..bfe0a2a 100644
--- a/tools/perf/util/include/linux/list.h
+++ b/tools/perf/util/include/linux/list.h
@@ -1,5 +1,4 @@
 #include linux/kernel.h
-#include linux/prefetch.h
 
 #include ../../../../include/linux/list.h
 
diff --git a/tools/perf/util/include/linux/prefetch.h 
b/tools/perf/util/include/linux/prefetch.h
deleted file mode 100644
index 7841e48..000
--- a/tools/perf/util/include/linux/prefetch.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef PERF_LINUX_PREFETCH_H
-#define PERF_LINUX_PREFETCH_H
-
-static inline void prefetch(void *a __attribute__((unused))) { }
-
-#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/urgent] x86, microcode, AMD: Unify valid container checks

2014-02-06 Thread tip-bot for Borislav Petkov
Commit-ID:  75a1ba5b2c529db60ca49626bcaf0bddf4548438
Gitweb: http://git.kernel.org/tip/75a1ba5b2c529db60ca49626bcaf0bddf4548438
Author: Borislav Petkov 
AuthorDate: Mon, 3 Feb 2014 21:41:44 +0100
Committer:  H. Peter Anvin 
CommitDate: Thu, 6 Feb 2014 11:11:19 -0800

x86, microcode, AMD: Unify valid container checks

For additional coverage, BorisO and friends unknowlingly did swap AMD
microcode with Intel microcode blobs in order to see what happens. What
did happen on 32-bit was

[5.722656] BUG: unable to handle kernel paging request at be3a6008
[5.722693] IP: [] load_microcode_amd+0x24/0x3f0
[5.722716] *pdpt =  *pde = 

because there was a valid initrd there but without valid microcode in it
and the container check happened *after* the relocated ramdisk handling
on 32-bit, which was clearly wrong.

While at it, take care of the ramdisk relocation on both 32- and 64-bit
as it is done on both. Also, comment what we're doing because this code
is a bit tricky.

Reported-and-tested-by: Boris Ostrovsky 
Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1391460104-7261-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/microcode/amd_early.c | 43 +--
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd_early.c 
b/arch/x86/kernel/cpu/microcode/amd_early.c
index 8384c0f..617a9e2 100644
--- a/arch/x86/kernel/cpu/microcode/amd_early.c
+++ b/arch/x86/kernel/cpu/microcode/amd_early.c
@@ -285,6 +285,15 @@ static void __init collect_cpu_sig_on_bsp(void *arg)
 
uci->cpu_sig.sig = cpuid_eax(0x0001);
 }
+
+static void __init get_bsp_sig(void)
+{
+   unsigned int bsp = boot_cpu_data.cpu_index;
+   struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
+
+   if (!uci->cpu_sig.sig)
+   smp_call_function_single(bsp, collect_cpu_sig_on_bsp, NULL, 1);
+}
 #else
 void load_ucode_amd_ap(void)
 {
@@ -337,31 +346,37 @@ void load_ucode_amd_ap(void)
 
 int __init save_microcode_in_initrd_amd(void)
 {
+   unsigned long cont;
enum ucode_state ret;
u32 eax;
 
-#ifdef CONFIG_X86_32
-   unsigned int bsp = boot_cpu_data.cpu_index;
-   struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
-
-   if (!uci->cpu_sig.sig)
-   smp_call_function_single(bsp, collect_cpu_sig_on_bsp, NULL, 1);
+   if (!container)
+   return -EINVAL;
 
+#ifdef CONFIG_X86_32
+   get_bsp_sig();
+   cont = (unsigned long)container;
+#else
/*
-* Take into account the fact that the ramdisk might get relocated
-* and therefore we need to recompute the container's position in
-* virtual memory space.
+* We need the physical address of the container for both bitness since
+* boot_params.hdr.ramdisk_image is a physical address.
 */
-   container = (u8 *)(__va((u32)relocated_ramdisk) +
-  ((u32)container - boot_params.hdr.ramdisk_image));
+   cont = __pa(container);
 #endif
+
+   /*
+* Take into account the fact that the ramdisk might get relocated and
+* therefore we need to recompute the container's position in virtual
+* memory space.
+*/
+   if (relocated_ramdisk)
+   container = (u8 *)(__va(relocated_ramdisk) +
+(cont - boot_params.hdr.ramdisk_image));
+
if (ucode_new_rev)
pr_info("microcode: updated early to new patch_level=0x%08x\n",
ucode_new_rev);
 
-   if (!container)
-   return -EINVAL;
-
eax   = cpuid_eax(0x0001);
eax   = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
 
--
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, microcode, AMD: Unify valid container checks

2014-02-06 Thread tip-bot for Borislav Petkov
Commit-ID:  75a1ba5b2c529db60ca49626bcaf0bddf4548438
Gitweb: http://git.kernel.org/tip/75a1ba5b2c529db60ca49626bcaf0bddf4548438
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 3 Feb 2014 21:41:44 +0100
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Thu, 6 Feb 2014 11:11:19 -0800

x86, microcode, AMD: Unify valid container checks

For additional coverage, BorisO and friends unknowlingly did swap AMD
microcode with Intel microcode blobs in order to see what happens. What
did happen on 32-bit was

[5.722656] BUG: unable to handle kernel paging request at be3a6008
[5.722693] IP: [c106d6b4] load_microcode_amd+0x24/0x3f0
[5.722716] *pdpt =  *pde = 

because there was a valid initrd there but without valid microcode in it
and the container check happened *after* the relocated ramdisk handling
on 32-bit, which was clearly wrong.

While at it, take care of the ramdisk relocation on both 32- and 64-bit
as it is done on both. Also, comment what we're doing because this code
is a bit tricky.

Reported-and-tested-by: Boris Ostrovsky boris.ostrov...@oracle.com
Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1391460104-7261-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/microcode/amd_early.c | 43 +--
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd_early.c 
b/arch/x86/kernel/cpu/microcode/amd_early.c
index 8384c0f..617a9e2 100644
--- a/arch/x86/kernel/cpu/microcode/amd_early.c
+++ b/arch/x86/kernel/cpu/microcode/amd_early.c
@@ -285,6 +285,15 @@ static void __init collect_cpu_sig_on_bsp(void *arg)
 
uci-cpu_sig.sig = cpuid_eax(0x0001);
 }
+
+static void __init get_bsp_sig(void)
+{
+   unsigned int bsp = boot_cpu_data.cpu_index;
+   struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
+
+   if (!uci-cpu_sig.sig)
+   smp_call_function_single(bsp, collect_cpu_sig_on_bsp, NULL, 1);
+}
 #else
 void load_ucode_amd_ap(void)
 {
@@ -337,31 +346,37 @@ void load_ucode_amd_ap(void)
 
 int __init save_microcode_in_initrd_amd(void)
 {
+   unsigned long cont;
enum ucode_state ret;
u32 eax;
 
-#ifdef CONFIG_X86_32
-   unsigned int bsp = boot_cpu_data.cpu_index;
-   struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
-
-   if (!uci-cpu_sig.sig)
-   smp_call_function_single(bsp, collect_cpu_sig_on_bsp, NULL, 1);
+   if (!container)
+   return -EINVAL;
 
+#ifdef CONFIG_X86_32
+   get_bsp_sig();
+   cont = (unsigned long)container;
+#else
/*
-* Take into account the fact that the ramdisk might get relocated
-* and therefore we need to recompute the container's position in
-* virtual memory space.
+* We need the physical address of the container for both bitness since
+* boot_params.hdr.ramdisk_image is a physical address.
 */
-   container = (u8 *)(__va((u32)relocated_ramdisk) +
-  ((u32)container - boot_params.hdr.ramdisk_image));
+   cont = __pa(container);
 #endif
+
+   /*
+* Take into account the fact that the ramdisk might get relocated and
+* therefore we need to recompute the container's position in virtual
+* memory space.
+*/
+   if (relocated_ramdisk)
+   container = (u8 *)(__va(relocated_ramdisk) +
+(cont - boot_params.hdr.ramdisk_image));
+
if (ucode_new_rev)
pr_info(microcode: updated early to new patch_level=0x%08x\n,
ucode_new_rev);
 
-   if (!container)
-   return -EINVAL;
-
eax   = cpuid_eax(0x0001);
eax   = ((eax  8)  0xf) + ((eax  20)  0xff);
 
--
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/build] x86: Disable generation of traditional x87 instructions

2014-02-04 Thread tip-bot for Borislav Petkov
Commit-ID:  b399fe355b30d0102e7690c99e6f764ddfd32ec3
Gitweb: http://git.kernel.org/tip/b399fe355b30d0102e7690c99e6f764ddfd32ec3
Author: Borislav Petkov 
AuthorDate: Wed, 5 Feb 2014 01:55:11 +0100
Committer:  H. Peter Anvin 
CommitDate: Tue, 4 Feb 2014 20:00:35 -0800

x86: Disable generation of traditional x87 instructions

We recently had the case where wrongly used floating-constant 'E' caused
the generation of traditional x87 instructions in kernel code and
wreaking all kinds of havoc.

Disable the generation of those too. This will save people a lot of time
when trying to debug such issues by erroring out of the build instead of
let them manifest themselves in very spectacular and happy-crappy ways
at runtime.

We're using -mno-fp-ret-in-387 in addition to -mno-80387 (which is ==
-msoft-float) because, as the gcc manpage says:

  On machines where a function returns floating-point results in the
  80387 register stack, some floating-point opcodes may be emitted even
  if -msoft-float is used.

so we want to turn off *all* non-integer instructions involving any
architectural FPU state, unless it is absolutely necessary (and those
cases need special handling anyway).

Cc: Jiri Kosina 
Cc: Michael Matz 
Cc: Michal Hocko 
Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1391561711-3023-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index eeda43a..a414b14 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -82,8 +82,8 @@ else
 KBUILD_AFLAGS += -m64
 KBUILD_CFLAGS += -m64
 
-# Don't autogenerate MMX or SSE instructions
-KBUILD_CFLAGS += -mno-mmx -mno-sse
+# Don't autogenerate traditional x87, MMX or SSE instructions
+KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387
 
# Use -mpreferred-stack-boundary=3 if supported.
KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
--
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/build] x86: Disable generation of traditional x87 instructions

2014-02-04 Thread tip-bot for Borislav Petkov
Commit-ID:  b399fe355b30d0102e7690c99e6f764ddfd32ec3
Gitweb: http://git.kernel.org/tip/b399fe355b30d0102e7690c99e6f764ddfd32ec3
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 5 Feb 2014 01:55:11 +0100
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Tue, 4 Feb 2014 20:00:35 -0800

x86: Disable generation of traditional x87 instructions

We recently had the case where wrongly used floating-constant 'E' caused
the generation of traditional x87 instructions in kernel code and
wreaking all kinds of havoc.

Disable the generation of those too. This will save people a lot of time
when trying to debug such issues by erroring out of the build instead of
let them manifest themselves in very spectacular and happy-crappy ways
at runtime.

We're using -mno-fp-ret-in-387 in addition to -mno-80387 (which is ==
-msoft-float) because, as the gcc manpage says:

  On machines where a function returns floating-point results in the
  80387 register stack, some floating-point opcodes may be emitted even
  if -msoft-float is used.

so we want to turn off *all* non-integer instructions involving any
architectural FPU state, unless it is absolutely necessary (and those
cases need special handling anyway).

Cc: Jiri Kosina jkos...@suse.cz
Cc: Michael Matz m...@suse.de
Cc: Michal Hocko mho...@suse.cz
Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1391561711-3023-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index eeda43a..a414b14 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -82,8 +82,8 @@ else
 KBUILD_AFLAGS += -m64
 KBUILD_CFLAGS += -m64
 
-# Don't autogenerate MMX or SSE instructions
-KBUILD_CFLAGS += -mno-mmx -mno-sse
+# Don't autogenerate traditional x87, MMX or SSE instructions
+KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387
 
# Use -mpreferred-stack-boundary=3 if supported.
KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
--
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, cpu, amd: Fix a shadowed variable situation

2014-01-15 Thread tip-bot for Borislav Petkov
Commit-ID:  d139336700a5f3a560da235e4dfcd286773025d4
Gitweb: http://git.kernel.org/tip/d139336700a5f3a560da235e4dfcd286773025d4
Author: Borislav Petkov 
AuthorDate: Wed, 15 Jan 2014 12:52:15 +0100
Committer:  H. Peter Anvin 
CommitDate: Wed, 15 Jan 2014 04:21:45 -0800

x86, cpu, amd: Fix a shadowed variable situation

Having u32 and struct cpuinfo_x86 * by the same name is not very smart,
although it was ok in this case due to the limited scope of u32 c and it
being used only once in there.

Fix this.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1389786735-16751-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/amd.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 39bc78d..e5647ab 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -789,14 +789,10 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
}
 
/* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */
-   if (!((eax >> 16) & mask)) {
-   u32 a, b, c, d;
-
-   cpuid(0x8005, , , , );
-   tlb_lld_2m[ENTRIES] = (a >> 16) & 0xff;
-   } else {
+   if (!((eax >> 16) & mask))
+   tlb_lld_2m[ENTRIES] = (cpuid_eax(0x8005) >> 16) & 0xff;
+   else
tlb_lld_2m[ENTRIES] = (eax >> 16) & mask;
-   }
 
/* a 4M entry uses two 2M entries */
tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1;
--
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, cpu, amd: Fix a shadowed variable situation

2014-01-15 Thread tip-bot for Borislav Petkov
Commit-ID:  d139336700a5f3a560da235e4dfcd286773025d4
Gitweb: http://git.kernel.org/tip/d139336700a5f3a560da235e4dfcd286773025d4
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 15 Jan 2014 12:52:15 +0100
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Wed, 15 Jan 2014 04:21:45 -0800

x86, cpu, amd: Fix a shadowed variable situation

Having u32 and struct cpuinfo_x86 * by the same name is not very smart,
although it was ok in this case due to the limited scope of u32 c and it
being used only once in there.

Fix this.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1389786735-16751-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/amd.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 39bc78d..e5647ab 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -789,14 +789,10 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
}
 
/* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */
-   if (!((eax  16)  mask)) {
-   u32 a, b, c, d;
-
-   cpuid(0x8005, a, b, c, d);
-   tlb_lld_2m[ENTRIES] = (a  16)  0xff;
-   } else {
+   if (!((eax  16)  mask))
+   tlb_lld_2m[ENTRIES] = (cpuid_eax(0x8005)  16)  0xff;
+   else
tlb_lld_2m[ENTRIES] = (eax  16)  mask;
-   }
 
/* a 4M entry uses two 2M entries */
tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES]  1;
--
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, cpu, amd: Add workaround for family 16h, erratum 793

2014-01-14 Thread tip-bot for Borislav Petkov
Commit-ID:  3b56496865f9f7d9bcb2f93b44c63f274f08e3b6
Gitweb: http://git.kernel.org/tip/3b56496865f9f7d9bcb2f93b44c63f274f08e3b6
Author: Borislav Petkov 
AuthorDate: Wed, 15 Jan 2014 00:07:11 +0100
Committer:  H. Peter Anvin 
CommitDate: Tue, 14 Jan 2014 16:39:07 -0800

x86, cpu, amd: Add workaround for family 16h, erratum 793

This adds the workaround for erratum 793 as a precaution in case not
every BIOS implements it.  This addresses CVE-2013-6885.

Erratum text:

[Revision Guide for AMD Family 16h Models 00h-0Fh Processors,
document 51810 Rev. 3.04 November 2013]

793 Specific Combination of Writes to Write Combined Memory Types and
Locked Instructions May Cause Core Hang

Description

Under a highly specific and detailed set of internal timing
conditions, a locked instruction may trigger a timing sequence whereby
the write to a write combined memory type is not flushed, causing the
locked instruction to stall indefinitely.

Potential Effect on System

Processor core hang.

Suggested Workaround

BIOS should set MSR
C001_1020[15] = 1b.

Fix Planned

No fix planned

[ hpa: updated description, fixed typo in MSR name ]

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/20140114230711.gs29...@pd.tnic
Tested-by: Aravind Gopalakrishnan 
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/uapi/asm/msr-index.h |  1 +
 arch/x86/kernel/cpu/amd.c | 10 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/x86/include/uapi/asm/msr-index.h 
b/arch/x86/include/uapi/asm/msr-index.h
index 37813b5..59cea18 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -184,6 +184,7 @@
 #define MSR_AMD64_PATCH_LOADER 0xc0010020
 #define MSR_AMD64_OSVW_ID_LENGTH   0xc0010140
 #define MSR_AMD64_OSVW_STATUS  0xc0010141
+#define MSR_AMD64_LS_CFG   0xc0011020
 #define MSR_AMD64_DC_CFG   0xc0011022
 #define MSR_AMD64_BU_CFG2  0xc001102a
 #define MSR_AMD64_IBSFETCHCTL  0xc0011030
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bca023b..59bfebc 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -508,6 +508,16 @@ static void early_init_amd(struct cpuinfo_x86 *c)
set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
}
 #endif
+
+   /* F16h erratum 793, CVE-2013-6885 */
+   if (c->x86 == 0x16 && c->x86_model <= 0xf) {
+   u64 val;
+
+   rdmsrl(MSR_AMD64_LS_CFG, val);
+   if (!(val & BIT(15)))
+   wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
+   }
+
 }
 
 static const int amd_erratum_383[];
--
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, cpu, amd: Add workaround for family 16h, erratum 793

2014-01-14 Thread tip-bot for Borislav Petkov
Commit-ID:  3b56496865f9f7d9bcb2f93b44c63f274f08e3b6
Gitweb: http://git.kernel.org/tip/3b56496865f9f7d9bcb2f93b44c63f274f08e3b6
Author: Borislav Petkov b...@suse.de
AuthorDate: Wed, 15 Jan 2014 00:07:11 +0100
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Tue, 14 Jan 2014 16:39:07 -0800

x86, cpu, amd: Add workaround for family 16h, erratum 793

This adds the workaround for erratum 793 as a precaution in case not
every BIOS implements it.  This addresses CVE-2013-6885.

Erratum text:

[Revision Guide for AMD Family 16h Models 00h-0Fh Processors,
document 51810 Rev. 3.04 November 2013]

793 Specific Combination of Writes to Write Combined Memory Types and
Locked Instructions May Cause Core Hang

Description

Under a highly specific and detailed set of internal timing
conditions, a locked instruction may trigger a timing sequence whereby
the write to a write combined memory type is not flushed, causing the
locked instruction to stall indefinitely.

Potential Effect on System

Processor core hang.

Suggested Workaround

BIOS should set MSR
C001_1020[15] = 1b.

Fix Planned

No fix planned

[ hpa: updated description, fixed typo in MSR name ]

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/20140114230711.gs29...@pd.tnic
Tested-by: Aravind Gopalakrishnan aravind.gopalakrish...@amd.com
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/uapi/asm/msr-index.h |  1 +
 arch/x86/kernel/cpu/amd.c | 10 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/x86/include/uapi/asm/msr-index.h 
b/arch/x86/include/uapi/asm/msr-index.h
index 37813b5..59cea18 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -184,6 +184,7 @@
 #define MSR_AMD64_PATCH_LOADER 0xc0010020
 #define MSR_AMD64_OSVW_ID_LENGTH   0xc0010140
 #define MSR_AMD64_OSVW_STATUS  0xc0010141
+#define MSR_AMD64_LS_CFG   0xc0011020
 #define MSR_AMD64_DC_CFG   0xc0011022
 #define MSR_AMD64_BU_CFG2  0xc001102a
 #define MSR_AMD64_IBSFETCHCTL  0xc0011030
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bca023b..59bfebc 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -508,6 +508,16 @@ static void early_init_amd(struct cpuinfo_x86 *c)
set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
}
 #endif
+
+   /* F16h erratum 793, CVE-2013-6885 */
+   if (c-x86 == 0x16  c-x86_model = 0xf) {
+   u64 val;
+
+   rdmsrl(MSR_AMD64_LS_CFG, val);
+   if (!(val  BIT(15)))
+   wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
+   }
+
 }
 
 static const int amd_erratum_383[];
--
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] tools/: Convert to new topic libraries

2013-12-18 Thread tip-bot for Borislav Petkov
Commit-ID:  553873e1df63a20559ac9c336765dc7055cfc3d4
Gitweb: http://git.kernel.org/tip/553873e1df63a20559ac9c336765dc7055cfc3d4
Author: Borislav Petkov 
AuthorDate: Mon, 9 Dec 2013 17:14:23 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 16 Dec 2013 16:03:27 -0300

tools/: Convert to new topic libraries

Move debugfs.* to api/fs/. We have a common tools/lib/api/ place where
the Makefile lives and then we place the headers in subdirs.

For example, all the fs-related stuff goes to tools/lib/api/fs/ from
which we get libapikfs.a (acme got almost the naming he wanted :-)) and
we link it into the tools which need it - in this case perf and
tools/vm/page-types.

acme:

"Looking at the implementation, I think some tools can even link
directly to the .o files, avoiding the .a file altogether.

But that is just an optimization/finer granularity tools/lib/
cherrypicking that toolers can make use of."

Fixup documentation cleaning target while at it.

Signed-off-by: Borislav Petkov 
Acked-by: Ingo Molnar 
Cc: Adrian Hunter 
Cc: Andi Kleen 
Cc: Arjan van de Ven 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Pekka Enberg 
Cc: Peter Zijlstra 
Cc: Robert Richter 
Cc: Stanislav Fomichev 
Cc: Stephane Eranian 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/1386605664-24041-2-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/Makefile | 12 ++--
 tools/lib/{lk => api}/Makefile | 18 +++---
 tools/lib/{lk => api/fs}/debugfs.c |  0
 tools/lib/{lk => api/fs}/debugfs.h |  6 +++---
 tools/perf/Makefile.perf   | 33 -
 tools/perf/builtin-kvm.c   |  2 +-
 tools/perf/builtin-probe.c |  2 +-
 tools/perf/perf.c  |  2 +-
 tools/perf/tests/parse-events.c|  2 +-
 tools/perf/util/evlist.c   |  2 +-
 tools/perf/util/evsel.c|  2 +-
 tools/perf/util/parse-events.c |  2 +-
 tools/perf/util/probe-event.c  |  2 +-
 tools/perf/util/setup.py   |  4 ++--
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/util.h |  2 +-
 tools/vm/Makefile  | 14 +++---
 tools/vm/page-types.c  |  2 +-
 18 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index a9b0200..927cd46 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -39,10 +39,10 @@ cpupower: FORCE
 cgroup firewire guest usb virtio vm net: FORCE
$(call descend,$@)
 
-liblk: FORCE
-   $(call descend,lib/lk)
+libapikfs: FORCE
+   $(call descend,lib/api)
 
-perf: liblk FORCE
+perf: libapikfs FORCE
$(call descend,$@)
 
 selftests: FORCE
@@ -80,10 +80,10 @@ cpupower_clean:
 cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean 
net_clean:
$(call descend,$(@:_clean=),clean)
 
-liblk_clean:
-   $(call descend,lib/lk,clean)
+libapikfs_clean:
+   $(call descend,lib/api,clean)
 
-perf_clean: liblk_clean
+perf_clean: libapikfs_clean
$(call descend,$(@:_clean=),clean)
 
 selftests_clean:
diff --git a/tools/lib/lk/Makefile b/tools/lib/api/Makefile
similarity index 66%
rename from tools/lib/lk/Makefile
rename to tools/lib/api/Makefile
index 3dba0a4..ed2f51e 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/api/Makefile
@@ -1,4 +1,5 @@
 include ../../scripts/Makefile.include
+include ../../perf/config/utilities.mak# QUIET_CLEAN
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
@@ -7,11 +8,11 @@ AR = $(CROSS_COMPILE)ar
 LIB_H=
 LIB_OBJS=
 
-LIB_H += debugfs.h
+LIB_H += fs/debugfs.h
 
-LIB_OBJS += $(OUTPUT)debugfs.o
+LIB_OBJS += $(OUTPUT)fs/debugfs.o
 
-LIBFILE = liblk.a
+LIBFILE = libapikfs.a
 
 CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 
$(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
 EXTLIBS = -lelf -lpthread -lrt -lm
@@ -25,14 +26,17 @@ $(LIBFILE): $(LIB_OBJS)
 
 $(LIB_OBJS): $(LIB_H)
 
-$(OUTPUT)%.o: %.c
+libapi_dirs:
+   $(QUIET_MKDIR)mkdir -p $(OUTPUT)fs/
+
+$(OUTPUT)%.o: %.c libapi_dirs
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
-$(OUTPUT)%.s: %.c
+$(OUTPUT)%.s: %.c libapi_dirs
$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
-$(OUTPUT)%.o: %.S
+$(OUTPUT)%.o: %.S libapi_dirs
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
 
 clean:
-   $(RM) $(LIB_OBJS) $(LIBFILE)
+   $(call QUIET_CLEAN, libapi) $(RM) $(LIB_OBJS) $(LIBFILE)
 
 .PHONY: clean
diff --git a/tools/lib/lk/debugfs.c b/tools/lib/api/fs/debugfs.c
similarity index 100%
rename from tools/lib/lk/debugfs.c
rename to tools/lib/api/fs/debugfs.c
diff --git a/tools/lib/lk/debugfs.h b/tools/lib/api/fs/debugfs.h
similarity index 86%
rename from tools/lib/lk/debugfs.h
rename to tools/lib/api/fs/debugfs.h
index 935c59b..f19d3df 100644
--- a/tools/lib/lk/debugfs.h
+++ b/tools/lib/api/fs/debugfs.h
@@ -1,5 +1,5 @@
-#ifndef __LK_DEBUGFS_H__
-#define 

[tip:perf/core] tools/: Convert to new topic libraries

2013-12-18 Thread tip-bot for Borislav Petkov
Commit-ID:  553873e1df63a20559ac9c336765dc7055cfc3d4
Gitweb: http://git.kernel.org/tip/553873e1df63a20559ac9c336765dc7055cfc3d4
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 9 Dec 2013 17:14:23 +0100
Committer:  Arnaldo Carvalho de Melo a...@redhat.com
CommitDate: Mon, 16 Dec 2013 16:03:27 -0300

tools/: Convert to new topic libraries

Move debugfs.* to api/fs/. We have a common tools/lib/api/ place where
the Makefile lives and then we place the headers in subdirs.

For example, all the fs-related stuff goes to tools/lib/api/fs/ from
which we get libapikfs.a (acme got almost the naming he wanted :-)) and
we link it into the tools which need it - in this case perf and
tools/vm/page-types.

acme:

Looking at the implementation, I think some tools can even link
directly to the .o files, avoiding the .a file altogether.

But that is just an optimization/finer granularity tools/lib/
cherrypicking that toolers can make use of.

Fixup documentation cleaning target while at it.

Signed-off-by: Borislav Petkov b...@suse.de
Acked-by: Ingo Molnar mi...@kernel.org
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Andi Kleen a...@linux.intel.com
Cc: Arjan van de Ven ar...@linux.intel.com
Cc: David Ahern dsah...@gmail.com
Cc: Frederic Weisbecker fweis...@gmail.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Jiri Olsa jo...@redhat.com
Cc: Mike Galbraith efa...@gmx.de
Cc: Namhyung Kim namhy...@gmail.com
Cc: Paul Mackerras pau...@samba.org
Cc: Pekka Enberg penb...@kernel.org
Cc: Peter Zijlstra pet...@infradead.org
Cc: Robert Richter r...@kernel.org
Cc: Stanislav Fomichev stfomic...@yandex-team.ru
Cc: Stephane Eranian eran...@google.com
Cc: Steven Rostedt rost...@goodmis.org
Link: http://lkml.kernel.org/r/1386605664-24041-2-git-send-email...@alien8.de
Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
---
 tools/Makefile | 12 ++--
 tools/lib/{lk = api}/Makefile | 18 +++---
 tools/lib/{lk = api/fs}/debugfs.c |  0
 tools/lib/{lk = api/fs}/debugfs.h |  6 +++---
 tools/perf/Makefile.perf   | 33 -
 tools/perf/builtin-kvm.c   |  2 +-
 tools/perf/builtin-probe.c |  2 +-
 tools/perf/perf.c  |  2 +-
 tools/perf/tests/parse-events.c|  2 +-
 tools/perf/util/evlist.c   |  2 +-
 tools/perf/util/evsel.c|  2 +-
 tools/perf/util/parse-events.c |  2 +-
 tools/perf/util/probe-event.c  |  2 +-
 tools/perf/util/setup.py   |  4 ++--
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/util.h |  2 +-
 tools/vm/Makefile  | 14 +++---
 tools/vm/page-types.c  |  2 +-
 18 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index a9b0200..927cd46 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -39,10 +39,10 @@ cpupower: FORCE
 cgroup firewire guest usb virtio vm net: FORCE
$(call descend,$@)
 
-liblk: FORCE
-   $(call descend,lib/lk)
+libapikfs: FORCE
+   $(call descend,lib/api)
 
-perf: liblk FORCE
+perf: libapikfs FORCE
$(call descend,$@)
 
 selftests: FORCE
@@ -80,10 +80,10 @@ cpupower_clean:
 cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean 
net_clean:
$(call descend,$(@:_clean=),clean)
 
-liblk_clean:
-   $(call descend,lib/lk,clean)
+libapikfs_clean:
+   $(call descend,lib/api,clean)
 
-perf_clean: liblk_clean
+perf_clean: libapikfs_clean
$(call descend,$(@:_clean=),clean)
 
 selftests_clean:
diff --git a/tools/lib/lk/Makefile b/tools/lib/api/Makefile
similarity index 66%
rename from tools/lib/lk/Makefile
rename to tools/lib/api/Makefile
index 3dba0a4..ed2f51e 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/api/Makefile
@@ -1,4 +1,5 @@
 include ../../scripts/Makefile.include
+include ../../perf/config/utilities.mak# QUIET_CLEAN
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
@@ -7,11 +8,11 @@ AR = $(CROSS_COMPILE)ar
 LIB_H=
 LIB_OBJS=
 
-LIB_H += debugfs.h
+LIB_H += fs/debugfs.h
 
-LIB_OBJS += $(OUTPUT)debugfs.o
+LIB_OBJS += $(OUTPUT)fs/debugfs.o
 
-LIBFILE = liblk.a
+LIBFILE = libapikfs.a
 
 CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 
$(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
 EXTLIBS = -lelf -lpthread -lrt -lm
@@ -25,14 +26,17 @@ $(LIBFILE): $(LIB_OBJS)
 
 $(LIB_OBJS): $(LIB_H)
 
-$(OUTPUT)%.o: %.c
+libapi_dirs:
+   $(QUIET_MKDIR)mkdir -p $(OUTPUT)fs/
+
+$(OUTPUT)%.o: %.c libapi_dirs
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $
-$(OUTPUT)%.s: %.c
+$(OUTPUT)%.s: %.c libapi_dirs
$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $
-$(OUTPUT)%.o: %.S
+$(OUTPUT)%.o: %.S libapi_dirs
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $
 
 clean:
-   $(RM) $(LIB_OBJS) $(LIBFILE)
+   $(call QUIET_CLEAN, libapi) $(RM) $(LIB_OBJS) $(LIBFILE)
 
 .PHONY: clean
diff --git a/tools/lib/lk/debugfs.c b/tools/lib/api/fs/debugfs.c
similarity index 100%
rename from 

[tip:x86/urgent] x86/microcode: Correct Kconfig dependencies

2013-10-14 Thread tip-bot for Borislav Petkov
Commit-ID:  80030e3d8ec6414790a5ec67ae4c582aba98
Gitweb: http://git.kernel.org/tip/80030e3d8ec6414790a5ec67ae4c582aba98
Author: Borislav Petkov 
AuthorDate: Sun, 13 Oct 2013 18:36:29 +0200
Committer:  Ingo Molnar 
CommitDate: Mon, 14 Oct 2013 09:24:27 +0200

x86/microcode: Correct Kconfig dependencies

I have a randconfig here which has enabled only

  CONFIG_MICROCODE=y
  CONFIG_MICROCODE_OLD_INTERFACE=y

with both

  # CONFIG_MICROCODE_INTEL is not set
  # CONFIG_MICROCODE_AMD is not set

off. Which makes building the microcode functionality a little
pointless. Don't do that in such cases then.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1381682189-14470-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 145d703..f67e839 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1033,6 +1033,7 @@ config X86_REBOOTFIXUPS
 
 config MICROCODE
tristate "CPU microcode loading support"
+   depends on CPU_SUP_AMD || CPU_SUP_INTEL
select FW_LOADER
---help---
 
--
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/microcode: Correct Kconfig dependencies

2013-10-14 Thread tip-bot for Borislav Petkov
Commit-ID:  80030e3d8ec6414790a5ec67ae4c582aba98
Gitweb: http://git.kernel.org/tip/80030e3d8ec6414790a5ec67ae4c582aba98
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 13 Oct 2013 18:36:29 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Mon, 14 Oct 2013 09:24:27 +0200

x86/microcode: Correct Kconfig dependencies

I have a randconfig here which has enabled only

  CONFIG_MICROCODE=y
  CONFIG_MICROCODE_OLD_INTERFACE=y

with both

  # CONFIG_MICROCODE_INTEL is not set
  # CONFIG_MICROCODE_AMD is not set

off. Which makes building the microcode functionality a little
pointless. Don't do that in such cases then.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1381682189-14470-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 145d703..f67e839 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1033,6 +1033,7 @@ config X86_REBOOTFIXUPS
 
 config MICROCODE
tristate CPU microcode loading support
+   depends on CPU_SUP_AMD || CPU_SUP_INTEL
select FW_LOADER
---help---
 
--
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/boot] x86/boot: Further compress CPUs bootup message

2013-10-01 Thread tip-bot for Borislav Petkov
Commit-ID:  a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Gitweb: http://git.kernel.org/tip/a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Author: Borislav Petkov 
AuthorDate: Mon, 30 Sep 2013 11:56:24 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 1 Oct 2013 10:52:30 +0200

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

[0.073380] x86: Booting SMP configuration:
[0.074005]  node   #0, CPUs:  #1   #2   #3   #4   #5   #6   #7
[0.603005]  node   #1, CPUs: #8   #9  #10  #11  #12  #13  #14  #15
[1.25]  node   #2, CPUs:#16  #17  #18  #19  #20  #21  #22  #23
[1.796005]  node   #3, CPUs:#24  #25  #26  #27  #28  #29  #30  #31
[2.393005]  node   #4, CPUs:#32  #33  #34  #35  #36  #37  #38  #39
[2.996005]  node   #5, CPUs:#40  #41  #42  #43  #44  #45  #46  #47
[3.65]  node   #6, CPUs:#48  #49  #50  #51  #52  #53  #54  #55
[4.202005]  node   #7, CPUs:#56  #57  #58  #59  #60  #61  #62  #63
[4.811005]  node   #8, CPUs:#64  #65  #66  #67  #68  #69  #70  #71
[5.421006]  node   #9, CPUs:#72  #73  #74  #75  #76  #77  #78  #79
[6.032005]  node  #10, CPUs:#80  #81  #82  #83  #84  #85  #86  #87
[6.648006]  node  #11, CPUs:#88  #89  #90  #91  #92  #93  #94  #95
[7.262005]  node  #12, CPUs:#96  #97  #98  #99 #100 #101 #102 #103
[7.865005]  node  #13, CPUs:   #104 #105 #106 #107 #108 #109 #110 #111
[8.466005]  node  #14, CPUs:   #112 #113 #114 #115 #116 #117 #118 #119
[9.073006]  node  #15, CPUs:   #120 #121 #122 #123 #124 #125 #126 #127
[9.679901] x86: Booted up 16 nodes, 128 CPUs

and drop useless elements.

Change num_digits() to hpa's division-avoiding, cell-phone-typed
version which he went at great lengths and pains to submit on a
Saturday evening.

Signed-off-by: Borislav Petkov 
Cc: huawei.li...@huawei.com
Cc: wangyij...@huawei.com
Cc: fenghua...@intel.com
Cc: guohan...@huawei.com
Cc: paul.gortma...@windriver.com
Cc: Linus Torvalds 
Cc: Andrew Morton 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20130930095624.gb16...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/smpboot.c | 24 +++-
 arch/x86/lib/misc.c   | 20 +++-
 kernel/smp.c  |  7 ++-
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba..2a16558 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -647,22 +647,38 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned 
long start_eip)
return (send_status | accept_status);
 }
 
+void smp_announce(void)
+{
+   int num_nodes = num_online_nodes();
+
+   printk(KERN_INFO "x86: Booted up %d node%s, %d CPUs\n",
+  num_nodes, (num_nodes > 1 ? "s" : ""), num_online_cpus());
+}
+
 /* reduce the number of lines printed when booting a large cpu count system */
 static void announce_cpu(int cpu, int apicid)
 {
static int current_node = -1;
int node = early_cpu_to_node(cpu);
-   static int width;
+   static int width, node_width;
 
if (!width)
width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
 
+   if (!node_width)
+   node_width = num_digits(num_possible_nodes()) + 1; /* + '#' */
+
+   if (cpu == 1)
+   printk(KERN_INFO "x86: Booting SMP configuration:\n");
+
if (system_state == SYSTEM_BOOTING) {
if (node != current_node) {
if (current_node > (-1))
-   pr_cont(" OK\n");
+   pr_cont("\n");
current_node = node;
-   pr_info("Booting Node %3d, Processors:", node);
+
+   printk(KERN_INFO " node %*s#%d, CPUs:  ",
+  node_width - num_digits(node), " ", node);
}
 
/* Add padding for the BSP */
@@ -671,8 +687,6 @@ static void announce_cpu(int cpu, int apicid)
 
pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu);
 
-   if (cpu == num_present_cpus() - 1)
-   pr_cont(" OK\n");
} else
pr_info("Booting Node %d Processor %d APIC 0x%x\n",
node, cpu, apicid);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde..76b373a 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -1,11 +1,21 @@
+/*
+ * Count the digits of @val including a possible sign.
+ *
+ * (Typed on and submitted from hpa's mobile phone.)
+ */
 int num_digits(int val)
 {
-   int digits = 0;
+   int m = 10;
+   int d = 1;
 
-   while (val) {
-   val /= 10;
-   digits++;
+   if (val < 0) {
+   d++;
+   val = -val;
}
 
-   

[tip:x86/boot] x86/boot: Further compress CPUs bootup message

2013-10-01 Thread tip-bot for Borislav Petkov
Commit-ID:  a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Gitweb: http://git.kernel.org/tip/a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Author: Borislav Petkov b...@alien8.de
AuthorDate: Mon, 30 Sep 2013 11:56:24 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 1 Oct 2013 10:52:30 +0200

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

[0.073380] x86: Booting SMP configuration:
[0.074005]  node   #0, CPUs:  #1   #2   #3   #4   #5   #6   #7
[0.603005]  node   #1, CPUs: #8   #9  #10  #11  #12  #13  #14  #15
[1.25]  node   #2, CPUs:#16  #17  #18  #19  #20  #21  #22  #23
[1.796005]  node   #3, CPUs:#24  #25  #26  #27  #28  #29  #30  #31
[2.393005]  node   #4, CPUs:#32  #33  #34  #35  #36  #37  #38  #39
[2.996005]  node   #5, CPUs:#40  #41  #42  #43  #44  #45  #46  #47
[3.65]  node   #6, CPUs:#48  #49  #50  #51  #52  #53  #54  #55
[4.202005]  node   #7, CPUs:#56  #57  #58  #59  #60  #61  #62  #63
[4.811005]  node   #8, CPUs:#64  #65  #66  #67  #68  #69  #70  #71
[5.421006]  node   #9, CPUs:#72  #73  #74  #75  #76  #77  #78  #79
[6.032005]  node  #10, CPUs:#80  #81  #82  #83  #84  #85  #86  #87
[6.648006]  node  #11, CPUs:#88  #89  #90  #91  #92  #93  #94  #95
[7.262005]  node  #12, CPUs:#96  #97  #98  #99 #100 #101 #102 #103
[7.865005]  node  #13, CPUs:   #104 #105 #106 #107 #108 #109 #110 #111
[8.466005]  node  #14, CPUs:   #112 #113 #114 #115 #116 #117 #118 #119
[9.073006]  node  #15, CPUs:   #120 #121 #122 #123 #124 #125 #126 #127
[9.679901] x86: Booted up 16 nodes, 128 CPUs

and drop useless elements.

Change num_digits() to hpa's division-avoiding, cell-phone-typed
version which he went at great lengths and pains to submit on a
Saturday evening.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: huawei.li...@huawei.com
Cc: wangyij...@huawei.com
Cc: fenghua...@intel.com
Cc: guohan...@huawei.com
Cc: paul.gortma...@windriver.com
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Andrew Morton a...@linux-foundation.org
Cc: Peter Zijlstra a.p.zijls...@chello.nl
Cc: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/20130930095624.gb16...@pd.tnic
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/smpboot.c | 24 +++-
 arch/x86/lib/misc.c   | 20 +++-
 kernel/smp.c  |  7 ++-
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba..2a16558 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -647,22 +647,38 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned 
long start_eip)
return (send_status | accept_status);
 }
 
+void smp_announce(void)
+{
+   int num_nodes = num_online_nodes();
+
+   printk(KERN_INFO x86: Booted up %d node%s, %d CPUs\n,
+  num_nodes, (num_nodes  1 ? s : ), num_online_cpus());
+}
+
 /* reduce the number of lines printed when booting a large cpu count system */
 static void announce_cpu(int cpu, int apicid)
 {
static int current_node = -1;
int node = early_cpu_to_node(cpu);
-   static int width;
+   static int width, node_width;
 
if (!width)
width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
 
+   if (!node_width)
+   node_width = num_digits(num_possible_nodes()) + 1; /* + '#' */
+
+   if (cpu == 1)
+   printk(KERN_INFO x86: Booting SMP configuration:\n);
+
if (system_state == SYSTEM_BOOTING) {
if (node != current_node) {
if (current_node  (-1))
-   pr_cont( OK\n);
+   pr_cont(\n);
current_node = node;
-   pr_info(Booting Node %3d, Processors:, node);
+
+   printk(KERN_INFO  node %*s#%d, CPUs:  ,
+  node_width - num_digits(node),  , node);
}
 
/* Add padding for the BSP */
@@ -671,8 +687,6 @@ static void announce_cpu(int cpu, int apicid)
 
pr_cont(%*s#%d, width - num_digits(cpu),  , cpu);
 
-   if (cpu == num_present_cpus() - 1)
-   pr_cont( OK\n);
} else
pr_info(Booting Node %d Processor %d APIC 0x%x\n,
node, cpu, apicid);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde..76b373a 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -1,11 +1,21 @@
+/*
+ * Count the digits of @val including a possible sign.
+ *
+ * (Typed on and submitted from hpa's mobile phone.)
+ */
 int num_digits(int val)
 {
-   int digits = 0;
+   int m = 10;
+   int d = 1;
 
-   while (val) {
-   val 

[tip:x86/boot] x86: Improve the printout of the SMP bootup CPU table

2013-09-28 Thread tip-bot for Borislav Petkov
Commit-ID:  646e29a1789a3a936871008c15199c50367bf291
Gitweb: http://git.kernel.org/tip/646e29a1789a3a936871008c15199c50367bf291
Author: Borislav Petkov 
AuthorDate: Fri, 27 Sep 2013 16:35:54 +0200
Committer:  Ingo Molnar 
CommitDate: Sat, 28 Sep 2013 10:10:26 +0200

x86: Improve the printout of the SMP bootup CPU table

As the new x86 CPU bootup printout format code maintainer, I am
taking immediate action to improve and clean (and thus indulge
my OCD) the reporting of the cores when coming up online.

Fix padding to a right-hand alignment, cleanup code and bind
reporting width to the max number of supported CPUs on the
system, like this:

 [0.074509] smpboot: Booting Node   0, Processors:  #1  #2  #3  #4  #5  
#6  #7 OK
 [0.644008] smpboot: Booting Node   1, Processors:  #8  #9 #10 #11 #12 #13 
#14 #15 OK
 [1.245006] smpboot: Booting Node   2, Processors: #16 #17 #18 #19 #20 #21 
#22 #23 OK
 [1.864005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 
#30 #31 OK
 [2.489005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 
#38 #39 OK
 [3.093005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 
#46 #47 OK
 [3.698005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 
#54 #55 OK
 [4.304005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 
#62 #63 OK
 [4.961413] Brought up 64 CPUs

and this:

 [0.072367] smpboot: Booting Node   0, Processors:#1 #2 #3 #4 #5 #6 #7 
OK
 [0.686329] Brought up 8 CPUs

Signed-off-by: Borislav Petkov 
Cc: Libin 
Cc: wangyij...@huawei.com
Cc: fenghua...@intel.com
Cc: guohan...@huawei.com
Cc: paul.gortma...@windriver.com
Link: http://lkml.kernel.org/r/20130927143554.gf4...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/misc.h |  6 ++
 arch/x86/kernel/smpboot.c   | 21 +++--
 arch/x86/lib/Makefile   |  2 +-
 arch/x86/lib/misc.c | 11 +++
 4 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/misc.h b/arch/x86/include/asm/misc.h
new file mode 100644
index 000..475f5bb
--- /dev/null
+++ b/arch/x86/include/asm/misc.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6cacab6..d41f3ba 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -73,11 +73,10 @@
 #include 
 #include 
 #include 
-
 #include 
 #include 
-
 #include 
+#include 
 
 /* State of each CPU */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
@@ -653,17 +652,27 @@ static void announce_cpu(int cpu, int apicid)
 {
static int current_node = -1;
int node = early_cpu_to_node(cpu);
-   int max_cpu_present = find_last_bit(cpumask_bits(cpu_present_mask), 
NR_CPUS);
+   static int width;
+
+   if (!width)
+   width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
 
if (system_state == SYSTEM_BOOTING) {
if (node != current_node) {
if (current_node > (-1))
pr_cont(" OK\n");
current_node = node;
-   pr_info("Booting Node %3d, Processors ", node);
+   pr_info("Booting Node %3d, Processors:", node);
}
-   pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
-   return;
+
+   /* Add padding for the BSP */
+   if (cpu == 1)
+   pr_cont("%*s", width + 1, " ");
+
+   pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu);
+
+   if (cpu == num_present_cpus() - 1)
+   pr_cont(" OK\n");
} else
pr_info("Booting Node %d Processor %d APIC 0x%x\n",
node, cpu, apicid);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 96b2c66..992d63b 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -16,7 +16,7 @@ clean-files := inat-tables.c
 
 obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o
 
-lib-y := delay.o
+lib-y := delay.o misc.o
 lib-y += thunk_$(BITS).o
 lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
 lib-y += memcpy_$(BITS).o
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
new file mode 100644
index 000..bc35cde
--- /dev/null
+++ b/arch/x86/lib/misc.c
@@ -0,0 +1,11 @@
+int num_digits(int val)
+{
+   int digits = 0;
+
+   while (val) {
+   val /= 10;
+   digits++;
+   }
+
+   return digits;
+}
--
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:core/locking] lockdep, x86/alternatives: Drop ancient lockdep fixup message

2013-09-28 Thread tip-bot for Borislav Petkov
Commit-ID:  2a929242ee50db84c1a561c81897bb0551f2c32f
Gitweb: http://git.kernel.org/tip/2a929242ee50db84c1a561c81897bb0551f2c32f
Author: Borislav Petkov 
AuthorDate: Fri, 27 Sep 2013 16:34:42 +0200
Committer:  Ingo Molnar 
CommitDate: Sat, 28 Sep 2013 10:09:41 +0200

lockdep, x86/alternatives: Drop ancient lockdep fixup message

It messes up the output of the nodes/cores bootup table and it
is obsolete anyway, see

  17abecfe651c x86: fix up alternatives with lockdep enabled

Signed-off-by: Borislav Petkov 
Cc: huawei.li...@huawei.com
Cc: wangyij...@huawei.com
Cc: fenghua...@intel.com
Cc: guohan...@huawei.com
Cc: paul.gortma...@windriver.com
Link: http://lkml.kernel.org/r/20130927143442.ge4...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/alternative.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 15e8563..df94598 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -402,17 +402,6 @@ void alternatives_enable_smp(void)
 {
struct smp_alt_module *mod;
 
-#ifdef CONFIG_LOCKDEP
-   /*
-* Older binutils section handling bug prevented
-* alternatives-replacement from working reliably.
-*
-* If this still occurs then you should see a hang
-* or crash shortly after this line:
-*/
-   pr_info("lockdep: fixing up alternatives\n");
-#endif
-
/* Why bother if there are no other CPUs? */
BUG_ON(num_possible_cpus() == 1);
 
--
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:core/locking] lockdep, x86/alternatives: Drop ancient lockdep fixup message

2013-09-28 Thread tip-bot for Borislav Petkov
Commit-ID:  2a929242ee50db84c1a561c81897bb0551f2c32f
Gitweb: http://git.kernel.org/tip/2a929242ee50db84c1a561c81897bb0551f2c32f
Author: Borislav Petkov b...@suse.de
AuthorDate: Fri, 27 Sep 2013 16:34:42 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Sat, 28 Sep 2013 10:09:41 +0200

lockdep, x86/alternatives: Drop ancient lockdep fixup message

It messes up the output of the nodes/cores bootup table and it
is obsolete anyway, see

  17abecfe651c x86: fix up alternatives with lockdep enabled

Signed-off-by: Borislav Petkov b...@suse.de
Cc: huawei.li...@huawei.com
Cc: wangyij...@huawei.com
Cc: fenghua...@intel.com
Cc: guohan...@huawei.com
Cc: paul.gortma...@windriver.com
Link: http://lkml.kernel.org/r/20130927143442.ge4...@pd.tnic
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/alternative.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 15e8563..df94598 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -402,17 +402,6 @@ void alternatives_enable_smp(void)
 {
struct smp_alt_module *mod;
 
-#ifdef CONFIG_LOCKDEP
-   /*
-* Older binutils section handling bug prevented
-* alternatives-replacement from working reliably.
-*
-* If this still occurs then you should see a hang
-* or crash shortly after this line:
-*/
-   pr_info(lockdep: fixing up alternatives\n);
-#endif
-
/* Why bother if there are no other CPUs? */
BUG_ON(num_possible_cpus() == 1);
 
--
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/boot] x86: Improve the printout of the SMP bootup CPU table

2013-09-28 Thread tip-bot for Borislav Petkov
Commit-ID:  646e29a1789a3a936871008c15199c50367bf291
Gitweb: http://git.kernel.org/tip/646e29a1789a3a936871008c15199c50367bf291
Author: Borislav Petkov b...@suse.de
AuthorDate: Fri, 27 Sep 2013 16:35:54 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Sat, 28 Sep 2013 10:10:26 +0200

x86: Improve the printout of the SMP bootup CPU table

As the new x86 CPU bootup printout format code maintainer, I am
taking immediate action to improve and clean (and thus indulge
my OCD) the reporting of the cores when coming up online.

Fix padding to a right-hand alignment, cleanup code and bind
reporting width to the max number of supported CPUs on the
system, like this:

 [0.074509] smpboot: Booting Node   0, Processors:  #1  #2  #3  #4  #5  
#6  #7 OK
 [0.644008] smpboot: Booting Node   1, Processors:  #8  #9 #10 #11 #12 #13 
#14 #15 OK
 [1.245006] smpboot: Booting Node   2, Processors: #16 #17 #18 #19 #20 #21 
#22 #23 OK
 [1.864005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 
#30 #31 OK
 [2.489005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 
#38 #39 OK
 [3.093005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 
#46 #47 OK
 [3.698005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 
#54 #55 OK
 [4.304005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 
#62 #63 OK
 [4.961413] Brought up 64 CPUs

and this:

 [0.072367] smpboot: Booting Node   0, Processors:#1 #2 #3 #4 #5 #6 #7 
OK
 [0.686329] Brought up 8 CPUs

Signed-off-by: Borislav Petkov b...@suse.de
Cc: Libin huawei.li...@huawei.com
Cc: wangyij...@huawei.com
Cc: fenghua...@intel.com
Cc: guohan...@huawei.com
Cc: paul.gortma...@windriver.com
Link: http://lkml.kernel.org/r/20130927143554.gf4...@pd.tnic
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/misc.h |  6 ++
 arch/x86/kernel/smpboot.c   | 21 +++--
 arch/x86/lib/Makefile   |  2 +-
 arch/x86/lib/misc.c | 11 +++
 4 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/misc.h b/arch/x86/include/asm/misc.h
new file mode 100644
index 000..475f5bb
--- /dev/null
+++ b/arch/x86/include/asm/misc.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6cacab6..d41f3ba 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -73,11 +73,10 @@
 #include asm/setup.h
 #include asm/uv/uv.h
 #include linux/mc146818rtc.h
-
 #include asm/smpboot_hooks.h
 #include asm/i8259.h
-
 #include asm/realmode.h
+#include asm/misc.h
 
 /* State of each CPU */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
@@ -653,17 +652,27 @@ static void announce_cpu(int cpu, int apicid)
 {
static int current_node = -1;
int node = early_cpu_to_node(cpu);
-   int max_cpu_present = find_last_bit(cpumask_bits(cpu_present_mask), 
NR_CPUS);
+   static int width;
+
+   if (!width)
+   width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
 
if (system_state == SYSTEM_BOOTING) {
if (node != current_node) {
if (current_node  (-1))
pr_cont( OK\n);
current_node = node;
-   pr_info(Booting Node %3d, Processors , node);
+   pr_info(Booting Node %3d, Processors:, node);
}
-   pr_cont( #%4d%s, cpu, cpu == max_cpu_present ?  OK\n : );
-   return;
+
+   /* Add padding for the BSP */
+   if (cpu == 1)
+   pr_cont(%*s, width + 1,  );
+
+   pr_cont(%*s#%d, width - num_digits(cpu),  , cpu);
+
+   if (cpu == num_present_cpus() - 1)
+   pr_cont( OK\n);
} else
pr_info(Booting Node %d Processor %d APIC 0x%x\n,
node, cpu, apicid);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 96b2c66..992d63b 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -16,7 +16,7 @@ clean-files := inat-tables.c
 
 obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o
 
-lib-y := delay.o
+lib-y := delay.o misc.o
 lib-y += thunk_$(BITS).o
 lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
 lib-y += memcpy_$(BITS).o
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
new file mode 100644
index 000..bc35cde
--- /dev/null
+++ b/arch/x86/lib/misc.c
@@ -0,0 +1,11 @@
+int num_digits(int val)
+{
+   int digits = 0;
+
+   while (val) {
+   val /= 10;
+   digits++;
+   }
+
+   return digits;
+}
--
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  

[tip:x86/urgent] x86: Remove now-unused save_rest()

2013-09-10 Thread tip-bot for Borislav Petkov
Commit-ID:  c0da0fa1d7ebe3c86747b10c92e0ac2be1524a8a
Gitweb: http://git.kernel.org/tip/c0da0fa1d7ebe3c86747b10c92e0ac2be1524a8a
Author: Borislav Petkov 
AuthorDate: Sat, 7 Sep 2013 11:39:10 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 10 Sep 2013 09:31:55 +0200

x86: Remove now-unused save_rest()

b3af11afe06a ("x86: get rid of pt_regs argument of iopl(2)")
dropped PTREGSCALL which was also the last user of save_rest.
Drop that now-unused function too.

Signed-off-by: Borislav Petkov 
Cc: Al Viro 
Link: http://lkml.kernel.org/r/1378546750-19727-1-git-send-email...@suse.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/entry_64.S | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1b69951..b077f4c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -487,21 +487,6 @@ ENDPROC(native_usergs_sysret64)
TRACE_IRQS_OFF
.endm
 
-ENTRY(save_rest)
-   PARTIAL_FRAME 1 (REST_SKIP+8)
-   movq 5*8+16(%rsp), %r11 /* save return address */
-   movq_cfi rbx, RBX+16
-   movq_cfi rbp, RBP+16
-   movq_cfi r12, R12+16
-   movq_cfi r13, R13+16
-   movq_cfi r14, R14+16
-   movq_cfi r15, R15+16
-   movq %r11, 8(%rsp)  /* return address */
-   FIXUP_TOP_OF_STACK %r11, 16
-   ret
-   CFI_ENDPROC
-END(save_rest)
-
 /* save complete stack frame */
.pushsection .kprobes.text, "ax"
 ENTRY(save_paranoid)
--
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: Remove now-unused save_rest()

2013-09-10 Thread tip-bot for Borislav Petkov
Commit-ID:  c0da0fa1d7ebe3c86747b10c92e0ac2be1524a8a
Gitweb: http://git.kernel.org/tip/c0da0fa1d7ebe3c86747b10c92e0ac2be1524a8a
Author: Borislav Petkov b...@suse.de
AuthorDate: Sat, 7 Sep 2013 11:39:10 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 10 Sep 2013 09:31:55 +0200

x86: Remove now-unused save_rest()

b3af11afe06a (x86: get rid of pt_regs argument of iopl(2))
dropped PTREGSCALL which was also the last user of save_rest.
Drop that now-unused function too.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: Al Viro v...@zeniv.linux.org.uk
Link: http://lkml.kernel.org/r/1378546750-19727-1-git-send-email...@suse.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/entry_64.S | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1b69951..b077f4c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -487,21 +487,6 @@ ENDPROC(native_usergs_sysret64)
TRACE_IRQS_OFF
.endm
 
-ENTRY(save_rest)
-   PARTIAL_FRAME 1 (REST_SKIP+8)
-   movq 5*8+16(%rsp), %r11 /* save return address */
-   movq_cfi rbx, RBX+16
-   movq_cfi rbp, RBP+16
-   movq_cfi r12, R12+16
-   movq_cfi r13, R13+16
-   movq_cfi r14, R14+16
-   movq_cfi r15, R15+16
-   movq %r11, 8(%rsp)  /* return address */
-   FIXUP_TOP_OF_STACK %r11, 16
-   ret
-   CFI_ENDPROC
-END(save_rest)
-
 /* save complete stack frame */
.pushsection .kprobes.text, ax
 ENTRY(save_paranoid)
--
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: Use new CC_HAVE_ASM_GOTO

2013-07-05 Thread tip-bot for Borislav Petkov
Commit-ID:  62122fd7dadac09704782d8bc051fb898a0272bd
Gitweb: http://git.kernel.org/tip/62122fd7dadac09704782d8bc051fb898a0272bd
Author: Borislav Petkov 
AuthorDate: Fri, 28 Jun 2013 18:41:41 +0200
Committer:  H. Peter Anvin 
CommitDate: Fri, 28 Jun 2013 15:26:48 -0700

x86, cpufeature: Use new CC_HAVE_ASM_GOTO

... for checking for "asm goto" compiler support. It is more explicit
this way and we cover the cases where distros have backported that
support even to gcc versions < 4.5.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1372437701-13351-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/cpufeature.h | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 47538a6..d3f5c63 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -366,9 +366,10 @@ extern bool __static_cpu_has_safe(u16 bit);
  */
 static __always_inline __pure bool __static_cpu_has(u16 bit)
 {
-#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
+#ifdef CC_HAVE_ASM_GOTO
 
 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+
/*
 * Catch too early usage of this before alternatives
 * have run.
@@ -384,6 +385,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 ".previous\n"
 /* skipping size check since replacement size = 0 */
 : : "i" (X86_FEATURE_ALWAYS) : : t_warn);
+
 #endif
 
asm goto("1: jmp %l[t_no]\n"
@@ -406,7 +408,9 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
warn_pre_alternatives();
return false;
 #endif
-#else /* GCC_VERSION >= 40500 */
+
+#else /* CC_HAVE_ASM_GOTO */
+
u8 flag;
/* Open-coded due to __stringify() in ALTERNATIVE() */
asm volatile("1: movb $0,%0\n"
@@ -427,7 +431,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 ".previous\n"
 : "=qm" (flag) : "i" (bit));
return flag;
-#endif
+
+#endif /* CC_HAVE_ASM_GOTO */
 }
 
 #define static_cpu_has(bit)\
@@ -441,7 +446,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 
 static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
 {
-#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
+#ifdef CC_HAVE_ASM_GOTO
 /*
  * We need to spell the jumps to the compiler because, depending on the offset,
  * the replacement jump can be bigger than the original jump, and this we 
cannot
@@ -475,7 +480,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 
bit)
return false;
t_dynamic:
return __static_cpu_has_safe(bit);
-#else /* GCC_VERSION >= 40500 */
+#else
u8 flag;
/* Open-coded due to __stringify() in ALTERNATIVE() */
asm volatile("1: movb $2,%0\n"
@@ -511,7 +516,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 
bit)
 : "=qm" (flag)
 : "i" (bit), "i" (X86_FEATURE_ALWAYS));
return (flag == 2 ? __static_cpu_has_safe(bit) : flag);
-#endif
+#endif /* CC_HAVE_ASM_GOTO */
 }
 
 #define static_cpu_has_safe(bit)   \
--
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: Use new CC_HAVE_ASM_GOTO

2013-07-05 Thread tip-bot for Borislav Petkov
Commit-ID:  62122fd7dadac09704782d8bc051fb898a0272bd
Gitweb: http://git.kernel.org/tip/62122fd7dadac09704782d8bc051fb898a0272bd
Author: Borislav Petkov b...@suse.de
AuthorDate: Fri, 28 Jun 2013 18:41:41 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Fri, 28 Jun 2013 15:26:48 -0700

x86, cpufeature: Use new CC_HAVE_ASM_GOTO

... for checking for asm goto compiler support. It is more explicit
this way and we cover the cases where distros have backported that
support even to gcc versions  4.5.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1372437701-13351-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/cpufeature.h | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 47538a6..d3f5c63 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -366,9 +366,10 @@ extern bool __static_cpu_has_safe(u16 bit);
  */
 static __always_inline __pure bool __static_cpu_has(u16 bit)
 {
-#if __GNUC__  4 || __GNUC_MINOR__ = 5
+#ifdef CC_HAVE_ASM_GOTO
 
 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+
/*
 * Catch too early usage of this before alternatives
 * have run.
@@ -384,6 +385,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 .previous\n
 /* skipping size check since replacement size = 0 */
 : : i (X86_FEATURE_ALWAYS) : : t_warn);
+
 #endif
 
asm goto(1: jmp %l[t_no]\n
@@ -406,7 +408,9 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
warn_pre_alternatives();
return false;
 #endif
-#else /* GCC_VERSION = 40500 */
+
+#else /* CC_HAVE_ASM_GOTO */
+
u8 flag;
/* Open-coded due to __stringify() in ALTERNATIVE() */
asm volatile(1: movb $0,%0\n
@@ -427,7 +431,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 .previous\n
 : =qm (flag) : i (bit));
return flag;
-#endif
+
+#endif /* CC_HAVE_ASM_GOTO */
 }
 
 #define static_cpu_has(bit)\
@@ -441,7 +446,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 
 static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
 {
-#if __GNUC__  4 || __GNUC_MINOR__ = 5
+#ifdef CC_HAVE_ASM_GOTO
 /*
  * We need to spell the jumps to the compiler because, depending on the offset,
  * the replacement jump can be bigger than the original jump, and this we 
cannot
@@ -475,7 +480,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 
bit)
return false;
t_dynamic:
return __static_cpu_has_safe(bit);
-#else /* GCC_VERSION = 40500 */
+#else
u8 flag;
/* Open-coded due to __stringify() in ALTERNATIVE() */
asm volatile(1: movb $2,%0\n
@@ -511,7 +516,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 
bit)
 : =qm (flag)
 : i (bit), i (X86_FEATURE_ALWAYS));
return (flag == 2 ? __static_cpu_has_safe(bit) : flag);
-#endif
+#endif /* CC_HAVE_ASM_GOTO */
 }
 
 #define static_cpu_has_safe(bit)   \
--
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/mm] x86/ioremap: Correct function name output

2013-06-28 Thread tip-bot for Borislav Petkov
Commit-ID:  4f4319a02a6108be3e65b9d44d1b7f5e8f520535
Gitweb: http://git.kernel.org/tip/4f4319a02a6108be3e65b9d44d1b7f5e8f520535
Author: Borislav Petkov 
AuthorDate: Thu, 27 Jun 2013 23:53:16 +0200
Committer:  Ingo Molnar 
CommitDate: Fri, 28 Jun 2013 11:11:58 +0200

x86/ioremap: Correct function name output

Infact, let the compiler enter the function name so that there
are no discrepancies.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1372369996-20556-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/mm/ioremap.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 9a1e658..0215e2c 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -501,15 +501,15 @@ __early_ioremap(resource_size_t phys_addr, unsigned long 
size, pgprot_t prot)
}
 
if (slot < 0) {
-   printk(KERN_INFO "early_iomap(%08llx, %08lx) not found slot\n",
-(u64)phys_addr, size);
+   printk(KERN_INFO "%s(%08llx, %08lx) not found slot\n",
+  __func__, (u64)phys_addr, size);
WARN_ON(1);
return NULL;
}
 
if (early_ioremap_debug) {
-   printk(KERN_INFO "early_ioremap(%08llx, %08lx) [%d] => ",
-  (u64)phys_addr, size, slot);
+   printk(KERN_INFO "%s(%08llx, %08lx) [%d] => ",
+  __func__, (u64)phys_addr, size, slot);
dump_stack();
}
 
--
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/mm] x86/ioremap: Correct function name output

2013-06-28 Thread tip-bot for Borislav Petkov
Commit-ID:  4f4319a02a6108be3e65b9d44d1b7f5e8f520535
Gitweb: http://git.kernel.org/tip/4f4319a02a6108be3e65b9d44d1b7f5e8f520535
Author: Borislav Petkov b...@suse.de
AuthorDate: Thu, 27 Jun 2013 23:53:16 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Fri, 28 Jun 2013 11:11:58 +0200

x86/ioremap: Correct function name output

Infact, let the compiler enter the function name so that there
are no discrepancies.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1372369996-20556-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/mm/ioremap.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 9a1e658..0215e2c 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -501,15 +501,15 @@ __early_ioremap(resource_size_t phys_addr, unsigned long 
size, pgprot_t prot)
}
 
if (slot  0) {
-   printk(KERN_INFO early_iomap(%08llx, %08lx) not found slot\n,
-(u64)phys_addr, size);
+   printk(KERN_INFO %s(%08llx, %08lx) not found slot\n,
+  __func__, (u64)phys_addr, size);
WARN_ON(1);
return NULL;
}
 
if (early_ioremap_debug) {
-   printk(KERN_INFO early_ioremap(%08llx, %08lx) [%d] = ,
-  (u64)phys_addr, size, slot);
+   printk(KERN_INFO %s(%08llx, %08lx) [%d] = ,
+  __func__, (u64)phys_addr, size, slot);
dump_stack();
}
 
--
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/platform] x86/platform: Add kvmconfig to the phony targets

2013-06-23 Thread tip-bot for Borislav Petkov
Commit-ID:  fc58be7596b832ee9635b2f7090a589ac5cdb807
Gitweb: http://git.kernel.org/tip/fc58be7596b832ee9635b2f7090a589ac5cdb807
Author: Borislav Petkov 
AuthorDate: Fri, 21 Jun 2013 10:04:51 +0200
Committer:  Ingo Molnar 
CommitDate: Sun, 23 Jun 2013 12:17:35 +0200

x86/platform: Add kvmconfig to the phony targets

... so as not to disable it with a file of the same name in the
toplevel build directory.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1371801891-23618-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 91ee171..07639c6 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -220,6 +220,7 @@ archclean:
$(Q)$(MAKE) $(clean)=$(boot)
$(Q)$(MAKE) $(clean)=arch/x86/tools
 
+PHONY += kvmconfig
 kvmconfig:
$(if $(wildcard $(objtree)/.config),, $(error You need an existing 
.config for this target))
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O 
$(objtree) $(objtree)/.config arch/x86/configs/kvm_guest.config
--
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/platform] x86/platform: Add kvmconfig to the phony targets

2013-06-23 Thread tip-bot for Borislav Petkov
Commit-ID:  fc58be7596b832ee9635b2f7090a589ac5cdb807
Gitweb: http://git.kernel.org/tip/fc58be7596b832ee9635b2f7090a589ac5cdb807
Author: Borislav Petkov b...@suse.de
AuthorDate: Fri, 21 Jun 2013 10:04:51 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Sun, 23 Jun 2013 12:17:35 +0200

x86/platform: Add kvmconfig to the phony targets

... so as not to disable it with a file of the same name in the
toplevel build directory.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1371801891-23618-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 91ee171..07639c6 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -220,6 +220,7 @@ archclean:
$(Q)$(MAKE) $(clean)=$(boot)
$(Q)$(MAKE) $(clean)=arch/x86/tools
 
+PHONY += kvmconfig
 kvmconfig:
$(if $(wildcard $(objtree)/.config),, $(error You need an existing 
.config for this target))
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O 
$(objtree) $(objtree)/.config arch/x86/configs/kvm_guest.config
--
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/fpu] x86: Add a static_cpu_has_safe variant

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  4a90a99c4f8002edaa6be11bd756872ebf3f3d97
Gitweb: http://git.kernel.org/tip/4a90a99c4f8002edaa6be11bd756872ebf3f3d97
Author: Borislav Petkov 
AuthorDate: Sun, 9 Jun 2013 12:07:33 +0200
Committer:  H. Peter Anvin 
CommitDate: Thu, 20 Jun 2013 17:38:14 -0700

x86: Add a static_cpu_has_safe variant

We want to use this in early code where alternatives might not have run
yet and for that case we fall back to the dynamic boot_cpu_has.

For that, force a 5-byte jump since the compiler could be generating
differently sized jumps for each label.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1370772454-6106-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/cpufeature.h | 86 ++-
 arch/x86/kernel/cpu/common.c  |  6 +++
 2 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 252b28f..47538a6 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -357,6 +357,7 @@ extern const char * const x86_power_flags[32];
 
 #if __GNUC__ >= 4
 extern void warn_pre_alternatives(void);
+extern bool __static_cpu_has_safe(u16 bit);
 
 /*
  * Static testing of CPU features.  Used the same as boot_cpu_has().
@@ -437,11 +438,94 @@ static __always_inline __pure bool __static_cpu_has(u16 
bit)
__static_cpu_has(bit) : \
boot_cpu_has(bit)   \
 )
+
+static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
+{
+#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
+/*
+ * We need to spell the jumps to the compiler because, depending on the offset,
+ * the replacement jump can be bigger than the original jump, and this we 
cannot
+ * have. Thus, we force the jump to the widest, 4-byte, signed relative
+ * offset even though the last would often fit in less bytes.
+ */
+   asm goto("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n"
+"2:\n"
+".section .altinstructions,\"a\"\n"
+" .long 1b - .\n"  /* src offset */
+" .long 3f - .\n"  /* repl offset */
+" .word %P1\n" /* always replace */
+" .byte 2b - 1b\n" /* src len */
+" .byte 4f - 3f\n" /* repl len */
+".previous\n"
+".section .altinstr_replacement,\"ax\"\n"
+"3: .byte 0xe9\n .long %l[t_no] - 2b\n"
+"4:\n"
+".previous\n"
+".section .altinstructions,\"a\"\n"
+" .long 1b - .\n"  /* src offset */
+" .long 0\n"   /* no replacement */
+" .word %P0\n" /* feature bit */
+" .byte 2b - 1b\n" /* src len */
+" .byte 0\n"   /* repl len */
+".previous\n"
+: : "i" (bit), "i" (X86_FEATURE_ALWAYS)
+: : t_dynamic, t_no);
+   return true;
+   t_no:
+   return false;
+   t_dynamic:
+   return __static_cpu_has_safe(bit);
+#else /* GCC_VERSION >= 40500 */
+   u8 flag;
+   /* Open-coded due to __stringify() in ALTERNATIVE() */
+   asm volatile("1: movb $2,%0\n"
+"2:\n"
+".section .altinstructions,\"a\"\n"
+" .long 1b - .\n"  /* src offset */
+" .long 3f - .\n"  /* repl offset */
+" .word %P2\n" /* always replace */
+" .byte 2b - 1b\n" /* source len */
+" .byte 4f - 3f\n" /* replacement len */
+".previous\n"
+".section .discard,\"aw\",@progbits\n"
+" .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check 
*/
+".previous\n"
+".section .altinstr_replacement,\"ax\"\n"
+"3: movb $0,%0\n"
+"4:\n"
+".previous\n"
+".section .altinstructions,\"a\"\n"
+" .long 1b - .\n"  /* src offset */
+" .long 5f - .\n"  /* repl offset */
+" .word %P1\n" /* feature bit */
+" .byte 4b - 3b\n" /* src len */
+" .byte 6f - 5f\n" /* repl len */
+  

[tip:x86/fpu] x86: Sanity-check static_cpu_has usage

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  5700f743b597951743da9c7d891d3989aac0486e
Gitweb: http://git.kernel.org/tip/5700f743b597951743da9c7d891d3989aac0486e
Author: Borislav Petkov 
AuthorDate: Sun, 9 Jun 2013 12:07:32 +0200
Committer:  H. Peter Anvin 
CommitDate: Thu, 20 Jun 2013 17:37:19 -0700

x86: Sanity-check static_cpu_has usage

static_cpu_has may be used only after alternatives have run. Before that
it always returns false if constant folding with __builtin_constant_p()
doesn't happen. And you don't want that.

This patch is the result of me debugging an issue where I overzealously
put static_cpu_has in code which executed before alternatives have run
and had to spend some time with scratching head and cursing at the
monitor.

So add a jump to a warning which screams loudly when we use this
function too early. The alternatives patch that check away in
conjunction with patching the rest of the kernel image.

[ hpa: factored this into its own configuration option.  If we want to
  have an overarching option, it should be an option which selects
  other options, not as a group option in the source code. ]

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1370772454-6106-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/Kconfig.debug| 10 ++
 arch/x86/include/asm/cpufeature.h | 30 --
 arch/x86/kernel/cpu/common.c  |  8 
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index c198b7e..c6acdf7 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -304,4 +304,14 @@ config DEBUG_NMI_SELFTEST
 
  If unsure, say N.
 
+config X86_DEBUG_STATIC_CPU_HAS
+   bool "Debug alternatives"
+   depends on DEBUG_KERNEL
+   ---help---
+ This option causes additional code to be generated which
+ fails if static_cpu_has() is used before alternatives have
+ run.
+
+ If unsure, say N.
+
 endmenu
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 043d61e..252b28f 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -356,15 +356,35 @@ extern const char * const x86_power_flags[32];
 #endif /* CONFIG_X86_64 */
 
 #if __GNUC__ >= 4
+extern void warn_pre_alternatives(void);
+
 /*
  * Static testing of CPU features.  Used the same as boot_cpu_has().
  * These are only valid after alternatives have run, but will statically
  * patch the target code for additional performance.
- *
  */
 static __always_inline __pure bool __static_cpu_has(u16 bit)
 {
 #if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
+
+#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+   /*
+* Catch too early usage of this before alternatives
+* have run.
+*/
+   asm goto("1: jmp %l[t_warn]\n"
+"2:\n"
+".section .altinstructions,\"a\"\n"
+" .long 1b - .\n"
+" .long 0\n"   /* no replacement */
+" .word %P0\n" /* 1: do replace */
+" .byte 2b - 1b\n" /* source len */
+" .byte 0\n"   /* replacement len */
+".previous\n"
+/* skipping size check since replacement size = 0 */
+: : "i" (X86_FEATURE_ALWAYS) : : t_warn);
+#endif
+
asm goto("1: jmp %l[t_no]\n"
 "2:\n"
 ".section .altinstructions,\"a\"\n"
@@ -379,7 +399,13 @@ static __always_inline __pure bool __static_cpu_has(u16 
bit)
return true;
t_no:
return false;
-#else
+
+#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+   t_warn:
+   warn_pre_alternatives();
+   return false;
+#endif
+#else /* GCC_VERSION >= 40500 */
u8 flag;
/* Open-coded due to __stringify() in ALTERNATIVE() */
asm volatile("1: movb $0,%0\n"
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d388ce1..59adaa1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1364,3 +1364,11 @@ void __cpuinit cpu_init(void)
fpu_init();
 }
 #endif
+
+#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+void warn_pre_alternatives(void)
+{
+   WARN(1, "You're using static_cpu_has before alternatives have run!\n");
+}
+EXPORT_SYMBOL_GPL(warn_pre_alternatives);
+#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/fpu] x86, cpu: Add a synthetic, always true, cpu feature

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  c3b83598c1eeb1507603b461f5843ec2a49e3033
Gitweb: http://git.kernel.org/tip/c3b83598c1eeb1507603b461f5843ec2a49e3033
Author: Borislav Petkov 
AuthorDate: Sun, 9 Jun 2013 12:07:30 +0200
Committer:  H. Peter Anvin 
CommitDate: Thu, 20 Jun 2013 17:06:07 -0700

x86, cpu: Add a synthetic, always true, cpu feature

This will be used in alternatives later as an always-replace flag.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1370772454-6106-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/cpufeature.h | 2 +-
 arch/x86/kernel/cpu/common.c  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index e99ac27..043d61e 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -92,7 +92,7 @@
 #define X86_FEATURE_LFENCE_RDTSC (3*32+18) /* "" Lfence synchronizes RDTSC */
 #define X86_FEATURE_11AP   (3*32+19) /* "" Bad local APIC aka 11AP */
 #define X86_FEATURE_NOPL   (3*32+20) /* The NOPL (0F 1F) instructions */
- /* 21 available, was AMD_C1E */
+#define X86_FEATURE_ALWAYS (3*32+21) /* "" Always-present feature */
 #define X86_FEATURE_XTOPOLOGY  (3*32+22) /* cpu topology enum extensions */
 #define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */
 #define X86_FEATURE_NONSTOP_TSC(3*32+24) /* TSC does not stop in C 
states */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d4dd993..d388ce1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -723,6 +723,8 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
if (this_cpu->c_bsp_init)
this_cpu->c_bsp_init(c);
+
+   setup_force_cpu_cap(X86_FEATURE_ALWAYS);
 }
 
 void __init early_cpu_init(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/fpu] x86, fpu: Use static_cpu_has_safe before alternatives

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  5f8c4218148822fde6eebbeefc34bd0a6061e031
Gitweb: http://git.kernel.org/tip/5f8c4218148822fde6eebbeefc34bd0a6061e031
Author: Borislav Petkov 
AuthorDate: Sun, 9 Jun 2013 12:07:34 +0200
Committer:  H. Peter Anvin 
CommitDate: Thu, 20 Jun 2013 17:38:22 -0700

x86, fpu: Use static_cpu_has_safe before alternatives

The call stack below shows how this happens: basically eager_fpu_init()
calls __thread_fpu_begin(current) which then does if (!use_eager_fpu()),
which, in turn, uses static_cpu_has.

And we're executing before alternatives so static_cpu_has doesn't work
there yet.

Use the safe variant in this path which becomes optimal after
alternatives have run.

WARNING: at arch/x86/kernel/cpu/common.c:1368 warn_pre_alternatives+0x1e/0x20()
You're using static_cpu_has before alternatives have run!
Modules linked in:
Pid: 0, comm: swapper Not tainted 3.9.0-rc8+ #1
Call Trace:
 warn_slowpath_common
 warn_slowpath_fmt
 ? fpu_finit
 warn_pre_alternatives
 eager_fpu_init
 fpu_init
 cpu_init
 trap_init
 start_kernel
 ? repair_env_string
 x86_64_start_reservations
 x86_64_start_kernel

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1370772454-6106-6-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/fpu-internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu-internal.h 
b/arch/x86/include/asm/fpu-internal.h
index fb808d7..4d0bda7 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -343,7 +343,7 @@ static inline void __thread_fpu_end(struct task_struct *tsk)
 
 static inline void __thread_fpu_begin(struct task_struct *tsk)
 {
-   if (!use_eager_fpu())
+   if (!static_cpu_has_safe(X86_FEATURE_EAGER_FPU))
clts();
__thread_set_has_fpu(tsk);
 }
--
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/intel/cacheinfo: Shut up last long-standing warning

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  719038de98bc8479b771c582a1e4a1e86079da22
Gitweb: http://git.kernel.org/tip/719038de98bc8479b771c582a1e4a1e86079da22
Author: Borislav Petkov 
AuthorDate: Sat, 8 Jun 2013 18:48:15 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 20 Jun 2013 12:27:41 +0200

x86/intel/cacheinfo: Shut up last long-standing warning

arch/x86/kernel/cpu/intel_cacheinfo.c: In function ‘init_intel_cacheinfo’:
arch/x86/kernel/cpu/intel_cacheinfo.c:642:28: warning: ‘this_leaf.size’ may be 
used uninitialized in this function [-Wmaybe-uninitialized] 
arch/x86/kernel/cpu/intel_cacheinfo.c:643:29: warning: 
‘this_leaf.eax.split.num_threads_sharing’ may be used uninitialized in this 
function [-Wmaybe-uninitialized]

This keeps on happening during randbuilds and the compiler is
wrong here:

In the case where cpuid4_cache_lookup_regs() returns 0, both
this_leaf.size and this_leaf.eax get initialized. In the case
where the CPUID leaf doesn't contain valid cache info, we error
out which init_intel_cacheinfo() handles correctly without
touching the abovementioned fields.

So shut up the warning by clearing out the struct which we hand
down.

While at it, reverse error handling and gain one indentation
level.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1370710095-20547-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/intel_cacheinfo.c | 52 +--
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c 
b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 7c6f7d5..8dc72dd 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -618,36 +618,34 @@ unsigned int __cpuinit init_intel_cacheinfo(struct 
cpuinfo_x86 *c)
 * parameters cpuid leaf to find the cache details
 */
for (i = 0; i < num_cache_leaves; i++) {
-   struct _cpuid4_info_regs this_leaf;
+   struct _cpuid4_info_regs this_leaf = {};
int retval;
 
retval = cpuid4_cache_lookup_regs(i, _leaf);
-   if (retval >= 0) {
-   switch (this_leaf.eax.split.level) {
-   case 1:
-   if (this_leaf.eax.split.type ==
-   CACHE_TYPE_DATA)
-   new_l1d = this_leaf.size/1024;
-   else if (this_leaf.eax.split.type ==
-   CACHE_TYPE_INST)
-   new_l1i = this_leaf.size/1024;
-   break;
-   case 2:
-   new_l2 = this_leaf.size/1024;
-   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
-   index_msb = 
get_count_order(num_threads_sharing);
-   l2_id = c->apicid & ~((1 << index_msb) 
- 1);
-   break;
-   case 3:
-   new_l3 = this_leaf.size/1024;
-   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
-   index_msb = get_count_order(
-   num_threads_sharing);
-   l3_id = c->apicid & ~((1 << index_msb) 
- 1);
-   break;
-   default:
-   break;
-   }
+   if (retval < 0)
+   continue;
+
+   switch (this_leaf.eax.split.level) {
+   case 1:
+   if (this_leaf.eax.split.type == CACHE_TYPE_DATA)
+   new_l1d = this_leaf.size/1024;
+   else if (this_leaf.eax.split.type == 
CACHE_TYPE_INST)
+   new_l1i = this_leaf.size/1024;
+   break;
+   case 2:
+   new_l2 = this_leaf.size/1024;
+   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
+   index_msb = 
get_count_order(num_threads_sharing);
+   l2_id = c->apicid & ~((1 << index_msb) - 1);
+   break;
+   case 3:
+   new_l3 = this_leaf.size/1024;
+   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
+ 

[tip:x86/cpu] x86/intel/cacheinfo: Shut up last long-standing warning

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  719038de98bc8479b771c582a1e4a1e86079da22
Gitweb: http://git.kernel.org/tip/719038de98bc8479b771c582a1e4a1e86079da22
Author: Borislav Petkov b...@suse.de
AuthorDate: Sat, 8 Jun 2013 18:48:15 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 20 Jun 2013 12:27:41 +0200

x86/intel/cacheinfo: Shut up last long-standing warning

arch/x86/kernel/cpu/intel_cacheinfo.c: In function ‘init_intel_cacheinfo’:
arch/x86/kernel/cpu/intel_cacheinfo.c:642:28: warning: ‘this_leaf.size’ may be 
used uninitialized in this function [-Wmaybe-uninitialized] 
arch/x86/kernel/cpu/intel_cacheinfo.c:643:29: warning: 
‘this_leaf.eax.split.num_threads_sharing’ may be used uninitialized in this 
function [-Wmaybe-uninitialized]

This keeps on happening during randbuilds and the compiler is
wrong here:

In the case where cpuid4_cache_lookup_regs() returns 0, both
this_leaf.size and this_leaf.eax get initialized. In the case
where the CPUID leaf doesn't contain valid cache info, we error
out which init_intel_cacheinfo() handles correctly without
touching the abovementioned fields.

So shut up the warning by clearing out the struct which we hand
down.

While at it, reverse error handling and gain one indentation
level.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1370710095-20547-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/kernel/cpu/intel_cacheinfo.c | 52 +--
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c 
b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 7c6f7d5..8dc72dd 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -618,36 +618,34 @@ unsigned int __cpuinit init_intel_cacheinfo(struct 
cpuinfo_x86 *c)
 * parameters cpuid leaf to find the cache details
 */
for (i = 0; i  num_cache_leaves; i++) {
-   struct _cpuid4_info_regs this_leaf;
+   struct _cpuid4_info_regs this_leaf = {};
int retval;
 
retval = cpuid4_cache_lookup_regs(i, this_leaf);
-   if (retval = 0) {
-   switch (this_leaf.eax.split.level) {
-   case 1:
-   if (this_leaf.eax.split.type ==
-   CACHE_TYPE_DATA)
-   new_l1d = this_leaf.size/1024;
-   else if (this_leaf.eax.split.type ==
-   CACHE_TYPE_INST)
-   new_l1i = this_leaf.size/1024;
-   break;
-   case 2:
-   new_l2 = this_leaf.size/1024;
-   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
-   index_msb = 
get_count_order(num_threads_sharing);
-   l2_id = c-apicid  ~((1  index_msb) 
- 1);
-   break;
-   case 3:
-   new_l3 = this_leaf.size/1024;
-   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
-   index_msb = get_count_order(
-   num_threads_sharing);
-   l3_id = c-apicid  ~((1  index_msb) 
- 1);
-   break;
-   default:
-   break;
-   }
+   if (retval  0)
+   continue;
+
+   switch (this_leaf.eax.split.level) {
+   case 1:
+   if (this_leaf.eax.split.type == CACHE_TYPE_DATA)
+   new_l1d = this_leaf.size/1024;
+   else if (this_leaf.eax.split.type == 
CACHE_TYPE_INST)
+   new_l1i = this_leaf.size/1024;
+   break;
+   case 2:
+   new_l2 = this_leaf.size/1024;
+   num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
+   index_msb = 
get_count_order(num_threads_sharing);
+   l2_id = c-apicid  ~((1  index_msb) - 1);
+   break;
+   case 3:
+   new_l3 = this_leaf.size/1024;
+   num_threads_sharing = 1 + 

[tip:x86/fpu] x86, fpu: Use static_cpu_has_safe before alternatives

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  5f8c4218148822fde6eebbeefc34bd0a6061e031
Gitweb: http://git.kernel.org/tip/5f8c4218148822fde6eebbeefc34bd0a6061e031
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Jun 2013 12:07:34 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 20 Jun 2013 17:38:22 -0700

x86, fpu: Use static_cpu_has_safe before alternatives

The call stack below shows how this happens: basically eager_fpu_init()
calls __thread_fpu_begin(current) which then does if (!use_eager_fpu()),
which, in turn, uses static_cpu_has.

And we're executing before alternatives so static_cpu_has doesn't work
there yet.

Use the safe variant in this path which becomes optimal after
alternatives have run.

WARNING: at arch/x86/kernel/cpu/common.c:1368 warn_pre_alternatives+0x1e/0x20()
You're using static_cpu_has before alternatives have run!
Modules linked in:
Pid: 0, comm: swapper Not tainted 3.9.0-rc8+ #1
Call Trace:
 warn_slowpath_common
 warn_slowpath_fmt
 ? fpu_finit
 warn_pre_alternatives
 eager_fpu_init
 fpu_init
 cpu_init
 trap_init
 start_kernel
 ? repair_env_string
 x86_64_start_reservations
 x86_64_start_kernel

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1370772454-6106-6-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/fpu-internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu-internal.h 
b/arch/x86/include/asm/fpu-internal.h
index fb808d7..4d0bda7 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -343,7 +343,7 @@ static inline void __thread_fpu_end(struct task_struct *tsk)
 
 static inline void __thread_fpu_begin(struct task_struct *tsk)
 {
-   if (!use_eager_fpu())
+   if (!static_cpu_has_safe(X86_FEATURE_EAGER_FPU))
clts();
__thread_set_has_fpu(tsk);
 }
--
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/fpu] x86, cpu: Add a synthetic, always true, cpu feature

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  c3b83598c1eeb1507603b461f5843ec2a49e3033
Gitweb: http://git.kernel.org/tip/c3b83598c1eeb1507603b461f5843ec2a49e3033
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Jun 2013 12:07:30 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 20 Jun 2013 17:06:07 -0700

x86, cpu: Add a synthetic, always true, cpu feature

This will be used in alternatives later as an always-replace flag.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1370772454-6106-2-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/cpufeature.h | 2 +-
 arch/x86/kernel/cpu/common.c  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index e99ac27..043d61e 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -92,7 +92,7 @@
 #define X86_FEATURE_LFENCE_RDTSC (3*32+18) /*  Lfence synchronizes RDTSC */
 #define X86_FEATURE_11AP   (3*32+19) /*  Bad local APIC aka 11AP */
 #define X86_FEATURE_NOPL   (3*32+20) /* The NOPL (0F 1F) instructions */
- /* 21 available, was AMD_C1E */
+#define X86_FEATURE_ALWAYS (3*32+21) /*  Always-present feature */
 #define X86_FEATURE_XTOPOLOGY  (3*32+22) /* cpu topology enum extensions */
 #define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */
 #define X86_FEATURE_NONSTOP_TSC(3*32+24) /* TSC does not stop in C 
states */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d4dd993..d388ce1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -723,6 +723,8 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
if (this_cpu-c_bsp_init)
this_cpu-c_bsp_init(c);
+
+   setup_force_cpu_cap(X86_FEATURE_ALWAYS);
 }
 
 void __init early_cpu_init(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/fpu] x86: Sanity-check static_cpu_has usage

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  5700f743b597951743da9c7d891d3989aac0486e
Gitweb: http://git.kernel.org/tip/5700f743b597951743da9c7d891d3989aac0486e
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Jun 2013 12:07:32 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 20 Jun 2013 17:37:19 -0700

x86: Sanity-check static_cpu_has usage

static_cpu_has may be used only after alternatives have run. Before that
it always returns false if constant folding with __builtin_constant_p()
doesn't happen. And you don't want that.

This patch is the result of me debugging an issue where I overzealously
put static_cpu_has in code which executed before alternatives have run
and had to spend some time with scratching head and cursing at the
monitor.

So add a jump to a warning which screams loudly when we use this
function too early. The alternatives patch that check away in
conjunction with patching the rest of the kernel image.

[ hpa: factored this into its own configuration option.  If we want to
  have an overarching option, it should be an option which selects
  other options, not as a group option in the source code. ]

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1370772454-6106-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/Kconfig.debug| 10 ++
 arch/x86/include/asm/cpufeature.h | 30 --
 arch/x86/kernel/cpu/common.c  |  8 
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index c198b7e..c6acdf7 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -304,4 +304,14 @@ config DEBUG_NMI_SELFTEST
 
  If unsure, say N.
 
+config X86_DEBUG_STATIC_CPU_HAS
+   bool Debug alternatives
+   depends on DEBUG_KERNEL
+   ---help---
+ This option causes additional code to be generated which
+ fails if static_cpu_has() is used before alternatives have
+ run.
+
+ If unsure, say N.
+
 endmenu
diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 043d61e..252b28f 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -356,15 +356,35 @@ extern const char * const x86_power_flags[32];
 #endif /* CONFIG_X86_64 */
 
 #if __GNUC__ = 4
+extern void warn_pre_alternatives(void);
+
 /*
  * Static testing of CPU features.  Used the same as boot_cpu_has().
  * These are only valid after alternatives have run, but will statically
  * patch the target code for additional performance.
- *
  */
 static __always_inline __pure bool __static_cpu_has(u16 bit)
 {
 #if __GNUC__  4 || __GNUC_MINOR__ = 5
+
+#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+   /*
+* Catch too early usage of this before alternatives
+* have run.
+*/
+   asm goto(1: jmp %l[t_warn]\n
+2:\n
+.section .altinstructions,\a\\n
+ .long 1b - .\n
+ .long 0\n   /* no replacement */
+ .word %P0\n /* 1: do replace */
+ .byte 2b - 1b\n /* source len */
+ .byte 0\n   /* replacement len */
+.previous\n
+/* skipping size check since replacement size = 0 */
+: : i (X86_FEATURE_ALWAYS) : : t_warn);
+#endif
+
asm goto(1: jmp %l[t_no]\n
 2:\n
 .section .altinstructions,\a\\n
@@ -379,7 +399,13 @@ static __always_inline __pure bool __static_cpu_has(u16 
bit)
return true;
t_no:
return false;
-#else
+
+#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+   t_warn:
+   warn_pre_alternatives();
+   return false;
+#endif
+#else /* GCC_VERSION = 40500 */
u8 flag;
/* Open-coded due to __stringify() in ALTERNATIVE() */
asm volatile(1: movb $0,%0\n
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d388ce1..59adaa1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1364,3 +1364,11 @@ void __cpuinit cpu_init(void)
fpu_init();
 }
 #endif
+
+#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
+void warn_pre_alternatives(void)
+{
+   WARN(1, You're using static_cpu_has before alternatives have run!\n);
+}
+EXPORT_SYMBOL_GPL(warn_pre_alternatives);
+#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/fpu] x86: Add a static_cpu_has_safe variant

2013-06-20 Thread tip-bot for Borislav Petkov
Commit-ID:  4a90a99c4f8002edaa6be11bd756872ebf3f3d97
Gitweb: http://git.kernel.org/tip/4a90a99c4f8002edaa6be11bd756872ebf3f3d97
Author: Borislav Petkov b...@suse.de
AuthorDate: Sun, 9 Jun 2013 12:07:33 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 20 Jun 2013 17:38:14 -0700

x86: Add a static_cpu_has_safe variant

We want to use this in early code where alternatives might not have run
yet and for that case we fall back to the dynamic boot_cpu_has.

For that, force a 5-byte jump since the compiler could be generating
differently sized jumps for each label.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1370772454-6106-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/include/asm/cpufeature.h | 86 ++-
 arch/x86/kernel/cpu/common.c  |  6 +++
 2 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 252b28f..47538a6 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -357,6 +357,7 @@ extern const char * const x86_power_flags[32];
 
 #if __GNUC__ = 4
 extern void warn_pre_alternatives(void);
+extern bool __static_cpu_has_safe(u16 bit);
 
 /*
  * Static testing of CPU features.  Used the same as boot_cpu_has().
@@ -437,11 +438,94 @@ static __always_inline __pure bool __static_cpu_has(u16 
bit)
__static_cpu_has(bit) : \
boot_cpu_has(bit)   \
 )
+
+static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
+{
+#if __GNUC__  4 || __GNUC_MINOR__ = 5
+/*
+ * We need to spell the jumps to the compiler because, depending on the offset,
+ * the replacement jump can be bigger than the original jump, and this we 
cannot
+ * have. Thus, we force the jump to the widest, 4-byte, signed relative
+ * offset even though the last would often fit in less bytes.
+ */
+   asm goto(1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n
+2:\n
+.section .altinstructions,\a\\n
+ .long 1b - .\n  /* src offset */
+ .long 3f - .\n  /* repl offset */
+ .word %P1\n /* always replace */
+ .byte 2b - 1b\n /* src len */
+ .byte 4f - 3f\n /* repl len */
+.previous\n
+.section .altinstr_replacement,\ax\\n
+3: .byte 0xe9\n .long %l[t_no] - 2b\n
+4:\n
+.previous\n
+.section .altinstructions,\a\\n
+ .long 1b - .\n  /* src offset */
+ .long 0\n   /* no replacement */
+ .word %P0\n /* feature bit */
+ .byte 2b - 1b\n /* src len */
+ .byte 0\n   /* repl len */
+.previous\n
+: : i (bit), i (X86_FEATURE_ALWAYS)
+: : t_dynamic, t_no);
+   return true;
+   t_no:
+   return false;
+   t_dynamic:
+   return __static_cpu_has_safe(bit);
+#else /* GCC_VERSION = 40500 */
+   u8 flag;
+   /* Open-coded due to __stringify() in ALTERNATIVE() */
+   asm volatile(1: movb $2,%0\n
+2:\n
+.section .altinstructions,\a\\n
+ .long 1b - .\n  /* src offset */
+ .long 3f - .\n  /* repl offset */
+ .word %P2\n /* always replace */
+ .byte 2b - 1b\n /* source len */
+ .byte 4f - 3f\n /* replacement len */
+.previous\n
+.section .discard,\aw\,@progbits\n
+ .byte 0xff + (4f-3f) - (2b-1b)\n /* size check 
*/
+.previous\n
+.section .altinstr_replacement,\ax\\n
+3: movb $0,%0\n
+4:\n
+.previous\n
+.section .altinstructions,\a\\n
+ .long 1b - .\n  /* src offset */
+ .long 5f - .\n  /* repl offset */
+ .word %P1\n /* feature bit */
+ .byte 4b - 3b\n /* src len */
+ .byte 6f - 5f\n /* repl len */
+.previous\n
+   

[tip:x86/microcode] x86, microcode, intel: Correct typo in printk

2013-05-30 Thread tip-bot for Borislav Petkov
Commit-ID:  83b325f1b4d00035494bc18a7a131b2197b3c718
Gitweb: http://git.kernel.org/tip/83b325f1b4d00035494bc18a7a131b2197b3c718
Author: Borislav Petkov 
AuthorDate: Thu, 30 May 2013 14:09:16 -0500
Committer:  H. Peter Anvin 
CommitDate: Thu, 30 May 2013 20:19:25 -0700

x86, microcode, intel: Correct typo in printk

User-visible so correct it.

Signed-off-by: Borislav Petkov 
Link: 
http://lkml.kernel.org/r/1369940959-2077-2-git-send-email-jacob.s...@amd.com
Signed-off-by: Jacob Shin 
Signed-off-by: H. Peter Anvin 
Cc: Fenghua Yu 
---
 arch/x86/kernel/microcode_intel_early.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/microcode_intel_early.c 
b/arch/x86/kernel/microcode_intel_early.c
index 2e9e128..a07f0a0 100644
--- a/arch/x86/kernel/microcode_intel_early.c
+++ b/arch/x86/kernel/microcode_intel_early.c
@@ -529,7 +529,7 @@ int save_mc_for_early(u8 *mc)
 */
ret = save_microcode(_saved_data, mc_saved_tmp, mc_saved_count);
if (ret) {
-   pr_err("Can not save microcode patch.\n");
+   pr_err("Cannot save microcode patch.\n");
goto out;
}
 
@@ -711,7 +711,7 @@ int __init save_microcode_in_initrd(void)
microcode_pointer(mc_saved, mc_saved_in_initrd, initrd_start, count);
ret = save_microcode(_saved_data, mc_saved, count);
if (ret)
-   pr_err("Can not save microcod patches from initrd");
+   pr_err("Cannot save microcode patches from initrd.\n");
 
show_saved_mc();
 
--
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/microcode] x86, microcode, intel: Correct typo in printk

2013-05-30 Thread tip-bot for Borislav Petkov
Commit-ID:  83b325f1b4d00035494bc18a7a131b2197b3c718
Gitweb: http://git.kernel.org/tip/83b325f1b4d00035494bc18a7a131b2197b3c718
Author: Borislav Petkov b...@suse.de
AuthorDate: Thu, 30 May 2013 14:09:16 -0500
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 30 May 2013 20:19:25 -0700

x86, microcode, intel: Correct typo in printk

User-visible so correct it.

Signed-off-by: Borislav Petkov b...@suse.de
Link: 
http://lkml.kernel.org/r/1369940959-2077-2-git-send-email-jacob.s...@amd.com
Signed-off-by: Jacob Shin jacob.s...@amd.com
Signed-off-by: H. Peter Anvin h...@linux.intel.com
Cc: Fenghua Yu fenghua...@intel.com
---
 arch/x86/kernel/microcode_intel_early.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/microcode_intel_early.c 
b/arch/x86/kernel/microcode_intel_early.c
index 2e9e128..a07f0a0 100644
--- a/arch/x86/kernel/microcode_intel_early.c
+++ b/arch/x86/kernel/microcode_intel_early.c
@@ -529,7 +529,7 @@ int save_mc_for_early(u8 *mc)
 */
ret = save_microcode(mc_saved_data, mc_saved_tmp, mc_saved_count);
if (ret) {
-   pr_err(Can not save microcode patch.\n);
+   pr_err(Cannot save microcode patch.\n);
goto out;
}
 
@@ -711,7 +711,7 @@ int __init save_microcode_in_initrd(void)
microcode_pointer(mc_saved, mc_saved_in_initrd, initrd_start, count);
ret = save_microcode(mc_saved_data, mc_saved, count);
if (ret)
-   pr_err(Can not save microcod patches from initrd);
+   pr_err(Cannot save microcode patches from initrd.\n);
 
show_saved_mc();
 
--
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/platform] x86, platform, kvm, kconfig: Turn existing .config's into KVM-capable configs

2013-05-28 Thread tip-bot for Borislav Petkov
Commit-ID:  46ff53874bd935ab9955dee56d60212857e89bf3
Gitweb: http://git.kernel.org/tip/46ff53874bd935ab9955dee56d60212857e89bf3
Author: Borislav Petkov 
AuthorDate: Wed, 22 May 2013 16:46:39 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 28 May 2013 12:11:32 +0200

x86, platform, kvm, kconfig: Turn existing .config's into KVM-capable configs

Add an config file snippet which enables additional options
useful for running the kernel in a kvm guest. When you execute
'make kvmconfig' it merges those options with an already
existing user config before you build the kernel.

Based on an patch from the external lkvm tree.

Signed-off-by: Borislav Petkov 
Acked-by: Pekka Enberg 
Cc: David Rientjes 
Cc: Michal Marek 
Cc: Randy Dunlap 
Cc: penb...@kernel.org
Cc: levinsasha...@gmail.com
Cc: mtosa...@redhat.com
Cc: fengguang...@intel.com
Link: http://lkml.kernel.org/r/20130522144638.gb15...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/Makefile |  6 ++
 arch/x86/configs/kvm_guest.config | 28 
 2 files changed, 34 insertions(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5c47726..91ee171 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -220,6 +220,11 @@ archclean:
$(Q)$(MAKE) $(clean)=$(boot)
$(Q)$(MAKE) $(clean)=arch/x86/tools
 
+kvmconfig:
+   $(if $(wildcard $(objtree)/.config),, $(error You need an existing 
.config for this target))
+   $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O 
$(objtree) $(objtree)/.config arch/x86/configs/kvm_guest.config
+   $(Q)yes "" | $(MAKE) oldconfig
+
 define archhelp
   echo  '* bzImage  - Compressed kernel image (arch/x86/boot/bzImage)'
   echo  '  install  - Install kernel using'
@@ -233,4 +238,5 @@ define archhelp
   echo  '  bzdisk/fdimage*/isoimage also accept:'
   echo  '  FDARGS="..."  arguments for the booted kernel'
   echo  '  FDINITRD=file initrd for the booted kernel'
+  echo  '  kvmconfig   - Enable additional options for guest kernel support'
 endef
diff --git a/arch/x86/configs/kvm_guest.config 
b/arch/x86/configs/kvm_guest.config
new file mode 100644
index 000..f9affcc
--- /dev/null
+++ b/arch/x86/configs/kvm_guest.config
@@ -0,0 +1,28 @@
+CONFIG_NET=y
+CONFIG_NET_CORE=y
+CONFIG_NETDEVICES=y
+CONFIG_BLOCK=y
+CONFIG_BLK_DEV=y
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_INET=y
+CONFIG_TTY=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_BINFMT_ELF=y
+CONFIG_PCI=y
+CONFIG_PCI_MSI=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_HYPERVISOR_GUEST=y
+CONFIG_PARAVIRT=y
+CONFIG_KVM_GUEST=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_VIRTIO_NET=y
+CONFIG_9P_FS=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
--
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/platform] x86, platform, kvm, kconfig: Turn existing .config's into KVM-capable configs

2013-05-28 Thread tip-bot for Borislav Petkov
Commit-ID:  46ff53874bd935ab9955dee56d60212857e89bf3
Gitweb: http://git.kernel.org/tip/46ff53874bd935ab9955dee56d60212857e89bf3
Author: Borislav Petkov b...@alien8.de
AuthorDate: Wed, 22 May 2013 16:46:39 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 28 May 2013 12:11:32 +0200

x86, platform, kvm, kconfig: Turn existing .config's into KVM-capable configs

Add an config file snippet which enables additional options
useful for running the kernel in a kvm guest. When you execute
'make kvmconfig' it merges those options with an already
existing user config before you build the kernel.

Based on an patch from the external lkvm tree.

Signed-off-by: Borislav Petkov b...@suse.de
Acked-by: Pekka Enberg penb...@kernel.org
Cc: David Rientjes rient...@google.com
Cc: Michal Marek mma...@suse.cz
Cc: Randy Dunlap rdun...@infradead.org
Cc: penb...@kernel.org
Cc: levinsasha...@gmail.com
Cc: mtosa...@redhat.com
Cc: fengguang...@intel.com
Link: http://lkml.kernel.org/r/20130522144638.gb15...@pd.tnic
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Makefile |  6 ++
 arch/x86/configs/kvm_guest.config | 28 
 2 files changed, 34 insertions(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5c47726..91ee171 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -220,6 +220,11 @@ archclean:
$(Q)$(MAKE) $(clean)=$(boot)
$(Q)$(MAKE) $(clean)=arch/x86/tools
 
+kvmconfig:
+   $(if $(wildcard $(objtree)/.config),, $(error You need an existing 
.config for this target))
+   $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O 
$(objtree) $(objtree)/.config arch/x86/configs/kvm_guest.config
+   $(Q)yes  | $(MAKE) oldconfig
+
 define archhelp
   echo  '* bzImage  - Compressed kernel image (arch/x86/boot/bzImage)'
   echo  '  install  - Install kernel using'
@@ -233,4 +238,5 @@ define archhelp
   echo  '  bzdisk/fdimage*/isoimage also accept:'
   echo  '  FDARGS=...  arguments for the booted kernel'
   echo  '  FDINITRD=file initrd for the booted kernel'
+  echo  '  kvmconfig   - Enable additional options for guest kernel support'
 endef
diff --git a/arch/x86/configs/kvm_guest.config 
b/arch/x86/configs/kvm_guest.config
new file mode 100644
index 000..f9affcc
--- /dev/null
+++ b/arch/x86/configs/kvm_guest.config
@@ -0,0 +1,28 @@
+CONFIG_NET=y
+CONFIG_NET_CORE=y
+CONFIG_NETDEVICES=y
+CONFIG_BLOCK=y
+CONFIG_BLK_DEV=y
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_INET=y
+CONFIG_TTY=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_BINFMT_ELF=y
+CONFIG_PCI=y
+CONFIG_PCI_MSI=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_HYPERVISOR_GUEST=y
+CONFIG_PARAVIRT=y
+CONFIG_KVM_GUEST=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_VIRTIO_NET=y
+CONFIG_9P_FS=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
--
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: Extend #DF debugging aid to 64-bit

2013-05-13 Thread tip-bot for Borislav Petkov
Commit-ID:  4d067d8e056d76a3327f0517c7722db55e7888fc
Gitweb: http://git.kernel.org/tip/4d067d8e056d76a3327f0517c7722db55e7888fc
Author: Borislav Petkov 
AuthorDate: Thu, 9 May 2013 12:02:29 +0200
Committer:  H. Peter Anvin 
CommitDate: Mon, 13 May 2013 13:42:44 -0700

x86: Extend #DF debugging aid to 64-bit

It is sometimes very helpful to be able to pinpoint the location which
causes a double fault before it turns into a triple fault and the
machine reboots. We have this for 32-bit already so extend it to 64-bit.
On 64-bit we get the register snapshot at #DF time and not from the
first exception which actually causes the #DF. It should be close
enough, though.

[ hpa: and definitely better than nothing, which is what we have now. ]

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1368093749-31296-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/Kconfig.debug  |  1 -
 arch/x86/include/asm/processor.h|  2 +-
 arch/x86/kernel/Makefile|  2 +-
 arch/x86/kernel/{doublefault_32.c => doublefault.c} | 15 +++
 arch/x86/kernel/traps.c |  3 +++
 5 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index c198b7e..b6a7701 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -122,7 +122,6 @@ config DEBUG_NX_TEST
 config DOUBLEFAULT
default y
bool "Enable doublefault exception handler" if EXPERT
-   depends on X86_32
---help---
  This option allows trapping of rare doublefault exceptions that
  would otherwise cause a system to silently reboot. Disabling this
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4b3..5b87d52 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -981,5 +981,5 @@ bool xen_set_default_idle(void);
 #endif
 
 void stop_this_cpu(void *dummy);
-
+void df_debug(struct pt_regs *regs, long error_code);
 #endif /* _ASM_X86_PROCESSOR_H */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 7bd3bd3..4ce822e 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -67,7 +67,7 @@ obj-$(CONFIG_KEXEC)   += relocate_kernel_$(BITS).o 
crash.o
 obj-$(CONFIG_CRASH_DUMP)   += crash_dump_$(BITS).o
 obj-y  += kprobes/
 obj-$(CONFIG_MODULES)  += module.o
-obj-$(CONFIG_DOUBLEFAULT)  += doublefault_32.o
+obj-$(CONFIG_DOUBLEFAULT)  += doublefault.o
 obj-$(CONFIG_KGDB) += kgdb.o
 obj-$(CONFIG_VM86) += vm86_32.o
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault.c
similarity index 84%
rename from arch/x86/kernel/doublefault_32.c
rename to arch/x86/kernel/doublefault.c
index 155a13f..5d3fe8d 100644
--- a/arch/x86/kernel/doublefault_32.c
+++ b/arch/x86/kernel/doublefault.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 
+#ifdef CONFIG_X86_32
+
 #define DOUBLEFAULT_STACKSIZE (1024)
 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
 #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
@@ -67,3 +69,16 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
.__cr3  = __pa_nodebug(swapper_pg_dir),
}
 };
+
+/* dummy for do_double_fault() call */
+void df_debug(struct pt_regs *regs, long error_code) {}
+
+#else /* !CONFIG_X86_32 */
+
+void df_debug(struct pt_regs *regs, long error_code)
+{
+   pr_emerg("PANIC: double fault, error_code: 0x%lx\n", error_code);
+   show_regs(regs);
+   panic("Machine halted.");
+}
+#endif
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 772e2a8..167d481 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -254,6 +254,9 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, 
long error_code)
tsk->thread.error_code = error_code;
tsk->thread.trap_nr = X86_TRAP_DF;
 
+#ifdef CONFIG_DOUBLEFAULT
+   df_debug(regs, error_code);
+#endif
/*
 * This is always a kernel trap and never fixable (and thus must
 * never return).
--
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: Extend #DF debugging aid to 64-bit

2013-05-13 Thread tip-bot for Borislav Petkov
Commit-ID:  4d067d8e056d76a3327f0517c7722db55e7888fc
Gitweb: http://git.kernel.org/tip/4d067d8e056d76a3327f0517c7722db55e7888fc
Author: Borislav Petkov b...@suse.de
AuthorDate: Thu, 9 May 2013 12:02:29 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Mon, 13 May 2013 13:42:44 -0700

x86: Extend #DF debugging aid to 64-bit

It is sometimes very helpful to be able to pinpoint the location which
causes a double fault before it turns into a triple fault and the
machine reboots. We have this for 32-bit already so extend it to 64-bit.
On 64-bit we get the register snapshot at #DF time and not from the
first exception which actually causes the #DF. It should be close
enough, though.

[ hpa: and definitely better than nothing, which is what we have now. ]

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/1368093749-31296-1-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/Kconfig.debug  |  1 -
 arch/x86/include/asm/processor.h|  2 +-
 arch/x86/kernel/Makefile|  2 +-
 arch/x86/kernel/{doublefault_32.c = doublefault.c} | 15 +++
 arch/x86/kernel/traps.c |  3 +++
 5 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index c198b7e..b6a7701 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -122,7 +122,6 @@ config DEBUG_NX_TEST
 config DOUBLEFAULT
default y
bool Enable doublefault exception handler if EXPERT
-   depends on X86_32
---help---
  This option allows trapping of rare doublefault exceptions that
  would otherwise cause a system to silently reboot. Disabling this
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4b3..5b87d52 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -981,5 +981,5 @@ bool xen_set_default_idle(void);
 #endif
 
 void stop_this_cpu(void *dummy);
-
+void df_debug(struct pt_regs *regs, long error_code);
 #endif /* _ASM_X86_PROCESSOR_H */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 7bd3bd3..4ce822e 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -67,7 +67,7 @@ obj-$(CONFIG_KEXEC)   += relocate_kernel_$(BITS).o 
crash.o
 obj-$(CONFIG_CRASH_DUMP)   += crash_dump_$(BITS).o
 obj-y  += kprobes/
 obj-$(CONFIG_MODULES)  += module.o
-obj-$(CONFIG_DOUBLEFAULT)  += doublefault_32.o
+obj-$(CONFIG_DOUBLEFAULT)  += doublefault.o
 obj-$(CONFIG_KGDB) += kgdb.o
 obj-$(CONFIG_VM86) += vm86_32.o
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault.c
similarity index 84%
rename from arch/x86/kernel/doublefault_32.c
rename to arch/x86/kernel/doublefault.c
index 155a13f..5d3fe8d 100644
--- a/arch/x86/kernel/doublefault_32.c
+++ b/arch/x86/kernel/doublefault.c
@@ -9,6 +9,8 @@
 #include asm/processor.h
 #include asm/desc.h
 
+#ifdef CONFIG_X86_32
+
 #define DOUBLEFAULT_STACKSIZE (1024)
 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
 #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
@@ -67,3 +69,16 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
.__cr3  = __pa_nodebug(swapper_pg_dir),
}
 };
+
+/* dummy for do_double_fault() call */
+void df_debug(struct pt_regs *regs, long error_code) {}
+
+#else /* !CONFIG_X86_32 */
+
+void df_debug(struct pt_regs *regs, long error_code)
+{
+   pr_emerg(PANIC: double fault, error_code: 0x%lx\n, error_code);
+   show_regs(regs);
+   panic(Machine halted.);
+}
+#endif
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 772e2a8..167d481 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -254,6 +254,9 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, 
long error_code)
tsk-thread.error_code = error_code;
tsk-thread.trap_nr = X86_TRAP_DF;
 
+#ifdef CONFIG_DOUBLEFAULT
+   df_debug(regs, error_code);
+#endif
/*
 * This is always a kernel trap and never fixable (and thus must
 * never return).
--
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/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

2013-05-02 Thread tip-bot for Borislav Petkov
Commit-ID:  7e0320e733eec67e40d2b53e438d9971f079862d
Gitweb: http://git.kernel.org/tip/7e0320e733eec67e40d2b53e438d9971f079862d
Author: Borislav Petkov 
AuthorDate: Fri, 26 Apr 2013 11:51:40 +0200
Committer:  H. Peter Anvin 
CommitDate: Thu, 2 May 2013 10:13:07 -0700

x86/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

This is pretty useful for the case where people want to boot the
resulting kernel in qemu/kvm or lkvm. Instead of going and
searching for each required option through the Kconfig maze,
this single option should simply enable everything required/good
to have to boot the resulting kernel in the guest.

Patch has been adapted from a version in the external lkvm tree.

[ hpa: rebased to resolve a merge conflict ]

Originally-by: Pekka Enberg 
Originally-by: Sasha Levin 
Signed-off-by: Borislav Petkov 
Cc: Marcelo Tosatti 
Cc: Pekka Enberg 
Cc: Sasha Levin 
Cc: Fengguang Wu 
Link: http://lkml.kernel.org/r/20130426095140.ga15...@pd.tnic
Signed-off-by: Ingo Molnar 
Signed-off-by: H. Peter Anvin 
---
 arch/x86/Kconfig | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5db2117..f724671f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -649,6 +649,45 @@ config KVM_GUEST
  underlying device model, the host provides the guest with
  timing infrastructure such as time of day, and system time
 
+config KVM_GUEST_COMMON_OPTIONS
+   bool "Enable commodity options for a standalone KVM guest"
+   depends on KVM_GUEST
+   select NET
+   select NETDEVICES
+   select BLOCK
+   select BLK_DEV
+   select NETWORK_FILESYSTEMS
+   select INET
+   select EXPERIMENTAL
+   select TTY
+   select SERIAL_8250
+   select SERIAL_8250_CONSOLE
+   select IP_PNP
+   select IP_PNP_DHCP
+   select BINFMT_ELF
+   select PCI_MSI
+   select HAVE_ARCH_KGDB
+   select DEBUG_KERNEL
+   select KGDB
+   select KGDB_SERIAL_CONSOLE
+   select VIRTUALIZATION
+   select VIRTIO
+   select VIRTIO_RING
+   select VIRTIO_PCI
+   select VIRTIO_BLK
+   select VIRTIO_CONSOLE
+   select VIRTIO_NET
+   select 9P_FS
+   select NET_9P
+   select NET_9P_VIRTIO
+   ---help---
+ Select guest kernel functionality which facilitates booting the
+ kernel as a guest in qemu or lkvm. This entails basic stuff like
+ serial support, kgdb, virtio and other so that you can be able to
+ have commodity functionality like serial output from the guest,
+ networking, seamless host file system integration into guest context
+ and other useful things.
+
 source "arch/x86/lguest/Kconfig"
 
 config PARAVIRT_TIME_ACCOUNTING
--
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/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

2013-05-02 Thread tip-bot for Borislav Petkov
Commit-ID:  7e0320e733eec67e40d2b53e438d9971f079862d
Gitweb: http://git.kernel.org/tip/7e0320e733eec67e40d2b53e438d9971f079862d
Author: Borislav Petkov b...@alien8.de
AuthorDate: Fri, 26 Apr 2013 11:51:40 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 2 May 2013 10:13:07 -0700

x86/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

This is pretty useful for the case where people want to boot the
resulting kernel in qemu/kvm or lkvm. Instead of going and
searching for each required option through the Kconfig maze,
this single option should simply enable everything required/good
to have to boot the resulting kernel in the guest.

Patch has been adapted from a version in the external lkvm tree.

[ hpa: rebased to resolve a merge conflict ]

Originally-by: Pekka Enberg penb...@kernel.org
Originally-by: Sasha Levin levinsasha...@gmail.com
Signed-off-by: Borislav Petkov b...@suse.de
Cc: Marcelo Tosatti mtosa...@redhat.com
Cc: Pekka Enberg penb...@kernel.org
Cc: Sasha Levin levinsasha...@gmail.com
Cc: Fengguang Wu fengguang...@intel.com
Link: http://lkml.kernel.org/r/20130426095140.ga15...@pd.tnic
Signed-off-by: Ingo Molnar mi...@kernel.org
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 arch/x86/Kconfig | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5db2117..f724671f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -649,6 +649,45 @@ config KVM_GUEST
  underlying device model, the host provides the guest with
  timing infrastructure such as time of day, and system time
 
+config KVM_GUEST_COMMON_OPTIONS
+   bool Enable commodity options for a standalone KVM guest
+   depends on KVM_GUEST
+   select NET
+   select NETDEVICES
+   select BLOCK
+   select BLK_DEV
+   select NETWORK_FILESYSTEMS
+   select INET
+   select EXPERIMENTAL
+   select TTY
+   select SERIAL_8250
+   select SERIAL_8250_CONSOLE
+   select IP_PNP
+   select IP_PNP_DHCP
+   select BINFMT_ELF
+   select PCI_MSI
+   select HAVE_ARCH_KGDB
+   select DEBUG_KERNEL
+   select KGDB
+   select KGDB_SERIAL_CONSOLE
+   select VIRTUALIZATION
+   select VIRTIO
+   select VIRTIO_RING
+   select VIRTIO_PCI
+   select VIRTIO_BLK
+   select VIRTIO_CONSOLE
+   select VIRTIO_NET
+   select 9P_FS
+   select NET_9P
+   select NET_9P_VIRTIO
+   ---help---
+ Select guest kernel functionality which facilitates booting the
+ kernel as a guest in qemu or lkvm. This entails basic stuff like
+ serial support, kgdb, virtio and other so that you can be able to
+ have commodity functionality like serial output from the guest,
+ networking, seamless host file system integration into guest context
+ and other useful things.
+
 source arch/x86/lguest/Kconfig
 
 config PARAVIRT_TIME_ACCOUNTING
--
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/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

2013-04-30 Thread tip-bot for Borislav Petkov
Commit-ID:  83aee67833071c7b73a83f7803388f7a9e481908
Gitweb: http://git.kernel.org/tip/83aee67833071c7b73a83f7803388f7a9e481908
Author: Borislav Petkov 
AuthorDate: Fri, 26 Apr 2013 11:51:40 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 30 Apr 2013 11:00:11 +0200

x86/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

This is pretty useful for the case where people want to boot the
resulting kernel in qemu/kvm or lkvm. Instead of going and
searching for each required option through the Kconfig maze,
this single option should simply enable everything required/good
to have to boot the resulting kernel in the guest.

Patch has been adapted from a version in the external lkvm tree.

Originally-by: Pekka Enberg 
Originally-by: Sasha Levin 
Signed-off-by: Borislav Petkov 
Cc: Marcelo Tosatti 
Cc: Pekka Enberg 
Cc: Sasha Levin 
Cc: Fengguang Wu 
Link: http://lkml.kernel.org/r/20130426095140.ga15...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 15b5cef..1d053dc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -633,6 +633,45 @@ config KVM_GUEST
  underlying device model, the host provides the guest with
  timing infrastructure such as time of day, and system time
 
+config KVM_GUEST_COMMON_OPTIONS
+   bool "Enable commodity options for a standalone KVM guest"
+   depends on KVM_GUEST
+   select NET
+   select NETDEVICES
+   select BLOCK
+   select BLK_DEV
+   select NETWORK_FILESYSTEMS
+   select INET
+   select EXPERIMENTAL
+   select TTY
+   select SERIAL_8250
+   select SERIAL_8250_CONSOLE
+   select IP_PNP
+   select IP_PNP_DHCP
+   select BINFMT_ELF
+   select PCI_MSI
+   select HAVE_ARCH_KGDB
+   select DEBUG_KERNEL
+   select KGDB
+   select KGDB_SERIAL_CONSOLE
+   select VIRTUALIZATION
+   select VIRTIO
+   select VIRTIO_RING
+   select VIRTIO_PCI
+   select VIRTIO_BLK
+   select VIRTIO_CONSOLE
+   select VIRTIO_NET
+   select 9P_FS
+   select NET_9P
+   select NET_9P_VIRTIO
+   ---help---
+ Select guest kernel functionality which facilitates booting the
+ kernel as a guest in qemu or lkvm. This entails basic stuff like
+ serial support, kgdb, virtio and other so that you can be able to
+ have commodity functionality like serial output from the guest,
+ networking, seamless host file system integration into guest context
+ and other useful things.
+
 source "arch/x86/lguest/Kconfig"
 
 config PARAVIRT
--
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/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

2013-04-30 Thread tip-bot for Borislav Petkov
Commit-ID:  83aee67833071c7b73a83f7803388f7a9e481908
Gitweb: http://git.kernel.org/tip/83aee67833071c7b73a83f7803388f7a9e481908
Author: Borislav Petkov b...@alien8.de
AuthorDate: Fri, 26 Apr 2013 11:51:40 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Tue, 30 Apr 2013 11:00:11 +0200

x86/kconfig: Add a Kconfig shortcut for building working KVM guest kernels

This is pretty useful for the case where people want to boot the
resulting kernel in qemu/kvm or lkvm. Instead of going and
searching for each required option through the Kconfig maze,
this single option should simply enable everything required/good
to have to boot the resulting kernel in the guest.

Patch has been adapted from a version in the external lkvm tree.

Originally-by: Pekka Enberg penb...@kernel.org
Originally-by: Sasha Levin levinsasha...@gmail.com
Signed-off-by: Borislav Petkov b...@suse.de
Cc: Marcelo Tosatti mtosa...@redhat.com
Cc: Pekka Enberg penb...@kernel.org
Cc: Sasha Levin levinsasha...@gmail.com
Cc: Fengguang Wu fengguang...@intel.com
Link: http://lkml.kernel.org/r/20130426095140.ga15...@pd.tnic
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/Kconfig | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 15b5cef..1d053dc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -633,6 +633,45 @@ config KVM_GUEST
  underlying device model, the host provides the guest with
  timing infrastructure such as time of day, and system time
 
+config KVM_GUEST_COMMON_OPTIONS
+   bool Enable commodity options for a standalone KVM guest
+   depends on KVM_GUEST
+   select NET
+   select NETDEVICES
+   select BLOCK
+   select BLK_DEV
+   select NETWORK_FILESYSTEMS
+   select INET
+   select EXPERIMENTAL
+   select TTY
+   select SERIAL_8250
+   select SERIAL_8250_CONSOLE
+   select IP_PNP
+   select IP_PNP_DHCP
+   select BINFMT_ELF
+   select PCI_MSI
+   select HAVE_ARCH_KGDB
+   select DEBUG_KERNEL
+   select KGDB
+   select KGDB_SERIAL_CONSOLE
+   select VIRTUALIZATION
+   select VIRTIO
+   select VIRTIO_RING
+   select VIRTIO_PCI
+   select VIRTIO_BLK
+   select VIRTIO_CONSOLE
+   select VIRTIO_NET
+   select 9P_FS
+   select NET_9P
+   select NET_9P_VIRTIO
+   ---help---
+ Select guest kernel functionality which facilitates booting the
+ kernel as a guest in qemu or lkvm. This entails basic stuff like
+ serial support, kgdb, virtio and other so that you can be able to
+ have commodity functionality like serial output from the guest,
+ networking, seamless host file system integration into guest context
+ and other useful things.
+
 source arch/x86/lguest/Kconfig
 
 config PARAVIRT
--
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, CPU, AMD: Drop useless label

2013-04-16 Thread tip-bot for Borislav Petkov
Commit-ID:  1077c932db63ecc571c31df1c24d4a44e30928e5
Gitweb: http://git.kernel.org/tip/1077c932db63ecc571c31df1c24d4a44e30928e5
Author: Borislav Petkov 
AuthorDate: Mon, 8 Apr 2013 17:57:46 +0200
Committer:  Borislav Petkov 
CommitDate: Tue, 16 Apr 2013 11:50:51 +0200

x86, CPU, AMD: Drop useless label

All we want to do is return from this function so stop jumping around
like a flea for no good reason.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/136543-9837-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/amd.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index cea02d7..5013a48 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -192,11 +192,11 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
/* Athlon 660/661 is valid. */
if ((c->x86_model == 6) && ((c->x86_mask == 0) ||
(c->x86_mask == 1)))
-   goto valid_k7;
+   return;
 
/* Duron 670 is valid */
if ((c->x86_model == 7) && (c->x86_mask == 0))
-   goto valid_k7;
+   return;
 
/*
 * Athlon 662, Duron 671, and Athlon >model 7 have capability
@@ -209,7 +209,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
((c->x86_model == 7) && (c->x86_mask >= 1)) ||
 (c->x86_model > 7))
if (cpu_has_mp)
-   goto valid_k7;
+   return;
 
/* If we get here, not a certified SMP capable AMD system. */
 
@@ -220,9 +220,6 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
WARN_ONCE(1, "WARNING: This combination of AMD"
" processors is not suitable for SMP.\n");
add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE);
-
-valid_k7:
-   ;
 }
 
 static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
--
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, AMD: Correct {rd,wr}msr_amd_safe warnings

2013-04-16 Thread tip-bot for Borislav Petkov
Commit-ID:  682469a5db6fade318a72406935b5000186e5643
Gitweb: http://git.kernel.org/tip/682469a5db6fade318a72406935b5000186e5643
Author: Borislav Petkov 
AuthorDate: Mon, 8 Apr 2013 17:57:45 +0200
Committer:  Borislav Petkov 
CommitDate: Tue, 16 Apr 2013 11:50:51 +0200

x86, AMD: Correct {rd,wr}msr_amd_safe warnings

The idea with those routines is to slowly phase them out and not call
them on anything else besides K8. They even have a check for that which,
when called too early, fails. Let me explain:

It gets the cpuinfo_x86 pointer from the per_cpu array and when this
happens for cpu0, before its boot_cpu_data has been copied back to the
per_cpu array in smp_store_boot_cpu_info(), we get an empty struct and
thus the check fails.

Use boot_cpu_data directly instead.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/136543-9837-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/amd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9a2a716..cea02d7 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -20,11 +20,11 @@
 
 static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
 {
-   struct cpuinfo_x86 *c = _data(smp_processor_id());
u32 gprs[8] = { 0 };
int err;
 
-   WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ "%s should only be used on K8!\n", __func__);
 
gprs[1] = msr;
gprs[7] = 0x9c5a203a;
@@ -38,10 +38,10 @@ static inline int rdmsrl_amd_safe(unsigned msr, unsigned 
long long *p)
 
 static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
 {
-   struct cpuinfo_x86 *c = _data(smp_processor_id());
u32 gprs[8] = { 0 };
 
-   WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ "%s should only be used on K8!\n", __func__);
 
gprs[0] = (u32)val;
gprs[1] = msr;
--
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: Fold-in trivial check_config function

2013-04-16 Thread tip-bot for Borislav Petkov
Commit-ID:  55a36b65ee7107d6bb557c96fd202c4e90164542
Gitweb: http://git.kernel.org/tip/55a36b65ee7107d6bb557c96fd202c4e90164542
Author: Borislav Petkov 
AuthorDate: Mon, 8 Apr 2013 17:57:44 +0200
Committer:  Borislav Petkov 
CommitDate: Tue, 16 Apr 2013 11:50:50 +0200

x86: Fold-in trivial check_config function

Fold it into its single call site. No functionality change.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/136543-9837-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/bugs.c | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index c59635e..4112be9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -81,21 +81,6 @@ static void __init check_fpu(void)
}
 }
 
-/*
- * Check whether we are able to run this kernel safely on SMP.
- *
- * - i386 is no longer supported.
- * - In order to run on anything without a TSC, we need to be
- *   compiled for a i486.
- */
-
-static void __init check_config(void)
-{
-   if (boot_cpu_data.x86 < 4)
-   panic("Kernel requires i486+ for 'invlpg' and other features");
-}
-
-
 void __init check_bugs(void)
 {
identify_boot_cpu();
@@ -103,7 +88,17 @@ void __init check_bugs(void)
pr_info("CPU: ");
print_cpu_info(_cpu_data);
 #endif
-   check_config();
+
+   /*
+* Check whether we are able to run this kernel safely on SMP.
+*
+* - i386 is no longer supported.
+* - In order to run on anything without a TSC, we need to be
+*   compiled for a i486.
+*/
+   if (boot_cpu_data.x86 < 4)
+   panic("Kernel requires i486+ for 'invlpg' and other features");
+
init_utsname()->machine[1] =
'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
alternative_instructions();
--
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: Fold-in trivial check_config function

2013-04-16 Thread tip-bot for Borislav Petkov
Commit-ID:  55a36b65ee7107d6bb557c96fd202c4e90164542
Gitweb: http://git.kernel.org/tip/55a36b65ee7107d6bb557c96fd202c4e90164542
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 8 Apr 2013 17:57:44 +0200
Committer:  Borislav Petkov b...@suse.de
CommitDate: Tue, 16 Apr 2013 11:50:50 +0200

x86: Fold-in trivial check_config function

Fold it into its single call site. No functionality change.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/136543-9837-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/bugs.c | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index c59635e..4112be9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -81,21 +81,6 @@ static void __init check_fpu(void)
}
 }
 
-/*
- * Check whether we are able to run this kernel safely on SMP.
- *
- * - i386 is no longer supported.
- * - In order to run on anything without a TSC, we need to be
- *   compiled for a i486.
- */
-
-static void __init check_config(void)
-{
-   if (boot_cpu_data.x86  4)
-   panic(Kernel requires i486+ for 'invlpg' and other features);
-}
-
-
 void __init check_bugs(void)
 {
identify_boot_cpu();
@@ -103,7 +88,17 @@ void __init check_bugs(void)
pr_info(CPU: );
print_cpu_info(boot_cpu_data);
 #endif
-   check_config();
+
+   /*
+* Check whether we are able to run this kernel safely on SMP.
+*
+* - i386 is no longer supported.
+* - In order to run on anything without a TSC, we need to be
+*   compiled for a i486.
+*/
+   if (boot_cpu_data.x86  4)
+   panic(Kernel requires i486+ for 'invlpg' and other features);
+
init_utsname()-machine[1] =
'0' + (boot_cpu_data.x86  6 ? 6 : boot_cpu_data.x86);
alternative_instructions();
--
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, AMD: Correct {rd,wr}msr_amd_safe warnings

2013-04-16 Thread tip-bot for Borislav Petkov
Commit-ID:  682469a5db6fade318a72406935b5000186e5643
Gitweb: http://git.kernel.org/tip/682469a5db6fade318a72406935b5000186e5643
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 8 Apr 2013 17:57:45 +0200
Committer:  Borislav Petkov b...@suse.de
CommitDate: Tue, 16 Apr 2013 11:50:51 +0200

x86, AMD: Correct {rd,wr}msr_amd_safe warnings

The idea with those routines is to slowly phase them out and not call
them on anything else besides K8. They even have a check for that which,
when called too early, fails. Let me explain:

It gets the cpuinfo_x86 pointer from the per_cpu array and when this
happens for cpu0, before its boot_cpu_data has been copied back to the
per_cpu array in smp_store_boot_cpu_info(), we get an empty struct and
thus the check fails.

Use boot_cpu_data directly instead.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/136543-9837-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/amd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9a2a716..cea02d7 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -20,11 +20,11 @@
 
 static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
 {
-   struct cpuinfo_x86 *c = cpu_data(smp_processor_id());
u32 gprs[8] = { 0 };
int err;
 
-   WARN_ONCE((c-x86 != 0xf), %s should only be used on K8!\n, __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ %s should only be used on K8!\n, __func__);
 
gprs[1] = msr;
gprs[7] = 0x9c5a203a;
@@ -38,10 +38,10 @@ static inline int rdmsrl_amd_safe(unsigned msr, unsigned 
long long *p)
 
 static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
 {
-   struct cpuinfo_x86 *c = cpu_data(smp_processor_id());
u32 gprs[8] = { 0 };
 
-   WARN_ONCE((c-x86 != 0xf), %s should only be used on K8!\n, __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ %s should only be used on K8!\n, __func__);
 
gprs[0] = (u32)val;
gprs[1] = msr;
--
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, CPU, AMD: Drop useless label

2013-04-16 Thread tip-bot for Borislav Petkov
Commit-ID:  1077c932db63ecc571c31df1c24d4a44e30928e5
Gitweb: http://git.kernel.org/tip/1077c932db63ecc571c31df1c24d4a44e30928e5
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 8 Apr 2013 17:57:46 +0200
Committer:  Borislav Petkov b...@suse.de
CommitDate: Tue, 16 Apr 2013 11:50:51 +0200

x86, CPU, AMD: Drop useless label

All we want to do is return from this function so stop jumping around
like a flea for no good reason.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/136543-9837-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/amd.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index cea02d7..5013a48 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -192,11 +192,11 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
/* Athlon 660/661 is valid. */
if ((c-x86_model == 6)  ((c-x86_mask == 0) ||
(c-x86_mask == 1)))
-   goto valid_k7;
+   return;
 
/* Duron 670 is valid */
if ((c-x86_model == 7)  (c-x86_mask == 0))
-   goto valid_k7;
+   return;
 
/*
 * Athlon 662, Duron 671, and Athlon model 7 have capability
@@ -209,7 +209,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
((c-x86_model == 7)  (c-x86_mask = 1)) ||
 (c-x86_model  7))
if (cpu_has_mp)
-   goto valid_k7;
+   return;
 
/* If we get here, not a certified SMP capable AMD system. */
 
@@ -220,9 +220,6 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
WARN_ONCE(1, WARNING: This combination of AMD
 processors is not suitable for SMP.\n);
add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE);
-
-valid_k7:
-   ;
 }
 
 static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
--
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/asm] extable: Flip the sorting message

2013-04-15 Thread tip-bot for Borislav Petkov
Commit-ID:  bec1b9e76353ecf05fac6a87f8e4102dfb618cd2
Gitweb: http://git.kernel.org/tip/bec1b9e76353ecf05fac6a87f8e4102dfb618cd2
Author: Borislav Petkov 
AuthorDate: Mon, 15 Apr 2013 12:51:49 +0200
Committer:  Ingo Molnar 
CommitDate: Mon, 15 Apr 2013 13:25:16 +0200

extable: Flip the sorting message

Now that we do sort the __extable at build time, we actually are
interested only in the case where we still do need to sort it.

Signed-off-by: Borislav Petkov 
Cc: David Daney 
Link: http://lkml.kernel.org/r/1366023109-12098-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 kernel/extable.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index fe35a63..67460b9 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -41,10 +41,10 @@ u32 __initdata main_extable_sort_needed = 1;
 /* Sort the kernel's built-in exception table */
 void __init sort_main_extable(void)
 {
-   if (main_extable_sort_needed)
+   if (main_extable_sort_needed) {
+   pr_notice("Sorting __ex_table...\n");
sort_extable(__start___ex_table, __stop___ex_table);
-   else
-   pr_notice("__ex_table already sorted, skipping sort\n");
+   }
 }
 
 /* Given an address, look for it in the exception tables. */
--
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/asm] extable: Flip the sorting message

2013-04-15 Thread tip-bot for Borislav Petkov
Commit-ID:  bec1b9e76353ecf05fac6a87f8e4102dfb618cd2
Gitweb: http://git.kernel.org/tip/bec1b9e76353ecf05fac6a87f8e4102dfb618cd2
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 15 Apr 2013 12:51:49 +0200
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Mon, 15 Apr 2013 13:25:16 +0200

extable: Flip the sorting message

Now that we do sort the __extable at build time, we actually are
interested only in the case where we still do need to sort it.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: David Daney david.da...@cavium.com
Link: http://lkml.kernel.org/r/1366023109-12098-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 kernel/extable.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index fe35a63..67460b9 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -41,10 +41,10 @@ u32 __initdata main_extable_sort_needed = 1;
 /* Sort the kernel's built-in exception table */
 void __init sort_main_extable(void)
 {
-   if (main_extable_sort_needed)
+   if (main_extable_sort_needed) {
+   pr_notice(Sorting __ex_table...\n);
sort_extable(__start___ex_table, __stop___ex_table);
-   else
-   pr_notice(__ex_table already sorted, skipping sort\n);
+   }
 }
 
 /* Given an address, look for it in the exception tables. */
--
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/mm] x86/mm/cpa: Cleanup split_large_page() and its callee

2013-04-10 Thread tip-bot for Borislav Petkov
Commit-ID:  5952886bfeec065041d04dfcc2693b581e8f2424
Gitweb: http://git.kernel.org/tip/5952886bfeec065041d04dfcc2693b581e8f2424
Author: Borislav Petkov 
AuthorDate: Thu, 21 Mar 2013 18:16:57 +0100
Committer:  Ingo Molnar 
CommitDate: Wed, 10 Apr 2013 14:39:08 +0200

x86/mm/cpa: Cleanup split_large_page() and its callee

So basically we're generating the pte_t * from a struct page and
we're handing it down to the __split_large_page() internal version
which then goes and gets back struct page * from it because it
needs it.

Change the caller to hand down struct page * directly and the
callee can compute the pte_t itself.

Net save is one virt_to_page() call and simpler code. While at
it, make __split_large_page() static.

Signed-off-by: Borislav Petkov 
Acked-by: Thomas Gleixner 
Link: http://lkml.kernel.org/r/1363886217-24703-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/pgtable_types.h | 1 -
 arch/x86/mm/pageattr.c   | 9 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index 567b5d0..e642300 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -351,7 +351,6 @@ static inline void update_page_count(int level, unsigned 
long pages) { }
  * as a pte too.
  */
 extern pte_t *lookup_address(unsigned long address, unsigned int *level);
-extern int __split_large_page(pte_t *kpte, unsigned long address, pte_t 
*pbase);
 extern phys_addr_t slow_virt_to_phys(void *__address);
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 091934e..25b1d35 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -542,13 +542,14 @@ out_unlock:
return do_split;
 }
 
-int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
+static int
+__split_large_page(pte_t *kpte, unsigned long address, struct page *base)
 {
+   pte_t *pbase = (pte_t *)page_address(base);
unsigned long pfn, pfninc = 1;
unsigned int i, level;
pte_t *tmp;
pgprot_t ref_prot;
-   struct page *base = virt_to_page(pbase);
 
spin_lock(_lock);
/*
@@ -633,7 +634,6 @@ int __split_large_page(pte_t *kpte, unsigned long address, 
pte_t *pbase)
 
 static int split_large_page(pte_t *kpte, unsigned long address)
 {
-   pte_t *pbase;
struct page *base;
 
if (!debug_pagealloc)
@@ -644,8 +644,7 @@ static int split_large_page(pte_t *kpte, unsigned long 
address)
if (!base)
return -ENOMEM;
 
-   pbase = (pte_t *)page_address(base);
-   if (__split_large_page(kpte, address, pbase))
+   if (__split_large_page(kpte, address, base))
__free_page(base);
 
return 0;
--
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/mm] x86/mm/cpa: Cleanup split_large_page() and its callee

2013-04-10 Thread tip-bot for Borislav Petkov
Commit-ID:  5952886bfeec065041d04dfcc2693b581e8f2424
Gitweb: http://git.kernel.org/tip/5952886bfeec065041d04dfcc2693b581e8f2424
Author: Borislav Petkov b...@suse.de
AuthorDate: Thu, 21 Mar 2013 18:16:57 +0100
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Wed, 10 Apr 2013 14:39:08 +0200

x86/mm/cpa: Cleanup split_large_page() and its callee

So basically we're generating the pte_t * from a struct page and
we're handing it down to the __split_large_page() internal version
which then goes and gets back struct page * from it because it
needs it.

Change the caller to hand down struct page * directly and the
callee can compute the pte_t itself.

Net save is one virt_to_page() call and simpler code. While at
it, make __split_large_page() static.

Signed-off-by: Borislav Petkov b...@suse.de
Acked-by: Thomas Gleixner t...@linutronix.de
Link: http://lkml.kernel.org/r/1363886217-24703-1-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 arch/x86/include/asm/pgtable_types.h | 1 -
 arch/x86/mm/pageattr.c   | 9 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index 567b5d0..e642300 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -351,7 +351,6 @@ static inline void update_page_count(int level, unsigned 
long pages) { }
  * as a pte too.
  */
 extern pte_t *lookup_address(unsigned long address, unsigned int *level);
-extern int __split_large_page(pte_t *kpte, unsigned long address, pte_t 
*pbase);
 extern phys_addr_t slow_virt_to_phys(void *__address);
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 091934e..25b1d35 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -542,13 +542,14 @@ out_unlock:
return do_split;
 }
 
-int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
+static int
+__split_large_page(pte_t *kpte, unsigned long address, struct page *base)
 {
+   pte_t *pbase = (pte_t *)page_address(base);
unsigned long pfn, pfninc = 1;
unsigned int i, level;
pte_t *tmp;
pgprot_t ref_prot;
-   struct page *base = virt_to_page(pbase);
 
spin_lock(pgd_lock);
/*
@@ -633,7 +634,6 @@ int __split_large_page(pte_t *kpte, unsigned long address, 
pte_t *pbase)
 
 static int split_large_page(pte_t *kpte, unsigned long address)
 {
-   pte_t *pbase;
struct page *base;
 
if (!debug_pagealloc)
@@ -644,8 +644,7 @@ static int split_large_page(pte_t *kpte, unsigned long 
address)
if (!base)
return -ENOMEM;
 
-   pbase = (pte_t *)page_address(base);
-   if (__split_large_page(kpte, address, pbase))
+   if (__split_large_page(kpte, address, base))
__free_page(base);
 
return 0;
--
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, CPU, AMD: Drop useless label

2013-04-08 Thread tip-bot for Borislav Petkov
Commit-ID:  042c16f14161fb569fd1a60b908c5196109052da
Gitweb: http://git.kernel.org/tip/042c16f14161fb569fd1a60b908c5196109052da
Author: Borislav Petkov 
AuthorDate: Mon, 8 Apr 2013 17:57:46 +0200
Committer:  H. Peter Anvin 
CommitDate: Mon, 8 Apr 2013 09:07:18 -0700

x86, CPU, AMD: Drop useless label

All we want to do is return from this function so stop jumping around
like a flea for no good reason.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/136543-9837-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/amd.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index cea02d7..5013a48 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -192,11 +192,11 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
/* Athlon 660/661 is valid. */
if ((c->x86_model == 6) && ((c->x86_mask == 0) ||
(c->x86_mask == 1)))
-   goto valid_k7;
+   return;
 
/* Duron 670 is valid */
if ((c->x86_model == 7) && (c->x86_mask == 0))
-   goto valid_k7;
+   return;
 
/*
 * Athlon 662, Duron 671, and Athlon >model 7 have capability
@@ -209,7 +209,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
((c->x86_model == 7) && (c->x86_mask >= 1)) ||
 (c->x86_model > 7))
if (cpu_has_mp)
-   goto valid_k7;
+   return;
 
/* If we get here, not a certified SMP capable AMD system. */
 
@@ -220,9 +220,6 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
WARN_ONCE(1, "WARNING: This combination of AMD"
" processors is not suitable for SMP.\n");
add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE);
-
-valid_k7:
-   ;
 }
 
 static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
--
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, AMD: Correct {rd,wr}msr_amd_safe warnings

2013-04-08 Thread tip-bot for Borislav Petkov
Commit-ID:  982f33db626e7b42f44e0d404ebb110bf139c18b
Gitweb: http://git.kernel.org/tip/982f33db626e7b42f44e0d404ebb110bf139c18b
Author: Borislav Petkov 
AuthorDate: Mon, 8 Apr 2013 17:57:45 +0200
Committer:  H. Peter Anvin 
CommitDate: Mon, 8 Apr 2013 09:07:17 -0700

x86, AMD: Correct {rd,wr}msr_amd_safe warnings

The idea with those routines is to slowly phase them out and not call
them on anything else besides K8. They even have a check for that which,
when called too early, fails. Let me explain:

It gets the cpuinfo_x86 pointer from the per_cpu array and when this
happens for cpu0, before its boot_cpu_data has been copied back to the
per_cpu array in smp_store_boot_cpu_info(), we get an empty struct and
thus the check fails.

Use boot_cpu_data directly instead.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/136543-9837-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/amd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9a2a716..cea02d7 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -20,11 +20,11 @@
 
 static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
 {
-   struct cpuinfo_x86 *c = _data(smp_processor_id());
u32 gprs[8] = { 0 };
int err;
 
-   WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ "%s should only be used on K8!\n", __func__);
 
gprs[1] = msr;
gprs[7] = 0x9c5a203a;
@@ -38,10 +38,10 @@ static inline int rdmsrl_amd_safe(unsigned msr, unsigned 
long long *p)
 
 static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
 {
-   struct cpuinfo_x86 *c = _data(smp_processor_id());
u32 gprs[8] = { 0 };
 
-   WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ "%s should only be used on K8!\n", __func__);
 
gprs[0] = (u32)val;
gprs[1] = msr;
--
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: Fold-in trivial check_config function

2013-04-08 Thread tip-bot for Borislav Petkov
Commit-ID:  e277a49385743dfa69a7adbb1ff19732d83d258c
Gitweb: http://git.kernel.org/tip/e277a49385743dfa69a7adbb1ff19732d83d258c
Author: Borislav Petkov 
AuthorDate: Mon, 8 Apr 2013 17:57:44 +0200
Committer:  H. Peter Anvin 
CommitDate: Mon, 8 Apr 2013 09:07:17 -0700

x86: Fold-in trivial check_config function

Fold it into its single call site. No functionality change.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/136543-9837-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/cpu/bugs.c | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index efa24c0..0344534 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -63,21 +63,6 @@ static void __init check_fpu(void)
}
 }
 
-/*
- * Check whether we are able to run this kernel safely on SMP.
- *
- * - i386 is no longer supported.
- * - In order to run on anything without a TSC, we need to be
- *   compiled for a i486.
- */
-
-static void __init check_config(void)
-{
-   if (boot_cpu_data.x86 < 4)
-   panic("Kernel requires i486+ for 'invlpg' and other features");
-}
-
-
 void __init check_bugs(void)
 {
identify_boot_cpu();
@@ -85,7 +70,17 @@ void __init check_bugs(void)
pr_info("CPU: ");
print_cpu_info(_cpu_data);
 #endif
-   check_config();
+
+   /*
+* Check whether we are able to run this kernel safely on SMP.
+*
+* - i386 is no longer supported.
+* - In order to run on anything without a TSC, we need to be
+*   compiled for a i486.
+*/
+   if (boot_cpu_data.x86 < 4)
+   panic("Kernel requires i486+ for 'invlpg' and other features");
+
init_utsname()->machine[1] =
'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
alternative_instructions();
--
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: Fold-in trivial check_config function

2013-04-08 Thread tip-bot for Borislav Petkov
Commit-ID:  e277a49385743dfa69a7adbb1ff19732d83d258c
Gitweb: http://git.kernel.org/tip/e277a49385743dfa69a7adbb1ff19732d83d258c
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 8 Apr 2013 17:57:44 +0200
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Mon, 8 Apr 2013 09:07:17 -0700

x86: Fold-in trivial check_config function

Fold it into its single call site. No functionality change.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/136543-9837-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/bugs.c | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index efa24c0..0344534 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -63,21 +63,6 @@ static void __init check_fpu(void)
}
 }
 
-/*
- * Check whether we are able to run this kernel safely on SMP.
- *
- * - i386 is no longer supported.
- * - In order to run on anything without a TSC, we need to be
- *   compiled for a i486.
- */
-
-static void __init check_config(void)
-{
-   if (boot_cpu_data.x86  4)
-   panic(Kernel requires i486+ for 'invlpg' and other features);
-}
-
-
 void __init check_bugs(void)
 {
identify_boot_cpu();
@@ -85,7 +70,17 @@ void __init check_bugs(void)
pr_info(CPU: );
print_cpu_info(boot_cpu_data);
 #endif
-   check_config();
+
+   /*
+* Check whether we are able to run this kernel safely on SMP.
+*
+* - i386 is no longer supported.
+* - In order to run on anything without a TSC, we need to be
+*   compiled for a i486.
+*/
+   if (boot_cpu_data.x86  4)
+   panic(Kernel requires i486+ for 'invlpg' and other features);
+
init_utsname()-machine[1] =
'0' + (boot_cpu_data.x86  6 ? 6 : boot_cpu_data.x86);
alternative_instructions();
--
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, AMD: Correct {rd,wr}msr_amd_safe warnings

2013-04-08 Thread tip-bot for Borislav Petkov
Commit-ID:  982f33db626e7b42f44e0d404ebb110bf139c18b
Gitweb: http://git.kernel.org/tip/982f33db626e7b42f44e0d404ebb110bf139c18b
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 8 Apr 2013 17:57:45 +0200
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Mon, 8 Apr 2013 09:07:17 -0700

x86, AMD: Correct {rd,wr}msr_amd_safe warnings

The idea with those routines is to slowly phase them out and not call
them on anything else besides K8. They even have a check for that which,
when called too early, fails. Let me explain:

It gets the cpuinfo_x86 pointer from the per_cpu array and when this
happens for cpu0, before its boot_cpu_data has been copied back to the
per_cpu array in smp_store_boot_cpu_info(), we get an empty struct and
thus the check fails.

Use boot_cpu_data directly instead.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/136543-9837-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/amd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9a2a716..cea02d7 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -20,11 +20,11 @@
 
 static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
 {
-   struct cpuinfo_x86 *c = cpu_data(smp_processor_id());
u32 gprs[8] = { 0 };
int err;
 
-   WARN_ONCE((c-x86 != 0xf), %s should only be used on K8!\n, __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ %s should only be used on K8!\n, __func__);
 
gprs[1] = msr;
gprs[7] = 0x9c5a203a;
@@ -38,10 +38,10 @@ static inline int rdmsrl_amd_safe(unsigned msr, unsigned 
long long *p)
 
 static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
 {
-   struct cpuinfo_x86 *c = cpu_data(smp_processor_id());
u32 gprs[8] = { 0 };
 
-   WARN_ONCE((c-x86 != 0xf), %s should only be used on K8!\n, __func__);
+   WARN_ONCE((boot_cpu_data.x86 != 0xf),
+ %s should only be used on K8!\n, __func__);
 
gprs[0] = (u32)val;
gprs[1] = msr;
--
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, CPU, AMD: Drop useless label

2013-04-08 Thread tip-bot for Borislav Petkov
Commit-ID:  042c16f14161fb569fd1a60b908c5196109052da
Gitweb: http://git.kernel.org/tip/042c16f14161fb569fd1a60b908c5196109052da
Author: Borislav Petkov b...@suse.de
AuthorDate: Mon, 8 Apr 2013 17:57:46 +0200
Committer:  H. Peter Anvin h...@zytor.com
CommitDate: Mon, 8 Apr 2013 09:07:18 -0700

x86, CPU, AMD: Drop useless label

All we want to do is return from this function so stop jumping around
like a flea for no good reason.

Signed-off-by: Borislav Petkov b...@suse.de
Link: http://lkml.kernel.org/r/136543-9837-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin h...@zytor.com
---
 arch/x86/kernel/cpu/amd.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index cea02d7..5013a48 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -192,11 +192,11 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
/* Athlon 660/661 is valid. */
if ((c-x86_model == 6)  ((c-x86_mask == 0) ||
(c-x86_mask == 1)))
-   goto valid_k7;
+   return;
 
/* Duron 670 is valid */
if ((c-x86_model == 7)  (c-x86_mask == 0))
-   goto valid_k7;
+   return;
 
/*
 * Athlon 662, Duron 671, and Athlon model 7 have capability
@@ -209,7 +209,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
((c-x86_model == 7)  (c-x86_mask = 1)) ||
 (c-x86_model  7))
if (cpu_has_mp)
-   goto valid_k7;
+   return;
 
/* If we get here, not a certified SMP capable AMD system. */
 
@@ -220,9 +220,6 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 
*c)
WARN_ONCE(1, WARNING: This combination of AMD
 processors is not suitable for SMP.\n);
add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE);
-
-valid_k7:
-   ;
 }
 
 static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
--
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, quirks: Shut-up a long-standing gcc warning

2013-04-02 Thread tip-bot for Borislav Petkov
Commit-ID:  73f460408ca9b6e917f32c89c9a85c586f17f732
Gitweb: http://git.kernel.org/tip/73f460408ca9b6e917f32c89c9a85c586f17f732
Author: Borislav Petkov 
AuthorDate: Mon, 4 Mar 2013 21:16:20 +0100
Committer:  H. Peter Anvin 
CommitDate: Tue, 2 Apr 2013 16:03:34 -0700

x86, quirks: Shut-up a long-standing gcc warning

So gcc nags about those since forever in randconfig builds.

arch/x86/kernel/quirks.c: In function ‘ati_ixp4x0_rev’:
arch/x86/kernel/quirks.c:361:4: warning: ‘b’ is used uninitialized in this 
function [-Wuninitialized]
arch/x86/kernel/quirks.c: In function ‘ati_force_enable_hpet’:
arch/x86/kernel/quirks.c:367:4: warning: ‘d’ may be used uninitialized in this 
function [-Wuninitialized]
arch/x86/kernel/quirks.c:357:6: note: ‘d’ was declared here
arch/x86/kernel/quirks.c:407:21: warning: ‘val’ may be used uninitialized in 
this function [-Wuninitialized]

This function quirk is called on a SB400 chipset only anyway so the
distant possibility of a PCI access failing becomes almost impossible
there. Even if it did fail, then something else more serious is the
problem.

So zero-out the variables so that gcc shuts up but do a coarse check
on the PCI accesses at the end and signal whether any of them had an
error. They shouldn't but in case they do, we'll at least know and we
can address it.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1362428180-8865-6-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/kernel/quirks.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 26ee48a..04ee1e2 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -354,18 +354,22 @@ static void ati_force_hpet_resume(void)
 
 static u32 ati_ixp4x0_rev(struct pci_dev *dev)
 {
-   u32 d;
-   u8  b;
+   int err = 0;
+   u32 d = 0;
+   u8  b = 0;
 
-   pci_read_config_byte(dev, 0xac, );
+   err = pci_read_config_byte(dev, 0xac, );
b &= ~(1<<5);
-   pci_write_config_byte(dev, 0xac, b);
-   pci_read_config_dword(dev, 0x70, );
+   err |= pci_write_config_byte(dev, 0xac, b);
+   err |= pci_read_config_dword(dev, 0x70, );
d |= 1<<8;
-   pci_write_config_dword(dev, 0x70, d);
-   pci_read_config_dword(dev, 0x8, );
+   err |= pci_write_config_dword(dev, 0x70, d);
+   err |= pci_read_config_dword(dev, 0x8, );
d &= 0xff;
dev_printk(KERN_DEBUG, >dev, "SB4X0 revision 0x%x\n", d);
+
+   WARN_ON_ONCE(err);
+
return d;
 }
 
--
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, msr: Unify variable names

2013-04-02 Thread tip-bot for Borislav Petkov
Commit-ID:  1423bed239415edd1562c25be8a7408858fdbb19
Gitweb: http://git.kernel.org/tip/1423bed239415edd1562c25be8a7408858fdbb19
Author: Borislav Petkov 
AuthorDate: Mon, 4 Mar 2013 21:16:19 +0100
Committer:  H. Peter Anvin 
CommitDate: Tue, 2 Apr 2013 16:03:32 -0700

x86, msr: Unify variable names

Make sure all MSR-accessing primitives which split MSR values in
two 32-bit parts have their variables called 'low' and 'high' for
consistence with the rest of the code and for ease of staring.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1362428180-8865-5-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/msr.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 9264802..cb75028 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -137,11 +137,11 @@ static inline unsigned long long native_read_pmc(int 
counter)
  * pointer indirection), this allows gcc to optimize better
  */
 
-#define rdmsr(msr, val1, val2) \
+#define rdmsr(msr, low, high)  \
 do {   \
u64 __val = native_read_msr((msr)); \
-   (void)((val1) = (u32)__val);\
-   (void)((val2) = (u32)(__val >> 32));\
+   (void)((low) = (u32)__val); \
+   (void)((high) = (u32)(__val >> 32));\
 } while (0)
 
 static inline void wrmsr(unsigned msr, unsigned low, unsigned high)
@@ -162,12 +162,12 @@ static inline int wrmsr_safe(unsigned msr, unsigned low, 
unsigned high)
 }
 
 /* rdmsr with exception handling */
-#define rdmsr_safe(msr, p1, p2)\
+#define rdmsr_safe(msr, low, high) \
 ({ \
int __err;  \
u64 __val = native_read_msr_safe((msr), &__err);\
-   (*p1) = (u32)__val; \
-   (*p2) = (u32)(__val >> 32); \
+   (*low) = (u32)__val;\
+   (*high) = (u32)(__val >> 32);   \
__err;  \
 })
 
@@ -208,7 +208,7 @@ do {
\
 #define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val),\
 (u32)((val) >> 32))
 
-#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))
+#define write_tsc(low, high) wrmsr(MSR_IA32_TSC, (low), (high))
 
 #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0)
 
--
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-64, docs, mm: Add vsyscall range to virtual address space layout

2013-04-02 Thread tip-bot for Borislav Petkov
Commit-ID:  aca91bfc67fe356544eb1cfc483c09b27ce49fa9
Gitweb: http://git.kernel.org/tip/aca91bfc67fe356544eb1cfc483c09b27ce49fa9
Author: Borislav Petkov 
AuthorDate: Mon, 4 Mar 2013 21:16:18 +0100
Committer:  H. Peter Anvin 
CommitDate: Tue, 2 Apr 2013 16:03:31 -0700

x86-64, docs, mm: Add vsyscall range to virtual address space layout

Add the end of the virtual address space to its layout documentation.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1362428180-8865-4-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 Documentation/x86/x86_64/mm.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index d6498e3..881582f 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -13,7 +13,9 @@ e900 - e9ff (=40 bits) hole
 ea00 - eaff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 8000 - a000 (=512 MB)  kernel text mapping, from phys 0
-a000 - fff0 (=1536 MB) module mapping space
+a000 - ff5f (=1525 MB) module mapping space
+ff60 - ffdf (=8 MB) vsyscalls
+ffe0 -  (=2 MB) unused hole
 
 The direct mapping covers all memory in the system up to the highest
 memory address (this means in some cases it can also include PCI memory
--
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 KERNEL_IMAGE_START

2013-04-02 Thread tip-bot for Borislav Petkov
Commit-ID:  8e3c2a8cf647e2f3a1e9d38009b0d1c02145822f
Gitweb: http://git.kernel.org/tip/8e3c2a8cf647e2f3a1e9d38009b0d1c02145822f
Author: Borislav Petkov 
AuthorDate: Mon, 4 Mar 2013 21:16:17 +0100
Committer:  H. Peter Anvin 
CommitDate: Tue, 2 Apr 2013 16:03:29 -0700

x86: Drop KERNEL_IMAGE_START

We have KERNEL_IMAGE_START and __START_KERNEL_map which both contain the
start of the kernel text mapping's virtual address. Remove the prior one
which has been replicated a lot less times around the tree.

No functionality change.

Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1362428180-8865-3-git-send-email...@alien8.de
Signed-off-by: H. Peter Anvin 
---
 arch/x86/include/asm/page_64_types.h | 1 -
 arch/x86/kernel/head64.c | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/page_64_types.h 
b/arch/x86/include/asm/page_64_types.h
index 8b491e6..6c896fb 100644
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -48,6 +48,5 @@
  * arch/x86/kernel/head_64.S), and it is mapped here:
  */
 #define KERNEL_IMAGE_SIZE  (512 * 1024 * 1024)
-#define KERNEL_IMAGE_START _AC(0x8000, UL)
 
 #endif /* _ASM_X86_PAGE_64_DEFS_H */
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index c5e403f..101ac1a9 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -144,10 +144,10 @@ void __init x86_64_start_kernel(char * real_mode_data)
 * Build-time sanity checks on the kernel image and module
 * area mappings. (these are purely build-time and produce no code)
 */
-   BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
-   BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
+   BUILD_BUG_ON(MODULES_VADDR < __START_KERNEL_map);
+   BUILD_BUG_ON(MODULES_VADDR - __START_KERNEL_map < KERNEL_IMAGE_SIZE);
BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
-   BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
+   BUILD_BUG_ON((__START_KERNEL_map & ~PMD_MASK) != 0);
BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
--
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/


<    5   6   7   8   9   10   11   12   >