From: "Lendacky, Thomas" <thomas.lendacky@amd.com>
To: devel@edk2.groups.io, yuanhao.xie@intel.com
Cc: Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
Rahul Kumar <rahul1.kumar@intel.com>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Use Top of each AP's stack to save CpuMpData
Date: Fri, 26 Aug 2022 09:27:27 -0500 [thread overview]
Message-ID: <f00bb4fc-fb5a-6339-86f5-00ebbc634d50@amd.com> (raw)
In-Reply-To: <20220816075715.932-1-yuanhao.xie@intel.com>
On 8/16/22 02:57, Yuanhao Xie via groups.io wrote:
> To remove the dependency of CPU register, 4/8 byte at the top of the stack
> is occupied for CpuMpData. BIST information is also taken care here.
> This modification is only for PEI phase, since in DXE phase CpuMpData is
> accessed via global variable.
>
> Signed-off-by: Yuanhao <yuanhao.xie@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> ---
> .../Library/MpInitLib/Ia32/MpFuncs.nasm | 5 +++
> UefiCpuPkg/Library/MpInitLib/MpLib.c | 41 ++++++++++++++-----
> UefiCpuPkg/Library/MpInitLib/MpLib.h | 8 ++++
> UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 10 +++--
> UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 6 +++
> 5 files changed, 56 insertions(+), 14 deletions(-)
>
> @@ -1796,30 +1806,41 @@ MpInitLibInitialize (
> AsmGetAddressMap (&AddressMap);
> GetApResetVectorSize (&AddressMap, &ApResetVectorSizeBelow1Mb, &ApResetVectorSizeAbove1Mb);
> ApStackSize = PcdGet32 (PcdCpuApStackSize);
> - ApLoopMode = GetApLoopMode (&MonitorFilterSize);
> + //
> + // ApStackSize must be power of 2
> + //
> + ASSERT ((ApStackSize & (ApStackSize - 1)) == 0);
> + ApLoopMode = GetApLoopMode (&MonitorFilterSize);
>
> //
> // Save BSP's Control registers for APs.
> //
> SaveVolatileRegisters (&VolatileRegisters);
>
> + //
> + // Allocate extra ApStackSize to let AP stack align on ApStackSize bounday
> + //
> BufferSize = ApStackSize * MaxLogicalProcessorNumber;
> + BufferSize += ApStackSize;
> BufferSize += MonitorFilterSize * MaxLogicalProcessorNumber;
> BufferSize += ApResetVectorSizeBelow1Mb;
> BufferSize = ALIGN_VALUE (BufferSize, 8);
> BufferSize += VolatileRegisters.Idtr.Limit + 1;
> BufferSize += sizeof (CPU_MP_DATA);
> BufferSize += (sizeof (CPU_AP_DATA) + sizeof (CPU_INFO_IN_HOB))* MaxLogicalProcessorNumber;
> - MpBuffer = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize));
> + //
> + // Allocate extra ApStackSize to let stack align on ApStackSize bounday
> + //
> + MpBuffer = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize));
If you're allocating pages, is all the alignment stuff really necessary?
The allocated value is going to be page aligned already, right?
Thanks,
Tom
> ASSERT (MpBuffer != NULL);
> ZeroMem (MpBuffer, BufferSize);
> - Buffer = (UINTN)MpBuffer;
> + Buffer = ALIGN_VALUE ((UINTN)MpBuffer, ApStackSize);
>
prev parent reply other threads:[~2022-08-26 14:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 7:57 [PATCH] UefiCpuPkg: Use Top of each AP's stack to save CpuMpData Yuanhao Xie
2022-08-16 9:14 ` [edk2-devel] " Ni, Ray
2022-08-26 14:27 ` Lendacky, Thomas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f00bb4fc-fb5a-6339-86f5-00ebbc634d50@amd.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox