Skip to contentSkip to conversation

x86/CPU: Get rid of show_msr

PATCH In review Borislav Petkov 3 participants 8 messages Oct 24, 2016 – Oct 26, 2016

Subsystems (3)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

cover x86/CPU: Get rid of show_msr

From: Borislav Petkov <[email protected]>

Hi,

respective patches should explain it all but in short, this removes some useles crap.

Borislav Petkov (3):
x86/CPU: Remove the printk format specifier in "CPU0: " x86/CPU: Merge bugs.c and bugs_64.c
x86/CPU: Get rid of show_msr

 Documentation/kernel-parameters.txt |  6 -----
 arch/x86/kernel/cpu/Makefile        |  4 +--
 arch/x86/kernel/cpu/bugs.c          | 26 +++++++++++++++---
 arch/x86/kernel/cpu/bugs_64.c       | 33 -----------------------
 arch/x86/kernel/cpu/common.c        | 53 -------------------------------------
 arch/x86/kernel/smpboot.c           |  2 +-
 6 files changed, 24 insertions(+), 100 deletions(-)
 delete mode 100644 arch/x86/kernel/cpu/bugs_64.c
Signature · 1 line
2.10.0
author maintainer
#1 lore raw

PATCH 1/3 x86/CPU: Remove the printk format specifier in "CPU0: "

From: Borislav Petkov <[email protected]>

We're using a literal, move it into the string.

No functionality change.

---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +1 -1
index 36cd5dc6c42e..105487738581 100644
@@ -1329,7 +1329,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 	default_setup_apic_routing();
 	cpu0_logical_apicid = apic_bsp_setup(false);
 
-	pr_info("CPU%d: ", 0);
+	pr_info("CPU0: ");
 	print_cpu_info(&cpu_data(0));
 
 	if (is_uv_system())
Signature · 1 line
2.10.0
#2 lore raw

[tip:x86/cpu] x86/cpu: Remove the printk format specifier in "CPU0: "

x86/cpu: Remove the printk format specifier in "CPU0: "
Commit-ID:  d54ff31dd86c6df734d6b2d6382206f2b0816642
Gitweb:     http://git.kernel.org/tip/d54ff31dd86c6df734d6b2d6382206f2b0816642
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 24 Oct 2016 19:38:42 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 25 Oct 2016 11:48:49 +0200

x86/cpu: Remove the printk format specifier in "CPU0: "

We're using a literal, move it into the string.

No functionality change.

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +1 -1
index 42f5eb7..e2e0e35 100644
@@ -1331,7 +1331,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 	default_setup_apic_routing();
 	cpu0_logical_apicid = apic_bsp_setup(false);
 
-	pr_info("CPU%d: ", 0);
+	pr_info("CPU0: ");
 	print_cpu_info(&cpu_data(0));
 
 	if (is_uv_system())
author maintainer
#3 lore raw

PATCH 2/3 x86/CPU: Merge bugs.c and bugs_64.c

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Should be easier when following boot paths. It probably is a left over from the x86 unification eons ago.

No functionality change.

---
 arch/x86/kernel/cpu/Makefile  |  4 +---
 arch/x86/kernel/cpu/bugs.c    | 26 ++++++++++++++++++++++----
 arch/x86/kernel/cpu/bugs_64.c | 33 ---------------------------------
 3 files changed, 23 insertions(+), 40 deletions(-)
 delete mode 100644 arch/x86/kernel/cpu/bugs_64.c
arch/x86/kernel/cpu/Makefile +1 -3
index 4a8697f7d4ef..33b63670bf09 100644
@@ -20,13 +20,11 @@ obj-y			:= intel_cacheinfo.o scattered.o topology.o
 obj-y			+= common.o
 obj-y			+= rdrand.o
 obj-y			+= match.o
+obj-y			+= bugs.o
 
 obj-$(CONFIG_PROC_FS)	+= proc.o
 obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o
 
-obj-$(CONFIG_X86_32)	+= bugs.o
-obj-$(CONFIG_X86_64)	+= bugs_64.o
-
 obj-$(CONFIG_CPU_SUP_INTEL)		+= intel.o
 obj-$(CONFIG_CPU_SUP_AMD)		+= amd.o
 obj-$(CONFIG_CPU_SUP_CYRIX_32)		+= cyrix.o
arch/x86/kernel/cpu/bugs.c +22 -4
index bd17db15a2c1..a44ef52184df 100644
@@ -16,15 +16,19 @@
 #include <asm/msr.h>
 #include <asm/paravirt.h>
 #include <asm/alternative.h>
