Skip to contentSkip to conversation

Add a boot parameter to force-enable PAT

X86 Dave Jones 5 participants 11 messages May 20, 2008 – May 21, 2008

Subsystems (3)
lore
Share & tools
lore

Dave Jones

author
#0 lore raw

* Add an enablepat boot parameter, useful for testing CPUs not yet added to the whitelist.
* Don't try to enable PAT if it was never enabled in the first place.

Documentation/kernel-parameters.txt +4 -0
index 72c07a0..e179c22 100644
@@ -236,6 +236,10 @@ and is between 256 and 4096 characters. It is defined in the file
 			try_unsupported: try to drive unsupported chipsets
 				(may crash computer or cause data corruption)
 
+	enablepat	[i386,x86-64]
+			Force the CPU's PAT feature to be used even if it
+			isn't in the kernels whitelist.
+
 	enable_timer_pin_1 [i386,x86-64]
 			Enable PIN 1 of APIC timer
 			Can be useful to work around chipset bugs
arch/x86/kernel/cpu/addon_cpuid_features.c +19 -0
index c2e1ce3..6ce3202 100644
@@ -50,9 +50,28 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 	}
 }
 
+static int forcepat;
+
+static int __init x86_forcepat_setup(char *s)
+{
+	forcepat = 1;
+	return 1;
+}
+__setup("enablepat", x86_forcepat_setup);
+
+
 #ifdef CONFIG_X86_PAT
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+	if (!test_cpu_cap(c, X86_FEATURE_PAT))
+		return;
+
+	if (forcepat == 1) {
+		printk(KERN_INFO "Force enabling PAT\n");
+		set_cpu_cap(c, X86_FEATURE_PAT);
+		return;
+	}
+
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
 		if (c->x86 >= 0xf && c->x86 <= 0x11)
#1 lore raw
Quoted 38 lines · Dave Jones

* Add an enablepat boot parameter, useful for testing CPUs not yet added to the whitelist.
* Don't try to enable PAT if it was never enabled in the first place.

Documentation/kernel-parameters.txt +4 -0
index 72c07a0..e179c22 100644
@@ -236,6 +236,10 @@ and is between 256 and 4096 characters. It is defined in the file
                       try_unsupported: try to drive unsupported chipsets
                               (may crash computer or cause data corruption)
 
+       enablepat       [i386,x86-64]
+                       Force the CPU's PAT feature to be used even if it
+                       isn't in the kernels whitelist.
+
       enable_timer_pin_1 [i386,x86-64]
                       Enable PIN 1 of APIC timer
                       Can be useful to work around chipset bugs
arch/x86/kernel/cpu/addon_cpuid_features.c +9 -0
index c2e1ce3..6ce3202 100644
@@ -50,9 +50,28 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
       }
 }
 
+static int forcepat;
+
+static int __init x86_forcepat_setup(char *s)
+{
+       forcepat = 1;
+       return 1;
+}
+__setup("enablepat", x86_forcepat_setup);
+

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 71

Quoted 10 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +7 -0
+
 #ifdef CONFIG_X86_PAT
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+       if (!test_cpu_cap(c, X86_FEATURE_PAT))
+               return;
+
+       if (forcepat == 1) {
+               printk(KERN_INFO "Force enabling PAT\n");
+               set_cpu_cap(c, X86_FEATURE_PAT);

you don't need to set that bit again...

prevoious !test_cpu_cap(..) already get out.

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 77

Quoted 7 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +3 -0
+               return;
+       }
+
       switch (c->x86_vendor) {
       case X86_VENDOR_AMD:
               if (c->x86 >= 0xf && c->x86 <= 0x11)

YH

author
#2 lore raw
Quoted 3 lines · Yinghai Lu

you don't need to set that bit again...

prevoious !test_cpu_cap(..) already get out.

* Add an enablepat boot parameter, useful for testing CPUs not yet added to the whitelist.
* Don't try to enable PAT if it was never enabled in the first place.

Documentation/kernel-parameters.txt +4 -0
index 72c07a0..e179c22 100644
@@ -236,6 +236,10 @@ and is between 256 and 4096 characters. It is defined in the file
 			try_unsupported: try to drive unsupported chipsets
 				(may crash computer or cause data corruption)
 
+	enablepat	[i386,x86-64]
+			Force the CPU's PAT feature to be used even if it
+			isn't in the kernels whitelist.
+
 	enable_timer_pin_1 [i386,x86-64]
 			Enable PIN 1 of APIC timer
 			Can be useful to work around chipset bugs
arch/x86/kernel/cpu/addon_cpuid_features.c +18 -0
index c2e1ce3..e22e809 100644
@@ -50,9 +50,27 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 	}
 }
 
