From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web12.46431.1661581332997885650 for ; Fri, 26 Aug 2022 23:22:41 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=NXWPoO6L; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661581361; x=1693117361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BtTjCvd5j2NNAf7CjvkfC99dyrwBEd7wZpJK7r5u5pI=; b=NXWPoO6L64783qiAPF4cx7rY1rhLmN9vw73mfojzd2KQvQ4dBnqsWtmw YOlNNaLn/kiwu2zQvsMakTLo6h9PC97TCrf/eKlY7E37OlAdpM6nZtB9T peiJ/12cnHYt26/d3ygt9g1lsZKT0Mt5TjmR05i8LW9a64Px5SW+JE7I2 V33H2d+I1IIidGeMOCbys8Kif/foQbj0OHC1XhzVCa/iy4oz0dUNvX6IG HzFSowr/xGoWPTmZ1qM3ym9tcfaSn05JNYx55A2kRyb6ARAwbvIljyCjf LVIHc48Z8/854wFZNb+PekI1oOV28cWuAt9njmPV9Pn600WZl483Ar/6m g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="356355960" X-IronPort-AV: E=Sophos;i="5.93,267,1654585200"; d="scan'208";a="356355960" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 23:22:40 -0700 X-IronPort-AV: E=Sophos;i="5.93,267,1654585200"; d="scan'208";a="671738925" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.171.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 23:22:39 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [PATCH V2 13/14] OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages Date: Sat, 27 Aug 2022 14:21:20 +0800 Message-Id: <45f2baece31f3fab25e6571fff590cc7bf45ac8d.1661579220.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Min M Xu RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3937 After EdkiiMemoryAcceptProtocol is implemented in TdxDxe driver, we can call it to accept pages in DXE phase. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Signed-off-by: Min Xu --- .../BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf | 3 +++ .../Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf index a8abfec12fa3..11768825f8ca 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf @@ -42,3 +42,6 @@ [Pcd] gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr + +[Protocols] + gEdkiiMemoryAcceptProtocolGuid diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c index 9d11c6e4df72..503f626d75c6 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c @@ -27,6 +27,8 @@ #include "VirtualMemory.h" #include #include +#include +#include #include typedef enum { @@ -517,8 +519,9 @@ SetOrClearSharedBit ( IN UINT64 Length ) { - UINT64 AddressEncMask; - UINT64 Status; + UINT64 AddressEncMask; + UINT64 Status; + EDKII_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol; AddressEncMask = GetMemEncryptionAddressMask (); @@ -539,7 +542,10 @@ SetOrClearSharedBit ( // If changing shared to private, must accept-page again // if (Mode == ClearSharedBit) { - TdAcceptPages (PhysicalAddress, Length / EFI_PAGE_SIZE, EFI_PAGE_SIZE); + Status = gBS->LocateProtocol (&gEdkiiMemoryAcceptProtocolGuid, NULL, (VOID **)&MemoryAcceptProtocol); + ASSERT (!EFI_ERROR (Status)); + Status = MemoryAcceptProtocol->AcceptMemory (MemoryAcceptProtocol, PhysicalAddress, Length); + ASSERT (!EFI_ERROR (Status)); } DEBUG (( -- 2.29.2.windows.2