From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.2598.1573002087018347422 for ; Tue, 05 Nov 2019 17:01:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=021332772c=derek.lin2@hpe.com) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xA611Pgl026551; Wed, 6 Nov 2019 01:01:26 GMT Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 2w3dfpaphb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Nov 2019 01:01:26 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id EEDFD91; Wed, 6 Nov 2019 01:01:06 +0000 (UTC) Received: from SZC0PA4FXD.asiapacific.hpqcorp.net (szc0pa4fxd.asiapacific.hpqcorp.net [10.43.42.135]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id BC3A136; Wed, 6 Nov 2019 01:01:04 +0000 (UTC) From: "Lin, Derek (HPS SW)" To: derek.lin2@hpe.com, devel@edk2.groups.io Cc: jason.spottswood@hpe.com, jiewen.yao@intel.com, jian.j.wang@intel.com, chao.b.zhang@intel.com Subject: [PATCH] SecurityPkg: Fix TPM2 ACPI measurement. Date: Wed, 6 Nov 2019 09:00:47 +0800 Message-Id: <20191106010047.489176-1-derek.lin2@hpe.com> X-Mailer: git-send-email 2.20.1.windows.1 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-11-05_09:2019-11-05,2019-11-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 mlxlogscore=851 adultscore=0 spamscore=0 phishscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1911060008 Content-Transfer-Encoding: 8bit We have discussed in this thread. https://edk2.groups.io/g/devel/topic/32205028 Before the change, TPM FW upgrade will impact TPM2 ACPI PCR value because TPM2 ACPI HID include FW version. This change make the measurement before TPM2 HID fixup. So, after TPM FW upgrade, the ACPI PCR record remains the same. Signed-off-by: Derek Lin --- SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c index bd786bf479..54966c83ce 100644 --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c @@ -664,7 +664,22 @@ PublishAcpiTable ( )); // - // Update TPM2 HID before measuring it to PCR + // Measure to PCR[0] with event EV_POST_CODE ACPI DATA. + // The measurement has to be done before UpdateHID since TPM2 ACPI HID + // imply TPM Firmware Version. Otherwise, the PCR record would be + // different after TPM FW update. + // + TpmMeasureAndLogData( + 0, + EV_POST_CODE, + EV_POSTCODE_INFO_ACPI_DATA, + ACPI_DATA_LEN, + Table, + TableSize + ); + + // + // Update TPM2 HID after measuring it to PCR // Status = UpdateHID(Table); if (EFI_ERROR(Status)) { @@ -694,19 +709,6 @@ PublishAcpiTable ( } } - // - // Measure to PCR[0] with event EV_POST_CODE ACPI DATA - // - TpmMeasureAndLogData( - 0, - EV_POST_CODE, - EV_POSTCODE_INFO_ACPI_DATA, - ACPI_DATA_LEN, - Table, - TableSize - ); - - ASSERT (Table->OemTableId == SIGNATURE_64 ('T', 'p', 'm', '2', 'T', 'a', 'b', 'l')); CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) ); mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS)); -- 2.20.1.windows.1