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