x86/cpu: Enable cpuid on Cyrix 6x86/6x86L processors
v2 cover x86/cpu: Enable cpuid on Cyrix 6x86/6x86L processors
On power up, the cpuid instruction is disabled on Cyrix 6x86 and 6x86L processors and needs to be enabled. This patchset enables it.
Matthew Whitehead (2):
x86/cpu: Use correct macros for Cyrix calls
x86/cpu: Change query logic so cpuid is enabled before testing
arch/x86/kernel/cpu/common.c | 4 +++- arch/x86/kernel/cpu/cyrix.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.16.4
PATCH v2 1/2 x86/cpu: Use correct macros for Cyrix calls
There are comments in processor-cyrix.h advising you to _not_ make calls using the deprecated macros in this style:
setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
This is because it expands the macro into a non-functioning calling sequence. The calling order must be:
outb(CX86_CCR2, 0x22); inb(0x23);
From the comments:
* When using the old macros a line like
* setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
* gets expanded to:
* do {
* outb((CX86_CCR2), 0x22);
* outb((({
* outb((CX86_CCR2), 0x22);
* inb(0x23);
* }) | 0x88), 0x23);
* } while (0);
The new macros fix this problem, so we use them instead.
--- arch/x86/kernel/cpu/cyrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/cyrix.c +1 -1
@@ -437,7 +437,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c)/* enable MAPEN */ setCx86 (CX86_CCR3 , (ccr3 &0x0f ) |0x10 );/* enable cpuid */ -setCx86_old (CX86_CCR4 ,getCx86_old (CX86_CCR4 ) |0x80 ); +setCx86 (CX86_CCR4 ,getCx86 (CX86_CCR4 ) |0x80 );/* disable MAPEN */ setCx86 (CX86_CCR3 , ccr3);local_irq_restore (flags);
Signature · 1 line
2.16.4
tip-bot for Matthew Whitehead
merge bot[tip:x86/cpu] x86/CPU: Use correct macros for Cyrix calls
x86/CPU: Use correct macros for Cyrix calls
Commit-ID: 03b099bdcdf7125d4a63dc9ddeefdd454e05123d Gitweb: https://git.kernel.org/tip/03b099bdcdf7125d4a63dc9ddeefdd454e05123d Author: Matthew Whitehead <[email protected]> AuthorDate: Fri, 21 Sep 2018 17:20:40 -0400 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 22 Sep 2018 11:46:56 +0200
x86/CPU: Use correct macros for Cyrix calls
There are comments in processor-cyrix.h advising you to _not_ make calls using the deprecated macros in this style:
setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
This is because it expands the macro into a non-functioning calling sequence. The calling order must be:
outb(CX86_CCR2, 0x22); inb(0x23);
From the comments:
* When using the old macros a line like
* setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
* gets expanded to:
* do {
* outb((CX86_CCR2), 0x22);
* outb((({
* outb((CX86_CCR2), 0x22);
* inb(0x23);
* }) | 0x88), 0x23);
* } while (0);
The new macros fix this problem, so use them instead.
--- arch/x86/kernel/cpu/cyrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/cyrix.c +1 -1
@@ -437,7 +437,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c)/* enable MAPEN */ setCx86 (CX86_CCR3 , (ccr3 &0x0f ) |0x10 );/* enable cpuid */ -setCx86_old (CX86_CCR4 ,getCx86_old (CX86_CCR4 ) |0x80 ); +setCx86 (CX86_CCR4 ,getCx86 (CX86_CCR4 ) |0x80 );/* disable MAPEN */ setCx86 (CX86_CCR3 , ccr3);local_irq_restore (flags);
PATCH v2 2/2 x86/cpu: Change query logic so cpuid is enabled before testing
In reply to Matthew WhiteheadPresently we check for cpuid to be enabled first. If it is not already enabled, then we next call identify_cpu_without_cpuid() and clear X86_FEATURE_CPUID.
Unfortunately, identify_cpu_without_cpuid() is the function where cpuid becomes _enabled_ on Cyrix 6x86/6x86L cpus. So we must reverse the calling sequence so that cpuid is first enabled, and then check a second time to see if the feature has now been activated.
--- arch/x86/kernel/cpu/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/common.c +3 -1
@@ -1040,6 +1040,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)memset (&c->x86_capability,0 ,sizeof c->x86_capability); c->extended_cpuid_level =0 ; +if (!have_cpuid_p ()) +identify_cpu_without_cpuid (c); +/* cyrix could have cpuid enabled via c_identify()*/ if (have_cpuid_p ()) {cpu_detect (c);
@@ -1057,7 +1060,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)if (this_cpu->c_bsp_init) this_cpu->c_bsp_init (c); }else { -identify_cpu_without_cpuid (c);setup_clear_cpu_cap (X86_FEATURE_CPUID ); }
Signature · 1 line
2.16.4
Re: [PATCH v2 2/2] x86/cpu: Change query logic so cpuid is enabled before testing
Quoted 11 lines · Matthew Whitehead
Presently we check for cpuid to be enabled first. If it is not already enabled, then we next call
identify_cpu_without_cpuid()and clearX86_FEATURE_CPUID.Unfortunately,
identify_cpu_without_cpuid()is the function where cpuid becomes _enabled_ on Cyrix 6x86/6x86L cpus. So we must reverse the calling sequence so that cpuid is first enabled, and then check a second time to see if the feature has now been activated.Reviewed-by Andy Lutomirski <[email protected]>
How about Suggested-and-reviewed-by: Andy Lutomirski <[email protected]> instead?
(No need to resubmit for just that. Ingo or Thomas, if you like these, can you just make that substitution?)
Quoted 30 lines
Signed-off-by Matthew Whitehead <[email protected]>--- arch/x86/kernel/cpu/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/common.c +3
-2@@ -1040,6 +1040,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)memset (&c->x86_capability,0 ,sizeof c->x86_capability); c->extended_cpuid_level =0 ; +if (!have_cpuid_p ()) +identify_cpu_without_cpuid (c); +/* cyrix could have cpuid enabled via c_identify()*/ if (have_cpuid_p ()) {cpu_detect (c);@@ -1057,7 +1060,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)if (this_cpu->c_bsp_init) this_cpu->c_bsp_init (c); }else { -identify_cpu_without_cpuid (c);setup_clear_cpu_cap (X86_FEATURE_CPUID ); } --2.16.4
Signature · 2 lines
Andy Lutomirski AMA Capital Management, LLC
tip-bot for Matthew Whitehead
merge bot[tip:x86/cpu] x86/CPU: Change query logic so CPUID is enabled before testing
In reply to Matthew Whiteheadx86/CPU: Change query logic so CPUID is enabled before testing
Commit-ID: 2893cc8ff892fa74972d8dc0e1d0dc65116daaa3 Gitweb: https://git.kernel.org/tip/2893cc8ff892fa74972d8dc0e1d0dc65116daaa3 Author: Matthew Whitehead <[email protected]> AuthorDate: Fri, 21 Sep 2018 17:20:41 -0400 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 22 Sep 2018 11:47:39 +0200
x86/CPU: Change query logic so CPUID is enabled before testing
Presently we check first if CPUID is enabled. If it is not already enabled, then we next call identify_cpu_without_cpuid() and clear X86_FEATURE_CPUID.
Unfortunately, identify_cpu_without_cpuid() is the function where CPUID becomes _enabled_ on Cyrix 6x86/6x86L CPUs.
Reverse the calling sequence so that CPUID is first enabled, and then check a second time to see if the feature has now been activated.
[ bp: Massage commit message and remove trailing whitespace. ]
--- arch/x86/kernel/cpu/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/common.c +3 -1
@@ -1076,6 +1076,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)memset (&c->x86_capability,0 ,sizeof c->x86_capability); c->extended_cpuid_level =0 ; +if (!have_cpuid_p ()) +identify_cpu_without_cpuid (c); +/* cyrix could have cpuid enabled via c_identify()*/ if (have_cpuid_p ()) {cpu_detect (c);
@@ -1093,7 +1096,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)if (this_cpu->c_bsp_init) this_cpu->c_bsp_init (c); }else { -identify_cpu_without_cpuid (c);setup_clear_cpu_cap (X86_FEATURE_CPUID ); }