| 1 |
|
| 2 |
|
| 3 |
#include <commonlib/region.h> |
| 4 |
#include <security/tpm/tspi/crtm.h> |
| 5 |
#include <soc/iomap.h> |
| 6 |
#include <stddef.h> |
| 7 |
#include <stdint.h> |
| 8 |
#include <symbols.h> |
| 9 |
|
| 10 |
extern const uint64_t fit_ptr; |
| 11 |
|
| 12 |
static const struct mem_region_device sram_rdev = |
| 13 |
MEM_REGION_DEV_RO_INIT(SHARED_SRAM_BASE, SHARED_SRAM_SIZE); |
| 14 |
|
| 15 |
|
| 16 |
static const struct region_device *shared_sram_device(void) |
| 17 |
{ |
| 18 |
return &sram_rdev.rdev; |
| 19 |
} |
| 20 |
|
| 21 |
static const size_t shared_sram_base(void) |
| 22 |
{ |
| 23 |
return (size_t)(sram_rdev.base); |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
static int ifwi_bootblock_locate_as_rdev(struct region_device *rdev) |
| 31 |
{ |
| 32 |
size_t offset = (size_t)(_program - shared_sram_base()); |
| 33 |
size_t size = (size_t)(0x100000000ULL - (uint32_t)_program); |
| 34 |
|
| 35 |
return rdev_chain(rdev, shared_sram_device(), offset, size); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
int tspi_soc_measure_bootblock(int pcr_index) |
| 47 |
{ |
| 48 |
struct region_device ifwi_bootblock; |
| 49 |
|
| 50 |
if (ifwi_bootblock_locate_as_rdev(&ifwi_bootblock)) |
| 51 |
return 1; |
| 52 |
if (tpm_measure_region(&ifwi_bootblock, pcr_index, "IFWI: bootblock")) |
| 53 |
return 1; |
| 54 |
printk(BIOS_DEBUG, "FIT pointer patched to 0x%llx by TXE.\n", fit_ptr); |
| 55 |
|
| 56 |
if (fit_ptr != SHARED_SRAM_BASE) { |
| 57 |
printk(BIOS_WARNING, |
| 58 |
"Runtime FIT pointer does not match the pre-defined address!\n"); |
| 59 |
} |
| 60 |
return 0; |
| 61 |
} |