|
@@ -602,6 +602,14 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
|
|
|
return AE_OK;
|
|
|
}
|
|
|
|
|
|
+static void acpi_table_taint(struct acpi_table_header *table)
|
|
|
+{
|
|
|
+ pr_warn(PREFIX
|
|
|
+ "Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
|
|
|
+ table->signature, table->oem_table_id);
|
|
|
+ add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
|
|
|
+}
|
|
|
+
|
|
|
#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
|
|
|
#include <linux/earlycpio.h>
|
|
|
#include <linux/memblock.h>
|
|
@@ -636,6 +644,7 @@ static const char * const table_sigs[] = {
|
|
|
|
|
|
#define ACPI_OVERRIDE_TABLES 64
|
|
|
static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES];
|
|
|
+static DECLARE_BITMAP(acpi_initrd_installed, ACPI_OVERRIDE_TABLES);
|
|
|
|
|
|
#define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT)
|
|
|
|
|
@@ -746,96 +755,125 @@ void __init acpi_initrd_override(void *data, size_t size)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */
|
|
|
|
|
|
-static void acpi_table_taint(struct acpi_table_header *table)
|
|
|
+acpi_status
|
|
|
+acpi_os_physical_table_override(struct acpi_table_header *existing_table,
|
|
|
+ acpi_physical_address *address, u32 *length)
|
|
|
{
|
|
|
- pr_warn(PREFIX
|
|
|
- "Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
|
|
|
- table->signature, table->oem_table_id);
|
|
|
- add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
|
|
|
-}
|
|
|
+ int table_offset = 0;
|
|
|
+ int table_index = 0;
|
|
|
+ struct acpi_table_header *table;
|
|
|
+ u32 table_length;
|
|
|
|
|
|
+ *length = 0;
|
|
|
+ *address = 0;
|
|
|
+ if (!acpi_tables_addr)
|
|
|
+ return AE_OK;
|
|
|
|
|
|
-acpi_status
|
|
|
-acpi_os_table_override(struct acpi_table_header * existing_table,
|
|
|
- struct acpi_table_header ** new_table)
|
|
|
-{
|
|
|
- if (!existing_table || !new_table)
|
|
|
- return AE_BAD_PARAMETER;
|
|
|
+ while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) {
|
|
|
+ table = acpi_os_map_memory(acpi_tables_addr + table_offset,
|
|
|
+ ACPI_HEADER_SIZE);
|
|
|
+ if (table_offset + table->length > all_tables_size) {
|
|
|
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
|
|
|
+ WARN_ON(1);
|
|
|
+ return AE_OK;
|
|
|
+ }
|
|
|
|
|
|
- *new_table = NULL;
|
|
|
+ table_length = table->length;
|
|
|
|
|
|
-#ifdef CONFIG_ACPI_CUSTOM_DSDT
|
|
|
- if (strncmp(existing_table->signature, "DSDT", 4) == 0)
|
|
|
- *new_table = (struct acpi_table_header *)AmlCode;
|
|
|
-#endif
|
|
|
- if (*new_table != NULL)
|
|
|
+ /* Only override tables matched */
|
|
|
+ if (test_bit(table_index, acpi_initrd_installed) ||
|
|
|
+ memcmp(existing_table->signature, table->signature, 4) ||
|
|
|
+ memcmp(table->oem_table_id, existing_table->oem_table_id,
|
|
|
+ ACPI_OEM_TABLE_ID_SIZE)) {
|
|
|
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
|
|
|
+ goto next_table;
|
|
|
+ }
|
|
|
+
|
|
|
+ *length = table_length;
|
|
|
+ *address = acpi_tables_addr + table_offset;
|
|
|
acpi_table_taint(existing_table);
|
|
|
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
|
|
|
+ set_bit(table_index, acpi_initrd_installed);
|
|
|
+ break;
|
|
|
+
|
|
|
+next_table:
|
|
|
+ table_offset += table_length;
|
|
|
+ table_index++;
|
|
|
+ }
|
|
|
return AE_OK;
|
|
|
}
|
|
|
|
|
|
-acpi_status
|
|
|
-acpi_os_physical_table_override(struct acpi_table_header *existing_table,
|
|
|
- acpi_physical_address *address,
|
|
|
- u32 *table_length)
|
|
|
+void __init acpi_initrd_initialize_tables(void)
|
|
|
{
|
|
|
-#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
|
|
|
- *table_length = 0;
|
|
|
- *address = 0;
|
|
|
- return AE_OK;
|
|
|
-#else
|
|
|
int table_offset = 0;
|
|
|
+ int table_index = 0;
|
|
|
+ u32 table_length;
|
|
|
struct acpi_table_header *table;
|
|
|
|
|
|
- *table_length = 0;
|
|
|
- *address = 0;
|
|
|
-
|
|
|
if (!acpi_tables_addr)
|
|
|
- return AE_OK;
|
|
|
-
|
|
|
- do {
|
|
|
- if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
|
|
|
- WARN_ON(1);
|
|
|
- return AE_OK;
|
|
|
- }
|
|
|
+ return;
|
|
|
|
|
|
+ while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) {
|
|
|
table = acpi_os_map_memory(acpi_tables_addr + table_offset,
|
|
|
ACPI_HEADER_SIZE);
|
|
|
-
|
|
|
if (table_offset + table->length > all_tables_size) {
|
|
|
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
|
|
|
WARN_ON(1);
|
|
|
- return AE_OK;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- table_offset += table->length;
|
|
|
+ table_length = table->length;
|
|
|
|
|
|
- if (memcmp(existing_table->signature, table->signature, 4)) {
|
|
|
- acpi_os_unmap_memory(table,
|
|
|
- ACPI_HEADER_SIZE);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- /* Only override tables with matching oem id */
|
|
|
- if (memcmp(table->oem_table_id, existing_table->oem_table_id,
|
|
|
- ACPI_OEM_TABLE_ID_SIZE)) {
|
|
|
- acpi_os_unmap_memory(table,
|
|
|
- ACPI_HEADER_SIZE);
|
|
|
- continue;
|
|
|
+ /* Skip RSDT/XSDT which should only be used for override */
|
|
|
+ if (test_bit(table_index, acpi_initrd_installed) ||
|
|
|
+ ACPI_COMPARE_NAME(table->signature, ACPI_SIG_RSDT) ||
|
|
|
+ ACPI_COMPARE_NAME(table->signature, ACPI_SIG_XSDT)) {
|
|
|
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
|
|
|
+ goto next_table;
|
|
|
}
|
|
|
|
|
|
- table_offset -= table->length;
|
|
|
- *table_length = table->length;
|
|
|
+ acpi_table_taint(table);
|
|
|
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
|
|
|
- *address = acpi_tables_addr + table_offset;
|
|
|
- break;
|
|
|
- } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
|
|
|
+ acpi_install_table(acpi_tables_addr + table_offset, TRUE);
|
|
|
+ set_bit(table_index, acpi_initrd_installed);
|
|
|
+next_table:
|
|
|
+ table_offset += table_length;
|
|
|
+ table_index++;
|
|
|
+ }
|
|
|
+}
|
|
|
+#else
|
|
|
+acpi_status
|
|
|
+acpi_os_physical_table_override(struct acpi_table_header *existing_table,
|
|
|
+ acpi_physical_address *address,
|
|
|
+ u32 *table_length)
|
|
|
+{
|
|
|
+ *table_length = 0;
|
|
|
+ *address = 0;
|
|
|
+ return AE_OK;
|
|
|
+}
|
|
|
+
|
|
|
+void __init acpi_initrd_initialize_tables(void)
|
|
|
+{
|
|
|
+}
|
|
|
+#endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */
|
|
|
|
|
|
- if (*address != 0)
|
|
|
+acpi_status
|
|
|
+acpi_os_table_override(struct acpi_table_header *existing_table,
|
|
|
+ struct acpi_table_header **new_table)
|
|
|
+{
|
|
|
+ if (!existing_table || !new_table)
|
|
|
+ return AE_BAD_PARAMETER;
|
|
|
+
|
|
|
+ *new_table = NULL;
|
|
|
+
|
|
|
+#ifdef CONFIG_ACPI_CUSTOM_DSDT
|
|
|
+ if (strncmp(existing_table->signature, "DSDT", 4) == 0)
|
|
|
+ *new_table = (struct acpi_table_header *)AmlCode;
|
|
|
+#endif
|
|
|
+ if (*new_table != NULL)
|
|
|
acpi_table_taint(existing_table);
|
|
|
return AE_OK;
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
static irqreturn_t acpi_irq(int irq, void *dev_id)
|