+#include <asm/pgtable.h>
+#include <asm/cacheflush.h>
 
 void __init check_bugs(void)
 {
 	identify_boot_cpu();
-#ifndef CONFIG_SMP
-	pr_info("CPU: ");
-	print_cpu_info(&boot_cpu_data);
-#endif
 
+	if (!IS_ENABLED(CONFIG_SMP)) {
+		pr_info("CPU: ");
+		print_cpu_info(&boot_cpu_data);
+	}
+
+#ifdef CONFIG_X86_32
 	/*
 	 * Check whether we are able to run this kernel safely on SMP.
 	 *
@@ -40,4 +44,18 @@ void __init check_bugs(void)
 	alternative_instructions();
 
 	fpu__init_check_bugs();
+#else /* CONFIG_X86_64 */
+	alternative_instructions();
+
+	/*
+	 * Make sure the first 2MB area is not mapped by huge pages
+	 * There are typically fixed size MTRRs in there and overlapping
+	 * MTRRs into large pages causes slow downs.
+	 *
+	 * Right now we don't do that with gbpages because there seems
+	 * very little benefit for that case.
+	 */
+	if (!direct_gbpages)
+		set_memory_4k((unsigned long)__va(0), 1);
+#endif
 }
arch/x86/kernel/cpu/bugs_64.c deleted +0 -33
deleted file mode 100644
index a972ac4c7e7d..000000000000
@@ -1,33 +0,0 @@
-/*
- *  Copyright (C) 1994  Linus Torvalds
- *  Copyright (C) 2000  SuSE
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/alternative.h>
-#include <asm/bugs.h>
-#include <asm/processor.h>
-#include <asm/mtrr.h>
-#include <asm/cacheflush.h>
-
-void __init check_bugs(void)
-{
-	identify_boot_cpu();
-#if !defined(CONFIG_SMP)
-	pr_info("CPU: ");
-	print_cpu_info(&boot_cpu_data);
-#endif
-	alternative_instructions();
-
-	/*
-	 * Make sure the first 2MB area is not mapped by huge pages
-	 * There are typically fixed size MTRRs in there and overlapping
-	 * MTRRs into large pages causes slow downs.
-	 *
-	 * Right now we don't do that with gbpages because there seems
-	 * very little benefit for that case.
-	 */
-	if (!direct_gbpages)
-		set_memory_4k((unsigned long)__va(0), 1);
-}
Signature · 1 line
2.10.0
#4 lore raw

[tip:x86/cpu] x86/cpu: Merge bugs.c and bugs_64.c

x86/cpu: Merge bugs.c and bugs_64.c
Commit-ID:  62a67e123e058a67db58bc6a14354dd037bafd0a
Gitweb:     http://git.kernel.org/tip/62a67e123e058a67db58bc6a14354dd037bafd0a
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 24 Oct 2016 19:38:43 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 25 Oct 2016 11:48:50 +0200

x86/cpu: Merge bugs.c and bugs_64.c

Should be easier when following boot paths. It probably is a left over from the x86 unification eons ago.

No functionality change.

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/cpu/Makefile  |  4 +---
 arch/x86/kernel/cpu/bugs.c    | 26 ++++++++++++++++++++++----
 arch/x86/kernel/cpu/bugs_64.c | 33 ---------------------------------
 3 files changed, 23 insertions(+), 40 deletions(-)
arch/x86/kernel/cpu/Makefile +1 -3
index 4a8697f..33b6367 100644
@@ -20,13 +20,11 @@ obj-y			:= intel_cacheinfo.o scattered.o topology.o
 obj-y			+= common.o
 obj-y			+= rdrand.o
 obj-y			+= match.o
+obj-y			+= bugs.o
 
 obj-$(CONFIG_PROC_FS)	+= proc.o
 obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o
 
-obj-$(CONFIG_X86_32)	+= bugs.o
-obj-$(CONFIG_X86_64)	+= bugs_64.o
-
 obj-$(CONFIG_CPU_SUP_INTEL)		+= intel.o
 obj-$(CONFIG_CPU_SUP_AMD)		+= amd.o
 obj-$(CONFIG_CPU_SUP_CYRIX_32)		+= cyrix.o
arch/x86/kernel/cpu/bugs.c +22 -4
index bd17db1..a44ef52 100644
@@ -16,15 +16,19 @@
 #include <asm/msr.h>
 #include <asm/paravirt.h>
 #include <asm/alternative.h>
+#include <asm/pgtable.h>
+#include <asm/cacheflush.h>
 
 void __init check_bugs(void)
 {
 	identify_boot_cpu();
-#ifndef CONFIG_SMP
-	pr_info("CPU: ");
-	print_cpu_info(&boot_cpu_data);
-#endif
 
+	if (!IS_ENABLED(CONFIG_SMP)) {
+		pr_info("CPU: ");
+		print_cpu_info(&boot_cpu_data);
+	}
+
+#ifdef CONFIG_X86_32
 	/*
 	 * Check whether we are able to run this kernel safely on SMP.
 	 *
@@ -40,4 +44,18 @@ void __init check_bugs(void)
 	alternative_instructions();
 
 	fpu__init_check_bugs();
+#else /* CONFIG_X86_64 */
+	alternative_instructions();
+
+	/*
+	 * Make sure the first 2MB area is not mapped by huge pages
+	 * There are typically fixed size MTRRs in there and overlapping
+	 * MTRRs into large pages causes slow downs.
+	 *
+	 * Right now we don't do that with gbpages because there seems
+	 * very little benefit for that case.
+	 */
+	if (!direct_gbpages)
+		set_memory_4k((unsigned long)__va(0), 1);
+#endif
 }
