It's a good optimization.

Can you eliminate the GetApResetStackSize() and embed the check and calculation 
in GetApResetVectorSize()?
Reason: GetApResetStackSize() is only called in one place. Removing the 
additional layer of function call makes
the code easier to read.

Thanks,
Ray

> -----Original Message-----
> From: Tom Lendacky <[email protected]>
> Sent: Wednesday, September 23, 2020 3:59 AM
> To: [email protected]
> Cc: Dong, Eric <[email protected]>; Ni, Ray <[email protected]>; Laszlo Ersek
> <[email protected]>; Kumar, Rahul1 <[email protected]>; Brijesh
> Singh <[email protected]>; Garrett Kirkendall
> <[email protected]>
> Subject: [PATCH 1/1] UefiCpuPkg/MpInitLib: Reduce reset vector memory
> pressure
> 
> From: Tom Lendacky <[email protected]>
> 
> The AP reset vector stack allocation is only required if running as an
> SEV-ES guest. Since the reset vector allocation is below 1MB in memory,
> eliminate the requirement for bare-metal systems and non SEV-ES guests
> to allocate the extra stack area, which can be large if the
> PcdCpuMaxLogicalProcessorNumber value is large.
> 
> Cc: Garrett Kirkendall <[email protected]>
> Signed-off-by: Tom Lendacky <[email protected]>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 07426274f639..39af2f9fba7d 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -1152,7 +1152,15 @@ GetApResetStackSize (
>    VOID
>    )
>  {
> -  return AP_RESET_STACK_SIZE *
> PcdGet32(PcdCpuMaxLogicalProcessorNumber);
> +  //
> +  // The AP reset stack is only used by SEV-ES guests. Don't add to the
> +  // allocation if not necessary.
> +  //
> +  if (PcdGetBool (PcdSevEsIsEnabled) == TRUE) {
> +    return AP_RESET_STACK_SIZE *
> PcdGet32(PcdCpuMaxLogicalProcessorNumber);
> +  } else {
> +    return 0;
> +  }
>  }
> 
>  /**
> --
> 2.28.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#65488): https://edk2.groups.io/g/devel/message/65488
Mute This Topic: https://groups.io/mt/77021282/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to