x86/topology: Fix function name in documentation
[cris-mirror.git] / drivers / char / tpm / tpm_eventlog_efi.c
blobe3f9ffd341d23768d7f25c6d13a7f874abc096c3
1 /*
2 * Copyright (C) 2017 Google
4 * Authors:
5 * Thiebaud Weksteen <tweek@google.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
14 #include <linux/efi.h>
15 #include <linux/tpm_eventlog.h>
17 #include "tpm.h"
19 /* read binary bios log from EFI configuration table */
20 int tpm_read_log_efi(struct tpm_chip *chip)
23 struct linux_efi_tpm_eventlog *log_tbl;
24 struct tpm_bios_log *log;
25 u32 log_size;
26 u8 tpm_log_version;
28 if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
29 return -ENODEV;
31 if (efi.tpm_log == EFI_INVALID_TABLE_ADDR)
32 return -ENODEV;
34 log = &chip->log;
36 log_tbl = memremap(efi.tpm_log, sizeof(*log_tbl), MEMREMAP_WB);
37 if (!log_tbl) {
38 pr_err("Could not map UEFI TPM log table !\n");
39 return -ENOMEM;
42 log_size = log_tbl->size;
43 memunmap(log_tbl);
45 log_tbl = memremap(efi.tpm_log, sizeof(*log_tbl) + log_size,
46 MEMREMAP_WB);
47 if (!log_tbl) {
48 pr_err("Could not map UEFI TPM log table payload!\n");
49 return -ENOMEM;
52 /* malloc EventLog space */
53 log->bios_event_log = kmalloc(log_size, GFP_KERNEL);
54 if (!log->bios_event_log)
55 goto err_memunmap;
56 memcpy(log->bios_event_log, log_tbl->log, log_size);
57 log->bios_event_log_end = log->bios_event_log + log_size;
59 tpm_log_version = log_tbl->version;
60 memunmap(log_tbl);
61 return tpm_log_version;
63 err_memunmap:
64 memunmap(log_tbl);
65 return -ENOMEM;