Linux 5.1.15
[linux/fpc-iii.git] / drivers / firmware / efi / tpm.c
blob3a689b40ccc064be1d5f246a1318333a0c3f4028
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2017 Google, Inc.
4 * Thiebaud Weksteen <tweek@google.com>
5 */
7 #include <linux/efi.h>
8 #include <linux/init.h>
9 #include <linux/memblock.h>
11 #include <asm/early_ioremap.h>
14 * Reserve the memory associated with the TPM Event Log configuration table.
16 int __init efi_tpm_eventlog_init(void)
18 struct linux_efi_tpm_eventlog *log_tbl;
19 unsigned int tbl_size;
21 if (efi.tpm_log == EFI_INVALID_TABLE_ADDR)
22 return 0;
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;
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;