| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include <stdbool.h> |
| 5 |
|
| 6 |
/* List of PE sections that have special meaning for us in unified kernels. This is the canonical order in |
| 7 |
* which we measure the sections into TPM PCR 11. PLEASE DO NOT REORDER! */ |
| 8 |
typedef enum UnifiedSection { |
| 9 |
UNIFIED_SECTION_LINUX, |
| 10 |
UNIFIED_SECTION_OSREL, |
| 11 |
UNIFIED_SECTION_CMDLINE, |
| 12 |
UNIFIED_SECTION_INITRD, |
| 13 |
UNIFIED_SECTION_UCODE, |
| 14 |
UNIFIED_SECTION_SPLASH, |
| 15 |
UNIFIED_SECTION_DTB, |
| 16 |
UNIFIED_SECTION_UNAME, |
| 17 |
UNIFIED_SECTION_SBAT, |
| 18 |
UNIFIED_SECTION_PCRSIG, /* This is is not measured actually */ |
| 19 |
UNIFIED_SECTION_PCRPKEY, |
| 20 |
UNIFIED_SECTION_PROFILE, |
| 21 |
UNIFIED_SECTION_DTBAUTO, |
| 22 |
UNIFIED_SECTION_HWIDS, |
| 23 |
UNIFIED_SECTION_EFIFW, |
| 24 |
_UNIFIED_SECTION_MAX, |
| 25 |
} UnifiedSection; |
| 26 |
|
| 27 |
extern const char* const unified_sections[_UNIFIED_SECTION_MAX + 1]; |
| 28 |
|
| 29 |
static inline bool unified_section_measure(UnifiedSection section) { |
| 30 |
/* Don't include the PCR signature in the PCR measurements, since they sign the expected result of |
| 31 |
* the measurement, and hence shouldn't be input to it. */ |
| 32 |
return section >= 0 && section < _UNIFIED_SECTION_MAX && section != UNIFIED_SECTION_PCRSIG; |
| 33 |
} |
| 34 |
|
| 35 |
/* Max number of profiles per UKI */ |
| 36 |
#define UNIFIED_PROFILES_MAX 256U |
| 37 |
|
| 38 |
/* The native PE machine type, if known, for a full list see: |
| 39 |
* https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types */ |
| 40 |
#ifndef _IMAGE_FILE_MACHINE_NATIVE |
| 41 |
# if defined(__x86_64__) |
| 42 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0x8664) |
| 43 |
# elif defined(__i386__) |
| 44 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0x014c) |
| 45 |
# elif defined(__ia64__) |
| 46 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0x0200) |
| 47 |
# elif defined(__aarch64__) |
| 48 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0xaa64) |
| 49 |
# elif defined(__arm__) |
| 50 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0x01c0) |
| 51 |
# elif defined(__riscv) |
| 52 |
# if __SIZEOF_POINTER__ == 4 |
| 53 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0x5032) |
| 54 |
# elif __SIZEOF_POINTER__ == 8 |
| 55 |
# define _IMAGE_FILE_MACHINE_NATIVE UINT16_C(0x5064) |
| 56 |
# endif |
| 57 |
# endif |
| 58 |
#endif |