1*33b6d034SThiebaud Weksteen /* 2*33b6d034SThiebaud Weksteen * Copyright (C) 2017 Google, Inc. 3*33b6d034SThiebaud Weksteen * Thiebaud Weksteen <tweek@google.com> 4*33b6d034SThiebaud Weksteen * 5*33b6d034SThiebaud Weksteen * This program is free software; you can redistribute it and/or modify 6*33b6d034SThiebaud Weksteen * it under the terms of the GNU General Public License version 2 as 7*33b6d034SThiebaud Weksteen * published by the Free Software Foundation. 8*33b6d034SThiebaud Weksteen */ 9*33b6d034SThiebaud Weksteen 10*33b6d034SThiebaud Weksteen #include <linux/efi.h> 11*33b6d034SThiebaud Weksteen #include <linux/init.h> 12*33b6d034SThiebaud Weksteen #include <linux/memblock.h> 13*33b6d034SThiebaud Weksteen 14*33b6d034SThiebaud Weksteen #include <asm/early_ioremap.h> 15*33b6d034SThiebaud Weksteen 16*33b6d034SThiebaud Weksteen /* 17*33b6d034SThiebaud Weksteen * Reserve the memory associated with the TPM Event Log configuration table. 18*33b6d034SThiebaud Weksteen */ 19*33b6d034SThiebaud Weksteen int __init efi_tpm_eventlog_init(void) 20*33b6d034SThiebaud Weksteen { 21*33b6d034SThiebaud Weksteen struct linux_efi_tpm_eventlog *log_tbl; 22*33b6d034SThiebaud Weksteen unsigned int tbl_size; 23*33b6d034SThiebaud Weksteen 24*33b6d034SThiebaud Weksteen if (efi.tpm_log == EFI_INVALID_TABLE_ADDR) 25*33b6d034SThiebaud Weksteen return 0; 26*33b6d034SThiebaud Weksteen 27*33b6d034SThiebaud Weksteen log_tbl = early_memremap(efi.tpm_log, sizeof(*log_tbl)); 28*33b6d034SThiebaud Weksteen if (!log_tbl) { 29*33b6d034SThiebaud Weksteen pr_err("Failed to map TPM Event Log table @ 0x%lx\n", 30*33b6d034SThiebaud Weksteen efi.tpm_log); 31*33b6d034SThiebaud Weksteen efi.tpm_log = EFI_INVALID_TABLE_ADDR; 32*33b6d034SThiebaud Weksteen return -ENOMEM; 33*33b6d034SThiebaud Weksteen } 34*33b6d034SThiebaud Weksteen 35*33b6d034SThiebaud Weksteen tbl_size = sizeof(*log_tbl) + log_tbl->size; 36*33b6d034SThiebaud Weksteen memblock_reserve(efi.tpm_log, tbl_size); 37*33b6d034SThiebaud Weksteen early_memunmap(log_tbl, sizeof(*log_tbl)); 38*33b6d034SThiebaud Weksteen return 0; 39*33b6d034SThiebaud Weksteen } 40*33b6d034SThiebaud Weksteen 41