+static int forcepat;
+
+static int __init x86_forcepat_setup(char *s)
+{
+	forcepat = 1;
+	return 1;
+}
+__setup("enablepat", x86_forcepat_setup);
+
+
 #ifdef CONFIG_X86_PAT
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+	if (!test_cpu_cap(c, X86_FEATURE_PAT))
+		return;
+
+	if (forcepat == 1) {
+		printk(KERN_INFO "Force enabling PAT\n");
+		return;
+	}
+
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
 		if (c->x86 >= 0xf && c->x86 <= 0x11)
Signature · 1 line
http://www.codemonkey.org.uk
#3 lore raw
Quoted 18 lines · Dave Jones
Quoted 3 lines · Yinghai Lu

you don't need to set that bit again...

prevoious !test_cpu_cap(..) already get out.

* Add an enablepat boot parameter, useful for testing CPUs not yet added to the whitelist.
* Don't try to enable PAT if it was never enabled in the first place.

Documentation/kernel-parameters.txt +0 -0
index 72c07a0..e179c22 100644

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 241

Quoted 6 lines
Documentation/kernel-parameters.txt +3 -0
@@ -236,6 +236,10 @@ and is between 256 and 4096 characters. It is defined in the file
 			try_unsupported: try to drive unsupported chipsets
 				(may crash computer or cause data corruption)
 
+	enablepat	[i386,x86-64]
+			Force the CPU's PAT feature to be used even if it
+			isn't in the kernels whitelist.

s/kernels/kernel's/

author
#4 lore raw

* Add an enablepat boot parameter, useful for testing CPUs not yet added to the whitelist.
* Don't try to enable PAT if it was never enabled in the first place.

Documentation/kernel-parameters.txt +4 -0
index 72c07a0..e179c22 100644
@@ -236,6 +236,10 @@ and is between 256 and 4096 characters. It is defined in the file
 			try_unsupported: try to drive unsupported chipsets
 				(may crash computer or cause data corruption)
 
+	enablepat	[i386,x86-64]
+			Force the CPU's PAT feature to be used even if it
+			isn't in the kernel's whitelist.
+
 	enable_timer_pin_1 [i386,x86-64]
 			Enable PIN 1 of APIC timer
 			Can be useful to work around chipset bugs
arch/x86/kernel/cpu/addon_cpuid_features.c +18 -0
index c2e1ce3..e22e809 100644
@@ -50,9 +50,27 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 	}
 }
 
+static int forcepat;
+
+static int __init x86_forcepat_setup(char *s)
+{
+	forcepat = 1;
+	return 1;
+}
+__setup("enablepat", x86_forcepat_setup);
+
+
 #ifdef CONFIG_X86_PAT
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+	if (!test_cpu_cap(c, X86_FEATURE_PAT))
+		return;
+
+	if (forcepat == 1) {
+		printk(KERN_INFO "Force enabling PAT\n");
+		return;
+	}
+
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
 		if (c->x86 >= 0xf && c->x86 <= 0x11)
Signature · 1 line
http://www.codemonkey.org.uk
#5 lore raw
Quoted 6 lines · Dave Jones
arch/x86/kernel/cpu/addon_cpuid_features.c +0 -0
index c2e1ce3..e22e809 100644
@@ -50,9 +50,27 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 	}

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 60

Quoted 10 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +8 -0
 }
 
+static int forcepat;
+
+static int __init x86_forcepat_setup(char *s)
+{
+	forcepat = 1;
+	return 1;
+}
+__setup("enablepat", x86_forcepat_setup);

