a238317ce8
ACPICA doesn't include protections around address space checking, Linux build tests always complain increased sparse warnings around ACPICA internal acpi_os_map/unmap_memory() invocations. This patch tries to fix this issue permanently. There are 2 choices left for us to solve this issue: 1. Add __iomem address space awareness into ACPICA. 2. Remove sparse checker of __iomem from ACPICA source code. This patch chooses solution 2, because: 1. Most of the acpi_os_map/unmap_memory() invocations are used for ACPICA. table mappings, which in fact are not IO addresses. 2. The only IO addresses usage is for "system memory space" mapping code in: drivers/acpi/acpica/exregion.c drivers/acpi/acpica/evrgnini.c drivers/acpi/acpica/exregion.c The mapped address is accessed in the handler of "system memory space" - acpi_ex_system_memory_space_handler(). This function in fact can be changed to invoke acpi_os_read/write_memory() so that __iomem can always be type-casted in the OSL layer. According to the above investigation, we drew the following conclusion: It is not a good idea to introduce __iomem address space awareness into ACPICA mostly in order to protect non-IO addresses. We can simply remove __iomem for acpi_os_map/unmap_memory() to remove __iomem checker for ACPICA code. Then we need to enforce external usages to invoke other APIs that are aware of __iomem address space. The external usages are: drivers/acpi/apei/einj.c drivers/acpi/acpi_extlog.c drivers/char/tpm/tpm_acpi.c drivers/acpi/nvs.c This patch thus performs cleanups in this way: 1. Add acpi_os_map/unmap_iomem() to be invoked by non-ACPICA code. 2. Remove __iomem from acpi_os_map/unmap_memory(). Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
110 lines
2.5 KiB
C
110 lines
2.5 KiB
C
/*
|
|
* Copyright (C) 2005 IBM Corporation
|
|
*
|
|
* Authors:
|
|
* Seiji Munetoh <munetoh@jp.ibm.com>
|
|
* Stefan Berger <stefanb@us.ibm.com>
|
|
* Reiner Sailer <sailer@watson.ibm.com>
|
|
* Kylene Hall <kjhall@us.ibm.com>
|
|
*
|
|
* Maintained by: <tpmdd-devel@lists.sourceforge.net>
|
|
*
|
|
* Access to the eventlog extended by the TCG BIOS of PC platform
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*
|
|
*/
|
|
|
|
#include <linux/seq_file.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/security.h>
|
|
#include <linux/module.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/acpi.h>
|
|
|
|
#include "tpm.h"
|
|
#include "tpm_eventlog.h"
|
|
|
|
struct acpi_tcpa {
|
|
struct acpi_table_header hdr;
|
|
u16 platform_class;
|
|
union {
|
|
struct client_hdr {
|
|
u32 log_max_len __packed;
|
|
u64 log_start_addr __packed;
|
|
} client;
|
|
struct server_hdr {
|
|
u16 reserved;
|
|
u64 log_max_len __packed;
|
|
u64 log_start_addr __packed;
|
|
} server;
|
|
};
|
|
};
|
|
|
|
/* read binary bios log */
|
|
int read_log(struct tpm_bios_log *log)
|
|
{
|
|
struct acpi_tcpa *buff;
|
|
acpi_status status;
|
|
void __iomem *virt;
|
|
u64 len, start;
|
|
|
|
if (log->bios_event_log != NULL) {
|
|
printk(KERN_ERR
|
|
"%s: ERROR - Eventlog already initialized\n",
|
|
__func__);
|
|
return -EFAULT;
|
|
}
|
|
|
|
/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
|
|
status = acpi_get_table(ACPI_SIG_TCPA, 1,
|
|
(struct acpi_table_header **)&buff);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
printk(KERN_ERR "%s: ERROR - Could not get TCPA table\n",
|
|
__func__);
|
|
return -EIO;
|
|
}
|
|
|
|
switch(buff->platform_class) {
|
|
case BIOS_SERVER:
|
|
len = buff->server.log_max_len;
|
|
start = buff->server.log_start_addr;
|
|
break;
|
|
case BIOS_CLIENT:
|
|
default:
|
|
len = buff->client.log_max_len;
|
|
start = buff->client.log_start_addr;
|
|
break;
|
|
}
|
|
if (!len) {
|
|
printk(KERN_ERR "%s: ERROR - TCPA log area empty\n", __func__);
|
|
return -EIO;
|
|
}
|
|
|
|
/* malloc EventLog space */
|
|
log->bios_event_log = kmalloc(len, GFP_KERNEL);
|
|
if (!log->bios_event_log) {
|
|
printk("%s: ERROR - Not enough Memory for BIOS measurements\n",
|
|
__func__);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
log->bios_event_log_end = log->bios_event_log + len;
|
|
|
|
virt = acpi_os_map_iomem(start, len);
|
|
if (!virt) {
|
|
kfree(log->bios_event_log);
|
|
printk("%s: ERROR - Unable to map memory\n", __func__);
|
|
return -EIO;
|
|
}
|
|
|
|
memcpy_fromio(log->bios_event_log, virt, len);
|
|
|
|
acpi_os_unmap_iomem(virt, len);
|
|
return 0;
|
|
}
|