Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  1/*
  2 * Copyright (C) 2005 IBM Corporation
  3 *
  4 * Authors:
  5 *	Seiji Munetoh <munetoh@jp.ibm.com>
  6 *	Stefan Berger <stefanb@us.ibm.com>
  7 *	Reiner Sailer <sailer@watson.ibm.com>
  8 *	Kylene Hall <kjhall@us.ibm.com>
  9 *	Nayna Jain <nayna@linux.vnet.ibm.com>
 10 *
 11 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
 12 *
 13 * Access to the event log extended by the TCG BIOS of PC platform
 14 *
 15 * This program is free software; you can redistribute it and/or
 16 * modify it under the terms of the GNU General Public License
 17 * as published by the Free Software Foundation; either version
 18 * 2 of the License, or (at your option) any later version.
 19 *
 20 */
 21
 22#include <linux/seq_file.h>
 23#include <linux/fs.h>
 24#include <linux/security.h>
 25#include <linux/module.h>
 26#include <linux/slab.h>
 27#include <linux/acpi.h>
 28
 29#include "tpm.h"
 30#include "tpm_eventlog.h"
 31
 32struct acpi_tcpa {
 33	struct acpi_table_header hdr;
 34	u16 platform_class;
 35	union {
 36		struct client_hdr {
 37			u32 log_max_len __packed;
 38			u64 log_start_addr __packed;
 39		} client;
 40		struct server_hdr {
 41			u16 reserved;
 42			u64 log_max_len __packed;
 43			u64 log_start_addr __packed;
 44		} server;
 45	};
 46};
 47
 48/* read binary bios log */
 49int tpm_read_log_acpi(struct tpm_chip *chip)
 50{
 51	struct acpi_tcpa *buff;
 52	acpi_status status;
 53	void __iomem *virt;
 54	u64 len, start;
 55	struct tpm_bios_log *log;
 56
 57	log = &chip->log;
 58
 59	/* Unfortuntely ACPI does not associate the event log with a specific
 60	 * TPM, like PPI. Thus all ACPI TPMs will read the same log.
 61	 */
 62	if (!chip->acpi_dev_handle)
 63		return -ENODEV;
 64
 65	/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
 66	status = acpi_get_table(ACPI_SIG_TCPA, 1,
 67				(struct acpi_table_header **)&buff);
 68
 69	if (ACPI_FAILURE(status))
 70		return -ENODEV;
 71
 72	switch(buff->platform_class) {
 73	case BIOS_SERVER:
 74		len = buff->server.log_max_len;
 75		start = buff->server.log_start_addr;
 76		break;
 77	case BIOS_CLIENT:
 78	default:
 79		len = buff->client.log_max_len;
 80		start = buff->client.log_start_addr;
 81		break;
 82	}
 83	if (!len) {
 84		dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__);
 85		return -EIO;
 86	}
 87
 88	/* malloc EventLog space */
 89	log->bios_event_log = kmalloc(len, GFP_KERNEL);
 90	if (!log->bios_event_log)
 91		return -ENOMEM;
 92
 93	log->bios_event_log_end = log->bios_event_log + len;
 94
 95	virt = acpi_os_map_iomem(start, len);
 96	if (!virt)
 97		goto err;
 98
 99	memcpy_fromio(log->bios_event_log, virt, len);
100
101	acpi_os_unmap_iomem(virt, len);
102	return 0;
103
104err:
105	kfree(log->bios_event_log);
106	log->bios_event_log = NULL;
107	return -EIO;
108
109}