Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Apr 14-17, 2025
Register
Loading...
Note: File does not exist in v6.8.
 1/*
 2 * Copyright 2012 IBM Corporation
 3 *
 4 * Author: Ashley Lai <ashleydlai@gmail.com>
 5 *         Nayna Jain <nayna@linux.vnet.ibm.com>
 6 *
 7 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
 8 *
 9 * Read the event log created by the firmware on PPC64
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 *
16 */
17
18#include <linux/slab.h>
19#include <linux/of.h>
20
21#include "tpm.h"
22#include "tpm_eventlog.h"
23
24int tpm_read_log_of(struct tpm_chip *chip)
25{
26	struct device_node *np;
27	const u32 *sizep;
28	const u64 *basep;
29	struct tpm_bios_log *log;
30
31	log = &chip->log;
32	if (chip->dev.parent && chip->dev.parent->of_node)
33		np = chip->dev.parent->of_node;
34	else
35		return -ENODEV;
36
37	sizep = of_get_property(np, "linux,sml-size", NULL);
38	basep = of_get_property(np, "linux,sml-base", NULL);
39	if (sizep == NULL && basep == NULL)
40		return -ENODEV;
41	if (sizep == NULL || basep == NULL)
42		return -EIO;
43
44	if (*sizep == 0) {
45		dev_warn(&chip->dev, "%s: Event log area empty\n", __func__);
46		return -EIO;
47	}
48
49	log->bios_event_log = kmalloc(*sizep, GFP_KERNEL);
50	if (!log->bios_event_log)
51		return -ENOMEM;
52
53	log->bios_event_log_end = log->bios_event_log + *sizep;
54
55	memcpy(log->bios_event_log, __va(*basep), *sizep);
56
57	return 0;
58}