OvmfPkg/PlatformInitLib: enable x2apic mode if needed

Enable x2apic mode in case the number of possible CPUs (including
hotplug-able CPus which are not (yet) online) is larger than 255.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2024-08-23 11:55:31 +02:00 committed by mergify[bot]
parent 800205678f
commit 8c8e05db24
2 changed files with 7 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include <Library/QemuFwCfgS3Lib.h> #include <Library/QemuFwCfgS3Lib.h>
#include <Library/QemuFwCfgSimpleParserLib.h> #include <Library/QemuFwCfgSimpleParserLib.h>
#include <Library/PciLib.h> #include <Library/PciLib.h>
#include <Library/LocalApicLib.h>
#include <Guid/SystemNvDataGuid.h> #include <Guid/SystemNvDataGuid.h>
#include <Guid/VariableFormat.h> #include <Guid/VariableFormat.h>
#include <OvmfPlatforms.h> #include <OvmfPlatforms.h>
@ -720,6 +721,11 @@ PlatformMaxCpuCountInitialization (
)); ));
ASSERT (BootCpuCount <= MaxCpuCount); ASSERT (BootCpuCount <= MaxCpuCount);
if (MaxCpuCount > 255) {
DEBUG ((DEBUG_INFO, "%a: enable x2apic mode\n", __func__));
SetApicMode (LOCAL_APIC_MODE_X2APIC);
}
PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber = MaxCpuCount; PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber = MaxCpuCount;
PlatformInfoHob->PcdCpuBootLogicalProcessorNumber = BootCpuCount; PlatformInfoHob->PcdCpuBootLogicalProcessorNumber = BootCpuCount;
} }

View File

@ -48,6 +48,7 @@
HobLib HobLib
QemuFwCfgLib QemuFwCfgLib
QemuFwCfgSimpleParserLib QemuFwCfgSimpleParserLib
LocalApicLib
MemEncryptSevLib MemEncryptSevLib
MemoryAllocationLib MemoryAllocationLib
MtrrLib MtrrLib