* [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled
@ 2011-12-22 1:45 Suresh Siddha
2011-12-22 1:45 ` [patch 1/5] x86, apic: add probe() for apic_flat Suresh Siddha
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Suresh Siddha @ 2011-12-22 1:45 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org
Cc: yinghai, flyboy, suresh.b.siddha
Previous version of this patch and discussion can be found at
https://lkml.org/lkml/2011/12/16/488
Splitup the patch from Yinghai into multiple patches with minor changes
and other review comments (https://lkml.org/lkml/2011/12/20/27)
thanks,
suresh
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 1/5] x86, apic: add probe() for apic_flat
2011-12-22 1:45 [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled Suresh Siddha
@ 2011-12-22 1:45 ` Suresh Siddha
2011-12-23 20:10 ` [tip:x86/apic] x86, apic: Add " tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 2/5] x86, acpi: skip acpi x2apic entries if the x2apic feature is not present Suresh Siddha
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Suresh Siddha @ 2011-12-22 1:45 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org
Cc: yinghai, flyboy, Suresh Siddha
[-- Attachment #1: flat_apic_probe.patch --]
[-- Type: text/plain, Size: 1358 bytes --]
From: Yinghai Lu <yinghai@kernel.org>
Currently we start with the default apic_flat mode and switch to some other
apic model depending on the apic drivers acpi_madt_oem_check() routines and
later followed by the apic drivers probe() routines.
Once we selected non flat mode there was no case where we fall back to
flat mode again.
Upcoming changes allow bios-enabled x2apic mode to be disabled by the OS
if interrupt-remapping etc is not setup properly by the bios.
We now has a case for the apic to fall back to legacy flat mode during
apic driver probe() seqeuence. Add a simple flat_probe() which allows
the apic_flat mode to be the last fallback option.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
index 57c1f41..8c3cdde 100644
--- a/arch/x86/kernel/apic/apic_flat_64.c
+++ b/arch/x86/kernel/apic/apic_flat_64.c
@@ -171,9 +171,14 @@ static int flat_phys_pkg_id(int initial_apic_id, int index_msb)
return initial_apic_id >> index_msb;
}
+static int flat_probe(void)
+{
+ return 1;
+}
+
static struct apic apic_flat = {
.name = "flat",
- .probe = NULL,
+ .probe = flat_probe,
.acpi_madt_oem_check = flat_acpi_madt_oem_check,
.apic_id_registered = flat_apic_id_registered,
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [patch 2/5] x86, acpi: skip acpi x2apic entries if the x2apic feature is not present
2011-12-22 1:45 [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled Suresh Siddha
2011-12-22 1:45 ` [patch 1/5] x86, apic: add probe() for apic_flat Suresh Siddha
@ 2011-12-22 1:45 ` Suresh Siddha
2011-12-23 20:11 ` [tip:x86/apic] x86, acpi: Skip " tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 3/5] x86, x2apic: fallback to xapic when bios doesnt setup interrupt-remapping Suresh Siddha
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Suresh Siddha @ 2011-12-22 1:45 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org
Cc: yinghai, flyboy, Suresh Siddha
[-- Attachment #1: nox2apic_acpi_parsing.patch --]
[-- Type: text/plain, Size: 2533 bytes --]
From: Yinghai Lu <yinghai@kernel.org>
If the x2apic feature is not present (either the cpu is not capable of it
or the user has disabled the feature using boot-parameter etc), ignore the
x2apic MADT and SRAT entries provided by the ACPI tables.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 4558f0d..1c54a9e 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -219,6 +219,8 @@ static int __init
acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
{
struct acpi_madt_local_x2apic *processor = NULL;
+ int apic_id;
+ u8 enabled;
processor = (struct acpi_madt_local_x2apic *)header;
@@ -227,6 +229,8 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
acpi_table_print_madt_entry(header);
+ apic_id = processor->local_apic_id;
+ enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
#ifdef CONFIG_X86_X2APIC
/*
* We need to register disabled CPU as well to permit
@@ -235,8 +239,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
* to not preallocating memory for all NR_CPUS
* when we use CPU hotplug.
*/
- acpi_register_lapic(processor->local_apic_id, /* APIC ID */
- processor->lapic_flags & ACPI_MADT_ENABLED);
+ if (!cpu_has_x2apic && (apic_id >= 0xff) && enabled)
+ printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
+ else
+ acpi_register_lapic(apic_id, enabled);
#else
printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
#endif
diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
index 81dbfde..6dd2b09 100644
--- a/arch/x86/mm/srat.c
+++ b/arch/x86/mm/srat.c
@@ -69,6 +69,12 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
return;
pxm = pa->proximity_domain;
+ apic_id = pa->apic_id;
+ if (!cpu_has_x2apic && (apic_id >= 0xff)) {
+ printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
+ pxm, apic_id);
+ return;
+ }
node = setup_node(pxm);
if (node < 0) {
printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
@@ -76,7 +82,6 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
return;
}
- apic_id = pa->apic_id;
if (apic_id >= MAX_LOCAL_APIC) {
printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
return;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [patch 3/5] x86, x2apic: fallback to xapic when bios doesnt setup interrupt-remapping
2011-12-22 1:45 [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled Suresh Siddha
2011-12-22 1:45 ` [patch 1/5] x86, apic: add probe() for apic_flat Suresh Siddha
2011-12-22 1:45 ` [patch 2/5] x86, acpi: skip acpi x2apic entries if the x2apic feature is not present Suresh Siddha
@ 2011-12-22 1:45 ` Suresh Siddha
2011-12-23 20:12 ` [tip:x86/apic] x86, x2apic: Fallback to xapic when BIOS doesn' t " tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios Suresh Siddha
2011-12-22 1:45 ` [patch 5/5] x86: skip cpus with apic-ids >= 255 in !x2apic_mode Suresh Siddha
4 siblings, 1 reply; 13+ messages in thread
From: Suresh Siddha @ 2011-12-22 1:45 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org
Cc: yinghai, flyboy, Suresh Siddha
[-- Attachment #1: allow_xapic_fallback_from_x2apic.patch --]
[-- Type: text/plain, Size: 6038 bytes --]
From: Yinghai Lu <yinghai@kernel.org>
On some of the recent Intel SNB platforms, by default bios is pre-enabling
x2apic mode in the cpu with out setting up interrupt-remapping.
This case was resulting in the kernel to panic as the cpu is already in
x2apic mode but the OS was not able to enable interrupt-remapping (which
is a pre-req for using x2apic capability).
On these platforms all the apic-ids are < 255 and the kernel can fallback to
xapic mode if the bios has not enabled interrupt-remapping (which is
mostly the case if the bios has not exported interrupt-remapping tables to the
OS).
Reported-by: Berck E. Nash <flyboy@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/include/asm/apic.h | 4 ++
arch/x86/include/asm/apicdef.h | 1
arch/x86/kernel/apic/apic.c | 73 ++++++++++++++++++++++++++++++-----------
arch/x86/kernel/apic/io_apic.c | 4 ++
4 files changed, 64 insertions(+), 18 deletions(-)
Index: tip/arch/x86/include/asm/apic.h
===================================================================
--- tip.orig/arch/x86/include/asm/apic.h
+++ tip/arch/x86/include/asm/apic.h
@@ -176,6 +176,7 @@ static inline u64 native_x2apic_icr_read
}
extern int x2apic_phys;
+extern int x2apic_preenabled;
extern void check_x2apic(void);
extern void enable_x2apic(void);
extern void x2apic_icr_write(u32 low, u32 id);
@@ -198,6 +199,9 @@ static inline void x2apic_force_phys(voi
x2apic_phys = 1;
}
#else
+static inline void disable_x2apic(void)
+{
+}
static inline void check_x2apic(void)
{
}
Index: tip/arch/x86/include/asm/apicdef.h
===================================================================
--- tip.orig/arch/x86/include/asm/apicdef.h
+++ tip/arch/x86/include/asm/apicdef.h
@@ -144,6 +144,7 @@
#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
#define APIC_BASE_MSR 0x800
+#define XAPIC_ENABLE (1UL << 11)
#define X2APIC_ENABLE (1UL << 10)
#ifdef CONFIG_X86_32
Index: tip/arch/x86/kernel/apic/apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/apic.c
+++ tip/arch/x86/kernel/apic/apic.c
@@ -146,7 +146,8 @@ __setup("apicpmtimer", setup_apicpmtimer
int x2apic_mode;
#ifdef CONFIG_X86_X2APIC
/* x2apic enabled before OS handover */
-static int x2apic_preenabled;
+int x2apic_preenabled;
+static int x2apic_disabled;
static __init int setup_nox2apic(char *str)
{
if (x2apic_enabled()) {
@@ -1431,6 +1432,40 @@ void __init bsp_end_local_APIC_setup(voi
}
#ifdef CONFIG_X86_X2APIC
+/*
+ * Need to disable xapic and x2apic at the same time and then enable xapic mode
+ */
+static inline void __disable_x2apic(u64 msr)
+{
+ wrmsrl(MSR_IA32_APICBASE,
+ msr & ~(X2APIC_ENABLE | XAPIC_ENABLE));
+ wrmsrl(MSR_IA32_APICBASE, msr & ~X2APIC_ENABLE);
+}
+
+static void disable_x2apic(void)
+{
+ u64 msr;
+
+ if (!cpu_has_x2apic)
+ return;
+
+ rdmsrl(MSR_IA32_APICBASE, msr);
+ if (msr & X2APIC_ENABLE) {
+ u32 x2apic_id = read_apic_id();
+
+ if (x2apic_id >= 255)
+ panic("Cannot disable x2apic, id: %08x\n", x2apic_id);
+
+ pr_info("Disabling x2apic\n");
+ __disable_x2apic(msr);
+
+ x2apic_disabled = 1;
+ x2apic_mode = 0;
+
+ register_lapic_address(mp_lapic_addr);
+ }
+}
+
void check_x2apic(void)
{
if (x2apic_enabled()) {
@@ -1441,15 +1476,20 @@ void check_x2apic(void)
void enable_x2apic(void)
{
- int msr, msr2;
+ u64 msr;
+
+ rdmsrl(MSR_IA32_APICBASE, msr);
+ if (x2apic_disabled) {
+ __disable_x2apic(msr);
+ return;
+ }
if (!x2apic_mode)
return;
- rdmsr(MSR_IA32_APICBASE, msr, msr2);
if (!(msr & X2APIC_ENABLE)) {
printk_once(KERN_INFO "Enabling x2apic\n");
- wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, msr2);
+ wrmsrl(MSR_IA32_APICBASE, msr | X2APIC_ENABLE);
}
}
#endif /* CONFIG_X86_X2APIC */
@@ -1486,7 +1526,7 @@ void __init enable_IR_x2apic(void)
ret = save_ioapic_entries();
if (ret) {
pr_info("Saving IO-APIC state failed: %d\n", ret);
- goto out;
+ return;
}
local_irq_save(flags);
@@ -1498,13 +1538,19 @@ void __init enable_IR_x2apic(void)
else
ret = enable_IR();
+ if (!x2apic_supported())
+ goto nox2apic;
+
if (ret < 0) {
/* IR is required if there is APIC ID > 255 even when running
* under KVM
*/
if (max_physical_apicid > 255 ||
- !hypervisor_x2apic_available())
+ !hypervisor_x2apic_available()) {
+ if (x2apic_preenabled)
+ disable_x2apic();
goto nox2apic;
+ }
/*
* without IR all CPUs can be addressed by IOAPIC/MSI
* only in physical mode
@@ -1512,8 +1558,10 @@ void __init enable_IR_x2apic(void)
x2apic_force_phys();
}
- if (ret == IRQ_REMAP_XAPIC_MODE)
+ if (ret == IRQ_REMAP_XAPIC_MODE) {
+ pr_info("x2apic not enabled, IRQ remapping is in xapic mode\n");
goto nox2apic;
+ }
x2apic_enabled = 1;
@@ -1528,17 +1576,6 @@ nox2apic:
restore_ioapic_entries();
legacy_pic->restore_mask();
local_irq_restore(flags);
-
-out:
- if (x2apic_enabled || !x2apic_supported())
- return;
-
- if (x2apic_preenabled)
- panic("x2apic: enabled by BIOS but kernel init failed.");
- else if (ret == IRQ_REMAP_XAPIC_MODE)
- pr_info("x2apic not enabled, IRQ remapping is in xapic mode\n");
- else if (ret < 0)
- pr_info("x2apic not enabled, IRQ remapping init failed\n");
}
#ifdef CONFIG_X86_64
Index: tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/io_apic.c
+++ tip/arch/x86/kernel/apic/io_apic.c
@@ -2948,6 +2948,10 @@ static inline void __init check_timer(vo
}
local_irq_disable();
apic_printk(APIC_QUIET, KERN_INFO "..... failed :(.\n");
+ if (x2apic_preenabled)
+ apic_printk(APIC_QUIET, KERN_INFO
+ "Perhaps problem with the pre-enabled x2apic mode\n"
+ "Try booting with x2apic and interrupt-remapping disabled in the bios.\n");
panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a "
"report. Then try booting with the 'noapic' option.\n");
out:
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios
2011-12-22 1:45 [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled Suresh Siddha
` (2 preceding siblings ...)
2011-12-22 1:45 ` [patch 3/5] x86, x2apic: fallback to xapic when bios doesnt setup interrupt-remapping Suresh Siddha
@ 2011-12-22 1:45 ` Suresh Siddha
2011-12-22 7:24 ` Yinghai Lu
2011-12-22 1:45 ` [patch 5/5] x86: skip cpus with apic-ids >= 255 in !x2apic_mode Suresh Siddha
4 siblings, 1 reply; 13+ messages in thread
From: Suresh Siddha @ 2011-12-22 1:45 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org
Cc: yinghai, flyboy, Suresh Siddha
[-- Attachment #1: allow_nox2apic_to_disable_pre-enabled_x2apic.patch --]
[-- Type: text/plain, Size: 3686 bytes --]
From: Yinghai Lu <yinghai@kernel.org>
Currently "nox2apic" boot parameter was not enabling x2apic mode if the cpu,
kernel are all capable of enabling x2apic mode and the OS handover
happened in xapic mode.
However If the bios enabled x2apic prior to OS handover, using "nox2apic"
boot parameter had no effect.
If the boot cpu's apicid is < 255, enable "nox2apic" boot parameter to
disable the x2apic mode setup by the bios. This will enable the kernel to
fallback to xapic mode and bringup only the cpu's which has apic-id < 255.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/include/asm/apic.h | 1 +
arch/x86/kernel/apic/apic.c | 39 ++++++++++++++++++++++++++++-----------
2 files changed, 29 insertions(+), 11 deletions(-)
Index: tip/arch/x86/kernel/apic/apic.c
===================================================================
--- tip.orig/arch/x86/kernel/apic/apic.c
+++ tip/arch/x86/kernel/apic/apic.c
@@ -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;
+ }
+
+ 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);
@@ -1453,12 +1462,17 @@ static void disable_x2apic(void)
if (msr & X2APIC_ENABLE) {
u32 x2apic_id = read_apic_id();
- if (x2apic_id > 255)
- panic("Can not disable x2apic, id: %08x\n", x2apic_id);
+ if (x2apic_id >= 255)
+ panic("Cannot disable x2apic, id: %08x\n", x2apic_id);
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;
@@ -1533,13 +1547,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
@@ -1549,7 +1566,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
@@ -1560,7 +1577,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;
@@ -1571,7 +1588,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();
Index: tip/arch/x86/include/asm/apic.h
===================================================================
--- tip.orig/arch/x86/include/asm/apic.h
+++ tip/arch/x86/include/asm/apic.h
@@ -216,6 +216,7 @@ static inline void x2apic_force_phys(voi
{
}
+#define nox2apic 0
#define x2apic_preenabled 0
#define x2apic_supported() 0
#endif
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 5/5] x86: skip cpus with apic-ids >= 255 in !x2apic_mode
2011-12-22 1:45 [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled Suresh Siddha
` (3 preceding siblings ...)
2011-12-22 1:45 ` [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios Suresh Siddha
@ 2011-12-22 1:45 ` Suresh Siddha
2011-12-23 20:13 ` [tip:x86/apic] x86: Skip " tip-bot for Suresh Siddha
4 siblings, 1 reply; 13+ messages in thread
From: Suresh Siddha @ 2011-12-22 1:45 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org
Cc: yinghai, flyboy, Suresh Siddha
[-- Attachment #1: skip_AP_with_bigger_apicids_in_xapic.patch --]
[-- Type: text/plain, Size: 1208 bytes --]
From: Suresh Siddha <suresh.b.siddha@intel.com>
If the x2apic mode is disabled for reasons like interrupt-remapping
not available etc, then we need to skip the logical cpu bringup of
apic-id's >= 255. Otherwise as the platform is in xapic mode, init/startup
IPI's will consider only the low 8-bits and there is a possibility of
re-sending init/startup IPI's to the logical cpu that is already online.
This will avoid potential reboots/unpredictable behavior etc.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/kernel/smpboot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: tip/arch/x86/kernel/smpboot.c
===================================================================
--- tip.orig/arch/x86/kernel/smpboot.c
+++ tip/arch/x86/kernel/smpboot.c
@@ -840,7 +840,8 @@ int __cpuinit native_cpu_up(unsigned int
pr_debug("++++++++++++++++++++=_---CPU UP %u\n", cpu);
if (apicid == BAD_APICID || apicid == boot_cpu_physical_apicid ||
- !physid_isset(apicid, phys_cpu_present_map)) {
+ !physid_isset(apicid, phys_cpu_present_map) ||
+ (!x2apic_mode && apicid >= 255)) {
printk(KERN_ERR "%s: bad cpu %d\n", __func__, cpu);
return -EINVAL;
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios
2011-12-22 1:45 ` [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios Suresh Siddha
@ 2011-12-22 7:24 ` Yinghai Lu
2011-12-23 19:01 ` Suresh Siddha
2011-12-23 20:13 ` [tip:x86/apic] x86, x2apic: Allow "nox2apic" to disable x2apic mode setup by BIOS tip-bot for Yinghai Lu
0 siblings, 2 replies; 13+ messages in thread
From: Yinghai Lu @ 2011-12-22 7:24 UTC (permalink / raw)
To: Suresh Siddha
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org, flyboy
[-- Attachment #1: Type: text/plain, Size: 605 bytes --]
On Wed, Dec 21, 2011 at 5:45 PM, Suresh Siddha
<suresh.b.siddha@intel.com> wrote:
> @@ -1453,12 +1462,17 @@ static void disable_x2apic(void)
> if (msr & X2APIC_ENABLE) {
> u32 x2apic_id = read_apic_id();
>
> - if (x2apic_id > 255)
> - panic("Can not disable x2apic, id: %08x\n", x2apic_id);
> + if (x2apic_id >= 255)
> + panic("Cannot disable x2apic, id: %08x\n", x2apic_id);
can not be applied cleanly.
update it a little bit.
need to use attached one to replace 4/5.
Thanks
Yinghai
[-- Attachment #2: nox2apic_v10_4.patch --]
[-- Type: text/x-patch, Size: 3862 bytes --]
Subject: [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios
From: Yinghai Lu <yinghai@kernel.org>
Currently "nox2apic" boot parameter was not enabling x2apic mode if the cpu,
kernel are all capable of enabling x2apic mode and the OS handover
happened in xapic mode.
However If the bios enabled x2apic prior to OS handover, using "nox2apic"
boot parameter had no effect.
If the boot cpu's apicid is < 255, enable "nox2apic" boot parameter to
disable the x2apic mode setup by the bios. This will enable the kernel to
fallback to xapic mode and bringup only the cpu's which has apic-id < 255.
-v2: fix patch error and two compiling warning
make disable_x2apic to be __init
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/include/asm/apic.h | 1 +
arch/x86/kernel/apic/apic.c | 37 +++++++++++++++++++++++++++----------
2 files changed, 28 insertions(+), 10 deletions(-)
Index: linux-2.6/arch/x86/kernel/apic/apic.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/apic/apic.c
+++ linux-2.6/arch/x86/kernel/apic/apic.c
@@ -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);
@@ -1443,7 +1452,7 @@ static inline void __disable_x2apic(u64
wrmsrl(MSR_IA32_APICBASE, msr & ~X2APIC_ENABLE);
}
-static void disable_x2apic(void)
+static __init void disable_x2apic(void)
{
u64 msr;
@@ -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;
@@ -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
@@ -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
@@ -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;
@@ -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();
Index: linux-2.6/arch/x86/include/asm/apic.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/apic.h
+++ linux-2.6/arch/x86/include/asm/apic.h
@@ -216,6 +216,7 @@ static inline void x2apic_force_phys(voi
{
}
+#define nox2apic 0
#define x2apic_preenabled 0
#define x2apic_supported() 0
#endif
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios
2011-12-22 7:24 ` Yinghai Lu
@ 2011-12-23 19:01 ` Suresh Siddha
2011-12-23 20:13 ` [tip:x86/apic] x86, x2apic: Allow "nox2apic" to disable x2apic mode setup by BIOS tip-bot for Yinghai Lu
1 sibling, 0 replies; 13+ messages in thread
From: Suresh Siddha @ 2011-12-23 19:01 UTC (permalink / raw)
To: Yinghai Lu
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
linux-kernel@vger.kernel.org, flyboy@gmail.com
On Wed, 2011-12-21 at 23:24 -0800, Yinghai Lu wrote:
> On Wed, Dec 21, 2011 at 5:45 PM, Suresh Siddha
> <suresh.b.siddha@intel.com> wrote:
>
> > @@ -1453,12 +1462,17 @@ static void disable_x2apic(void)
> > if (msr & X2APIC_ENABLE) {
> > u32 x2apic_id = read_apic_id();
> >
> > - if (x2apic_id > 255)
> > - panic("Can not disable x2apic, id: %08x\n", x2apic_id);
> > + if (x2apic_id >= 255)
> > + panic("Cannot disable x2apic, id: %08x\n", x2apic_id);
>
> can not be applied cleanly.
>
> update it a little bit.
>
> need to use attached one to replace 4/5.
>
Thanks Yinghai. updated patch look good.
Ingo, can you please queue this series to -tip?
thanks,
suresh
^ permalink raw reply [flat|nested] 13+ messages in thread
* [tip:x86/apic] x86, apic: Add probe() for apic_flat
2011-12-22 1:45 ` [patch 1/5] x86, apic: add probe() for apic_flat Suresh Siddha
@ 2011-12-23 20:10 ` tip-bot for Yinghai Lu
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Yinghai Lu @ 2011-12-23 20:10 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, yinghai, suresh.b.siddha, tglx, hpa
Commit-ID: e8524b2f43ab6747518aef81c709d104c478b1cd
Gitweb: http://git.kernel.org/tip/e8524b2f43ab6747518aef81c709d104c478b1cd
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Wed, 21 Dec 2011 17:45:15 -0800
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 23 Dec 2011 11:00:45 -0800
x86, apic: Add probe() for apic_flat
Currently we start with the default apic_flat mode and switch to some other
apic model depending on the apic drivers acpi_madt_oem_check() routines and
later followed by the apic drivers probe() routines.
Once we selected non flat mode there was no case where we fall back to
flat mode again.
Upcoming changes allow bios-enabled x2apic mode to be disabled by the OS
if interrupt-remapping etc is not setup properly by the bios.
We now has a case for the apic to fall back to legacy flat mode during
apic driver probe() seqeuence. Add a simple flat_probe() which allows
the apic_flat mode to be the last fallback option.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/20111222014632.484984298@sbsiddha-desk.sc.intel.com
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/apic/apic_flat_64.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
index 57c1f41..8c3cdde 100644
--- a/arch/x86/kernel/apic/apic_flat_64.c
+++ b/arch/x86/kernel/apic/apic_flat_64.c
@@ -171,9 +171,14 @@ static int flat_phys_pkg_id(int initial_apic_id, int index_msb)
return initial_apic_id >> index_msb;
}
+static int flat_probe(void)
+{
+ return 1;
+}
+
static struct apic apic_flat = {
.name = "flat",
- .probe = NULL,
+ .probe = flat_probe,
.acpi_madt_oem_check = flat_acpi_madt_oem_check,
.apic_id_registered = flat_apic_id_registered,
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:x86/apic] x86, acpi: Skip acpi x2apic entries if the x2apic feature is not present
2011-12-22 1:45 ` [patch 2/5] x86, acpi: skip acpi x2apic entries if the x2apic feature is not present Suresh Siddha
@ 2011-12-23 20:11 ` tip-bot for Yinghai Lu
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Yinghai Lu @ 2011-12-23 20:11 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, yinghai, suresh.b.siddha, tglx, hpa
Commit-ID: a35fd28256e7736cc84af8931a16224f0bfaaf6c
Gitweb: http://git.kernel.org/tip/a35fd28256e7736cc84af8931a16224f0bfaaf6c
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Wed, 21 Dec 2011 17:45:16 -0800
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 23 Dec 2011 11:00:50 -0800
x86, acpi: Skip acpi x2apic entries if the x2apic feature is not present
If the x2apic feature is not present (either the cpu is not capable of it
or the user has disabled the feature using boot-parameter etc), ignore the
x2apic MADT and SRAT entries provided by the ACPI tables.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/20111222014632.540896503@sbsiddha-desk.sc.intel.com
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/acpi/boot.c | 10 ++++++++--
arch/x86/mm/srat.c | 7 ++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 4558f0d..ce664f3 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -219,6 +219,8 @@ static int __init
acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
{
struct acpi_madt_local_x2apic *processor = NULL;
+ int apic_id;
+ u8 enabled;
processor = (struct acpi_madt_local_x2apic *)header;
@@ -227,6 +229,8 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
acpi_table_print_madt_entry(header);
+ apic_id = processor->local_apic_id;
+ enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
#ifdef CONFIG_X86_X2APIC
/*
* We need to register disabled CPU as well to permit
@@ -235,8 +239,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
* to not preallocating memory for all NR_CPUS
* when we use CPU hotplug.
*/
- acpi_register_lapic(processor->local_apic_id, /* APIC ID */
- processor->lapic_flags & ACPI_MADT_ENABLED);
+ if (!cpu_has_x2apic && (apic_id >= 0xff) && enabled)
+ printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
+ else
+ acpi_register_lapic(apic_id, enabled);
#else
printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
#endif
diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
index 81dbfde..fd61b3f 100644
--- a/arch/x86/mm/srat.c
+++ b/arch/x86/mm/srat.c
@@ -69,6 +69,12 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
return;
pxm = pa->proximity_domain;
+ apic_id = pa->apic_id;
+ if (!cpu_has_x2apic && (apic_id >= 0xff)) {
+ printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
+ pxm, apic_id);
+ return;
+ }
node = setup_node(pxm);
if (node < 0) {
printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
@@ -76,7 +82,6 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
return;
}
- apic_id = pa->apic_id;
if (apic_id >= MAX_LOCAL_APIC) {
printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
return;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:x86/apic] x86, x2apic: Fallback to xapic when BIOS doesn' t setup interrupt-remapping
2011-12-22 1:45 ` [patch 3/5] x86, x2apic: fallback to xapic when bios doesnt setup interrupt-remapping Suresh Siddha
@ 2011-12-23 20:12 ` tip-bot for Yinghai Lu
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Yinghai Lu @ 2011-12-23 20:12 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, flyboy, yinghai, suresh.b.siddha, tglx,
hpa
Commit-ID: fb209bd891645bb87b9618b724f0b4928e0df3de
Gitweb: http://git.kernel.org/tip/fb209bd891645bb87b9618b724f0b4928e0df3de
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Wed, 21 Dec 2011 17:45:17 -0800
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 23 Dec 2011 11:01:01 -0800
x86, x2apic: Fallback to xapic when BIOS doesn't setup interrupt-remapping
On some of the recent Intel SNB platforms, by default bios is pre-enabling
x2apic mode in the cpu with out setting up interrupt-remapping.
This case was resulting in the kernel to panic as the cpu is already in
x2apic mode but the OS was not able to enable interrupt-remapping (which
is a pre-req for using x2apic capability).
On these platforms all the apic-ids are < 255 and the kernel can fallback to
xapic mode if the bios has not enabled interrupt-remapping (which is
mostly the case if the bios has not exported interrupt-remapping tables to the
OS).
Reported-by: Berck E. Nash <flyboy@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/20111222014632.600418637@sbsiddha-desk.sc.intel.com
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/include/asm/apic.h | 4 ++
arch/x86/include/asm/apicdef.h | 1 +
arch/x86/kernel/apic/apic.c | 73 ++++++++++++++++++++++++++++++----------
arch/x86/kernel/apic/io_apic.c | 4 ++
4 files changed, 64 insertions(+), 18 deletions(-)
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index a0f541a..a12d571 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -176,6 +176,7 @@ static inline u64 native_x2apic_icr_read(void)
}
extern int x2apic_phys;
+extern int x2apic_preenabled;
extern void check_x2apic(void);
extern void enable_x2apic(void);
extern void x2apic_icr_write(u32 low, u32 id);
@@ -198,6 +199,9 @@ static inline void x2apic_force_phys(void)
x2apic_phys = 1;
}
#else
+static inline void disable_x2apic(void)
+{
+}
static inline void check_x2apic(void)
{
}
diff --git a/arch/x86/include/asm/apicdef.h b/arch/x86/include/asm/apicdef.h
index 3925d80..134bba0 100644
--- a/arch/x86/include/asm/apicdef.h
+++ b/arch/x86/include/asm/apicdef.h
@@ -144,6 +144,7 @@
#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
#define APIC_BASE_MSR 0x800
+#define XAPIC_ENABLE (1UL << 11)
#define X2APIC_ENABLE (1UL << 10)
#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 0783236..2c07aeb 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -146,7 +146,8 @@ __setup("apicpmtimer", setup_apicpmtimer);
int x2apic_mode;
#ifdef CONFIG_X86_X2APIC
/* x2apic enabled before OS handover */
-static int x2apic_preenabled;
+int x2apic_preenabled;
+static int x2apic_disabled;
static __init int setup_nox2apic(char *str)
{
if (x2apic_enabled()) {
@@ -1432,6 +1433,40 @@ void __init bsp_end_local_APIC_setup(void)
}
#ifdef CONFIG_X86_X2APIC
+/*
+ * Need to disable xapic and x2apic at the same time and then enable xapic mode
+ */
+static inline void __disable_x2apic(u64 msr)
+{
+ wrmsrl(MSR_IA32_APICBASE,
+ msr & ~(X2APIC_ENABLE | XAPIC_ENABLE));
+ wrmsrl(MSR_IA32_APICBASE, msr & ~X2APIC_ENABLE);
+}
+
+static void disable_x2apic(void)
+{
+ u64 msr;
+
+ if (!cpu_has_x2apic)
+ return;
+
+ rdmsrl(MSR_IA32_APICBASE, msr);
+ if (msr & X2APIC_ENABLE) {
+ u32 x2apic_id = read_apic_id();
+
+ if (x2apic_id >= 255)
+ panic("Cannot disable x2apic, id: %08x\n", x2apic_id);
+
+ pr_info("Disabling x2apic\n");
+ __disable_x2apic(msr);
+
+ x2apic_disabled = 1;
+ x2apic_mode = 0;
+
+ register_lapic_address(mp_lapic_addr);
+ }
+}
+
void check_x2apic(void)
{
if (x2apic_enabled()) {
@@ -1442,15 +1477,20 @@ void check_x2apic(void)
void enable_x2apic(void)
{
- int msr, msr2;
+ u64 msr;
+
+ rdmsrl(MSR_IA32_APICBASE, msr);
+ if (x2apic_disabled) {
+ __disable_x2apic(msr);
+ return;
+ }
if (!x2apic_mode)
return;
- rdmsr(MSR_IA32_APICBASE, msr, msr2);
if (!(msr & X2APIC_ENABLE)) {
printk_once(KERN_INFO "Enabling x2apic\n");
- wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, msr2);
+ wrmsrl(MSR_IA32_APICBASE, msr | X2APIC_ENABLE);
}
}
#endif /* CONFIG_X86_X2APIC */
@@ -1487,7 +1527,7 @@ void __init enable_IR_x2apic(void)
ret = save_ioapic_entries();
if (ret) {
pr_info("Saving IO-APIC state failed: %d\n", ret);
- goto out;
+ return;
}
local_irq_save(flags);
@@ -1499,13 +1539,19 @@ void __init enable_IR_x2apic(void)
else
ret = enable_IR();
+ if (!x2apic_supported())
+ goto nox2apic;
+
if (ret < 0) {
/* IR is required if there is APIC ID > 255 even when running
* under KVM
*/
if (max_physical_apicid > 255 ||
- !hypervisor_x2apic_available())
+ !hypervisor_x2apic_available()) {
+ if (x2apic_preenabled)
+ disable_x2apic();
goto nox2apic;
+ }
/*
* without IR all CPUs can be addressed by IOAPIC/MSI
* only in physical mode
@@ -1513,8 +1559,10 @@ void __init enable_IR_x2apic(void)
x2apic_force_phys();
}
- if (ret == IRQ_REMAP_XAPIC_MODE)
+ if (ret == IRQ_REMAP_XAPIC_MODE) {
+ pr_info("x2apic not enabled, IRQ remapping is in xapic mode\n");
goto nox2apic;
+ }
x2apic_enabled = 1;
@@ -1529,17 +1577,6 @@ nox2apic:
restore_ioapic_entries();
legacy_pic->restore_mask();
local_irq_restore(flags);
-
-out:
- if (x2apic_enabled || !x2apic_supported())
- return;
-
- if (x2apic_preenabled)
- panic("x2apic: enabled by BIOS but kernel init failed.");
- else if (ret == IRQ_REMAP_XAPIC_MODE)
- pr_info("x2apic not enabled, IRQ remapping is in xapic mode\n");
- else if (ret < 0)
- pr_info("x2apic not enabled, IRQ remapping init failed\n");
}
#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 6d939d7..45b461f 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2948,6 +2948,10 @@ static inline void __init check_timer(void)
}
local_irq_disable();
apic_printk(APIC_QUIET, KERN_INFO "..... failed :(.\n");
+ if (x2apic_preenabled)
+ apic_printk(APIC_QUIET, KERN_INFO
+ "Perhaps problem with the pre-enabled x2apic mode\n"
+ "Try booting with x2apic and interrupt-remapping disabled in the bios.\n");
panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a "
"report. Then try booting with the 'noapic' option.\n");
out:
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:x86/apic] x86, x2apic: Allow "nox2apic" to disable x2apic mode setup by BIOS
2011-12-22 7:24 ` Yinghai Lu
2011-12-23 19:01 ` Suresh Siddha
@ 2011-12-23 20:13 ` tip-bot for Yinghai Lu
1 sibling, 0 replies; 13+ messages in thread
From: tip-bot for Yinghai Lu @ 2011-12-23 20:13 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, yinghai, suresh.b.siddha, tglx, hpa
Commit-ID: a31bc32760992a2c68f3d6bf7da9f760c0fd7c41
Gitweb: http://git.kernel.org/tip/a31bc32760992a2c68f3d6bf7da9f760c0fd7c41
Author: Yinghai Lu <yinghai@kernel.org>
AuthorDate: Fri, 23 Dec 2011 11:01:43 -0800
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 23 Dec 2011 11:01:43 -0800
x86, x2apic: Allow "nox2apic" to disable x2apic mode setup by BIOS
Currently "nox2apic" boot parameter was not enabling x2apic mode if the cpu,
kernel are all capable of enabling x2apic mode and the OS handover
happened in xapic mode.
However If the bios enabled x2apic prior to OS handover, using "nox2apic"
boot parameter had no effect.
If the boot cpu's apicid is < 255, enable "nox2apic" boot parameter to
disable the x2apic mode setup by the bios. This will enable the kernel to
fallback to xapic mode and bringup only the cpu's which has apic-id < 255.
-v2: fix patch error and two compiling warning
make disable_x2apic to be __init
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/CAE9FiQUeB-3uxJAMiHsz=uPWoFv5Hg1pVepz7aU6YtqOxMC-=Q@mail.gmail.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/include/asm/apic.h | 1 +
arch/x86/kernel/apic/apic.c | 37 +++++++++++++++++++++++++++----------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index a12d571..3ab9bdd 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -216,6 +216,7 @@ static inline void x2apic_force_phys(void)
{
}
+#define nox2apic 0
#define x2apic_preenabled 0
#define x2apic_supported() 0
#endif
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2c07aeb..ff69d5d 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -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);
@@ -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;
@@ -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;
@@ -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
@@ -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
@@ -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;
@@ -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();
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:x86/apic] x86: Skip cpus with apic-ids >= 255 in !x2apic_mode
2011-12-22 1:45 ` [patch 5/5] x86: skip cpus with apic-ids >= 255 in !x2apic_mode Suresh Siddha
@ 2011-12-23 20:13 ` tip-bot for Suresh Siddha
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Suresh Siddha @ 2011-12-23 20:13 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, suresh.b.siddha, tglx, hpa
Commit-ID: c284b42abadbb22083bfde24d308899c08d44ffa
Gitweb: http://git.kernel.org/tip/c284b42abadbb22083bfde24d308899c08d44ffa
Author: Suresh Siddha <suresh.b.siddha@intel.com>
AuthorDate: Wed, 21 Dec 2011 17:45:19 -0800
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 23 Dec 2011 11:01:49 -0800
x86: Skip cpus with apic-ids >= 255 in !x2apic_mode
If the x2apic mode is disabled for reasons like interrupt-remapping
not available etc, then we need to skip the logical cpu bringup of
apic-id's >= 255. Otherwise as the platform is in xapic mode, init/startup
IPI's will consider only the low 8-bits and there is a possibility of
re-sending init/startup IPI's to the logical cpu that is already online.
This will avoid potential reboots/unpredictable behavior etc.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/20111222014632.702932458@sbsiddha-desk.sc.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/smpboot.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 9f548cb..e38e217 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -840,7 +840,8 @@ int __cpuinit native_cpu_up(unsigned int cpu)
pr_debug("++++++++++++++++++++=_---CPU UP %u\n", cpu);
if (apicid == BAD_APICID || apicid == boot_cpu_physical_apicid ||
- !physid_isset(apicid, phys_cpu_present_map)) {
+ !physid_isset(apicid, phys_cpu_present_map) ||
+ (!x2apic_mode && apicid >= 255)) {
printk(KERN_ERR "%s: bad cpu %d\n", __func__, cpu);
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-12-23 20:14 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-22 1:45 [patch 0/5] x86: allow pre-enabled x2apic mode to be disabled Suresh Siddha
2011-12-22 1:45 ` [patch 1/5] x86, apic: add probe() for apic_flat Suresh Siddha
2011-12-23 20:10 ` [tip:x86/apic] x86, apic: Add " tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 2/5] x86, acpi: skip acpi x2apic entries if the x2apic feature is not present Suresh Siddha
2011-12-23 20:11 ` [tip:x86/apic] x86, acpi: Skip " tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 3/5] x86, x2apic: fallback to xapic when bios doesnt setup interrupt-remapping Suresh Siddha
2011-12-23 20:12 ` [tip:x86/apic] x86, x2apic: Fallback to xapic when BIOS doesn' t " tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 4/5] x86, x2apic: allow "nox2apic" to disable x2apic mode setup by bios Suresh Siddha
2011-12-22 7:24 ` Yinghai Lu
2011-12-23 19:01 ` Suresh Siddha
2011-12-23 20:13 ` [tip:x86/apic] x86, x2apic: Allow "nox2apic" to disable x2apic mode setup by BIOS tip-bot for Yinghai Lu
2011-12-22 1:45 ` [patch 5/5] x86: skip cpus with apic-ids >= 255 in !x2apic_mode Suresh Siddha
2011-12-23 20:13 ` [tip:x86/apic] x86: Skip " tip-bot for Suresh Siddha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox