* [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu
@ 2021-01-14 13:12 Ni, Ray
2021-01-14 18:29 ` Laszlo Ersek
2021-01-19 14:18 ` Dong, Eric
0 siblings, 2 replies; 3+ messages in thread
From: Ni, Ray @ 2021-01-14 13:12 UTC (permalink / raw)
To: devel; +Cc: Eric Dong, Laszlo Ersek, Rahul Kumar
When StackGuard is enabled, the CpuMp driver allocates
known good stacks for all CPUs for DF# and PF# exceptions.
It uses AllocatePool to do so.
The size needed equals to 64KB
= StackSize (2K) * ExceptionNumber (2) * NumberOfProcessors (16)
However, AllocatePool max allocation size is less than 64K.
To fix the issue, AllocatePages() is used.
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
UefiCpuPkg/CpuMpPei/CpuMpPei.c | 10 +++-------
UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 ++-
UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 ++-
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index d07540cf74..40729a09b9 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -1,7 +1,7 @@
/** @file
CPU PEI Module installs CPU Multiple Processor PPI.
- Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers (
ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);
NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
- Status = PeiServicesAllocatePool (
- NewStackSize * NumberOfProcessors,
- (VOID **)&StackTop
- );
+ StackTop = AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfProcessors));
ASSERT(StackTop != NULL);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
+ if (StackTop == NULL) {
return;
}
StackTop += NewStackSize * NumberOfProcessors;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 6a481a84dc..c6870656ca 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -1,7 +1,7 @@
/** @file
Definitions to install Multiple Processor PPI.
- Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -27,6 +27,7 @@
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/MpInitLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index 7e511325d8..ba829d816e 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -1,7 +1,7 @@
## @file
# CPU driver installs CPU PI Multi-processor PPI.
#
-# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -45,6 +45,7 @@ [LibraryClasses]
MpInitLib
BaseMemoryLib
CpuLib
+ MemoryAllocationLib
[Guids]
gEdkiiMigratedFvInfoGuid ## SOMETIMES_CONSUMES ## HOB
--
2.27.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu
2021-01-14 13:12 [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu Ni, Ray
@ 2021-01-14 18:29 ` Laszlo Ersek
2021-01-19 14:18 ` Dong, Eric
1 sibling, 0 replies; 3+ messages in thread
From: Laszlo Ersek @ 2021-01-14 18:29 UTC (permalink / raw)
To: Ray Ni, devel; +Cc: Eric Dong, Rahul Kumar
On 01/14/21 14:12, Ray Ni wrote:
> When StackGuard is enabled, the CpuMp driver allocates
> known good stacks for all CPUs for DF# and PF# exceptions.
> It uses AllocatePool to do so.
>
> The size needed equals to 64KB
> = StackSize (2K) * ExceptionNumber (2) * NumberOfProcessors (16)
>
> However, AllocatePool max allocation size is less than 64K.
> To fix the issue, AllocatePages() is used.
>
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> ---
> UefiCpuPkg/CpuMpPei/CpuMpPei.c | 10 +++-------
> UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 ++-
> UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 ++-
> 3 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
> index d07540cf74..40729a09b9 100644
> --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
> +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
> @@ -1,7 +1,7 @@
> /** @file
> CPU PEI Module installs CPU Multiple Processor PPI.
>
> - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers (
> ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);
> NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
>
> - Status = PeiServicesAllocatePool (
> - NewStackSize * NumberOfProcessors,
> - (VOID **)&StackTop
> - );
> + StackTop = AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfProcessors));
> ASSERT(StackTop != NULL);
> - if (EFI_ERROR (Status)) {
> - ASSERT_EFI_ERROR (Status);
> + if (StackTop == NULL) {
> return;
> }
> StackTop += NewStackSize * NumberOfProcessors;
> diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
> index 6a481a84dc..c6870656ca 100644
> --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
> +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
> @@ -1,7 +1,7 @@
> /** @file
> Definitions to install Multiple Processor PPI.
>
> - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -27,6 +27,7 @@
> #include <Library/CpuExceptionHandlerLib.h>
> #include <Library/MpInitLib.h>
> #include <Library/BaseMemoryLib.h>
> +#include <Library/MemoryAllocationLib.h>
>
> extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;
>
> diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> index 7e511325d8..ba829d816e 100644
> --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> @@ -1,7 +1,7 @@
> ## @file
> # CPU driver installs CPU PI Multi-processor PPI.
> #
> -# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> ##
> @@ -45,6 +45,7 @@ [LibraryClasses]
> MpInitLib
> BaseMemoryLib
> CpuLib
> + MemoryAllocationLib
>
> [Guids]
> gEdkiiMigratedFvInfoGuid ## SOMETIMES_CONSUMES ## HOB
>
Please link <https://bugzilla.tianocore.org/show_bug.cgi?id=3167> into
the commit message.
Additionally, please add a link, pointing to this message in the list
archive, to BZ#3167.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks
Laszlo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu
2021-01-14 13:12 [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu Ni, Ray
2021-01-14 18:29 ` Laszlo Ersek
@ 2021-01-19 14:18 ` Dong, Eric
1 sibling, 0 replies; 3+ messages in thread
From: Dong, Eric @ 2021-01-19 14:18 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io; +Cc: Laszlo Ersek, Kumar, Rahul1
Reviewed-by: Eric Dong <eric.dong@intel.com>
-----Original Message-----
From: Ni, Ray <ray.ni@intel.com>
Sent: Thursday, January 14, 2021 9:12 PM
To: devel@edk2.groups.io
Cc: Dong, Eric <eric.dong@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
Subject: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu
When StackGuard is enabled, the CpuMp driver allocates
known good stacks for all CPUs for DF# and PF# exceptions.
It uses AllocatePool to do so.
The size needed equals to 64KB
= StackSize (2K) * ExceptionNumber (2) * NumberOfProcessors (16)
However, AllocatePool max allocation size is less than 64K.
To fix the issue, AllocatePages() is used.
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
UefiCpuPkg/CpuMpPei/CpuMpPei.c | 10 +++-------
UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 ++-
UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 ++-
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index d07540cf74..40729a09b9 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -1,7 +1,7 @@
/** @file
CPU PEI Module installs CPU Multiple Processor PPI.
- Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers (
ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);
NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
- Status = PeiServicesAllocatePool (
- NewStackSize * NumberOfProcessors,
- (VOID **)&StackTop
- );
+ StackTop = AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfProcessors));
ASSERT(StackTop != NULL);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
+ if (StackTop == NULL) {
return;
}
StackTop += NewStackSize * NumberOfProcessors;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 6a481a84dc..c6870656ca 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -1,7 +1,7 @@
/** @file
Definitions to install Multiple Processor PPI.
- Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -27,6 +27,7 @@
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/MpInitLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index 7e511325d8..ba829d816e 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -1,7 +1,7 @@
## @file
# CPU driver installs CPU PI Multi-processor PPI.
#
-# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -45,6 +45,7 @@ [LibraryClasses]
MpInitLib
BaseMemoryLib
CpuLib
+ MemoryAllocationLib
[Guids]
gEdkiiMigratedFvInfoGuid ## SOMETIMES_CONSUMES ## HOB
--
2.27.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-19 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-14 13:12 [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu Ni, Ray
2021-01-14 18:29 ` Laszlo Ersek
2021-01-19 14:18 ` Dong, Eric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox