Reviewed-by: Min Xu
> -Original Message-
> From: Yamahata, Isaku
> Sent: Thursday, August 3, 2023 5:09 AM
> To: devel@edk2.groups.io
> Cc: isaku.yamah...@gmail.com; Yamahata, Isaku
> ; Yao, Jiewen ; Xu, Min
> M
> Subject: [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make
> SetOrClearSharedBit() handle retry error
>
> From: Isaku Yamahata
>
> TDG.VP.VMCALL 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
> ---
> 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_ERR0x10003 #define
> TDVMCALL_SETUP_EVENT_NOTIFY 0x10004 +// TDVMCALL API sub-function
> Completion Status Codes+#define TDG_VP_VMCALL_SUCCESS
> 0x+#define TDG_VP_VMCALL_RETRY
> 0x0001+ #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, r9jz .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
> parammov [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 (
>UINT64TdStatus; 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,
> );+ } 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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-