From: "Min Xu" <min.m.xu@intel.com>
To: "Yamahata, Isaku" <isaku.yamahata@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "isaku.yamahata@gmail.com" <isaku.yamahata@gmail.com>,
"Yao, Jiewen" <jiewen.yao@intel.com>
Subject: Re: [edk2-devel] [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make SetOrClearSharedBit() handle retry error
Date: Fri, 4 Aug 2023 06:29:22 +0000 [thread overview]
Message-ID: <PH0PR11MB5064021B3A80B2E04DC737AAC509A@PH0PR11MB5064.namprd11.prod.outlook.com> (raw)
In-Reply-To: <448dd0fdd1ae9faa938e9b3649570ad2d30952a9.1691010366.git.isaku.yamahata@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
> -----Original Message-----
> From: Yamahata, Isaku <isaku.yamahata@intel.com>
> Sent: Thursday, August 3, 2023 5:09 AM
> To: devel@edk2.groups.io
> Cc: isaku.yamahata@gmail.com; Yamahata, Isaku
> <isaku.yamahata@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Xu, Min
> M <min.m.xu@intel.com>
> Subject: [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make
> SetOrClearSharedBit() handle retry error
>
> From: Isaku Yamahata <isaku.yamahata@intel.com>
>
> TDG.VP.VMCALL<MAPGPA> can return TDG.VP.VMCALL_RETRY when the
> length is too large so that VMM can avoid too long processing time. The
> caller should retry with the updated starting GPA on the error. Add check
> TDG.VP.VMCALL_RETRY check.
>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> ---
> MdePkg/Include/IndustryStandard/Tdx.h | 4 ++++
> MdePkg/Library/BaseLib/X64/TdVmcall.nasm | 4 +---
> .../Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 10 ++++++++--
> 3 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/MdePkg/Include/IndustryStandard/Tdx.h
> b/MdePkg/Include/IndustryStandard/Tdx.h
> index 81df1361842b..4ea2960a70f9 100644
> --- a/MdePkg/Include/IndustryStandard/Tdx.h
> +++ b/MdePkg/Include/IndustryStandard/Tdx.h
> @@ -103,6 +103,10 @@
> #define TDVMCALL_REPORT_FATAL_ERR 0x10003 #define
> TDVMCALL_SETUP_EVENT_NOTIFY 0x10004 +// TDVMCALL API sub-function
> Completion Status Codes+#define TDG_VP_VMCALL_SUCCESS
> 0x0000000000000000+#define TDG_VP_VMCALL_RETRY
> 0x0000000000000001+ #pragma pack(1) typedef struct { UINT64
> Data[6];diff --git a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> b/MdePkg/Library/BaseLib/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 - ; 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_postamblediff --git
> a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c
> b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c
> index a01dc98852b8..d55c2a34a44e 100644
> --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c
> +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c
> @@ -526,6 +526,8 @@ SetOrClearSharedBit (
> UINT64 TdStatus; EFI_STATUS Status;
> EDKII_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol;+
> PHYSICAL_ADDRESS TmpPhysicalAddress;+ UINT64
> TmpLength; AddressEncMask = GetMemEncryptionAddressMask (); @@ -
> 540,8 +542,12 @@ SetOrClearSharedBit (
> PhysicalAddress &= ~AddressEncMask; } - TdStatus = TdVmCall
> (TDVMCALL_MAPGPA, PhysicalAddress, Length, 0, 0, NULL);- if (TdStatus !=
> 0) {+ TmpPhysicalAddress = PhysicalAddress;+ do {+ TmpLength =
> PhysicalAddress + Length - TmpPhysicalAddress;+ TdStatus = TdVmCall
> (TDVMCALL_MAPGPA, TmpPhysicalAddress, TmpLength, 0, 0,
> &TmpPhysicalAddress);+ } while (TdStatus == TDG_VP_VMCALL_RETRY);+ if
> (TdStatus != TDG_VP_VMCALL_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a:
> TdVmcall(MAPGPA) failed with %llx\n", __func__, TdStatus)); ASSERT
> (FALSE); return EFI_DEVICE_ERROR;
> base-commit: 677f2c6f1509da21258e02957b869b71b008fc61
> --
> 2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107562): https://edk2.groups.io/g/devel/message/107562
Mute This Topic: https://groups.io/mt/100514591/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~2023-08-04 6:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 21:09 [edk2-devel] [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make SetOrClearSharedBit() handle retry error Isaku Yamahata
2023-08-04 6:29 ` Min Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PH0PR11MB5064021B3A80B2E04DC737AAC509A@PH0PR11MB5064.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox