tpm.c 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (C) 2017 Google, Inc.
  3. * Thiebaud Weksteen <tweek@google.com>
  4. *
  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. */
  9. #include <linux/efi.h>
  10. #include <linux/init.h>
  11. #include <linux/memblock.h>
  12. #include <asm/early_ioremap.h>
  13. /*
  14. * Reserve the memory associated with the TPM Event Log configuration table.
  15. */
  16. int __init efi_tpm_eventlog_init(void)
  17. {
  18. struct linux_efi_tpm_eventlog *log_tbl;
  19. unsigned int tbl_size;
  20. if (efi.tpm_log == EFI_INVALID_TABLE_ADDR)
  21. return 0;
  22. log_tbl = early_memremap(efi.tpm_log, sizeof(*log_tbl));
  23. if (!log_tbl) {
  24. pr_err("Failed to map TPM Event Log table @ 0x%lx\n",
  25. efi.tpm_log);
  26. efi.tpm_log = EFI_INVALID_TABLE_ADDR;
  27. return -ENOMEM;
  28. }
  29. tbl_size = sizeof(*log_tbl) + log_tbl->size;
  30. memblock_reserve(efi.tpm_log, tbl_size);
  31. early_memunmap(log_tbl, sizeof(*log_tbl));
  32. return 0;
  33. }