Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: Add reserved memory event log

Some platforms may desire to pass the event log up to Linux in the
form of a reserved memory region. In particular, this is desirable
for embedded systems or baseboard management controllers (BMCs)
booting with U-Boot. IBM OpenBMC BMCs will be the first user.
Add support for the reserved memory in the TPM core to find the
region and map it.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
[jarkko: removed spurious dev_info()'s from tpm_read_log_memory_region()]
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
[yang: return -ENOMEM when devm_memremap() fails]
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>

authored by

Eddie James and committed by
Jarkko Sakkinen
1e2714bb 441b7152

+31 -1
+31 -1
drivers/char/tpm/eventlog/of.c
··· 12 12 13 13 #include <linux/device.h> 14 14 #include <linux/slab.h> 15 + #include <linux/io.h> 16 + #include <linux/ioport.h> 15 17 #include <linux/of.h> 18 + #include <linux/of_address.h> 19 + #include <linux/of_reserved_mem.h> 16 20 #include <linux/tpm_eventlog.h> 17 21 18 22 #include "../tpm.h" 19 23 #include "common.h" 24 + 25 + static int tpm_read_log_memory_region(struct tpm_chip *chip) 26 + { 27 + struct device_node *node; 28 + struct resource res; 29 + int rc; 30 + 31 + node = of_parse_phandle(chip->dev.parent->of_node, "memory-region", 0); 32 + if (!node) 33 + return -ENODEV; 34 + 35 + rc = of_address_to_resource(node, 0, &res); 36 + of_node_put(node); 37 + if (rc) 38 + return rc; 39 + 40 + chip->log.bios_event_log = devm_memremap(&chip->dev, res.start, resource_size(&res), 41 + MEMREMAP_WB); 42 + if (IS_ERR(chip->log.bios_event_log)) 43 + return -ENOMEM; 44 + 45 + chip->log.bios_event_log_end = chip->log.bios_event_log + resource_size(&res); 46 + 47 + return chip->flags & TPM_CHIP_FLAG_TPM2 ? EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 : 48 + EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2; 49 + } 20 50 21 51 int tpm_read_log_of(struct tpm_chip *chip) 22 52 { ··· 69 39 sizep = of_get_property(np, "linux,sml-size", NULL); 70 40 basep = of_get_property(np, "linux,sml-base", NULL); 71 41 if (sizep == NULL && basep == NULL) 72 - return -ENODEV; 42 + return tpm_read_log_memory_region(chip); 73 43 if (sizep == NULL || basep == NULL) 74 44 return -EIO; 75 45