This source file includes following definitions.
- tpm_read_log_of
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/slab.h>
14 #include <linux/of.h>
15 #include <linux/tpm_eventlog.h>
16
17 #include "../tpm.h"
18 #include "common.h"
19
20 int tpm_read_log_of(struct tpm_chip *chip)
21 {
22 struct device_node *np;
23 const u32 *sizep;
24 const u64 *basep;
25 struct tpm_bios_log *log;
26 u32 size;
27 u64 base;
28
29 log = &chip->log;
30 if (chip->dev.parent && chip->dev.parent->of_node)
31 np = chip->dev.parent->of_node;
32 else
33 return -ENODEV;
34
35 if (of_property_read_bool(np, "powered-while-suspended"))
36 chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
37
38 sizep = of_get_property(np, "linux,sml-size", NULL);
39 basep = of_get_property(np, "linux,sml-base", NULL);
40 if (sizep == NULL && basep == NULL)
41 return -ENODEV;
42 if (sizep == NULL || basep == NULL)
43 return -EIO;
44
45
46
47
48
49
50
51
52
53
54 if (of_property_match_string(np, "compatible", "IBM,vtpm") < 0) {
55 size = be32_to_cpup((__force __be32 *)sizep);
56 base = be64_to_cpup((__force __be64 *)basep);
57 } else {
58 size = *sizep;
59 base = *basep;
60 }
61
62 if (size == 0) {
63 dev_warn(&chip->dev, "%s: Event log area empty\n", __func__);
64 return -EIO;
65 }
66
67 log->bios_event_log = kmemdup(__va(base), size, GFP_KERNEL);
68 if (!log->bios_event_log)
69 return -ENOMEM;
70
71 log->bios_event_log_end = log->bios_event_log + size;
72
73 if (chip->flags & TPM_CHIP_FLAG_TPM2)
74 return EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
75 return EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
76 }