vaseboot/include/VasEBoot/efi/cc.h

152 lines
5.1 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2022 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_EFI_CC_H
#define VAS_EBOOT_EFI_CC_H 1
#include <VasEBoot/efi/api.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/err.h>
#define VAS_EBOOT_EFI_CC_MEASUREMENT_PROTOCOL_GUID \
{ 0x96751a3d, 0x72f4, 0x41a6, \
{ 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b } \
};
struct VasEBoot_efi_cc_version
{
VasEBoot_efi_uint8_t Major;
VasEBoot_efi_uint8_t Minor;
};
typedef struct VasEBoot_efi_cc_version VasEBoot_efi_cc_version_t;
/* EFI_CC Type/SubType definition. */
#define VAS_EBOOT_EFI_CC_TYPE_NONE 0
#define VAS_EBOOT_EFI_CC_TYPE_SEV 1
#define VAS_EBOOT_EFI_CC_TYPE_TDX 2
struct VasEBoot_efi_cc_type
{
VasEBoot_efi_uint8_t Type;
VasEBoot_efi_uint8_t SubType;
};
typedef struct VasEBoot_efi_cc_type VasEBoot_efi_cc_type_t;
typedef VasEBoot_efi_uint32_t VasEBoot_efi_cc_event_log_bitmap_t;
typedef VasEBoot_efi_uint32_t VasEBoot_efi_cc_event_log_format_t;
typedef VasEBoot_efi_uint32_t VasEBoot_efi_cc_event_algorithm_bitmap_t;
typedef VasEBoot_efi_uint32_t VasEBoot_efi_cc_mr_index_t;
/* Intel TDX measure register index. */
#define VAS_EBOOT_TDX_MR_INDEX_MRTD 0
#define VAS_EBOOT_TDX_MR_INDEX_RTMR0 1
#define VAS_EBOOT_TDX_MR_INDEX_RTMR1 2
#define VAS_EBOOT_TDX_MR_INDEX_RTMR2 3
#define VAS_EBOOT_TDX_MR_INDEX_RTMR3 4
#define VAS_EBOOT_EFI_CC_EVENT_LOG_FORMAT_TCG_2 0x00000002
#define VAS_EBOOT_EFI_CC_BOOT_HASH_ALG_SHA384 0x00000004
#define VAS_EBOOT_EFI_CC_EVENT_HEADER_VERSION 1
struct VasEBoot_efi_cc_event_header
{
/* Size of the event header itself (sizeof(EFI_TD_EVENT_HEADER)). */
VasEBoot_efi_uint32_t HeaderSize;
/*
* Header version. For this version of this specification,
* the value shall be 1.
*/
VasEBoot_efi_uint16_t HeaderVersion;
/* Index of the MR that shall be extended. */
VasEBoot_efi_cc_mr_index_t MrIndex;
/* Type of the event that shall be extended (and optionally logged). */
VasEBoot_efi_uint32_t EventType;
} VAS_EBOOT_PACKED;
typedef struct VasEBoot_efi_cc_event_header VasEBoot_efi_cc_event_header_t;
struct VasEBoot_efi_cc_event
{
/* Total size of the event including the Size component, the header and the Event data. */
VasEBoot_efi_uint32_t Size;
VasEBoot_efi_cc_event_header_t Header;
VasEBoot_efi_uint8_t Event[0];
} VAS_EBOOT_PACKED;
typedef struct VasEBoot_efi_cc_event VasEBoot_efi_cc_event_t;
struct VasEBoot_efi_cc_boot_service_capability
{
/* Allocated size of the structure. */
VasEBoot_efi_uint8_t Size;
/*
* Version of the VasEBoot_efi_cc_boot_service_capability_t 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.
*/
VasEBoot_efi_cc_version_t 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.
*/
VasEBoot_efi_cc_version_t ProtocolVersion;
/* Supported hash algorithms. */
VasEBoot_efi_cc_event_algorithm_bitmap_t HashAlgorithmBitmap;
/* Bitmap of supported event log formats. */
VasEBoot_efi_cc_event_log_bitmap_t SupportedEventLogs;
/* Indicates the CC type. */
VasEBoot_efi_cc_type_t CcType;
};
typedef struct VasEBoot_efi_cc_boot_service_capability VasEBoot_efi_cc_boot_service_capability_t;
struct VasEBoot_efi_cc_protocol
{
VasEBoot_efi_status_t
(__VasEBoot_efi_api *get_capability) (struct VasEBoot_efi_cc_protocol *this,
VasEBoot_efi_cc_boot_service_capability_t *ProtocolCapability);
VasEBoot_efi_status_t
(__VasEBoot_efi_api *get_event_log) (struct VasEBoot_efi_cc_protocol *this,
VasEBoot_efi_cc_event_log_format_t EventLogFormat,
VasEBoot_efi_physical_address_t *EventLogLocation,
VasEBoot_efi_physical_address_t *EventLogLastEntry,
VasEBoot_efi_boolean_t *EventLogTruncated);
VasEBoot_efi_status_t
(__VasEBoot_efi_api *hash_log_extend_event) (struct VasEBoot_efi_cc_protocol *this,
VasEBoot_efi_uint64_t Flags,
VasEBoot_efi_physical_address_t DataToHash,
VasEBoot_efi_uint64_t DataToHashLen,
VasEBoot_efi_cc_event_t *EfiCcEvent);
VasEBoot_efi_status_t
(__VasEBoot_efi_api *map_pcr_to_mr_index) (struct VasEBoot_efi_cc_protocol *this,
VasEBoot_efi_uint32_t PcrIndex,
VasEBoot_efi_cc_mr_index_t *MrIndex);
};
typedef struct VasEBoot_efi_cc_protocol VasEBoot_efi_cc_protocol_t;
#endif