[edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP index == 0 Assumption.

Dong, Eric eric.dong at intel.com
Wed Jan 15 07:52:38 UTC 2020


Ray,

I applied this change to an internal desktop machine and did below tests:

1.       boot it to shell

2.       reboot the system to shell.

Thanks,
Eric
From: Ni, Ray
Sent: Wednesday, January 15, 2020 3:43 PM
To: devel at edk2.groups.io; Dong, Eric <eric.dong at intel.com>
Cc: Laszlo Ersek <lersek at redhat.com>
Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP index == 0 Assumption.

Eric,
What unit test was done for this patch?

> -----Original Message-----
> From: devel at edk2.groups.io<mailto:devel at edk2.groups.io> <devel at edk2.groups.io<mailto:devel at edk2.groups.io>> On Behalf Of Dong, Eric
> Sent: Wednesday, January 15, 2020 2:07 PM
> To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>
> Cc: Ni, Ray <ray.ni at intel.com<mailto:ray.ni at intel.com>>; Laszlo Ersek <lersek at redhat.com<mailto:lersek at redhat.com>>
> Subject: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP index == 0 Assumption.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2392
>
>
> Current code implementation assumes BSP index is 0 at the begin.
> This code change removes this assumption. It get BSP index from
> the saved data structure if it existed.
>
> Cc: Ray Ni <ray.ni at intel.com<mailto:ray.ni at intel.com>>
> Cc: Laszlo Ersek <lersek at redhat.com<mailto:lersek at redhat.com>>
> Signed-off-by: Eric Dong <eric.dong at intel.com<mailto:eric.dong at intel.com>>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 6ec9b172b8..922c87b766 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -636,7 +636,7 @@ ApWakeupFunction (
>        //   to initialize AP in InitConfig path.
>
>        // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegisters points to a different IDT shared by all APs.
>
>        //
>
> -      RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, FALSE);
>
> +      RestoreVolatileRegisters (&CpuMpData->CpuData[CpuMpData->BspNumber].VolatileRegisters, FALSE);
>
>        InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack);
>
>        ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal;
>
>
>
> @@ -1615,6 +1615,7 @@ MpInitLibInitialize (
>    UINTN                    ApResetVectorSize;
>
>    UINTN                    BackupBufferAddr;
>
>    UINTN                    ApIdtBase;
>
> +  UINT64                   BspTopOfStack;
>
>
>
>    OldCpuMpData = GetCpuMpDataFromGuidedHob ();
>
>    if (OldCpuMpData == NULL) {
>
> @@ -1677,7 +1678,7 @@ MpInitLibInitialize (
>    CpuMpData->BackupBufferSize = ApResetVectorSize;
>
>    CpuMpData->WakeupBuffer     = (UINTN) -1;
>
>    CpuMpData->CpuCount         = 1;
>
> -  CpuMpData->BspNumber        = 0;
>
> +  CpuMpData->BspNumber        = OldCpuMpData != NULL ? OldCpuMpData->BspNumber : 0;
>
>    CpuMpData->WaitEvent        = NULL;
>
>    CpuMpData->SwitchBspFlag    = FALSE;
>
>    CpuMpData->CpuData          = (CPU_AP_DATA *) (CpuMpData + 1);
>
> @@ -1704,11 +1705,12 @@ MpInitLibInitialize (
>    // Don't pass BSP's TR to APs to avoid AP init failure.
>
>    //
>
>    VolatileRegisters.Tr = 0;
>
> -  CopyMem (&CpuMpData->CpuData[0].VolatileRegisters, &VolatileRegisters, sizeof (VolatileRegisters));
>
> +  CopyMem (&CpuMpData->CpuData[CpuMpData->BspNumber].VolatileRegisters, &VolatileRegisters, sizeof
> (VolatileRegisters));
>
>    //
>
>    // Set BSP basic information
>
>    //
>
> -  InitializeApData (CpuMpData, 0, 0, CpuMpData->Buffer + ApStackSize);
>
> +  BspTopOfStack = CpuMpData->Buffer + (CpuMpData->BspNumber + 1) * CpuMpData->CpuApStackSize;
>
> +  InitializeApData (CpuMpData, CpuMpData->BspNumber, 0, BspTopOfStack);
>
>    //
>
>    // Save assembly code information
>
>    //
>
> --
> 2.23.0.windows.1
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
>
> View/Reply Online (#53263): https://edk2.groups.io/g/devel/message/53263
> Mute This Topic: https://groups.io/mt/69712223/1712937
> Group Owner: devel+owner at edk2.groups.io<mailto:devel+owner at edk2.groups.io>
> Unsubscribe: https://edk2.groups.io/g/devel/unsub  [ray.ni at intel.com]
> -=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#53265): https://edk2.groups.io/g/devel/message/53265
Mute This Topic: https://groups.io/mt/69712223/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20200115/354641b2/attachment.htm>


More information about the edk2-devel-archive mailing list