I added a noclflush option because Ingo asked for it to make
it possible to disable parts of the new CPA code.While I was at it I did some generic cleanup in the area of cpuid disable
options and generalized them a bit. That is where the other patches come from.-Andi
--
Add a generic option to clear any cpuid bit. I added it because it was
very easy to add with the new generic cpuid disable bitmap and perhaps
it will be useful in the future.Signed-off-by: Andi Kleen <ak@suse.de>
---
Documentation/kernel-parameters.txt | 13 +++++++++++++
arch/x86/kernel/cpu/common.c | 11 +++++++++++
arch/x86/kernel/setup_64.c | 11 +++++++++++
3 files changed, 35 insertions(+)Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -572,6 +572,17 @@ void __cpuinit print_cpu_info(struct cpu
printk("\n");
}+static __init int setup_disablecpuid(char *arg)
+{
+ int bit;
+ if (get_option(&arg, &bit) && bit < NCAPINTS*32)
+ setup_clear_cpu_cap(bit);
+ else
+ return 0;
+ return 1;
+}
+__setup("clearcpuid=", setup_disablecpuid);
+
cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;/* This is hacky. :)
Index: linux/arch/x86/kernel/setup_64.c
===================================================================
--- linux.orig/arch/x86/kernel/setup_64.c
+++ linux/arch/x86/kernel/setup_64.c
@@ -1060,6 +1060,17 @@ void __cpuinit print_cpu_info(struct cpu
printk(KERN_CONT "\n");
}+static __init int setup_disablecpuid(char *arg)
+{
+ int bit;
+ if (get_option(&arg, &bit) && bit < NCAPINTS*32)
+ setup_clear_cpu_cap(bit);
+ else
+ return 0;
+ return 1;
+}
+__setup("clearcpuid=", setup_disablecpuid);
+
/*
* Get CPU information for use by the procfs.
*/
Index: linux/Documentation/kernel-parameters.txt
===================================================================
--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -408,6 +408,19 @@ and is between 256 and 4096 characters.
[SPARC64] tick
[X86-64] hpet,tsc+ clearcpuid=BITNUM [X86]
+ Disable CPUID ...
To disable CLFLUSH usage, especially in change_page_attr().
Ingo asked for this.
Signed-off-by: Andi Kleen <ak@suse.de>
---
Documentation/kernel-parameters.txt | 2 ++
arch/x86/kernel/cpu/common.c | 7 +++++++
arch/x86/kernel/setup_64.c | 7 +++++++
3 files changed, 16 insertions(+)Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -542,6 +542,13 @@ void __cpuinit detect_ht(struct cpuinfo_
}
#endif+static __init int setup_noclflush(char *arg)
+{
+ setup_clear_cpu_cap(X86_FEATURE_CLFLSH);
+ return 1;
+}
+__setup("noclflush", setup_noclflush);
+
void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
{
char *vendor = NULL;
Index: linux/arch/x86/kernel/setup_64.c
===================================================================
--- linux.orig/arch/x86/kernel/setup_64.c
+++ linux/arch/x86/kernel/setup_64.c
@@ -1042,6 +1042,13 @@ void __cpuinit identify_cpu(struct cpuin
}
}+static __init int setup_noclflush(char *arg)
+{
+ setup_clear_cpu_cap(X86_FEATURE_CLFLSH);
+ return 1;
+}
+__setup("noclflush", setup_noclflush);
+
void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
{
if (c->x86_model_id[0])
Index: linux/Documentation/kernel-parameters.txt
===================================================================
--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -1173,6 +1173,8 @@ and is between 256 and 4096 characters.
register save and restore. The kernel will only save
legacy floating-point registers on task switch.+ noclflush [BUGS=X86] Don't use the CLFLUSH instruction
+
nohlt [BUGS=ARM]no-hlt [BUGS=X86-32] Tells the kernel that the hlt
--
The config option protects so little code that it is fairly pointless.
Also a lot of its code was related to itself only (as in panicing without
TSC). And TSC less CPUs are completely handled at runtime anyways.This makes 32bit behaviour match x86-64.
I also removed an #if defined(CONFIG_X86_GENERIC) in get_cycles. Not sure
what that was good for, it didn't make any sense.Signed-off-by: Andi Kleen <ak@suse.de>
---
arch/x86/Kconfig.cpu | 4 ----
arch/x86/kernel/cpu/bugs.c | 8 --------
arch/x86/kernel/tsc_32.c | 10 ----------
drivers/acpi/processor_idle.c | 10 +++++-----
include/asm-x86/tsc.h | 6 ------
5 files changed, 5 insertions(+), 33 deletions(-)Index: linux/arch/x86/kernel/cpu/bugs.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/bugs.c
+++ linux/arch/x86/kernel/cpu/bugs.c
@@ -151,14 +151,6 @@ static void __init check_config(void)
#endif/*
- * If we configured ourselves for a TSC, we'd better have one!
- */
-#ifdef CONFIG_X86_TSC
- if (!cpu_has_tsc)
- panic("Kernel compiled for Pentium+, requires TSC feature!");
-#endif
-
-/*
* If we were told we had a good local APIC, check for buggy Pentia,
* i.e. all B steppings and the C2 stepping of P54C when using their
* integrated APIC (see 11AP erratum in "Pentium Processor
Index: linux/arch/x86/kernel/tsc_32.c
===================================================================
--- linux.orig/arch/x86/kernel/tsc_32.c
+++ linux/arch/x86/kernel/tsc_32.c
@@ -24,14 +24,6 @@ static int tsc_enabled;
unsigned int tsc_khz;
EXPORT_SYMBOL_GPL(tsc_khz);-#ifdef CONFIG_X86_TSC
-static int __init tsc_setup(char *str)
-{
- printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, "
- "cannot disable TSC.\n");
- return 1;
-}
-#else
/*
* disable flag for tsc. Takes effect by clearing the TSC cpu flag
* in cpu/common.c
@@ -41,8 +33,6 @@ static int __init tsc_setup(char *str)
setup...
Hmm, during further testing i found that the patch causes boot failures
in some configuration. I withdraw this one for now.The other patches in the series are independent and should be still
considered for merging.-Andi
--
ok, pulled. In what situations did it fail? It worked fine on a (small)
yep, they are in and have caused no problems so far.
Ingo
--
This cleans up quite a lot of code.
I think I test compiled all the affected variants (voyager, numaq),
but didn't test them, but the change is pretty straight forward for
them.This means NUMAQ didn't compile, but I don't think it was related
to my patches.Signed-off-by: Andi Kleen <ak@suse.de>
---
arch/x86/kernel/cpu/bugs.c | 2 +-
arch/x86/kernel/cpu/common.c | 9 ---------
arch/x86/kernel/numaq_32.c | 2 +-
arch/x86/kernel/tsc_32.c | 14 +++-----------
arch/x86/mach-voyager/setup.c | 2 +-
arch/x86/xen/time.c | 2 +-
include/asm-x86/tsc.h | 2 --
7 files changed, 7 insertions(+), 26 deletions(-)Index: linux/arch/x86/kernel/cpu/bugs.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/bugs.c
+++ linux/arch/x86/kernel/cpu/bugs.c
@@ -154,7 +154,7 @@ static void __init check_config(void)
* If we configured ourselves for a TSC, we'd better have one!
*/
#ifdef CONFIG_X86_TSC
- if (!cpu_has_tsc && !tsc_disable)
+ if (!cpu_has_tsc)
panic("Kernel compiled for Pentium+, requires TSC feature!");
#endifIndex: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -446,10 +446,6 @@ void __cpuinit identify_cpu(struct cpuin
* we do "generic changes."
*/- /* TSC disabled? */
- if ( tsc_disable )
- clear_bit(X86_FEATURE_TSC, c->x86_capability);
-
/* If the model name is still unset, do table lookup. */
if ( !c->x86_model_id[0] ) {
char *p;
@@ -650,11 +646,6 @@ void __cpuinit cpu_init(void)if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
- if (tsc_disable && cpu_has_tsc) {
- printk(KERN_NOTICE "Disabling TSC...\n");
- /**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
- clear_bit(X86_FEATURE_TSC, boot_c...
Should have added Jeremy to CC, sorry for the duplicate message.
That inverts the meaning, doesn't it? Previously the code force the TSC
to be on and now it forcefully disables it. Now when booting a Xen guest
I get:
Kernel panic - not syncing: Kernel compiled for Pentium+, requires TSC feature!I think you want something like the following
From: Ian Campbell <ijc@hellion.org.uk>
Date: Sat, 19 Jan 2008 18:08:23 +0000
Subject: [PATCH] x86: Xen requires TSC support to be forced on, not disabled.Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
arch/x86/xen/time.c | 2 +-
include/asm-x86/cpufeature.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 6f5c74a..b3721fd 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -592,7 +592,7 @@ __init void xen_time_init(void)
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);- setup_clear_cpu_cap(X86_FEATURE_TSC);
+ setup_force_cpu_cap(X86_FEATURE_TSC);xen_setup_timer(cpu);
xen_setup_cpu_clockevents();
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
index 91a7665..b6f969c 100644
--- a/include/asm-x86/cpufeature.h
+++ b/include/asm-x86/cpufeature.h
@@ -135,6 +135,10 @@
clear_cpu_cap(&boot_cpu_data, bit); \
set_bit(bit, cleared_cpu_caps); \
} while (0)
+#define setup_force_cpu_cap(bit) do { \
+ set_cpu_cap(&boot_cpu_data, bit); \
+ clear_bit(bit, cleared_cpu_caps); \
+} while (0)#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
--
1.5.3.8--
Ian CampbellAll that glitters is not gold; all that wander are not lost.
--
That inverts the meaning, doesn't it? Previously the code force the TSC
to be on and now it forcefully disables it. Now when booting a Xen guest
I get:
Kernel panic - not syncing: Kernel compiled for Pentium+, requires TSC feature!I think you want something like the following
From: Ian Campbell <ijc@hellion.org.uk>
Date: Sat, 19 Jan 2008 18:08:23 +0000
Subject: [PATCH] x86: Xen requires TSC support to be forced on, not disabled.Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
arch/x86/xen/time.c | 2 +-
include/asm-x86/cpufeature.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 6f5c74a..b3721fd 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -592,7 +592,7 @@ __init void xen_time_init(void)
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);- setup_clear_cpu_cap(X86_FEATURE_TSC);
+ setup_force_cpu_cap(X86_FEATURE_TSC);xen_setup_timer(cpu);
xen_setup_cpu_clockevents();
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
index 91a7665..b6f969c 100644
--- a/include/asm-x86/cpufeature.h
+++ b/include/asm-x86/cpufeature.h
@@ -135,6 +135,10 @@
clear_cpu_cap(&boot_cpu_data, bit); \
set_bit(bit, cleared_cpu_caps); \
} while (0)
+#define setup_force_cpu_cap(bit) do { \
+ set_cpu_cap(&boot_cpu_data, bit); \
+ clear_bit(bit, cleared_cpu_caps); \
+} while (0)#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
--
1.5.3.8--
Ian CampbellAll that glitters is not gold; all that wander are not lost.
--
You're right -- i was a bit overzealous in search'n'replace with that one.
Actually that would be only needed if someone else disabled TSC explicitely before.
Simply deleting this should be sufficient. Does this patch work for you?
It would break if someone passes notsc to a Xen kernel, but then a lot of options make the kernel
break if you don't know what you're doing so that doesn't seem like a big issue.-Andi
---
Don't disable TSC in Xen boot
That was a typo in the previous TSC option changes.
TSC shouldn't be disabled at this point, so just don't do anything.
Signed-off-by: Andi Kleen <ak@suse.de>
Index: linux/arch/x86/xen/time.c
===================================================================
--- linux.orig/arch/x86/xen/time.c
+++ linux/arch/x86/xen/time.c
@@ -592,8 +592,6 @@ __init void xen_time_init(void)
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);- setup_clear_cpu_cap(X86_FEATURE_TSC);
-
xen_setup_timer(cpu);
xen_setup_cpu_clockevents();
}
--
I'm happy either way. I think the Xen paravirt subsystem will use TSC
where it has to due to the Xen architecture regardless of this setting.Ian.
--
Ian CampbellGood day for overcoming obstacles. Try a steeplechase.
--
Modern 32bit userland doesn't even boot when the TSC is disabled
because ld.so tends to contain RDTSCs. So make notsc only effective for the
kernel, similar to 64bit.
Signed-off-by: Andi Kleen <ak@suse.de>---
arch/x86/kernel/cpu/common.c | 1 -
1 file changed, 1 deletion(-)Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -654,7 +654,6 @@ void __cpuinit cpu_init(void)
printk(KERN_NOTICE "Disabling TSC...\n");
/**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
- set_in_cr4(X86_CR4_TSD);
}load_idt(&idt_descr);
--
This convers nofxsr, mem=nopentium and nosep to use the new
generic cpuid disable bitmap instead of using own variables.Signed-off-by: Andi Kleen <ak@suse.de>
---
arch/x86/kernel/cpu/common.c | 34 ++++------------------------------
arch/x86/kernel/setup_32.c | 5 +----
2 files changed, 5 insertions(+), 34 deletions(-)Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -60,14 +60,10 @@ EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;static int cachesize_override __cpuinitdata = -1;
-static int disable_x86_fxsr __cpuinitdata;
static int disable_x86_serial_nr __cpuinitdata = 1;
-static int disable_x86_sep __cpuinitdata;struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
-extern int disable_pse;
-
static void __cpuinit default_init(struct cpuinfo_x86 * c)
{
/* Not much we can do here... */
@@ -216,16 +212,8 @@ static void __cpuinit get_cpu_vendor(strstatic int __init x86_fxsr_setup(char * s)
{
- /* Tell all the other CPUs to not use it... */
- disable_x86_fxsr = 1;
-
- /*
- * ... and clear the bits early in the boot_cpu_data
- * so that the bootup process doesn't try to do this
- * either.
- */
- clear_bit(X86_FEATURE_FXSR, boot_cpu_data.x86_capability);
- clear_bit(X86_FEATURE_XMM, boot_cpu_data.x86_capability);
+ setup_clear_cpu_cap(X86_FEATURE_FXSR);
+ setup_clear_cpu_cap(X86_FEATURE_XMM);
return 1;
}
__setup("nofxsr", x86_fxsr_setup);
@@ -233,7 +221,7 @@ __setup("nofxsr", x86_fxsr_setup);static int __init x86_sep_setup(char * s)
{
- disable_x86_sep = 1;
+ setup_clear_cpu_cap(X86_FEATURE_SEP);
return 1;
}
__setup("nosep", x86_sep_setup);
@@ -462,19 +450,6 @@ void __cpuinit identify_cpu(struct cpuin
if ( tsc_disable )
clear_bit(X86_FEATURE_TSC, c->x86_capability);- /* FXSR disabled? */
- if (disable_x86_fxsr) {
...
There are already various options to disable specific cpuid bits
on the command line. They all use their own variable. Add a generic
mask to make this easier in the future.Signed-off-by: Andi Kleen <ak@suse.de>
---
arch/x86/kernel/cpu/common.c | 6 ++++++
arch/x86/kernel/setup_64.c | 6 ++++++
include/asm-x86/cpufeature.h | 4 ++++
include/asm-x86/processor.h | 1 +
4 files changed, 17 insertions(+)Index: linux/arch/x86/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/common.c
+++ linux/arch/x86/kernel/cpu/common.c
@@ -57,6 +57,8 @@ DEFINE_PER_CPU(struct gdt_page, gdt_page
} };
EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);+__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;
+
static int cachesize_override __cpuinitdata = -1;
static int disable_x86_fxsr __cpuinitdata;
static int disable_x86_serial_nr __cpuinitdata = 1;
@@ -497,6 +499,10 @@ void __cpuinit identify_cpu(struct cpuin
boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
}+ /* Clear all flags overriden by options */
+ for (i = 0; i < NCAPINTS; i++)
+ c->x86_capability[i] ^= cleared_cpu_caps[i];
+
/* Init Machine Check Exception if available. */
mcheck_init(c);Index: linux/include/asm-x86/cpufeature.h
===================================================================
--- linux.orig/include/asm-x86/cpufeature.h
+++ linux/include/asm-x86/cpufeature.h
@@ -132,6 +132,10 @@#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
#define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability))
+#define setup_clear_cpu_cap(bit) do { \
+ clear_cpu_cap(&boot_cpu_data, bit); \
+ set_bit(bit, cleared_cpu_caps); \
+} while (0)#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
Index: linux/include/asm-x86/processor.h
======================================================...
| Greg Kroah-Hartman | [PATCH 004/196] Chinese: add translation of SubmittingPatches |
| David Chinner | Re: [RFD] BIO_RW_BARRIER - what it means for devices, filesystems, and dm/md. |
| Andrew Morton | -mm merge plans for 2.6.23 |
| Trent Piepho | Re: [PATCH] [POWERPC] Improve (in|out)_beXX() asm code |
git: | |
| David Miller | Re: iptables very slow after commit784544739a25c30637397ace5489eeb6e15d7d49 |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | [GIT]: Networking |
