mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 07:04:28 +02:00
UefiCpuPkg/CpuMpPei: Parallel get stack base for better performance.
Parallel run the function GetStackBase for all APs for better performance. Reviewed-by: Ray Ni <ray.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Daoxiang Li <daoxiang.li@intel.com> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
This commit is contained in:
parent
e449451770
commit
e8166a852e
@ -267,13 +267,15 @@ GetStackBase (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PHYSICAL_ADDRESS StackBase;
|
EFI_PHYSICAL_ADDRESS StackBase;
|
||||||
|
UINTN Index;
|
||||||
|
|
||||||
|
MpInitLibWhoAmI (&Index);
|
||||||
StackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)&StackBase;
|
StackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)&StackBase;
|
||||||
StackBase += BASE_4KB;
|
StackBase += BASE_4KB;
|
||||||
StackBase &= ~((EFI_PHYSICAL_ADDRESS)BASE_4KB - 1);
|
StackBase &= ~((EFI_PHYSICAL_ADDRESS)BASE_4KB - 1);
|
||||||
StackBase -= PcdGet32 (PcdCpuApStackSize);
|
StackBase -= PcdGet32 (PcdCpuApStackSize);
|
||||||
|
|
||||||
*(EFI_PHYSICAL_ADDRESS *)Buffer = StackBase;
|
*((EFI_PHYSICAL_ADDRESS *)Buffer + Index) = StackBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,7 +289,7 @@ SetupStackGuardPage (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PEI_HOB_POINTERS Hob;
|
EFI_PEI_HOB_POINTERS Hob;
|
||||||
EFI_PHYSICAL_ADDRESS StackBase;
|
EFI_PHYSICAL_ADDRESS *StackBase;
|
||||||
UINTN NumberOfProcessors;
|
UINTN NumberOfProcessors;
|
||||||
UINTN Bsp;
|
UINTN Bsp;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
@ -308,11 +310,15 @@ SetupStackGuardPage (
|
|||||||
NumberOfProcessors = 1;
|
NumberOfProcessors = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MpInitLibWhoAmI (&Bsp);
|
StackBase = (EFI_PHYSICAL_ADDRESS *)AllocatePages (EFI_SIZE_TO_PAGES (sizeof (EFI_PHYSICAL_ADDRESS) * NumberOfProcessors));
|
||||||
for (Index = 0; Index < NumberOfProcessors; ++Index) {
|
ASSERT (StackBase != NULL);
|
||||||
StackBase = 0;
|
if (StackBase == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Index == Bsp) {
|
ZeroMem (StackBase, sizeof (EFI_PHYSICAL_ADDRESS) * NumberOfProcessors);
|
||||||
|
MpInitLibStartupAllAPs (GetStackBase, FALSE, NULL, 0, (VOID *)StackBase, NULL);
|
||||||
|
MpInitLibWhoAmI (&Bsp);
|
||||||
Hob.Raw = GetHobList ();
|
Hob.Raw = GetHobList ();
|
||||||
while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
|
while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
|
||||||
if (CompareGuid (
|
if (CompareGuid (
|
||||||
@ -320,32 +326,28 @@ SetupStackGuardPage (
|
|||||||
&(Hob.MemoryAllocationStack->AllocDescriptor.Name)
|
&(Hob.MemoryAllocationStack->AllocDescriptor.Name)
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
StackBase = Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress;
|
StackBase[Bsp] = Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Ask AP to return is stack base address.
|
|
||||||
//
|
|
||||||
MpInitLibStartupThisAP (GetStackBase, Index, NULL, 0, (VOID *)&StackBase, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT (StackBase != 0);
|
for (Index = 0; Index < NumberOfProcessors; ++Index) {
|
||||||
|
ASSERT (StackBase[Index] != 0);
|
||||||
//
|
//
|
||||||
// Set Guard page at stack base address.
|
// Set Guard page at stack base address.
|
||||||
//
|
//
|
||||||
ConvertMemoryPageToNotPresent (StackBase, EFI_PAGE_SIZE);
|
ConvertMemoryPageToNotPresent (StackBase[Index], EFI_PAGE_SIZE);
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"Stack Guard set at %lx [cpu%lu]!\n",
|
"Stack Guard set at %lx [cpu%lu]!\n",
|
||||||
(UINT64)StackBase,
|
(UINT64)StackBase[Index],
|
||||||
(UINT64)Index
|
(UINT64)Index
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FreePages (StackBase, EFI_SIZE_TO_PAGES (sizeof (EFI_PHYSICAL_ADDRESS) * NumberOfProcessors));
|
||||||
//
|
//
|
||||||
// Publish the changes of page table.
|
// Publish the changes of page table.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user