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.31; helo=mga06.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 BCA7A21102D96 for ; Mon, 27 Aug 2018 00:52:53 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2018 00:52:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,294,1531810800"; d="scan'208";a="86641658" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.8]) by orsmga002.jf.intel.com with ESMTP; 27 Aug 2018 00:52:52 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Hao Wu , Andrew Fish Date: Mon, 27 Aug 2018 15:53:27 +0800 Message-Id: <20180827075330.269224-8-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180827075330.269224-1-ruiyu.ni@intel.com> References: <20180827075330.269224-1-ruiyu.ni@intel.com> Subject: [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Aug 2018 07:52:53 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1119 Today's implementation unconditionally reports CPU address size as 36 through CPU HOB. But when WinHost is running at 64bit, the system memory might be allocated above 2^36. It causes system asserts when DxeCore code tries to find the corresponding GCD entry for a given valid address. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Hao Wu Cc: Andrew Fish --- EmulatorPkg/AutoScanPei/AutoScanPei.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.c b/EmulatorPkg/AutoScanPei/AutoScanPei.c index 78a40db3a2..bf9958a4a9 100644 --- a/EmulatorPkg/AutoScanPei/AutoScanPei.c +++ b/EmulatorPkg/AutoScanPei/AutoScanPei.c @@ -1,6 +1,6 @@ /*++ @file -Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
Portions copyright (c) 2011, Apple Inc. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -51,7 +51,8 @@ Returns: EFI_PHYSICAL_ADDRESS MemoryBase; UINTN Index; EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; - + UINTN HighBitSet; + UINT8 SizeOfMemorySpace; DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n")); @@ -66,7 +67,8 @@ Returns: ); ASSERT_EFI_ERROR (Status); - Index = 0; + SizeOfMemorySpace = 0; + Index = 0; do { Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize); if (!EFI_ERROR (Status)) { @@ -96,6 +98,12 @@ Returns: MemoryBase, MemorySize ); + HighBitSet = HighBitSet64 (MemoryBase + MemorySize); + SizeOfMemorySpace = MAX (SizeOfMemorySpace, (UINT8)HighBitSet + 1); + DEBUG (( + DEBUG_INFO, "Emu Memory Discoverred[%d]: Base = %016lx / Size = %016x\n", + Index, MemoryBase, MemorySize + )); } Index++; } while (!EFI_ERROR (Status)); @@ -103,7 +111,8 @@ Returns: // // Build the CPU hob with 36-bit addressing and 16-bits of IO space. // - BuildCpuHob (36, 16); + DEBUG ((DEBUG_INFO, "Emu SizeOfMemorySpace = %d\n", SizeOfMemorySpace)); + BuildCpuHob (SizeOfMemorySpace, 16); return Status; } -- 2.16.1.windows.1