SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.8k stars 3.18k forks source link

APIC Bare-Metal: freeze when sending SIPI to APs #7065

Open ElectrodeYT opened 3 years ago

ElectrodeYT commented 3 years ago

CC @tomuta When booting the APs on my test PC it freezes when sending the SIPI to the APs Fixes ive tried: Init/SIPI on each AP individually Increasing delay

ElectrodeYT commented 3 years ago

This line specifically causes the freeze: https://github.com/SerenityOS/serenity/blob/91eda222087048fef131a1bc39bcda947bce2288/Kernel/Interrupts/APIC.cpp#L352

ElectrodeYT commented 3 years ago

Log:

[Kernel]: CPU[0]: Supported features: pae pge sse tsc constant_tsc sep mmx sse2 sse3 ssse3
[Kernel]: CPU[0]: No RDRAND support detected, randomness will be poor
[Kernel]: CPU[0]: Physical address bit width: 36
[#0 Kernel]: Installing Unhandled Handlers
[Kernel]: MM: boot_pdpt @ P0x0010a000
[Kernel]: MM: boot_pd0 @ P0x0010b000
[Kernel]: MM: boot_pd3 @ P0x0010c000
[Kernel]: MM: Low memory range @ P0x00000000 - P0x00100000
[Kernel]: MM: Kernel range @ P0x00100000 - P0x00f89000
[Kernel]: MM: Multiboot mmap: address=0x00000000, length=651264, type=1
[Kernel]: MM: Multiboot mmap: address=0x0009f000, length=4096, type=2
[Kernel]: MM: Multiboot mmap: address=0x000f0000, length=65536, type=2
[Kernel]: MM: Multiboot mmap: address=0x00100000, length=1071579136, type=1
[Kernel]: MM: Multiboot mmap: address=0x3fef0000, length=12288, type=4
[Kernel]: MM: Multiboot mmap: address=0x3fef3000, length=53248, type=3
[Kernel]: MM: Multiboot mmap: address=0xf0000000, length=33554432, type=2
[Kernel]: MM: Multiboot mmap: address=0xfec00000, length=20971520, type=2
[Kernel]: MM: Super physical region: P0x00e89000 - P0x00f89000
[Kernel]: MM: User physical region: P0x00f8a000 - P0x3fef0000
[Kernel]: MM: Contiguous reserved range from P0x0009f000, length is 397312
[Kernel]: MM: Contiguous reserved range from P0xf0000000, length is 268435456
[#0 Kernel]: Early access to ACPI tables for interrupt setup
[Kernel]: Interrupts: Switch to IOAPIC mode
[#0 Kernel]: Interrupts: MADT @ P 0x3fef99c0
[Kernel]: PIC: Cascading mode, vectors 0x50-0x5f
[#0 Kernel]: IOAPIC found @ MADT entry 4, MMIO Registers @ P0xfec00000
[Kernel]: IOAPIC ID: 0x0
[Kernel]: IOAPIC Version: 0x11, redirection entries: 24
[Kernel]: IOAPIC Arbitration ID 0x0
[#0 Kernel]: Interrupts: Overriding INT 0x0 with GSI 2, for bus 0x0
[#0 Kernel]: Interrupts: Overriding INT 0x9 with GSI 9, for bus 0x0
[#0 Kernel]: Interrupts: Overriding INT 0xe with GSI 14, for bus 0x0
[#0 Kernel]: Interrupts: Overriding INT 0xf with GSI 15, for bus 0x0
[#0 Kernel]: Interrupts: Detected Dual i8259 - Disabled
[#0 Kernel]: Interrupts: Detected IOAPIC
[#0 Kernel]: MultiProcessor: Floating Pointer Structure @ P0x000f5dd0
[#0 Kernel]: Features 0, IMCR? 0
[#0 Kernel]: MultiProcessor: Get PCI IOAPIC redirections
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 40, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 44, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 45, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 3, polarity 15, trigger mode 0, INT 32, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 80, IOAPIC 4, IOAPIC INTIN 5
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 65, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 1, polarity 15, trigger mode 0, INT 1, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 1, polarity 15, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 60, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 0, polarity 15, trigger mode 0, INT 56, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 10, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 11, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 11, trigger mode 0, INT 1, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 3, polarity 15, PCI device 8, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 20, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 5
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 16, trigger mode 0, INT 1, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 1, polarity 15, PCI device 0, trigger mode 0, INT 1, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 1, polarity 15, PCI device 0, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 15, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 10
[#0 Kernel]: Interrupts: Bus 0, polarity 15, PCI device 14, trigger mode 0, INT 0, IOAPIC 4, IOAPIC INTIN 11
[#0 Kernel]: Initializing APIC, base: P0xfee00000
[#0 Kernel]: APIC: AP found @ MADT entry 0, processor ID: 0, APIC ID: 0, flags: 0x00000001
[#0 Kernel]: APIC: AP found @ MADT entry 1, processor ID: 1, APIC ID: 1, flags: 0x00000001
[#0 Kernel]: APIC: AP found @ MADT entry 2, processor ID: 2, APIC ID: 3, flags: 0x00000001
[#0 Kernel]: APIC: AP found @ MADT entry 3, processor ID: 3, APIC ID: 2, flags: 0x00000001
[#0 Kernel]: APIC processors found: 4, enabled: 4
[#0 Kernel]: Enabling local APIC for CPU #0, logical APIC ID: 0
[#0 Kernel]: Trying to unregister unused handler (?)
[#0 Kernel]: Trying to unregister unused handler (?)
[#0 Kernel]: Trying to unregister unused handler (?)
[Kernel]: ACPI: Using RSDP @ P0x000f7910
[Kernel]: ACPI: Main Description Table valid? true
[Kernel]: ACPI: Using XSDT, enumerating tables @ P0x3fef30c0
[Kernel]: ACPI: XSDT revision 1, total length: 76
[Kernel]: ACPI: Initializing Fixed ACPI data
[Kernel]: ACPI: Searching for the Fixed ACPI Data Table
[Kernel]: ACPI: Fixed ACPI data, Revision 3, length: 244 bytes
[Kernel]: ACPI: DSDT P0x3fef3240
[Kernel]: ACPI: Dynamic Parsing Enabled, Can parse AML
[Kernel]: Starting SerenityOS...
[Kernel]: RTC: Year: 2009, month: 1, day: 18, hour: 17, minute: 51, second: 8
[Kernel]: HPET @ P0x3fef9ac0
[Kernel]: HPET: Minimum clock tick - 250
[Kernel]: HPET: Timers count - 3
[Kernel]: HPET: Main counter size: 32-bit
[Kernel]: HPET: Timer[0] comparator size: 32-bit, mode: 32-bit
[Kernel]: HPET: Timer[1] comparator size: 32-bit, mode: 32-bit
[Kernel]: HPET: Timer[2] comparator size: 32-bit, mode: 32-bit
[Kernel]: HPET: frequency 25000000 Hz (25 MHz) resolution: 40 ns
[#0 Kernel]: Trying to unregister unused handler (?)
[#0 Kernel]: Trying to unregister unused handler (?)
[#0 Kernel]: HPET: Setting appropriate functions to timers.
[#0 Kernel]: Time: Scanning for periodic timers
[#0 Kernel]: HPET: Set comparator 0 to be periodic.
[#0 Kernel]: HPET: Disable comparator 0
[#0 Kernel]: HPET: Enable comparator 0
[#0 Kernel]: Time: Scanning for non-periodic timers
[#0 Kernel]: HPET: Update periodic comparator 0 comparator value to 100000 main value was: 1573765
[#0 Kernel]: Trying to unregister unused handler (?)
[Kernel]: APICTimer: Using HPET as calibration source
[Kernel]: KernelRng: Using HPET as entropy source
[Kernel]: APICTimer: Ticks per second: 266 (3.751120ms)
[Kernel]: APICTimer: Bus clock speed: 250.73120 MHz
[Kernel]: APICTimer: CPU clock speed: 2250.657720 MHz
[Kernel]: Time: Using APIC timer as system timer
[#0 Kernel]: HPET: Disable comparator 0
[#0 Kernel]: I8042: Dual channel controller
[Kernel]: PS2MouseDevice: Mouse wheel enabled!
[#0 Kernel]: Trying to unregister unused handler (?)
[#0 Kernel]: Trying to unregister unused handler (?)
[#0 Kernel]: VC: Switch to 0 (0xc0dcf750)
[#0 colonel(0:0)]: Scheduler[0]: idle loop running
[#0 init_stage2(2:2)]: top of init_stage2
[#0 init_stage2(2:2)]: booting aps
[#0 init_stage2(2:2)]: APIC: CPU[1] stack at V0xc1151000
[#0 init_stage2(2:2)]: APIC: CPU[2] stack at V0xc1162000
[#0 init_stage2(2:2)]: APIC: CPU[3] stack at V0xc1173000
[#0 init_stage2(2:2)]: APIC: CPU[1] processor at V0xc0ae5c24
[#0 init_stage2(2:2)]: APIC: CPU[2] processor at V0xc0ae6544
[#0 init_stage2(2:2)]: APIC: CPU[3] processor at V0xc0ae6e64
[#0 init_stage2(2:2)]: APIC: Starting 3 AP(s)
tomuta commented 3 years ago

So it freezes directly on that line? Maybe we are not initializing it correctly for that particular hardware.

ElectrodeYT commented 3 years ago

Possible. I have yet to investigate it more though.