| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "efi.h" |
| 5 |
|
| 6 |
/* The UEFI specification defines the interface between the confidential virtual guest OS and |
| 7 |
* virtual firmware as EFI_CC_MEASUREMENT_PROTOCOL. The measurements are captured in the CC eventlog |
| 8 |
* that follows the TCG2 format. TPM PCR registers are mapped to vendor specific measurement registers |
| 9 |
* and the mapping can be queried using MapPcrToMrIndex service as part of the protocol. |
| 10 |
* |
| 11 |
* The "Confidential Computing" section in the UEFI specification covers the details. */ |
| 12 |
|
| 13 |
#define EFI_CC_MEASUREMENT_PROTOCOL_GUID \ |
| 14 |
GUID_DEF(0x96751a3d, 0x72f4, 0x41a6, 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b) |
| 15 |
|
| 16 |
#define EFI_CC_EVENT_HEADER_VERSION 1 |
| 17 |
#define EFI_CC_EVENT_LOG_FORMAT_TCG_2 0x00000002 |
| 18 |
|
| 19 |
typedef struct { |
| 20 |
uint8_t Type; |
| 21 |
uint8_t SubType; |
| 22 |
} EFI_CC_TYPE; |
| 23 |
|
| 24 |
typedef struct { |
| 25 |
uint8_t Major; |
| 26 |
uint8_t Minor; |
| 27 |
} EFI_CC_VERSION; |
| 28 |
|
| 29 |
typedef struct { |
| 30 |
uint8_t Size; |
| 31 |
EFI_CC_VERSION StructureVersion; |
| 32 |
EFI_CC_VERSION ProtocolVersion; |
| 33 |
uint32_t HashAlgorithmBitmap; |
| 34 |
uint32_t SupportedEventLogs; |
| 35 |
EFI_CC_TYPE CcType; |
| 36 |
} EFI_CC_BOOT_SERVICE_CAPABILITY; |
| 37 |
|
| 38 |
typedef struct { |
| 39 |
uint32_t HeaderSize; |
| 40 |
uint16_t HeaderVersion; |
| 41 |
uint32_t MrIndex; |
| 42 |
uint32_t EventType; |
| 43 |
} _packed_ EFI_CC_EVENT_HEADER; |
| 44 |
|
| 45 |
typedef struct { |
| 46 |
uint32_t Size; |
| 47 |
EFI_CC_EVENT_HEADER Header; |
| 48 |
uint8_t Event[]; |
| 49 |
} _packed_ EFI_CC_EVENT; |
| 50 |
|
| 51 |
typedef struct EFI_CC_MEASUREMENT_PROTOCOL EFI_CC_MEASUREMENT_PROTOCOL; |
| 52 |
struct EFI_CC_MEASUREMENT_PROTOCOL { |
| 53 |
EFI_STATUS (EFIAPI *GetCapability)( |
| 54 |
EFI_CC_MEASUREMENT_PROTOCOL *This, |
| 55 |
EFI_CC_BOOT_SERVICE_CAPABILITY *ProtocolCapability); |
| 56 |
void *GetEventLog; |
| 57 |
EFI_STATUS (EFIAPI *HashLogExtendEvent)( |
| 58 |
EFI_CC_MEASUREMENT_PROTOCOL *This, |
| 59 |
uint64_t Flags, |
| 60 |
EFI_PHYSICAL_ADDRESS DataToHash, |
| 61 |
uint64_t DataToHashLen, |
| 62 |
EFI_CC_EVENT *EfiCcEvent); |
| 63 |
EFI_STATUS (EFIAPI *MapPcrToMrIndex)( |
| 64 |
EFI_CC_MEASUREMENT_PROTOCOL *This, |
| 65 |
uint32_t PcrIndex, |
| 66 |
uint32_t *MrIndex); |
| 67 |
}; |