This should probably be called plain "pat" to mirror arch/x86/mm/pat.c "nopat" force off parameter. That by the way is an early_param which I guess this should then also be?

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 67

Quoted 7 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +4 -0
+
+
 #ifdef CONFIG_X86_PAT
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+	if (!test_cpu_cap(c, X86_FEATURE_PAT))
+		return;

It seems you needn't test this, the !cpu_has_pat test in pat_init() will trigger and user knows best... :-)

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 76

Quoted 9 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +6 -0
+
+	if (forcepat == 1) {
+		printk(KERN_INFO "Force enabling PAT\n");
+		return;
+	}
+
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
 		if (c->x86 >= 0xf && c->x86 <= 0x11)

Rene.

#6 lore raw
Quoted 5 lines · Rene Herman

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 60

Quoted 2 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +2 -0
+}
+__setup("enablepat", x86_forcepat_setup);

This should probably be called plain "pat" to mirror arch/x86/mm/pat.c "nopat" force off parameter. That by the way is an early_param which I guess this should then also be?

Either that or "pat={off,on,force}" to give space for other options... would mean keeping "nopat" around as an alias for now, though...

-hpa

#7 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 5 lines · Rene Herman

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 60

Quoted 2 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +2 -0
+}
+__setup("enablepat", x86_forcepat_setup);

This should probably be called plain "pat" to mirror arch/x86/mm/pat.c "nopat" force off parameter. That by the way is an early_param which I guess this should then also be?

Either that or "pat={off,on,force}" to give space for other options... would mean keeping "nopat" around as an alias for now, though...

Yes, that would be nicer. As to the alias; "nopat" hasn't been in a released kernel yet so should be okay to do away with? It's not like it's in Documentation/kernel-parameters.txt or anything... ;-/

Rene.

#8 lore raw
Quoted 9 lines · Rene Herman
Quoted 7 lines · H. Peter Anvin
Quoted 5 lines · Rene Herman

arch/x86/kernel/cpu/addon_cpuid_features.c void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) · line 60

Quoted 2 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +2 -0
+}
+__setup("enablepat", x86_forcepat_setup);

This should probably be called plain "pat" to mirror arch/x86/mm/pat.c "nopat" force off parameter. That by the way is an early_param which I guess this should then also be?

Quoted 4 lines
Quoted 1 line

Either that or "pat={off,on,force}" to give space for other options... would mean keeping "nopat" around as an alias for now, though...

Yes, that would be nicer. As to the alias; "nopat" hasn't been in a released kernel yet so should be okay to do away with? It's not like it's in Documentation/kernel-parameters.txt or anything... ;-/

OK, just double-checked... since it's not in Linus we can still change it, and as so I'd suggest the pat= option.

-hpa

author
#9 lore raw
Quoted 7 lines · H. Peter Anvin
Quoted 4 lines

Yes, that would be nicer. As to the alias; "nopat" hasn't been in a released kernel yet so should be okay to do away with? It's not like it's in Documentation/kernel-parameters.txt or anything... ;-/

OK, just double-checked... since it's not in Linus we can still change it, and as so I'd suggest the pat= option.

Not boot-tested, but it compiles for me..
I also folded in the 'debugpat' option.

Documentation/kernel-parameters.txt +6 -0
index e37f456..9f9c2c2 100644
@@ -1478,6 +1478,12 @@ and is between 256 and 4096 characters. It is defined in the file
 			the specified number of seconds.  This is to be used if
 			your oopses keep scrolling off the screen.
 
+	pat=		[X86] Page attribute table support.
+			off	don't use page attribute tables.
+			force	enable use of page attribute tables, even if the
+				CPU isn't in the kernel's whitelist.
+			debug	output additional debugging information during setup.
+
 	pcbit=		[HW,ISDN]
 
 	pcd.		[PARIDE]
arch/x86/kernel/cpu/addon_cpuid_features.c +7 -0
index c2e1ce3..8b65f14 100644
@@ -51,8 +51,15 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 }
 
 #ifdef CONFIG_X86_PAT