arch/x86/kernel/cpu/bugs_64.c deleted +0 -33
deleted file mode 100644
index a972ac4..0000000
@@ -1,33 +0,0 @@
-/*
- *  Copyright (C) 1994  Linus Torvalds
- *  Copyright (C) 2000  SuSE
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/alternative.h>
-#include <asm/bugs.h>
-#include <asm/processor.h>
-#include <asm/mtrr.h>
-#include <asm/cacheflush.h>
-
-void __init check_bugs(void)
-{
-	identify_boot_cpu();
-#if !defined(CONFIG_SMP)
-	pr_info("CPU: ");
-	print_cpu_info(&boot_cpu_data);
-#endif
-	alternative_instructions();
-
-	/*
-	 * Make sure the first 2MB area is not mapped by huge pages
-	 * There are typically fixed size MTRRs in there and overlapping
-	 * MTRRs into large pages causes slow downs.
-	 *
-	 * Right now we don't do that with gbpages because there seems
-	 * very little benefit for that case.
-	 */
-	if (!direct_gbpages)
-		set_memory_4k((unsigned long)__va(0), 1);
-}
author maintainer
#5 lore raw

PATCH 3/3 x86/CPU: Get rid of show_msr

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

It is useless as it dumps the MSRs too early BUT(!) we do set MSRs later too.

Also, it dumps only BSP MSRs as it gets called only for CPU 0.

And the MSR range array would need constant updating anyway, and so on and so on...

Oh, and we have msr.ko and msr-tools which are the much better solution anyway. So off it goes...

---
 Documentation/kernel-parameters.txt |  6 -----
 arch/x86/kernel/cpu/common.c        | 53 -------------------------------------
 2 files changed, 59 deletions(-)
Documentation/kernel-parameters.txt +0 -6
index 459b301137c2..73de01eb92b6 100644
@@ -3818,12 +3818,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	shapers=	[NET]
 			Maximal number of shapers.
 
-	show_msr=	[x86] show boot-time MSR settings
-			Format: { <integer> }
-			Show boot-time (BIOS-initialized) MSR settings.
-			The parameter means the number of CPUs to show,
-			for example 1 means boot CPU only.
-
 	simeth=		[IA-64]
 	simscsi=
 
arch/x86/kernel/cpu/common.c +0 -53

65 lines not on this page · raw message

Signature · 1 line
2.10.0
#6 lore raw

[tip:x86/cpu] x86/cpu: Get rid of the show_msr= boot option

x86/cpu: Get rid of the show_msr= boot option
Commit-ID:  59c6f278bdeea4147e8be92a3ed50a9907e60088
Gitweb:     http://git.kernel.org/tip/59c6f278bdeea4147e8be92a3ed50a9907e60088
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 24 Oct 2016 19:38:44 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 25 Oct 2016 11:48:50 +0200

x86/cpu: Get rid of the show_msr= boot option

It is useless as it dumps the MSRs too early BUT(!) we do set MSRs later too. Also, it dumps only BSP MSRs as it gets called only for CPU 0.

And the MSR range array would need constant updating anyway, and so on and so on...

Oh, and we have msr.ko and msr-tools which are the much better solution anyway. So off it goes...

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 Documentation/kernel-parameters.txt |  6 -----
 arch/x86/kernel/cpu/common.c        | 53 -------------------------------------
 2 files changed, 59 deletions(-)
Documentation/kernel-parameters.txt +0 -6
index 37babf9..b676a05a 100644
@@ -3824,12 +3824,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	shapers=	[NET]
 			Maximal number of shapers.
 
-	show_msr=	[x86] show boot-time MSR settings
-			Format: { <integer> }
-			Show boot-time (BIOS-initialized) MSR settings.
-			The parameter means the number of CPUs to show,
-			for example 1 means boot CPU only.
-
 	simeth=		[IA-64]
 	simscsi=
 
arch/x86/kernel/cpu/common.c +0 -53

65 lines not on this page · raw message

#7 lore raw

Re: [tip:x86/cpu] x86/cpu: Get rid of the show_msr= boot option

Quoted 10 lines · tip-bot for Borislav Petkov
Commit-ID:  59c6f278bdeea4147e8be92a3ed50a9907e60088
Gitweb:     http://git.kernel.org/tip/59c6f278bdeea4147e8be92a3ed50a9907e60088
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 24 Oct 2016 19:38:44 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 25 Oct 2016 11:48:50 +0200

x86/cpu: Get rid of the show_msr= boot option

It is useless as it dumps the MSRs too early BUT(!) we do set MSRs later too.

So that is reason that was added to print the MSR early before kernel try to change it.

Quoted 1 line

Also, it dumps only BSP MSRs as it gets called only for CPU 0.

I sent the fix last year.

https://patchwork.kernel.org/patch/6739171/

Yinghai