blob: 3a689b40ccc064be1d5f246a1318333a0c3f4028 [file] [log] [blame]
Ard Biesheuvel4febfb82019-02-02 10:41:15 +01001// SPDX-License-Identifier: GPL-2.0
Thiebaud Weksteen33b6d032017-09-20 10:13:39 +02002/*
3 * Copyright (C) 2017 Google, Inc.
4 * Thiebaud Weksteen <tweek@google.com>
Thiebaud Weksteen33b6d032017-09-20 10:13:39 +02005 */
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 */
16int __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