From nobody Sun May 12 12:32:10 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+90217+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+90217+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484423; cv=none; d=zohomail.com; s=zohoarc; b=Qo2DaAXObq+nM6kjx75NEgQgEXf4zwJNOqZajMvKkS2a0b9e0MIYsGQFh6px1+vqsf8EnyWT/3GCBiucajHdjgZIzrUdGeqF2H9wMmUn38B8i4LSTcWATstTzXMQbzzkml/sMmmsD9VLXDgPn0eq/8lzPP05RawFLosv/17CycA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484423; 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=xfC6T6eiosEvWMqSfoMJ1qWe4XbuT/Tmd+QO6hH++qE=; b=C8GQGSgDwpXm+Kzqws6goedcTWH4kyHTYwadORqGV86csqiqaSDsv+zSMx8+WvqyVrxWfZPRuFDZ19+3FJ+0cka4O+mBavmD9AyKfZRt0E9QIKgNnE2nwOVSVJpkeCWmSxdKjCo9EiX6yOVgfWs8ofZCLaD6SJfVJ3ixWhy+miQ= 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+90217+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 1654484423832681.2878830061768; Sun, 5 Jun 2022 20:00:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BCRfYY1788612xdexhNG9l8o; Sun, 05 Jun 2022 20:00:23 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.27717.1654484422708210907 for ; Sun, 05 Jun 2022 20:00:22 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458017" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458017" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:21 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285708" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 01/14] MdeModulePkg: Add PrePiHob.h Date: Mon, 6 Jun 2022 10:59:49 +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: yXrGuWabrs1NdRJKVlWuzzHcx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484423; bh=xbe6xnwXSypQZPcPg3fI22IFdne3zRQ89mwO+oIx318=; h=Cc:Date:From:Reply-To:Subject:To; b=Foz4UNGQjc6GN6C2AIDgHzowToas0dDvE1+rV/2U6BXwTHU9kgUKEJrRv6p0+zA5dDN sH3X1yktm0exlu5WQDnxAhMma590nGBf0442iUqLZanVLdGFH9bF+jDnDFJtPASO+cwZZ F2gDgEKJP5lnHYJWCMzI03zy2+TtJuz5lrc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484424829100001 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 --- 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 (#90217): https://edk2.groups.io/g/devel/message/90217 Mute This Topic: https://groups.io/mt/91570193/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 12:32:10 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+90218+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+90218+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484427; cv=none; d=zohomail.com; s=zohoarc; b=jTlqHvY2PuGAIkiDI+5Dj3qrayhEnTiHebXVFPNnssHaHKneKwnF34vFO7El4nZgiUxumEKBFZyLXtOhqzaAAe95N/K6oNy6wNVcKHz0Y6LQJL+zkeWV+DaVAoD3AfPQyLXd6xQnWav+BOZuWcv3o7nzFgzJbh+XdinBHEWD86c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484427; 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=SS8wVfMQDicqD8IobAPCG/XcrvyUEIH2RM0jKBht25s=; b=XcqbBR4LXmBhkHfgNKrQI0b5I6JuJIMsx1rGfjrD0NY2tevirsrc/tiVHa0JlcRMD+WjdtjQugpnkrw+/VphAM5XqWg0twqsoTTJxXnDbSYwZn8nV960+d9Rcjgb6yK1maEdpAdtSFcsua1kBf94NrC6+b/uct7dpydSnt0oAY0= 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+90218+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 1654484427244994.9722231480451; Sun, 5 Jun 2022 20:00:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FxVcYY1788612x7kU73oye6h; Sun, 05 Jun 2022 20:00:26 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:25 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458048" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458048" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:24 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285722" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 02/14] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Date: Mon, 6 Jun 2022 10:59:50 +0800 Message-Id: <13769f246c324cdd21c7e22e42fa3f92cbaa6a1d.1654420875.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: 9YtVdTcHy8eh48ogaYblOzEZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484426; bh=SbGt9gTsyEF4exqk+wsQcNjHKOv8NqVay/PJmuSkRSM=; h=Cc:Date:From:Reply-To:Subject:To; b=fsFqHpNquMqit/yP9MuO2slqOHmiDay4IBi9TCmZ9/FWSbuN8XXaBpeap0/HHtMoh2H OFa1HAImL6aV+oLp9KtpTgWF3Y0WNB9SWtEn2OX96dAoVV6NKOYmVZDtR2JTjGvIgMNPM FLWVjr+YKfGGgNKXsRY7swwl00Lqn/kvsEY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484428844100001 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 Signed-off-by: Min Xu Reviewed-by: Jiewen Yao --- 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 (#90218): https://edk2.groups.io/g/devel/message/90218 Mute This Topic: https://groups.io/mt/91570194/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 12:32:10 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+90219+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+90219+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484429; cv=none; d=zohomail.com; s=zohoarc; b=BLzoneHIdHdoaNi94J1NIkQ4ULVL/+1e9Jtap/CmD5JJY/f9WJ+Ki/yE/ldpXEuE9X2t2W0/POFhSiwD1NVwk4PpZJdmoty+ufNa/A8V3JN+kXdqoX05Gl46eSS0ppczw45HEyteJRTAR2fgG/JMSJL1I0Dn6o503yrQ2kIx+nI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484429; 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=+JKux+X9SXD5ABlpdvwD1OlMoCHSCOtjWQjAEXzRVFc=; b=a9/5LouM6EdQfzVvyA9t5Hwuh/t7ro+NFgbptpSI8exQQo1VKjw8LQRTMw/qZnK9+cCyZ/zHI2avkHTqSsiMWhAvXts5zYmeHeV2iyIyrYYpBMFlvtT25ZSEkE59HILcM1AZDoc2OBhlxaJ82xNS+DNy7JgP5SjpeoSssyqnv0A= 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+90219+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 1654484429429339.1189624062158; Sun, 5 Jun 2022 20:00:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VljFYY1788612xoJrRfULq7g; Sun, 05 Jun 2022 20:00:29 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:28 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458064" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458064" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:26 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285741" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 03/14] OvmfPkg: Use EFI_RESOURCE_MEMORY_UNACCEPTED which defined in MdeModulePkg Date: Mon, 6 Jun 2022 10:59:51 +0800 Message-Id: <4038743e19a7eba49e9aada8f64d2eae4acabf04.1654420875.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: SvqJ1qD0SQbcn7QT85X6uIzox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484429; bh=U2dpa3k4J8Xm/xmudDpP5e+0Bpaa5UFeIPVgwS2DAPA=; h=Cc:Date:From:Reply-To:Subject:To; b=PCAZMb/zSZBYnYLaMDstuaqcNKdVbv+Ctat7IA2gYryFAzHwUOMMAeaSeYmU68BJg5+ r7XQ73dRZOZJSLVHJhQKy/dZS7pXGhwlXcSqxHUnDtDw7UyDg+TCUEzGHNv/rCE1KVqel KsPCYbYpSXC96ChsNuhf7sz5ZSrqBj4CO9M= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484430871100005 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 --- 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 (#90219): https://edk2.groups.io/g/devel/message/90219 Mute This Topic: https://groups.io/mt/91570196/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 12:32:10 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+90220+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+90220+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484433; cv=none; d=zohomail.com; s=zohoarc; b=ar3NxpfWk4crQL1PK9NfxXPmLsJ/zXU5MKBOc/LHQV7Dv29b3dP9A3PmF4HQ9CaRiGv6VuJeBZBosYjpvPajm6dnv220f74sQAtmiDGh4ER6V1Ef18nD4wIkkhY8y7V4W3VkcCgwru3eOMoJ97TCbTVXDYfkhuPgJLI0eLfB0EM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484433; 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=+6+gX1dwpl9oQatcik/HGhSTtTtDutCe+qea0vRGDrc=; b=FS/6SNktWpZOwPih0SrB2qJ2bQ3DAsyVw2mjGQgqa5F/6FaUr+Ax6h0BXWyEHMJ269Nf0lXS7Fkzx7PKA1L0vyAYfUSdMQCnRrTaAPtBpQ6MVk/UkxGmSDwOuHVs/31CY3f0EH6ZvaTvOoxpSvS2KmdNodqxsOoP+kEkECN8MDs= 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+90220+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 1654484433124373.63306056199565; Sun, 5 Jun 2022 20:00:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tUxbYY1788612xzeCo20t6zr; Sun, 05 Jun 2022 20:00:32 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:32 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458080" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458080" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:31 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285763" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 04/14] MdePkg: Add UEFI Unaccepted memory definition Date: Mon, 6 Jun 2022 10:59:52 +0800 Message-Id: <88c1fe7b630b5fe65ef07ddc588f896f1346861f.1654420875.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: KdGaO7QX5vkGmm27XtwaGAmWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484432; bh=+iMzdsxGailXkP3t/wYtGn40nOBp1jocn5Boke4m8EI=; h=Cc:Date:From:Reply-To:Subject:To; b=Rhxu4O2UBdxobVD8+tR31mnFRPHbN3jSMrnX5d51dfJpvTs/QuhD0BfNMKNtXoHeo2t yFEN1RjO3nMFQx7m/T+CNOTuUb+GU7pIUvoUMR2KWeUXXhakkPFEGilVExwzAc78rirAa fz4UhpFGwJ2xEIWpPSNVvJdGdNEyvON4DQM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484434875100011 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 Signed-off-by: Min Xu Reviewed-by: Jiewen Yao --- MdePkg/Include/Pi/PiDxeCis.h | 5 +++++ MdePkg/Include/Uefi/UefiMultiPhase.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/MdePkg/Include/Pi/PiDxeCis.h b/MdePkg/Include/Pi/PiDxeCis.h index d0f2ed0e58df..67c99801b00d 100644 --- a/MdePkg/Include/Pi/PiDxeCis.h +++ b/MdePkg/Include/Pi/PiDxeCis.h @@ -56,6 +56,11 @@ typedef enum { /// system. If all memory has the same reliability, then this bit is not= used. /// EfiGcdMemoryTypeMoreReliable, + /// + /// A memory region that describes system memory that has not been accep= ted + /// by a corresponding call to the underlying isolation architecture. + /// + EfiGcdMemoryTypeUnaccepted, EfiGcdMemoryTypeMaximum } EFI_GCD_MEMORY_TYPE; =20 diff --git a/MdePkg/Include/Uefi/UefiMultiPhase.h b/MdePkg/Include/Uefi/Uef= iMultiPhase.h index 22bae43e36e8..29aabab5948e 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. + /// + EfiUnacceptedMemory, 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 (#90220): https://edk2.groups.io/g/devel/message/90220 Mute This Topic: https://groups.io/mt/91570197/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 12:32:10 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+90221+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+90221+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484434; cv=none; d=zohomail.com; s=zohoarc; b=N6BqR3azUp2CanVIT5CndtK/AJNw0teKJSyMQzUfO1OorhejZohyen4JgddVerGqfWxrCZjpBAVAxh2cTpQzzLsqKSaHDn7qgiLfNloHaRv/zceUexAe1sep5a1TwE55mh52J0Dmrh4BWDlHmkEa5z+qCXb4puVAkgAZ/lK8DFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484434; 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=stTv8e3u+7dLpnOOWSfz5Pe5w55ikGg8pWrfmvrwXPU=; b=W+OePEOlRLxch4HQiQiDmoajIAlbkt+kl0GSW1YVPelJ2RwHH+c3rlQvDl3sChP3WWwHfhmbRhjQmWT17O5XG4swaP9K0RECHbT+zB8Y+DQzGrRHhMDCJuVn1WRcs9NgsysvwJRL1pqA7iO8Nr/5+CBA9D/oBqvg5zVmX4iZrLU= 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+90221+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 1654484434157650.3836910377776; Sun, 5 Jun 2022 20:00:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id sPrWYY1788612xtVIhPj3rhy; Sun, 05 Jun 2022 20:00:33 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:33 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458098" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458098" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:32 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285778" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 05/14] MdeModulePkg: Update Dxe to handle unaccepted memory type Date: Mon, 6 Jun 2022 10:59:53 +0800 Message-Id: <48f0b328f456550ac532462b7034da53cfe99886.1654420875.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: 6XKC8VM0cJ5cfL3opz2bXqN0x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484433; bh=yLYm4wq8zs0zDnysKcmQV9rfS3vONBBc8FzvWc9r3uw=; h=Cc:Date:From:Reply-To:Subject:To; b=sb1Jjf+bFN07mnOauIhtFtZoA5YaTH2rFmwVv8JlsAnvOXlsDVJBNdrbJtYUIhFv6Dz 8At+9BmAJ1pLk7BwGkijCOF4b14IgEAWAT1cOpvFMvmGthETMkDutmOPKw9Eds/n18iEH 6V9NXfWK8m6LaAycv+3IVLZg+HqQLt4AQRo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484434877100012 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 --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 5 +++++ MdeModulePkg/Core/Dxe/Mem/Page.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index 3763467bdbc0..b82fe11cb0f3 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -8,6 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include #include "DxeMain.h" #include "Gcd.h" #include "Mem/HeapGuard.h" @@ -103,6 +104,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryT= ypeNames[] =3D { "MMIO ", // EfiGcdMemoryTypeMemoryMappedIo "PersisMem", // EfiGcdMemoryTypePersistent "MoreRelia", // EfiGcdMemoryTypeMoreReliable + "Unaccepte", // EfiGcdMemoryTypeUnaccepted "Unknown " // EfiGcdMemoryTypeMaximum }; =20 @@ -2600,6 +2602,9 @@ CoreInitializeGcdServices ( case EFI_RESOURCE_MEMORY_RESERVED: GcdMemoryType =3D EfiGcdMemoryTypeReserved; break; + case EFI_RESOURCE_MEMORY_UNACCEPTED: + GcdMemoryType =3D EfiGcdMemoryTypeUnaccepted; + 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 47d4c5d92e15..008efdf397e0 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -61,6 +61,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= nacceptedMemory { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiM= axMemoryType }; =20 @@ -83,6 +84,7 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMa= xMemoryType + 1] =3D { { EfiMemoryMappedIOPortSpace, 0 }, { EfiPalCode, 0 }, { EfiPersistentMemory, 0 }, + { EfiGcdMemoryTypeUnaccepted, 0 }, { EfiMaxMemoryType, 0 } }; // @@ -1947,6 +1949,32 @@ CoreGetMemoryMap ( MemoryMap =3D MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, S= ize); } =20 + if (MergeGcdMapEntry.GcdMemoryType =3D=3D EfiGcdMemoryTypeUnaccepted) { + // + // 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 EfiUnacceptedMemory; + + // + // 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 (#90221): https://edk2.groups.io/g/devel/message/90221 Mute This Topic: https://groups.io/mt/91570199/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 12:32:10 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+90222+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+90222+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484435; cv=none; d=zohomail.com; s=zohoarc; b=EIgdGn6q/fIM/YVNv4JL8j09j3yhC5tuoLnsnutTbQ0kf1GTAQd81h56Td5YxwDT6jUVlaUgnL1e4C6JAJ/rKh3OJab5lGwExoDz1aH5C8YfAaZ4QcRc0C+6XS7+HqZHhEqgyNSDlyNRkTa35fnZrBjpETcTykXl2GxkZrp1Pho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484435; 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=u/u0QUxDznE28uSTT9Ge9QiR1g33d9Du38pZTz7uW9k=; b=JZIl0McehxfH3hk0AKAGVMV/+5ogI6QmqUaJ6oRoTwKRrepVoilQcf77oSo2MFVXjFV9lfn0nXUauq9qOMDo2nz0xDJbZbJLYRVpHletjS+Ev9tBWcEX1P9Qcz8sNb76D96XG9F9w48JHf6TPnEh5rWfPovU1FnlsHP8Iekhzy8= 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+90222+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 1654484435821562.3772888772107; Sun, 5 Jun 2022 20:00:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id g9wdYY1788612xtjB8ikWu3A; Sun, 05 Jun 2022 20:00:35 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:35 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458108" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458108" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:34 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285786" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:32 -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 06/14] ShellPkg: Update shell command memmap to show unaccepted memory Date: Mon, 6 Jun 2022 10:59:54 +0800 Message-Id: <45dd9950d91333c703d31f96a9058f7e968e5a93.1654420876.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: 91sKrdDjqITQkVPSiFYb8MeOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484435; bh=2/ARGMfFw/HULQr5/klc//qibYC2K23udOT+4LHA39k=; h=Cc:Date:From:Reply-To:Subject:To; b=qlufQp1Wk470yx1DWv3cdm8Go7yJcLmUVLorzNs/TcbV5wFOnBm+5BUmXNPMm5wuSxx gVsbqv09r/W3k1/ZMuTGVTMvBjgPyw3jotbgGUZG3qSJCFH9D8hmvyFDAdWsMn1TbLC8o AfAS0JObja3b3JSfeY0ZP/PXobkbSsxVIe8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484436880100017 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 Signed-off-by: Min Xu Reviewed-by: Ray Ni --- ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPk= g/Library/UefiShellDebug1CommandsLib/MemMap.c index 72f3c58b0970..41994ae709ce 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 NameEfiUnacceptedMemory[] =3D L"Unaccepted"; =20 // // Need short names for some memory types @@ -303,6 +304,11 @@ ShellCommandRunMemMap ( TotalPages +=3D Walker->NumberOfPages; PalCodePages +=3D Walker->NumberOfPages; break; + case EfiUnacceptedMemory: + ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING= _TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), g= ShellDebug1HiiHandle, NameEfiUnacceptedMemory, Walker->PhysicalStart, Walke= r->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->Nu= mberOfPages, Walker->Attribute); + TotalPages +=3D Walker->NumberOfPages; + PalCodePages +=3D Walker->NumberOfPages; + break; default: // // Shell Spec defines the SFO format. --=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 (#90222): https://edk2.groups.io/g/devel/message/90222 Mute This Topic: https://groups.io/mt/91570201/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 12:32:10 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+90223+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+90223+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484438; cv=none; d=zohomail.com; s=zohoarc; b=dDwlF44r+rK20EJBCmbne8GXLRZ1fUB7vcCI55xb0NQAoDp7D8Cx1djOOUf00YL7AaX6oddhZvxIFEJ6BgGqvTD6/j5tFG9xR/Iq5ysj7YXTdEF1Lxx6XMqnnbhZV981rLHUgTPQ3G83NVW4qmf3dfEIAfokcIFvP2H0VjeyWiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484438; 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=LQSFxPgihhWLLdyKefJQrZWI2wsxjPGp7f2/ZAVXjc0=; b=J4S9Uww5qI/klFuPm2YrhASimfIykj/j36IzXJLLbWABgqWYYcT7hCwijrnACdQWT1QmRS93DxMEXbgzo1TS2qxI8Ow0g2Dqz1ocYQ2eO/NXSQlu0v09uTCwtxel58F0OgoepWMuWaAHfTFh4P847DjqG1TURfqGUb7W+GnFE+M= 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+90223+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 165448443808025.10505788081889; Sun, 5 Jun 2022 20:00:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id W4oKYY1788612xBvNPhF2JZ8; Sun, 05 Jun 2022 20:00:37 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:37 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458115" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458115" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:36 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285792" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page. Date: Mon, 6 Jun 2022 10:59:55 +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: 3AG9u4VJrYKIk1srlFvzJheGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484437; bh=LrwGNcdENsTvxkM7xx/w2yPqJxaxP+6jVhK3DuK5G+w=; h=Cc:Date:From:Reply-To:Subject:To; b=F6pcnLamfLqA8Iao6/yXcRJJimPKArDutOkTPoa0yuv3QggZNziQtta9NLpO21RYJM5 92qkHDHgl45qPVwV+gBmhZugFnbr5PtUz6zu6rPO/m/W3OzLTxFJlQjWuxz21r41Qmluz T0VeQX8Ij4zcDLUnlP6gS2I5AaiqqzMcmj0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484438886100021 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 Lazy accept page can be controlled in build time like below: -D LAZY_ACCEPT_PARTIAL_MEM=3D512 The unit is MB. If it is 0 then it means Lazy-accept is turned off. Lazy-accept is turned off by default in OvmfPkgX64. Lazy-accept is turned on with 512MB by default in IntelTdxX64. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 8 ++++++++ OvmfPkg/OvmfPkg.dec | 4 ++++ OvmfPkg/OvmfPkgX64.dsc | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX6= 4.dsc index 43ab8bd089d9..c6195ab9c9d7 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -62,6 +62,11 @@ # DEFINE UP_CPU_DXE_GUID =3D 6490f1c5-ebcc-4665-8892-0075b9bb49b7 =20 + # + # Define the size of lazy accepted memory. The unit is MB. + # + DEFINE LAZY_ACCEPT_PARTIAL_MEM =3D 512 + [BuildOptions] GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG INTEL:RELEASE_*_*_CC_FLAGS =3D /D MDEPKG_NDEBUG @@ -450,6 +455,9 @@ # Point to the MdeModulePkg/Application/UiApp/UiApp.inf gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 } =20 + # The partial memory size in Lazy accept + gUefiOvmfPkgTokenSpaceGuid.PcdLazyAcceptPartialMemorySize|$(LAZY_ACCEPT_= PARTIAL_MEM) + ##########################################################################= ###### # # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Pla= tform diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 5fe487f82d1a..7444765fe760 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -399,6 +399,10 @@ ## The Tdx accept page size. 0x1000(4k),0x200000(2M) gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize|0x200000|UINT32|0x65 =20 + ## The partial memory size in Lazy accept. Its unit is MB. + ## The default value is 0 which means lazy accept is turned off. + gUefiOvmfPkgTokenSpaceGuid.PcdLazyAcceptPartialMemorySize|0|UINT64|0x68 + [PcdsDynamic, PcdsDynamicEx] gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 1448f925b782..398981b6dad8 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -78,6 +78,12 @@ DEFINE UP_CPU_PEI_GUID =3D 280251c4-1d09-4035-9062-839acb5f18c1 DEFINE UP_CPU_DXE_GUID =3D 6490f1c5-ebcc-4665-8892-0075b9bb49b7 =20 + # + # Define the size of lazy accepted memory. The unit is MB. + # In OvmfPkgX64, the lazy accept page is disabled by default. + # + DEFINE LAZY_ACCEPT_PARTIAL_MEM =3D 0 + [BuildOptions] GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG INTEL:RELEASE_*_*_CC_FLAGS =3D /D MDEPKG_NDEBUG @@ -601,6 +607,9 @@ # Point to the MdeModulePkg/Application/UiApp/UiApp.inf gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 } =20 + # The partial memory size in Lazy accept + gUefiOvmfPkgTokenSpaceGuid.PcdLazyAcceptPartialMemorySize|$(LAZY_ACCEPT_= PARTIAL_MEM) + ##########################################################################= ###### # # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Pla= tform --=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 (#90223): https://edk2.groups.io/g/devel/message/90223 Mute This Topic: https://groups.io/mt/91570202/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 12:32:10 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+90224+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+90224+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484440; cv=none; d=zohomail.com; s=zohoarc; b=LljuPkjNODJGvhrZaAVNNgWl5SnqQi37FIYcsUoy4Ug2W0dRnUab+OxKElsYvDStdrFyl2Pk+wP0hjjzC1peJH0qP2mYm8kRodL6EYsRpx3hh/JQIJqMQatv0RyHh9vQJa1S1K23nGPEe+TtBUup7WHx6Q/i5LGtJndsogU6uxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484440; 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=8bz+J13VXB3KWvY5Y7WWUXCLXBxXXj069uW6ifG43SI=; b=dkLIrKiHwx2CLSXVkYbDM21uxl98Ivu380DYnd8AtEu2I5uCMk7AhvDUvtvCOtCXoJb09xUQn9g0YLVfg1ftpaqz916Mv8tV8EY2Uv3rWF+sop3v6J/q9qVHC7PW8+Ov3o3/+5ZCYw9L7PJ/rI2pfSM5FTYqE2FjmV98e9V0AyQ= 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+90224+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 1654484440276875.2713014169025; Sun, 5 Jun 2022 20:00:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZH2aYY1788612xgXUoMuWPyl; Sun, 05 Jun 2022 20:00:39 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:39 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458123" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458123" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:39 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285799" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 08/14] OvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase Date: Mon, 6 Jun 2022 10:59:56 +0800 Message-Id: <63e9cfb295ce7a39cce3ae19c80f9bd48a9e4cf7.1654420876.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: mDanZ0pPNIeLWtHSFuVYKjVAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484439; bh=M4Jg3LtscTi4/78ueParkDFKqP1qopF/VQ9w1QZv6DM=; h=Cc:Date:From:Reply-To:Subject:To; b=Q07d+s5awlSTiLwqQsScVp92GuHGlHf9wB8pEOm7jlkdT61f63fgrzk8s+u9CH0gYyw hyw1XuD4diQywA4rBqfj+WiM7svksQRiEnjjQ5VY0ETvfLob/GMsTU2x++C9pL2negZfi sodxGKM6gCQVTjt9lme3ESTFYBSK0SZrxQ0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484440918100025 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 It is an typo error that HobList pointer should be stored at PcdOvmfWorkAreaBase, not PcdSevEsWorkAreaBase. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- .../IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c | 4 ++-- .../PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer= .c b/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c index 1b41a3983c99..ecd271c0bdff 100644 --- a/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c +++ b/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c @@ -27,7 +27,7 @@ PrePeiGetHobList ( { TDX_WORK_AREA *TdxWorkArea; =20 - TdxWorkArea =3D (TDX_WORK_AREA *)(UINTN)FixedPcdGet32 (PcdSevEsWorkAreaB= ase); + TdxWorkArea =3D (TDX_WORK_AREA *)(UINTN)FixedPcdGet32 (PcdOvmfWorkAreaBa= se); ASSERT (TdxWorkArea !=3D NULL); ASSERT (TdxWorkArea->SecTdxWorkArea.HobList !=3D 0); =20 @@ -48,7 +48,7 @@ PrePeiSetHobList ( { TDX_WORK_AREA *TdxWorkArea; =20 - TdxWorkArea =3D (TDX_WORK_AREA *)(UINTN)FixedPcdGet32 (PcdSevEsWorkAreaB= ase); + TdxWorkArea =3D (TDX_WORK_AREA *)(UINTN)FixedPcdGet32 (PcdOvmfWorkAreaBa= se); ASSERT (TdxWorkArea !=3D NULL); =20 TdxWorkArea->SecTdxWorkArea.HobList =3D (UINTN)HobList; diff --git a/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer= LibTdx.inf b/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer= LibTdx.inf index 2667f841cea2..fe7ee23fdc8a 100644 --- a/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.= inf +++ b/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.= inf @@ -23,7 +23,7 @@ UefiCpuPkg/UefiCpuPkg.dec =20 [Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase =20 [LibraryClasses] PcdLib --=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 (#90224): https://edk2.groups.io/g/devel/message/90224 Mute This Topic: https://groups.io/mt/91570203/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 12:32:10 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+90225+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+90225+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484443; cv=none; d=zohomail.com; s=zohoarc; b=BvT2ngLfR6AaaL3Y9tQvam2iYPob75YpU0iAJUr9cRXAISnfPdLOAbRqGuu3lpIlrJEm+gMcbS6K06eTeQ6WCus+L19xBEm1lkOQawAdjinox4sjx2iiCKqC/Pj9C/E4xVF+R1jdQb5MISQf6LNDoVIh6K5tckqTTMlYVPL5IV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484443; 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=rDf77a6naWj9VRybF1zWRXbNw28aa0SOHjJ9oz+nHtk=; b=VLqrStvSrlnmOUh6+yFyJ2YCrSMlRHjgTzUThjR86I000AjvR/BY4hOpFl12+zW49XCQR8kvpAVZZwl5DwTYyvcbuUybNIp71CdH3Z4OPNPYPehKtjGGZliwtToRHJZRrwxHnUSWvS7KzVbiGCVZ2ejzvx+20YDV1Bqx0uwCtck= 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+90225+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 165448444358464.94231812932264; Sun, 5 Jun 2022 20:00:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KD2YYY1788612xrxf5EGGdQG; Sun, 05 Jun 2022 20:00:42 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:42 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458127" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458127" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:41 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285806" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:39 -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 09/14] OvmfPkg: Add MaxAcceptedMemoryAddress in TDX work area Date: Mon, 6 Jun 2022 10:59:57 +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: za8jeuxpC8gS0sw9nJ9GGNgYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484442; bh=E3+H2kifE9x9lcx3R5v9VsWokZQ9VLYZKmz5HWOPAB0=; h=Cc:Date:From:Reply-To:Subject:To; b=CVf2s4TgHF4+AlG1IU3NFTzUL1Jc9TxqcT8wjR6XA1DreWNYt6U7uqC8Lrs9W1h7/lJ LnGbZuS3SxcsbY0lfXrf9+qyqoda3IoX+SL/o5JmaKQiF1oufLSgxm98M7cwzpkkOrbna qTnnQFhEt7Ky7tMcDN0bfBeFgNGCOX+RQ6Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484444920100031 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 (#90225): https://edk2.groups.io/g/devel/message/90225 Mute This Topic: https://groups.io/mt/91570205/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 12:32:10 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+90226+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+90226+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484444; cv=none; d=zohomail.com; s=zohoarc; b=n+wT3aBu1NoHf2Vxktibh+1cj+HCdXjaXGSetXna8QjOdG68PqTYlZtglHs9L+ZMdZ1HU57+J90koshvLEts78lTmic0iB1RQ2oB8BMxncMOYV/xipSsrnU+VcTwhTzEJZp9wfLq2juJZ3KjRC72Wa4nGG5Avse6qcRuOtVu0/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484444; 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=SmfKG15T4mY9Ix8O32Qzuh1/Cqe49OBGnJsSMrjCvns=; b=CNN9xmnju0Lfc1cpkehNZhUVtDtjl+wwzFqaQB63JoSFPYW8mNOFtzsYpLesK9O2AnTmlzOa2NDOOy0wIUyD1KCq7282Ar5ySnfyrLAqP1+2W7N3KiQ3bhR0WSKb6fUcw9nYc65AY5mf12JssdB2ckIeNIK5bZD6RNKGJR066q0= 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+90226+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 1654484444534669.5946315167915; Sun, 5 Jun 2022 20:00:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RPh0YY1788612x1FvquN10N3; Sun, 05 Jun 2022 20:00:44 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.27749.1654484424914450989 for ; Sun, 05 Jun 2022 20:00:43 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458143" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458143" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:43 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285811" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 10/14] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Date: Mon, 6 Jun 2022 10:59:58 +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: WUUFOfXKe95vbhQC2Ca4gO1Ax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484444; bh=47oLgXfNxiwpxM48JppqOWd+OyE1WLNdOsnGzbZg7WU=; h=Cc:Date:From:Reply-To:Subject:To; b=qi/+CnxZ5iRDsH97dBK2TSlYrxazcIo2fFxbLpUzZlQh0WNEcyt2vn6BRuKUlTzS4nX JdYwgzAMSLV4IYV6/0uZopKNmDoYyixNPmnPQQH/o2t49tTm9+r3PIbkK1rkht/GzDRfT F1W+u2IxEmGZ++oOv+NyL4sf6hzOlB1JkPc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484444968100032 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 the accumulated accepted memory is smaller than the LazyAcceptMemSize. If a EFI_RESOURCE_MEMORY_UNACCEPTED hob is cross the LazyAcceptMemSize, it will be split into 2 parts and only the left one is accepted. The max accepted memory address is stored in Tdx workarea which will be used in TransferTdxHobList. 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. 3. PlatformAdjustSystemMemorySizeBelow4gbForLazyAccep The system memory size below 4GB may be larger than the accepted memory. This function is used to handle this situation. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Include/Library/PlatformInitLib.h | 6 + OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 143 ++++++++++++++++-- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 27 ++++ .../PlatformInitLib/PlatformInitLib.inf | 1 + OvmfPkg/PlatformPei/MemDetect.c | 5 + 5 files changed, 171 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h b/OvmfPkg/Include/Li= brary/PlatformInitLib.h index 2987a367cc9c..187efcf34e14 100644 --- a/OvmfPkg/Include/Library/PlatformInitLib.h +++ b/OvmfPkg/Include/Library/PlatformInitLib.h @@ -144,6 +144,12 @@ PlatformGetSystemMemorySizeBelow4gb ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ); =20 +UINT32 +EFIAPI +PlatformAdjustSystemMemorySizeBelow4gbForLazyAccept ( + IN UINT32 LowerMemorySize + ); + /** Initialize the PhysMemAddressWidth field in PlatformInfoHob based on gue= st RAM size. **/ diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c b/OvmfPkg/Library/P= latformInitLib/IntelTdx.c index 396b14d919d2..7be466ee34d1 100644 --- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c +++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c @@ -24,7 +24,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,15 +376,33 @@ ProcessHobList ( EFI_STATUS Status; EFI_PEI_HOB_POINTERS Hob; EFI_PHYSICAL_ADDRESS PhysicalEnd; + TDX_WORK_AREA *WorkArea; + UINT64 ResourceLength; + UINT64 AccumulateAcceptedMemory; + UINT64 LazyAcceptMemSize; + UINT64 MaxAcceptedMemoryAddress; =20 Status =3D EFI_SUCCESS; ASSERT (VmmHobList !=3D NULL); Hob.Raw =3D (UINT8 *)VmmHobList; =20 + AccumulateAcceptedMemory =3D 0; + MaxAcceptedMemoryAddress =3D 0; + LazyAcceptMemSize =3D FixedPcdGet64 (PcdLazyAcceptPartialMemorySi= ze); + // + // If specified accept size is zero, accept all of the memory. + // Else transfer the size in megabyte to the number in byte. + // + if (LazyAcceptMemSize =3D=3D 0) { + LazyAcceptMemSize =3D MAX_UINT64; + } else { + LazyAcceptMemSize <<=3D MEGABYTE_SHIFT; + } + // // Parse the HOB list until end of list or matching type is found. // - while (!END_OF_HOB_LIST (Hob)) { + while (!END_OF_HOB_LIST (Hob) && AccumulateAcceptedMemory < LazyAcceptMe= mSize) { if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { DEBUG ((DEBUG_INFO, "\nResourceType: 0x%x\n", Hob.ResourceDescriptor= ->ResourceType)); =20 @@ -393,7 +412,17 @@ 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 (AccumulateAcceptedMemory + ResourceLength > LazyAcceptMemSize)= { + // + // If the memory can't be accepted completely, accept the part o= f it to meet the + // PcdLazyAcceptPartialMemorySize. + // + ResourceLength =3D LazyAcceptMemSize - AccumulateAcceptedMemory; + PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Resou= rceLength; + } =20 Status =3D BspAcceptMemoryResourceRange ( Hob.ResourceDescriptor->PhysicalStart, @@ -402,12 +431,26 @@ 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 needed in TransferTdxHobList and ContructFwHobLis= t(at PeilessStartupLib). + // But in SEC phase we cannot use a global variable to pass this value. = So it has + // to be 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 +503,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 +588,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 +610,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 c28d7601f87e..2bb346f31d44 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -41,6 +41,8 @@ Module Name: =20 #include =20 +#define MEGABYTE_SHIFT 20 + VOID EFIAPI PlatformQemuUc32BaseInitialization ( @@ -288,6 +290,31 @@ GetHighestSystemMemoryAddressFromPvhMemmap ( return HighestAddress; } =20 +UINT32 +EFIAPI +PlatformAdjustSystemMemorySizeBelow4gbForLazyAccept ( + IN UINT32 LowerMemorySize + ) +{ + #ifdef MDE_CPU_X64 + UINT64 LazyAcceptMemSize; + + LazyAcceptMemSize =3D FixedPcdGet64 (PcdLazyAcceptPartialMemorySize); + // + // If specified accept size is not zero, + // transfer the size in megabyte to the number in byte. + // + if (LazyAcceptMemSize !=3D 0) { + LazyAcceptMemSize <<=3D MEGABYTE_SHIFT; + if (LazyAcceptMemSize < LowerMemorySize) { + LowerMemorySize =3D (UINT32)(UINTN)LazyAcceptMemSize; + } + } + + #endif + return LowerMemorySize; +} + UINT32 EFIAPI PlatformGetSystemMemorySizeBelow4gb ( diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/= Library/PlatformInitLib/PlatformInitLib.inf index d2a0bec43452..affb2fb90408 100644 --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf @@ -95,6 +95,7 @@ gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize =20 gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize + gUefiOvmfPkgTokenSpaceGuid.PcdLazyAcceptPartialMemorySize =20 [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 2e47b1322990..acc1d7f63ee8 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -279,6 +279,11 @@ PublishPeiMemory ( LowerMemorySize -=3D mPlatformInfoHob.Q35TsegMbytes * SIZE_1MB; } =20 + // + // Adjustment for Lazy accept because it may accept part of the memory. + // + LowerMemorySize =3D PlatformAdjustSystemMemorySizeBelow4gbForLazyAccept = (LowerMemorySize); + S3AcpiReservedMemoryBase =3D 0; S3AcpiReservedMemorySize =3D 0; =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 (#90226): https://edk2.groups.io/g/devel/message/90226 Mute This Topic: https://groups.io/mt/91570207/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 12:32:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90227+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90227+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484469; cv=none; d=zohomail.com; s=zohoarc; b=PWkR7r9zUEoFzCAFK8ms0CdOrTcOZyi4rURfVmSkmndbivig53NFKk60Z7gAPI34zvmX4llp1wEDYRRLj28V9L57fMr8tsi+hEjarjoYLRmtKK7yMul4XwiEXgSv4xwOVYkGJotEOAM4PrIFzOixjw8H9nR/1akUhzkXGKWYLFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484469; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=crwMSYOQ9X1q0cxMmfoSUaZ+gz76SNrrAc3iYN9TPdQ=; b=jmhCrGUwgVZlyV+oo8y5LJIY7cDjBKWeIFE9ROfcTML3bunhQIpldUwlBEV1/X6sq0djDf6oULx1xTpfVMRmvCUnkXtcmezumekGu2kCY5FvqquH//BhPqA6WTz4AnoydzyVbUxAvE2eE4JyF+xKv2Ouy6HYoSUbvKasWpsAKI8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90227+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1654484469344659.5941194772568; Sun, 5 Jun 2022 20:01:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OxwIYY1788612xZdWHNO2pms; Sun, 05 Jun 2022 20:01:09 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.27883.1654484468358335759 for ; Sun, 05 Jun 2022 20:01:08 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458157" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458157" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:45 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285828" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:43 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [edk2-devel] [PATCH 11/14] OvmfPkg: Update ConstructFwHobList for lazy accept Date: Mon, 6 Jun 2022 10:59:59 +0800 Message-Id: <2df2ea9db98907b59b32e8555cf96eb42d6d9134.1654420876.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: 3NMgIBvGiUhf2Drdh0Nz3z5Qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484469; bh=iEYqWqmXhq0WAE/grEn0w8Mg2k5DCXSCqiFCWOdtS+M=; h=Cc:Date:From:Reply-To:Subject:To; b=SuZ8SoJfA4tzFQf21iGqQr18FNGDSR2WXFmeo5WUNz3Dp+3oBfWQz2dM3pK8UBXGhu2 RVJnZM2qHE4OjeVrCUcyNIvifdVj8QUhxmmmt5CobnB42OW1blfB7MSyG9BE53tp74q2S ljMgIXt6+Q6PgNcwXF32sbdjsh9X/BlL1ZI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484471138100003 Content-Type: text/plain; charset="utf-8" From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 In TDVF the hob list is constructed at the memory region which is the largest one below 4GB. After lazy accept is introduced, the MaxAcceptedMemoryAddress (which is tha max accpeted memory address in lazy accept) should be considered. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 23 ++++++++++++++++++- .../PeilessStartupLib/PeilessStartupLib.inf | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/Peil= essStartupLib/Hob.c index a9b92b5fbaba..884490af68fd 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "PeilessStartupInternal.h" =20 /** @@ -74,10 +75,13 @@ ConstructFwHobList ( ) { EFI_PEI_HOB_POINTERS Hob; + EFI_PHYSICAL_ADDRESS PhysicalStart; EFI_PHYSICAL_ADDRESS PhysicalEnd; UINT64 ResourceLength; EFI_PHYSICAL_ADDRESS LowMemoryStart; UINT64 LowMemoryLength; + UINT64 MaxAcceptedMemoryAddress; + TDX_WORK_AREA *WorkArea; =20 ASSERT (VmmHobList !=3D NULL); =20 @@ -86,14 +90,31 @@ ConstructFwHobList ( LowMemoryLength =3D 0; LowMemoryStart =3D 0; =20 + WorkArea =3D (TDX_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); + ASSERT (WorkArea !=3D NULL); + ASSERT (WorkArea->Header.GuestType =3D=3D CcGuestTypeIntelTdx); + MaxAcceptedMemoryAddress =3D WorkArea->SecTdxWorkArea.MaxAcceptedMemoryA= ddress; + if (MaxAcceptedMemoryAddress =3D=3D 0) { + MaxAcceptedMemoryAddress =3D MAX_UINT64; + } + // // Parse the HOB list until end of list or matching type is found. // while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - if (Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY_= UNACCEPTED) { + if ((Hob.ResourceDescriptor->ResourceType =3D=3D EFI_RESOURCE_MEMORY= _UNACCEPTED) && (Hob.ResourceDescriptor->PhysicalStart < MaxAcceptedMemoryA= ddress)) { PhysicalEnd =3D Hob.ResourceDescriptor->PhysicalStart + Hob.Res= ourceDescriptor->ResourceLength; ResourceLength =3D Hob.ResourceDescriptor->ResourceLength; + PhysicalStart =3D Hob.ResourceDescriptor->PhysicalStart; + + if ((PhysicalEnd >=3D MaxAcceptedMemoryAddress) && (PhysicalStart = < MaxAcceptedMemoryAddress)) { + // + // This memory region is split into 2 parts. The left part is ac= cepted. + // + PhysicalEnd =3D MaxAcceptedMemoryAddress; + ResourceLength =3D PhysicalEnd - PhysicalStart; + } =20 if (PhysicalEnd <=3D BASE_4GB) { if (ResourceLength > LowMemoryLength) { diff --git a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf b/Ovmf= Pkg/Library/PeilessStartupLib/PeilessStartupLib.inf index c5d291f02bcd..2ca49324d8f9 100644 --- a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf +++ b/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf @@ -88,3 +88,4 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ##= CONSUMES gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90227): https://edk2.groups.io/g/devel/message/90227 Mute This Topic: https://groups.io/mt/91570210/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 12:32:10 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+90228+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+90228+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484471; cv=none; d=zohomail.com; s=zohoarc; b=bruH12K/RR0g3fZ5AvcClTPgqiatUcUgPmXM1rEwyJSb9sF3F7A51UubfJ3OsZf9NpEPebtrFud+SX09lhe0Ubcv3BwL9k/IA0RH7f3mW/vQlk4mHObxiuiCQC4Hr1zvxxUF06teQcEy7f3T1fYgWRtwoewKKWuZOHyFAOTL+S4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484471; 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=GZ9r0Yi6R0M6xJs9QMSExQqKHkachTahRVeXzWcK6UE=; b=Xq2bYAkEf0RMv3MJl0J+AJOS6e8WjnbNiGbJ9T9+UJUSj616U3JE5hTjArf2yECVz/f1ci7FTBNXPwzvND7sShAxsAd7a7yENmOJp3U6KreaCv9uVMJ/O+jFA+gYjzjJ3HhUTptn89ebnjkjt/A1mH85sWEl8gpAzpsLLCbWmBY= 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+90228+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 165448447109634.00752334264598; Sun, 5 Jun 2022 20:01:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zRiwYY1788612xeeLUEVu9VJ; Sun, 05 Jun 2022 20:01:10 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.27883.1654484468358335759 for ; Sun, 05 Jun 2022 20:01:09 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458168" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458168" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:48 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285852" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 12/14] MdePkg: The prototype definition of EfiMemoryAcceptProtocol Date: Mon, 6 Jun 2022 11:00:00 +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: YMWTdR7dmH4CdRCvs7aJxpwOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484470; bh=4mS9Q7V9/EB1sTlTBJtUJx1kIpfuGR5487ReYt4dBZU=; h=Cc:Date:From:Reply-To:Subject:To; b=sV1v8BKDQ55ZtBYQLfDUUh0pkeVwMehryBJzdCb0s2F9RTvppd8/z4EJSBsozyz4Ku+ mcM3ih1L/iS19IwWvGF8qp+om7qBWWRqNdRK4sSb9MWoeat827ga30BQ+tntVIJkNGaQC JDTCMWKSxGnVue1RZWQC5VS9Q2azXp3Aa2E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484473056100007 Content-Type: text/plain; charset="utf-8" From: Jiaqi Gao RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 EfiMemoryAcceptProtocol is defined in MdePkg, the method AcceptMemory() can be called when memory needs to be accepted. EfiMemoryAcceptProtocol 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 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..27b43ce81126 --- /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 EFI_MEMORY_ACCEPT_PROTOCOL_GUID \ + { 0x38c74800, 0x5590, 0x4db4, { 0xa0, 0xf3, 0x67, 0x5d, 0x9b, 0x8e, 0x80= , 0x26 } }; + +typedef struct _EFI_MEMORY_ACCEPT_PROTOCOL EFI_MEMORY_ACCEPT_PROTOCOL; + +/** + @param This A pointer to a MEMORY_ACCEPT_PROTOCOL. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_ACCEPT_MEMORY)( + IN EFI_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size + ); + +/// +/// The MEMORY_ACCEPT_PROTOCOL provides the ability for memory services +/// to accept memory. +/// +struct _EFI_MEMORY_ACCEPT_PROTOCOL { + EFI_ACCEPT_MEMORY AcceptMemory; +}; + +extern EFI_GUID gEfiMemoryAcceptProtocolGuid; + +#endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f1ebf9e251c1..de3c56758b95 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 + gEfiMemoryAcceptProtocolGuid =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 (#90228): https://edk2.groups.io/g/devel/message/90228 Mute This Topic: https://groups.io/mt/91570211/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 12:32:10 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+90230+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+90230+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484473; cv=none; d=zohomail.com; s=zohoarc; b=EO2p1QT1iuGQ3n+KQzOWLzSCvaX7j5SWuz9C0fO0/DIAVpYfmqi9BeHy2hta/qBTYQ5oEwuE0OKCvLpzxKASIer0I3iyr78uOq2HbK8YofKIFPUA9yOVh3V6t61dYR6N/goPcrD1+VKali65ul6u6gMVqrEhvgIsBqGXzWhevC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484473; 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=GlhkWgw3Yx52gpYnIgn+YYNFcv0Qmj83oL/vP72iTCw=; b=JrKq8ohorZQ6pgPk0YqYPRDD2Lbo93rl5ACoGOVVNoCw6C5LA3Y+QjVH68JXmbp2gyeLL6Z1qlNlxO9mMFUsSVPAQwfiS5BnN/GaFkt8OKMJ8GI55HTDFVLc3tP6f9Gk7dPI+Rt83LLrTL1xA3kffWpcrr7ygvHnk1GSUjP0h1U= 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+90230+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 1654484473965282.6881002426511; Sun, 5 Jun 2022 20:01:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0dBiYY1788612xSCiSrOMQbH; Sun, 05 Jun 2022 20:01:13 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.27883.1654484468358335759 for ; Sun, 05 Jun 2022 20:01:13 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458177" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458177" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:50 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285859" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00: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 13/14] OvmfPkg: Realize EfiMemoryAcceptProtocol in TdxDxe Date: Mon, 6 Jun 2022 11:00:01 +0800 Message-Id: <1a17ee9c780bbe6a8ea53f4d69e497584b1af896.1654420876.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: FrstZQse6KQqt65MJgRYmBwFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484473; bh=hK1NBsvnFeb5VjA439nJG8xMdmMeQCQw2sXHDjnlL6M=; h=Cc:Date:From:Reply-To:Subject:To; b=gNOvrIWcfcjUJ3HjDjSmoPTd/zwN2E6JLnarN7J9zEYNG+i2/nfD1y2asztAYfuAsM7 WSOn763ldJyE5EHdj0T4MSP0yLFj4ImReE9cYqaBsMIJf1ylxRpxrhv992BREvPDj8jnI ORbjTxjYLDgZHZuMcW7uIeULV4uCTA+5BEI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484475057100011 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. EfiMemoryAcceptProtocol 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 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..7cc9bf5f8c98 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 EFI_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; +} + +EFI_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, + &gEfiMemoryAcceptProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMemoryAcceptProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install EfiMemoryAcceptProtocol 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..e24a000f768c 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.inf +++ b/OvmfPkg/TdxDxe/TdxDxe.inf @@ -52,6 +52,7 @@ gEfiAcpiTableProtocolGuid ## CONSUMES gEfiMpInitLibMpDepProtocolGuid gEfiMpInitLibUpDepProtocolGuid + gEfiMemoryAcceptProtocolGuid =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 (#90230): https://edk2.groups.io/g/devel/message/90230 Mute This Topic: https://groups.io/mt/91570215/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 12:32:10 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+90229+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+90229+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1654484474; cv=none; d=zohomail.com; s=zohoarc; b=J2SOBxdeEA04X9jszHCKPLmqA0gogtMvZNyOLp+QKrcNVYwmrmAiLn3t6G5Xfo1HduDxbdRMX5w6zg4mYKBQRmOx+RS360t1eo2B9jGNsJA3/Zx2xKzbgr5muw4wKtGQaeLKa9/QAHOZG2idq+splVA4iTJzXnX58Yv9gmALfg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654484474; 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=dRXOICl2Hi7XjzsdJGihsByHE3xHSeguoUO7iEpK1Ug=; b=WgPZOa0P6PYGtO745v0iYtbiSN3y2zK9u2uDTKWX7m2RzSZ094llf5Qv/UhF6UDncg+8IGD9/R/ozLT4L+b9onLRkuw3LzWwjB5AlOmgLrMZoSiUUA0vaAUFIPDo3VL3ConUIb5dU6dL2IBxWvgjEmAPi4pxijXwEAt8ZD9xGBM= 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+90229+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 1654484474354412.91841478093806; Sun, 5 Jun 2022 20:01:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CDXOYY1788612xDcOmPWNVns; Sun, 05 Jun 2022 20:01:14 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.27724.1654484472793901780 for ; Sun, 05 Jun 2022 20:01:13 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="276458198" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="276458198" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:53 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="647285867" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.66]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 20:00:50 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Jiaqi Gao , Jian J Wang , Liming Gao , Dandan Bi , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann , Min Xu Subject: [edk2-devel] [PATCH 14/14] MdeModulePkg: Pool and page functions accept memory when OOM occurs Date: Mon, 6 Jun 2022 11:00:02 +0800 Message-Id: <0c6aadb4fbf75d804a491e871b250cd5d39a1589.1654420876.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: PQSQ723v3Jwe2zr8KQdsSbfjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1654484474; bh=iNrFfEn1A8hjyI9VisjatpzMg16Psw7z3vhs/j9ju50=; h=Cc:Date:From:Reply-To:Subject:To; b=aXV6BbFWU1UDgZrOVZt9Khs8vftMAZRK2crclEWpnNjBHIwtqYbZu50D+TyzfFuMuaL KZQ8PJzOz37BJFJENxLd2So4T4TKTLMyKMmwurZsYKXpDaMTot/mMqyUrrZONqwXOK4xb Hst4GIKxxR9Oyv5CF2EmgAlZeblhhlS4ODY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1654484475069100012 Content-Type: text/plain; charset="utf-8" From: Jiaqi Gao RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 When CoreAllocatePages()/CoreAllocatePool() meets error of EFI_OUT_OF_RESOURCES, locate the EfiMemoryAcceptProtocol and accept extra memory dynamically. Firstly, find the unaccpeted memory region with enough size in GCD entries. Then locate the EfiMemoryAcceptProtocol and accept the memory. Finally, update the GCD memory and gMemoryMap entries. After updating the memory infomation, CoreInternalAllocatePages()/ CoreInternalAllocatePool() will be recalled to allocate pages/pool. Cc: Jian J Wang Cc: Liming Gao Cc: Dandan Bi Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Signed-off-by: Jiaqi Gao Signed-off-by: Min Xu --- MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/Mem/Imem.h | 16 +++ MdeModulePkg/Core/Dxe/Mem/Page.c | 190 ++++++++++++++++++++++++++++++ MdeModulePkg/Core/Dxe/Mem/Pool.c | 14 +++ 4 files changed, 221 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index e4bca895773d..4b6c627a2cde 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -169,6 +169,7 @@ gEfiVariableArchProtocolGuid ## CONSUMES gEfiCapsuleArchProtocolGuid ## CONSUMES gEfiWatchdogTimerArchProtocolGuid ## CONSUMES + gEfiMemoryAcceptProtocolGuid ## CONSUMES =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressBootTimeCodePageNumber = ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Core/Dxe/Mem/Imem.h b/MdeModulePkg/Core/Dxe/Mem/I= mem.h index 2f0bf2bf631f..22e0d0e44030 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Imem.h +++ b/MdeModulePkg/Core/Dxe/Mem/Imem.h @@ -47,6 +47,22 @@ typedef struct { // Internal prototypes // =20 +/** + Internal function. Used by the pool and page functions to accept memory + when OOM occurs. + + @param Type The type of allocation to perform. + @param AcceptSize Size of memory to be accepted. + @param Memory Accept memory address + +**/ +EFI_STATUS +AcceptMemoryResource ( + IN EFI_ALLOCATE_TYPE Type, + IN UINTN AcceptSize, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ); + /** Internal function. Used by the pool functions to allocate pages to back pool allocation requests. diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index 008efdf397e0..0584373d68be 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 @@ -378,6 +379,176 @@ CoreFreeMemoryMapStack ( mFreeMapStack -=3D 1; } =20 +/** + Used to accept memory when OOM occurs. + + @param Type The type of allocation to perform. + @param AcceptSize Size of memory to be accepted. + @param Memory Accept memory address + +**/ +EFI_STATUS +AcceptMemoryResource ( + IN EFI_ALLOCATE_TYPE Type, + IN UINTN AcceptSize, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ) +{ + #ifdef MDE_CPU_X64 + + LIST_ENTRY *Link; + EFI_GCD_MAP_ENTRY *GcdEntry; + EFI_GCD_MAP_ENTRY UnacceptedEntry; + EFI_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol; + UINTN Start; + UINTN End; + EFI_STATUS Status; + + // + // We accept n*32MB at one time to improve the efficiency. + // + AcceptSize =3D (AcceptSize + SIZE_32MB - 1) & ~(SIZE_32MB - 1); + + if (AcceptSize =3D=3D 0) { + return EFI_INVALID_PARAMETER; + } + + Status =3D gBS->LocateProtocol (&gEfiMemoryAcceptProtocolGuid, NULL, (VO= ID **)&MemoryAcceptProtocol); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + if (Type =3D=3D AllocateAddress) { + Start =3D *Memory; + End =3D *Memory + AcceptSize; + } + + if (Type =3D=3D AllocateMaxAddress) { + if (*Memory < EFI_PAGE_MASK) { + return EFI_INVALID_PARAMETER; + } + + if ((*Memory & EFI_PAGE_MASK) !=3D EFI_PAGE_MASK) { + // + // Change MaxAddress to be 1 page lower + // + *Memory -=3D EFI_PAGE_SIZE; + + // + // Set MaxAddress to a page boundary + // + *Memory &=3D ~(UINT64)EFI_PAGE_MASK; + + // + // Set MaxAddress to end of the page + // + *Memory |=3D EFI_PAGE_MASK; + } + } + + // + // Traverse the mGcdMemorySpaceMap to find out the unaccepted + // memory entry with big enough size. + // + Link =3D mGcdMemorySpaceMap.ForwardLink; + while (Link !=3D &mGcdMemorySpaceMap) { + GcdEntry =3D CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE); + if (GcdEntry->GcdMemoryType =3D=3D EfiGcdMemoryTypeUnaccepted) { + if (Type =3D=3D AllocateMaxAddress) { + if (GcdEntry->BaseAddress + AcceptSize - 1 > *Memory) { + Link =3D Link->ForwardLink; + continue; + } + } else if (Type =3D=3D AllocateAddress) { + if ((GcdEntry->BaseAddress > *Memory) || (GcdEntry->EndAddress < *= Memory + AcceptSize - 1)) { + Link =3D Link->ForwardLink; + continue; + } + } + + // + // Is the entry big enough? + // + if (AcceptSize <=3D GcdEntry->EndAddress - GcdEntry->BaseAddress + 1= ) { + UnacceptedEntry =3D *GcdEntry; + if (Type !=3D AllocateAddress) { + Start =3D UnacceptedEntry.BaseAddress; + End =3D UnacceptedEntry.BaseAddress + AcceptSize - 1; + } + + break; + } + } + + Link =3D Link->ForwardLink; + } + + if (Link =3D=3D &mGcdMemorySpaceMap) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Accept memory using the interface provide by the protocol. + // + Status =3D MemoryAcceptProtocol->AcceptMemory (MemoryAcceptProtocol, Sta= rt, AcceptSize); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + // + // If memory is accepted successfully, remove the target memory space fr= om GCD. + // + CoreRemoveMemorySpace (UnacceptedEntry.BaseAddress, UnacceptedEntry.EndA= ddress - UnacceptedEntry.BaseAddress + 1); + + // + // Add the remain lower part of unaccepted memory to the + // Gcd memory space and memory map. + // + if (Start > UnacceptedEntry.BaseAddress) { + CoreAddMemorySpace ( + EfiGcdMemoryTypeUnaccepted, + UnacceptedEntry.BaseAddress, + Start - UnacceptedEntry.BaseAddress, + UnacceptedEntry.Capabilities + ); + } + + // + // Update accepted part of the memory entry to type of EfiGcdMemoryTypeS= ystemMemory + // and add the range to the memory map. + // + CoreAddMemorySpace ( + EfiGcdMemoryTypeSystemMemory, + Start, + AcceptSize, + // + // Hardcode memory space attributes. + // + EFI_MEMORY_CPU_CRYPTO | EFI_MEMORY_XP | EFI_MEMORY_RO | EFI_MEMORY_RP + ); + + // + // Add the remain higher part of unaccepted memory to the + // Gcd memory space and memory map. + // + if (UnacceptedEntry.EndAddress > End) { + CoreAddMemorySpace ( + EfiGcdMemoryTypeUnaccepted, + End + 1, + UnacceptedEntry.EndAddress - End, + UnacceptedEntry.Capabilities + ); + } + + return EFI_SUCCESS; + + #else + + return EFI_UNSUPPORTED; + + #endif +} + /** Find untested but initialized memory regions in GCD map and convert them= to be DXE allocatable. =20 @@ -1471,6 +1642,25 @@ CoreAllocatePages ( Memory, NeedGuard ); + #ifdef MDE_CPU_X64 + + if (Status =3D=3D EFI_OUT_OF_RESOURCES) { + Status =3D AcceptMemoryResource (Type, NumberOfPages << EFI_PAGE_SHIFT= , Memory); + if (!EFI_ERROR (Status)) { + Status =3D CoreInternalAllocatePages ( + Type, + MemoryType, + NumberOfPages, + Memory, + NeedGuard + ); + } else { + Status =3D EFI_OUT_OF_RESOURCES; + } + } + + #endif + if (!EFI_ERROR (Status)) { CoreUpdateProfile ( (EFI_PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/P= ool.c index 7aaf501600cf..9e8c8611c1ef 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -273,6 +273,20 @@ CoreAllocatePool ( EFI_STATUS Status; =20 Status =3D CoreInternalAllocatePool (PoolType, Size, Buffer); + + #ifdef MDE_CPU_X64 + + if (Status =3D=3D EFI_OUT_OF_RESOURCES) { + Status =3D AcceptMemoryResource (AllocateAnyPages, Size, NULL); + if (!EFI_ERROR (Status)) { + Status =3D CoreInternalAllocatePool (PoolType, Size, Buffer); + } else { + Status =3D EFI_OUT_OF_RESOURCES; + } + } + + #endif + if (!EFI_ERROR (Status)) { CoreUpdateProfile ( (EFI_PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), --=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 (#90229): https://edk2.groups.io/g/devel/message/90229 Mute This Topic: https://groups.io/mt/91570214/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-