x86/smpboot: Init apic mapping before usage

The recent changes, which forced the registration of the boot cpu on UP
systems, which do not have ACPI tables, have been fixed for systems w/o
local APIC, but left a wreckage for systems which have neither ACPI nor
mptables, but the CPU has an APIC, e.g. virtualbox.

The boot process crashes in prefill_possible_map() as it wants to register
the boot cpu, which needs to access the local apic, but the local APIC is
not yet mapped.

There is no reason why init_apic_mapping() can't be invoked before
prefill_possible_map(). So instead of playing another silly early mapping
game, as the ACPI/mptables code does, we just move init_apic_mapping()
before the call to prefill_possible_map().

In hindsight, I should have noticed that combination earlier.

Sorry for the churn (also in stable)!

Fixes: ff8560512b8d ("x86/boot/smp: Don't try to poke disabled/non-existent APIC")
Reported-and-debugged-by: Michal Necasek <michal.necasek@oracle.com>
Reported-and-tested-by: Wolfgang Bauer <wbauer@tmo.at>
Cc: prarit@redhat.com
Cc: ville.syrjala@linux.intel.com
Cc: michael.thayer@oracle.com
Cc: knut.osmundsen@oracle.com
Cc: frank.mehnert@oracle.com
Cc: Borislav Petkov <bp@alien8.de>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1610282114380.5053@nanos
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Changed files
+6 -1
arch
x86
kernel
+6 -1
arch/x86/kernel/setup.c
··· 1221 1221 */ 1222 1222 get_smp_config(); 1223 1223 1224 + /* 1225 + * Systems w/o ACPI and mptables might not have it mapped the local 1226 + * APIC yet, but prefill_possible_map() might need to access it. 1227 + */ 1228 + init_apic_mappings(); 1229 + 1224 1230 prefill_possible_map(); 1225 1231 1226 1232 init_cpu_to_node(); 1227 1233 1228 - init_apic_mappings(); 1229 1234 io_apic_init_mappings(); 1230 1235 1231 1236 kvm_guest_init();