From nobody Fri Nov 15 10:27:33 2024 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+90227+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+90227+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484469; cv=none; d=zohomail.com; s=zohoarc; b=PWkR7r9zUEoFzCAFK8ms0CdOrTcOZyi4rURfVmSkmndbivig53NFKk60Z7gAPI34zvmX4llp1wEDYRRLj28V9L57fMr8tsi+hEjarjoYLRmtKK7yMul4XwiEXgSv4xwOVYkGJotEOAM4PrIFzOixjw8H9nR/1akUhzkXGKWYLFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484469; 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=crwMSYOQ9X1q0cxMmfoSUaZ+gz76SNrrAc3iYN9TPdQ=; b=jmhCrGUwgVZlyV+oo8y5LJIY7cDjBKWeIFE9ROfcTML3bunhQIpldUwlBEV1/X6sq0djDf6oULx1xTpfVMRmvCUnkXtcmezumekGu2kCY5FvqquH//BhPqA6WTz4AnoydzyVbUxAvE2eE4JyF+xKv2Ouy6HYoSUbvKasWpsAKI8= 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+90227+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 1654484469344659.5941194772568; Sun, 5 Jun 2022 20:01:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OxwIYY1788612xZdWHNO2pms; Sun, 05 Jun 2022 20:01:09 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.27883.1654484468358335759 for ; Sun, 05 Jun 2022 20:01:08 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458157" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458157" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:45 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285828" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:43 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH 11/14] OvmfPkg: Update ConstructFwHobList for lazy accept Date: Mon, 6 Jun 2022 10:59:59 +0800 Message-Id: <2df2ea9db98907b59b32e8555cf96eb42d6d9134.1654420876.git.min.m.xu@intel.com> In-Reply-To: References: 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,min.m.xu@intel.com X-Gm-Message-State: 3NMgIBvGiUhf2Drdh0Nz3z5Qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484469; bh=iEYqWqmXhq0WAE/grEn0w8Mg2k5DCXSCqiFCWOdtS+M=; h=Cc:Date:From:Reply-To:Subject:To; b=SuZ8SoJfA4tzFQf21iGqQr18FNGDSR2WXFmeo5WUNz3Dp+3oBfWQz2dM3pK8UBXGhu2 RVJnZM2qHE4OjeVrCUcyNIvifdVj8QUhxmmmt5CobnB42OW1blfB7MSyG9BE53tp74q2S ljMgIXt6+Q6PgNcwXF32sbdjsh9X/BlL1ZI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484471138100003 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 In TDVF the hob list is constructed at the memory region which is the largest one below 4GB. After lazy accept is introduced, the MaxAcceptedMemoryAddress (which is tha max accpeted memory address in lazy accept) should be considered. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 23 ++++++++++++++++++- .../PeilessStartupLib/PeilessStartupLib.inf | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/Peil= essStartupLib/Hob.c index a9b92b5fbaba..884490af68fd 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "PeilessStartupInternal.h" =20 /** @@ -74,10 +75,13 @@ ConstructFwHobList ( ) { EFI_PEI_HOB_POINTERS Hob; + EFI_PHYSICAL_ADDRESS PhysicalStart; EFI_PHYSICAL_ADDRESS PhysicalEnd; UINT64 ResourceLength; EFI_PHYSICAL_ADDRESS LowMemoryStart; UINT64 LowMemoryLength; + UINT64 MaxAcceptedMemoryAddress; + TDX_WORK_AREA *WorkArea; =20 ASSERT (VmmHobList !=3D NULL); =20 @@ -86,14 +90,31 @@ ConstructFwHobList ( LowMemoryLength =3D 0; LowMemoryStart =3D 0; =20 + WorkArea =3D (TDX_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); + ASSERT (WorkArea !=3D NULL); + ASSERT (WorkArea->Header.GuestType =3D=3D CcGuestTypeIntelTdx); + MaxAcceptedMemoryAddress =3D WorkArea->SecTdxWorkArea.MaxAcceptedMemoryA= ddress; + if (MaxAcceptedMemoryAddress =3D=3D 0) { + MaxAcceptedMemoryAddress =3D MAX_UINT64; + } + // // Parse the HOB list until end of list or matching type is found. // while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - if (Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY_= UNACCEPTED) { + if ((Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY= _UNACCEPTED) && (Hob.ResourceDescriptor->PhysicalStart < MaxAcceptedMemoryA= ddress)) { PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; + PhysicalStart =3D Hob.ResourceDescriptor->PhysicalStart; + + if ((PhysicalEnd >=3D MaxAcceptedMemoryAddress) && (PhysicalStart = < MaxAcceptedMemoryAddress)) { + // + // This memory region is split into 2 parts. The left part is ac= cepted. + // + PhysicalEnd =3D MaxAcceptedMemoryAddress; + ResourceLength =3D PhysicalEnd - PhysicalStart; + } =20 if (PhysicalEnd <=3D BASE_4GB) { if (ResourceLength > LowMemoryLength) { diff --git a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf b/Ovmf= Pkg/Library/PeilessStartupLib/PeilessStartupLib.inf index c5d291f02bcd..2ca49324d8f9 100644 --- a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf +++ b/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf @@ -88,3 +88,4 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ##= CONSUMES gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase --=20 2.29.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 (#90227): https://edk2.groups.io/g/devel/message/90227 Mute This Topic: https://groups.io/mt/91570210/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-