• Suresh Siddha's avatar
    x86, ioapic: initialize nr_ioapic_registers early in mp_register_ioapic() · dadd486a
    Suresh Siddha authored
    Lin Bao reported that one of the HP platforms failed to boot
    2.6.32 kernel, when the BIOS enabled interrupt-remapping and
    x2apic before handing over the control to the Linux kernel.
    
    During boot, Linux kernel masks all the interrupt sources
    (8259, IO-APIC RTE's), setup the interrupt-remapping hardware
    with the OS controlled table and unmasks the 8259 interrupts
    but not the IO-APIC RTE's (as the newly setup interrupt-remapping
    table and the IO-APIC RTE's are not yet programmed by the kernel).
    
    Shortly after this, IO-APIC RTE's and the interrupt-remapping table
    entries are programmed based on the ACPI tables etc. So the
    expectation is that any interrupt during this window will be dropped
    and not see the intermediate configuration.
    
    In the reported problematic case, BIOS has configured the IO-APIC
    in virtual wire-B mode. Between the window of the kernel setting up
    new interrupt-remapping table  and the IO-APIC RTE's are properly
    configured, an interrupt gets routed by the IO-APIC RTE (setup
    by the virtual wire-B configuration) and sees the empty
    interrupt-remapping table entry, resulting in vt-d fault causing
    the platform to generate NMI. And the OS panics on this unexpected NMI.
    
    This problem doesn't happen with more recent kernels and closer
    look at the 2.6.32 kernel shows that the code which masks
    the IO-APIC RTE's is not working as expected as the nr_ioapic_registers
    for each IO-APIC is not yet initialized at this point. In the later
    kernels we initialize nr_ioapic_registers much before and
    everything works as expected.
    
    For 2.6.[32..34] kernels, fix this issue by initializing
    nr_ioapic_registers early in mp_register_ioapic()
    
    [ Relevant upstream commit info:
      commit 7716a5c4
      Author: Eric W. Biederman <ebiederm@xmission.com>
      Date:   Tue Mar 30 01:07:12 2010 -0700
    
        x86, ioapic: Move nr_ioapic_registers calculation to mp_register_ioapic.
    
      As the upstream commit depends on quite a few prior commits
      and some followup fixes in the mainline, we just picked
      the smallest relevant hunk for fixing the issue at hand.
      Problematic platform uses ACPI for IO-APIC, VT-d enumeration etc
      and this hunk only touches the ACPI based platforms.
    
      nr_ioapic_reigsters initialization in enable_IO_APIC() is still
      retained, so that other configurations like legacy MPS table based
      enumeration etc works with no change.
    ]
    Reported-and-tested-by: default avatarZhang, Lin-Bao <linbao.zhang@hp.com>
    Signed-off-by: default avatarSuresh Siddha <suresh.b.siddha@intel.com>
    Cc: stable@vger.kernel.org
    Reviewed-by: default avatarJonathan Nieder <jrnieder@gmail.com>
    Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
    dadd486a
io_apic.c 102 KB