1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2017 Google, Inc. 4 * Thiebaud Weksteen <tweek@google.com> 5 */ 6 7 #include <linux/efi.h> 8 #include <linux/init.h> 9 #include <linux/memblock.h> 10 11 #include <asm/early_ioremap.h> 12 13 /* 14 * Reserve the memory associated with the TPM Event Log configuration table. 15 */ 16 int __init efi_tpm_eventlog_init(void) 17 { 18 struct linux_efi_tpm_eventlog *log_tbl; 19 unsigned int tbl_size; 20 21 if (efi.tpm_log == EFI_INVALID_TABLE_ADDR) 22 return 0; 23 24 log_tbl = early_memremap(efi.tpm_log, sizeof(*log_tbl)); 25 if (!log_tbl) { 26 pr_err("Failed to map TPM Event Log table @ 0x%lx\n", 27 efi.tpm_log); 28 efi.tpm_log = EFI_INVALID_TABLE_ADDR; 29 return -ENOMEM; 30 } 31 32 tbl_size = sizeof(*log_tbl) + log_tbl->size; 33 memblock_reserve(efi.tpm_log, tbl_size); 34 early_memunmap(log_tbl, sizeof(*log_tbl)); 35 return 0; 36 } 37 38