From nobody Sun Feb 8 19:37:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96320+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96320+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1668225665; cv=none; d=zohomail.com; s=zohoarc; b=QyZdcxzEFgY7iPlPbrrdP4WB0ro9iEa60uTUNjOB30a3GNCHnq8Ebn1wXCKAkjZLITbYSgXwAJetkFH8yuXftERC/X4xLfCVhxWdlqV1Ah19cWz6M4VzhVNxBHEqmyTAuceh1EEcdoqb8ZdONPVhvXl/RTN5chHqgQs5ZS97ikk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668225665; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=EyIKhDZHfvwClaYqh8n9lL4UL7RFOpKIW9VB4GAjByQ=; b=D2WTlk1Q40OAGiJ693wS1vU7jAy0vMGGfJYjmGAy7FQePwkt/QMQe28iHn6AumIz3dxrgQYA/Gls5hpqC2M+Jx9bbcoK80Jpbc+IMmIQ2/4gLGW7NDLNrPGItbIS8CfW188+zpZIrg9eJIUTX0eZP33XSw6/xsLxYskNIpaBSAM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96320+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668225665288517.6708881285399; Fri, 11 Nov 2022 20:01:05 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bxA0YY1788612xfWmq0wA26A; Fri, 11 Nov 2022 20:01:05 -0800 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.1518.1668225663457832422 for ; Fri, 11 Nov 2022 20:01:04 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="373827651" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="373827651" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 20:01:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="588725569" X-IronPort-AV: E=Sophos;i="5.96,158,1665471600"; d="scan'208";a="588725569" X-Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.56.10]) by orsmga003.jf.intel.com with ESMTP; 11 Nov 2022 20:00:47 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Andrew Fish , Zhiguang Liu Subject: [edk2-devel] [PATCH 1/3] EmulatorPkg/WinHost: pre-allocate "physical" RAM Date: Sat, 12 Nov 2022 12:00:40 +0800 Message-Id: <20221112040042.741-2-ray.ni@intel.com> In-Reply-To: <20221112040042.741-1-ray.ni@intel.com> References: <20221112040042.741-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: P49Zjvbqgk6VvSLeOPoE6H7ax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668225665; bh=VKJt/4eM0jvn/PwIZAOP02PM7BATDxVxfnXUSM/S5OA=; h=Cc:Date:From:Reply-To:Subject:To; b=OxHadDS5dmKwmtU2I15MhaKCHN4++hDCR+27TK6oWFS6Vykk7zxWxmqPpNdGq3kNi/8 FytghqFU0tC36Rm7N1aMLwyhVbjC45zB+wuTjm96WzClU5HF04EPqcBEN2ZQuaZZHutxJ MYZ1JugcsMAVrr7Jlc9ad+SRCLHOJC1ERAQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668225666569100005 Content-Type: text/plain; charset="utf-8" Move the "physical" RAM allocation from WinPeiAutoScan to main() entrypoint. This is to prepare the changes for "reset" support. Signed-off-by: Ray Ni Cc: Andrew Fish Cc: Zhiguang Liu --- EmulatorPkg/Win/Host/WinHost.c | 60 ++++++++++++++-------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 93247c5043..5b780ca8af 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -8,7 +8,7 @@ This code produces 128 K of temporary memory for the SEC stack by direct= ly allocate memory space with ReadWrite and Execute attribute. =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
(C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -87,14 +87,6 @@ WinPeiAutoScan ( return EFI_UNSUPPORTED; } =20 - // - // Allocate enough memory space for emulator - // - gSystemMemory[Index].Memory =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAllo= c (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_READ= WRITE); - if (gSystemMemory[Index].Memory =3D=3D 0) { - return EFI_OUT_OF_RESOURCES; - } - *MemoryBase =3D gSystemMemory[Index].Memory; *MemorySize =3D gSystemMemory[Index].Size; =20 @@ -457,6 +449,30 @@ Returns: exit (1); } =20 + // + // Allocate "physical" memory space for emulator. It will be reported ou= t later throuth MemoryAutoScan() + // + for (Index =3D 0, Done =3D FALSE; !Done; Index++) { + ASSERT (Index < gSystemMemoryCount); + gSystemMemory[Index].Size =3D ((UINT64)_wtoi (MemorySizeStr)) * ((UI= NT64)SIZE_1MB); + gSystemMemory[Index].Memory =3D (EFI_PHYSICAL_ADDRESS)(UINTN)VirtualAl= loc (NULL, (SIZE_T)(gSystemMemory[Index].Size), MEM_COMMIT, PAGE_EXECUTE_RE= ADWRITE); + if (gSystemMemory[Index].Memory =3D=3D 0) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Find the next region + // + for (Index1 =3D 0; MemorySizeStr[Index1] !=3D '!' && MemorySizeStr[Ind= ex1] !=3D 0; Index1++) { + } + + if (MemorySizeStr[Index1] =3D=3D 0) { + Done =3D TRUE; + } + + MemorySizeStr =3D MemorySizeStr + Index1 + 1; + } + // // Allocate space for gSystemMemory Array // @@ -575,32 +591,6 @@ Returns: SecPrint ("\n\r"); } =20 - // - // Calculate memory regions and store the information in the gSystemMemo= ry - // global for later use. The autosizing code will use this data to - // map this memory into the SEC process memory space. - // - for (Index =3D 0, Done =3D FALSE; !Done; Index++) { - // - // Save the size of the memory and make a Unicode filename SystemMemor= y00, ... - // - gSystemMemory[Index].Size =3D ((UINT64)_wtoi (MemorySizeStr)) * ((UINT= 64)SIZE_1MB); - - // - // Find the next region - // - for (Index1 =3D 0; MemorySizeStr[Index1] !=3D '!' && MemorySizeStr[Ind= ex1] !=3D 0; Index1++) { - } - - if (MemorySizeStr[Index1] =3D=3D 0) { - Done =3D TRUE; - } - - MemorySizeStr =3D MemorySizeStr + Index1 + 1; - } - - SecPrint ("\n\r"); - // // Hand off to SEC Core // --=20 2.37.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96320): https://edk2.groups.io/g/devel/message/96320 Mute This Topic: https://groups.io/mt/94974520/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-