From nobody Thu May 16 14:32:12 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+110909+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+110909+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699443596; cv=none; d=zohomail.com; s=zohoarc; b=hsfSZHyb97KEbQR4ZByXnT3vg209C3RkbTxB9mYLcWXWSbfnAO+CjMW/2tG6BibWQfvSe5pwzeegFa6UkoLAmBzhVu9HE/Ll2qv1gfCWt0RctNAuxler8K5MWls7Gmywu8oQOHjuLwvq+ofpBpRRvj+O0NJ8PGjBGyexRA4zkio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699443596; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=mXx3xc4CgwrEj/Kwwnb3xd04T/0PpuaIsBQGMEqPW0A=; b=YugolTxx95RBMqhz9/AR4TehNJqSRLUPo6oOEoD1ddLFEUIjRIUH7zBDoicv3w63ON5LRvvyy9eorFIfh5Z4GcbmCFR4jhIkXYg3uiWCMq6WvG8v0wi9VUYgUSuSZuEnRvbEOIqV8v1boJ6fPD7NMAaK1hQMGQnS4S64/1FQv88= 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+110909+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 1699443596839822.4764534060172; Wed, 8 Nov 2023 03:39:56 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=vHFfwutDXjNmPFMMq2Ddo2CW4jiIYtN+Y5Zq+6IrL2M=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699443596; v=1; b=l923k5iRVjtCJ5YaSWl1pWPAkRco2O1Wic3Yt3zWm85mnnSnWwyOmFZeWS/OhdTgQqmlf+Kb 7SNel+VPTua+j0bFKoN6vZIYXlpfcOplVZzP+99nv8+lu/ZMMB08phnuI8Wu2/PnIjQovc7AgCo UiOhTabB5nZlVuBfnBq2mFag= X-Received: by 127.0.0.2 with SMTP id sGOVYY1788612xXbuTPS22kZ; Wed, 08 Nov 2023 03:39:56 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.11525.1699443595939056670 for ; Wed, 08 Nov 2023 03:39:55 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="388603331" X-IronPort-AV: E=Sophos;i="6.03,286,1694761200"; d="scan'208";a="388603331" X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 03:39:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="797979635" X-IronPort-AV: E=Sophos;i="6.03,286,1694761200"; d="scan'208";a="797979635" X-Received: from cepingsx-mobl1.ccr.corp.intel.com ([10.239.49.140]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 03:39:52 -0800 From: "sunceping" To: devel@edk2.groups.io Cc: Ceping Sun , Liming Gao , Michael D Kinney , Erdem Aktas , James Bottomley , Min Xu , Tom Lendacky , Michael Roth , Gerd Hoffmann , Jiewen Yao Subject: [edk2-devel] [PATCH V4 1/3] MdePkg/BaseLib: Update TdVmcall to always output the value in R11 Date: Wed, 8 Nov 2023 19:38:25 +0800 Message-Id: <20231108113827.3917-2-cepingx.sun@intel.com> In-Reply-To: <20231108113827.3917-1-cepingx.sun@intel.com> References: <20231108113827.3917-1-cepingx.sun@intel.com> MIME-Version: 1.0 Precedence: Bulk 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,cepingx.sun@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: KEhh2smSrPNulcVMS92oxMAgx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699443599427100003 Content-Type: text/plain; charset="utf-8" From: Ceping Sun REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4572 According to section 3.2 of the [GHCI] spec, if the return status of MapGPA is "TDG.VP.VMCALL_RETRY", TD must retry this operation for the pages in the region starting at the GPA specified in R11. Currently, TDVF has not handled the retry results and always clears the R11 on unsuccessful return status. For this, the TdVmcall needs to output the value of R11 on unsuccessful return status to handle the retry results of MapGPA. Reference: [GHCI]: TDX Guest-Host-Communication Interface v1.0 https://cdrdv2.intel.com/v1/dl/getContent/726790 Cc: Liming Gao Cc: Michael D Kinney Cc: Erdem Aktas Cc: James Bottomley Cc: Min Xu Cc: Tom Lendacky Cc: Michael Roth Acked-by: Gerd Hoffmann Reviewed-by: Jiewen Yao Signed-off-by: Ceping Sun --- MdePkg/Library/BaseLib/X64/TdVmcall.nasm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm b/MdePkg/Library/Base= Lib/X64/TdVmcall.nasm index 5ecc10b17193..8dd9bfcbfa14 100644 --- a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm +++ b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm @@ -133,9 +133,7 @@ ASM_PFX(TdVmCall): test r9, r9 jz .no_return_data =20 - ; On success, propagate TDVMCALL output value to output param - test rax, rax - jnz .no_return_data + ; Propagate TDVMCALL output value to output param mov [r9], r11 .no_return_data: tdcall_regs_postamble --=20 2.34.1 -=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 (#110909): https://edk2.groups.io/g/devel/message/110909 Mute This Topic: https://groups.io/mt/102461782/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 14:32:12 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+110910+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+110910+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699443602; cv=none; d=zohomail.com; s=zohoarc; b=lL2OKNs2I7t7i1yDFgctrq/rWuVX3I/ERm76xA9nqPbMMaZvZyiESFY/UlVJmBXUzDAiQWIlQ23wzP2JlAuyJc/3RfCA2qk5vZ87PjrxDbHCE6Nkm8ZkXPExejrXkqAIjyZFYAQTFUyKnw3g/Jit7+E0P0Z9eDqxCdVorR1UTLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699443602; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=rka1Eet9gMZJxf9LDtoM4r6Z5QnHL8xfADJpS0KGzPM=; b=D8N4OLCoD+/C9XkTa51uoxuQ4EQQ2F8E+0nuGZDaM7rt0CgPTWCfo9WG6Sb3fQqtx3TuOZDINsjMSrpmN5pkYQ1M8q33xRwW6hOzJlhNz1fj5QJuos5M2oQd9qDTplbsHXS5VZW4+YBSyrUbQ9+tbgMeY6jhJv/ftGzQcBZYTlI= 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+110910+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 1699443602249190.6801296796781; Wed, 8 Nov 2023 03:40:02 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=3/CE8Webl/mPbYf+Z2/4EM4nIhB6tIaFR44n5tGl5bE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699443601; v=1; b=Qc2ecpXoK+xs0UwYpZzHc105GhG9+ADGG0qpkZ8qlBFqFgisjm5DyK+waO1AQLeb0tKI/+/c O79S1G9Y5cQMn12wi+SfRTBZMrCxDppaQpLfYYy0Sx12/LLVEI0cB1d4SB+8NdZ19Yhu7KHyLYc sVGeuAAqmpsx9ZqX8XZixssI= X-Received: by 127.0.0.2 with SMTP id dcwtYY1788612xkozPqkMQCA; Wed, 08 Nov 2023 03:40:01 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.11528.1699443601366899194 for ; Wed, 08 Nov 2023 03:40:01 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="388603360" X-IronPort-AV: E=Sophos;i="6.03,286,1694761200"; d="scan'208";a="388603360" X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 03:40:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="797979643" X-IronPort-AV: E=Sophos;i="6.03,286,1694761200"; d="scan'208";a="797979643" X-Received: from cepingsx-mobl1.ccr.corp.intel.com ([10.239.49.140]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 03:39:57 -0800 From: "sunceping" To: devel@edk2.groups.io Cc: Ceping Sun , Liming Gao , Michael D Kinney , Erdem Aktas , James Bottomley , Min Xu , Tom Lendacky , Michael Roth , Gerd Hoffmann , Jiewen Yao Subject: [edk2-devel] [PATCH V4 2/3] MdePkg/Tdx.h: Add TDVMCALL_STATUS_RETRY Date: Wed, 8 Nov 2023 19:38:26 +0800 Message-Id: <20231108113827.3917-3-cepingx.sun@intel.com> In-Reply-To: <20231108113827.3917-1-cepingx.sun@intel.com> References: <20231108113827.3917-1-cepingx.sun@intel.com> MIME-Version: 1.0 Precedence: Bulk 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,cepingx.sun@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rJZFXeaGpx7eXhDpv5tGsSJxx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699443602684100001 Content-Type: text/plain; charset="utf-8" From: Ceping Sun REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4572 TDVMCALL_STATUS_RETRY is defined in GHCI spec section 2.4.1. Reference: [GHCI]: TDX Guest-Host-Communication Interface v1.0 https://cdrdv2.intel.com/v1/dl/getContent/726790 Cc: Liming Gao Cc: Michael D Kinney Cc: Erdem Aktas Cc: James Bottomley Cc: Min Xu Cc: Tom Lendacky Cc: Michael Roth Cc: Gerd Hoffmann Cc: Jiewen Yao Signed-off-by: Ceping Sun Acked-by: Gerd Hoffmann --- MdePkg/Include/IndustryStandard/Tdx.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MdePkg/Include/IndustryStandard/Tdx.h b/MdePkg/Include/Industr= yStandard/Tdx.h index 81df1361842b..2662761883e5 100644 --- a/MdePkg/Include/IndustryStandard/Tdx.h +++ b/MdePkg/Include/IndustryStandard/Tdx.h @@ -103,6 +103,8 @@ #define TDVMCALL_REPORT_FATAL_ERR 0x10003 #define TDVMCALL_SETUP_EVENT_NOTIFY 0x10004 =20 +#define TDVMCALL_STATUS_RETRY 0x1 + #pragma pack(1) typedef struct { UINT64 Data[6]; --=20 2.34.1 -=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 (#110910): https://edk2.groups.io/g/devel/message/110910 Mute This Topic: https://groups.io/mt/102461783/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 14:32:12 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+110911+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+110911+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699443610; cv=none; d=zohomail.com; s=zohoarc; b=Ty8IoYDTBWSqG8zOfv+6m/xn1QRlgwr440O5744fxZc/p6hI4HoB0MorfrR2+nWXIfoSTmDI2zjxMtR0MMoWcdP7XA/WBC7+4Jv0/W4DuGXx3z/lPok69gF0b07OnEMyG7WzxtFw++3Q6R5ym4diTTWGHdBXTSqgqPsldPB1wNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699443610; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=1rapCGGXQHjmYFvDZXPNrXumoAGeteTbCuNAKZIpjDs=; b=AYNLjx2qETI+tLqppTX0o2scNbHwD2YhAAoHoKeJpLgsTyxzc/+rjWdpzgHyYkcMB/dYEGuCIIChL8V+L/IwqYkfHqXMRtL8wS0WVKJL9FtNMOeKhETg24doPEo/snWm6VpiqHZfoGy7wYodh6DnUBfVZeLmgz8W4zTFj+DRwck= 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+110911+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 1699443610518435.132013737933; Wed, 8 Nov 2023 03:40:10 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=OIynVy6tQYT3U6ejXQXlCwLyCSfm1ejUQrV+nBE1Omk=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699443610; v=1; b=TGjv46p2hzJH+Cmk+TX30nZPW7AtVkgbOJfdJWkj91yP4mEcwA9LTcf7kzxR9ZgrdFg+JV/X PaILDzSvkPmfrg9gjPXzfZsojW7qgN1dd42VnBV0FUMaor/ht8Q+X4+dZ3wN75uQVft3XapzzC1 LGcB2pxoMIAOrklLbf5kPmtE= X-Received: by 127.0.0.2 with SMTP id fvZcYY1788612xOJMiBbmu4a; Wed, 08 Nov 2023 03:40:10 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.11635.1699443609590180891 for ; Wed, 08 Nov 2023 03:40:09 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="388603410" X-IronPort-AV: E=Sophos;i="6.03,286,1694761200"; d="scan'208";a="388603410" X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 03:40:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10887"; a="797979696" X-IronPort-AV: E=Sophos;i="6.03,286,1694761200"; d="scan'208";a="797979696" X-Received: from cepingsx-mobl1.ccr.corp.intel.com ([10.239.49.140]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 03:40:04 -0800 From: "sunceping" To: devel@edk2.groups.io Cc: Ceping Sun , Erdem Aktas , James Bottomley , Jiewen Yao , Min Xu , Tom Lendacky , Michael Roth , Gerd Hoffmann Subject: [edk2-devel] [PATCH V4 3/3] OvmfPkg/BaseMemEncryptTdxLib: Handle retry result of MapGPA Date: Wed, 8 Nov 2023 19:38:27 +0800 Message-Id: <20231108113827.3917-4-cepingx.sun@intel.com> In-Reply-To: <20231108113827.3917-1-cepingx.sun@intel.com> References: <20231108113827.3917-1-cepingx.sun@intel.com> MIME-Version: 1.0 Precedence: Bulk 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,cepingx.sun@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: fm2xY05Zyw0zdjZZDIP8yRi2x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699443612848100003 Content-Type: text/plain; charset="utf-8" From: Ceping Sun REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4572 According to section 3.2 of the [GHCI] document, if the return status of MapGPA is "TDG.VP.VMCALL_RETRY", TD must retry this operation for the pages in the region starting at the GPA specified in R11. In this patch, when a retry state is detected, TDVF needs to retry the mapping with the specified address from the output results of TdVmCall. Reference: [GHCI]: TDX Guest-Host-Communication Interface v1.0 https://cdrdv2.intel.com/v1/dl/getContent/726790 Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Min Xu Cc: Tom Lendacky Cc: Michael Roth Cc: Gerd Hoffmann Signed-off-by: Ceping Sun Acked-by: Gerd Hoffmann --- .../BaseMemEncryptTdxLib/MemoryEncryption.c | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c b/Ovmf= Pkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c index a01dc98852b8..a71b1efbca7a 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c @@ -38,6 +38,8 @@ typedef enum { =20 STATIC PAGE_TABLE_POOL *mPageTablePool =3D NULL; =20 +#define MAX_RETRIES_PER_PAGE 3 + /** Returns boolean to indicate whether to indicate which, if any, memory en= cryption is enabled =20 @@ -527,6 +529,13 @@ SetOrClearSharedBit ( EFI_STATUS Status; EDKII_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol; =20 + UINT64 MapGpaRetryAddr; + UINT32 RetryCount; + UINT64 EndAddress; + + MapGpaRetryAddr =3D 0; + RetryCount =3D 0; + AddressEncMask =3D GetMemEncryptionAddressMask (); =20 // @@ -540,7 +549,37 @@ SetOrClearSharedBit ( PhysicalAddress &=3D ~AddressEncMask; } =20 - TdStatus =3D TdVmCall (TDVMCALL_MAPGPA, PhysicalAddress, Length, 0, 0, N= ULL); + EndAddress =3D PhysicalAddress + Length; + while (RetryCount < MAX_RETRIES_PER_PAGE) { + TdStatus =3D TdVmCall (TDVMCALL_MAPGPA, PhysicalAddress, Length, 0, 0,= &MapGpaRetryAddr); + if (TdStatus !=3D TDVMCALL_STATUS_RETRY) { + break; + } + + DEBUG ((DEBUG_VERBOSE, "%a: TdVmcall(MAPGPA) Retry PhysicalAddress is = %llx, MapGpaRetryAddr is %llx\n", __func__, PhysicalAddress, MapGpaRetryAdd= r)); + + if ((MapGpaRetryAddr < PhysicalAddress) || (MapGpaRetryAddr >=3D EndAd= dress)) { + DEBUG (( + DEBUG_ERROR, + "%a: TdVmcall(MAPGPA) failed with MapGpaRetryAddr(%llx) less than = PhysicalAddress(%llx) or more than or equal to EndAddress(%llx) \n", + __func__, + MapGpaRetryAddr, + PhysicalAddress, + EndAddress + )); + break; + } + + if (MapGpaRetryAddr =3D=3D PhysicalAddress) { + RetryCount++; + continue; + } + + PhysicalAddress =3D MapGpaRetryAddr; + Length =3D EndAddress - PhysicalAddress; + RetryCount =3D 0; + } + if (TdStatus !=3D 0) { DEBUG ((DEBUG_ERROR, "%a: TdVmcall(MAPGPA) failed with %llx\n", __func= __, TdStatus)); ASSERT (FALSE); --=20 2.34.1 -=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 (#110911): https://edk2.groups.io/g/devel/message/110911 Mute This Topic: https://groups.io/mt/102461785/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-