Kyösti Mälkki has submitted this change. ( https://review.coreboot.org/c/coreboot/+/60213 )
Change subject: cpu/x86/lapic: Fix choice X2APIC_ONLY ......................................................................
cpu/x86/lapic: Fix choice X2APIC_ONLY
When sending self an IPI, some instructions may be processed before IPI is serviced. Spend some time doing nothing, to avoid entering a printk() and acquiring console_lock and dead-locking.
Change-Id: I78070ae91e78c11c3e3aa225e5673d4667d6f7bb Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/60213 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Arthur Heymans arthur@aheymans.xyz --- M src/include/cpu/x86/lapic.h 1 file changed, 8 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Arthur Heymans: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve
diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index c1603f2..e131d2e 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -145,8 +145,16 @@
static __always_inline void lapic_send_ipi_self(uint32_t icrlow) { + int i = 1000; + /* LAPIC_DEST_SELF does not support all delivery mode -fields. */ lapic_send_ipi(icrlow, lapicid()); + + /* In case of X2APIC force a short delay, to prevent deadlock in a case + * the immediately following code acquires some lock, like with printk(). + */ + while (CONFIG(X2APIC_ONLY) && i--) + cpu_relax(); }
static __always_inline void lapic_send_ipi_others(uint32_t icrlow)