From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.52]) by mx.groups.io with SMTP id smtpd.web12.9623.1634649675567047537 for ; Tue, 19 Oct 2021 06:21:17 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Hgyc87Bz; spf=pass (domain: arm.com, ip: 40.107.1.52, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1mqsMQ5ZhdQybgTlzhRvoiYVC09VybAGIC82n4r2uI8=; b=Hgyc87BzlheDlsWikvNBdUT472JimgQaDRgw57/hWq5v5ZQ4mITE9Oq/+082yiSTCvR8T1kgI/UoReDyFLibCiFVb2XJN2lfLSl7qaA7pINiMGR1+fcYDQW4jxEeLWE6ETigQdV4VE7Tdk10k+O5MEMvw2XaS16OdU/nkwYsjnE= Received: from AS8P189CA0009.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::19) by DB8PR08MB5419.eurprd08.prod.outlook.com (2603:10a6:10:118::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Tue, 19 Oct 2021 13:21:11 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31f:cafe::29) by AS8P189CA0009.outlook.office365.com (2603:10a6:20b:31f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Tue, 19 Oct 2021 13:21:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT042.mail.protection.outlook.com (10.152.17.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 13:21:10 +0000 Received: ("Tessian outbound 16951d3c485e:v103"); Tue, 19 Oct 2021 13:21:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 222baed81fc34457 X-CR-MTA-TID: 64aa7808 Received: from a35f4817b9a4.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DC4AE312-0204-4FDB-9154-7B509A87EC3A.1; Tue, 19 Oct 2021 13:21:04 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a35f4817b9a4.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 19 Oct 2021 13:21:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QT0G74g2G/VIpfFofrBV2HSUPugCEyJn0jpO6hiIkybAUUuQvLcrvPhFLd+/fVkwuBRZhUEA+DVHLZSea7dGCelsYehHF7rbiJqri2ncYRQaaCe2kWVREvzqz2PGnjg0Kn6GYEQNTbUWW1a0CcnQtC/Toq9LHGp76u/OrIm1DD/Ev9z9vscmgK77ns+x9NA8KCcoLTqQZe6gFPhJ8KpklA1BIccvXd8wMIC0n1eusqsxVwxv8Iw3lONxUpCCe56y8NPcr4jEY3xPBZHeizdb7/9GgHoQZaaFsNVUVpEvE3U57CFQ9G6/epFWDD81uQDW/0rtu46f1jLgfZ+xeLXr9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1mqsMQ5ZhdQybgTlzhRvoiYVC09VybAGIC82n4r2uI8=; b=ICAieHPuoRZ7syEEqaEWTDuMUDIvFhuwP5sW28exYV+EGPbet9gxdx2BqRrlkUV6vHSpPDRZAfAYdD87PCSLE8Tsrk0zUMKjY5TkwFwCQvVJ3Fom843Waoc/ZWYSEZKD913K67BLGTXFfbIq4PLoHnAdNWYHfhTTtZIONEP5e2LvXU3m4tPpuL4fd4fepXUHXSKPKCFRYAs771/Rxi8ltphB3BD5yZV4bcboWBOJ6JUDFsCwBkIISjWb1HGf5XvWq4myAQ6Sp2MAV3rAUAgDUT9K3mBEw6yPZEgBO6ZkQlu0jUJKfuSWnQ6Q5TYJ9pfZdGoHWb1jAPD6+FagOTCP9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1mqsMQ5ZhdQybgTlzhRvoiYVC09VybAGIC82n4r2uI8=; b=Hgyc87BzlheDlsWikvNBdUT472JimgQaDRgw57/hWq5v5ZQ4mITE9Oq/+082yiSTCvR8T1kgI/UoReDyFLibCiFVb2XJN2lfLSl7qaA7pINiMGR1+fcYDQW4jxEeLWE6ETigQdV4VE7Tdk10k+O5MEMvw2XaS16OdU/nkwYsjnE= Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AM6PR08MB4167.eurprd08.prod.outlook.com (2603:10a6:20b:ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Tue, 19 Oct 2021 13:21:02 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65%4]) with mapi id 15.20.4608.018; Tue, 19 Oct 2021 13:21:02 +0000 Subject: Re: [edk2-devel] [PATCH V2 1/3] MdePkg: Introduce TdProtocol for TD-Guest firmware To: devel@edk2.groups.io, min.m.xu@intel.com Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Jiewen Yao , Jian J Wang , Ken Lu , nd , Joey Gouly References: From: "Sami Mujawar" Message-ID: <92fc7754-8ac4-40b5-14ee-1d2b12555ea7@arm.com> Date: Tue, 19 Oct 2021 14:21:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: X-ClientProxiedBy: LO4P123CA0040.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::9) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 Received: from [10.1.196.43] (217.140.106.52) by LO4P123CA0040.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Tue, 19 Oct 2021 13:21:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4493c09-ac3f-4372-887c-08d993035152 X-MS-TrafficTypeDiagnostic: AM6PR08MB4167:|DB8PR08MB5419: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 52jM1eHt/FcVoKHRFIm+njU5DIQLZBEWMbD1V0ihJD0WBtNsPcq/VBJrOJ7cqQeK3nOv3fzuSFiFewruTYh5rvVeEiCusi++i59X8YhzwFEYjZrVCmf5rhw50VnfkDCmOSuAgekpUoiJ6z40koWxFmaWGhfj3/I2Zoe/9abrQO5z5UeKYvNwxMJOw+88jNj9qgZm/11o5E0h7oSiw80CVtHPAtoRvfmr6mk+2xdcPBErePdVkXWSnkiqobYZZlYXdFISe2P0d+6RH+/zRoGSiz6r5e7NaKl5+zIvUfJtbqxk3r3wOo+mYnF6CioHtcU9f+refccgNtkg1VqVNJYRs3wVobSHTmbq+xLyhiW8bOpA9Naf+oi7w20kvBk2TWSpK4boDMQpL+I0jQuvcQ5EdSwTne0lobTQgMTmRvvhX80mq5gmqlbIbhSywrT3DEzQ+P8e/9jcHiZjDQxUo/W5kdd5ms7wdQbCQNG4C1EHuo2lXoXpgFeVA2ZtGoxe6AhiXg3uRacNK4ZJ3nDR+nb9AbCZhjdux5fahD0B2DANQFeIUpdvIMxwJCvZOcJijPEZPd53p90/uLsYfaIXp2sko/F4DvJI8sKGH/zLUzxppS5WrFUWkY2CGrcbygFiCblGHlWTP6BaUaefIdvjAKXuKBG5HbMNVji62inFXQcGITVdBzBjK1vJo/maIw8GnGsRHXMuDAj+51GPbH7Tuu2tvdcikifbyTVZASmpr1A+bfrWnMrQqOHzbk5iqoTMobnkClEK/1mwj9mxWLQiGskWWvg9HFhET7vWImclzsmqO1VtP7hazPNqOxWmXJxZZf0AiR+Hslw6n5w9Wv0TbX2d/sEbwOiFI2DpH+jrKSc5YU6Oaj0OC8vbvWf6n360e+6lz1KEuweEbwBwdL1NvISRew== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(366004)(66556008)(6666004)(66476007)(956004)(5660300002)(16576012)(6486002)(86362001)(316002)(36756003)(4326008)(38350700002)(2616005)(53546011)(508600001)(31696002)(8676002)(26005)(30864003)(38100700002)(966005)(83380400001)(44832011)(31686004)(54906003)(52116002)(66946007)(8936002)(186003)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4167 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 718b3f1b-01fb-4e22-30f2-08d993034c13 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2EDIrFqjoayrw5JWRrz+v4zfR8D211WTLgxk1lI5fT0jWAGvi1W2u9CmdmIeZRRBFffIWX5XGE9NAvY4NxTSyucM4p2EVHEe4ZdZrhm2rcDnS9pvSuFzeITNh/QNxPuD0MnbeCR81g+w0a8l1kDQvWvL4vIuFjOk1rGO81BVdz4DwA22j054oOCXsL8YM/UpDPt+CFc+50DUXldh0d9icb41DI44ah/O5ZSi5gbFmE2/rfTH5DvjYRZTnuUG7cqFCkM549fzO3I5/NiAR5uqDi55tM+EvYrWqgLPHq9c+d3s6R07uazlK9jOQtbqW2LXZEscuOS5BrjFI+hu5nFgY6D4q8PiVL53bZ0LT0gbJMqGzwxZUh/vtMRweXX3Nq2Smi33ZKJeaeqYnVm71MZzgl9Vf8MZcz+sFY079nojGga/uABVqU7NUxvdwIcDnZ+NgDqERD04mqJXaRSQ9wpjxqf2jyjY3u3lS/I7TwBSlR37K4wsvEHVnAomC64eKpMVZeujrGNJTSFXQgol0QgySv5InQl2PzLxLhWSQPRq+MWNvdiXzywmy53jLhOJngo9ozWwIMjJVtXwXDqFIvYtWkiSs/OqbCCsZcwiZ3XTcycZ2D+0avAKCt/2Q9BLhachg1Z1Be9WgkniWeeJR4DFRgD+rUqf5KPBmZklKKWEfIJ2jmKXwDKe04HGnCOIlHEZZ8rHhaQWJuGQ3MkS2MthSKI9CJi0pwI552iNcQZMQwfD6kG1PDWIseKsyY4rl6MjTt/UeI0jsYSI2xVQrWWuix8FDgoZoY5+gymNE3ypLclQARu7/vTPrI2a1+NtSf/A53Jks6RYPjpR6oh9vDsSvexPyt7MAbcnsoXWiqXB1Og= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(6029001)(4636009)(36840700001)(46966006)(36860700001)(6666004)(54906003)(508600001)(2616005)(83380400001)(86362001)(70206006)(31696002)(53546011)(6486002)(70586007)(44832011)(8676002)(316002)(4326008)(82310400003)(8936002)(47076005)(2906002)(16576012)(356005)(966005)(5660300002)(36756003)(186003)(31686004)(81166007)(336012)(30864003)(956004)(26005)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 13:21:10.7364 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4493c09-ac3f-4372-887c-08d993035152 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5419 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Hi Min, Jiewen, Thank you for this patch. I think the protocol definition can be made architecturally neutral with a few modifications marked inline as [SAMI]. I am fine with renaming the protocol to either EFI_TEE_MEASUREMENT_PROTOCOL or EFI_CCAM_PROTOCOL. Similarly, some of the data structures, variables, etc. would need renaming as well. Please let me know if you have any queries. Regards, Sami Mujawar On 08/10/2021 06:21 AM, Min Xu via groups.io wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3625 > > If TD-Guest firmware supports measurement and an event is created, > TD-Guest firmware is designed to report the event log with the same data > structure in TCG-Platform-Firmware-Profile specification with > EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 format. > > The TD-Guest firmware supports measurement, the TD Guest Firmware is > designed to produce EFI_TD_PROTOCOL with new GUID EFI_TD_PROTOCOL_GUID > to report event log and provides hash capability. > > https://software.intel.com/content/dam/develop/external/us/en/documents/ > intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf > Section 4.3.2 includes the EFI_TD_PROTOCOL. > > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Jiewen Yao > Cc: Jian J Wang > Cc: Ken Lu > Reviewed-by: Jiewen Yao > Signed-off-by: Min Xu > --- > MdePkg/Include/Protocol/TdProtocol.h | 305 +++++++++++++++++++++++++++ > MdePkg/MdePkg.dec | 3 + > 2 files changed, 308 insertions(+) > create mode 100644 MdePkg/Include/Protocol/TdProtocol.h > > diff --git a/MdePkg/Include/Protocol/TdProtocol.h b/MdePkg/Include/Protocol/TdProtocol.h > new file mode 100644 > index 000000000000..89b09928d33a > --- /dev/null > +++ b/MdePkg/Include/Protocol/TdProtocol.h > @@ -0,0 +1,305 @@ > +/** @file > + If TD-Guest firmware supports measurement and an event is created, TD-Guest > + firmware is designed to report the event log with the same data structure > + in TCG-Platform-Firmware-Profile specification with > + EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 format. > + > + The TD-Guest firmware supports measurement, the TD Guest Firmware is designed > + to produce EFI_TD_PROTOCOL with new GUID EFI_TD_PROTOCOL_GUID to report > + event log and provides hash capability. > + > +Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > + > +#ifndef TD_PROTOCOL_H_ > +#define TD_PROTOCOL_H_ > + > +#include > +#include > +#include [SAMI] Maybe the Tpm20.h include is not required here. Can you check, please? > + > + > +#define EFI_TD_PROTOCOL_GUID \ > + { 0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b }} > +extern EFI_GUID gEfiTdProtocolGuid; > + > +typedef struct _EFI_TD_PROTOCOL EFI_TD_PROTOCOL; [SAMI] I think this could be renamed to either EFI_TEE_MEASUREMENT_PROTOCOL or EFI_CCAM_PROTOCOL. Similarly, the usage of _TD_ would need to be replaced accordingly. > + > +typedef struct { > + UINT8 Major; > + UINT8 Minor; > +} EFI_TD_VERSION; > + > +typedef UINT32 EFI_TD_EVENT_LOG_BITMAP; > +typedef UINT32 EFI_TD_EVENT_LOG_FORMAT; > +typedef UINT32 EFI_TD_EVENT_ALGORITHM_BITMAP; > +typedef UINT32 EFI_TD_MR_INDEX; > + > +#define EFI_TD_EVENT_LOG_FORMAT_TCG_2 0x00000002 > +#define EFI_TD_BOOT_HASH_ALG_SHA384 0x00000004 [SAMI] It is good that the values for these macros match that of TCG2. I believe it should be possible to extend these to add macros for other algorithms in the future. > + > +// > +// This bit is shall be set when an event shall be extended but not logged. > +// > +#define EFI_TD_FLAG_EXTEND_ONLY 0x0000000000000001 > +// > +// This bit shall be set when the intent is to measure a PE/COFF image. > +// > +#define EFI_TD_FLAG_PE_COFF_IMAGE 0x0000000000000010 > + > +#define MR_INDEX_MRTD 0 > +#define MR_INDEX_RTMR0 1 > +#define MR_INDEX_RTMR1 2 > +#define MR_INDEX_RTMR2 3 > +#define MR_INDEX_RTMR3 4 > + [SAMI] I think these indexes could go to a TD specific include file Or the indexes could be defined generically. May be it would be good to introduce a PcdMaxMrIndex that is configurable for different architectures. This may be useful should any asserts/checks are needed in the code. > +// > +// This bit shall be set when the intent is to measure a PE/COFF image. > +// > +#define PE_COFF_IMAGE 0x0000000000000010 > + [SAMI] I think this macro is not needed. > +#pragma pack (1) > + > +#define EFI_TD_EVENT_HEADER_VERSION 1 > + > +typedef struct { > + // > + // Size of the event header itself (sizeof(EFI_TD_EVENT_HEADER)). > + // > + UINT32 HeaderSize; > + // > + // Header version. For this version of this specification, the value shall be 1. > + // > + UINT16 HeaderVersion; > + // > + // Index of the MR that shall be extended. > + // > + EFI_TD_MR_INDEX MrIndex; > + // > + // Type of the event that shall be extended (and optionally logged). > + // > + UINT32 EventType; > +} EFI_TD_EVENT_HEADER; > + > +typedef struct { > + // > + // Total size of the event including the Size component, the header and the Event data. > + // > + UINT32 Size; > + EFI_TD_EVENT_HEADER Header; > + UINT8 Event[1]; > +} EFI_TD_EVENT; > + > +#pragma pack() > + > + > +typedef struct { > + // > + // Allocated size of the structure > + // > + UINT8 Size; > + // > + // Version of the EFI_TD_BOOT_SERVICE_CAPABILITY structure itself. > + // For this version of the protocol, the Major version shall be set to 1 > + // and the Minor version shall be set to 1. > + // > + EFI_TD_VERSION StructureVersion; > + // > + // Version of the EFI TD protocol. > + // For this version of the protocol, the Major version shall be set to 1 > + // and the Minor version shall be set to 1. > + // > + EFI_TD_VERSION ProtocolVersion; [SAMI] Should the protocol version be 1.0 (Major.Minor), as this is the first introduction. Same for the StructureVersion field above. > + // > + // Supported hash algorithms > + // > + EFI_TD_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap; > + // > + // Bitmap of supported event log formats > + // > + EFI_TD_EVENT_LOG_BITMAP SupportedEventLogs; > + > + // > + // False = TD not present > + // > + BOOLEAN TdPresentFlag; [SAMI] I believe this would need to be renamed to something like TeePresentFlag or CcaPresentFlag or a suitable alternative. > +} EFI_TD_BOOT_SERVICE_CAPABILITY; > + > +/** > + The EFI_TD_PROTOCOL GetCapability function call provides protocol > + capability information and state information. > + > + @param[in] This Indicates the calling context > + @param[in, out] ProtocolCapability The caller allocates memory for a EFI_TD_BOOT_SERVICE_CAPABILITY > + structure and sets the size field to the size of the structure allocated. > + The callee fills in the fields with the EFI protocol capability information > + and the current EFI TD state information up to the number of fields which > + fit within the size of the structure passed in. > + > + @retval EFI_SUCCESS Operation completed successfully. > + @retval EFI_DEVICE_ERROR The command was unsuccessful. > + The ProtocolCapability variable will not be populated. > + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. > + The ProtocolCapability variable will not be populated. > + @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response. > + It will be partially populated (required Size field will be set). > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EFI_TD_GET_CAPABILITY) ( > + IN EFI_TD_PROTOCOL *This, > + IN OUT EFI_TD_BOOT_SERVICE_CAPABILITY *ProtocolCapability > + ); > + > +/** > + The EFI_TD_PROTOCOL Get Event Log function call allows a caller to > + retrieve the address of a given event log and its last entry. > + > + @param[in] This Indicates the calling context > + @param[in] EventLogFormat The type of the event log for which the information is requested. > + @param[out] EventLogLocation A pointer to the memory address of the event log. > + @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the > + address of the start of the last entry in the event log in memory. > + @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would > + have exceeded the area allocated for events, this value is set to TRUE. > + Otherwise, the value will be FALSE and the Event Log will be complete. > + > + @retval EFI_SUCCESS Operation completed successfully. > + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect > + (e.g. asking for an event log whose format is not supported). > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EFI_TD_GET_EVENT_LOG) ( > + IN EFI_TD_PROTOCOL *This, > + IN EFI_TD_EVENT_LOG_FORMAT EventLogFormat, > + OUT EFI_PHYSICAL_ADDRESS *EventLogLocation, > + OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry, > + OUT BOOLEAN *EventLogTruncated > + ); > + > +/** > + The EFI_TD_PROTOCOL HashLogExtendEvent function call provides callers with > + an opportunity to extend and optionally log events without requiring > + knowledge of actual TD commands. > + The extend operation will occur even if this function cannot create an event > + log entry (e.g. due to the event log being full). > + > + @param[in] This Indicates the calling context > + @param[in] Flags Bitmap providing additional information. > + @param[in] DataToHash Physical address of the start of the data buffer to be hashed. > + @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash. > + @param[in] EfiTdEvent Pointer to data buffer containing information about the event. > + > + @retval EFI_SUCCESS Operation completed successfully. > + @retval EFI_DEVICE_ERROR The command was unsuccessful. > + @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs. > + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. > + @retval EFI_UNSUPPORTED The PE/COFF image type is not supported. > +**/ > +typedef > +EFI_STATUS > +(EFIAPI * EFI_TD_HASH_LOG_EXTEND_EVENT) ( > + IN EFI_TD_PROTOCOL *This, > + IN UINT64 Flags, > + IN EFI_PHYSICAL_ADDRESS DataToHash, > + IN UINT64 DataToHashLen, > + IN EFI_TD_EVENT *EfiTdEvent > + ); > + > +/** > + The EFI_TD_PROTOCOL MapPcrToMrIndex function call provides callers > + the info on TPM PCR<-> measurement register mapping information. > + > + In current version, we use below mapping: > + PCR0 -> MRTD (Index 0) > + PCR1 -> RTMR0 (Index 1) > + PCR2~6 -> RTMR1 (Index 2) > + PCR7 -> RTMR0 (Index 1) > + PCR8~15 -> RTMR2 (Index 3) > + [SAMI] I think different architecures may map the PCRs differently. I think the comment could be reworded to a more generic representation of the mapping. Also, I need to check the mailing list if there is a patch that adds the TD protocol implementaiton, and if it could be made generic as well. Maybe the protocol implementation would need to use an architecture specific library that provides the mapping function. [/SAMI] > + @param[in] This Indicates the calling context > + @param[in] PcrIndex TPM PCR index. > + @param[out] MrIndex Measurement register index. > + > + @retval EFI_SUCCESS The MR index is returned. > + @retval EFI_INVALID_PARAMETER The MrIndex is NULL. > + @retval EFI_UNSUPPORTED The PcrIndex is invalid. > +**/ > +typedef > +EFI_STATUS > +(EFIAPI * EFI_TD_MAP_PCR_TO_MR_INDEX) ( > + IN EFI_TD_PROTOCOL *This, > + IN TCG_PCRINDEX PcrIndex, > + OUT EFI_TD_MR_INDEX *MrIndex > + ); > + > +struct _EFI_TD_PROTOCOL { > + EFI_TD_GET_CAPABILITY GetCapability; > + EFI_TD_GET_EVENT_LOG GetEventLog; > + EFI_TD_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; > + EFI_TD_MAP_PCR_TO_MR_INDEX MapPcrToMrIndex; > +}; > + > + > +// > +// TD event log > +// > + > +#pragma pack(1) > + > +// > +// Crypto Agile Log Entry Format. > +// It is similar with TCG_PCR_EVENT2 except the field of MrIndex and PCRIndex. > +// > +typedef struct { > + EFI_TD_MR_INDEX MrIndex; > + UINT32 EventType; > + TPML_DIGEST_VALUES Digests; > + UINT32 EventSize; > + UINT8 Event[1]; > +} TD_EVENT; > + > +// > +// EFI TD Event Header > +// It is similar with TCG_PCR_EVENT2_HDR except the field of MrIndex and PCRIndex > +// > +typedef struct { > + EFI_TD_MR_INDEX MrIndex; > + UINT32 EventType; > + TPML_DIGEST_VALUES Digests; > + UINT32 EventSize; > +} TD_EVENT_HDR; > + > +#pragma pack() > + > +// > +// Log entries after Get Event Log service > +// > + > + > +typedef struct { > + // > + // The version of this structure. It shall be set ot 1. [SAMI] It may be good to define a macro for the events table version, similar to EFI_TCG2_FINAL_EVENTS_TABLE_VERSION. > + // > + UINT64 Version; > + // > + // Number of events recorded after invocation of GetEventLog API > + // > + UINT64 NumberOfEvents; > + // > + // List of events of type TD_EVENT. > + // > + //TD_EVENT Event[1]; > +} EFI_TD_FINAL_EVENTS_TABLE; > + > + > +#define EFI_TD_FINAL_EVENTS_TABLE_GUID \ > + {0xdd4a4648, 0x2de7, 0x4665, {0x96, 0x4d, 0x21, 0xd9, 0xef, 0x5f, 0xb4, 0x46}} > + > +extern EFI_GUID gEfiTdFinalEventsTableGuid; > + > +#endif > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index 9cdc915ebae9..a31c44d3a689 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -1011,6 +1011,9 @@ > ## Include/Protocol/PcdInfo.h > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > + ## Include/Protocol/TdProtocol.h > + gEfiTdProtocolGuid = { 0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b }} > + > # > # Protocols defined in PI1.0. > #