From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web12.50468.1654007497740690682 for ; Tue, 31 May 2022 07:31:38 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=juY5hkLd; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654007497; x=1685543497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VKh9VQjZ58b6ckBL/6uzI+94lzZegifqjXE14KfBcQU=; b=juY5hkLdU2zEG5ObmKhi6l2mZi5MwrdgAoY5Xjv9elYqSqLQPrfLxSRX yQXYYAB0uInaVFEorzEHCGqe5knHlp2QXTgWPOjsivK6inCP8U/7ndICj /D1l3WkMyBXL833ps5ISLZfRNe90b2Wz6RG1CLP6RgIfwqiFl3TQKv+RY n13DEkkoolpWb49R//YCKExtc+4iiG/a9N43aDqsQ55gxaN6OIB3sLT0n +k+hFjnlkvCfQyeq3RbYbePiuHlKTsl2hXIWO4CZxTl1DvQmmdE3Epxck yckXWudaDeFaGpEam35uc5rnSSp+ssQ2qcT2MpAKEvlKZ+0cAXMmQZMMC A==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="335928102" X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="335928102" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 07:31:36 -0700 X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="605697664" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.6]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 07:31:34 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [PATCH 2/2] OvmfPkg: Search EFI_RESOURCE_MEMORY_UNACCEPTED for Fw hoblist Date: Tue, 31 May 2022 22:31:17 +0800 Message-Id: <4a4fc3a0e4084dbadcacac95b11d246c6b3b7539.1654007213.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In current TDVF implementation all unaccepted memory passed in Hoblist are tagged as EFI_RESOURCE_MEMORY_UNACCEPTED. They're all accepted before they can be accessed. After accepting memory region, the Hob ResourceType is unchanged (still be EFI_RESOURCE_MEMORY_UNACCEPTED). TDVF Config-B skip PEI phase and it tries to find a memory region which is the largest one below 4GB. Then this memory region will be used as the firmware hoblist. So we should walk thru the input hoblist and search for the memory region with the type of EFI_RESOURCE_MEMORY_UNACCEPTED. Because EFI_RESOURCE_MEMORY_UNACCEPTED has not been officially in PI spec. So it cannot be defined in MdePkg/Include/Pi/PiHob.h. As a temporary solution it is defined in Hob.c. There is a patch-set for lazy-accept very soon. In that patch-set EFI_RESOURCE_MEMORY_UNACCEPTED will be defined in MdeModulePkg. Config-B: https://edk2.groups.io/g/devel/message/76367 Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Ccigned-off-by: Min Xu --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/PeilessStartupLib/Hob.c index 3c544ca1f67d..5fc84a809025 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -22,6 +22,8 @@ #include #include "PeilessStartupInternal.h" +#define EFI_RESOURCE_MEMORY_UNACCEPTED 7 + /** * Construct the HobList in SEC phase. * @@ -90,7 +92,7 @@ ConstructFwHobList ( // while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) { + if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_MEMORY_UNACCEPTED) { PhysicalEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength; ResourceLength = Hob.ResourceDescriptor->ResourceLength; -- 2.29.2.windows.2