]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/SecTpmMeasurementLib: Fix the mapping error of PCR and RTMR index
authorMin M Xu <min.m.xu@intel.com>
Wed, 14 Dec 2022 07:14:19 +0000 (15:14 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 15 Dec 2022 03:07:33 +0000 (03:07 +0000)
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@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.c

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