From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.22417.1662366920227192887 for ; Mon, 05 Sep 2022 01:35:46 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bHGM5r+O; spf=permerror, err=too many SPF records (domain: intel.com, ip: 134.134.136.126, 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=1662366946; x=1693902946; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=23X4ZcFecBrJAN7bmW5zcYSC7Hb2nFj2WO323SvyHaM=; b=bHGM5r+OY2Wx8qR9zOmwm1YLDgLKlUx4gUfXqIQuiWw5tZY4/xy0MT7n CStHnqSO1jcST2kPqb6Mb/ipcLX/qFh1wegIP+1naSQ5T0mNUcnWQj9Zo I4AossSpBBufHqxbALFopyzpivfY9zcfGjS1Nn9M6vzUEfDtgQuq+Ew5o QLx+QChh88hVvDdpuvE4nv6zHHjo5KosAhYkgGI1nVSW+H/xhywnoF2Pq h9Tv4CQVTBFNRbKiCQlK9rF9DMbx9O3hTvQrdOThgtyQaJWPAYrRe4pX2 IDbuj5UCGtnklDBqvUBR2XdDo02WLwDquCud5srYStOZ7S3KDIITGAsuX g==; X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="279355992" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="279355992" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:45 -0700 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675194563" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.119]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 01:35:43 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [PATCH V3 12/12] OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages Date: Mon, 5 Sep 2022 16:35:06 +0800 Message-Id: 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 Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- .../BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf | 3 +++ .../Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf index a8abfec12fa3..11768825f8ca 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf @@ -42,3 +42,6 @@ [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