From nobody Thu May 9 14:39:40 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+93671+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+93671+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027352; cv=none; d=zohomail.com; s=zohoarc; b=Ur6T7WiLI3HOGXwdho+UD0rZ2R/Qugl9wPgMtrZ3EaCXBVuFiwv++IYrRci81l9guH8f+iR85PnOvw9ggTQh/x8clCSoREoAFeOWYeDIR/b1ZJubZdQMCZk6ee+MpGSX5POzSw/EFeYeZqfPLEevT4wfNNr1WhESlGyv0eCHaGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027352; 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=pqCg2leIcuuiKokiNSS4JjlZw6wjQBj8B48vO6b/K+U=; b=W7ux1fSFMkuhh/5pw+WYfhnfmqhNyensEL2ic9rSajGPoZDWXfB+C5Gzp+k8dCRhY08qtMuIqixPPYPrpTQ1b+UlmLy03O/hW31jwrpjPYWRPiUZI9+647qgwc4Pey2Cahg98JsA1RLjEFmGz7XnK56qcyv8HSkG2ZVKaCks0yQ= 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+93671+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 1663027352938610.9407029364011; Mon, 12 Sep 2022 17:02:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FXgWYY1788612xhrI5JYSEwA; Mon, 12 Sep 2022 17:02:32 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294365" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294365" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:31 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320826" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:29 -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 V4 01/10] MdeModulePkg: Add PrePiHob.h Date: Tue, 13 Sep 2022 08:02:05 +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: WcViNkT8LR8eojgPv25U1cLAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027352; bh=wxeKcP+WXExjEIZ7gJgTrrQBY6LfTMEeqLMvKxBFGtw=; h=Cc:Date:From:Reply-To:Subject:To; b=X7OFJpwX6xB+/r4rZk7OylL1psGovtdUGDrjPG1LWCSoNKUxtyKrdH9iSZgLuTzo9A9 dFkeowF5P4QgoadxbQDY3D0Vrqbzroh90ZaL2bOn58Kl4jUuBan7X5R8HfMz7Ref0Wh6F rFHqwFQuKfmDy5i5T6QEUp1QEPXGfhgkJF0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027355061100007 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 BZ3937_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 BZ3937_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 Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- 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..ac575e59721b --- /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_ + +// +// BZ3937_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 BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED at +// MdeModulePkg/Include/Pi/PrePiHob.h. +// +#define BZ3937_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 (#93671): https://edk2.groups.io/g/devel/message/93671 Mute This Topic: https://groups.io/mt/93645530/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 Thu May 9 14:39:40 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+93672+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+93672+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027356; cv=none; d=zohomail.com; s=zohoarc; b=LhEGc95S6+7pLVHUXOJfA/hjDSxoPN1QCsLQTGKjvb1JfGSSfeec767WQ8wIpVKw7VT+yFMGT31KDL/f8whuCaeY/iEcH2UXOXvGQW0St0lKmRQcjgAgZy3EYqXqJJZVfW45gg94/RCWJh0RPe//b9k6CMTLZFLCfb7KAsIKK3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027356; 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=17dSUFwJu2Ig2DdCff3fsILqy6quf27+HxCmGUBQ+gc=; b=Ys7JAtHAzfhc8Xgz3i7EklxARovg1fM1Fetuvjfb1/N4HZRSmH16kg1sRs9FgOJjJ2uJy+Sr4ADkpkZIRG+yflqV53dA+j3m7xZN9hX9tO1cIXWI+zLZIUFZVulh1T9wfhe46P6uvGOnh/MjnHTwTiqiOAVhrumZLGHOs6ejvG4= 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+93672+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 1663027356113647.0436561681144; Mon, 12 Sep 2022 17:02:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZYmqYY1788612x6TKEzeqE8I; Mon, 12 Sep 2022 17:02:34 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:34 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294378" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294378" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:33 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320848" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:31 -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 V4 02/10] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Date: Tue, 13 Sep 2022 08:02: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: uWdTYebGR943I8gKiuVkH2Fjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027354; bh=Y1DFCn9fstSVJtrLWzp/WHgl7eYSKrzrKVUwvhFnLF4=; h=Cc:Date:From:Reply-To:Subject:To; b=K/hkOjd6C7ubs5AriqWrgdO3koFHkQxNKClqpHmGZn7JJdarHZyAUOW5Y4D4uciPwhk Fif1vlNBPuGhKouC+nH1ykXd6IuCTl/tRYXdXwB4wlRGf5Xi8LTnCopzC8rRGc337opaK jarWmMA7tqUrfxi+RHNlsd55FQldja8vK3M= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027357080100011 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 BZ3937_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 BZ3937_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 Acked-by: Gerd Hoffmann --- 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..4605da56e247 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 +// +// BZ3937_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 BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED at +// MdeModulePkg/Include/Pi/PrePiHob.h and update EFI_RESOURCE_MAX_MEMORY_T= YPE +// to 8. After BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED is officially publish= ed +// in PI spec, we will re-visit here. +// +// #define BZ3937_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 (#93672): https://edk2.groups.io/g/devel/message/93672 Mute This Topic: https://groups.io/mt/93645534/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 Thu May 9 14:39:40 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+93673+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+93673+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027357; cv=none; d=zohomail.com; s=zohoarc; b=WHEiZHNjz6DFlURgvuiki2zZAEv5pJ0Bjbh8U0chpxpyv9Xek11YIgjJeyPJ/ofhT5taplKYEMe/t1EuFmIbsn1lM74e5c6aqdv9HFpDBuW05sY2Sg3otuiVpl0ppQQ/D/g59JTDXivWQQbMTEzSFAjNmk/LOePbrH4b9JCCIgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027357; 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=6UXz77CjGiEa/vRjTL9ii4LBX9aS3OHkROLsm3sKqFI=; b=KMMbUtid01/t3IqSy1HbeaBO6Sow7MUyUEHfM7fqLk4YWVtYIfUCGCHOiCtmqsWFoM9OJq7hivhm9LmNpulqhybJfG6HuANXU+jYK5ANqHUOkI2hYovs+/LqqJZ9wD5SUuImHOtciaJyYjQzm5FLBVTBIh3ZLHEMWf4xgmka8tY= 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+93673+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 1663027357013332.4579799741646; Mon, 12 Sep 2022 17:02:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Q7KgYY1788612xkqCHSYr8W7; Mon, 12 Sep 2022 17:02:36 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:36 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294389" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294389" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:35 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320858" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:34 -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 V4 03/10] OvmfPkg: Use BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED defined in MdeModulePkg Date: Tue, 13 Sep 2022 08:02:07 +0800 Message-Id: <85fddf4e02243bf973279409a02b8cb8822d96b4.1663026445.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: mr6ZdWcmuMMshDKrOExtqqB6x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027356; bh=IIh3KxHWOSmaUlCi8JmAW23yxcgmoHlZeDd5TCXsNBE=; h=Cc:Date:From:Reply-To:Subject:To; b=ZujMhOMVyFfytCiUrvgw1Da6YgpSkWQX3d9hE5gDGiqrA0zQVguNYWrioVkdXJ8rxY+ PWjuN4g9czEIuAgmwHlk9mEbjW0EnG7oBOhb5E2kyKplrQZyDbYC0u7snoEY1WoqMVCH3 wr0ahauXZ0JbRoGs5kIK2fMnirU5L51zP74= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027359083100015 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 BZ3937_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 Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 5 ++--- OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/Peil= essStartupLib/Hob.c index 5fc84a809025..630ce445ebec 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. * @@ -92,7 +91,7 @@ ConstructFwHobList ( // 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 BZ3937_EFI_RESOURCE_= MEMORY_UNACCEPTED) { PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; =20 diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index c6d7c8bb6e0e..797f880df035 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 +#define ALIGNED_2MB_MASK 0x1fffff =20 /** This function will be called to accept pages. Only BSP accepts pages. @@ -211,7 +211,7 @@ ValidateHobList ( EFI_RESOURCE_MEMORY_MAPPED_IO_PORT, EFI_RESOURCE_MEMORY_RESERVED, EFI_RESOURCE_IO_RESERVED, - EFI_RESOURCE_MEMORY_UNACCEPTED + BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED }; =20 if (VmmHobList =3D=3D NULL) { @@ -387,7 +387,7 @@ ProcessHobList ( if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { DEBUG ((DEBUG_INFO, "\nResourceType: 0x%x\n", Hob.ResourceDescriptor= ->ResourceType)); =20 - if (Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY_= UNACCEPTED) { + if (Hob.ResourceDescriptor->ResourceType =3D=3D BZ3937_EFI_RESOURCE_= MEMORY_UNACCEPTED) { DEBUG ((DEBUG_INFO, "ResourceAttribute: 0x%x\n", Hob.ResourceDescr= iptor->ResourceAttribute)); DEBUG ((DEBUG_INFO, "PhysicalStart: 0x%llx\n", Hob.ResourceDescrip= tor->PhysicalStart)); DEBUG ((DEBUG_INFO, "ResourceLength: 0x%llx\n", Hob.ResourceDescri= ptor->ResourceLength)); @@ -488,7 +488,7 @@ TransferTdxHobList ( ResourceType =3D Hob.ResourceDescriptor->ResourceType; ResourceAttribute =3D Hob.ResourceDescriptor->ResourceAttribute; =20 - if (ResourceType =3D=3D EFI_RESOURCE_MEMORY_UNACCEPTED) { + if (ResourceType =3D=3D BZ3937_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); } --=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 (#93673): https://edk2.groups.io/g/devel/message/93673 Mute This Topic: https://groups.io/mt/93645535/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 Thu May 9 14:39:40 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+93674+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+93674+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027360; cv=none; d=zohomail.com; s=zohoarc; b=QMsgzVPhKRN6ozmt9N40Fe738z+rnJOsymxGZEkzjUwsn7mzCI9b5drfLWGKtrMyyQbJglRSH/gBnHjQPDw5KbajCq4xf8RgzQRpTf//hK09J81OY9z0kue/17GToH8Jzz038rCYJmefK/ynBHrMH2YAlFK44L8qWXmRyabT65g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027360; 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=oUWrXYVXB0CzHbivM+LRXj8Pk4okGorELKU9rBoUWaA=; b=aqLAHQDzXkMwwiBqSOkVhBquoZ70BGpFKLtunCwODVf1NYfAqz3uOe8AR1yxIV3WrFaXMyomnt22mGfhzPFQR3a1uHveRyyBq6rnnZEaE0YY+cmOwHAKMWl1QJOAbA+Wv5p8Y+J+wh+uVaPzG7ubtEjRAlANnOxI35C69Z7bnE0= 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+93674+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 1663027360629528.770677499949; Mon, 12 Sep 2022 17:02:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dEHXYY1788612xH9vPopwhW9; Mon, 12 Sep 2022 17:02:39 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:38 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294394" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294394" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320874" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:36 -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 V4 04/10] MdePkg: Add UEFI Unaccepted memory definition Date: Tue, 13 Sep 2022 08:02:08 +0800 Message-Id: <8332966c5cec58392aec0e1fd873a3008e8ed738.1663026445.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: 58NkzsEB8g7FN2SuWopUeTjQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027359; bh=9t/QQAhMDCKSMPOl58e7HHz6UIGRua6VBhReJFbGlW4=; h=Cc:Date:From:Reply-To:Subject:To; b=EZKztfJiElMqyOXo68dvB6T+b9FXCPxd9wNk0hIVBlLkqW6OfXwhKpWyl6qKzuW+UHO 0gQ5nWFnkh6qCqww9RJBaGugDL/EuT0BcQCM4Hc80e9erHgmpj6JtPuk33jd+ynTvtRr/ sXQyS/stVlXUOOfK3c1/eJ5RoLhhDyD9hXA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027361118100019 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 Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- 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 (#93674): https://edk2.groups.io/g/devel/message/93674 Mute This Topic: https://groups.io/mt/93645537/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 Thu May 9 14:39:40 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+93675+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+93675+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027362; cv=none; d=zohomail.com; s=zohoarc; b=jv0to/aYXv6BRtDNPWAmnsOtgEEQefDIgMPRMLEpae02LYFg0hvKD4ja8mAutV4FliYrQUmaxBAZmJroBJngs7Q/1QL/E+gx8tPpQJQcOXpiNIrMNeFOITsQsKVAdnDrS69o8QvCdb861Rom6kxXRKnZ9663DtW0oSVnNbFb1aQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027362; 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=bNey+1NYWgW2x5ae+y/HEXu2DO1HmPSLSYwN5pr96WU=; b=W7DMjvPaCJyUjGZKLg/8rDFW5JfTlDoXYdG/pxPLUhYVtVdgZMn6LEpEThqpJ5keTl/RoXEwvxX9UYgGsfYOQoUiU2exD2QNG6Bd8MdO4ui78gMp+uBLezwG3OyHHdBqlDBYqF4ULHrl17RMhkRaJ0XmKoGOlh+PqJWPU2H6xvo= 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+93675+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 1663027362121765.4354750122884; Mon, 12 Sep 2022 17:02:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UlbFYY1788612xXrNgxt77s2; Mon, 12 Sep 2022 17:02:41 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:41 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294408" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294408" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:41 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320892" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:38 -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 V4 05/10] MdeModulePkg: Update Dxe to handle unaccepted memory type Date: Tue, 13 Sep 2022 08:02:09 +0800 Message-Id: <7ec13978a407949dafd353d5f01e34ad0a0409aa.1663026445.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: 3ljaFV552m0IPfVqSVDgGo5Ax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027361; bh=h3pkD6vrk0ONJ32Dv5TJvdrEmDvOMHS01LSheMlUCH4=; h=Cc:Date:From:Reply-To:Subject:To; b=GtwaH3FGFhnQofi44xIvRuew6Q56ft2/uobj5rKe4aZZTO7nWAcxfn+mKqs9bKY2CQf EY1sRoNlfkwD57U0qt2LAm1Z8g4qUUqu3UamkYlN0oboPM+xC9rV4R77nQ4v9iWudTroA ndL9o3uU6slFn8ui/5XUORxa2vNIRMvr1MA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027363158100021 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 Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- 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..792cd2e0af23 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 BZ3937_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 (#93675): https://edk2.groups.io/g/devel/message/93675 Mute This Topic: https://groups.io/mt/93645539/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 Thu May 9 14:39:40 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+93676+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+93676+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027364; cv=none; d=zohomail.com; s=zohoarc; b=P6vCRFXlW2g7X0VfMuBvisHntkXND34J5VaNhozFjyQQNi86bVTXARn002Xkbd1TCS0N2ix0PYMTKY0CZoC02dD/uZMly/BDV9sIxlUmNkFBjvmNk06k7j56V4xs6cQPUbXaFNYpzOB8MkX9NuLcTrZeRsXnuBRSd8Uqdpbd3wk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027364; 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=gF6iJQiaAmhCjF9pPQDB02KiLd8mf14E9n8nK3STJ7w=; b=b91vc/Zt8NUIWcesb18I0Mp1YYsYwNHroPwsF2a75A0GiRlMwYQRp9VmPpDiLAlZKLu2zAAVPPPcagjgp3PJ8L+p5eNhtwm4sJckRAqctrG1B4yoLx2Ez6gjInPtC//oKBOtzciXAVcBq2sgOs1l4zbOHcf4b06Jeg3hpxU9sdk= 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+93676+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 1663027364729189.8776513645255; Mon, 12 Sep 2022 17:02:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id AytkYY1788612xD1Xx2jwve7; Mon, 12 Sep 2022 17:02:44 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:43 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294432" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294432" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:43 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320906" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:41 -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 V4 06/10] ShellPkg: Update shell command memmap to show unaccepted memory Date: Tue, 13 Sep 2022 08:02:10 +0800 Message-Id: <91d6622326a90c86ae6a70121f2ad15299e56e75.1663026445.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: 259Qg4BrbkkKMxCo6uye6dZdx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027364; bh=3xMBXC8A9Eow0vhIlVyI/OaUTRD+g6Y00xUVxUnLvsM=; h=Cc:Date:From:Reply-To:Subject:To; b=M6nrp52YLV5fKoDVtAZTYCKd0z63rfRwBzVi4EBcR6QCrzPCqhzX8R4bXtc/jCsmFOu rDwZAIGW/9Zmp8GB+MP3SBdzGwKDpetx7PuMKsMb+MhAoR5VKeYiaOBQ/DqyZ9UQDGEun 31TVJMJIT2Rp8T02JTp6a/lvak1EAq2zSm8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027365149100023 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 Acked-by: Zhichao Gao Signed-off-by: Min Xu --- .../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 (#93676): https://edk2.groups.io/g/devel/message/93676 Mute This Topic: https://groups.io/mt/93645541/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 Thu May 9 14:39:40 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+93677+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+93677+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027366; cv=none; d=zohomail.com; s=zohoarc; b=FX5sSmvpRlgT5IPD5zcPNx3gAjp4uoDK1VtZujeaQ+QqnE/RU4YNvJKxe/ns7Rcy5NFn68eh/Vq+OdKCK7yYNLfFoMhSjfRIm46rKGIHMtUsXiQL+CA87W2Z3Bj5ng5ShRfTBxDdFU421CeNsD4HJpkIRb9PKm4Q+QHY8GWJDsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027366; 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=/nOqpurEObRJQJJzPE5S44GFPqsQp1jVDC3u3nTVDRc=; b=hLcoP4JrRKb1phExznAX13tdP8Wt6EtA3vpgBBVQYOc3CefA9v2bYVeWJKyo76NzBHeyMgqRHU1vRDgpoWRX7nuUyhtSBtmmlrZNrSDrO4t6qcAtOIgxhMJzVGwzJAlgLawNGTAHC+yhiy0a+fQujwH4F7/ETh8nWVIzfUkK3yE= 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+93677+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 1663027366842733.4290924604957; Mon, 12 Sep 2022 17:02:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id q4zpYY1788612xubj98BIwbH; Mon, 12 Sep 2022 17:02:46 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:46 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294464" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294464" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:45 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320919" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02: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 V4 07/10] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Date: Tue, 13 Sep 2022 08:02:11 +0800 Message-Id: <7b67ee2b4b49c696edb2c519840f50600c6d334f.1663026445.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: 5nU9191GUlZIvPhV9DZdZKP9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027366; bh=YL6jnT6Ex7XBEKF+5R5Zb7Y6PaGRSMfZOXddBehLZxY=; h=Cc:Date:From:Reply-To:Subject:To; b=A6VrsOFHbBtpzqcUJY9fJ50Wrl4Ccbui4geXVs5lWWrxNv7yIRTUVGBzfV4eW40xelK jR3xpjHxvf77YEs4qi14WTzrSO1uQ2TV98fAOYjSdeE06XAQMDgwo21scINfusMaP/kX3 YeljURRawVzvX1Ws/V2wobEH23h+PJGxpWU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027367147100027 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. 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. 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/PlatformInitLib/IntelTdx.c | 88 ++++++++++++++++++--- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 2 + 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index 797f880df035..acd114e38e46 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -7,6 +7,7 @@ =20 **/ =20 +#include #include #include #include @@ -25,6 +26,7 @@ #include =20 #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,15 @@ ProcessHobList ( EFI_STATUS Status; EFI_PEI_HOB_POINTERS Hob; EFI_PHYSICAL_ADDRESS PhysicalEnd; + UINT64 ResourceLength; + UINT64 AccumulateAcceptedMemory; =20 Status =3D EFI_SUCCESS; ASSERT (VmmHobList !=3D NULL); Hob.Raw =3D (UINT8 *)VmmHobList; =20 + AccumulateAcceptedMemory =3D 0; + // // Parse the HOB list until end of list or matching type is found. // @@ -393,7 +399,15 @@ 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 (Hob.ResourceDescriptor->PhysicalStart >=3D BASE_4GB) { + // + // In current stage, we only accept the memory under 4G + // + break; + } =20 Status =3D BspAcceptMemoryResourceRange ( Hob.ResourceDescriptor->PhysicalStart, @@ -402,6 +416,8 @@ ProcessHobList ( if (EFI_ERROR (Status)) { break; } + + AccumulateAcceptedMemory +=3D ResourceLength; } } =20 @@ -460,6 +476,60 @@ 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 + * @return VOID + */ +VOID +BuildResourceDescriptorHobForUnacceptedMemory ( + IN EFI_HOB_RESOURCE_DESCRIPTOR *Hob + ) +{ + EFI_PHYSICAL_ADDRESS PhysicalStart; + EFI_PHYSICAL_ADDRESS PhysicalEnd; + UINT64 ResourceLength; + EFI_RESOURCE_TYPE ResourceType; + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; + UINT64 MaxAcceptedMemoryAddress; + + ASSERT (Hob->ResourceType =3D=3D BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED); + + ResourceType =3D BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED; + ResourceAttribute =3D Hob->ResourceAttribute; + PhysicalStart =3D Hob->PhysicalStart; + ResourceLength =3D Hob->ResourceLength; + PhysicalEnd =3D PhysicalStart + ResourceLength; + + // + // In the first stage of lazy-accept, all the memory under 4G will be ac= cepted. + // The memory above 4G will not be accepted. + // + MaxAcceptedMemoryAddress =3D BASE_4GB; + + 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. + // + } + + 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 @@ -489,16 +559,16 @@ TransferTdxHobList ( ResourceAttribute =3D Hob.ResourceDescriptor->ResourceAttribute; =20 if (ResourceType =3D=3D BZ3937_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); + } 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 (#93677): https://edk2.groups.io/g/devel/message/93677 Mute This Topic: https://groups.io/mt/93645543/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 Thu May 9 14:39:40 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+93678+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+93678+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027370; cv=none; d=zohomail.com; s=zohoarc; b=Iiz7INe0WzCCNhMLGLpJFUwjaf8WaKfLlwgJ6hb9NXwBDpp02LwLh0OUjTpX4uNcjFn/AMB7SfiOWVhZaxDeou42gGu0JEsfvGFMXsyqzldQM/DWZb8P9g2uPVgipwKhryXWI0ej5EbYz/Aj7b9G3849gUXd8zCNAVH8pzstIvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027370; 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=qcWZ1L+LjSxIWOpwK2GcFV2NMCVKm2ym/cy9sjCDKyM=; b=lRqeTs7ZPeFCCDF4fJU2IX4nVHUxotVXeX0wKa5JEaj7439UISiuE/iWnyPRntORVWaDmSSByvjqHwR9Eps8ThuwZrAT7bBkWz8ykoZae9HiPTyjf/9GytnbZ2qENGRD1jgBE5GlE5Vljr5NXt56SnhCqPt39NTuJGYeT/UkiTY= 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+93678+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 1663027369941190.7187761256671; Mon, 12 Sep 2022 17:02:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tG6OYY1788612xoFi2FmDwiC; Mon, 12 Sep 2022 17:02:49 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:49 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294506" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294506" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:48 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320937" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:45 -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 V4 08/10] MdePkg: The prototype definition of EdkiiMemoryAcceptProtocol Date: Tue, 13 Sep 2022 08:02:12 +0800 Message-Id: <437cf3371272ec5412d3f0011f578c844a973101.1663026445.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: Spn5CIq7dmXVC0hyOJH1tYpwx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027369; bh=TMxqPkay5wNcDWlRup8gIuVyExUVcxVD/NYhBVaaeq0=; h=Cc:Date:From:Reply-To:Subject:To; b=H3NyusB508UjZipARByqddSpamKBQP7eP83VnYqouqnsb1Vx+C5a8zYVSzUveZVviNw 3TzBcXZwoDxqWZzUuP2Bb6fPAk4P4Rna/fG4yeIEZol4Nzn9ToMnjrbdVw/tfWbgK7zXp c80drVKdSUDYxiweNlW518ZuD0DIn+6pazo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027371208100035 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 (#93678): https://edk2.groups.io/g/devel/message/93678 Mute This Topic: https://groups.io/mt/93645546/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 Thu May 9 14:39:40 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+93679+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+93679+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027371; cv=none; d=zohomail.com; s=zohoarc; b=G+J30Eucr1EYmHkt8Cu3aS5cYNyZukMd66rUT4khn/CVtdjGHRjBEBLoNpbApqx8F3AF9Br8XNqzioM3k4CEOgaJKAD/Pxyans4CEfMjwgD5ZNgVXTblboTnZNdbOOhCTI5rSD2coRP46RSPA6vPw4bvFr1ImX7s/bo6dpsWZuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027371; 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=1Iq/ZN6zWhDs1SruM5uKwwIrUr2yO140kqC9t1Hn1jw=; b=SUT/pp5NcfJLCOSiAhm4Obq+cId66jxvFLkYo+d4qNAn5S15J1ZjNoSNGsjfht/L3DEo0qTheE8UbqwTn0oGGvv7r7p6fO+RsZ8OfhrbC76xs8DlFVGcptFdpJYS1dSRSaFM5XUvY0hMnzErwZoIAbAv+HNZ8FcbX0Fsq8VTK7Q= 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+93679+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 1663027371659695.0428701075886; Mon, 12 Sep 2022 17:02:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 32X4YY1788612xIMmAScFys9; Mon, 12 Sep 2022 17:02:51 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:50 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294531" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294531" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:50 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678320967" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:48 -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 V4 09/10] OvmfPkg: Realize EdkiiMemoryAcceptProtocol in TdxDxe Date: Tue, 13 Sep 2022 08:02:13 +0800 Message-Id: <16d5bbf15610d2d274e570649ea1c02aca50a930.1663026445.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: fhlYryD5yAucIfgSMPlzV08tx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027371; bh=tIdS5nXjTY5aUh+l0xT24WpOOJM+tffqo0hV0cSV71c=; h=Cc:Date:From:Reply-To:Subject:To; b=gwqUmbUpdnO0by+GY4CEuqM3IYd0s7XaWWXoS8nTE0I7xlzby4rcrh4tnlAIftcBHNg /2t1QE8hhSa3ea8rSksHvn0BC6MUpLA0LJr5dHCczHKYDK520MmzZP6J7kirAjZtaL/tu 6BkoGmeZw+qeAHm58PUCumKVwYuB0FshHW4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027373168100039 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 05cfb597dc64..30732f421bb6 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 @@ -279,6 +369,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 3ce8a5c32c98..9793562884c7 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.inf +++ b/OvmfPkg/TdxDxe/TdxDxe.inf @@ -52,6 +52,7 @@ gEfiAcpiTableProtocolGuid ## CONSUMES gEfiMpInitLibMpDepProtocolGuid gEfiMpInitLibUpDepProtocolGuid + gEdkiiMemoryAcceptProtocolGuid =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase @@ -69,3 +70,4 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved + 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 (#93679): https://edk2.groups.io/g/devel/message/93679 Mute This Topic: https://groups.io/mt/93645547/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 Thu May 9 14:39:40 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+93680+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+93680+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1663027373; cv=none; d=zohomail.com; s=zohoarc; b=CBtv0lVqV/HHXdWBcu7oByVgitmica3RASWnPJZvNEd2bDe+tJwXPwB4OlsV1/H0q1zKpnu19tr9KpkuZlto88OZlv2yGkE4PiH0Nl8R9/ofUvMYi/i3r56x4B6qCgWBiO2GL7cjGayiuJbqCpYFK0zQ3316hu1vOAvmvlTSi4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663027373; 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=K18vAoRv8O0P+Ywo8xT51LfjEss/y2u1/qo/vpR27d8=; b=XktkSoOjtxS0HbhtKDdWAdXKITqSr1JBPuJA3fXBaZIwW0Nsyb6X4rBeE9UUISAo81YQhtfcTEqpWF4frcmcJWh4L/2i0NXz0v8MSS6MkCtd0OQMPwybtlBuK1Naf/ViN6fq/dwm/Mev0SMuroctSxIiawjbJVjBFVKoMLcQDts= 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+93680+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 1663027373494223.57947689315654; Mon, 12 Sep 2022 17:02:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HNPPYY1788612xEUwxIvxR6K; Mon, 12 Sep 2022 17:02:53 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.3237.1663027349527091004 for ; Mon, 12 Sep 2022 17:02:52 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384294553" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="384294553" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:52 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="678321002" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.212.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:02:50 -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 V4 10/10] OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages Date: Tue, 13 Sep 2022 08:02:14 +0800 Message-Id: <94f2b47d407484585db944c085d4de087769cb03.1663026445.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: PhTZyR1NaZFbazwE0SBVCVsyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663027373; bh=dfGxbegyoAytzKc3X3gMhGaq9L4A2Hpd0QQZZTuYaFs=; h=Cc:Date:From:Reply-To:Subject:To; b=vTSm2e9VW0TeffZ6mdklzupVGzhCYjklACoBh8gEzXcC6PnpAoCWiM2gQDVRYA/o631 LaSXxhRxOANatkhkehg0VtF+AJqDziEvCamLYaSHsu56pNaylv2BjiQXYjTKExhHJXbcs eWpLqdukigy4HfZ3v8GXZhFPkBYrMWB/rCo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663027375160100043 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 (#93680): https://edk2.groups.io/g/devel/message/93680 Mute This Topic: https://groups.io/mt/93645548/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-