TencentOS-kernel/arch/x86/kernel
Kairui Song 0f57be5819 x86/mpparse, kexec: switch apic driver early if x2apic is pre-enabled
Following kernel panic is observed when doing kexec/kdump on machines
that use mptable, and supports x2apic:

[    0.010090] Intel MultiProcessor Specification v1.4
[    0.010688] MPTABLE: OEM ID: BOCHSCPU
[    0.010886] MPTABLE: Product ID: 0.1
[    0.011119] MPTABLE: APIC at: 0xFEE00000
[    0.011332] BUG: unable to handle page fault for address: ffffffffff5fc020
[    0.011702] #PF: supervisor read access in kernel mode
[    0.011981] #PF: error_code(0x0000) - not-present page
[    0.012256] PGD 25e15067 P4D 25e15067 PUD 25e17067 PMD 25e18067 PTE 0
[    0.012603] Oops: 0000 [#1] SMP NOPTI
[    0.012801] CPU: 0 PID: 0 Comm: swapper Not tainted 5.14.10-300.fc35.x86_64 #1
[    0.013189] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1.fc35 04/01/2014
[    0.013658] RIP: 0010:native_apic_mem_read+0x2/0x10
[    0.013924] Code: 14 25 20 cd e3 82 c3 90 bf 30 08 00 00 ff 14 25 18 cd e3 82 c3 cc cc cc 89 ff 89 b7 00 c0 5f ff c3 0f 1f 80 00 00 00 00 89 ff <8b> 87 00 c0 5f ff c3 0f 1f 80 00 00 00 0
[    0.014930] RSP: 0000:ffffffff82e03e18 EFLAGS: 00010046
[    0.015211] RAX: ffffffff81064840 RBX: ffffffffff240b6c RCX: ffffffff82f17428
[    0.015593] RDX: c0000000ffffdfff RSI: 00000000ffffdfff RDI: 0000000000000020
[    0.015977] RBP: ffff888023200000 R08: 0000000000000000 R09: ffffffff82e03c50
[    0.016385] R10: ffffffff82e03c48 R11: ffffffff82f47468 R12: ffffffffff240b40
[    0.016768] R13: ffffffffff200b30 R14: 0000000000000000 R15: 00000000000000d4
[    0.017155] FS:  0000000000000000(0000) GS:ffffffff8365b000(0000) knlGS:0000000000000000
[    0.017589] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.017899] CR2: ffffffffff5fc020 CR3: 0000000025e10000 CR4: 00000000000006b0
[    0.018284] Call Trace:
[    0.018417]  ? read_apic_id+0x15/0x30
[    0.018616]  ? register_lapic_address+0x76/0x97
[    0.018864]  ? default_get_smp_config+0x28b/0x42d
[    0.019119]  ? dmi_check_system+0x1c/0x60
[    0.019337]  ? acpi_boot_init+0x1d/0x4c3
[    0.019550]  ? setup_arch+0xb37/0xc2a
[    0.019749]  ? slab_is_available+0x5/0x10
[    0.019969]  ? start_kernel+0x61/0x980
[    0.020173]  ? load_ucode_bsp+0x4c/0xcd
[    0.020380]  ? secondary_startup_64_no_verify+0xc2/0xcb
[    0.020664] Modules linked in:
[    0.020830] CR2: ffffffffff5fc020
[    0.021012] random: get_random_bytes called from oops_exit+0x35/0x60 with crng_init=0
[    0.021015] ---[ end trace c9e569df3bdbefd3 ]---

Checking following init order we have:

setup_arch()
  check_x2apic()     <-- x2apic is enabled by first kernel before kexec,
                         this set x2apic_mode = 1, make sure later probes
                         will recognize pre-enabled x2apic.
  ....
  acpi_boot_init();  <-- With ACPI MADT, this will switch apic driver
                         to x2apic, but it will do nothing with mptable.
  x86_dtb_init();
  get_smp_config();
    default_get_smp_config();
      check_physptr();
        smp_read_mpc();
          register_lapic_address(); <-- panic here
  init_apic_mappings();
  ....

