From nobody Thu May 2 05:28:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516612625579345.1248522051544; Mon, 22 Jan 2018 01:17:05 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7C07A222CF1DD; Mon, 22 Jan 2018 01:11:38 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 8A70321F833CB for ; Mon, 22 Jan 2018 01:11:36 -0800 (PST) Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 01:17:01 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga007.fm.intel.com with ESMTP; 22 Jan 2018 01:17:00 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,396,1511856000"; d="scan'208";a="12033343" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 17:16:59 +0800 Message-Id: <20180122091659.283656-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [edk2] [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: , Cc: Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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/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 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 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; =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 + Hob.Re= sourceDescriptor->ResourceLength; if (WakeupBufferEnd > BASE_1MB) { // // Wakeup buffer should be under 1MB @@ -174,7 +173,7 @@ GetWakeupBuffer ( } DEBUG ((DEBUG_INFO, "WakeupBufferStart =3D %x, WakeupBufferSize = =3D %x\n", WakeupBufferStart, WakeupBufferSize)); - return WakeupBufferStart; + return (UINTN)WakeupBufferStart; } } } --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel