From: "Fan, Jeff" <jeff.fan@intel.com>
To: Laszlo Ersek <lersek@redhat.com>,
"edk2-devel@ml01.01.org" <edk2-devel@ml01.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Yao, Jiewen" <jiewen.yao@intel.com>
Subject: Re: [PATCH v2] UefiCpuPkg/DxeMpLib: Allocate below 4GB mem for AsmRelocateApLoopFunc
Date: Tue, 15 Nov 2016 01:46:58 +0000 [thread overview]
Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4A2DD203@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: 54156d2c-cbf5-ea32-8a29-7b1e5ae9bdd7@redhat.com
Laszlo,
Oh. It's another committed patch, I will send another patch to fix it.
Jeff
-----Original Message-----
From: Fan, Jeff
Sent: Tuesday, November 15, 2016 9:43 AM
To: Laszlo Ersek; edk2-devel@ml01.01.org
Cc: Kinney, Michael D; Paolo Bonzini; Yao, Jiewen
Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/DxeMpLib: Allocate below 4GB mem for AsmRelocateApLoopFunc
Laszlo,
Good catch before I push this serial of patch. I will remove sizeof() when I push the patch.
Thanks!
Jeff
-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Tuesday, November 15, 2016 9:40 AM
To: Fan, Jeff; edk2-devel@ml01.01.org
Cc: Kinney, Michael D; Paolo Bonzini; Yao, Jiewen
Subject: Re: [edk2] [PATCH v2] UefiCpuPkg/DxeMpLib: Allocate below 4GB mem for AsmRelocateApLoopFunc
Jeff,
independently from the other discussion, I found a small mistake in this patch (after I reviewed, tested, and committed it for you...):
On 11/11/16 09:56, Jeff Fan wrote:
> Current implementation just allocates reserve memory for AsmRelocateApLoopFunc.
> It not be safe because APs will be placed into 32bit protected mode on
> long mode DXE. This reserve memory must be located below 4GB memory.
>
> This fix is to allocate < 4GB memory for AsmRelocateApLoopFunc.
>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan <jeff.fan@intel.com>
> ---
> UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 27
> ++++++++++++++++++++-------
> 1 file changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> index eb36d6f..4b929ff 100644
> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> @@ -286,7 +286,8 @@ InitMpGlobalData (
> IN CPU_MP_DATA *CpuMpData
> )
> {
> - EFI_STATUS Status;
> + EFI_STATUS Status;
> + EFI_PHYSICAL_ADDRESS Address;
>
> SaveCpuMpData (CpuMpData);
>
> @@ -298,16 +299,28 @@ InitMpGlobalData (
> }
>
> //
> - // Avoid APs access invalid buff data which allocated by
> BootServices,
> - // so we will allocate reserved data for AP loop code.
> + // Avoid APs access invalid buffer data which allocated by
> + BootServices, // so we will allocate reserved data for AP loop
> + code. We also need to // allocate this buffer below 4GB due to APs
> + may be transferred to 32bit // protected mode on long mode DXE.
> // Allocating it in advance since memory services are not available in
> // Exit Boot Services callback function.
> //
> - mReservedApLoopFunc = AllocateReservedCopyPool (
> - CpuMpData->AddressMap.RelocateApLoopFuncSize,
> - CpuMpData->AddressMap.RelocateApLoopFuncAddress
> - );
> + Address = BASE_4GB - 1;
> + Status = gBS->AllocatePages (
> + AllocateMaxAddress,
> + EfiReservedMemoryType,
> + EFI_SIZE_TO_PAGES (sizeof
> + (CpuMpData->AddressMap.RelocateApLoopFuncSize)),
The "sizeof" operator should be unnecessary here.
(It is no problem in practice because the function size is really small, so it gets rounded up to 1 page anyway.)
Sorry for not noticing this earlier.
Thanks
Laszlo
> + &Address
> + );
> + ASSERT_EFI_ERROR (Status);
> + mReservedApLoopFunc = (VOID *) (UINTN) Address;
> ASSERT (mReservedApLoopFunc != NULL);
> + CopyMem (
> + mReservedApLoopFunc,
> + CpuMpData->AddressMap.RelocateApLoopFuncAddress,
> + CpuMpData->AddressMap.RelocateApLoopFuncSize
> + );
>
> Status = gBS->CreateEvent (
> EVT_TIMER | EVT_NOTIFY_SIGNAL,
>
next prev parent reply other threads:[~2016-11-15 1:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 8:56 [PATCH v2] UefiCpuPkg/DxeMpLib: Allocate below 4GB mem for AsmRelocateApLoopFunc Jeff Fan
2016-11-11 10:51 ` Laszlo Ersek
2016-11-11 12:08 ` Laszlo Ersek
2016-11-11 12:15 ` Fan, Jeff
2016-11-15 1:40 ` Laszlo Ersek
2016-11-15 1:42 ` Fan, Jeff
2016-11-15 1:46 ` Fan, Jeff [this message]
2016-11-15 1:50 ` Laszlo Ersek
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=542CF652F8836A4AB8DBFAAD40ED192A4A2DD203@shsmsx102.ccr.corp.intel.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