From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web08.2747.1615253955227564542 for ; Mon, 08 Mar 2021 17:39:17 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Tue, 09 Mar 2021 09:38:39 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Doug Reiland'" , "'Zhiguang Liu'" , "'Jiewen Yao'" References: <9986f966565c980ac4e33a86c7a7ce41533433ae.1615249174.git.min.m.xu@intel.com> In-Reply-To: <9986f966565c980ac4e33a86c7a7ce41533433ae.1615249174.git.min.m.xu@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIDEvM10gTWRlUGtnOiBBZGQgVGR4IHN1cHBvcnQgbGli?= Date: Tue, 9 Mar 2021 09:38:42 +0800 Message-ID: <000c01d71484$f0169790$d043c6b0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJ3EKhp2CCYcXvRafLF5AdCYq/18gIE0i2GqSrBmcA= Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Min: =20 Where is the definition in MdePkg/Include/IndustryStandard/Tdx.h from?=20 Is it from https://software.intel.com/content/www/us/en/develop/articles/intel-trust= -do main-extensions.html? Where is the definition in MdePkg/Include/Protocol/Tdx.h from? Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: devel@edk2.groups.io = =B4=FA=B1=ED > min.m.xu@intel.com > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA3=D4=C29=C8=D5 8:55 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Min Xu ; Doug Reiland > ; Liming Gao ; > Zhiguang Liu ; Jiewen Yao = > =D6=F7=CC=E2: [edk2-devel] [PATCH 1/3] MdePkg: Add Tdx support lib >=20 > From: Min Xu >=20 > Intel Trust Domain Extension (Intel TDX) refers to an Intel technology > that extends Virtual Machines Extensions (VMX) and Multi-Key Total > Memory Encryption (MKTME) with a new kind of virtual machine guest > called a Trust Domain (TD). >=20 > TdxLib is created with functions to perform the related Tdx operation. > This includes functions for: > - TdCall : to cause a VM exit to the Intel TDX module > - TdVmCall : it is a leaf function 0 for TDCALL > - TdVmCallCpuid : enable the TD guest to request VMM to emulate > CPUID > - TdReport : to retrieve TDREPORT_STRUCT > - TdAcceptPages : to accept pending private pages > - TdExtendRtmr : to extend one of the RTMR registers >=20 > The base function in this dirver will not do anything and will return > an error if a return value is required. It is expected that other > packages (like OvmfPkg) will create a version of the library to fully > support a TD guest. >=20 > Signed-off-by: Min Xu > Signed-off-by: Doug Reiland >=20 > CC: Liming Gao > CC: Zhiguang Liu > CC: Jiewen Yao > --- > MdePkg/Include/IndustryStandard/Tdx.h | 201 > ++++++++++++++++++++++++++ > MdePkg/Include/Library/TdxLib.h | 165 +++++++++++++++++++++ > MdePkg/Include/Protocol/Tdx.h | 22 +++ > MdePkg/Library/TdxLib/TdxLibNull.c | 155 ++++++++++++++++++++ > MdePkg/Library/TdxLib/TdxLibNull.inf | 33 +++++ > 5 files changed, 576 insertions(+) > create mode 100644 MdePkg/Include/IndustryStandard/Tdx.h > create mode 100644 MdePkg/Include/Library/TdxLib.h > create mode 100644 MdePkg/Include/Protocol/Tdx.h > create mode 100644 MdePkg/Library/TdxLib/TdxLibNull.c > create mode 100644 MdePkg/Library/TdxLib/TdxLibNull.inf >=20 > diff --git a/MdePkg/Include/IndustryStandard/Tdx.h > b/MdePkg/Include/IndustryStandard/Tdx.h > new file mode 100644 > index 0000000000..dbcc31c265 > --- /dev/null > +++ b/MdePkg/Include/IndustryStandard/Tdx.h > @@ -0,0 +1,201 @@ > +/** @file >=20 > + Intel Trust Domain Extension definitions >=20 > + >=20 > + Copyright (c) 2020 - 2021, Intel Corporation. All rights = reserved.
>=20 > + This program and the accompanying materials >=20 > + are licensed and made available under the terms and conditions of = the > BSD License >=20 > + which accompanies this distribution. The full text of the license = may be > found at >=20 > + http://opensource.org/licenses/bsd-license.php >=20 > + >=20 > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, >=20 > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef _TDX_H_ >=20 > +#define _TDX_H_ >=20 > + >=20 > +#define EXIT_REASON_EXTERNAL_INTERRUPT 1 >=20 > +#define EXIT_REASON_TRIPLE_FAULT 2 >=20 > + >=20 > +#define EXIT_REASON_PENDING_INTERRUPT 7 >=20 > +#define EXIT_REASON_NMI_WINDOW 8 >=20 > +#define EXIT_REASON_TASK_SWITCH 9 >=20 > +#define EXIT_REASON_CPUID 10 >=20 > +#define EXIT_REASON_HLT 12 >=20 > +#define EXIT_REASON_INVD 13 >=20 > +#define EXIT_REASON_INVLPG 14 >=20 > +#define EXIT_REASON_RDPMC 15 >=20 > +#define EXIT_REASON_RDTSC 16 >=20 > +#define EXIT_REASON_VMCALL 18 >=20 > +#define EXIT_REASON_VMCLEAR 19 >=20 > +#define EXIT_REASON_VMLAUNCH 20 >=20 > +#define EXIT_REASON_VMPTRLD 21 >=20 > +#define EXIT_REASON_VMPTRST 22 >=20 > +#define EXIT_REASON_VMREAD 23 >=20 > +#define EXIT_REASON_VMRESUME 24 >=20 > +#define EXIT_REASON_VMWRITE 25 >=20 > +#define EXIT_REASON_VMOFF 26 >=20 > +#define EXIT_REASON_VMON 27 >=20 > +#define EXIT_REASON_CR_ACCESS 28 >=20 > +#define EXIT_REASON_DR_ACCESS 29 >=20 > +#define EXIT_REASON_IO_INSTRUCTION 30 >=20 > +#define EXIT_REASON_MSR_READ 31 >=20 > +#define EXIT_REASON_MSR_WRITE 32 >=20 > +#define EXIT_REASON_INVALID_STATE 33 >=20 > +#define EXIT_REASON_MSR_LOAD_FAIL 34 >=20 > +#define EXIT_REASON_MWAIT_INSTRUCTION 36 >=20 > +#define EXIT_REASON_MONITOR_TRAP_FLAG 37 >=20 > +#define EXIT_REASON_MONITOR_INSTRUCTION 39 >=20 > +#define EXIT_REASON_PAUSE_INSTRUCTION 40 >=20 > +#define EXIT_REASON_MCE_DURING_VMENTRY 41 >=20 > +#define EXIT_REASON_TPR_BELOW_THRESHOLD 43 >=20 > +#define EXIT_REASON_APIC_ACCESS 44 >=20 > +#define EXIT_REASON_EOI_INDUCED 45 >=20 > +#define EXIT_REASON_GDTR_IDTR 46 >=20 > +#define EXIT_REASON_LDTR_TR 47 >=20 > +#define EXIT_REASON_EPT_VIOLATION 48 >=20 > +#define EXIT_REASON_EPT_MISCONFIG 49 >=20 > +#define EXIT_REASON_INVEPT 50 >=20 > +#define EXIT_REASON_RDTSCP 51 >=20 > +#define EXIT_REASON_PREEMPTION_TIMER 52 >=20 > +#define EXIT_REASON_INVVPID 53 >=20 > +#define EXIT_REASON_WBINVD 54 >=20 > +#define EXIT_REASON_XSETBV 55 >=20 > +#define EXIT_REASON_APIC_WRITE 56 >=20 > +#define EXIT_REASON_RDRAND 57 >=20 > +#define EXIT_REASON_INVPCID 58 >=20 > +#define EXIT_REASON_VMFUNC 59 >=20 > +#define EXIT_REASON_ENCLS 60 >=20 > +#define EXIT_REASON_RDSEED 61 >=20 > +#define EXIT_REASON_PML_FULL 62 >=20 > +#define EXIT_REASON_XSAVES 63 >=20 > +#define EXIT_REASON_XRSTORS 64 >=20 > + >=20 > +// TDCALL API Function Completion Status Codes >=20 > +#define TDX_EXIT_REASON_SUCCESS > 0x0000000000000000 >=20 > +#define TDX_EXIT_REASON_PAGE_ALREADY_ACCEPTED > 0x00000B0A00000000 >=20 > +#define TDX_EXIT_REASON_OPERAND_INVALID > 0xC000010000000000 >=20 > +#define TDX_EXIT_REASON_OPERAND_BUSY > 0x8000020000000000 >=20 > + >=20 > +#define TDCALL_TDVMCALL 0 >=20 > +#define TDCALL_TDINFO 1 >=20 > +#define TDCALL_TDEXTENDRTMR 2 >=20 > +#define TDCALL_TDGETVEINFO 3 >=20 > +#define TDCALL_TDREPORT 4 >=20 > +#define TDCALL_TDSETCPUIDVE 5 >=20 > +#define TDCALL_TDACCEPTPAGE 6 >=20 > + >=20 > +#define TDVMCALL_CPUID 0x0000a >=20 > +#define TDVMCALL_HALT 0x0000c >=20 > +#define TDVMCALL_IO 0x0001e >=20 > +#define TDVMCALL_RDMSR 0x0001f >=20 > +#define TDVMCALL_WRMSR 0x00020 >=20 > +#define TDVMCALL_MMIO 0x00030 >=20 > +#define TDVMCALL_PCONFIG 0x00041 >=20 > + >=20 > +#define TDVMCALL_GET_TDVMCALL_INFO 0x10000 >=20 > +#define TDVMCALL_MAPGPA 0x10001 >=20 > +#define TDVMCALL_GET_QUOTE 0x10002 >=20 > +#define TDVMCALL_REPORT_FATAL_ERR 0x10003 >=20 > +#define TDVMCALL_SETUP_EVENT_NOTIFY 0x10004 >=20 > + >=20 > +#pragma pack(1) >=20 > +typedef struct { >=20 > + UINT64 Data[6]; >=20 > +} TDCALL_GENERIC_RETURN_DATA; >=20 > + >=20 > +typedef struct { >=20 > + UINT64 Gpaw; >=20 > + UINT64 Attributes; >=20 > + UINT32 MaxVcpus; >=20 > + UINT32 NumVcpus; >=20 > + UINT64 Resv[3]; >=20 > +} TDCALL_INFO_RETURN_DATA; >=20 > + >=20 > +typedef union { >=20 > + UINT64 Val; >=20 > + struct { >=20 > + UINT32 Size:3; >=20 > + UINT32 Direction:1; >=20 > + UINT32 String:1; >=20 > + UINT32 Rep:1; >=20 > + UINT32 Encoding:1; >=20 > + UINT32 Resv:9; >=20 > + UINT32 Port:16; >=20 > + UINT32 Resv2; >=20 > + } Io; >=20 > +} VMX_EXIT_QUALIFICATION; >=20 > + >=20 > +typedef struct { >=20 > + UINT32 ExitReason; >=20 > + UINT32 Resv; >=20 > + VMX_EXIT_QUALIFICATION ExitQualification; >=20 > + UINT64 GuestLA; >=20 > + UINT64 GuestPA; >=20 > + UINT32 ExitInstructionLength; >=20 > + UINT32 ExitInstructionInfo; >=20 > + UINT32 Resv1; >=20 > +} TDCALL_VEINFO_RETURN_DATA; >=20 > + >=20 > +typedef union { >=20 > + TDCALL_GENERIC_RETURN_DATA Generic; >=20 > + TDCALL_INFO_RETURN_DATA TdInfo; >=20 > + TDCALL_VEINFO_RETURN_DATA VeInfo; >=20 > +} TD_RETURN_DATA; >=20 > + >=20 > +/* data structure used in TDREPORT_STRUCT */ >=20 > +typedef struct{ >=20 > + UINT8 Type; >=20 > + UINT8 Subtype; >=20 > + UINT8 Version; >=20 > + UINT8 Rsvd; >=20 > +}TD_REPORT_TYPE; >=20 > + >=20 > +typedef struct{ >=20 > + TD_REPORT_TYPE ReportType; >=20 > + UINT8 Rsvd1[12]; >=20 > + UINT8 CpuSvn[16]; >=20 > + UINT8 TeeTcbInfoHash[48]; >=20 > + UINT8 TeeInfoHash[48]; >=20 > + UINT8 ReportData[64]; >=20 > + UINT8 Rsvd2[32]; >=20 > + UINT8 Mac[32]; >=20 > +}REPORTMACSTRUCT; >=20 > + >=20 > +typedef struct{ >=20 > + UINT8 Seam[2]; >=20 > + UINT8 Rsvd[14]; >=20 > +}TEE_TCB_SVN; >=20 > + >=20 > +typedef struct{ >=20 > + UINT8 Valid[8]; >=20 > + TEE_TCB_SVN TeeTcbSvn; >=20 > + UINT8 Mrseam[48]; >=20 > + UINT8 Mrsignerseam[48]; >=20 > + UINT8 Attributes[8]; >=20 > + UINT8 Rsvd[111]; >=20 > +}TEE_TCB_INFO; >=20 > + >=20 > +typedef struct{ >=20 > + UINT8 Attributes[8]; >=20 > + UINT8 Xfam[8]; >=20 > + UINT8 Mrtd[48]; >=20 > + UINT8 Mrconfigid[48]; >=20 > + UINT8 Mrowner[48]; >=20 > + UINT8 Mrownerconfig[48]; >=20 > + UINT8 Rtmrs[4][48]; >=20 > + UINT8 Rsvd[112]; >=20 > +}TDINFO; >=20 > + >=20 > +typedef struct{ >=20 > + REPORTMACSTRUCT ReportMacStruct; >=20 > + TEE_TCB_INFO TeeTcbInfo; >=20 > + UINT8 Rsvd[17]; >=20 > + TDINFO Tdinfo; >=20 > +}TDREPORT_STRUCT; >=20 > + >=20 > +#pragma pack() >=20 > + >=20 > +#endif >=20 > + >=20 > diff --git a/MdePkg/Include/Library/TdxLib.h > b/MdePkg/Include/Library/TdxLib.h > new file mode 100644 > index 0000000000..5e8634c6df > --- /dev/null > +++ b/MdePkg/Include/Library/TdxLib.h > @@ -0,0 +1,165 @@ > +/** @file >=20 > + TdxLib definitions >=20 > + >=20 > + Copyright (c) 2020 - 2021, Intel Corporation. All rights = reserved.
>=20 > + This program and the accompanying materials >=20 > + are licensed and made available under the terms and conditions of = the > BSD License >=20 > + which accompanies this distribution. The full text of the license = may be > found at >=20 > + http://opensource.org/licenses/bsd-license.php >=20 > + >=20 > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, >=20 > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef _TDX_LIB_H_ >=20 > +#define _TDX_LIB_H_ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > + >=20 > +/** >=20 > + This function retrieve TDREPORT_STRUCT structure from TDX. >=20 > + The struct contains the measurements/configuration information of >=20 > + the guest TD that called the function, measurements/configuratio >=20 > + information of the TDX-SEAM module and a REPORTMACSTRUCT. >=20 > + The REPORTMACSTRUCT is integrity protected with a MAC and >=20 > + contains the hash of the measurements and configuration >=20 > + as well as additional REPORTDATA provided by the TD software. >=20 > + >=20 > + AdditionalData, a 64-byte value, is provided by the guest TD >=20 > + to be included in the TDREPORT >=20 > + >=20 > + @param[in,out] Report Holds the TEREPORT_STRUCT. >=20 > + @param[in] ReportSize Size of the report. It must be >=20 > + larger than 1024B. >=20 > + @param[in] AdditionalData Point to the additional data. >=20 > + @param[in] AdditionalDataSize Size of the additional data. >=20 > + If AdditionalData !=3D NULL, > then >=20 > + this value must be 64B. >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return EFI_INVALID_PARAMETER >=20 > + @return EFI_DEVICE_ERROR >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdReport( >=20 > + IN OUT UINT8 *Report, >=20 > + IN UINT32 ReportSize, >=20 > + IN UINT8 *AdditionalData, >=20 > + IN UINT32 AdditionalDataSize >=20 > +); >=20 > + >=20 > +/** >=20 > + This function accept a pending private page, and initialize the = page to >=20 > + all-0 using the TD ephemeral private key. >=20 > + >=20 > + @param[in] StartAddress Guest physical address of the private > page >=20 > + to accept. >=20 > + @param[in] NumberOfPages Number of the pages to be accepted. >=20 > + >=20 > + @return EFI_SUCCESS >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdAcceptPages ( >=20 > + IN UINT64 StartAddress, >=20 > + IN UINT64 NumberOfPages >=20 > + ); >=20 > + >=20 > +/** >=20 > + This function extends one of the RTMR measurement register >=20 > + in TDCS with the provided extension data in memory. >=20 > + RTMR extending supports SHA384 which length is 48 bytes. >=20 > + >=20 > + @param[in] Data Point to the data to be extended >=20 > + @param[in] DataLen Length of the data. Must be 48 >=20 > + @param[in] Index RTMR index >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return EFI_INVALID_PARAMETER >=20 > + @return EFI_DEVICE_ERROR >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdExtendRtmr( >=20 > + IN UINT32 *Data, >=20 > + IN UINT32 DataLen, >=20 > + IN UINT8 PcrIndex >=20 > + ); >=20 > + >=20 > +/** >=20 > + The TDCALL instruction causes a VM exit to the Intel TDX module. = It is >=20 > + used to call guest-side Intel TDX functions, either local or a TD = exit >=20 > + to the host VMM, as selected by Leaf. >=20 > + Leaf functions are described at = =20 > + www/us/en/develop/articles/intel-trust-domain-extensions.html> >=20 > + >=20 > + @param[in] Leaf Leaf number of TDCALL instruction >=20 > + @param[in] Arg1 Arg1 >=20 > + @param[in] Arg2 Arg2 >=20 > + @param[in] Arg3 Arg3 >=20 > + @param[in,out] Results Returned result of the Leaf function >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return Other See individual leaf functions >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdCall( >=20 > + IN UINT64 Leaf, >=20 > + IN UINT64 Arg1, >=20 > + IN UINT64 Arg2, >=20 > + IN UINT64 Arg3, >=20 > + IN OUT VOID *Results >=20 > + ); >=20 > + >=20 > +/** >=20 > + TDVMALL is a leaf function 0 for TDCALL. It helps invoke services = from the >=20 > + host VMM to pass/receive information. >=20 > + >=20 > + @param[in] Leaf Number of sub-functions >=20 > + @param[in] Arg1 Arg1 >=20 > + @param[in] Arg2 Arg2 >=20 > + @param[in] Arg3 Arg3 >=20 > + @param[in] Arg4 Arg4 >=20 > + @param[in,out] Results Returned result of the sub-function >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return Other See individual sub-functions >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdVmCall ( >=20 > + IN UINT64 Leaf, >=20 > + IN UINT64 Arg1, >=20 > + IN UINT64 Arg2, >=20 > + IN UINT64 Arg3, >=20 > + IN UINT64 Arg4, >=20 > + IN OUT VOID *Results >=20 > + ); >=20 > + >=20 > +/** >=20 > + This function enable the TD guest to request the VMM to emulate = CPUID >=20 > + operation, especially for non-architectural, CPUID leaves. >=20 > + >=20 > + @param[in] Eax Main leaf of the CPUID >=20 > + @param[in] Ecx Sub-leaf of the CPUID >=20 > + @param[out] Results Returned result of CPUID operation >=20 > + >=20 > + @return EFI_SUCCESS >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdVmCallCpuid ( >=20 > + IN UINT64 Eax, >=20 > + IN UINT64 Ecx, >=20 > + OUT VOID *Results >=20 > + ); >=20 > +#endif >=20 > diff --git a/MdePkg/Include/Protocol/Tdx.h = b/MdePkg/Include/Protocol/Tdx.h > new file mode 100644 > index 0000000000..d3e1eae135 > --- /dev/null > +++ b/MdePkg/Include/Protocol/Tdx.h > @@ -0,0 +1,22 @@ > +/** @file >=20 > + Tcg for Intel TDX definitions. >=20 > + >=20 > +Copyright (c) 2020 - 2021, Intel Corporation. All rights = reserved.
>=20 > +SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > + >=20 > +#ifndef __TCG_TDX_H__ >=20 > +#define __TCG_TDX_H__ >=20 > + >=20 > +#include >=20 > + >=20 > +#define TCG_TDX_EVENT_DATA_SIGNATURE SIGNATURE_32 ('T', 'D', 'X', > 'S') >=20 > + >=20 > +#define TD_TCG2_PROTOCOL_GUID \ >=20 > + {0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, > 0x6b }} >=20 > +extern EFI_GUID gTdTcg2ProtocolGuid; >=20 > + >=20 > + >=20 > +#endif >=20 > diff --git a/MdePkg/Library/TdxLib/TdxLibNull.c > b/MdePkg/Library/TdxLib/TdxLibNull.c > new file mode 100644 > index 0000000000..8d759e4d33 > --- /dev/null > +++ b/MdePkg/Library/TdxLib/TdxLibNull.c > @@ -0,0 +1,155 @@ > +/** @file >=20 > + Null instance of TdxLib. >=20 > + >=20 > + Copyright (c) 2020 - 2021, Intel Corporation. All rights = reserved.
>=20 > + This program and the accompanying materials >=20 > + are licensed and made available under the terms and conditions of = the > BSD License >=20 > + which accompanies this distribution. The full text of the license = may be > found at >=20 > + http://opensource.org/licenses/bsd-license.php >=20 > + >=20 > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, >=20 > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. >=20 > + >=20 > +**/ >=20 > + >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > + >=20 > +/** >=20 > + This function retrieve TDREPORT_STRUCT structure from TDX. >=20 > + The struct contains the measurements/configuration information of >=20 > + the guest TD that called the function, measurements/configuratio >=20 > + information of the TDX-SEAM module and a REPORTMACSTRUCT. >=20 > + The REPORTMACSTRUCT is integrity protected with a MAC and >=20 > + contains the hash of the measurements and configuration >=20 > + as well as additional REPORTDATA provided by the TD software. >=20 > + >=20 > + AdditionalData, a 64-byte value, is provided by the guest TD >=20 > + to be included in the TDREPORT >=20 > + >=20 > + @param[in,out] Report Holds the TEREPORT_STRUCT. >=20 > + @param[in] ReportSize Size of the report. It must be >=20 > + larger than 1024B. >=20 > + @param[in] AdditionalData Point to the additional data. >=20 > + @param[in] AdditionalDataSize Size of the additional data. >=20 > + If AdditionalData !=3D NULL, > then >=20 > + this value must be 64B. >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return EFI_INVALID_PARAMETER >=20 > + @return EFI_DEVICE_ERROR >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdReport( >=20 > + IN OUT UINT8 *Report, >=20 > + IN UINT32 ReportSize, >=20 > + IN UINT8 *AdditionalData, >=20 > + IN UINT32 AdditionalDataSize >=20 > + ) >=20 > +{ >=20 > + return EFI_UNSUPPORTED; >=20 > +} >=20 > + >=20 > +/** >=20 > + This function accept a pending private page, and initialize the = page to >=20 > + all-0 using the TD ephemeral private key. >=20 > + >=20 > + @param[in] StartAddress Guest physical address of the private > page >=20 > + to accept. >=20 > + @param[in] NumberOfPages Number of the pages to be accepted. >=20 > + >=20 > + @return EFI_UNSUPPORTED >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdAcceptPages ( >=20 > + IN UINT64 StartAddress, >=20 > + IN UINT64 NumberOfPages >=20 > + ) >=20 > +{ >=20 > + return EFI_UNSUPPORTED; >=20 > +} >=20 > + >=20 > +/** >=20 > + The TDCALL instruction causes a VM exit to the Intel TDX module. = It is >=20 > + used to call guest-side Intel TDX functions, either local or a TD = exit >=20 > + to the host VMM, as selected by Leaf. >=20 > + Leaf functions are described at = =20 > + www/us/en/develop/articles/intel-trust-domain-extensions.html> >=20 > + >=20 > + @param[in] Leaf Leaf number of TDCALL instruction >=20 > + @param[in] Arg1 Arg1 >=20 > + @param[in] Arg2 Arg2 >=20 > + @param[in] Arg3 Arg3 >=20 > + @param[in,out] Results Returned result of the Leaf function >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return Other See individual leaf functions >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdCall( >=20 > + IN UINT64 Leaf, >=20 > + IN UINT64 Arg1, >=20 > + IN UINT64 Arg2, >=20 > + IN UINT64 Arg3, >=20 > + IN OUT VOID *Results >=20 > + ) >=20 > +{ >=20 > + return EFI_UNSUPPORTED; >=20 > +} >=20 > + >=20 > +/** >=20 > + TDVMALL is a leaf function 0 for TDCALL. It helps invoke services = from the >=20 > + host VMM to pass/receive information. >=20 > + >=20 > + @param[in] Leaf Number of sub-functions >=20 > + @param[in] Arg1 Arg1 >=20 > + @param[in] Arg2 Arg2 >=20 > + @param[in] Arg3 Arg3 >=20 > + @param[in] Arg4 Arg4 >=20 > + @param[in,out] Results Returned result of the sub-function >=20 > + >=20 > + @return EFI_SUCCESS >=20 > + @return Other See individual sub-functions >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdVmCall ( >=20 > + IN UINT64 Leaf, >=20 > + IN UINT64 Arg1, >=20 > + IN UINT64 Arg2, >=20 > + IN UINT64 Arg3, >=20 > + IN UINT64 Arg4, >=20 > + IN OUT VOID *Results >=20 > + ) >=20 > +{ >=20 > + return EFI_UNSUPPORTED; >=20 > +} >=20 > + >=20 > +/** >=20 > + This function enable the TD guest to request the VMM to emulate = CPUID >=20 > + operation, especially for non-architectural, CPUID leaves. >=20 > + >=20 > + @param[in] Eax Main leaf of the CPUID >=20 > + @param[in] Ecx Sub-leaf of the CPUID >=20 > + @param[in,out] Results Returned result of CPUID operation >=20 > + >=20 > + @return EFI_SUCCESS >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +TdVmCallCpuid ( >=20 > + IN UINT64 Eax, >=20 > + IN UINT64 Ecx, >=20 > + IN OUT VOID *Results >=20 > + ) >=20 > +{ >=20 > + return EFI_UNSUPPORTED; >=20 > +} >=20 > diff --git a/MdePkg/Library/TdxLib/TdxLibNull.inf > b/MdePkg/Library/TdxLib/TdxLibNull.inf > new file mode 100644 > index 0000000000..0d07595a8c > --- /dev/null > +++ b/MdePkg/Library/TdxLib/TdxLibNull.inf > @@ -0,0 +1,33 @@ > +## @file >=20 > +# Null Tdx library instance >=20 > +# >=20 > +# Copyright (c) 2020 - 2021, Intel Corporation. All rights = reserved.
>=20 > +# This program and the accompanying materials >=20 > +# are licensed and made available under the terms and conditions of = the BSD > License >=20 > +# which accompanies this distribution. The full text of the license = may be > found at >=20 > +# http://opensource.org/licenses/bsd-license.php. >=20 > +# >=20 > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, >=20 > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. >=20 > +# >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010005 >=20 > + BASE_NAME =3D TdxLibNull >=20 > + FILE_GUID =3D > 05C5E621-FC66-4420-9C80-F0DE9E5B95FF >=20 > + MODULE_TYPE =3D BASE >=20 > + VERSION_STRING =3D 1.0 >=20 > + LIBRARY_CLASS =3D TdxLib >=20 > + >=20 > +# >=20 > +# The following information is for reference only and not required by = the > build tools. >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D X64 >=20 > +# >=20 > + >=20 > +[Sources] >=20 > + TdxLibNull.c >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > -- > 2.29.2.windows.2 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#72548): = https://edk2.groups.io/g/devel/message/72548 > Mute This Topic: https://groups.io/mt/81191034/4905953 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [gaoliming@byosoft.com.cn] > -=3D-=3D-=3D-=3D-=3D-=3D >=20