+int forcepat;
+
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+	if (forcepat == 1) {
+		printk(KERN_INFO "Force enabling PAT\n");
+		return;
+	}
+
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
 		if (c->x86 >= 0xf && c->x86 <= 0x11)
arch/x86/mm/pat.c +13 -11
index e83b770..7429bee 100644
@@ -25,8 +25,11 @@
 #include <asm/mtrr.h>
 #include <asm/io.h>
 
+static int debug_enable;
+
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_wc_enabled = 1;
+extern int forcepat;
 
 void __cpuinit pat_disable(char *reason)
 {
@@ -34,23 +37,22 @@ void __cpuinit pat_disable(char *reason)
 	printk(KERN_INFO "%s\n", reason);
 }
 
-static int nopat(char *str)
+static int __init patsetup(char *str)
 {
-	pat_disable("PAT support disabled.");
+	if (strcmp("force", str) == 0) {
+		forcepat = 1;
+		printk(KERN_INFO "Force enabling PAT\n");
+	}
+	if (strcmp("off", str) == 0)
+		pat_disable("PAT support disabled.");
+	if (strcmp("debug", str) == 0)
+		debug_enable = 1;
 	return 0;
 }
-early_param("nopat", nopat);
+early_param("pat=", patsetup);
 #endif
 
 
-static int debug_enable;
-static int __init pat_debug_setup(char *str)
-{
-	debug_enable = 1;
-	return 0;
-}
-__setup("debugpat", pat_debug_setup);
-
 #define dprintk(fmt, arg...) \
 	do { if (debug_enable) printk(KERN_INFO fmt, ##arg); } while (0)
 
Signature · 1 line
http://www.codemonkey.org.uk
#10 lore raw
Quoted 1 line · Dave Jones

Not boot-tested, but it compiles for me..

It doesn't even apply for me. Moreover though -- __early_param() still seems to be too late for validate_pat_support() so this isn't going to work.

__setup() is even later than that. I guess this just wants to set a flag from validate_pat_support() which arch/x86/mm/pat.c can then check later?

Quoted 59 lines
arch/x86/kernel/cpu/addon_cpuid_features.c +7 -0
@@ -51,8 +51,15 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 }
 
 #ifdef CONFIG_X86_PAT
+int forcepat;
+
 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
 {
+	if (forcepat == 1) {
+		printk(KERN_INFO "Force enabling PAT\n");
+		return;
+	}
+
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
 		if (c->x86 >= 0xf && c->x86 <= 0x11)
arch/x86/mm/pat.c +13 -4
index e83b770..7429bee 100644
@@ -25,8 +25,11 @@
 #include <asm/mtrr.h>
 #include <asm/io.h>
 
+static int debug_enable;
+
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_wc_enabled = 1;
+extern int forcepat;
 
 void __cpuinit pat_disable(char *reason)
 {
@@ -34,23 +37,22 @@ void __cpuinit pat_disable(char *reason)
 	printk(KERN_INFO "%s\n", reason);
 }
 
-static int nopat(char *str)
+static int __init patsetup(char *str)
 {
-	pat_disable("PAT support disabled.");
+	if (strcmp("force", str) == 0) {
+		forcepat = 1;
+		printk(KERN_INFO "Force enabling PAT\n");
+	}
+	if (strcmp("off", str) == 0)
+		pat_disable("PAT support disabled.");
+	if (strcmp("debug", str) == 0)
+		debug_enable = 1;
 	return 0;
 }
-early_param("nopat", nopat);
+early_param("pat=", patsetup);
 #endif
 
 
-static int debug_enable;

arch/x86/mm/pat.c void __cpuinit pat_disable(char *reason) · line 58

Quoted 10 lines
arch/x86/mm/pat.c +0 -7
-static int __init pat_debug_setup(char *str)
-{
-	debug_enable = 1;
-	return 0;
-}
-__setup("debugpat", pat_debug_setup);
-
 #define dprintk(fmt, arg...) \
 	do { if (debug_enable) printk(KERN_INFO fmt, ##arg); } while (0)
 

Rene.