From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 013A2221F93D4 for ; Tue, 23 Jan 2018 18:51:58 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2018 18:57:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,405,1511856000"; d="scan'208";a="24937727" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.19]) ([10.239.9.19]) by fmsmga001.fm.intel.com with ESMTP; 23 Jan 2018 18:57:11 -0800 To: "Zeng, Star" , "edk2-devel@lists.01.org" Cc: "Dong, Eric" References: <20180122091659.283656-1-ruiyu.ni@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BA009FA@shsmsx102.ccr.corp.intel.com> From: "Ni, Ruiyu" Message-ID: <3b55c1a0-7b64-279d-5ce3-c82dcf193231@Intel.com> Date: Wed, 24 Jan 2018 10:57:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BA009FA@shsmsx102.ccr.corp.intel.com> Subject: Re: [PATCH] UefiCpuPkg/PeiMpLib: Fix a system hang-in-pei issue. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 02:51:59 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 1/22/2018 7:02 PM, Zeng, Star wrote: > In fact, the failure case is like below. > > GetWakeupBuffer() could find < 1M range, but it will always fail with the check in CheckOverlapWithAllocatedBuffer() when there is a memory allocation hob for a range like base 0xff00000000 with size 0x10000000, the high bits 'ff' in base 0xff00000000 will be truncated when UINTN = UINT32. > > > The code change is good to me, Reviewed-by: Star Zeng > How about updating the commit log? :) Sure. I will update the commit message. > > > Thanks, > Star > -----Original Message----- > From: Ni, Ruiyu > Sent: Monday, January 22, 2018 5:17 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric ; Zeng, Star > Subject: [PATCH] UefiCpuPkg/PeiMpLib: Fix a system hang-in-pei issue. > > When HOB contains a system memory resource which is above 4GB, the (UINTN) typecast truncates the high-32 bits. > It causes a memory range above 4GB be used by CpuMpPei code as the waking up buffer. > > The patch fixes this issue by using UINT64 type. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Eric Dong > Cc: Star Zeng > --- > UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 23 +++++++++++------------ > 1 file changed, 11 insertions(+), 12 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > index ad43bd33f5..791ae9db6e 100644 > --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > @@ -1,7 +1,7 @@ > /** @file > MP initialize support functions for PEI phase. > > - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights > + reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD License > which accompanies this distribution. The full text of the license may be found at @@ -75,15 +75,15 @@ SaveCpuMpData ( **/ BOOLEAN CheckOverlapWithAllocatedBuffer ( > - IN UINTN WakeupBufferStart, > - IN UINTN WakeupBufferEnd > + IN UINT64 WakeupBufferStart, > + IN UINT64 WakeupBufferEnd > ) > { > EFI_PEI_HOB_POINTERS Hob; > EFI_HOB_MEMORY_ALLOCATION *MemoryHob; > BOOLEAN Overlapped; > - UINTN MemoryStart; > - UINTN MemoryEnd; > + UINT64 MemoryStart; > + UINT64 MemoryEnd; > > Overlapped = FALSE; > // > @@ -96,9 +96,8 @@ CheckOverlapWithAllocatedBuffer ( > while (!END_OF_HOB_LIST (Hob)) { > if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) { > MemoryHob = Hob.MemoryAllocation; > - MemoryStart = (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress; > - MemoryEnd = (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddress + > - MemoryHob->AllocDescriptor.MemoryLength); > + MemoryStart = MemoryHob->AllocDescriptor.MemoryBaseAddress; > + MemoryEnd = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength; > if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) { > Overlapped = TRUE; > break; > @@ -123,8 +122,8 @@ GetWakeupBuffer ( > ) > { > EFI_PEI_HOB_POINTERS Hob; > - UINTN WakeupBufferStart; > - UINTN WakeupBufferEnd; > + UINT64 WakeupBufferStart; > + UINT64 WakeupBufferEnd; > > WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1); > > @@ -149,7 +148,7 @@ GetWakeupBuffer ( > // > // Need memory under 1MB to be collected here > // > - WakeupBufferEnd = (UINTN) (Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength); > + WakeupBufferEnd = Hob.ResourceDescriptor->PhysicalStart + > + Hob.ResourceDescriptor->ResourceLength; > if (WakeupBufferEnd > BASE_1MB) { > // > // Wakeup buffer should be under 1MB @@ -174,7 +173,7 @@ GetWakeupBuffer ( > } > DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n", > WakeupBufferStart, WakeupBufferSize)); > - return WakeupBufferStart; > + return (UINTN)WakeupBufferStart; > } > } > } > -- > 2.15.1.windows.2 > -- Thanks, Ray