Skip to contentSkip to conversation

x86/cpu: Enable cpuid instruction on Cyrix 6x86/6x86L processors

PATCH Superseded Matthew Whitehead 2 participants 2 messages Sep 20, 2018 x86

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cpu: Enable cpuid instruction on Cyrix 6x86/6x86L processors

On power up, the cpuid instruction is disabled on Cyrix 6x86 and 6x86L processors and it needs to be enabled. There is code to do this, but it does not work because it uses the broken {set,get}Cx86_old() macros.

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 new macros fix this problem, so we use them instead.

We also need to forcibly enable X86_FEATURE_CPUID. This is because early_identify_cpu() does not know that the call to identify_cpu_without_cpuid() actually enables the cpuid instruction in the odd Cyrix case, and it turns X86_FEATURE_CPUID off after it has just been enabled on the processor.

This was tested on actual Cyrix hardware.

---
 arch/x86/kernel/cpu/cyrix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/cyrix.c +2 -1
index 8949b7a..e603cc5 100644
@@ -437,10 +437,11 @@ 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);
+			setup_force_cpu_cap(X86_FEATURE_CPUID);
 		}
 	}
 }
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 31 lines · Matthew Whitehead

On power up, the cpuid instruction is disabled on Cyrix 6x86 and 6x86L processors and it needs to be enabled. There is code to do this, but it does not work because it uses the broken {set,get}Cx86_old() macros.

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 new macros fix this problem, so we use them instead.

We also need to forcibly enable X86_FEATURE_CPUID. This is because early_identify_cpu() does not know that the call to identify_cpu_without_cpuid() actually enables the cpuid instruction in the odd Cyrix case, and it turns X86_FEATURE_CPUID off after it has just been enabled on the processor.

This was tested on actual Cyrix hardware.

---
 arch/x86/kernel/cpu/cyrix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/cyrix.c +0 -0
index 8949b7a..e603cc5 100644

arch/x86/kernel/cpu/cyrix.c static void cyrix_identify(struct cpuinfo_x86 *c) · line 440

Quoted 5 lines
arch/x86/kernel/cpu/cyrix.c +1 -1
@@ -437,10 +437,11 @@ 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);

Fine with me.

arch/x86/kernel/cpu/cyrix.c static void cyrix_identify(struct cpuinfo_x86 *c) · line 444

Quoted 4 lines
arch/x86/kernel/cpu/cyrix.c +1 -0
                        /* disable MAPEN */
                        setCx86(CX86_CCR3, ccr3);
                        local_irq_restore(flags);
+                       setup_force_cpu_cap(X86_FEATURE_CPUID);

I don't think this is right. This called from here:

        /* cyrix could have cpuid enabled via c_identify()*/
        if (have_cpuid_p()) {
                cpu_detect(c);
                get_cpu_vendor(c);
                get_cpu_cap(c);
                get_cpu_address_sizes(c);
                setup_force_cpu_cap(X86_FEATURE_CPUID);

                if (this_cpu->c_early_init)
                        this_cpu->c_early_init(c);

                c->cpu_index = 0;
                filter_cpuid_features(c, false);

                if (this_cpu->c_bsp_init)
                        this_cpu->c_bsp_init(c);
        } else {
                identify_cpu_without_cpuid(c);  <-- here
                setup_clear_cpu_cap(X86_FEATURE_CPUID);
        }

and it won't do what it should do. I would instead restructure the code:

if (!have_cpuid_p())
identify_cpu_without_cpuid(c);

/* cyrix could have cpuid enabled via c_identify() */ if (have_cpuid_p()) {
cpu_detect();
...
} else {
setup_clear_cpu_cal(X86_FEATURE_CPUID);
}

and then re-test, of course, to make sure that the Cyrix identification code actually works when it gets re-invoked with CPUID on.

--Andy