From 319835abb8517fde84bff31740fb1e61b33a3ae8 Mon Sep 17 00:00:00 2001 From: Ray Ni Date: Tue, 18 Apr 2023 17:41:21 +0800 Subject: [PATCH] UefiCpuPkg/MpInitLib: Skip X2APIC enabling when BSP in X2APIC already The BSP's APIC mode is synced to all APs in CollectProcessorCount(). So, it's safe to skip the X2 APIC enabling in AutoEnableX2Apic() which runs later when BSP's APIC mode is X2 APIC already. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 4e28ff3fe4..67e8556a4a 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -2248,7 +2248,9 @@ MpInitLibInitialize ( // // Enable X2APIC if needed. // - AutoEnableX2Apic (CpuMpData); + if (CpuMpData->InitialBspApicMode == LOCAL_APIC_MODE_XAPIC) { + AutoEnableX2Apic (CpuMpData); + } // // Sort BSP/Aps by CPU APIC ID in ascending order