Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277441
b: refs/heads/master
c: a31bc32
h: refs/heads/master
i:
  277439: 273101f
v: v3
  • Loading branch information
Yinghai Lu authored and H. Peter Anvin committed Dec 23, 2011
1 parent 9fdf2db commit 27923e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 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: fb209bd891645bb87b9618b724f0b4928e0df3de
refs/heads/master: a31bc32760992a2c68f3d6bf7da9f760c0fd7c41
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/apic.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ static inline void x2apic_force_phys(void)
{
}

#define nox2apic 0
#define x2apic_preenabled 0
#define x2apic_supported() 0
#endif
Expand Down
37 changes: 27 additions & 10 deletions trunk/arch/x86/kernel/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,24 @@ int x2apic_mode;
/* x2apic enabled before OS handover */
int x2apic_preenabled;
static int x2apic_disabled;
static int nox2apic;
static __init int setup_nox2apic(char *str)
{
if (x2apic_enabled()) {
pr_warning("Bios already enabled x2apic, "
"can't enforce nox2apic");
return 0;
}
int apicid = native_apic_msr_read(APIC_ID);

if (apicid >= 255) {
pr_warning("Apicid: %08x, cannot enforce nox2apic\n",
apicid);
return 0;
}

pr_warning("x2apic already enabled. will disable it\n");
} else
setup_clear_cpu_cap(X86_FEATURE_X2APIC);

nox2apic = 1;

setup_clear_cpu_cap(X86_FEATURE_X2APIC);
return 0;
}
early_param("nox2apic", setup_nox2apic);
Expand Down Expand Up @@ -1443,7 +1452,7 @@ static inline void __disable_x2apic(u64 msr)
wrmsrl(MSR_IA32_APICBASE, msr & ~X2APIC_ENABLE);
}

static void disable_x2apic(void)
static __init void disable_x2apic(void)
{
u64 msr;

Expand All @@ -1460,6 +1469,11 @@ static void disable_x2apic(void)
pr_info("Disabling x2apic\n");
__disable_x2apic(msr);

if (nox2apic) {
clear_cpu_cap(&cpu_data(0), X86_FEATURE_X2APIC);
setup_clear_cpu_cap(X86_FEATURE_X2APIC);
}

x2apic_disabled = 1;
x2apic_mode = 0;

Expand Down Expand Up @@ -1534,13 +1548,16 @@ void __init enable_IR_x2apic(void)
legacy_pic->mask_all();
mask_ioapic_entries();

if (x2apic_preenabled && nox2apic)
disable_x2apic();

if (dmar_table_init_ret)
ret = -1;
else
ret = enable_IR();

if (!x2apic_supported())
goto nox2apic;
goto skip_x2apic;

if (ret < 0) {
/* IR is required if there is APIC ID > 255 even when running
Expand All @@ -1550,7 +1567,7 @@ void __init enable_IR_x2apic(void)
!hypervisor_x2apic_available()) {
if (x2apic_preenabled)
disable_x2apic();
goto nox2apic;
goto skip_x2apic;
}
/*
* without IR all CPUs can be addressed by IOAPIC/MSI
Expand All @@ -1561,7 +1578,7 @@ void __init enable_IR_x2apic(void)

if (ret == IRQ_REMAP_XAPIC_MODE) {
pr_info("x2apic not enabled, IRQ remapping is in xapic mode\n");
goto nox2apic;
goto skip_x2apic;
}

x2apic_enabled = 1;
Expand All @@ -1572,7 +1589,7 @@ void __init enable_IR_x2apic(void)
pr_info("Enabled x2apic\n");
}

nox2apic:
skip_x2apic:
if (ret < 0) /* IR enabling failed */
restore_ioapic_entries();
legacy_pic->restore_mask();
Expand Down

0 comments on commit 27923e8

Please sign in to comment.