cpu/x86/lapic.h: Fix CONFIG_X2APIC_RUNTIME

The deadlock prevention is also needed with CONFIG_X2APIC_RUNTIME when
the cpu is in x2apic mode.

TESTED: Fixes SMI generation on xeon_sp hardware with
CONFIG_X2APIC_RUNTIME.

Change-Id: I6a71204fcff35e11613fc8363ce061b348e73496
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67239
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Zhang <jonzhang@fb.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h
index 5fa5608..cfb9c90 100644
--- a/src/include/cpu/x86/lapic.h
+++ b/src/include/cpu/x86/lapic.h
@@ -155,7 +155,9 @@
 	/* 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--)
+	const bool x2apic = is_x2apic_mode();
+
+	while (x2apic && i--)
 		cpu_relax();
 }