[edk2-devel] [PATCH V1 3/3] OvmfPkg/SecTpmMeasurementLib: Fix the mapping error of PCR and RTMR index

Min Xu min.m.xu at intel.com
Wed Dec 14 07:14:19 UTC 2022


From: Min M Xu <min.m.xu at intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4179

TDVF has the feature to do RTMR measurement in SEC phase. In the same time
it builds a GUID hob which carries the hash value of the measurement so
that in DXE phase a td event can be created based on this GUID Hob. There
is a mapping error between TPM PCR index and RTMR index according to UEFI
2.10. That PCR6 is missing in the mapping. This patch fixes this issue.

Cc: Erdem Aktas <erdemaktas at google.com> [ruleof2]
Cc: James Bottomley <jejb at linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao at intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky at amd.com> [tlendacky]
Cc: Arti Gupta <ARGU at microsoft.com>
Signed-off-by: Min Xu <min.m.xu at intel.com>
---
 .../Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.c b/SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.c
index 38887b172dc0..36bfa373fe0f 100644
--- a/SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.c
+++ b/SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.c
@@ -33,12 +33,11 @@ typedef struct {
 /**
   Get the mapped RTMR index based on the input PCRIndex.
   RTMR[0]  => PCR[1,7]
-  RTMR[1]  => PCR[2,3,4,5]
+  RTMR[1]  => PCR[2,3,4,5,6]
   RTMR[2]  => PCR[8~15]
   RTMR[3]  => NA
   Note:
     PCR[0] is mapped to MRTD and should not appear here.
-    PCR[6] is reserved for OEM. It is not used.
 
    @param[in] PCRIndex The input PCR index
 
@@ -51,7 +50,7 @@ GetMappedRtmrIndex (
 {
   UINT8  RtmrIndex;
 
-  if ((PCRIndex == 6) || (PCRIndex == 0) || (PCRIndex > 15)) {
+  if ((PCRIndex == 0) || (PCRIndex > 15)) {
     DEBUG ((DEBUG_ERROR, "Invalid PCRIndex(%d) map to MR Index.\n", PCRIndex));
     ASSERT (FALSE);
     return INVALID_PCR2MR_INDEX;
@@ -60,7 +59,7 @@ GetMappedRtmrIndex (
   RtmrIndex = 0;
   if ((PCRIndex == 1) || (PCRIndex == 7)) {
     RtmrIndex = 0;
-  } else if ((PCRIndex >= 2) && (PCRIndex < 6)) {
+  } else if ((PCRIndex >= 2) && (PCRIndex <= 6)) {
     RtmrIndex = 1;
   } else if ((PCRIndex >= 8) && (PCRIndex <= 15)) {
     RtmrIndex = 2;
-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97349): https://edk2.groups.io/g/devel/message/97349
Mute This Topic: https://groups.io/mt/95662133/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list