From nobody Sun May 12 17:14:56 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+93126+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+93126+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366922; cv=none; d=zohomail.com; s=zohoarc; b=Y51wGfOX+KTalojz5Fx5LSfMcgkiGVnd5zU1PoZkmT5qltX5I46iTEoilbHiETJtmpck+2B9N9K0zxaN+4l+t8fitjv3gXhfOqFhZvWTVji1JSNgleR4IhPGPC+gQ1kGzRBOuE1uTPU2N1bdJalHBaHFgsFDN75ou7UNHaOZtnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366922; 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=anWEh0IvFhbNyJcQuayV7uu4mcM+ae8YlLFFNVpBzkE=; b=HNDPuxK/I4c6Ct5lYuRA6U3M0br0zNV2qkMeE5mhHtwSue3l38FWcv6MAgBvJCvCdshhFPMZ8v3MHPz4Vj5Sy6rNL1hqDDpsQpBw+twPnLYVw+Q6vOKY/KfDjp18sRrL5uMD97mbK9+FGlmSfIXPri0lppAFldeLeUqUVaIIxG8= 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+93126+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 1662366922833406.4702403567851; Mon, 5 Sep 2022 01:35:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8CymYY1788612xccXrvvsgB3; Mon, 05 Sep 2022 01:35:22 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:22 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355782" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355782" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:21 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194227" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:19 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Jian J Wang , Liming Gao , Ray Ni , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V3 01/12] MdeModulePkg: Add PrePiHob.h Date: Mon, 5 Sep 2022 16:34:55 +0800 Message-Id: <63dd9e41155d50cc17f4ecce7e6c0a520a3ee7a8.1662365866.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: 0qVucE8aFrmPDPyy1VU8yhqax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366922; bh=+sX2aDTHqKZ9iynWI+PJhtgOzx8C1vieVtrctgt675I=; h=Cc:Date:From:Reply-To:Subject:To; b=eM+sTzdpbPeMvMzg40mFWuyoZjNhY5bNwZmpKU6MPKFr2tDmcn1OQKJe+BCjzre2zVH fkJn+LaUtYHIKWb25+VqeQDd29ruUaIxZV35tOtkz2ypJ0iUU6w/YpizRZh81M2aRZNJu G/HqhvNfZb/Wfjj7bkAkRXE0cSrWXsx8xLg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366924510100005 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. But this defitinion has not been officially in the PI spec. Base on the code-first we define EFI_RESOURCE_MEMORY_UNACCEPTED at MdeModulePkg/Include/Pi/PrePiHob.h. Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu Acked-by: Gerd Hoffmann --- MdeModulePkg/Include/Pi/PrePiHob.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 MdeModulePkg/Include/Pi/PrePiHob.h diff --git a/MdeModulePkg/Include/Pi/PrePiHob.h b/MdeModulePkg/Include/Pi/P= rePiHob.h new file mode 100644 index 000000000000..38a8f1be149d --- /dev/null +++ b/MdeModulePkg/Include/Pi/PrePiHob.h @@ -0,0 +1,20 @@ +/** @file + HOB related definitions which has not been officially published in PI. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MDE_MODULEPKG_PRE_PI_HOB_H_ +#define MDE_MODULEPKG_PRE_PI_HOB_H_ + +// +// EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. +// But this defitinion has not been officially in the PI spec. Base +// on the code-first we define EFI_RESOURCE_MEMORY_UNACCEPTED at +// MdeModulePkg/Include/Pi/PrePiHob.h. +// +#define EFI_RESOURCE_MEMORY_UNACCEPTED 0x00000007 + +#endif --=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 (#93126): https://edk2.groups.io/g/devel/message/93126 Mute This Topic: https://groups.io/mt/93474511/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- From nobody Sun May 12 17:14:57 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+93127+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+93127+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366925; cv=none; d=zohomail.com; s=zohoarc; b=a33ysFWw2MA7PNQzO13GjOG6g4J+EpWmmgwLmyVLq85o0WnY1sGF0bUuIcW8QVX52plRaEm7TDLlRFKm0eD2puy1eK5Sy9UMgNrBNJgL2+3hEPr7rw74cGywU2cxwI4wuQfBJo08lPjwreqQ6m1Oik7ispdrNYj4+ivqYDsOHYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366925; 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=OT9JcQGGf2B/Vb4/KzfM7xm/JVL0vvwyL3JSSfyodak=; b=a4HumVZiyzUjYgFwUKrlcnkQRrWBxr1HSzC6iOzC/T9u8AVMpUfRzQYTlse4Og6c3Knah/XRUUnnP0LO7t6B7FJkYhdHLx+qNAi2jbWjwCROdcEO//UYnioTcKP50J6fJrrnUPGjxwANuitPWmT9MwAoxjQDXTy3vJlrUdWRom4= 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+93127+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 1662366925474560.9293491642276; Mon, 5 Sep 2022 01:35:25 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kyVUYY1788612xrSHdksCxrT; Mon, 05 Sep 2022 01:35:25 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:24 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355816" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355816" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:24 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194249" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:21 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V3 02/12] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Date: Mon, 5 Sep 2022 16:34:56 +0800 Message-Id: <2c77b268cdc290c4325387d3d20227b1e758de80.1662365866.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: 86peo8e0S8ANSmS2rPfBWONox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366925; bh=HeRGMczvwKEHyMC+/lK6tLY6o4RvVq/jWHYVePpKFjs=; h=Cc:Date:From:Reply-To:Subject:To; b=W4TMprHOAO6Npu6ro3VSLCUTPlmF4PDeunUltTHG6YkilZoX4usQ2sIoyXspdrS+EXa hQdbhiJeybpF4wRBAitoq137NYlwVGVCX9KJpgN0Ecyj66Q1OCMCCb320ZlD/8TvCrqGu gNohrtCOus7O7u4wWKBE6SSiasr02go2O7o= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366926490100009 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. But this defitinion has not been officially in the PI spec. Base on the code-first we define EFI_RESOURCE_MEMORY_UNACCEPTED at MdeModulePkg/Include/Pi/PrePiHob.h and update EFI_RESOURCE_MAX_MEMORY_TYPE to 8. After EFI_RESOURCE_MEMORY_UNACCEPTED is officially published in PI spec, we will re-visit here. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Reviewed-by: Jiewen Yao Signed-off-by: Min Xu --- MdePkg/Include/Pi/PiHob.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Pi/PiHob.h b/MdePkg/Include/Pi/PiHob.h index e9f0ab4309d1..9af2e957fee5 100644 --- a/MdePkg/Include/Pi/PiHob.h +++ b/MdePkg/Include/Pi/PiHob.h @@ -232,7 +232,16 @@ typedef UINT32 EFI_RESOURCE_TYPE; #define EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 0x00000004 #define EFI_RESOURCE_MEMORY_RESERVED 0x00000005 #define EFI_RESOURCE_IO_RESERVED 0x00000006 -#define EFI_RESOURCE_MAX_MEMORY_TYPE 0x00000007 +// +// EFI_RESOURCE_MEMORY_UNACCEPTED is defined for unaccepted memory. +// But this defitinion has not been officially in the PI spec. Base +// on the code-first we define EFI_RESOURCE_MEMORY_UNACCEPTED at +// MdeModulePkg/Include/Pi/PrePiHob.h and update EFI_RESOURCE_MAX_MEMORY_T= YPE +// to 8. After EFI_RESOURCE_MEMORY_UNACCEPTED is officially published +// in PI spec, we will re-visit here. +// +// #define EFI_RESOURCE_MEMORY_UNACCEPTED 0x00000007 +#define EFI_RESOURCE_MAX_MEMORY_TYPE 0x00000008 =20 /// /// A type of recount attribute type. --=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 (#93127): https://edk2.groups.io/g/devel/message/93127 Mute This Topic: https://groups.io/mt/93474512/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- From nobody Sun May 12 17:14:57 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+93128+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+93128+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366928; cv=none; d=zohomail.com; s=zohoarc; b=YAsHXEVajxT7GKK+8k8eBLXxtNvuQjSU4eUEJR/jmgyPUY3rKR5F8XgjZ8MjFUIknIYjpi4v60LxLQWIRkmCOC/JKuzoCkry06nz96mzoeuFVTl5yORV9RTHRalhY9HRcn1bD7gati+4CMxQzhbwg1/4c/dZpRoSEiehzLNdacY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366928; 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=3e2pGWONqNJqBM35j2jj0H4JhCz0sFlEUe5BiRZnKiQ=; b=YB3A9t4cAsHMPLQ91EQiFuRVzkD8LCO2LWuj3snMAUvQUN807d56uOu/Cck+NZA1Zbz8WLrU1gF1Wnpybxykc6xYr8ZadZv98xsAKNvmMmox4h6r559O4ZPXoazEi4qPnorV74DKMzvJ32piy3nlQP3G2SOV1mS8w5Hzpogx4X8= 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+93128+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 1662366928805140.0976361029883; Mon, 5 Sep 2022 01:35:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XyfJYY1788612x9RnnJaJYN7; Mon, 05 Sep 2022 01:35:27 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:26 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355819" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355819" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:26 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194277" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:24 -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 V3 03/12] OvmfPkg: Use EFI_RESOURCE_MEMORY_UNACCEPTED which defined in MdeModulePkg Date: Mon, 5 Sep 2022 16:34:57 +0800 Message-Id: <5d5cdd14a1c5e1632f9721db6223c5f12c8e63e2.1662365866.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: iTcxaXryWceFtuom18bc5WlKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366927; bh=6W7ckuJEs5th7JA40191559EQ1jBf8mQIRSDt1k2Iig=; h=Cc:Date:From:Reply-To:Subject:To; b=tBxfAmqDYfbJQ//fjrLoxkbMgMnEf9Gr3xT1mAJ1SuGRlgaEkV0LWgdM74KDqjl5DxO 9i6ZdfEpFCHcwZjGPghBEzxQ9dPAoJmQ9RdwFmWfz1Acdn9COvZGGs0gDV5kPiXaYjFs3 xSfvXW+Ze/SoV/aYdwQWLjBnShxZRJFznow= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366930519100015 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 EFI_RESOURCE_MEMORY_UNACCEPTED is defined in MdeModulePkg. The files which use the definition are updated as well. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu Acked-by: Gerd Hoffmann --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 3 +-- OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/Peil= essStartupLib/Hob.c index 5fc84a809025..a9b92b5fbaba 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -20,10 +20,9 @@ #include #include #include +#include #include "PeilessStartupInternal.h" =20 -#define EFI_RESOURCE_MEMORY_UNACCEPTED 7 - /** * Construct the HobList in SEC phase. * diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index c6d7c8bb6e0e..396b14d919d2 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -20,11 +20,11 @@ #include #include #include +#include #include #include =20 #define ALIGNED_2MB_MASK 0x1fffff -#define EFI_RESOURCE_MEMORY_UNACCEPTED 7 =20 /** This function will be called to accept pages. Only BSP accepts pages. --=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 (#93128): https://edk2.groups.io/g/devel/message/93128 Mute This Topic: https://groups.io/mt/93474513/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- From nobody Sun May 12 17:14:57 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+93129+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+93129+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366930; cv=none; d=zohomail.com; s=zohoarc; b=Bdr2vxpfCsSv5jK2TTKNp6GTnG/BwaituCivBAzPMeVE4RkXJbe69M/ZaXbde1b3OydgGzSAhecXBVFK5LjPgxJK9GL5729py0LbFR5nZWptR72/CmuS2qaD7rlWUV3ksycyLZOkvkLRsRgeUCvhYOqihYmZGWVZ0ncG8xY4Ack= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366930; 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=KmqhPzML8MM/ypk7yTe9yb1EP5U8DG+SGbZzfhTGXkE=; b=TRB3BWtrDEtMnpjIJXOCIc7pkw7/O0eF6eJc5ZMvo0sNNVaB4odlJFaAXsKrPrtTkdq4O7iBDTOzSRfr6qjC2qmTWTpCabekCAS/nXqiiHeWDKxJGsyhFWUxJqDKg+41ZZYTdBuoRuiTTMbX2ilJ/zjBHYSKLrHR7VOq8mG5O1k= 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+93129+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 1662366930586377.16370342248683; Mon, 5 Sep 2022 01:35:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id inCiYY1788612xCEG4m8NlBR; Mon, 05 Sep 2022 01:35:29 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:28 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355846" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355846" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:28 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194311" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:26 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V3 04/12] MdePkg: Add UEFI Unaccepted memory definition Date: Mon, 5 Sep 2022 16:34:58 +0800 Message-Id: <124c04c209003aec90797d09692d56e68ba75642.1662365866.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: GkmWV4lbVlMZWveeZoy9WH6xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366929; bh=0AMF8JicnmFwLAtibYmyWf+OkYmALUqsIzIJpLUHBU4=; h=Cc:Date:From:Reply-To:Subject:To; b=G+tvK1WU5ePKI1+PrJ8AbxFq0dL0FKLp4WE+RB5gBHzPfGO/B4tgzo4XpAAweS7h8wq iQxAp9IG+X4fPvT3QpS7LkwwmUQnME5h7Uu/7LlR+FXL810ZWvqfVuHT1lV+uOI18H4uf XBMoLArxRAGXQlFbmfA+DKAPGbYUzBrTDzw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366932535100019 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Plase refer to: UEFI Spec v2.9 Table 7-5 Memory Type Usage before ExitBootServices() Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Reviewed-by: Jiewen Yao Signed-off-by: Min Xu Acked-by: Gerd Hoffmann --- MdeModulePkg/Include/Pi/PrePiDxeCis.h | 25 +++++++++++++++++++++++++ MdePkg/Include/Pi/PiDxeCis.h | 10 +++++++++- MdePkg/Include/Uefi/UefiMultiPhase.h | 5 +++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Include/Pi/PrePiDxeCis.h diff --git a/MdeModulePkg/Include/Pi/PrePiDxeCis.h b/MdeModulePkg/Include/P= i/PrePiDxeCis.h new file mode 100644 index 000000000000..113ac37924cc --- /dev/null +++ b/MdeModulePkg/Include/Pi/PrePiDxeCis.h @@ -0,0 +1,25 @@ +/** @file + Include file matches things in PI. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MDE_MODULEPKG_PRE_PI_DXE_CIS_H_ +#define MDE_MODULEPKG_PRE_PI_DXE_CIS_H_ + +/// +/// A memory region that describes system memory that has not been accepted +/// by a corresponding call to the underlying isolation architecture. +/// +/// This memory region has not been defined in PI spec, so it is defined in +/// PrePiDxeCis.h. And it is defined in the format of captial letters +/// because only capital letters are allowed to be used for #define declar= ations. +/// +/// After this memory region is defined in PI spec, it should be a value in +/// EFI_GCD_MEMORY_TYPE in PiDxeCis.h. +/// +#define EFI_GCD_MEMORY_TYPE_UNACCEPTED 7 + +#endif diff --git a/MdePkg/Include/Pi/PiDxeCis.h b/MdePkg/Include/Pi/PiDxeCis.h index d0f2ed0e58df..27b219aa3ffa 100644 --- a/MdePkg/Include/Pi/PiDxeCis.h +++ b/MdePkg/Include/Pi/PiDxeCis.h @@ -56,7 +56,15 @@ typedef enum { /// system. If all memory has the same reliability, then this bit is not= used. /// EfiGcdMemoryTypeMoreReliable, - EfiGcdMemoryTypeMaximum + // /// + // /// A memory region that describes system memory that has not been ac= cepted + // /// by a corresponding call to the underlying isolation architecture. + // /// + // /// Please be noted: + // /// EfiGcdMemoryTypeUnaccepted is defined in PrePiDxeCis.h because it= has not been + // /// defined in PI spec. + // EfiGcdMemoryTypeUnaccepted, + EfiGcdMemoryTypeMaximum =3D 8 } EFI_GCD_MEMORY_TYPE; =20 /// diff --git a/MdePkg/Include/Uefi/UefiMultiPhase.h b/MdePkg/Include/Uefi/Uef= iMultiPhase.h index 22bae43e36e8..7884913371a9 100644 --- a/MdePkg/Include/Uefi/UefiMultiPhase.h +++ b/MdePkg/Include/Uefi/UefiMultiPhase.h @@ -103,6 +103,11 @@ typedef enum { /// however it happens to also support byte-addressable non-volatility. /// EfiPersistentMemory, + /// + /// A memory region that describes system memory that has not been accep= ted + /// by a corresponding call to the underlying isolation architecture. + /// + EfiUnacceptedMemoryType, EfiMaxMemoryType } EFI_MEMORY_TYPE; =20 --=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 (#93129): https://edk2.groups.io/g/devel/message/93129 Mute This Topic: https://groups.io/mt/93474514/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- From nobody Sun May 12 17:14:57 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+93130+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+93130+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366932; cv=none; d=zohomail.com; s=zohoarc; b=dUicUg4sTzbWEqlUVWFDtrT4G6mNl9WubJNTKvrHP7evAGwn6OK8WZfk+givFQPn/zvU5koRPTEHp4dX1cre+9yknYQQAdbsp9P5J5rnfI1wB8qC2ZbNAVHypva+Ax2HcsYd7bJ+a7u6NHdJrUtZ57/Nsn1vG+Kmi1YYK8Kms2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366932; 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=qYJgBQKpE4BQCEDep0g5tAnsLdOJOX9wPJCcvQBakKQ=; b=VuDY121u15IBbmmnwcEyV1x3kqKB0wwIh4EdzfY6UKjAEEVSNL6x+0QSADGLZmn/jvqirBfUEJWpzSXVNyfgHhfdNT1HFQiFdMe9pZiGXq8p8cafKiet3qNFIuyv+QQyfEGGlM61SfBK5BhynG9/rD2qy7daXhnY1qG6bElqdyo= 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+93130+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 1662366932336446.75450786456065; Mon, 5 Sep 2022 01:35:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DthBYY1788612xtca8hZ9uFA; Mon, 05 Sep 2022 01:35:32 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:31 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355868" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355868" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194364" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:28 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Jian J Wang , Liming Gao , Ray Ni , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V3 05/12] MdeModulePkg: Update Dxe to handle unaccepted memory type Date: Mon, 5 Sep 2022 16:34:59 +0800 Message-Id: <3c3bb3ffd45ce059240e8e9c7d45fdbea619cd3f.1662365866.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: BOSvC3nmfdk6EXSpzMqiG1shx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366932; bh=qgLUvfQMubtgBbZVj1kzBUfC0MaEU+s8czUzpckB5po=; h=Cc:Date:From:Reply-To:Subject:To; b=qhpqepZ4JdNNLcZCYEd4QwYfEXe39Vfoo5wfY5ckFGBjSMay+zG5s0Mkoip/hhKf/Hp fSwi5fbkJi2n6XyyOMzRKZQOzd+iWjqQz4ngjUAOyQwagFXiy00h45HU3bYotX8lVX6Wu mj4D/pYMv1/W3mmBoVvF0LdiWu0ZlsWKCGk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366932571100020 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Unaccepted memory is a kind of new memory type, CoreInitializeGcdServices() and CoreGetMemoryMap() are updated to handle the unaccepted memory type. Ref: microsoft/mu_basecore@97e9c31 Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu Acked-by: Gerd Hoffmann --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 6 +++ MdeModulePkg/Core/Dxe/Mem/Page.c | 63 +++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index 3763467bdbc0..9ba73d148af3 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -8,6 +8,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include +#include #include "DxeMain.h" #include "Gcd.h" #include "Mem/HeapGuard.h" @@ -103,6 +105,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryT= ypeNames[] =3D { "MMIO ", // EfiGcdMemoryTypeMemoryMappedIo "PersisMem", // EfiGcdMemoryTypePersistent "MoreRelia", // EfiGcdMemoryTypeMoreReliable + "Unaccepte", // EFI_GCD_MEMORY_TYPE_UNACCEPTED "Unknown " // EfiGcdMemoryTypeMaximum }; =20 @@ -2600,6 +2603,9 @@ CoreInitializeGcdServices ( case EFI_RESOURCE_MEMORY_RESERVED: GcdMemoryType =3D EfiGcdMemoryTypeReserved; break; + case EFI_RESOURCE_MEMORY_UNACCEPTED: + GcdMemoryType =3D EFI_GCD_MEMORY_TYPE_UNACCEPTED; + break; case EFI_RESOURCE_IO: GcdIoType =3D EfiGcdIoTypeIo; break; diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index cc0b90ac0df5..160289c1f9ec 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h" #include "Imem.h" #include "HeapGuard.h" +#include =20 // // Entry for tracking the memory regions for each memory type to coalesce = similar memory types @@ -61,6 +62,7 @@ EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxM= emoryType + 1] =3D { { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiM= emoryMappedIOPortSpace { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiP= alCode { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiP= ersistentMemory + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiU= nacceptedMemoryType { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiM= axMemoryType }; =20 @@ -68,22 +70,23 @@ EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress =3D MAX_AL= LOC_ADDRESS; EFI_PHYSICAL_ADDRESS mDefaultBaseAddress =3D MAX_ALLOC_ADDRESS; =20 EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = =3D { - { EfiReservedMemoryType, 0 }, - { EfiLoaderCode, 0 }, - { EfiLoaderData, 0 }, - { EfiBootServicesCode, 0 }, - { EfiBootServicesData, 0 }, - { EfiRuntimeServicesCode, 0 }, - { EfiRuntimeServicesData, 0 }, - { EfiConventionalMemory, 0 }, - { EfiUnusableMemory, 0 }, - { EfiACPIReclaimMemory, 0 }, - { EfiACPIMemoryNVS, 0 }, - { EfiMemoryMappedIO, 0 }, - { EfiMemoryMappedIOPortSpace, 0 }, - { EfiPalCode, 0 }, - { EfiPersistentMemory, 0 }, - { EfiMaxMemoryType, 0 } + { EfiReservedMemoryType, 0 }, + { EfiLoaderCode, 0 }, + { EfiLoaderData, 0 }, + { EfiBootServicesCode, 0 }, + { EfiBootServicesData, 0 }, + { EfiRuntimeServicesCode, 0 }, + { EfiRuntimeServicesData, 0 }, + { EfiConventionalMemory, 0 }, + { EfiUnusableMemory, 0 }, + { EfiACPIReclaimMemory, 0 }, + { EfiACPIMemoryNVS, 0 }, + { EfiMemoryMappedIO, 0 }, + { EfiMemoryMappedIOPortSpace, 0 }, + { EfiPalCode, 0 }, + { EfiPersistentMemory, 0 }, + { EFI_GCD_MEMORY_TYPE_UNACCEPTED, 0 }, + { EfiMaxMemoryType, 0 } }; // // Only used when load module at fixed address feature is enabled. True me= ans the memory is alreay successfully allocated @@ -1286,7 +1289,7 @@ CoreInternalAllocatePages ( } =20 if (((MemoryType >=3D EfiMaxMemoryType) && (MemoryType < MEMORY_TYPE_OEM= _RESERVED_MIN)) || - (MemoryType =3D=3D EfiConventionalMemory) || (MemoryType =3D=3D EfiP= ersistentMemory)) + (MemoryType =3D=3D EfiConventionalMemory) || (MemoryType =3D=3D EfiP= ersistentMemory) || (MemoryType =3D=3D EfiUnacceptedMemoryType)) { return EFI_INVALID_PARAMETER; } @@ -1961,6 +1964,32 @@ CoreGetMemoryMap ( MemoryMap =3D MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, S= ize); } =20 + if (MergeGcdMapEntry.GcdMemoryType =3D=3D EFI_GCD_MEMORY_TYPE_UNACCEPT= ED) { + // + // Page Align GCD range is required. When it is converted to EFI_MEM= ORY_DESCRIPTOR, + // it will be recorded as page PhysicalStart and NumberOfPages. + // + ASSERT ((MergeGcdMapEntry.BaseAddress & EFI_PAGE_MASK) =3D=3D 0); + ASSERT (((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress= + 1) & EFI_PAGE_MASK) =3D=3D 0); + + // + // Create EFI_MEMORY_DESCRIPTOR for every Unaccepted GCD entries + // + MemoryMap->PhysicalStart =3D MergeGcdMapEntry.BaseAddress; + MemoryMap->VirtualStart =3D 0; + MemoryMap->NumberOfPages =3D RShiftU64 ((MergeGcdMapEntry.EndAddress= - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT); + MemoryMap->Attribute =3D MergeGcdMapEntry.Attributes | + (MergeGcdMapEntry.Capabilities & (EFI_MEM= ORY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO | + EFI_MEM= ORY_UC | EFI_MEMORY_UCE | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB)); + MemoryMap->Type =3D EfiUnacceptedMemoryType; + + // + // Check to see if the new Memory Map Descriptor can be merged with = an + // existing descriptor if they are adjacent and have the same attrib= utes + // + MemoryMap =3D MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, S= ize); + } + if (Link =3D=3D &mGcdMemorySpaceMap) { // // break loop when arrive at head. --=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 (#93130): https://edk2.groups.io/g/devel/message/93130 Mute This Topic: https://groups.io/mt/93474515/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- From nobody Sun May 12 17:14:57 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+93131+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+93131+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366934; cv=none; d=zohomail.com; s=zohoarc; b=SSW6qcjUIr2dOXq3xj+BWB8KyroWDWqKQlEW1SbsQyY/yAf51yVXB//s5536VcOX7ba5EqHmgaYOcrrZUXyU79g+qnPzSasy3ITFL5TrugAAVWmnGd20RDoZ7x7P0SG2Jc/RFe4A/wGJuee+rv7sT7kxSZuK37OXwoIMMsACZXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366934; 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=YHnpLqYpZi/bWtrH/sGrbbzY2Ohzhmx0lcIs6PRLeOU=; b=meFIcdxhdkBdLUR95H/xJzryJRqcVZX3jRwtcWZGRB8sN2xE7Vl1KJsmiNfx/wNmb+lni254ugz/lejDD44UfmS+41HPzDgz4kP0n02p5k5X6NSfQHGcGN2J/ZaLzoyuGyKRu9RtCNQpwZsd5jLdQqdipBAqn3WTB37VDXsYdmM= 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+93131+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 1662366934816646.9996019694347; Mon, 5 Sep 2022 01:35:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YYm3YY1788612xTqRzpgBh9O; Mon, 05 Sep 2022 01:35:34 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:34 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355879" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355879" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:33 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194391" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:30 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Ray Ni , Zhichao Gao , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH V3 06/12] ShellPkg: Update shell command memmap to show unaccepted memory Date: Mon, 5 Sep 2022 16:35:00 +0800 Message-Id: <9c907dfec78032252b748cd213d4af76ad5ef524.1662365866.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: NbzBdxwr1pld0jrTpYN1FvWCx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366934; bh=uhfaubH6h6WodpbFgSE3PFNmREM/iahpXD2nRrakmLw=; h=Cc:Date:From:Reply-To:Subject:To; b=LhXXJbHFRXaqHKF3ZFKHExV0KG9mLVxdtGZExGSXltkan17SC2dvgoa180sNQ5MsWhU vREkrIoXHcchs9EMpTlMuGizB+b7fNmigUbFeGIHulSDwBxO8ijQStjDWPuRLLrlXDQj6 r9Om99x+xW1MPr7RL5Y/MgKrHrzJK4fPUXA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366936577100003 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 ShellCommandRunMemMap() is updated to handle the case of unaccepted memory type. Cc: Ray Ni Cc: Zhichao Gao Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu Reviewed-by: Zhichao Gao --- .../Library/UefiShellDebug1CommandsLib/MemMap.c | 13 +++++++++++++ .../UefiShellDebug1CommandsLib.uni | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPk= g/Library/UefiShellDebug1CommandsLib/MemMap.c index 72f3c58b0970..a089953b286f 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c @@ -26,6 +26,7 @@ STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] =3D= L"ACPIMemoryNVS"; STATIC CONST CHAR16 NameEfiMemoryMappedIO[] =3D L"MemoryMappedIO= "; STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] =3D L"MemoryMappedIO= PortSpace"; STATIC CONST CHAR16 NameEfiPalCode[] =3D L"PalCode"; +STATIC CONST CHAR16 NameEfiUnacceptedMemoryType[] =3D L"Unaccepted"; =20 // // Need short names for some memory types @@ -151,6 +152,8 @@ ShellCommandRunMemMap ( UINT64 UnusableMemoryPagesSize; UINT64 PalCodePages; UINT64 PalCodePagesSize; + UINT64 UnacceptedPages; + UINT64 UnacceptedPagesSize; UINT64 PersistentPages; UINT64 PersistentPagesSize; BOOLEAN Sfo; @@ -175,6 +178,7 @@ ShellCommandRunMemMap ( PalCodePages =3D 0; PersistentPages =3D 0; Size =3D 0; + UnacceptedPages =3D 0; Descriptors =3D NULL; ShellStatus =3D SHELL_SUCCESS; Status =3D EFI_SUCCESS; @@ -303,6 +307,11 @@ ShellCommandRunMemMap ( TotalPages +=3D Walker->NumberOfPages; PalCodePages +=3D Walker->NumberOfPages; break; + case EfiUnacceptedMemoryType: + ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING= _TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), g= ShellDebug1HiiHandle, NameEfiUnacceptedMemoryType, Walker->PhysicalStart, W= alker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker= ->NumberOfPages, Walker->Attribute); + TotalPages +=3D Walker->NumberOfPages; + UnacceptedPages +=3D Walker->NumberOfPages; + break; default: // // Shell Spec defines the SFO format. @@ -335,6 +344,7 @@ ShellCommandRunMemMap ( MmioSpacePagesSize =3D MultU64x64 (SIZE_4KB, MmioSpacePages); MmioPortPagesSize =3D MultU64x64 (SIZE_4KB, MmioPortPages); PalCodePagesSize =3D MultU64x64 (SIZE_4KB, PalCodePages); + UnacceptedPagesSize =3D MultU64x64 (SIZE_4KB, UnacceptedPages); PersistentPagesSize =3D MultU64x64 (SIZE_4KB, PersistentPages); UnusableMemoryPagesSize =3D MultU64x64 (SIZE_4KB, UnusableMemoryPa= ges); if (!Sfo) { @@ -368,6 +378,8 @@ ShellCommandRunMemMap ( MmioPortPagesSize, PalCodePages, PalCodePagesSize, + UnacceptedPages, + UnacceptedPagesSize, AvailPages, AvailPagesSize, PersistentPages, @@ -422,6 +434,7 @@ ShellCommandRunMemMap ( AcpiReclaimPagesSize, AcpiNvsPagesSize, PalCodePagesSize, + UnacceptedPagesSize, PersistentPagesSize ); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com= mandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C= ommandsLib.uni index 6693be26e699..b1d239ed37ea 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni @@ -88,13 +88,14 @@ " MMIO : %,14ld Pa= ges (%,ld Bytes)\r\n" " MMIO_Port : %,14ld Pa= ges (%,ld Bytes)\r\n" " PalCode : %,14ld Pa= ges (%,ld Bytes)\r\n" + " Unaccepted: %,14ld Pa= ges (%,ld Bytes)\r\n" " Available : %,14ld Pa= ges (%,ld Bytes)\r\n" " Persistent: %,14ld Pa= ges (%,ld Bytes)\r\n" #string STR_MEMMAP_LIST_SUMM_OTHER #language en-US " %08x : %,14ld Pa= ges (%,ld Bytes)\r\n" #string STR_MEMMAP_LIST_SUMM2 #language en-US " ---------= ----- \r\n" "Total Memory: %,14ld MB= (%,ld Bytes)\r\n" #string STR_MEMMAP_LIST_ITEM_SFO #language en-US "MemoryMap,"%s","%LX","%= LX","%LX","%LX"\r\n" -#string STR_MEMMAP_LIST_SUMM_SFO #language en-US "MemoryMapSummary,"%Ld",= "%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%L= d","%Ld","%Ld"\r\n" +#string STR_MEMMAP_LIST_SUMM_SFO #language en-US "MemoryMapSummary,"%Ld",= "%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%Ld","%L= d","%Ld","%Ld", "%Ld"\r\n" =20 #string STR_EFI_COMPRESS_FAIL #language en-US "Unable to compress: %r.= \r\n" #string STR_EFI_DECOMPRESS_FAIL #language en-US "Unable to decompress: %= r.\r\n" --=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 (#93131): https://edk2.groups.io/g/devel/message/93131 Mute This Topic: https://groups.io/mt/93474516/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- From nobody Sun May 12 17:14:57 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+93132+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+93132+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366936; cv=none; d=zohomail.com; s=zohoarc; b=Wq/Eh6jCgm8xYGft6yqfZy9WSlTbD+5yR88cFk0Ce2VE+pRahGudbAJ3BlSEaGpFLu8dw0CoKR8Ovu25vMwOjRn9ejd3YciBQd+l/ZNwdQ2B0uW3hImI/LOaGoiEhQlNSOMnXqMpS+HeomX8o9SlnELw528E7pIf4ykbN2tpE4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366936; 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=vX4YcbCK6tVINfrnxyIbFRPOqMing39szVHPiLvYKNc=; b=LbHhLnE2esXt//L2E2sXu+V2m1T4rfAIzEui0Fe2zZGeulNz18yj12pj39ypmhXj4aeadzDvcfsqfb5lTbJYP2kiuJSJLjlNysdS+u9EPMThGxPjSIWlonPm1j4w0iZUjy58ufGxGfMUCQ1AkmkqV5OtdmtauiCBcKXdvaMH71w= 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+93132+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 166236693640575.31612888545249; Mon, 5 Sep 2022 01:35:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id c4pyYY1788612xoC1FkiZ6Zu; Mon, 05 Sep 2022 01:35:36 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:35 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355889" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355889" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:34 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194409" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:33 -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 V3 07/12] OvmfPkg: Add MaxAcceptedMemoryAddress in TDX work area Date: Mon, 5 Sep 2022 16:35:01 +0800 Message-Id: <832a392e8b8657ea649df9cb8f91b4bf63c914c9.1662365866.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: HleeVoQKr3XSGlJ75i0ZDBM5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366936; bh=HCbHcoY6e7eKqC8gVPYH2YMsoS0yqfLPQBaY17936A4=; h=Cc:Date:From:Reply-To:Subject:To; b=dK6dfFgn2U+jhv+eiv+qFbAHqtHzSzyJRE6ek2/F7HAI7+1eWePiU9busHgI+R0wpW9 34yWAKrRUfb4X9OObnKMr5jyYe20rxnKZ+o3LNrNhENekBWOiYNkegKA2sEWBWFnMHN1d O5EvsDw7TB2OU3SK7+OGgogzFWFf25LUHGw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366938555100007 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 In lazy-accept the MaxAcceptedMemoryAddress is needed in TransferTdxHobList and ContructFwHobList(at PeilessStartupLib). But in SEC phase we cannot use a global variable to pass this value. So we add a new field (MaxAcceptedMemoryAddress) in Tdx work area. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Include/WorkArea.h | 1 + 1 file changed, 1 insertion(+) diff --git a/OvmfPkg/Include/WorkArea.h b/OvmfPkg/Include/WorkArea.h index bf56fc4a6f65..2c2a5816b0dc 100644 --- a/OvmfPkg/Include/WorkArea.h +++ b/OvmfPkg/Include/WorkArea.h @@ -71,6 +71,7 @@ typedef struct _SEC_TDX_WORK_AREA { UINT32 PageTableReady; UINT32 Gpaw; UINT64 HobList; + UINT64 MaxAcceptedMemoryAddress; } SEC_TDX_WORK_AREA; =20 typedef struct _TDX_WORK_AREA { --=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 (#93132): https://edk2.groups.io/g/devel/message/93132 Mute This Topic: https://groups.io/mt/93474517/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- From nobody Sun May 12 17:14:57 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+93133+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+93133+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366938; cv=none; d=zohomail.com; s=zohoarc; b=fEl22fbk1dZeJxgFziG1wOTXkBzt/B7xCtQ8YqMRTGcSVEbpJFpnZ1SnDdsTrlLJgJ+IzCGgBr35qTGeYC8XKE9noRw+ek0MKrrWWnZPZVvHdbKGPNpcoM1Qf03KemK2RZ4mVJ0rW//cTkJiJ7CXQvvBd8LP2u7FNTFMVm312lM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366938; 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=cttsZ+ae6RD7iqa0epoT1fMGWE0/Vye7jhDNy7K1yj0=; b=n8x5Jco42SFPW0wr+fjte5MULOw5Iy3BIdD4dlkqkfRcqgE6EdEs3y9pdal4cesVlyG6n7PPetHjUAe4Udfp8OgZF0bk+TLs4nSGbnHR8vA0LtBpM0NNMGn4z2JfbTd6AFrGW9w1W18/Z83VJwAuAp5OYd6vDGdTXCgP2tgz0ts= 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+93133+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 1662366938560725.0903776562723; Mon, 5 Sep 2022 01:35:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Rj4pYY1788612xnrlpt9yUQx; Mon, 05 Sep 2022 01:35:38 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:37 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355910" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355910" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:37 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194451" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:35 -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 V3 08/12] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Date: Mon, 5 Sep 2022 16:35:02 +0800 Message-Id: <1cfb199b8cde681f11d25f5b471fa39c7032f9de.1662365866.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: H8SwMMAY2owCp1ELPrukTyKQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366938; bh=nnMByCMdu32Nz/cSBn8TlZB7VfJFhSsyxmiacfMfhb4=; h=Cc:Date:From:Reply-To:Subject:To; b=effOdx7tRCv2Fr/rkyRBMplzBksVMNSsFNfSwSVRwS/tKxk0NPFv776WLCLyyRhu0P6 YQ7+L4de9nooYSP6t4REBTQ9KNDfhmU+Liy/9eNPOdY8gYqSnsMQdEQYCMuMRw8+D9MeX ACKPcKMu3kr45UTJVgeOvZXvxpL04E443h0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366940710100013 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 There are below major changes in PlatformInitLib/PlatformPei 1. ProcessHobList The unaccepted memory is accepted if it is under 4G address.If an EFI_RESOURCE_MEMORY_UNACCEPTED memory region is cross the 4G address, it will be split into 2 parts and only the left one (<4G) is accepted. The max accepted memory address is stored in Tdx workarea which will be used in TransferTdxHobList. Please be noted: in current stage, we only accept the memory under 4G. We will re-visit here in the future when on-demand accept memory is required. 2. TransferTdxHobList Transfer the unaccepted memory hob to EFI_RESOURCE_SYSTEM_MEMORY hob if it is accepted. As it is mentioned in 1), there may be a EFI_RESOURCE_MEMORY_UNACCEPTED hob which only part of the memory describes in the hob is accepted. We also handles this situation in TransferTdxHobList. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 129 ++++++++++++++++++-- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 2 + 2 files changed, 121 insertions(+), 10 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index 396b14d919d2..333c69d1a854 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -7,6 +7,7 @@ =20 **/ =20 +#include #include #include #include @@ -24,7 +25,8 @@ #include #include =20 -#define ALIGNED_2MB_MASK 0x1fffff +#define ALIGNED_2MB_MASK 0x1fffff +#define MEGABYTE_SHIFT 20 =20 /** This function will be called to accept pages. Only BSP accepts pages. @@ -375,11 +377,18 @@ ProcessHobList ( EFI_STATUS Status; EFI_PEI_HOB_POINTERS Hob; EFI_PHYSICAL_ADDRESS PhysicalEnd; + TDX_WORK_AREA *WorkArea; + UINT64 ResourceLength; + UINT64 AccumulateAcceptedMemory; + UINT64 MaxAcceptedMemoryAddress; =20 Status =3D EFI_SUCCESS; ASSERT (VmmHobList !=3D NULL); Hob.Raw =3D (UINT8 *)VmmHobList; =20 + AccumulateAcceptedMemory =3D 0; + MaxAcceptedMemoryAddress =3D 0; + // // Parse the HOB list until end of list or matching type is found. // @@ -393,7 +402,16 @@ ProcessHobList ( DEBUG ((DEBUG_INFO, "ResourceLength: 0x%llx\n", Hob.ResourceDescri= ptor->ResourceLength)); DEBUG ((DEBUG_INFO, "Owner: %g\n\n", &Hob.ResourceDescriptor->Owne= r)); =20 - PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Resour= ceDescriptor->ResourceLength; + PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; + ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; + + if (PhysicalEnd > SIZE_4GB) { + // + // In current stage, we only accept the memory under 4G + // + ResourceLength -=3D (PhysicalEnd - SIZE_4GB); + PhysicalEnd =3D SIZE_4GB; + } =20 Status =3D BspAcceptMemoryResourceRange ( Hob.ResourceDescriptor->PhysicalStart, @@ -402,12 +420,25 @@ ProcessHobList ( if (EFI_ERROR (Status)) { break; } + + AccumulateAcceptedMemory +=3D ResourceLength; + MaxAcceptedMemoryAddress =3D PhysicalEnd; } } =20 Hob.Raw =3D GET_NEXT_HOB (Hob); } =20 + // + // Record MaxAcceptedMemoryAddress in OvmfWorkArea. + // This information is useful later but in SEC phase we cannot use a glo= bal + // variable to pass this value. So it is stored in OvmfWorkarea. + // + WorkArea =3D (TDX_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); + ASSERT (WorkArea !=3D NULL); + ASSERT (WorkArea->Header.GuestType =3D=3D CcGuestTypeIntelTdx); + WorkArea->SecTdxWorkArea.MaxAcceptedMemoryAddress =3D MaxAcceptedMemoryA= ddress; + return Status; } =20 @@ -460,6 +491,74 @@ ProcessTdxHobList ( return Status; } =20 +/** + * Build ResourceDescriptorHob for the unaccepted memory region. + * This memory region may be splitted into 2 parts because of lazy accept. + * + * @param Hob Point to the EFI_HOB_RESOURCE_DESCRIPTOR + * @param MaxAcceptedMemoryAddress The max accepted memory address + * @return VOID + */ +VOID +BuildResourceDescriptorHobForUnacceptedMemory ( + IN EFI_HOB_RESOURCE_DESCRIPTOR *Hob, + IN UINT64 MaxAcceptedMemoryAddress + ) +{ + EFI_PHYSICAL_ADDRESS PhysicalStart; + EFI_PHYSICAL_ADDRESS PhysicalEnd; + UINT64 ResourceLength; + EFI_RESOURCE_TYPE ResourceType; + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; + UINT64 AcceptedResourceLength; + + ASSERT (Hob->ResourceType =3D=3D EFI_RESOURCE_MEMORY_UNACCEPTED); + + ResourceType =3D EFI_RESOURCE_MEMORY_UNACCEPTED; + ResourceAttribute =3D Hob->ResourceAttribute; + PhysicalStart =3D Hob->PhysicalStart; + ResourceLength =3D Hob->ResourceLength; + PhysicalEnd =3D PhysicalStart + ResourceLength; + + if (PhysicalEnd <=3D MaxAcceptedMemoryAddress) { + // + // This memory region has been accepted. + // + ResourceType =3D EFI_RESOURCE_SYSTEM_MEMORY; + ResourceAttribute |=3D (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_= ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED); + } else if (PhysicalStart >=3D MaxAcceptedMemoryAddress) { + // + // This memory region hasn't been accepted. + // So keep the ResourceType and ResourceAttribute unchange. + // + } else { + // + // This memory region is splitted into 2 parts: + // the accepted and unaccepted. + // + AcceptedResourceLength =3D MaxAcceptedMemoryAddress - Hob->PhysicalSta= rt; + + // We build the ResourceDescriptorHob for the accepted part. + // The unaccepted part will be build out side the if-else block. + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttribute | (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_A= TTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED), + Hob->PhysicalStart, + AcceptedResourceLength + ); + + PhysicalStart =3D Hob->PhysicalStart + AcceptedResourceLength; + ResourceLength -=3D AcceptedResourceLength; + } + + BuildResourceDescriptorHob ( + ResourceType, + ResourceAttribute, + PhysicalStart, + ResourceLength + ); +} + /** Transfer the incoming HobList for the TD to the final HobList for Dxe. The Hobs transferred in this function are ResourceDescriptor hob and @@ -477,6 +576,16 @@ TransferTdxHobList ( EFI_PEI_HOB_POINTERS Hob; EFI_RESOURCE_TYPE ResourceType; EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; + UINT64 MaxAcceptedMemoryAddress; + TDX_WORK_AREA *WorkArea; + + 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; + } =20 // // PcdOvmfSecGhcbBase is used as the TD_HOB in Tdx guest. @@ -489,16 +598,16 @@ TransferTdxHobList ( ResourceAttribute =3D Hob.ResourceDescriptor->ResourceAttribute; =20 if (ResourceType =3D=3D EFI_RESOURCE_MEMORY_UNACCEPTED) { - ResourceType =3D EFI_RESOURCE_SYSTEM_MEMORY; - ResourceAttribute |=3D (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RES= OURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED); + BuildResourceDescriptorHobForUnacceptedMemory (Hob.ResourceDescr= iptor, MaxAcceptedMemoryAddress); + } else { + BuildResourceDescriptorHob ( + ResourceType, + ResourceAttribute, + Hob.ResourceDescriptor->PhysicalStart, + Hob.ResourceDescriptor->ResourceLength + ); } =20 - BuildResourceDescriptorHob ( - ResourceType, - ResourceAttribute, - Hob.ResourceDescriptor->PhysicalStart, - Hob.ResourceDescriptor->ResourceLength - ); break; case EFI_HOB_TYPE_MEMORY_ALLOCATION: BuildMemoryAllocationHob ( diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index 942eaf89cfcf..62132f9cacfa 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -42,6 +42,8 @@ Module Name: =20 #include =20 +#define MEGABYTE_SHIFT 20 + VOID EFIAPI PlatformQemuUc32BaseInitialization ( --=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 (#93133): https://edk2.groups.io/g/devel/message/93133 Mute This Topic: https://groups.io/mt/93474519/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- From nobody Sun May 12 17:14:57 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+93134+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+93134+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366940; cv=none; d=zohomail.com; s=zohoarc; b=fRx0Nbixs8ifSIM7dakxfzF6hFkZ1pDccNNLj5K96fIJvgA41Ec3YFYNjip+yLRdzkGg9wbA3n5PLlLb9FNz+qnV1yzhAqpF9DR9QeDZ8irFyCIDUiZSqbzLlkqR3I4O/0EZaFPRAxvYgHPhHT4RGQNclHBBgeMSUTAj+HEHbpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366940; 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=tkSzdCrfHpAUXNrWkZnbMkiyWAhc8JJ5+VO/ObZ72J8=; b=h92Vi+uc9H5OAsOoyHjjlI0fCL2boRu45AwVdGa34vtWsqPztcBQdZEtN7P3+GJkc3rgRXhERuDvw3xzzQTjId4rakQcwIzkE3w1pPHSZyAw34qgOYEKHfYeOHsttJ9j4yK43tz2gPSbrloMmLpd9ZowP6dlIa5A0U3sCtAWIk4= 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+93134+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 1662366940260809.1027897391273; Mon, 5 Sep 2022 01:35:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DEHFYY1788612xvtAvpkX3wO; Mon, 05 Sep 2022 01:35:39 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:39 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355930" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355930" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194465" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:37 -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 V3 09/12] OvmfPkg: Update ConstructFwHobList for lazy accept Date: Mon, 5 Sep 2022 16:35:03 +0800 Message-Id: <5f53ebaa41c5231ff9bb0031ca95afd7e05684c1.1662365866.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: 13VZTILpoTrLJPrrhd3d38Hsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366939; bh=JqFpcCgRyJ8Z7WKOEsfsNCtXWn5lIjYT8j8IWyOYuMQ=; h=Cc:Date:From:Reply-To:Subject:To; b=hlZRkoWfNJCcFskFanrUqI77KEZRKBdJjIdn5Fq5X9oAn7bE0bGB9dnJvo3kfA0pnap LBvOerIgbDM+Lmxib3DtgiEqUT9rpZNe3+Z4rNDmf4OYSPOb4/1DKzl65GRFJgcbtJLvE 14KiKDIU1kC20Js7Ao4W7ZSuOo+v5ccocCU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366940567100011 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 def50b4b019e..eed9f27d3d01 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 (#93134): https://edk2.groups.io/g/devel/message/93134 Mute This Topic: https://groups.io/mt/93474520/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- From nobody Sun May 12 17:14:57 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+93135+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+93135+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366942; cv=none; d=zohomail.com; s=zohoarc; b=blKVIEaaWiTb83scPnxQoo4k9VAncPwuMAybICZCoGm+xcn80y7R8smRr7GGuiJVdxAtKdT7K0+/gjX3jOX/3Yd5VXupXZh48VpnvT2oUkqIoxOpMNbzHjQ36xzvbhlj97h/zWnfhQHSUgs+NE4xuklNMdUxi6n75wgTZQ3SIWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366942; 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=R7M/GpNLflKpLdgA3DWwUBaHIV5kjYGimu6PrsZ3PSA=; b=erbpgMhJUdkFCEc/e5/R5/K0nqhvcwbIXJ8Rszt9aEQ1fUsvpqdSCfZLb0ahgM0U7R338X1mTWuO5BWNw3f83ye7gCfIrkaqTwo36giG34Y44owudm5NzFcUa51N0Hx3AW3FxLiWzHDRwsC4Q26VtBJF3fpAKOxPAEXuHWTtdro= 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+93135+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 1662366942910541.7371404457516; Mon, 5 Sep 2022 01:35:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5IsoYY1788612xpZ1Bhmj27s; Mon, 05 Sep 2022 01:35:42 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:42 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355951" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355951" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:41 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194507" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:38 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Jiaqi Gao , Michael D Kinney , Liming Gao , Zhiguang Liu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Min Xu Subject: [edk2-devel] [PATCH V3 10/12] MdePkg: The prototype definition of EdkiiMemoryAcceptProtocol Date: Mon, 5 Sep 2022 16:35:04 +0800 Message-Id: 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: ZdzrrH9BCBWb5ul0SQeZ2BMKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366942; bh=OeeW4tqAxyinS7QMDmvnBl+5YWX0oyFPtyM+BaPF83Q=; h=Cc:Date:From:Reply-To:Subject:To; b=ld2NCBwQAabNQusy0sGJaY0WgI2dl6UxJK+kDFfEaV79O/ZcDe+QWSoCTi2eclEoYg/ hCUSQA2Q+dAJfzRR7H1IEk52uen049NbFc4mHJ2haWktl86ym3ouEiBKIp6Lv1PEbiTxv 1atIW++T2Ll8Lsob/XuSgqNWy9XjF54KUAM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366944571100001 Content-Type: text/plain; charset="utf-8" From: Jiaqi Gao RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 EdkiiMemoryAcceptProtocol is defined in MdePkg, the method AcceptMemory() can be called when memory needs to be accepted. EdkiiMemoryAcceptProtocol can be installed by architecture-specific drivers such as TdxDxe. This allows different isolation architectures to realize their own low-level methods to accept memory. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Jiaqi Gao Signed-off-by: Min Xu --- MdePkg/Include/Protocol/MemoryAccept.h | 37 ++++++++++++++++++++++++++ MdePkg/MdePkg.dec | 3 +++ 2 files changed, 40 insertions(+) create mode 100644 MdePkg/Include/Protocol/MemoryAccept.h diff --git a/MdePkg/Include/Protocol/MemoryAccept.h b/MdePkg/Include/Protoc= ol/MemoryAccept.h new file mode 100644 index 000000000000..f7646e04d8a1 --- /dev/null +++ b/MdePkg/Include/Protocol/MemoryAccept.h @@ -0,0 +1,37 @@ +/** @file + The file provides the protocol to provide interface to accept memory. + + Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MEMORY_ACCEPT_H_ +#define MEMORY_ACCEPT_H_ + +#define EDKII_MEMORY_ACCEPT_PROTOCOL_GUID \ + { 0x38c74800, 0x5590, 0x4db4, { 0xa0, 0xf3, 0x67, 0x5d, 0x9b, 0x8e, 0x80= , 0x26 } }; + +typedef struct _EDKII_MEMORY_ACCEPT_PROTOCOL EDKII_MEMORY_ACCEPT_PROTOCOL; + +/** + @param This A pointer to a EDKII_MEMORY_ACCEPT_PROTOCO= L. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_ACCEPT_MEMORY)( + IN EDKII_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size + ); + +/// +/// The EDKII_MEMORY_ACCEPT_PROTOCOL provides the ability for memory servi= ces +/// to accept memory. +/// +struct _EDKII_MEMORY_ACCEPT_PROTOCOL { + EDKII_ACCEPT_MEMORY AcceptMemory; +}; + +extern EFI_GUID gEdkiiMemoryAcceptProtocolGuid; + +#endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f1ebf9e251c1..6b6bfbec29b3 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1019,6 +1019,9 @@ gEfiPeiDelayedDispatchPpiGuid =3D { 0x869c711d, 0x649c, 0x44fe, { 0x8b,= 0x9e, 0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6 }} =20 [Protocols] + ## Include/Protocol/MemoryAccept.h + gEdkiiMemoryAcceptProtocolGuid =3D { 0x38c74800, 0x5590, 0x4db4, { 0xa0,= 0xf3, 0x67, 0x5d, 0x9b, 0x8e, 0x80, 0x26 }} + ## Include/Protocol/Pcd.h gPcdProtocolGuid =3D { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2,= 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }} =20 --=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 (#93135): https://edk2.groups.io/g/devel/message/93135 Mute This Topic: https://groups.io/mt/93474521/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- From nobody Sun May 12 17:14:57 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+93136+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+93136+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366944; cv=none; d=zohomail.com; s=zohoarc; b=VZHHcrf25air/mHGDlvN5CmvEw8PonPx/QKycedzjB2CARfioF7hgNd7Ne1cQJdFeB4c4ry7ATvjJRwKJ+s2/X+k46/MkD5A/epeHANs6Ke7xXL8o0mO9HlSNE0TajJmKkSYfLQta6frHbyuQuJ6SYQEJuk+BcLcjmJIwNMSToo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366944; 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=rVxWWarjrSJKKkFasXS/QWTC77IozHFWi4CnpLIQnLY=; b=VI2oHKBvyGqQEmc2yjrBLMQqvmQvvYjZFCQVR//sGCvVxL+vzUTdcRZXuaqXryredA7eA5YWo4dQsjXDlG1sToNlIQs1xrD42LsY8otI/bjRa6DKmoqCpwjeEks1rHIYzsF7vM37tpjvf+WTNgDhYWjSkjKUZA6plPovvM7nka0= 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+93136+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 1662366944769103.96599226039189; Mon, 5 Sep 2022 01:35:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5ZSjYY1788612x1mF0gU4rYY; Mon, 05 Sep 2022 01:35:44 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:43 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355973" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355973" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:43 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194542" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:41 -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 V3 11/12] OvmfPkg: Realize EdkiiMemoryAcceptProtocol in TdxDxe Date: Mon, 5 Sep 2022 16:35:05 +0800 Message-Id: <1fc2489e36e45804efc5fee5089719d9ec318146.1662365866.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: 3iJod7TN3ppYjtyrB3NcTScQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366944; bh=ym/BqpD8DOxtKW4YtVHQ34XTuPh9OUSUhV/XAwgO540=; h=Cc:Date:From:Reply-To:Subject:To; b=jSTENdPgHKlJN6ME260FKUIrpZhX8jY8MjDWYFZrzTocg8OnLOP8Yaku1BHzKOWYcK6 H+Xq7MzlrJFUKegkz2ctVhgcEFKD4Jzzl3LiRjSuRfGBkh3adbcfRIrwwq71NDK9hPD/L nwXSB26uoIeP+LQ+8gMs41hbu/ys5xSwcpg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366946581100005 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Memory usage may exceed the amount accepted at the begining (SEC), TDVF needs to accept memory dynamically when OUT_OF_RESOURCE occurs. Another usage is in SetOrClearSharedBit. If a memory region is changed from shared to private, it must be accepted again. EdkiiMemoryAcceptProtocol is defined in MdePkg and is implementated / installed in TdxDxe for Intel TDX memory acceptance. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/TdxDxe/TdxDxe.c | 103 ++++++++++++++++++++++++++++++++++++++ OvmfPkg/TdxDxe/TdxDxe.inf | 2 + 2 files changed, 105 insertions(+) diff --git a/OvmfPkg/TdxDxe/TdxDxe.c b/OvmfPkg/TdxDxe/TdxDxe.c index 2318db989792..ca948522a42c 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.c +++ b/OvmfPkg/TdxDxe/TdxDxe.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,95 @@ #include #include =20 +#define ALIGNED_2MB_MASK 0x1fffff +EFI_HANDLE mTdxDxeHandle =3D NULL; + +EFI_STATUS +EFIAPI +TdxMemoryAccept ( + IN EDKII_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size + ) +{ + EFI_STATUS Status; + UINT32 AcceptPageSize; + UINT64 StartAddress1; + UINT64 StartAddress2; + UINT64 StartAddress3; + UINT64 Length1; + UINT64 Length2; + UINT64 Length3; + UINT64 Pages; + + AcceptPageSize =3D FixedPcdGet32 (PcdTdxAcceptPageSize); + StartAddress1 =3D 0; + StartAddress2 =3D 0; + StartAddress3 =3D 0; + Length1 =3D 0; + Length2 =3D 0; + Length3 =3D 0; + + if (Size =3D=3D 0) { + return EFI_SUCCESS; + } + + if (ALIGN_VALUE (StartAddress, SIZE_2MB) !=3D StartAddress) { + StartAddress1 =3D StartAddress; + Length1 =3D ALIGN_VALUE (StartAddress, SIZE_2MB) - StartAddress; + if (Length1 >=3D Size) { + Length1 =3D Size; + } + + StartAddress +=3D Length1; + Size -=3D Length1; + } + + if (Size > SIZE_2MB) { + StartAddress2 =3D StartAddress; + Length2 =3D Size & ~(UINT64)ALIGNED_2MB_MASK; + StartAddress +=3D Length2; + Size -=3D Length2; + } + + if (Size) { + StartAddress3 =3D StartAddress; + Length3 =3D Size; + } + + Status =3D EFI_SUCCESS; + if (Length1 > 0) { + Pages =3D Length1 / SIZE_4KB; + Status =3D TdAcceptPages (StartAddress1, Pages, SIZE_4KB); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (Length2 > 0) { + Pages =3D Length2 / AcceptPageSize; + Status =3D TdAcceptPages (StartAddress2, Pages, AcceptPageSize); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (Length3 > 0) { + Pages =3D Length3 / SIZE_4KB; + Status =3D TdAcceptPages (StartAddress3, Pages, SIZE_4KB); + ASSERT (!EFI_ERROR (Status)); + if (EFI_ERROR (Status)) { + return Status; + } + } + + return Status; +} + +EDKII_MEMORY_ACCEPT_PROTOCOL mMemoryAcceptProtocol =3D { + TdxMemoryAccept +}; + VOID SetPcdSettings ( EFI_HOB_PLATFORM_INFO *PlatformInfoHob @@ -277,6 +367,19 @@ TdxDxeEntryPoint ( NULL ); =20 + // + // Install MemoryAccept protocol for TDX + // + Status =3D gBS->InstallProtocolInterface ( + &mTdxDxeHandle, + &gEdkiiMemoryAcceptProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMemoryAcceptProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install EdkiiMemoryAcceptProtocol failed.\n")); + } + // // Call TDINFO to get actual number of cpus in domain // diff --git a/OvmfPkg/TdxDxe/TdxDxe.inf b/OvmfPkg/TdxDxe/TdxDxe.inf index a7e0abda1522..9be021f28648 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.inf +++ b/OvmfPkg/TdxDxe/TdxDxe.inf @@ -52,6 +52,7 @@ gEfiAcpiTableProtocolGuid ## CONSUMES gEfiMpInitLibMpDepProtocolGuid gEfiMpInitLibUpDepProtocolGuid + gEdkiiMemoryAcceptProtocolGuid =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase @@ -68,3 +69,4 @@ gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack + gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize --=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 (#93136): https://edk2.groups.io/g/devel/message/93136 Mute This Topic: https://groups.io/mt/93474522/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- From nobody Sun May 12 17:14:57 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+93137+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+93137+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662366947; cv=none; d=zohomail.com; s=zohoarc; b=FT6/zfqvnZO4hbXKuWvfKe/6MJxA13SZruyzm6FbmJ1voVVqmAJkYb4PEQ+Y6BPPGFQGT2ubyUv+eO+v7Uef9wJf8ij3e/6TgJJ8rud7XKV5/6s+YVPQWgDXX7tkIJFq3GWnhX1Z+uczBgOnhH1dYVwb4qR7DjuLFfwxduaT/fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662366947; 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=NUXTUcNNhjs2HXoTF6CVQujMZeh2tkzpKcaxuNkxTJA=; b=QYlCLdxX/D/kLHtCXOtOGgvmegfw2SCO+zbPLo0mhy5q552TFsgk1r/DUls2sEWf16bLDIhSck8EUcgvQ75YZgK9k8AGumHMLo5pbmM6ghlstqOqaKzpJkIFoqTmRptMwfUbu85ri0T861tPnhNiWG9RG+OoREdEFpFxOh1THHs= 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+93137+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 166236694714599.60142795274271; Mon, 5 Sep 2022 01:35:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FpieYY1788612xjBYh0IgYC7; Mon, 05 Sep 2022 01:35:46 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:46 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355992" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355992" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:45 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194563" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:43 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [edk2-devel] [PATCH V3 12/12] OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages Date: Mon, 5 Sep 2022 16:35:06 +0800 Message-Id: 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: yonVrxda2b1WC3U4jR8T95abx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662366946; bh=IpAkV/MlvzutXCJtuzsxbvfEGpZH60jycCEjqthQ/Zw=; h=Cc:Date:From:Reply-To:Subject:To; b=LOfDg1AyggNJWYZ7IEMXaAZdO2PGM3W9xxsCy8q3wAM2+KWueMWI7Eh7b3osnG7FfwO 9ZeNwy7xbiKRYpw7rqEt8Et1m20F/kb3IBm8NsbwjS8O9LvaHmAwePx1Lp5tITZqwLZc6 UBqZ9lm22vRX6j4OwKNdT1W5s+QQwp+tP1Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662366948660100009 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 After EdkiiMemoryAcceptProtocol is implemented in TdxDxe driver, we can call it to accept pages in DXE phase. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- .../BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf | 3 +++ .../Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf = b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf index a8abfec12fa3..11768825f8ca 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf @@ -42,3 +42,6 @@ =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr + +[Protocols] + gEdkiiMemoryAcceptProtocolGuid diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c b/Ovmf= Pkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c index 9d11c6e4df72..503f626d75c6 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c @@ -27,6 +27,8 @@ #include "VirtualMemory.h" #include #include +#include +#include #include =20 typedef enum { @@ -517,8 +519,9 @@ SetOrClearSharedBit ( IN UINT64 Length ) { - UINT64 AddressEncMask; - UINT64 Status; + UINT64 AddressEncMask; + UINT64 Status; + EDKII_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol; =20 AddressEncMask =3D GetMemEncryptionAddressMask (); =20 @@ -539,7 +542,10 @@ SetOrClearSharedBit ( // If changing shared to private, must accept-page again // if (Mode =3D=3D ClearSharedBit) { - TdAcceptPages (PhysicalAddress, Length / EFI_PAGE_SIZE, EFI_PAGE_SIZE); + Status =3D gBS->LocateProtocol (&gEdkiiMemoryAcceptProtocolGuid, NULL,= (VOID **)&MemoryAcceptProtocol); + ASSERT (!EFI_ERROR (Status)); + Status =3D MemoryAcceptProtocol->AcceptMemory (MemoryAcceptProtocol, P= hysicalAddress, Length); + ASSERT (!EFI_ERROR (Status)); } =20 DEBUG (( --=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 (#93137): https://edk2.groups.io/g/devel/message/93137 Mute This Topic: https://groups.io/mt/93474523/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-