Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 145824
b: refs/heads/master
c: e826fe1
h: refs/heads/master
v: v3
  • Loading branch information
Jeremy Fitzhardinge committed Mar 30, 2009
1 parent c51f7e3 commit c6f6fb7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e9e2d1ffcfdb38bed11a3064aa74bea9ee38ed80
refs/heads/master: e826fe1ba1563a9272345da8e3279a930ac160a7
50 changes: 44 additions & 6 deletions trunk/arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,67 @@ static void __init xen_banner(void)
xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
}

static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;

static void xen_cpuid(unsigned int *ax, unsigned int *bx,
unsigned int *cx, unsigned int *dx)
{
unsigned maskecx = ~0;
unsigned maskedx = ~0;

/*
* Mask out inconvenient features, to try and disable as many
* unsupported kernel subsystems as possible.
*/
if (*ax == 1)
maskedx = ~((1 << X86_FEATURE_APIC) | /* disable APIC */
(1 << X86_FEATURE_ACPI) | /* disable ACPI */
(1 << X86_FEATURE_MCE) | /* disable MCE */
(1 << X86_FEATURE_MCA) | /* disable MCA */
(1 << X86_FEATURE_ACC)); /* thermal monitoring */
if (*ax == 1) {
maskecx = cpuid_leaf1_ecx_mask;
maskedx = cpuid_leaf1_edx_mask;
}

asm(XEN_EMULATE_PREFIX "cpuid"
: "=a" (*ax),
"=b" (*bx),
"=c" (*cx),
"=d" (*dx)
: "0" (*ax), "2" (*cx));

*cx &= maskecx;
*dx &= maskedx;
}

static __init void xen_init_cpuid_mask(void)
{
unsigned int ax, bx, cx, dx;

cpuid_leaf1_edx_mask =
~((1 << X86_FEATURE_MCE) | /* disable MCE */
(1 << X86_FEATURE_MCA) | /* disable MCA */
(1 << X86_FEATURE_ACC)); /* thermal monitoring */

if (!xen_initial_domain())
cpuid_leaf1_edx_mask &=
~((1 << X86_FEATURE_APIC) | /* disable local APIC */
(1 << X86_FEATURE_ACPI)); /* disable ACPI */

ax = 1;
xen_cpuid(&ax, &bx, &cx, &dx);

/* cpuid claims we support xsave; try enabling it to see what happens */
if (cx & (1 << (X86_FEATURE_XSAVE % 32))) {
unsigned long cr4;

set_in_cr4(X86_CR4_OSXSAVE);

cr4 = read_cr4();

if ((cr4 & X86_CR4_OSXSAVE) == 0)
cpuid_leaf1_ecx_mask &= ~(1 << (X86_FEATURE_XSAVE % 32));

clear_in_cr4(X86_CR4_OSXSAVE);
}
}

static void xen_set_debugreg(int reg, unsigned long val)
{
HYPERVISOR_set_debugreg(reg, val);
Expand Down Expand Up @@ -901,6 +937,8 @@ asmlinkage void __init xen_start_kernel(void)

xen_init_irq_ops();

xen_init_cpuid_mask();

#ifdef CONFIG_X86_LOCAL_APIC
/*
* set up the basic apic ops.
Expand Down

0 comments on commit c6f6fb7

Please sign in to comment.