kernel - Warn/assert on broken ACPI MADT * Add warnings and assertions for broken ACPI MADT tables. I encountered this trying to boot a 3990X on a motherboard with an old BIOS that didn't support it. It tried to boot anyway, but the MADT table was mangled and caused a null-pointer indirection in the kernel. Assert nicely instead.
x86_64: Implement x2apic support. Now LAPIC registers are accessed through MSR at fixed location, instead of going through MMIO region. Most noticeable is that ICR operation is greatly simplified, i.e. IPI sending operation: - Reserved bits are read as 0; there is no need to read ICR first for OR with the new values. - No more pending bit, i.e. ICR write is synchronized; there is no need to read ICR to test pending bit. - ICR is 64 bits in x2apic mode, i.e. two 32 bits writes to ICR-low and ICR-high become one write to ICR. NOTE: Though Intel SDM says that wrmsr to LAPIC registers are relaxed, we don't need to put mfence or sfence before them, especially for sending IPIs, since the generic IPIQ and the machdep code already uses atomic operation before doing ICR operation. For the rest of the code, there really are no needs to add mfence/sfence before rdmsr/wrmsr to LAPIC registers. As of this commit, x2apic mode is _not_ enabled by default. It can be enabled through hw.x2apic_enable tuneable, and a read-only sysctl node with the same name is available for debugging purpose. Based on work by ivadasz@.
x86_64: Prepare for x2apic support. - Use macro to access and modify LAPIC registers. - Use function pointers for hot LAPIC operation, i.e. IPI and timer. - Refactor the related code a bit. Global variable 'lapic' is renamed to 'lapic_mem' to ease code search. Based on work by ivadasz@.
kernel/acpi: Reduce code duplication with ACPICA (second attempt). Use the types which the ACPICA framework provides whereever possible in our acpi_fadt and acpi_madt code. Since we do not use any actual ACPICA functions here, this is no problem even for code which (so far) runs before ACPICA is initialized. Compared to the previous attempt which I pushed (and reverted again) this commit has the following additional fixes: * Compare the FADT length to the length of the ACPI 2.0 (up to 4.0) version of the table (which is 24 bytes shorter than the ACPI 5.0 version). * Doesn't shift again an already shifted value. Discussed-with-and-approved-by: sephe Tested-by: Robin Hahling <robin.hahling@gw-computing.net>
Revert "kernel/acpi: Reduce code duplication with ACPICA." This reverts commit fc673eaa749a01e148fc5f0b6e81587531576344. I did some mistakes here, one of which I found already. But there are more. So let's revert it for now (since it causes rather nasty issues) until the issues are all found. Reported-by: Robin Hahling <robin.hahling@gw-computing.net>
kernel/acpi: Reduce code duplication with ACPICA. Use the types which the ACPICA framework provides whereever possible in our acpi_fadt and acpi_madt code. Since we do not use any actual ACPICA functions here, this is no problem even for code which (so far) runs before ACPICA is initialized. Discussed-with-and-approved-by: sephe