:: commit ebde1ee08674bb814d751804b659fcad655423cf

Mintsuki <mintsuki@protonmail.com> — 2026-02-08 15:14

parents: b5eae051b4

sys/smp: Send two SIPIs per Intel SDM recommendation for AP startup

diff --git a/common/sys/smp.c b/common/sys/smp.c
index 13b29eed..bd33f1d4 100644
--- a/common/sys/smp.c
+++ b/common/sys/smp.c
@@ -84,13 +84,16 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
     }
     delay(10000000);
 
-    // Send the Startup IPI
-    if (x2apic) {
-        x2apic_write(LAPIC_REG_ICR0, ((uint64_t)lapic_id << 32) |
-                                     ((size_t)trampoline / 4096) | 0x4600);
-    } else {
-        lapic_write(LAPIC_REG_ICR1, lapic_id << 24);
-        lapic_write(LAPIC_REG_ICR0, ((size_t)trampoline / 4096) | 0x4600);
+    // Send two Startup IPIs per Intel SDM recommendation (Vol 3, 8.4.4.1)
+    for (int j = 0; j < 2; j++) {
+        if (x2apic) {
+            x2apic_write(LAPIC_REG_ICR0, ((uint64_t)lapic_id << 32) |
+                                         ((size_t)trampoline / 4096) | 0x4600);
+        } else {
+            lapic_write(LAPIC_REG_ICR1, lapic_id << 24);
+            lapic_write(LAPIC_REG_ICR0, ((size_t)trampoline / 4096) | 0x4600);
+        }
+        delay(200000); // ~200 us
     }
 
     for (int i = 0; i < 100; i++) {
tab: 248 wrap: offon