[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1/2] x86/cpu: Introduce cpu_dev.c_early_init()



The name is chosen to be consistent with Linux.  Doing this allows
early_intel_workaround() to be removed from common code.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
 xen/arch/x86/cpu/common.c | 17 +++++++++++------
 xen/arch/x86/cpu/cpu.h    |  3 +--
 xen/arch/x86/cpu/intel.c  |  5 ++---
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index e60929d..6b320a7 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -226,10 +226,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 
*c)
        /* Initialize the standard set of capabilities */
        /* Note that the vendor-specific code below might override */
 
-       /* Intel-defined flags: level 0x00000001 */
+       /* Model and family information. */
        cpuid(0x00000001, &eax, &ebx, &ecx, &edx);
-       c->x86_capability[cpufeat_word(X86_FEATURE_FPU)] = edx;
-       c->x86_capability[cpufeat_word(X86_FEATURE_XMM3)] = ecx;
        c->x86 = (eax >> 8) & 15;
        c->x86_model = (eax >> 4) & 15;
        if (c->x86 == 0xf)
@@ -239,6 +237,16 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 
*c)
        c->x86_mask = eax & 15;
        c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
        c->phys_proc_id = c->apicid;
+
+       if (this_cpu->c_early_init)
+               this_cpu->c_early_init(c);
+
+       /* c_early_init() may have adjusted cpuid levels/features.  Reread. */
+       c->cpuid_level = cpuid_eax(0);
+       cpuid(0x00000001, &eax, &ebx, &ecx, &edx);
+       c->x86_capability[cpufeat_word(X86_FEATURE_FPU)] = edx;
+       c->x86_capability[cpufeat_word(X86_FEATURE_XMM3)] = ecx;
+
        if ( cpu_has(c, X86_FEATURE_CLFLSH) )
                c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
 
@@ -258,9 +266,6 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 
*c)
                        get_model_name(c); /* Default name */
        }
 
-       /* Might lift BIOS max_leaf=3 limit. */
-       early_intel_workaround(c);
-
        /* Intel-defined flags: level 0x00000007 */
        if ( c->cpuid_level >= 0x00000007 )
                cpuid_count(0x00000007, 0, &tmp,
diff --git a/xen/arch/x86/cpu/cpu.h b/xen/arch/x86/cpu/cpu.h
index ed6cdf0..1877e7d 100644
--- a/xen/arch/x86/cpu/cpu.h
+++ b/xen/arch/x86/cpu/cpu.h
@@ -5,6 +5,7 @@ struct cpu_dev {
        /* some have two possibilities for cpuid string */
        char    * c_ident[2];   
 
+       void            (*c_early_init)(struct cpuinfo_x86 *c);
        void            (*c_init)(struct cpuinfo_x86 * c);
 };
 
@@ -17,5 +18,3 @@ extern unsigned int opt_cpuid_mask_ext_ecx, 
opt_cpuid_mask_ext_edx;
 
 extern int get_model_name(struct cpuinfo_x86 *c);
 extern void display_cacheinfo(struct cpuinfo_x86 *c);
-
-extern void early_intel_workaround(struct cpuinfo_x86 *c);
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index c00657e..fda8d1b 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -156,10 +156,8 @@ static void __devinit set_cpuidmask(const struct 
cpuinfo_x86 *c)
        }
 }
 
-void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
+static void __devinit early_init_intel(struct cpuinfo_x86 *c)
 {
-       if (c->x86_vendor != X86_VENDOR_INTEL)
-               return;
        /* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
        if (c->x86 == 15 && c->x86_cache_alignment == 64)
                c->x86_cache_alignment = 128;
@@ -290,6 +288,7 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
 static const struct cpu_dev intel_cpu_dev = {
        .c_vendor       = "Intel",
        .c_ident        = { "GenuineIntel" },
+       .c_early_init   = early_init_intel,
        .c_init         = init_intel,
 };
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.