The problem here is mpparse need to read some boot info from apic, so
calls register_lapic_address() early. But without MADT, apic driver
is still apic_flat, it attempts to use the MMIO interface which is
never mapped since: commit 0450193bffed6 ("x86, x2apic: Don't map lapic
addr for preenabled x2apic systems")

Simply map it won't work either as in x2apic mode the MMIO interface is
not really available (Intel SDM Volume 3A 10.12.2), later code will
fail with other errors. So here we do the apic driver probe early.
With pre-enabled x2apic, the probe will recognize it and switch to
the right driver just fine.

Such issue is currently only seen with kexec/kdump, which enabled the
x2apic in first kernel and kept it enabled to 2nd kernel.

This can be easily reproduced with qemu, use -no-acpi and enable x2apic.

Signed-off-by: Kairui Song <kasong@tencent.com>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
2022-06-09 10:01:21 +08:00
..
acpi ACPI: tables: x86: Reserve memory occupied by ACPI tables 2021-05-20 16:07:17 +08:00
apic x86/apic/of: Fix CPU devicetree-node lookups 2021-04-12 12:53:21 +08:00
cpu locking/qspinlock: Introduce llc aware spinlock 2021-12-20 11:43:06 +08:00
fpu x86/fpu: Add kernel_fpu_begin_mask() to selectively initialize state 2021-04-12 12:51:37 +08:00
kprobes x86/kprobes: Fix to check non boostable prefixes correctly 2021-05-20 16:07:52 +08:00
.gitignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Makefile Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
alternative.c locking/qspinlock: Introduce CNA into the slow path of qspinlock 2021-12-20 11:43:06 +08:00
amd_gart_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
amd_nb.c x86/amd_nb: Add AMD family 17h model 60h PCI IDs 2021-03-16 16:29:43 +08:00
apb_timer.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
aperture_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
apm_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
asm-offsets.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
asm-offsets_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
asm-offsets_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
audit_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
bootflag.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
check.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
cpuid.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
crash.c x86/crash: Fix crash_setup_memmap_entries() out-of-bounds access 2021-05-20 16:07:16 +08:00
crash_dump_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
crash_dump_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
devicetree.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
doublefault.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
dumpstack.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
dumpstack_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
dumpstack_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
e820.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
early-quirks.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
early_printk.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ebda.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
eisa.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
espfix_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ftrace.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ftrace_32.S x86/asm/32: Add ENDs to some functions and relabel with SYM_CODE_* 2021-04-12 12:51:15 +08:00
ftrace_64.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
head32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
head64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
head_32.S x86/asm/32: Add ENDs to some functions and relabel with SYM_CODE_* 2021-04-12 12:51:15 +08:00
head_64.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
hpet.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
hw_breakpoint.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
i8237.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
i8253.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
i8259.c x86/i8259: Use printk_deferred() to prevent deadlock 2021-03-16 16:32:57 +08:00
idt.c x86/idt: Keep spurious entries unset in system_vectors 2021-03-16 16:30:35 +08:00
ima_arch.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
io_delay.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ioport.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
irq.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
irq_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
irq_64.c x86: fix vmap arguments in map_irq_stack 2021-03-16 16:29:22 +08:00
irq_work.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
irqflags.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
irqinit.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
itmt.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
jailhouse.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
jump_label.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
kdebugfs.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
kexec-bzimage64.c x86/kexec: Use up-to-dated screen_info copy to fill boot params 2021-03-16 16:40:24 +08:00
kgdb.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ksysfs.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
kvm.c qspinlock: Diable virt_spin_lock for dedicated vm 2022-02-16 19:18:18 +08:00
kvmclock.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ldt.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
livepatch.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
machine_kexec_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
machine_kexec_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
mmconf-fam10h_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
module.c x86/build: Treat R_386_PLT32 relocation as R_386_PC32 2021-04-12 12:52:46 +08:00
mpparse.c x86/mpparse, kexec: switch apic driver early if x2apic is pre-enabled 2022-06-09 10:01:21 +08:00
msr.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
nmi.c x86/nmi: Fix nmi_handle() duration miscalculation 2021-03-16 16:38:23 +08:00
nmi_selftest.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
paravirt-spinlocks.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
paravirt.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
paravirt_patch.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pci-calgary_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pci-dma.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pci-iommu_table.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pci-swiotlb.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pcspeaker.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
perf_regs.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
platform-quirks.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pmem.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
probe_roms.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
process.c x86/process/64: Use FSGSBASE instructions on thread copy and ptrace 2021-08-17 06:29:11 +00:00
process.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
process_32.c x86/process: Unify copy_thread_tls() 2021-08-17 06:29:11 +00:00
process_64.c x86/process/64: Use FSBSBASE in switch_to() if available 2021-08-17 06:29:11 +00:00
ptrace.c x86/ptrace: Fix 32-bit PTRACE_SETREGS vs fsbase and gsbase 2021-08-17 06:29:11 +00:00
pvclock.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
quirks.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
reboot.c x86/reboot: Add Zotac ZBOX CI327 nano PCI reboot quirk 2021-04-12 12:52:46 +08:00
reboot_fixups_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
relocate_kernel_32.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
relocate_kernel_64.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
resource.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
rtc.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
setup.c x86: kdump: move reserve_crashkernel[_low]() into crash_core.c 2022-06-06 13:50:12 +08:00
setup_percpu.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
signal.c x86: Introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall() 2021-04-12 12:53:20 +08:00
signal_compat.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
smp.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
smpboot.c x86/hotplug: Silence APIC only after all interrupts are migrated 2021-03-16 16:35:14 +08:00
stacktrace.c x86/stacktrace: Fix reliable check for empty user task stacks 2021-03-16 16:32:56 +08:00
step.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sys_x86_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sysfb.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sysfb_efi.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sysfb_simplefb.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tboot.c iommu/vt-d: Avoid panic if iommu init fails in tboot system 2021-03-16 16:41:21 +08:00
tce_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
time.c x86_64: Fix jiffies ODR violation 2021-03-16 16:28:59 +08:00
tls.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tls.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
topology.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
trace_clock.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tracepoint.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
traps.c x86/traps: Attempt to fixup exceptions in vDSO before signaling 2021-07-12 08:56:46 +00:00
tsc.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tsc_msr.c x86/tsr: Fix tsc frequency enumeration bug on Lightning Mountain SoC 2021-03-16 16:34:19 +08:00
tsc_sync.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
umip.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
unwind_frame.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
unwind_guess.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
unwind_orc.c x86/unwind/orc: Disable KASAN checking in the ORC unwinder, part 2 2021-04-12 12:53:12 +08:00
uprobes.c x86/uprobes: Do not use prefixes.nbytes when looping over prefixes.bytes 2021-03-16 16:42:04 +08:00
verify_cpu.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
vm86_32.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
vmlinux.lds.S x86, vmlinux.lds: Page-align end of ..page_aligned sections 2021-03-16 16:32:39 +08:00
vsmp_64.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
x86_init.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00