2009-03-14 18:24:02 +07:00
|
|
|
#include <linux/bitops.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/kernel.h>
|
2008-02-18 09:30:47 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/e820.h>
|
2006-03-23 17:59:50 +07:00
|
|
|
#include <asm/mtrr.h>
|
2009-03-14 18:24:02 +07:00
|
|
|
#include <asm/msr.h>
|
2008-02-18 09:30:47 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
#define ACE_PRESENT (1 << 6)
|
|
|
|
#define ACE_ENABLED (1 << 7)
|
|
|
|
#define ACE_FCR (1 << 28) /* MSR_VIA_FCR */
|
|
|
|
|
|
|
|
#define RNG_PRESENT (1 << 2)
|
|
|
|
#define RNG_ENABLED (1 << 3)
|
|
|
|
#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
static void init_c3(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
u32 lo, hi;
|
|
|
|
|
|
|
|
/* Test for Centaur Extended Feature Flags presence */
|
|
|
|
if (cpuid_eax(0xC0000000) >= 0xC0000001) {
|
|
|
|
u32 tmp = cpuid_edx(0xC0000001);
|
|
|
|
|
|
|
|
/* enable ACE unit, if present and disabled */
|
|
|
|
if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) {
|
2008-02-18 05:30:23 +07:00
|
|
|
rdmsr(MSR_VIA_FCR, lo, hi);
|
2005-04-17 05:20:36 +07:00
|
|
|
lo |= ACE_FCR; /* enable ACE unit */
|
2008-02-18 05:30:23 +07:00
|
|
|
wrmsr(MSR_VIA_FCR, lo, hi);
|
2005-04-17 05:20:36 +07:00
|
|
|
printk(KERN_INFO "CPU: Enabled ACE h/w crypto\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable RNG unit, if present and disabled */
|
|
|
|
if ((tmp & (RNG_PRESENT | RNG_ENABLED)) == RNG_PRESENT) {
|
2008-02-18 05:30:23 +07:00
|
|
|
rdmsr(MSR_VIA_RNG, lo, hi);
|
2005-04-17 05:20:36 +07:00
|
|
|
lo |= RNG_ENABLE; /* enable RNG unit */
|
2008-02-18 05:30:23 +07:00
|
|
|
wrmsr(MSR_VIA_RNG, lo, hi);
|
2005-04-17 05:20:36 +07:00
|
|
|
printk(KERN_INFO "CPU: Enabled h/w RNG\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store Centaur Extended Feature Flags as
|
|
|
|
* word 5 of the CPU capability bit array
|
|
|
|
*/
|
2015-12-07 16:39:40 +07:00
|
|
|
c->x86_capability[CPUID_C000_0001_EDX] = cpuid_edx(0xC0000001);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2009-03-14 18:24:02 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2007-10-20 06:13:56 +07:00
|
|
|
/* Cyrix III family needs CX8 & PGE explicitly enabled. */
|
2011-12-15 22:11:28 +07:00
|
|
|
if (c->x86_model >= 6 && c->x86_model <= 13) {
|
2008-02-18 05:30:23 +07:00
|
|
|
rdmsr(MSR_VIA_FCR, lo, hi);
|
2005-04-17 05:20:36 +07:00
|
|
|
lo |= (1<<1 | 1<<7);
|
2008-02-18 05:30:23 +07:00
|
|
|
wrmsr(MSR_VIA_FCR, lo, hi);
|
2008-02-26 14:51:22 +07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_CX8);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Before Nehemiah, the C3's had 3dNOW! */
|
2008-02-18 05:30:23 +07:00
|
|
|
if (c->x86_model >= 6 && c->x86_model < 9)
|
2008-02-26 14:51:22 +07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_3DNOW);
|
2009-03-14 18:24:02 +07:00
|
|
|
#endif
|
|
|
|
if (c->x86 == 0x6 && c->x86_model >= 0xf) {
|
|
|
|
c->x86_cache_alignment = c->x86_clflush_size * 2;
|
|
|
|
set_cpu_cap(c, X86_FEATURE_REP_GOOD);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-11-21 20:01:45 +07:00
|
|
|
cpu_detect_cache_sizes(c);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-02-18 09:30:47 +07:00
|
|
|
enum {
|
|
|
|
ECX8 = 1<<1,
|
|
|
|
EIERRINT = 1<<2,
|
|
|
|
DPM = 1<<3,
|
|
|
|
DMCE = 1<<4,
|
|
|
|
DSTPCLK = 1<<5,
|
|
|
|
ELINEAR = 1<<6,
|
|
|
|
DSMC = 1<<7,
|
|
|
|
DTLOCK = 1<<8,
|
|
|
|
EDCTLB = 1<<8,
|
|
|
|
EMMX = 1<<9,
|
|
|
|
DPDC = 1<<11,
|
|
|
|
EBRPRED = 1<<12,
|
|
|
|
DIC = 1<<13,
|
|
|
|
DDC = 1<<14,
|
|
|
|
DNA = 1<<15,
|
|
|
|
ERETSTK = 1<<16,
|
|
|
|
E2MMX = 1<<19,
|
|
|
|
EAMD3D = 1<<20,
|
|
|
|
};
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
static void early_init_centaur(struct cpuinfo_x86 *c)
|
2008-09-05 02:09:43 +07:00
|
|
|
{
|
|
|
|
switch (c->x86) {
|
2009-03-14 18:24:02 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-09-05 02:09:43 +07:00
|
|
|
case 5:
|
|
|
|
/* Emulate MTRRs using Centaur's MCR. */
|
|
|
|
set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
|
|
|
|
break;
|
2009-03-14 18:24:02 +07:00
|
|
|
#endif
|
|
|
|
case 6:
|
|
|
|
if (c->x86_model >= 0xf)
|
|
|
|
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
|
|
|
break;
|
2008-09-05 02:09:43 +07:00
|
|
|
}
|
2009-03-14 18:24:02 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
set_cpu_cap(c, X86_FEATURE_SYSENTER32);
|
|
|
|
#endif
|
2008-09-05 02:09:43 +07:00
|
|
|
}
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
static void init_centaur(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-03-14 18:24:02 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2005-04-17 05:20:36 +07:00
|
|
|
char *name;
|
2008-02-18 05:30:23 +07:00
|
|
|
u32 fcr_set = 0;
|
|
|
|
u32 fcr_clr = 0;
|
|
|
|
u32 lo, hi, newlo;
|
|
|
|
u32 aa, bb, cc, dd;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-02-18 09:30:47 +07:00
|
|
|
/*
|
|
|
|
* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
|
|
|
|
* 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway
|
|
|
|
*/
|
2008-02-26 14:51:22 +07:00
|
|
|
clear_cpu_cap(c, 0*32+31);
|
2009-03-14 18:24:02 +07:00
|
|
|
#endif
|
|
|
|
early_init_centaur(c);
|
2005-04-17 05:20:36 +07:00
|
|
|
switch (c->x86) {
|
2009-03-14 18:24:02 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-02-18 05:30:23 +07:00
|
|
|
case 5:
|
2008-02-18 09:30:47 +07:00
|
|
|
switch (c->x86_model) {
|
|
|
|
case 4:
|
|
|
|
name = "C6";
|
|
|
|
fcr_set = ECX8|DSMC|EDCTLB|EMMX|ERETSTK;
|
|
|
|
fcr_clr = DPDC;
|
|
|
|
printk(KERN_NOTICE "Disabling bugged TSC.\n");
|
2008-02-26 14:51:22 +07:00
|
|
|
clear_cpu_cap(c, X86_FEATURE_TSC);
|
2008-02-18 09:30:47 +07:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
switch (c->x86_mask) {
|
|
|
|
default:
|
|
|
|
name = "2";
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
2008-02-18 09:30:47 +07:00
|
|
|
case 7 ... 9:
|
|
|
|
name = "2A";
|
|
|
|
break;
|
|
|
|
case 10 ... 15:
|
|
|
|
name = "2B";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fcr_set = ECX8|DSMC|DTLOCK|EMMX|EBRPRED|ERETSTK|
|
|
|
|
E2MMX|EAMD3D;
|
|
|
|
fcr_clr = DPDC;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
name = "3";
|
|
|
|
fcr_set = ECX8|DSMC|DTLOCK|EMMX|EBRPRED|ERETSTK|
|
|
|
|
E2MMX|EAMD3D;
|
|
|
|
fcr_clr = DPDC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
name = "??";
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-02-18 09:30:47 +07:00
|
|
|
rdmsr(MSR_IDT_FCR1, lo, hi);
|
|
|
|
newlo = (lo|fcr_set) & (~fcr_clr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-02-18 09:30:47 +07:00
|
|
|
if (newlo != lo) {
|
|
|
|
printk(KERN_INFO "Centaur FCR was 0x%X now 0x%X\n",
|
|
|
|
lo, newlo);
|
|
|
|
wrmsr(MSR_IDT_FCR1, newlo, hi);
|
|
|
|
} else {
|
|
|
|
printk(KERN_INFO "Centaur FCR is 0x%X\n", lo);
|
|
|
|
}
|
|
|
|
/* Emulate MTRRs using Centaur's MCR. */
|
2008-02-26 14:51:22 +07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
|
2008-02-18 09:30:47 +07:00
|
|
|
/* Report CX8 */
|
2008-02-26 14:51:22 +07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_CX8);
|
2008-02-18 09:30:47 +07:00
|
|
|
/* Set 3DNow! on Winchip 2 and above. */
|
|
|
|
if (c->x86_model >= 8)
|
2008-02-26 14:51:22 +07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_3DNOW);
|
2008-02-18 09:30:47 +07:00
|
|
|
/* See if we can find out some more. */
|
|
|
|
if (cpuid_eax(0x80000000) >= 0x80000005) {
|
|
|
|
/* Yes, we can. */
|
|
|
|
cpuid(0x80000005, &aa, &bb, &cc, &dd);
|
|
|
|
/* Add L1 data and code cache sizes. */
|
|
|
|
c->x86_cache_size = (cc>>24)+(dd>>24);
|
|
|
|
}
|
|
|
|
sprintf(c->x86_model_id, "WinChip %s", name);
|
|
|
|
break;
|
2009-03-14 18:24:02 +07:00
|
|
|
#endif
|
2008-02-18 05:30:23 +07:00
|
|
|
case 6:
|
2008-02-18 09:30:47 +07:00
|
|
|
init_c3(c);
|
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2009-03-14 18:24:02 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2013-10-21 15:35:20 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
static unsigned int
|
2008-02-18 09:30:47 +07:00
|
|
|
centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
/* VIA C3 CPUs (670-68F) need further shifting. */
|
|
|
|
if ((c->x86 == 6) && ((c->x86_model == 7) || (c->x86_model == 8)))
|
|
|
|
size >>= 8;
|
|
|
|
|
2008-02-18 09:30:47 +07:00
|
|
|
/*
|
|
|
|
* There's also an erratum in Nehemiah stepping 1, which
|
|
|
|
* returns '65KB' instead of '64KB'
|
|
|
|
* - Note, it seems this may only be in engineering samples.
|
|
|
|
*/
|
|
|
|
if ((c->x86 == 6) && (c->x86_model == 9) &&
|
|
|
|
(c->x86_mask == 1) && (size == 65))
|
2008-02-18 05:30:23 +07:00
|
|
|
size -= 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
return size;
|
|
|
|
}
|
2013-10-21 15:35:20 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
static const struct cpu_dev centaur_cpu_dev = {
|
2005-04-17 05:20:36 +07:00
|
|
|
.c_vendor = "Centaur",
|
|
|
|
.c_ident = { "CentaurHauls" },
|
2008-09-05 02:09:43 +07:00
|
|
|
.c_early_init = early_init_centaur,
|
2005-04-17 05:20:36 +07:00
|
|
|
.c_init = init_centaur,
|
2013-10-21 15:35:20 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
.legacy_cache_size = centaur_size_cache,
|
|
|
|
#endif
|
2008-09-05 02:09:45 +07:00
|
|
|
.c_x86_vendor = X86_VENDOR_CENTAUR,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-09-05 02:09:45 +07:00
|
|
|
cpu_dev_register(centaur_cpu_dev);
|