Skip to content

Commit d97f530

Browse files
suncepingmergify[bot]
authored andcommitted
UefiCpuPkg: Add NULL TdxMeasurementLib instance
Add NULL instance of TdxMeasurementLib. Cc: Ray Ni <[email protected]> Cc: Jiaxin Wu <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Gerd Hoffmann <[email protected]> Signed-off-by: Min Xu <[email protected]> Signed-off-by: Ceping Sun <[email protected]>
1 parent 94bfc6f commit d97f530

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/** @file
2+
NULL instance of TdxMeasurementLib
3+
Copyright (c) 2025, Intel Corporation. All rights reserved.<BR>
4+
SPDX-License-Identifier: BSD-2-Clause-Patent
5+
**/
6+
7+
#include <Base.h>
8+
#include <PiPei.h>
9+
#include <Library/TdxMeasurementLib.h>
10+
11+
/**
12+
According to UEFI Spec 2.10 Section 38.4.1:
13+
The following table shows the TPM PCR index mapping and CC event log measurement
14+
register index interpretation for Intel TDX, where MRTD means Trust Domain Measurement
15+
Register and RTMR means Runtime Measurement Register
16+
// TPM PCR Index | CC Measurement Register Index | TDX-measurement register
17+
// ------------------------------------------------------------------------
18+
// 0 | 0 | MRTD
19+
// 1, 7 | 1 | RTMR[0]
20+
// 2~6 | 2 | RTMR[1]
21+
// 8~15 | 3 | RTMR[2]
22+
@param[in] PCRIndex Index of the TPM PCR
23+
@retval UINT32 Index of the CC Event Log Measurement Register Index
24+
@retval CC_MR_INDEX_INVALID Invalid MR Index
25+
**/
26+
UINT32
27+
EFIAPI
28+
TdxMeasurementMapPcrToMrIndex (
29+
IN UINT32 PCRIndex
30+
)
31+
{
32+
return CC_MR_INDEX_INVALID;
33+
}
34+
35+
/**
36+
* Calculate the sha384 of input Data and extend it to RTMR register.
37+
*
38+
* @param RtmrIndex Index of the RTMR register
39+
* @param DataToHash Data to be hashed
40+
* @param DataToHashLen Length of the data
41+
* @param Digest Hash value of the input data
42+
* @param DigestLen Length of the hash value
43+
*
44+
* @retval EFI_SUCCESS Successfully hash and extend to RTMR
45+
* @retval Others Other errors as indicated
46+
*/
47+
EFI_STATUS
48+
EFIAPI
49+
TdxMeasurementHashAndExtendToRtmr (
50+
IN UINT32 RtmrIndex,
51+
IN VOID *DataToHash,
52+
IN UINTN DataToHashLen,
53+
OUT UINT8 *Digest,
54+
IN UINTN DigestLen
55+
)
56+
{
57+
return EFI_UNSUPPORTED;
58+
}
59+
60+
/**
61+
* Build GuidHob for Tdx CC measurement event.
62+
*
63+
* @param RtmrIndex RTMR index
64+
* @param EventType Event type
65+
* @param EventData Event data
66+
* @param EventSize Size of event data
67+
* @param HashValue Hash value
68+
* @param HashSize Size of hash
69+
*
70+
* @retval EFI_SUCCESS Successfully build the GuidHobs
71+
* @retval Others Other error as indicated
72+
*/
73+
EFI_STATUS
74+
EFIAPI
75+
TdxMeasurementBuildGuidHob (
76+
UINT32 RtmrIndex,
77+
UINT32 EventType,
78+
UINT8 *EventData,
79+
UINT32 EventSize,
80+
UINT8 *HashValue,
81+
UINT32 HashSize
82+
)
83+
{
84+
return EFI_UNSUPPORTED;
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## @file
2+
# TdxMeasurementLib NULL instance
3+
#
4+
# Copyright (c) 2025, Intel Corporation. All rights reserved.<BR>
5+
#
6+
# SPDX-License-Identifier: BSD-2-Clause-Patent
7+
#
8+
##
9+
10+
[Defines]
11+
INF_VERSION = 0x00010005
12+
BASE_NAME = TdxMeasurementNullLib
13+
FILE_GUID = 975d11ff-b11e-4cf4-b453-6d93a9ea8d7b
14+
MODULE_TYPE = BASE
15+
VERSION_STRING = 1.0
16+
LIBRARY_CLASS = TdxMeasurementLib
17+
18+
#
19+
# The following information is for reference only and not required by the build tools.
20+
#
21+
# VALID_ARCHITECTURES = X64
22+
#
23+
24+
[Sources]
25+
TdxMeasurementLibNull.c
26+
27+
[Packages]
28+
MdePkg/MdePkg.dec
29+
UefiCpuPkg/UefiCpuPkg.dec
30+
31+
[LibraryClasses]
32+
BaseLib

UefiCpuPkg/UefiCpuPkg.dsc

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
6363
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
6464
CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
65+
TdxMeasurementLib|UefiCpuPkg/Library/TdxMeasurementLibNull/TdxMeasurementLibNull.inf
6566
AmdSvsmLib|UefiCpuPkg/Library/AmdSvsmLibNull/AmdSvsmLibNull.inf
6667
MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
6768
SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf
@@ -171,6 +172,7 @@
171172
UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
172173
UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
173174
UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
175+
UefiCpuPkg/Library/TdxMeasurementLibNull/TdxMeasurementLibNull.inf
174176
UefiCpuPkg/Library/AmdSvsmLibNull/AmdSvsmLibNull.inf
175177
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
176178
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf

0 commit comments

Comments
 (0)