From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 B034E2232BDF1 for ; Mon, 22 Jan 2018 02:57:35 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 03:03:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,396,1511856000"; d="scan'208";a="197540528" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 22 Jan 2018 03:03:00 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Jan 2018 03:03:00 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Jan 2018 03:03:00 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Mon, 22 Jan 2018 19:02:58 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [PATCH] UefiCpuPkg/PeiMpLib: Fix a system hang-in-pei issue. Thread-Index: AQHTk2HE3xggx3rsDUKJASNdfyx176N/uH+w Date: Mon, 22 Jan 2018 11:02:57 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BA009FA@shsmsx102.ccr.corp.intel.com> References: <20180122091659.283656-1-ruiyu.ni@intel.com> In-Reply-To: <20180122091659.283656-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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: Mon, 22 Jan 2018 10:57:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable In fact, the failure case is like below. GetWakeupBuffer() could find < 1M range, but it will always fail with the c= heck 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 =3D UINT32. The code change is good to me, Reviewed-by: Star Zeng How about updating the commit log? :) Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 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 u= p 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/M= pInitLib/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. =20 - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights=20 + reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -75,15 +75,15 @@ SaveCpuMpData ( **/ BOOLEAN CheckOverlapW= ithAllocatedBuffer ( - 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; =20 Overlapped =3D FALSE; // @@ -96,9 +96,8 @@ CheckOverlapWithAllocatedBuffer ( while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) { MemoryHob =3D Hob.MemoryAllocation; - MemoryStart =3D (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress= ; - MemoryEnd =3D (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddres= s + - MemoryHob->AllocDescriptor.MemoryLength); + MemoryStart =3D MemoryHob->AllocDescriptor.MemoryBaseAddress; + MemoryEnd =3D MemoryHob->AllocDescriptor.MemoryBaseAddress + Memor= yHob->AllocDescriptor.MemoryLength; if (!((WakeupBufferStart >=3D MemoryEnd) || (WakeupBufferEnd <=3D Me= moryStart))) { Overlapped =3D TRUE; break; @@ -123,8 +122,8 @@ GetWakeupBuffer ( ) { EFI_PEI_HOB_POINTERS Hob; - UINTN WakeupBufferStart; - UINTN WakeupBufferEnd; + UINT64 WakeupBufferStart; + UINT64 WakeupBufferEnd; =20 WakeupBufferSize =3D (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1)= ; =20 @@ -149,7 +148,7 @@ GetWakeupBuffer ( // // Need memory under 1MB to be collected here // - WakeupBufferEnd =3D (UINTN) (Hob.ResourceDescriptor->PhysicalStart= + Hob.ResourceDescriptor->ResourceLength); + WakeupBufferEnd =3D Hob.ResourceDescriptor->PhysicalStart +=20 + Hob.ResourceDescriptor->ResourceLength; if (WakeupBufferEnd > BASE_1MB) { // // Wakeup buffer should be under 1MB @@ -174,7 +173,7 @@ GetWake= upBuffer ( } DEBUG ((DEBUG_INFO, "WakeupBufferStart =3D %x, WakeupBufferSize = =3D %x\n", WakeupBufferStart, WakeupBufferSize)); - return WakeupBufferStart; + return (UINTN)WakeupBufferStart; } } } -- 2.15.1.windows.2