* [Patch v3 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API.
2019-07-24 7:07 [Patch v3 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
@ 2019-07-24 7:07 ` Dong, Eric
2019-07-26 10:36 ` [edk2-devel] " Laszlo Ersek
2019-07-24 7:07 ` [Patch v3 2/6] UefiCpuPkg/MpInitLib: " Dong, Eric
` (4 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Dong, Eric @ 2019-07-24 7:07 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
---
UefiCpuPkg/Include/Library/MpInitLib.h | 36 +++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h b/UefiCpuPkg/Include/Library/MpInitLib.h
index fa82529373..31eb227f12 100644
--- a/UefiCpuPkg/Include/Library/MpInitLib.h
+++ b/UefiCpuPkg/Include/Library/MpInitLib.h
@@ -1,7 +1,7 @@
/** @file
Multiple-Processor initialization Library.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -344,4 +344,38 @@ MpInitLibWhoAmI (
OUT UINTN *ProcessorNumber
);
+/**
+ This service executes a caller provided function on all enabled CPUs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system. See type
+ EFI_AP_PROCEDURE.
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
+ APs to return from Procedure, either for
+ blocking or non-blocking mode. Zero means
+ infinity. TimeoutInMicroseconds is ignored
+ for BSP.
+ @param[in] ProcedureArgument The parameter passed into Procedure for
+ all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all CPUs have finished before
+ the timeout expired.
+ @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
+ to all enabled CPUs.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_NOT_READY MP Initialize Library is not initialized.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+ all enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
#endif
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Patch v3 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API.
2019-07-24 7:07 [Patch v3 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
2019-07-24 7:07 ` [Patch v3 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API Dong, Eric
@ 2019-07-24 7:07 ` Dong, Eric
2019-07-26 10:36 ` [edk2-devel] " Laszlo Ersek
2019-07-24 7:07 ` [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Dong, Eric @ 2019-07-24 7:07 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
---
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 5 +-
UefiCpuPkg/Library/MpInitLib/MpLib.c | 61 +++++++++++++++++++++++--
UefiCpuPkg/Library/MpInitLib/MpLib.h | 6 ++-
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 5 +-
4 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 6be1bae464..b17e287bbf 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -1,7 +1,7 @@
/** @file
MP initialize support functions for DXE phase.
- Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -568,9 +568,10 @@ MpInitLibStartupAllAPs (
//
mStopCheckAllApsStatus = TRUE;
- Status = StartupAllAPsWorker (
+ Status = StartupAllCPUsWorker (
Procedure,
SingleThread,
+ TRUE,
WaitEvent,
TimeoutInMicroseconds,
ProcedureArgument,
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 6f51bc4ebf..572495ec36 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2130,6 +2130,7 @@ MpInitLibGetNumberOfProcessors (
number. If FALSE, then all the enabled APs
execute the function specified by Procedure
simultaneously.
+ @param[in] ExcludeBsp Whether let BSP also trig this task.
@param[in] WaitEvent The event created by the caller with CreateEvent()
service.
@param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
@@ -2151,9 +2152,10 @@ MpInitLibGetNumberOfProcessors (
**/
EFI_STATUS
-StartupAllAPsWorker (
+StartupAllCPUsWorker (
IN EFI_AP_PROCEDURE Procedure,
IN BOOLEAN SingleThread,
+ IN BOOLEAN ExcludeBsp,
IN EFI_EVENT WaitEvent OPTIONAL,
IN UINTN TimeoutInMicroseconds,
IN VOID *ProcedureArgument OPTIONAL,
@@ -2175,7 +2177,7 @@ StartupAllAPsWorker (
*FailedCpuList = NULL;
}
- if (CpuMpData->CpuCount == 1) {
+ if (CpuMpData->CpuCount == 1 && ExcludeBsp) {
return EFI_NOT_STARTED;
}
@@ -2218,9 +2220,9 @@ StartupAllAPsWorker (
}
}
- if (!HasEnabledAp) {
+ if (!HasEnabledAp && ExcludeBsp) {
//
- // If no enabled AP exists, return EFI_NOT_STARTED.
+ // If no enabled AP exists and not include Bsp to do the procedure, return EFI_NOT_STARTED.
//
return EFI_NOT_STARTED;
}
@@ -2266,6 +2268,13 @@ StartupAllAPsWorker (
}
}
+ if (!ExcludeBsp) {
+ //
+ // Start BSP.
+ //
+ Procedure (ProcedureArgument);
+ }
+
Status = EFI_SUCCESS;
if (WaitEvent == NULL) {
do {
@@ -2411,3 +2420,47 @@ GetCpuMpDataFromGuidedHob (
return CpuMpData;
}
+/**
+ This service executes a caller provided function on all enabled CPUs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system. See type
+ EFI_AP_PROCEDURE.
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
+ APs to return from Procedure, either for
+ blocking or non-blocking mode. Zero means
+ infinity. TimeoutInMicroseconds is ignored
+ for BSP.
+ @param[in] ProcedureArgument The parameter passed into Procedure for
+ all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all CPUs have finished before
+ the timeout expired.
+ @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
+ to all enabled CPUs.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_NOT_READY MP Initialize Library is not initialized.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+ all enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ return StartupAllCPUsWorker (
+ Procedure,
+ FALSE,
+ FALSE,
+ NULL,
+ TimeoutInMicroseconds,
+ ProcedureArgument,
+ NULL
+ );
+}
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index f89037c59e..effa235778 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -1,7 +1,7 @@
/** @file
Common header file for MP Initialize Library.
- Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -405,6 +405,7 @@ InitMpGlobalData (
number. If FALSE, then all the enabled APs
execute the function specified by Procedure
simultaneously.
+ @param[in] ExcludeBsp Whether let BSP also trig this task.
@param[in] WaitEvent The event created by the caller with CreateEvent()
service.
@param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
@@ -426,9 +427,10 @@ InitMpGlobalData (
**/
EFI_STATUS
-StartupAllAPsWorker (
+StartupAllCPUsWorker (
IN EFI_AP_PROCEDURE Procedure,
IN BOOLEAN SingleThread,
+ IN BOOLEAN ExcludeBsp,
IN EFI_EVENT WaitEvent OPTIONAL,
IN UINTN TimeoutInMicroseconds,
IN VOID *ProcedureArgument OPTIONAL,
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index 35dff91fd2..3999603c3e 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -1,7 +1,7 @@
/** @file
MP initialize support functions for PEI phase.
- Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -401,9 +401,10 @@ MpInitLibStartupAllAPs (
return EFI_UNSUPPORTED;
}
- return StartupAllAPsWorker (
+ return StartupAllCPUsWorker (
Procedure,
SingleThread,
+ TRUE,
NULL,
TimeoutInMicroseconds,
ProcedureArgument,
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch v3 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API.
2019-07-24 7:07 ` [Patch v3 2/6] UefiCpuPkg/MpInitLib: " Dong, Eric
@ 2019-07-26 10:36 ` Laszlo Ersek
0 siblings, 0 replies; 17+ messages in thread
From: Laszlo Ersek @ 2019-07-26 10:36 UTC (permalink / raw)
To: devel, eric.dong; +Cc: Ray Ni, Chandana Kumar, Star Zeng
On 07/24/19 09:07, Dong, Eric wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add new MpInitLibStartupAllCPUs API uses to start all processors
> at the same time.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> Reviewed-by: Ray Ni <ray.ni@intel.com>
> ---
> UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 5 +-
> UefiCpuPkg/Library/MpInitLib/MpLib.c | 61 +++++++++++++++++++++++--
> UefiCpuPkg/Library/MpInitLib/MpLib.h | 6 ++-
> UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 5 +-
> 4 files changed, 67 insertions(+), 10 deletions(-)
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API.
2019-07-24 7:07 [Patch v3 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
2019-07-24 7:07 ` [Patch v3 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API Dong, Eric
2019-07-24 7:07 ` [Patch v3 2/6] UefiCpuPkg/MpInitLib: " Dong, Eric
@ 2019-07-24 7:07 ` Dong, Eric
2019-07-25 8:53 ` [edk2-devel] " Ni, Ray
2019-07-26 10:37 ` Laszlo Ersek
2019-07-24 7:07 ` [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
` (2 subsequent siblings)
5 siblings, 2 replies; 17+ messages in thread
From: Dong, Eric @ 2019-07-24 7:07 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 35 ++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
index 36c2bb5326..b4024ee1ae 100644
--- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
+++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
@@ -405,3 +405,38 @@ MpInitLibWhoAmI (
*ProcessorNumber = 0;
return EFI_SUCCESS;
}
+
+/**
+ This service executes a caller provided function on all enabled CPUs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system. See type
+ EFI_AP_PROCEDURE.
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
+ APs to return from Procedure, either for
+ blocking or non-blocking mode. Zero means
+ infinity. TimeoutInMicroseconds is ignored
+ for BSP.
+ @param[in] ProcedureArgument The parameter passed into Procedure for
+ all APs.
+
+ @retval EFI_SUCCESS CPU have finished the procedure.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ if (Procedure == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Procedure (ProcedureArgument);
+
+ return EFI_SUCCESS;
+}
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API.
2019-07-24 7:07 ` [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
@ 2019-07-25 8:53 ` Ni, Ray
2019-07-26 10:37 ` Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Ni, Ray @ 2019-07-25 8:53 UTC (permalink / raw)
To: devel@edk2.groups.io, Dong, Eric
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Dong,
> Eric
> Sent: Wednesday, July 24, 2019 3:07 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [edk2-devel] [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: Add
> MpInitLibStartupAllCPUs API.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 35
> ++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> index 36c2bb5326..b4024ee1ae 100644
> --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> @@ -405,3 +405,38 @@ MpInitLibWhoAmI (
> *ProcessorNumber = 0;
> return EFI_SUCCESS;
> }
> +
> +/**
> + This service executes a caller provided function on all enabled CPUs.
> +
> + @param[in] Procedure A pointer to the function to be run on
> + enabled APs of the system. See type
> + EFI_AP_PROCEDURE.
> + @param[in] TimeoutInMicroseconds Indicates the time limit in
> microseconds for
> + APs to return from Procedure, either for
> + blocking or non-blocking mode. Zero means
> + infinity. TimeoutInMicroseconds is ignored
> + for BSP.
> + @param[in] ProcedureArgument The parameter passed into
> Procedure for
> + all APs.
> +
> + @retval EFI_SUCCESS CPU have finished the procedure.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MpInitLibStartupAllCPUs (
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN TimeoutInMicroseconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + )
> +{
> + if (Procedure == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Procedure (ProcedureArgument);
> +
> + return EFI_SUCCESS;
> +}
> --
> 2.21.0.windows.1
>
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API.
2019-07-24 7:07 ` [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
2019-07-25 8:53 ` [edk2-devel] " Ni, Ray
@ 2019-07-26 10:37 ` Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Laszlo Ersek @ 2019-07-26 10:37 UTC (permalink / raw)
To: devel, eric.dong; +Cc: Ray Ni, Chandana Kumar, Star Zeng
On 07/24/19 09:07, Dong, Eric wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add new MpInitLibStartupAllCPUs API uses to start all processors
> at the same time.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 35 ++++++++++++++++++++
> 1 file changed, 35 insertions(+)
My testing did not cover this patch.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
2019-07-24 7:07 [Patch v3 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
` (2 preceding siblings ...)
2019-07-24 7:07 ` [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
@ 2019-07-24 7:07 ` Dong, Eric
2019-07-25 8:53 ` Ni, Ray
2019-07-26 10:37 ` [edk2-devel] " Laszlo Ersek
2019-07-24 7:07 ` [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
2019-07-24 7:07 ` [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously Dong, Eric
5 siblings, 2 replies; 17+ messages in thread
From: Dong, Eric @ 2019-07-24 7:07 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add definition for new EDKII_PEI_MP_SERVICES2_PPI.
It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/Include/Ppi/MpServices2.h | 279 +++++++++++++++++++++++++++
UefiCpuPkg/UefiCpuPkg.dec | 3 +
2 files changed, 282 insertions(+)
create mode 100644 UefiCpuPkg/Include/Ppi/MpServices2.h
diff --git a/UefiCpuPkg/Include/Ppi/MpServices2.h b/UefiCpuPkg/Include/Ppi/MpServices2.h
new file mode 100644
index 0000000000..83a56588a5
--- /dev/null
+++ b/UefiCpuPkg/Include/Ppi/MpServices2.h
@@ -0,0 +1,279 @@
+/** @file
+ This file declares edkii Multi-processor service PPI.
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __EDKII_PEI_MP_SERVICES2_PPI_H__
+#define __EDKII_PEI_MP_SERVICES2_PPI_H__
+
+#include <Ppi/MpServices.h>
+
+#define EDKII_PEI_MP_SERVICES2_PPI_GUID \
+ { \
+ 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba} \
+ }
+
+typedef struct _EDKII_PEI_MP_SERVICES2_PPI EDKII_PEI_MP_SERVICES2_PPI;
+
+/**
+ Get the number of CPU's.
+
+ @param[in] This Pointer to this instance of the PPI.
+ @param[out] NumberOfProcessors Pointer to the total number of logical processors in
+ the system, including the BSP and disabled APs.
+ @param[out] NumberOfEnabledProcessors
+ Number of processors in the system that are enabled.
+
+ @retval EFI_SUCCESS The number of logical processors and enabled
+ logical processors was retrieved.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
+ NumberOfEnabledProcessors is NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ OUT UINTN *NumberOfProcessors,
+ OUT UINTN *NumberOfEnabledProcessors
+ );
+
+/**
+ Get information on a specific CPU.
+
+ @param[in] This Pointer to this instance of the PPI.
+ @param[in] ProcessorNumber Pointer to the total number of logical processors in
+ the system, including the BSP and disabled APs.
+ @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled.
+
+ @retval EFI_SUCCESS Processor information was returned.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
+ @retval EFI_NOT_FOUND The processor with the handle specified by
+ ProcessorNumber does not exist in the platform.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN UINTN ProcessorNumber,
+ OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
+ );
+
+/**
+ Activate all of the application proessors.
+
+ @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] SingleThread If TRUE, then all the enabled APs execute the function
+ specified by Procedure one by one, in ascending order
+ of processor handle number. If FALSE, then all the
+ enabled APs execute the function specified by Procedure
+ simultaneously.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires before all APs
+ return from Procedure, then Procedure on the failed APs
+ is terminated. All enabled APs are available for next
+ function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
+ or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
+ timeout expires in blocking mode, BSP returns
+ EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_STARTED No enabled APs exist in the system.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN BOOLEAN SingleThread,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
+/**
+ Activate a specific application processor.
+
+ @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires before all APs
+ return from Procedure, then Procedure on the failed APs
+ is terminated. All enabled APs are available for next
+ function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
+ or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
+ timeout expires in blocking mode, BSP returns
+ EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
+
+ @retval EFI_SUCCESS In blocking mode, specified AP finished before the
+ timeout expires.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before the
+ specified AP has finished.
+ @retval EFI_NOT_FOUND The processor with the handle specified by
+ ProcessorNumber does not exist.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN ProcessorNumber,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
+/**
+ Switch the boot strap processor.
+
+ @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
+ @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
+ @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled
+ AP. Otherwise, it will be disabled.
+
+ @retval EFI_SUCCESS BSP successfully switched.
+ @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this
+ service returning.
+ @retval EFI_UNSUPPORTED Switching the BSP is not supported.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_NOT_FOUND The processor with the handle specified by
+ ProcessorNumber does not exist.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled
+ AP.
+ @retval EFI_NOT_READY The specified AP is busy.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_SWITCH_BSP) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN UINTN ProcessorNumber,
+ IN BOOLEAN EnableOldBSP
+ );
+
+/**
+ Enable or disable an application processor.
+
+ @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
+ @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
+ @param[in] EnableAP Specifies the new state for the processor for enabled,
+ FALSE for disabled.
+ @param[in] HealthFlag If not NULL, a pointer to a value that specifies the
+ new health status of the AP. This flag corresponds to
+ StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo().
+ Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other
+ bits are ignored. If it is NULL, this parameter is
+ ignored.
+
+ @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
+ @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior
+ to this service returning.
+ @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
+ does not exist.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN UINTN ProcessorNumber,
+ IN BOOLEAN EnableAP,
+ IN UINT32 *HealthFlag OPTIONAL
+ );
+
+/**
+ Identify the currently executing processor.
+
+ @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
+ @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
+
+ @retval EFI_SUCCESS The current processor handle number was returned in
+ ProcessorNumber.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_WHOAMI) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ OUT UINTN *ProcessorNumber
+ );
+
+
+/**
+ Activate all of the application proessors.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires in blocking
+ mode, BSP returns EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all CPUs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
+struct _EDKII_PEI_MP_SERVICES2_PPI {
+ EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;
+ EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo;
+ EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs;
+ EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP;
+ EDKII_PEI_MP_SERVICES_SWITCH_BSP SwitchBSP;
+ EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP;
+ EDKII_PEI_MP_SERVICES_WHOAMI WhoAmI;
+ EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS StartupAllCPUs;
+};
+
+extern EFI_GUID gEdkiiPeiMpServices2PpiGuid;
+
+#endif
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 6ddf0cd224..14ddaa8633 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -75,6 +75,9 @@
# 0x80000001 | Invalid value provided.
#
+[Ppis]
+ gEdkiiPeiMpServices2PpiGuid = { 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba}}
+
[PcdsFeatureFlag]
## Indicates if SMM Profile will be enabled.
# If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged.
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
2019-07-24 7:07 ` [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-25 8:53 ` Ni, Ray
2019-07-26 10:37 ` [edk2-devel] " Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Ni, Ray @ 2019-07-25 8:53 UTC (permalink / raw)
To: Dong, Eric, devel@edk2.groups.io
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
> -----Original Message-----
> From: Dong, Eric
> Sent: Wednesday, July 24, 2019 3:07 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add definition for new EDKII_PEI_MP_SERVICES2_PPI.
>
> It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI and add new API
> EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Include/Ppi/MpServices2.h | 279
> +++++++++++++++++++++++++++
> UefiCpuPkg/UefiCpuPkg.dec | 3 +
> 2 files changed, 282 insertions(+)
> create mode 100644 UefiCpuPkg/Include/Ppi/MpServices2.h
>
> diff --git a/UefiCpuPkg/Include/Ppi/MpServices2.h
> b/UefiCpuPkg/Include/Ppi/MpServices2.h
> new file mode 100644
> index 0000000000..83a56588a5
> --- /dev/null
> +++ b/UefiCpuPkg/Include/Ppi/MpServices2.h
> @@ -0,0 +1,279 @@
> +/** @file
> + This file declares edkii Multi-processor service PPI.
With edkii changed to EDKII, Reviewed-by: Ray Ni <ray.ni@intel.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
2019-07-24 7:07 ` [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
2019-07-25 8:53 ` Ni, Ray
@ 2019-07-26 10:37 ` Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Laszlo Ersek @ 2019-07-26 10:37 UTC (permalink / raw)
To: devel, eric.dong; +Cc: Ray Ni, Chandana Kumar, Star Zeng
On 07/24/19 09:07, Dong, Eric wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add definition for new EDKII_PEI_MP_SERVICES2_PPI.
>
> It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
> and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Include/Ppi/MpServices2.h | 279 +++++++++++++++++++++++++++
> UefiCpuPkg/UefiCpuPkg.dec | 3 +
> 2 files changed, 282 insertions(+)
> create mode 100644 UefiCpuPkg/Include/Ppi/MpServices2.h
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI.
2019-07-24 7:07 [Patch v3 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
` (3 preceding siblings ...)
2019-07-24 7:07 ` [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-24 7:07 ` Dong, Eric
2019-07-25 8:55 ` Ni, Ray
2019-07-26 10:38 ` [edk2-devel] " Laszlo Ersek
2019-07-24 7:07 ` [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously Dong, Eric
5 siblings, 2 replies; 17+ messages in thread
From: Dong, Eric @ 2019-07-24 7:07 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Produce new EDKII_PEI_MP_SERVICES2_PPI service.
It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/CpuMpPei/CpuMpPei.c | 21 +-
UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 +-
UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 2 +
UefiCpuPkg/CpuMpPei/Mp2Pei.c | 417 +++++++++++++++++++++++++++++++
4 files changed, 436 insertions(+), 7 deletions(-)
create mode 100644 UefiCpuPkg/CpuMpPei/Mp2Pei.c
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 926541c937..07ccbe7c6a 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -1,13 +1,15 @@
/** @file
CPU PEI Module installs CPU Multiple Processor PPI.
- Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "CpuMpPei.h"
+extern EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi;
+
//
// CPU MP PPI to be installed
//
@@ -21,10 +23,17 @@ EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = {
PeiWhoAmI,
};
-EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc = {
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiPeiMpServicesPpiGuid,
- &mMpServicesPpi
+EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEdkiiPeiMpServices2PpiGuid,
+ &mMpServices2Ppi
+ },
+ {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiMpServicesPpiGuid,
+ &mMpServicesPpi
+ }
};
/**
@@ -667,7 +676,7 @@ InitializeCpuMpWorker (
//
// Install CPU MP PPI
//
- Status = PeiServicesInstallPpi(&mPeiCpuMpPpiDesc);
+ Status = PeiServicesInstallPpi(mPeiCpuMpPpiList);
ASSERT_EFI_ERROR (Status);
return Status;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index a5d8a755b2..7d5c527d60 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 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -15,6 +15,7 @@
#include <Ppi/SecPlatformInformation.h>
#include <Ppi/SecPlatformInformation2.h>
#include <Ppi/EndOfPeiPhase.h>
+#include <Ppi/MpServices2.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index 4fc4ea77ba..fb2db650e5 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -26,6 +26,7 @@
CpuMpPei.c
CpuBist.c
CpuPaging.c
+ Mp2Pei.c
[Packages]
MdePkg/MdePkg.dec
@@ -54,6 +55,7 @@
gEfiSecPlatformInformation2PpiGuid
gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES
gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES
+ gEdkiiPeiMpServices2PpiGuid ## PRODUCES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
diff --git a/UefiCpuPkg/CpuMpPei/Mp2Pei.c b/UefiCpuPkg/CpuMpPei/Mp2Pei.c
new file mode 100644
index 0000000000..c1116a5b77
--- /dev/null
+++ b/UefiCpuPkg/CpuMpPei/Mp2Pei.c
@@ -0,0 +1,417 @@
+/** @file
+ EDKII_PEI_MP_SERVICES2_PPI Implementation code.
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "CpuMpPei.h"
+
+/**
+ This service retrieves the number of logical processor in the platform
+ and the number of those logical processors that are enabled on this boot.
+ This service may only be called from the BSP.
+
+ This function is used to retrieve the following information:
+ - The number of logical processors that are present in the system.
+ - The number of enabled logical processors in the system at the instant
+ this call is made.
+
+ Because MP Service Ppi provides services to enable and disable processors
+ dynamically, the number of enabled logical processors may vary during the
+ course of a boot session.
+
+ If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
+ If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
+ EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
+ is returned in NumberOfProcessors, the number of currently enabled processor
+ is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
+
+ @param[in] This Pointer to this instance of the PPI.
+ @param[out] NumberOfProcessors Pointer to the total number of logical processors in
+ the system, including the BSP and disabled APs.
+ @param[out] NumberOfEnabledProcessors
+ Number of processors in the system that are enabled.
+
+ @retval EFI_SUCCESS The number of logical processors and enabled
+ logical processors was retrieved.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
+ NumberOfEnabledProcessors is NULL.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiGetNumberOfProcessors (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ OUT UINTN *NumberOfProcessors,
+ OUT UINTN *NumberOfEnabledProcessors
+ )
+{
+ if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return MpInitLibGetNumberOfProcessors (
+ NumberOfProcessors,
+ NumberOfEnabledProcessors
+ );
+}
+
+/**
+ Gets detailed MP-related information on the requested processor at the
+ instant this call is made. This service may only be called from the BSP.
+
+ This service retrieves detailed MP-related information about any processor
+ on the platform. Note the following:
+ - The processor information may change during the course of a boot session.
+ - The information presented here is entirely MP related.
+
+ Information regarding the number of caches and their sizes, frequency of operation,
+ slot numbers is all considered platform-related information and is not provided
+ by this service.
+
+ @param[in] This Pointer to this instance of the PPI.
+ @param[in] ProcessorNumber Pointer to the total number of logical processors in
+ the system, including the BSP and disabled APs.
+ @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled.
+
+ @retval EFI_SUCCESS Processor information was returned.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
+ @retval EFI_NOT_FOUND The processor with the handle specified by
+ ProcessorNumber does not exist in the platform.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiGetProcessorInfo (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN UINTN ProcessorNumber,
+ OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
+ )
+{
+ return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL);
+}
+
+/**
+ This service executes a caller provided function on all enabled APs. APs can
+ run either simultaneously or one at a time in sequence. This service supports
+ both blocking requests only. This service may only
+ be called from the BSP.
+
+ This function is used to dispatch all the enabled APs to the function specified
+ by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
+ immediately and Procedure is not started on any AP.
+
+ If SingleThread is TRUE, all the enabled APs execute the function specified by
+ Procedure one by one, in ascending order of processor handle number. Otherwise,
+ all the enabled APs execute the function specified by Procedure simultaneously.
+
+ If the timeout specified by TimeoutInMicroSeconds expires before all APs return
+ from Procedure, then Procedure on the failed APs is terminated. All enabled APs
+ are always available for further calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
+ and EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If FailedCpuList is not NULL, its
+ content points to the list of processor handle numbers in which Procedure was
+ terminated.
+
+ Note: It is the responsibility of the consumer of the EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
+ to make sure that the nature of the code that is executed on the BSP and the
+ dispatched APs is well controlled. The MP Services Ppi does not guarantee
+ that the Procedure function is MP-safe. Hence, the tasks that can be run in
+ parallel are limited to certain independent tasks and well-controlled exclusive
+ code. PEI services and Ppis may not be called by APs unless otherwise
+ specified.
+
+ In blocking execution mode, BSP waits until all APs finish or
+ TimeoutInMicroSeconds expires.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] SingleThread If TRUE, then all the enabled APs execute the function
+ specified by Procedure one by one, in ascending order
+ of processor handle number. If FALSE, then all the
+ enabled APs execute the function specified by Procedure
+ simultaneously.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires before all APs
+ return from Procedure, then Procedure on the failed APs
+ is terminated. All enabled APs are available for next
+ function assigned by EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
+ or EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If the
+ timeout expires in blocking mode, BSP returns
+ EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_STARTED No enabled APs exist in the system.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiStartupAllAPs (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN BOOLEAN SingleThread,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ return MpInitLibStartupAllAPs (
+ Procedure,
+ SingleThread,
+ NULL,
+ TimeoutInMicroSeconds,
+ ProcedureArgument,
+ NULL
+ );
+}
+
+/**
+ This service lets the caller get one enabled AP to execute a caller-provided
+ function. The caller can request the BSP to wait for the completion
+ of the AP. This service may only be called from the BSP.
+
+ This function is used to dispatch one enabled AP to the function specified by
+ Procedure passing in the argument specified by ProcedureArgument.
+ The execution is in blocking mode. The BSP waits until the AP finishes or
+ TimeoutInMicroSecondss expires.
+
+ If the timeout specified by TimeoutInMicroseconds expires before the AP returns
+ from Procedure, then execution of Procedure by the AP is terminated. The AP is
+ available for subsequent calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs() and
+ EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP().
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
+ @param[in] TimeoutInMicroseconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires before all APs
+ return from Procedure, then Procedure on the failed APs
+ is terminated. All enabled APs are available for next
+ function assigned by EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
+ or EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If the
+ timeout expires in blocking mode, BSP returns
+ EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
+
+ @retval EFI_SUCCESS In blocking mode, specified AP finished before the
+ timeout expires.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before the
+ specified AP has finished.
+ @retval EFI_NOT_FOUND The processor with the handle specified by
+ ProcessorNumber does not exist.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiStartupThisAP (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN ProcessorNumber,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ return MpInitLibStartupThisAP (
+ Procedure,
+ ProcessorNumber,
+ NULL,
+ TimeoutInMicroseconds,
+ ProcedureArgument,
+ NULL
+ );
+}
+
+/**
+ This service switches the requested AP to be the BSP from that point onward.
+ This service changes the BSP for all purposes. This call can only be performed
+ by the current BSP.
+
+ This service switches the requested AP to be the BSP from that point onward.
+ This service changes the BSP for all purposes. The new BSP can take over the
+ execution of the old BSP and continue seamlessly from where the old one left
+ off.
+
+ If the BSP cannot be switched prior to the return from this service, then
+ EFI_UNSUPPORTED must be returned.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
+ @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled
+ AP. Otherwise, it will be disabled.
+
+ @retval EFI_SUCCESS BSP successfully switched.
+ @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this
+ service returning.
+ @retval EFI_UNSUPPORTED Switching the BSP is not supported.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_NOT_FOUND The processor with the handle specified by
+ ProcessorNumber does not exist.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled
+ AP.
+ @retval EFI_NOT_READY The specified AP is busy.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiSwitchBSP (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN UINTN ProcessorNumber,
+ IN BOOLEAN EnableOldBSP
+ )
+{
+ return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP);
+}
+
+/**
+ This service lets the caller enable or disable an AP from this point onward.
+ This service may only be called from the BSP.
+
+ This service allows the caller enable or disable an AP from this point onward.
+ The caller can optionally specify the health status of the AP by Health. If
+ an AP is being disabled, then the state of the disabled AP is implementation
+ dependent. If an AP is enabled, then the implementation must guarantee that a
+ complete initialization sequence is performed on the AP, so the AP is in a state
+ that is compatible with an MP operating system.
+
+ If the enable or disable AP operation cannot be completed prior to the return
+ from this service, then EFI_UNSUPPORTED must be returned.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
+ @param[in] EnableAP Specifies the new state for the processor for enabled,
+ FALSE for disabled.
+ @param[in] HealthFlag If not NULL, a pointer to a value that specifies the
+ new health status of the AP. This flag corresponds to
+ StatusFlag defined in EDKII_PEI_MP_SERVICES2_PPI.GetProcessorInfo().
+ Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other
+ bits are ignored. If it is NULL, this parameter is
+ ignored.
+
+ @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
+ @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior
+ to this service returning.
+ @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.
+ @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
+ does not exist.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiEnableDisableAP (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN UINTN ProcessorNumber,
+ IN BOOLEAN EnableAP,
+ IN UINT32 *HealthFlag OPTIONAL
+ )
+{
+ return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag);
+}
+
+/**
+ This return the handle number for the calling processor. This service may be
+ called from the BSP and APs.
+
+ This service returns the processor handle number for the calling processor.
+ The returned value is in the range from 0 to the total number of logical
+ processors minus 1. The total number of logical processors can be retrieved
+ with EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors(). This service may be
+ called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
+ is returned. Otherwise, the current processors handle number is returned in
+ ProcessorNumber, and EFI_SUCCESS is returned.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the
+ total number of logical processors minus 1. The total
+ number of logical processors can be retrieved by
+ EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
+
+ @retval EFI_SUCCESS The current processor handle number was returned in
+ ProcessorNumber.
+ @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiWhoAmI (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ OUT UINTN *ProcessorNumber
+ )
+{
+ return MpInitLibWhoAmI (ProcessorNumber);
+}
+
+/**
+ This service executes a caller provided function on all enabled CPUs. CPUs can
+ run either simultaneously or one at a time in sequence. This service may only
+ be called from the BSP.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires in blocking
+ mode, BSP returns EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all CPUs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+EFI_STATUS
+EFIAPI
+EdkiiPeiStartupAllCPUs (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ return MpInitLibStartupAllCPUs (
+ Procedure,
+ TimeoutInMicroSeconds,
+ ProcedureArgument
+ );
+}
+
+//
+// CPU MP2 PPI to be installed
+//
+EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi = {
+ EdkiiPeiGetNumberOfProcessors,
+ EdkiiPeiGetProcessorInfo,
+ EdkiiPeiStartupAllAPs,
+ EdkiiPeiStartupThisAP,
+ EdkiiPeiSwitchBSP,
+ EdkiiPeiEnableDisableAP,
+ EdkiiPeiWhoAmI,
+ EdkiiPeiStartupAllCPUs
+};
+
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI.
2019-07-24 7:07 ` [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-25 8:55 ` Ni, Ray
2019-07-26 10:38 ` [edk2-devel] " Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Ni, Ray @ 2019-07-25 8:55 UTC (permalink / raw)
To: Dong, Eric, devel@edk2.groups.io
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
With file name changing from Mp2Pei.c to CpuMp2Pei.c, Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Dong, Eric
> Sent: Wednesday, July 24, 2019 3:07 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce
> EDKII_PEI_MP_SERVICES2_PPI.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Produce new EDKII_PEI_MP_SERVICES2_PPI service.
>
> It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI and add new API
> EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/CpuMpPei/CpuMpPei.c | 21 +-
> UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 +-
> UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 2 +
> UefiCpuPkg/CpuMpPei/Mp2Pei.c | 417
> +++++++++++++++++++++++++++++++
> 4 files changed, 436 insertions(+), 7 deletions(-) create mode 100644
> UefiCpuPkg/CpuMpPei/Mp2Pei.c
>
> diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
> b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index 926541c937..07ccbe7c6a 100644
> --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
> +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
> @@ -1,13 +1,15 @@
> /** @file
> CPU PEI Module installs CPU Multiple Processor PPI.
>
> - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
>
> #include "CpuMpPei.h"
>
> +extern EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi;
> +
> //
> // CPU MP PPI to be installed
> //
> @@ -21,10 +23,17 @@ EFI_PEI_MP_SERVICES_PPI mMpServicesPpi =
> {
> PeiWhoAmI,
> };
>
> -EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc = {
> - (EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> - &gEfiPeiMpServicesPpiGuid,
> - &mMpServicesPpi
> +EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
> + {
> + EFI_PEI_PPI_DESCRIPTOR_PPI,
> + &gEdkiiPeiMpServices2PpiGuid,
> + &mMpServices2Ppi
> + },
> + {
> + (EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> + &gEfiPeiMpServicesPpiGuid,
> + &mMpServicesPpi
> + }
> };
>
> /**
> @@ -667,7 +676,7 @@ InitializeCpuMpWorker (
> //
> // Install CPU MP PPI
> //
> - Status = PeiServicesInstallPpi(&mPeiCpuMpPpiDesc);
> + Status = PeiServicesInstallPpi(mPeiCpuMpPpiList);
> ASSERT_EFI_ERROR (Status);
>
> return Status;
> diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
> b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index a5d8a755b2..7d5c527d60
> 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 - 2018, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -15,6 +15,7 @@
> #include <Ppi/SecPlatformInformation.h> #include
> <Ppi/SecPlatformInformation2.h> #include <Ppi/EndOfPeiPhase.h>
> +#include <Ppi/MpServices2.h>
>
> #include <Library/BaseLib.h>
> #include <Library/DebugLib.h>
> diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> index 4fc4ea77ba..fb2db650e5 100644
> --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
> @@ -26,6 +26,7 @@
> CpuMpPei.c
> CpuBist.c
> CpuPaging.c
> + Mp2Pei.c
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -54,6 +55,7 @@
> gEfiSecPlatformInformation2PpiGuid
> gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES
> gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES
> + gEdkiiPeiMpServices2PpiGuid ## PRODUCES
>
> [Pcd]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM
> ask ## CONSUMES
> diff --git a/UefiCpuPkg/CpuMpPei/Mp2Pei.c
> b/UefiCpuPkg/CpuMpPei/Mp2Pei.c new file mode 100644 index
> 0000000000..c1116a5b77
> --- /dev/null
> +++ b/UefiCpuPkg/CpuMpPei/Mp2Pei.c
> @@ -0,0 +1,417 @@
> +/** @file
> + EDKII_PEI_MP_SERVICES2_PPI Implementation code.
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "CpuMpPei.h"
> +
> +/**
> + This service retrieves the number of logical processor in the
> +platform
> + and the number of those logical processors that are enabled on this boot.
> + This service may only be called from the BSP.
> +
> + This function is used to retrieve the following information:
> + - The number of logical processors that are present in the system.
> + - The number of enabled logical processors in the system at the instant
> + this call is made.
> +
> + Because MP Service Ppi provides services to enable and disable
> + processors dynamically, the number of enabled logical processors may
> + vary during the course of a boot session.
> +
> + If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
> + If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
> + EFI_INVALID_PARAMETER is returned. Otherwise, the total number of
> + processors is returned in NumberOfProcessors, the number of currently
> + enabled processor is returned in NumberOfEnabledProcessors, and
> EFI_SUCCESS is returned.
> +
> + @param[in] This Pointer to this instance of the PPI.
> + @param[out] NumberOfProcessors Pointer to the total number of logical
> processors in
> + the system, including the BSP and disabled APs.
> + @param[out] NumberOfEnabledProcessors
> + Number of processors in the system that are enabled.
> +
> + @retval EFI_SUCCESS The number of logical processors and enabled
> + logical processors was retrieved.
> + @retval EFI_DEVICE_ERROR The calling processor is an AP.
> + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
> + NumberOfEnabledProcessors is NULL.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiGetNumberOfProcessors (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + OUT UINTN *NumberOfProcessors,
> + OUT UINTN *NumberOfEnabledProcessors
> + )
> +{
> + if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors ==
> NULL)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + return MpInitLibGetNumberOfProcessors (
> + NumberOfProcessors,
> + NumberOfEnabledProcessors
> + );
> +}
> +
> +/**
> + Gets detailed MP-related information on the requested processor at
> +the
> + instant this call is made. This service may only be called from the BSP.
> +
> + This service retrieves detailed MP-related information about any
> + processor on the platform. Note the following:
> + - The processor information may change during the course of a boot
> session.
> + - The information presented here is entirely MP related.
> +
> + Information regarding the number of caches and their sizes, frequency
> + of operation, slot numbers is all considered platform-related
> + information and is not provided by this service.
> +
> + @param[in] This Pointer to this instance of the PPI.
> + @param[in] ProcessorNumber Pointer to the total number of logical
> processors in
> + the system, including the BSP and disabled APs.
> + @param[out] ProcessorInfoBuffer Number of processors in the system
> that are enabled.
> +
> + @retval EFI_SUCCESS Processor information was returned.
> + @retval EFI_DEVICE_ERROR The calling processor is an AP.
> + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
> + @retval EFI_NOT_FOUND The processor with the handle specified by
> + ProcessorNumber does not exist in the platform.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiGetProcessorInfo (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN UINTN ProcessorNumber,
> + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
> + )
> +{
> + return MpInitLibGetProcessorInfo (ProcessorNumber,
> +ProcessorInfoBuffer, NULL); }
> +
> +/**
> + This service executes a caller provided function on all enabled APs.
> +APs can
> + run either simultaneously or one at a time in sequence. This service
> +supports
> + both blocking requests only. This service may only
> + be called from the BSP.
> +
> + This function is used to dispatch all the enabled APs to the function
> + specified by Procedure. If any enabled AP is busy, then
> + EFI_NOT_READY is returned immediately and Procedure is not started on
> any AP.
> +
> + If SingleThread is TRUE, all the enabled APs execute the function
> + specified by Procedure one by one, in ascending order of processor
> + handle number. Otherwise, all the enabled APs execute the function
> specified by Procedure simultaneously.
> +
> + If the timeout specified by TimeoutInMicroSeconds expires before all
> + APs return from Procedure, then Procedure on the failed APs is
> + terminated. All enabled APs are always available for further calls to
> + EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
> + and EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If FailedCpuList is
> + not NULL, its content points to the list of processor handle numbers
> + in which Procedure was terminated.
> +
> + Note: It is the responsibility of the consumer of the
> + EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
> + to make sure that the nature of the code that is executed on the BSP
> + and the dispatched APs is well controlled. The MP Services Ppi does
> + not guarantee that the Procedure function is MP-safe. Hence, the
> + tasks that can be run in parallel are limited to certain independent
> + tasks and well-controlled exclusive code. PEI services and Ppis may
> + not be called by APs unless otherwise specified.
> +
> + In blocking execution mode, BSP waits until all APs finish or
> + TimeoutInMicroSeconds expires.
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[in] Procedure A pointer to the function to be run on
> enabled APs of
> + the system.
> + @param[in] SingleThread If TRUE, then all the enabled APs execute
> the function
> + specified by Procedure one by one, in ascending order
> + of processor handle number. If FALSE, then all the
> + enabled APs execute the function specified by Procedure
> + simultaneously.
> + @param[in] TimeoutInMicroSeconds
> + Indicates the time limit in microseconds for APs to
> + return from Procedure, for blocking mode only. Zero
> + means infinity. If the timeout expires before all APs
> + return from Procedure, then Procedure on the failed APs
> + is terminated. All enabled APs are available for next
> + function assigned by
> EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
> + or EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If the
> + timeout expires in blocking mode, BSP returns
> + EFI_TIMEOUT.
> + @param[in] ProcedureArgument The parameter passed into Procedure
> for all APs.
> +
> + @retval EFI_SUCCESS In blocking mode, all APs have finished before
> the
> + timeout expired.
> + @retval EFI_DEVICE_ERROR Caller processor is AP.
> + @retval EFI_NOT_STARTED No enabled APs exist in the system.
> + @retval EFI_NOT_READY Any enabled APs are busy.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> all
> + enabled APs have finished.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiStartupAllAPs (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN EFI_AP_PROCEDURE Procedure,
> + IN BOOLEAN SingleThread,
> + IN UINTN TimeoutInMicroSeconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + )
> +{
> + return MpInitLibStartupAllAPs (
> + Procedure,
> + SingleThread,
> + NULL,
> + TimeoutInMicroSeconds,
> + ProcedureArgument,
> + NULL
> + );
> +}
> +
> +/**
> + This service lets the caller get one enabled AP to execute a
> +caller-provided
> + function. The caller can request the BSP to wait for the completion
> + of the AP. This service may only be called from the BSP.
> +
> + This function is used to dispatch one enabled AP to the function
> + specified by Procedure passing in the argument specified by
> ProcedureArgument.
> + The execution is in blocking mode. The BSP waits until the AP
> + finishes or TimeoutInMicroSecondss expires.
> +
> + If the timeout specified by TimeoutInMicroseconds expires before the
> + AP returns from Procedure, then execution of Procedure by the AP is
> + terminated. The AP is available for subsequent calls to
> + EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs() and
> EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP().
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[in] Procedure A pointer to the function to be run on
> enabled APs of
> + the system.
> + @param[in] ProcessorNumber The handle number of the AP. The range
> is from 0 to the
> + total number of logical processors minus 1. The total
> + number of logical processors can be retrieved by
> + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
> + @param[in] TimeoutInMicroseconds
> + Indicates the time limit in microseconds for APs to
> + return from Procedure, for blocking mode only. Zero
> + means infinity. If the timeout expires before all APs
> + return from Procedure, then Procedure on the failed APs
> + is terminated. All enabled APs are available for next
> + function assigned by
> EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
> + or EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If the
> + timeout expires in blocking mode, BSP returns
> + EFI_TIMEOUT.
> + @param[in] ProcedureArgument The parameter passed into Procedure
> for all APs.
> +
> + @retval EFI_SUCCESS In blocking mode, specified AP finished before
> the
> + timeout expires.
> + @retval EFI_DEVICE_ERROR The calling processor is an AP.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> the
> + specified AP has finished.
> + @retval EFI_NOT_FOUND The processor with the handle specified by
> + ProcessorNumber does not exist.
> + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or
> disabled AP.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiStartupThisAP (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN ProcessorNumber,
> + IN UINTN TimeoutInMicroseconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + )
> +{
> + return MpInitLibStartupThisAP (
> + Procedure,
> + ProcessorNumber,
> + NULL,
> + TimeoutInMicroseconds,
> + ProcedureArgument,
> + NULL
> + );
> +}
> +
> +/**
> + This service switches the requested AP to be the BSP from that point
> onward.
> + This service changes the BSP for all purposes. This call can only be
> performed
> + by the current BSP.
> +
> + This service switches the requested AP to be the BSP from that point
> onward.
> + This service changes the BSP for all purposes. The new BSP can take
> + over the execution of the old BSP and continue seamlessly from where
> + the old one left off.
> +
> + If the BSP cannot be switched prior to the return from this service,
> + then EFI_UNSUPPORTED must be returned.
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[in] ProcessorNumber The handle number of the AP. The range
> is from 0 to the
> + total number of logical processors minus 1. The total
> + number of logical processors can be retrieved by
> + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
> + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
> enabled
> + AP. Otherwise, it will be disabled.
> +
> + @retval EFI_SUCCESS BSP successfully switched.
> + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed
> prior to this
> + service returning.
> + @retval EFI_UNSUPPORTED Switching the BSP is not supported.
> + @retval EFI_DEVICE_ERROR The calling processor is an AP.
> + @retval EFI_NOT_FOUND The processor with the handle specified by
> + ProcessorNumber does not exist.
> + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the
> current BSP or a disabled
> + AP.
> + @retval EFI_NOT_READY The specified AP is busy.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiSwitchBSP (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN UINTN ProcessorNumber,
> + IN BOOLEAN EnableOldBSP
> + )
> +{
> + return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); }
> +
> +/**
> + This service lets the caller enable or disable an AP from this point onward.
> + This service may only be called from the BSP.
> +
> + This service allows the caller enable or disable an AP from this point
> onward.
> + The caller can optionally specify the health status of the AP by
> + Health. If an AP is being disabled, then the state of the disabled AP
> + is implementation dependent. If an AP is enabled, then the
> + implementation must guarantee that a complete initialization sequence
> + is performed on the AP, so the AP is in a state that is compatible with an
> MP operating system.
> +
> + If the enable or disable AP operation cannot be completed prior to
> + the return from this service, then EFI_UNSUPPORTED must be returned.
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[in] ProcessorNumber The handle number of the AP. The range
> is from 0 to the
> + total number of logical processors minus 1. The total
> + number of logical processors can be retrieved by
> + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
> + @param[in] EnableAP Specifies the new state for the processor for
> enabled,
> + FALSE for disabled.
> + @param[in] HealthFlag If not NULL, a pointer to a value that specifies
> the
> + new health status of the AP. This flag corresponds to
> + StatusFlag defined in
> EDKII_PEI_MP_SERVICES2_PPI.GetProcessorInfo().
> + Only the PROCESSOR_HEALTH_STATUS_BIT is used. All
> other
> + bits are ignored. If it is NULL, this parameter is
> + ignored.
> +
> + @retval EFI_SUCCESS The specified AP was enabled or disabled
> successfully.
> + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be
> completed prior
> + to this service returning.
> + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not
> supported.
> + @retval EFI_DEVICE_ERROR The calling processor is an AP.
> + @retval EFI_NOT_FOUND Processor with the handle specified by
> ProcessorNumber
> + does not exist.
> + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiEnableDisableAP (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN UINTN ProcessorNumber,
> + IN BOOLEAN EnableAP,
> + IN UINT32 *HealthFlag OPTIONAL
> + )
> +{
> + return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP,
> +HealthFlag); }
> +
> +/**
> + This return the handle number for the calling processor. This
> +service may be
> + called from the BSP and APs.
> +
> + This service returns the processor handle number for the calling processor.
> + The returned value is in the range from 0 to the total number of
> + logical processors minus 1. The total number of logical processors
> + can be retrieved with
> + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors(). This service
> may
> + be called from the BSP and APs. If ProcessorNumber is NULL, then
> + EFI_INVALID_PARAMETER is returned. Otherwise, the current processors
> handle number is returned in ProcessorNumber, and EFI_SUCCESS is
> returned.
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[out] ProcessorNumber The handle number of the AP. The
> range is from 0 to the
> + total number of logical processors minus 1. The total
> + number of logical processors can be retrieved by
> + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
> +
> + @retval EFI_SUCCESS The current processor handle number was
> returned in
> + ProcessorNumber.
> + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiWhoAmI (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + OUT UINTN *ProcessorNumber
> + )
> +{
> + return MpInitLibWhoAmI (ProcessorNumber); }
> +
> +/**
> + This service executes a caller provided function on all enabled CPUs.
> +CPUs can
> + run either simultaneously or one at a time in sequence. This service
> +may only
> + be called from the BSP.
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[in] Procedure A pointer to the function to be run on
> enabled APs of
> + the system.
> + @param[in] TimeoutInMicroSeconds
> + Indicates the time limit in microseconds for APs to
> + return from Procedure, for blocking mode only. Zero
> + means infinity. If the timeout expires in blocking
> + mode, BSP returns EFI_TIMEOUT.
> + @param[in] ProcedureArgument The parameter passed into Procedure
> for all CPUs.
> +
> + @retval EFI_SUCCESS In blocking mode, all APs have finished before
> the
> + timeout expired.
> + @retval EFI_DEVICE_ERROR Caller processor is AP.
> + @retval EFI_NOT_READY Any enabled APs are busy.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> all
> + enabled APs have finished.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EdkiiPeiStartupAllCPUs (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN TimeoutInMicroSeconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + )
> +{
> + return MpInitLibStartupAllCPUs (
> + Procedure,
> + TimeoutInMicroSeconds,
> + ProcedureArgument
> + );
> +}
> +
> +//
> +// CPU MP2 PPI to be installed
> +//
> +EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi = {
> + EdkiiPeiGetNumberOfProcessors,
> + EdkiiPeiGetProcessorInfo,
> + EdkiiPeiStartupAllAPs,
> + EdkiiPeiStartupThisAP,
> + EdkiiPeiSwitchBSP,
> + EdkiiPeiEnableDisableAP,
> + EdkiiPeiWhoAmI,
> + EdkiiPeiStartupAllCPUs
> +};
> +
> --
> 2.21.0.windows.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI.
2019-07-24 7:07 ` [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
2019-07-25 8:55 ` Ni, Ray
@ 2019-07-26 10:38 ` Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Laszlo Ersek @ 2019-07-26 10:38 UTC (permalink / raw)
To: devel, eric.dong; +Cc: Ray Ni, Chandana Kumar, Star Zeng
On 07/24/19 09:07, Dong, Eric wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Produce new EDKII_PEI_MP_SERVICES2_PPI service.
>
> It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
> and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/CpuMpPei/CpuMpPei.c | 21 +-
> UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 +-
> UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 2 +
> UefiCpuPkg/CpuMpPei/Mp2Pei.c | 417 +++++++++++++++++++++++++++++++
> 4 files changed, 436 insertions(+), 7 deletions(-)
> create mode 100644 UefiCpuPkg/CpuMpPei/Mp2Pei.c
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously.
2019-07-24 7:07 [Patch v3 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
` (4 preceding siblings ...)
2019-07-24 7:07 ` [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-24 7:07 ` Dong, Eric
2019-07-25 8:59 ` Ni, Ray
2019-07-26 10:38 ` [edk2-devel] " Laszlo Ersek
5 siblings, 2 replies; 17+ messages in thread
From: Dong, Eric @ 2019-07-24 7:07 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
For semaphore type register, it required all processors to do the
task at the same time.
Current logic begins BSP's task after all APs have finished their tasks.
This will caused set semaphore task hang if semaphore has package
level type.
This patch use new EDKII_PEI_MP_SERVICES2_PPI to start all processors at
the same time to fix the potential hang issue.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
.../CpuFeaturesInitialize.c | 2 +-
.../DxeRegisterCpuFeaturesLib.c | 6 +-
.../PeiRegisterCpuFeaturesLib.c | 66 ++++++++++++++-----
.../PeiRegisterCpuFeaturesLib.inf | 1 +
.../RegisterCpuFeatures.h | 2 +-
5 files changed, 54 insertions(+), 23 deletions(-)
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index 33752c1a9f..4e97e863c7 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -1074,7 +1074,7 @@ CpuFeaturesDetect (
//
// Wakeup all APs for data collection.
//
- StartupAPsWorker (CollectProcessorData, NULL);
+ StartupAllAPsWorker (CollectProcessorData, NULL);
}
//
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
index f87b2892aa..e2e06e88e0 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
@@ -1,7 +1,7 @@
/** @file
CPU Register Table Library functions.
- Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -116,7 +116,7 @@ GetProcessorInformation (
to check whether procedure has done.
**/
VOID
-StartupAPsWorker (
+StartupAllAPsWorker (
IN EFI_AP_PROCEDURE Procedure,
IN EFI_EVENT MpEvent
)
@@ -248,7 +248,7 @@ CpuFeaturesInitialize (
//
// Wakeup all APs for programming.
//
- StartupAPsWorker (SetProcessorRegister, MpEvent);
+ StartupAllAPsWorker (SetProcessorRegister, MpEvent);
}
//
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
index 8ad5a40e5a..52b849ce13 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
@@ -1,7 +1,7 @@
/** @file
CPU Register Table Library functions.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -12,6 +12,8 @@
#include <Library/PeiServicesLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Ppi/MpServices.h>
+#include <Ppi/MpServices2.h>
+
#include "RegisterCpuFeatures.h"
#define REGISTER_CPU_FEATURES_GUID \
@@ -154,7 +156,7 @@ GetProcessorInformation (
**/
VOID
-StartupAPsWorker (
+StartupAllAPsWorker (
IN EFI_AP_PROCEDURE Procedure,
IN EFI_EVENT MpEvent
)
@@ -180,6 +182,48 @@ StartupAPsWorker (
ASSERT_EFI_ERROR (Status);
}
+/**
+ Worker function to execute a caller provided function on all enabled APs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system.
+ @param[in] MpEvent The Event used to sync the result.
+
+**/
+VOID
+StartupAllCPUsWorker (
+ IN EFI_AP_PROCEDURE Procedure
+ )
+{
+ EFI_STATUS Status;
+ EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi;
+ CPU_FEATURES_DATA *CpuFeaturesData;
+
+ CpuFeaturesData = GetCpuFeaturesData ();
+
+ //
+ // Get MP Services2 Ppi
+ //
+ Status = PeiServicesLocatePpi (
+ &gEdkiiPeiMpServices2PpiGuid,
+ 0,
+ NULL,
+ (VOID **)&CpuMp2Ppi
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Wakeup all APs for data collection.
+ //
+ Status = CpuMp2Ppi->StartupAllCPUs (
+ CpuMp2Ppi,
+ Procedure,
+ 0,
+ CpuFeaturesData
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
/**
Worker function to switch the requested AP to be the BSP from that point onward.
@@ -267,23 +311,9 @@ CpuFeaturesInitialize (
CpuFeaturesData->BspNumber = OldBspNumber;
//
- // Known limitation: In PEI phase, CpuFeatures driver not
- // support async mode execute tasks. So semaphore type
- // register can't been used for this instance, must use
- // DXE type instance.
- //
-
- if (CpuFeaturesData->NumberOfCpus > 1) {
- //
- // Wakeup all APs for programming.
- //
- StartupAPsWorker (SetProcessorRegister, NULL);
- }
-
- //
- // Programming BSP
+ // Start to program register for all CPUs.
//
- SetProcessorRegister (CpuFeaturesData);
+ StartupAllCPUsWorker (SetProcessorRegister);
//
// Switch to new BSP if required
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
index 63091dfeb8..61f922bf63 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
@@ -46,6 +46,7 @@
[Ppis]
gEfiPeiMpServicesPpiGuid ## CONSUMES
+ gEdkiiPeiMpServices2PpiGuid ## CONSUMES
[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
index a18f926641..a25dd69292 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
@@ -145,7 +145,7 @@ GetProcessorInformation (
to check whether procedure has done.
**/
VOID
-StartupAPsWorker (
+StartupAllAPsWorker (
IN EFI_AP_PROCEDURE Procedure,
IN EFI_EVENT MpEvent
);
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously.
2019-07-24 7:07 ` [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously Dong, Eric
@ 2019-07-25 8:59 ` Ni, Ray
2019-07-26 10:38 ` [edk2-devel] " Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Ni, Ray @ 2019-07-25 8:59 UTC (permalink / raw)
To: Dong, Eric, devel@edk2.groups.io
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Dong, Eric
> Sent: Wednesday, July 24, 2019 3:07 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all
> processors simultaneously.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> For semaphore type register, it required all processors to do the task at the
> same time.
> Current logic begins BSP's task after all APs have finished their tasks.
> This will caused set semaphore task hang if semaphore has package level
> type.
> This patch use new EDKII_PEI_MP_SERVICES2_PPI to start all processors at
> the same time to fix the potential hang issue.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> .../CpuFeaturesInitialize.c | 2 +-
> .../DxeRegisterCpuFeaturesLib.c | 6 +-
> .../PeiRegisterCpuFeaturesLib.c | 66 ++++++++++++++-----
> .../PeiRegisterCpuFeaturesLib.inf | 1 +
> .../RegisterCpuFeatures.h | 2 +-
> 5 files changed, 54 insertions(+), 23 deletions(-)
>
> diff --git
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> index 33752c1a9f..4e97e863c7 100644
> --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> @@ -1074,7 +1074,7 @@ CpuFeaturesDetect (
> //
> // Wakeup all APs for data collection.
> //
> - StartupAPsWorker (CollectProcessorData, NULL);
> + StartupAllAPsWorker (CollectProcessorData, NULL);
> }
>
> //
> diff --git
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
> index f87b2892aa..e2e06e88e0 100644
> ---
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
> +++
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLi
> +++ b.c
> @@ -1,7 +1,7 @@
> /** @file
> CPU Register Table Library functions.
>
> - Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2017 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -116,7 +116,7 @@ GetProcessorInformation (
> to check whether procedure has done.
> **/
> VOID
> -StartupAPsWorker (
> +StartupAllAPsWorker (
> IN EFI_AP_PROCEDURE Procedure,
> IN EFI_EVENT MpEvent
> )
> @@ -248,7 +248,7 @@ CpuFeaturesInitialize (
> //
> // Wakeup all APs for programming.
> //
> - StartupAPsWorker (SetProcessorRegister, MpEvent);
> + StartupAllAPsWorker (SetProcessorRegister, MpEvent);
> }
>
> //
> diff --git
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
> index 8ad5a40e5a..52b849ce13 100644
> ---
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
> +++
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLi
> +++ b.c
> @@ -1,7 +1,7 @@
> /** @file
> CPU Register Table Library functions.
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -12,6 +12,8 @@
> #include <Library/PeiServicesLib.h>
> #include <Library/PeiServicesTablePointerLib.h>
> #include <Ppi/MpServices.h>
> +#include <Ppi/MpServices2.h>
> +
> #include "RegisterCpuFeatures.h"
>
> #define REGISTER_CPU_FEATURES_GUID \
> @@ -154,7 +156,7 @@ GetProcessorInformation (
>
> **/
> VOID
> -StartupAPsWorker (
> +StartupAllAPsWorker (
> IN EFI_AP_PROCEDURE Procedure,
> IN EFI_EVENT MpEvent
> )
> @@ -180,6 +182,48 @@ StartupAPsWorker (
> ASSERT_EFI_ERROR (Status);
> }
>
> +/**
> + Worker function to execute a caller provided function on all enabled APs.
> +
> + @param[in] Procedure A pointer to the function to be run on
> + enabled APs of the system.
> + @param[in] MpEvent The Event used to sync the result.
> +
> +**/
> +VOID
> +StartupAllCPUsWorker (
> + IN EFI_AP_PROCEDURE Procedure
> + )
> +{
> + EFI_STATUS Status;
> + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi;
> + CPU_FEATURES_DATA *CpuFeaturesData;
> +
> + CpuFeaturesData = GetCpuFeaturesData ();
> +
> + //
> + // Get MP Services2 Ppi
> + //
> + Status = PeiServicesLocatePpi (
> + &gEdkiiPeiMpServices2PpiGuid,
> + 0,
> + NULL,
> + (VOID **)&CpuMp2Ppi
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Wakeup all APs for data collection.
> + //
> + Status = CpuMp2Ppi->StartupAllCPUs (
> + CpuMp2Ppi,
> + Procedure,
> + 0,
> + CpuFeaturesData
> + );
> + ASSERT_EFI_ERROR (Status);
> +}
> +
> /**
> Worker function to switch the requested AP to be the BSP from that point
> onward.
>
> @@ -267,23 +311,9 @@ CpuFeaturesInitialize (
> CpuFeaturesData->BspNumber = OldBspNumber;
>
> //
> - // Known limitation: In PEI phase, CpuFeatures driver not
> - // support async mode execute tasks. So semaphore type
> - // register can't been used for this instance, must use
> - // DXE type instance.
> - //
> -
> - if (CpuFeaturesData->NumberOfCpus > 1) {
> - //
> - // Wakeup all APs for programming.
> - //
> - StartupAPsWorker (SetProcessorRegister, NULL);
> - }
> -
> - //
> - // Programming BSP
> + // Start to program register for all CPUs.
> //
> - SetProcessorRegister (CpuFeaturesData);
> + StartupAllCPUsWorker (SetProcessorRegister);
>
> //
> // Switch to new BSP if required
> diff --git
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.in
> f
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.in
> f
> index 63091dfeb8..61f922bf63 100644
> ---
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.in
> f
> +++
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLi
> +++ b.inf
> @@ -46,6 +46,7 @@
>
> [Ppis]
> gEfiPeiMpServicesPpiGuid ## CONSUMES
> + gEdkiiPeiMpServices2PpiGuid ## CONSUMES
>
> [Pcd]
> gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ##
> CONSUMES
> diff --git
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
> index a18f926641..a25dd69292 100644
> --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
> +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
> @@ -145,7 +145,7 @@ GetProcessorInformation (
> to check whether procedure has done.
> **/
> VOID
> -StartupAPsWorker (
> +StartupAllAPsWorker (
> IN EFI_AP_PROCEDURE Procedure,
> IN EFI_EVENT MpEvent
> );
> --
> 2.21.0.windows.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [edk2-devel] [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously.
2019-07-24 7:07 ` [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously Dong, Eric
2019-07-25 8:59 ` Ni, Ray
@ 2019-07-26 10:38 ` Laszlo Ersek
1 sibling, 0 replies; 17+ messages in thread
From: Laszlo Ersek @ 2019-07-26 10:38 UTC (permalink / raw)
To: devel, eric.dong; +Cc: Ray Ni, Chandana Kumar, Star Zeng
On 07/24/19 09:07, Dong, Eric wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> For semaphore type register, it required all processors to do the
> task at the same time.
> Current logic begins BSP's task after all APs have finished their tasks.
> This will caused set semaphore task hang if semaphore has package
> level type.
> This patch use new EDKII_PEI_MP_SERVICES2_PPI to start all processors at
> the same time to fix the potential hang issue.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> .../CpuFeaturesInitialize.c | 2 +-
> .../DxeRegisterCpuFeaturesLib.c | 6 +-
> .../PeiRegisterCpuFeaturesLib.c | 66 ++++++++++++++-----
> .../PeiRegisterCpuFeaturesLib.inf | 1 +
> .../RegisterCpuFeatures.h | 2 +-
> 5 files changed, 54 insertions(+), 23 deletions(-)
My testing did not cover this patch.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 17+ messages in thread