public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Jeff Fan <jeff.fan@intel.com>, edk2-devel@ml01.01.org
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jiewen Yao <jiewen.yao@intel.com>
Subject: Re: [PATCH v2] UefiCpuPkg/DxeMpLib: Allocate below 4GB mem for AsmRelocateApLoopFunc
Date: Fri, 11 Nov 2016 13:08:10 +0100	[thread overview]
Message-ID: <1a64a6db-39a6-6e67-218d-58e2feb9cd5d@redhat.com> (raw)
In-Reply-To: <94d628af-b57c-9d69-3629-3e57cf9192e6@redhat.com>

On 11/11/16 11:51, Laszlo Ersek wrote:
> 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 

There was a superfluous space character at the end of this line
(reported by git-am), but I removed it.

>> +  // 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)),
>> +                   &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,
>>
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 

Tested-by: Laszlo Ersek <lersek@redhat.com>
[lersek@redhat.com: strip whitespace at EOL]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Commit ffd6b0b1b65e.

(I pushed the patch because it's simple -- Jeff is the sole maintainer,
according to Maintainers.txt, of UefiCpuPkg, and I thought he'd push
this simple patch with just my review anyway. I'm trying to flush my
review / test queue, simplifying the possible orderings between the
pending patch sets.)

Thanks
Laszlo


  reply	other threads:[~2016-11-11 12:08 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 [this message]
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
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=1a64a6db-39a6-6e67-218d-58e2feb9cd5d@redhat.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