diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-09-17 22:22:31 -0700 |
---|---|---|
committer | Yinghai Lu <yinghai@kernel.org> | 2012-09-17 22:22:31 -0700 |
commit | d01f579d9ced1a8cf3816a5087a09e3cb3475b3c (patch) | |
tree | a0fa514d0d666b888023446fb80009d4d9350914 | |
parent | aeaa2da417ef0440d2930545938cb1deff21cc5c (diff) | |
download | linux-yinghai-d01f579d9ced1a8cf3816a5087a09e3cb3475b3c.tar.gz |
x86, irq: more strict check for register ioapic
1. check overlaping gsi range
for hotplug ioapic case, BIOS may have some entries in MADT
and also in pci bus with _GSB.
2. make bad_ioapics take idx instead of nr_ioapics.
for hotadd ioapic could find spare slot in the middle later.
3. check if entries in right range.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 516ca2420d18d..0b1938f7aa780 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -3913,7 +3913,7 @@ void __init ioapic_insert_resources(void) } } -int mp_find_ioapic(u32 gsi) +static int __mp_find_ioapic(u32 gsi, bool quiet) { int i = 0; @@ -3928,10 +3928,17 @@ int mp_find_ioapic(u32 gsi) return i; } - printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi); + if (!quiet) + printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", + gsi); return -1; } +int mp_find_ioapic(u32 gsi) +{ + return __mp_find_ioapic(gsi, false); +} + int mp_find_ioapic_pin(int ioapic, u32 gsi) { struct mp_ioapic_gsi *gsi_cfg; @@ -3946,11 +3953,11 @@ int mp_find_ioapic_pin(int ioapic, u32 gsi) return gsi - gsi_cfg->gsi_base; } -static __init int bad_ioapic(unsigned long address) +static __init int bad_ioapic(int idx, unsigned long address) { - if (nr_ioapics >= MAX_IO_APICS) { + if (idx >= MAX_IO_APICS) { pr_warn("WARNING: Max # of I/O APICs (%d) exceeded (found %d), skipping\n", - MAX_IO_APICS, nr_ioapics); + MAX_IO_APICS, idx); return 1; } if (!address) { @@ -3981,14 +3988,17 @@ static __init int bad_ioapic_register(int idx) void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) { - int idx = 0; + int idx; int entries; struct mp_ioapic_gsi *gsi_cfg; - if (bad_ioapic(address)) + idx = __mp_find_ioapic(gsi_base, true); + if (idx >= 0) return; idx = nr_ioapics; + if (bad_ioapic(idx, address)) + return; ioapics[idx].mp_config.type = MP_IOAPIC; ioapics[idx].mp_config.flags = MPC_APIC_USABLE; @@ -4009,6 +4019,12 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) * and to prevent reprogramming of IOAPIC pins (PCI GSIs). */ entries = io_apic_get_redir_entries(idx); + + if (!entries || entries > MP_MAX_IOAPIC_PIN) { + clear_fixmap(FIX_IO_APIC_BASE_0 + idx); + return; + } + gsi_cfg = mp_ioapic_gsi_routing(idx); gsi_cfg->gsi_base = gsi_base; gsi_cfg->gsi_end = gsi_base + entries - 1; |