[tip:x86/urgent] x86/microcode/amd: Tone down printk(), don' t treat a missing firmware file as an error
Commit-ID: 11f918d3e2d3861b6931e97b3aa778e4984935aa Gitweb: http://git.kernel.org/tip/11f918d3e2d3861b6931e97b3aa778e4984935aa Author: Thomas Renninger AuthorDate: Tue, 12 Nov 2013 17:39:43 +0100 Committer: Ingo Molnar CommitDate: Tue, 12 Nov 2013 22:03:49 +0100 x86/microcode/amd: Tone down printk(), don't treat a missing firmware file as an error Do it the same way as done in microcode_intel.c: use pr_debug() for missing firmware files. There seem to be CPUs out there for which no microcode update has been submitted to kernel-firmware repo yet resulting in scary sounding error messages in dmesg: microcode: failed to load file amd-ucode/microcode_amd_fam16h.bin Signed-off-by: Thomas Renninger Acked-by: Borislav Petkov Cc: Link: http://lkml.kernel.org/r/1384274383-43510-1-git-send-email-tr...@suse.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/microcode_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c index af99f71..c3d4cc9 100644 --- a/arch/x86/kernel/microcode_amd.c +++ b/arch/x86/kernel/microcode_amd.c @@ -431,7 +431,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device, snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86); if (request_firmware(, (const char *)fw_name, device)) { - pr_err("failed to load file %s\n", fw_name); + pr_debug("failed to load file %s\n", fw_name); goto out; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/urgent] x86/microcode/amd: Tone down printk(), don' t treat a missing firmware file as an error
Commit-ID: 11f918d3e2d3861b6931e97b3aa778e4984935aa Gitweb: http://git.kernel.org/tip/11f918d3e2d3861b6931e97b3aa778e4984935aa Author: Thomas Renninger tr...@suse.de AuthorDate: Tue, 12 Nov 2013 17:39:43 +0100 Committer: Ingo Molnar mi...@kernel.org CommitDate: Tue, 12 Nov 2013 22:03:49 +0100 x86/microcode/amd: Tone down printk(), don't treat a missing firmware file as an error Do it the same way as done in microcode_intel.c: use pr_debug() for missing firmware files. There seem to be CPUs out there for which no microcode update has been submitted to kernel-firmware repo yet resulting in scary sounding error messages in dmesg: microcode: failed to load file amd-ucode/microcode_amd_fam16h.bin Signed-off-by: Thomas Renninger tr...@suse.de Acked-by: Borislav Petkov b...@suse.de Cc: sta...@kernel.org Link: http://lkml.kernel.org/r/1384274383-43510-1-git-send-email-tr...@suse.de Signed-off-by: Ingo Molnar mi...@kernel.org --- arch/x86/kernel/microcode_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c index af99f71..c3d4cc9 100644 --- a/arch/x86/kernel/microcode_amd.c +++ b/arch/x86/kernel/microcode_amd.c @@ -431,7 +431,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device, snprintf(fw_name, sizeof(fw_name), amd-ucode/microcode_amd_fam%.2xh.bin, c-x86); if (request_firmware(fw, (const char *)fw_name, device)) { - pr_err(failed to load file %s\n, fw_name); + pr_debug(failed to load file %s\n, fw_name); goto out; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/urgent] ACPI: Overriding ACPI tables via initrd only works with an initrd and on X86
Commit-ID: 565d956a7e191e95d81f515196951715f2616e6b Gitweb: http://git.kernel.org/tip/565d956a7e191e95d81f515196951715f2616e6b Author: Thomas Renninger AuthorDate: Fri, 22 Feb 2013 14:12:22 +0100 Committer: H. Peter Anvin CommitDate: Mon, 25 Feb 2013 10:47:09 -0800 ACPI: Overriding ACPI tables via initrd only works with an initrd and on X86 Reflect this dependency in Kconfig, to prevent build failures. Shorten the config description as suggested by Borislav Petkov. Finding a suitable memory area to store the modified table(s) has been taken over from arch/x86/kernel/setup.c and makes use of max_low_pfn_mapped: memblock_find_in_range(0, max_low_pfn_mapped,...) This one is X86 specific. It may not be hard to extend this functionality for other ACPI aware architectures if there is need for. For now make this feature only available for X86 to avoid build failures on IA64, compare with: https://bugzilla.kernel.org/show_bug.cgi?id=54091 Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1361538742-67599-3-git-send-email-tr...@suse.de Signed-off-by: H. Peter Anvin --- drivers/acpi/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 38c5078..f5ae996 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -268,7 +268,8 @@ config ACPI_CUSTOM_DSDT default ACPI_CUSTOM_DSDT_FILE != "" config ACPI_INITRD_TABLE_OVERRIDE - bool "ACPI tables can be passed via uncompressed cpio in initrd" + bool "ACPI tables override via initrd" + depends on BLK_DEV_INITRD && X86 default n help This option provides functionality to override arbitrary ACPI tables -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/urgent] ACPI: Overriding ACPI tables via initrd only works with an initrd and on X86
Commit-ID: 565d956a7e191e95d81f515196951715f2616e6b Gitweb: http://git.kernel.org/tip/565d956a7e191e95d81f515196951715f2616e6b Author: Thomas Renninger tr...@suse.de AuthorDate: Fri, 22 Feb 2013 14:12:22 +0100 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Mon, 25 Feb 2013 10:47:09 -0800 ACPI: Overriding ACPI tables via initrd only works with an initrd and on X86 Reflect this dependency in Kconfig, to prevent build failures. Shorten the config description as suggested by Borislav Petkov. Finding a suitable memory area to store the modified table(s) has been taken over from arch/x86/kernel/setup.c and makes use of max_low_pfn_mapped: memblock_find_in_range(0, max_low_pfn_mapped,...) This one is X86 specific. It may not be hard to extend this functionality for other ACPI aware architectures if there is need for. For now make this feature only available for X86 to avoid build failures on IA64, compare with: https://bugzilla.kernel.org/show_bug.cgi?id=54091 Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1361538742-67599-3-git-send-email-tr...@suse.de Signed-off-by: H. Peter Anvin h...@linux.intel.com --- drivers/acpi/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 38c5078..f5ae996 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -268,7 +268,8 @@ config ACPI_CUSTOM_DSDT default ACPI_CUSTOM_DSDT_FILE != config ACPI_INITRD_TABLE_OVERRIDE - bool ACPI tables can be passed via uncompressed cpio in initrd + bool ACPI tables override via initrd + depends on BLK_DEV_INITRD X86 default n help This option provides functionality to override arbitrary ACPI tables -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Document ACPI table overriding via initrd
Commit-ID: 8347bbecf3518aa1518f6157e661812a35775130 Gitweb: http://git.kernel.org/tip/8347bbecf3518aa1518f6157e661812a35775130 Author: Thomas Renninger AuthorDate: Mon, 1 Oct 2012 00:23:57 +0200 Committer: H. Peter Anvin CommitDate: Sun, 30 Sep 2012 18:03:41 -0700 ACPI: Document ACPI table overriding via initrd Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1349043837-22659-7-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- Documentation/acpi/initrd_table_override.txt | 94 ++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/Documentation/acpi/initrd_table_override.txt b/Documentation/acpi/initrd_table_override.txt new file mode 100644 index 000..35c3f54 --- /dev/null +++ b/Documentation/acpi/initrd_table_override.txt @@ -0,0 +1,94 @@ +Overriding ACPI tables via initrd += + +1) Introduction (What is this about) +2) What is this for +3) How does it work +4) References (Where to retrieve userspace tools) + +1) What is this about +- + +If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible to +override nearly any ACPI table provided by the BIOS with an instrumented, +modified one. + +For a full list of ACPI tables that can be overridden, take a look at +the char *table_sigs[MAX_ACPI_SIGNATURE]; definition in drivers/acpi/osl.c +All ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should +be overridable, except: + - ACPI_SIG_RSDP (has a signature of 6 bytes) + - ACPI_SIG_FACS (does not have an ordinary ACPI table header) +Both could get implemented as well. + + +2) What is this for +--- + +Please keep in mind that this is a debug option. +ACPI tables should not get overridden for productive use. +If BIOS ACPI tables are overridden the kernel will get tainted with the +TAINT_OVERRIDDEN_ACPI_TABLE flag. +Complain to your platform/BIOS vendor if you find a bug which is so sever +that a workaround is not accepted in the Linux kernel. + +Still, it can and should be enabled in any kernel, because: + - There is no functional change with not instrumented initrds + - It provides a powerful feature to easily debug and test ACPI BIOS table +compatibility with the Linux kernel. + + +3) How does it work +--- + +# Extract the machine's ACPI tables: +cd /tmp +acpidump >acpidump +acpixtract -a acpidump +# Disassemble, modify and recompile them: +iasl -d *.dat +# For example add this statement into a _PRT (PCI Routing Table) function +# of the DSDT: +Store("HELLO WORLD", debug) +iasl -sa dsdt.dsl +# Add the raw ACPI tables to an uncompressed cpio archive. +# They must be put into a /kernel/firmware/acpi directory inside the +# cpio archive. +# The uncompressed cpio archive must be the first. +# Other, typically compressed cpio archives, must be +# concatenated on top of the uncompressed one. +mkdir -p kernel/firmware/acpi +cp dsdt.aml kernel/firmware/acpi +# A maximum of: #define ACPI_OVERRIDE_TABLES 10 +# tables are currently allowed (see osl.c): +iasl -sa facp.dsl +iasl -sa ssdt1.dsl +cp facp.aml kernel/firmware/acpi +cp ssdt1.aml kernel/firmware/acpi +# Create the uncompressed cpio archive and concatenate the original initrd +# on top: +find kernel | cpio -H newc --create > /boot/instrumented_initrd +cat /boot/initrd >>/boot/instrumented_initrd +# reboot with increased acpi debug level, e.g. boot params: +acpi.debug_level=0x2 acpi.debug_layer=0x +# and check your syslog: +[1.268089] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT] +[1.272091] [ACPI Debug] String [0x0B] "HELLO WORLD" + +iasl is able to disassemble and recompile quite a lot different, +also static ACPI tables. + + +4) Where to retrieve userspace tools + + +iasl and acpixtract are part of Intel's ACPICA project: +http://acpica.org/ +and should be packaged by distributions (for example in the acpica package +on SUSE). + +acpidump can be found in Len Browns pmtools: +ftp://kernel.org/pub/linux/kernel/people/lenb/acpi/utils/pmtools/acpidump +This tool is also part of the acpica package on SUSE. +Alternatively, used ACPI tables can be retrieved via sysfs in latest kernels: +/sys/firmware/acpi/tables -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Create acpi_table_taint() function to avoid code duplication
Commit-ID: 325a8d36035f0623950e38e9cf7a47a48e72df11 Gitweb: http://git.kernel.org/tip/325a8d36035f0623950e38e9cf7a47a48e72df11 Author: Thomas Renninger AuthorDate: Mon, 1 Oct 2012 00:23:56 +0200 Committer: H. Peter Anvin CommitDate: Sun, 30 Sep 2012 18:03:35 -0700 ACPI: Create acpi_table_taint() function to avoid code duplication There are two ways of overriding ACPI tables now, both need to taint the the kernel. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1349043837-22659-6-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- drivers/acpi/osl.c | 20 +--- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 007224b..a2845ff 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -656,6 +656,15 @@ 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) +{ + 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); +} + + acpi_status acpi_os_table_override(struct acpi_table_header * existing_table, struct acpi_table_header ** new_table) @@ -669,13 +678,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, if (strncmp(existing_table->signature, "DSDT", 4) == 0) *new_table = (struct acpi_table_header *)AmlCode; #endif - if (*new_table != NULL) { - printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " - "this is unsafe: tainting kernel\n", - existing_table->signature, - existing_table->oem_table_id); - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); - } + if (*new_table != NULL) + acpi_table_taint(existing_table); return AE_OK; } @@ -736,6 +740,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table, break; } while (table_offset + ACPI_HEADER_SIZE < all_tables_size); + if (*address != 0) + acpi_table_taint(existing_table); return AE_OK; #endif } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Implement physical address table override
Commit-ID: b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5 Gitweb: http://git.kernel.org/tip/b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5 Author: Thomas Renninger AuthorDate: Mon, 1 Oct 2012 00:23:55 +0200 Committer: H. Peter Anvin CommitDate: Sun, 30 Sep 2012 18:03:29 -0700 ACPI: Implement physical address table override Previous patches stored ACPI tables provided via initrd in a memblock reserved area. If a table is loaded and the table type of an initrd provided one matches, the one from initrd is prefered. In case of a SSDT table, the OEM table id also has to match. ACPI tables can be loaded at boot time (static table pointers in XSDT), but also dynamically any time later via ASL commands load() or loadTable(). The override mechanism always works. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1349043837-22659-5-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- drivers/acpi/osl.c | 60 --- 1 files changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index b20b079..007224b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * existing_table, acpi_status acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address * new_address, - u32 *new_table_length) + acpi_physical_address *address, + u32 *table_length) { - return AE_SUPPORT; -} +#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE + *table_length = 0; + *address = 0; + return AE_OK; +#else + int table_offset = 0; + 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; + } + + 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; + } + table_offset += 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; + } + + table_offset -= table->length; + *table_length = table->length; + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + *address = acpi_tables_addr + table_offset; + break; + } while (table_offset + ACPI_HEADER_SIZE < all_tables_size); + + return AE_OK; +#endif +} static irqreturn_t acpi_irq(int irq, void *dev_id) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas
Commit-ID: 53aac44c904abbad9f474f652f099de13b5c3563 Gitweb: http://git.kernel.org/tip/53aac44c904abbad9f474f652f099de13b5c3563 Author: Thomas Renninger AuthorDate: Mon, 1 Oct 2012 00:23:54 +0200 Committer: H. Peter Anvin CommitDate: Sun, 30 Sep 2012 18:03:23 -0700 ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas A later patch will compare them with ACPI tables that get loaded at boot or runtime and if criteria match, a stored one is loaded. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1349043837-22659-4-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- arch/x86/kernel/setup.c |2 + drivers/acpi/Kconfig|9 drivers/acpi/osl.c | 122 +++ include/linux/acpi.h|8 +++ 4 files changed, 141 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f4b9b80..764e543 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -941,6 +941,8 @@ void __init setup_arch(char **cmdline_p) reserve_initrd(); + acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start); + reserve_crashkernel(); vsmp_init(); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8099895..8cf7195 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -261,6 +261,15 @@ config ACPI_CUSTOM_DSDT bool default ACPI_CUSTOM_DSDT_FILE != "" +config ACPI_INITRD_TABLE_OVERRIDE + bool "ACPI tables can be passed via uncompressed cpio in initrd" + default n + help + This option provides functionality to override arbitrary ACPI tables + via initrd. No functional change if no ACPI tables are passed via + initrd, therefore it's safe to say Y. + See Documentation/acpi/initrd_table_override.txt for details + config ACPI_BLACKLIST_YEAR int "Disable ACPI for systems before Jan 1st this year" if X86_32 default 0 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 9eaf708..b20b079 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -534,6 +534,128 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, return AE_OK; } +#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE +#include +#include + +static u64 acpi_tables_addr; +static int all_tables_size; + +/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ +u8 __init acpi_table_checksum(u8 *buffer, u32 length) +{ + u8 sum = 0; + u8 *end = buffer + length; + + while (buffer < end) + sum = (u8) (sum + *(buffer++)); + return sum; +} + +/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ +static const char * const table_sigs[] = { + ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, + ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, + ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF, + ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET, + ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI, + ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA, + ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, + ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, + ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; + +/* Non-fatal errors: Affected tables/files are ignored */ +#define INVALID_TABLE(x, path, name) \ + { pr_err("ACPI OVERRIDE: " x " [%s%s]\n", path, name); continue; } + +#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) + +/* Must not increase 10 or needs code modification below */ +#define ACPI_OVERRIDE_TABLES 10 + +void __init acpi_initrd_override(void *data, size_t size) +{ + int sig, no, table_nr = 0, total_offset = 0; + long offset = 0; + struct acpi_table_header *table; + char cpio_path[32] = "kernel/firmware/acpi/"; + struct cpio_data file; + struct cpio_data early_initrd_files[ACPI_OVERRIDE_TABLES]; + char *p; + + if (data == NULL || size == 0) + return; + + for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) { + file = find_cpio_data(cpio_path, data, size, ); + if (!file.data) + break; + + data += offset; + size -= offset; + + if (file.size < sizeof(struct acpi_table_header)) + INVALID_TABLE("Table smaller than ACPI header", + cpio_path, file.name); + + table = file.data; + + for (sig = 0; table_sigs[sig]; sig++) + if (!memcmp(table->signature, table_sigs[sig], 4)) + break; + + if (!table_sigs[sig]) + INVALID_TABLE("Unknown signature", +
[tip:x86/acpi] ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas
Commit-ID: 53aac44c904abbad9f474f652f099de13b5c3563 Gitweb: http://git.kernel.org/tip/53aac44c904abbad9f474f652f099de13b5c3563 Author: Thomas Renninger tr...@suse.de AuthorDate: Mon, 1 Oct 2012 00:23:54 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Sun, 30 Sep 2012 18:03:23 -0700 ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas A later patch will compare them with ACPI tables that get loaded at boot or runtime and if criteria match, a stored one is loaded. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1349043837-22659-4-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- arch/x86/kernel/setup.c |2 + drivers/acpi/Kconfig|9 drivers/acpi/osl.c | 122 +++ include/linux/acpi.h|8 +++ 4 files changed, 141 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f4b9b80..764e543 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -941,6 +941,8 @@ void __init setup_arch(char **cmdline_p) reserve_initrd(); + acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start); + reserve_crashkernel(); vsmp_init(); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8099895..8cf7195 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -261,6 +261,15 @@ config ACPI_CUSTOM_DSDT bool default ACPI_CUSTOM_DSDT_FILE != +config ACPI_INITRD_TABLE_OVERRIDE + bool ACPI tables can be passed via uncompressed cpio in initrd + default n + help + This option provides functionality to override arbitrary ACPI tables + via initrd. No functional change if no ACPI tables are passed via + initrd, therefore it's safe to say Y. + See Documentation/acpi/initrd_table_override.txt for details + config ACPI_BLACKLIST_YEAR int Disable ACPI for systems before Jan 1st this year if X86_32 default 0 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 9eaf708..b20b079 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -534,6 +534,128 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, return AE_OK; } +#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE +#include linux/earlycpio.h +#include linux/memblock.h + +static u64 acpi_tables_addr; +static int all_tables_size; + +/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ +u8 __init acpi_table_checksum(u8 *buffer, u32 length) +{ + u8 sum = 0; + u8 *end = buffer + length; + + while (buffer end) + sum = (u8) (sum + *(buffer++)); + return sum; +} + +/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ +static const char * const table_sigs[] = { + ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, + ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, + ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF, + ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET, + ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI, + ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA, + ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, + ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, + ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; + +/* Non-fatal errors: Affected tables/files are ignored */ +#define INVALID_TABLE(x, path, name) \ + { pr_err(ACPI OVERRIDE: x [%s%s]\n, path, name); continue; } + +#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) + +/* Must not increase 10 or needs code modification below */ +#define ACPI_OVERRIDE_TABLES 10 + +void __init acpi_initrd_override(void *data, size_t size) +{ + int sig, no, table_nr = 0, total_offset = 0; + long offset = 0; + struct acpi_table_header *table; + char cpio_path[32] = kernel/firmware/acpi/; + struct cpio_data file; + struct cpio_data early_initrd_files[ACPI_OVERRIDE_TABLES]; + char *p; + + if (data == NULL || size == 0) + return; + + for (no = 0; no ACPI_OVERRIDE_TABLES; no++) { + file = find_cpio_data(cpio_path, data, size, offset); + if (!file.data) + break; + + data += offset; + size -= offset; + + if (file.size sizeof(struct acpi_table_header)) + INVALID_TABLE(Table smaller than ACPI header, + cpio_path, file.name); + + table = file.data; + + for (sig = 0; table_sigs[sig]; sig++) + if
[tip:x86/acpi] ACPI: Implement physical address table override
Commit-ID: b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5 Gitweb: http://git.kernel.org/tip/b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5 Author: Thomas Renninger tr...@suse.de AuthorDate: Mon, 1 Oct 2012 00:23:55 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Sun, 30 Sep 2012 18:03:29 -0700 ACPI: Implement physical address table override Previous patches stored ACPI tables provided via initrd in a memblock reserved area. If a table is loaded and the table type of an initrd provided one matches, the one from initrd is prefered. In case of a SSDT table, the OEM table id also has to match. ACPI tables can be loaded at boot time (static table pointers in XSDT), but also dynamically any time later via ASL commands load() or loadTable(). The override mechanism always works. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1349043837-22659-5-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- drivers/acpi/osl.c | 60 --- 1 files changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index b20b079..007224b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * existing_table, acpi_status acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address * new_address, - u32 *new_table_length) + acpi_physical_address *address, + u32 *table_length) { - return AE_SUPPORT; -} +#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE + *table_length = 0; + *address = 0; + return AE_OK; +#else + int table_offset = 0; + 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; + } + + 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; + } + table_offset += 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; + } + + table_offset -= table-length; + *table_length = table-length; + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + *address = acpi_tables_addr + table_offset; + break; + } while (table_offset + ACPI_HEADER_SIZE all_tables_size); + + return AE_OK; +#endif +} static irqreturn_t acpi_irq(int irq, void *dev_id) { -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Create acpi_table_taint() function to avoid code duplication
Commit-ID: 325a8d36035f0623950e38e9cf7a47a48e72df11 Gitweb: http://git.kernel.org/tip/325a8d36035f0623950e38e9cf7a47a48e72df11 Author: Thomas Renninger tr...@suse.de AuthorDate: Mon, 1 Oct 2012 00:23:56 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Sun, 30 Sep 2012 18:03:35 -0700 ACPI: Create acpi_table_taint() function to avoid code duplication There are two ways of overriding ACPI tables now, both need to taint the the kernel. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1349043837-22659-6-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- drivers/acpi/osl.c | 20 +--- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 007224b..a2845ff 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -656,6 +656,15 @@ 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) +{ + 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); +} + + acpi_status acpi_os_table_override(struct acpi_table_header * existing_table, struct acpi_table_header ** new_table) @@ -669,13 +678,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, if (strncmp(existing_table-signature, DSDT, 4) == 0) *new_table = (struct acpi_table_header *)AmlCode; #endif - if (*new_table != NULL) { - printk(KERN_WARNING PREFIX Override [%4.4s-%8.8s], - this is unsafe: tainting kernel\n, - existing_table-signature, - existing_table-oem_table_id); - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); - } + if (*new_table != NULL) + acpi_table_taint(existing_table); return AE_OK; } @@ -736,6 +740,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table, break; } while (table_offset + ACPI_HEADER_SIZE all_tables_size); + if (*address != 0) + acpi_table_taint(existing_table); return AE_OK; #endif } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Document ACPI table overriding via initrd
Commit-ID: 8347bbecf3518aa1518f6157e661812a35775130 Gitweb: http://git.kernel.org/tip/8347bbecf3518aa1518f6157e661812a35775130 Author: Thomas Renninger tr...@suse.de AuthorDate: Mon, 1 Oct 2012 00:23:57 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Sun, 30 Sep 2012 18:03:41 -0700 ACPI: Document ACPI table overriding via initrd Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1349043837-22659-7-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- Documentation/acpi/initrd_table_override.txt | 94 ++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/Documentation/acpi/initrd_table_override.txt b/Documentation/acpi/initrd_table_override.txt new file mode 100644 index 000..35c3f54 --- /dev/null +++ b/Documentation/acpi/initrd_table_override.txt @@ -0,0 +1,94 @@ +Overriding ACPI tables via initrd += + +1) Introduction (What is this about) +2) What is this for +3) How does it work +4) References (Where to retrieve userspace tools) + +1) What is this about +- + +If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible to +override nearly any ACPI table provided by the BIOS with an instrumented, +modified one. + +For a full list of ACPI tables that can be overridden, take a look at +the char *table_sigs[MAX_ACPI_SIGNATURE]; definition in drivers/acpi/osl.c +All ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should +be overridable, except: + - ACPI_SIG_RSDP (has a signature of 6 bytes) + - ACPI_SIG_FACS (does not have an ordinary ACPI table header) +Both could get implemented as well. + + +2) What is this for +--- + +Please keep in mind that this is a debug option. +ACPI tables should not get overridden for productive use. +If BIOS ACPI tables are overridden the kernel will get tainted with the +TAINT_OVERRIDDEN_ACPI_TABLE flag. +Complain to your platform/BIOS vendor if you find a bug which is so sever +that a workaround is not accepted in the Linux kernel. + +Still, it can and should be enabled in any kernel, because: + - There is no functional change with not instrumented initrds + - It provides a powerful feature to easily debug and test ACPI BIOS table +compatibility with the Linux kernel. + + +3) How does it work +--- + +# Extract the machine's ACPI tables: +cd /tmp +acpidump acpidump +acpixtract -a acpidump +# Disassemble, modify and recompile them: +iasl -d *.dat +# For example add this statement into a _PRT (PCI Routing Table) function +# of the DSDT: +Store(HELLO WORLD, debug) +iasl -sa dsdt.dsl +# Add the raw ACPI tables to an uncompressed cpio archive. +# They must be put into a /kernel/firmware/acpi directory inside the +# cpio archive. +# The uncompressed cpio archive must be the first. +# Other, typically compressed cpio archives, must be +# concatenated on top of the uncompressed one. +mkdir -p kernel/firmware/acpi +cp dsdt.aml kernel/firmware/acpi +# A maximum of: #define ACPI_OVERRIDE_TABLES 10 +# tables are currently allowed (see osl.c): +iasl -sa facp.dsl +iasl -sa ssdt1.dsl +cp facp.aml kernel/firmware/acpi +cp ssdt1.aml kernel/firmware/acpi +# Create the uncompressed cpio archive and concatenate the original initrd +# on top: +find kernel | cpio -H newc --create /boot/instrumented_initrd +cat /boot/initrd /boot/instrumented_initrd +# reboot with increased acpi debug level, e.g. boot params: +acpi.debug_level=0x2 acpi.debug_layer=0x +# and check your syslog: +[1.268089] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT] +[1.272091] [ACPI Debug] String [0x0B] HELLO WORLD + +iasl is able to disassemble and recompile quite a lot different, +also static ACPI tables. + + +4) Where to retrieve userspace tools + + +iasl and acpixtract are part of Intel's ACPICA project: +http://acpica.org/ +and should be packaged by distributions (for example in the acpica package +on SUSE). + +acpidump can be found in Len Browns pmtools: +ftp://kernel.org/pub/linux/kernel/people/lenb/acpi/utils/pmtools/acpidump +This tool is also part of the acpica package on SUSE. +Alternatively, used ACPI tables can be retrieved via sysfs in latest kernels: +/sys/firmware/acpi/tables -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Document ACPI table overriding via initrd
Commit-ID: 4901b402c957d4ebaff123ffc34fafe3cef99542 Gitweb: http://git.kernel.org/tip/4901b402c957d4ebaff123ffc34fafe3cef99542 Author: Thomas Renninger AuthorDate: Wed, 26 Sep 2012 14:19:01 +0200 Committer: H. Peter Anvin CommitDate: Thu, 27 Sep 2012 15:01:43 -0700 ACPI: Document ACPI table overriding via initrd Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1348661941-71287-7-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- Documentation/acpi/initrd_table_override.txt | 94 ++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/Documentation/acpi/initrd_table_override.txt b/Documentation/acpi/initrd_table_override.txt new file mode 100644 index 000..35c3f54 --- /dev/null +++ b/Documentation/acpi/initrd_table_override.txt @@ -0,0 +1,94 @@ +Overriding ACPI tables via initrd += + +1) Introduction (What is this about) +2) What is this for +3) How does it work +4) References (Where to retrieve userspace tools) + +1) What is this about +- + +If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible to +override nearly any ACPI table provided by the BIOS with an instrumented, +modified one. + +For a full list of ACPI tables that can be overridden, take a look at +the char *table_sigs[MAX_ACPI_SIGNATURE]; definition in drivers/acpi/osl.c +All ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should +be overridable, except: + - ACPI_SIG_RSDP (has a signature of 6 bytes) + - ACPI_SIG_FACS (does not have an ordinary ACPI table header) +Both could get implemented as well. + + +2) What is this for +--- + +Please keep in mind that this is a debug option. +ACPI tables should not get overridden for productive use. +If BIOS ACPI tables are overridden the kernel will get tainted with the +TAINT_OVERRIDDEN_ACPI_TABLE flag. +Complain to your platform/BIOS vendor if you find a bug which is so sever +that a workaround is not accepted in the Linux kernel. + +Still, it can and should be enabled in any kernel, because: + - There is no functional change with not instrumented initrds + - It provides a powerful feature to easily debug and test ACPI BIOS table +compatibility with the Linux kernel. + + +3) How does it work +--- + +# Extract the machine's ACPI tables: +cd /tmp +acpidump >acpidump +acpixtract -a acpidump +# Disassemble, modify and recompile them: +iasl -d *.dat +# For example add this statement into a _PRT (PCI Routing Table) function +# of the DSDT: +Store("HELLO WORLD", debug) +iasl -sa dsdt.dsl +# Add the raw ACPI tables to an uncompressed cpio archive. +# They must be put into a /kernel/firmware/acpi directory inside the +# cpio archive. +# The uncompressed cpio archive must be the first. +# Other, typically compressed cpio archives, must be +# concatenated on top of the uncompressed one. +mkdir -p kernel/firmware/acpi +cp dsdt.aml kernel/firmware/acpi +# A maximum of: #define ACPI_OVERRIDE_TABLES 10 +# tables are currently allowed (see osl.c): +iasl -sa facp.dsl +iasl -sa ssdt1.dsl +cp facp.aml kernel/firmware/acpi +cp ssdt1.aml kernel/firmware/acpi +# Create the uncompressed cpio archive and concatenate the original initrd +# on top: +find kernel | cpio -H newc --create > /boot/instrumented_initrd +cat /boot/initrd >>/boot/instrumented_initrd +# reboot with increased acpi debug level, e.g. boot params: +acpi.debug_level=0x2 acpi.debug_layer=0x +# and check your syslog: +[1.268089] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT] +[1.272091] [ACPI Debug] String [0x0B] "HELLO WORLD" + +iasl is able to disassemble and recompile quite a lot different, +also static ACPI tables. + + +4) Where to retrieve userspace tools + + +iasl and acpixtract are part of Intel's ACPICA project: +http://acpica.org/ +and should be packaged by distributions (for example in the acpica package +on SUSE). + +acpidump can be found in Len Browns pmtools: +ftp://kernel.org/pub/linux/kernel/people/lenb/acpi/utils/pmtools/acpidump +This tool is also part of the acpica package on SUSE. +Alternatively, used ACPI tables can be retrieved via sysfs in latest kernels: +/sys/firmware/acpi/tables -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Create acpi_table_taint() function to avoid code duplication
Commit-ID: 1fab0ef6149d6a036137ef5fa4d4ad18cb117227 Gitweb: http://git.kernel.org/tip/1fab0ef6149d6a036137ef5fa4d4ad18cb117227 Author: Thomas Renninger AuthorDate: Wed, 26 Sep 2012 14:19:00 +0200 Committer: H. Peter Anvin CommitDate: Thu, 27 Sep 2012 15:01:36 -0700 ACPI: Create acpi_table_taint() function to avoid code duplication There are two ways of overriding ACPI tables now, both need to taint the the kernel. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1348661941-71287-6-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- drivers/acpi/osl.c | 20 +--- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 007224b..a2845ff 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -656,6 +656,15 @@ 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) +{ + 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); +} + + acpi_status acpi_os_table_override(struct acpi_table_header * existing_table, struct acpi_table_header ** new_table) @@ -669,13 +678,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, if (strncmp(existing_table->signature, "DSDT", 4) == 0) *new_table = (struct acpi_table_header *)AmlCode; #endif - if (*new_table != NULL) { - printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " - "this is unsafe: tainting kernel\n", - existing_table->signature, - existing_table->oem_table_id); - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); - } + if (*new_table != NULL) + acpi_table_taint(existing_table); return AE_OK; } @@ -736,6 +740,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table, break; } while (table_offset + ACPI_HEADER_SIZE < all_tables_size); + if (*address != 0) + acpi_table_taint(existing_table); return AE_OK; #endif } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Implement physical address table override
Commit-ID: 6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc Gitweb: http://git.kernel.org/tip/6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc Author: Thomas Renninger AuthorDate: Wed, 26 Sep 2012 14:18:59 +0200 Committer: H. Peter Anvin CommitDate: Thu, 27 Sep 2012 15:01:30 -0700 ACPI: Implement physical address table override Previous patches stored ACPI tables provided via initrd in a memblock reserved area. If a table is loaded and the table type of an initrd provided one matches, the one from initrd is prefered. In case of a SSDT table, the OEM table id also has to match. ACPI tables can be loaded at boot time (static table pointers in XSDT), but also dynamically any time later via ASL commands load() or loadTable(). The override mechanism always works. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1348661941-71287-5-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- drivers/acpi/osl.c | 60 --- 1 files changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index b20b079..007224b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * existing_table, acpi_status acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address * new_address, - u32 *new_table_length) + acpi_physical_address *address, + u32 *table_length) { - return AE_SUPPORT; -} +#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE + *table_length = 0; + *address = 0; + return AE_OK; +#else + int table_offset = 0; + 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; + } + + 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; + } + table_offset += 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; + } + + table_offset -= table->length; + *table_length = table->length; + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + *address = acpi_tables_addr + table_offset; + break; + } while (table_offset + ACPI_HEADER_SIZE < all_tables_size); + + return AE_OK; +#endif +} static irqreturn_t acpi_irq(int irq, void *dev_id) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas
Commit-ID: 9b17afd44dadf5065c46bc8e4df55b938d92c529 Gitweb: http://git.kernel.org/tip/9b17afd44dadf5065c46bc8e4df55b938d92c529 Author: Thomas Renninger AuthorDate: Wed, 26 Sep 2012 14:18:58 +0200 Committer: H. Peter Anvin CommitDate: Thu, 27 Sep 2012 15:01:22 -0700 ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas A later patch will compare them with ACPI tables that get loaded at boot or runtime and if criteria match, a stored one is loaded. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1348661941-71287-4-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- arch/x86/kernel/setup.c |2 + drivers/acpi/Kconfig|9 drivers/acpi/osl.c | 122 +++ include/linux/acpi.h|8 +++ 4 files changed, 141 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f4b9b80..764e543 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -941,6 +941,8 @@ void __init setup_arch(char **cmdline_p) reserve_initrd(); + acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start); + reserve_crashkernel(); vsmp_init(); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8099895..c461ca1 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -261,6 +261,15 @@ config ACPI_CUSTOM_DSDT bool default ACPI_CUSTOM_DSDT_FILE != "" +config ACPI_INITRD_TABLE_OVERRIDE + bool + default n + help + This option provides functionality to override arbitrary ACPI tables + via initrd. No functional change if no ACPI tables are passed via + initrd, therefore it's safe to say Y. + See Documentation/acpi/initrd_table_override.txt for details + config ACPI_BLACKLIST_YEAR int "Disable ACPI for systems before Jan 1st this year" if X86_32 default 0 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 9eaf708..b20b079 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -534,6 +534,128 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, return AE_OK; } +#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE +#include +#include + +static u64 acpi_tables_addr; +static int all_tables_size; + +/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ +u8 __init acpi_table_checksum(u8 *buffer, u32 length) +{ + u8 sum = 0; + u8 *end = buffer + length; + + while (buffer < end) + sum = (u8) (sum + *(buffer++)); + return sum; +} + +/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ +static const char * const table_sigs[] = { + ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, + ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, + ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF, + ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET, + ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI, + ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA, + ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, + ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, + ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; + +/* Non-fatal errors: Affected tables/files are ignored */ +#define INVALID_TABLE(x, path, name) \ + { pr_err("ACPI OVERRIDE: " x " [%s%s]\n", path, name); continue; } + +#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) + +/* Must not increase 10 or needs code modification below */ +#define ACPI_OVERRIDE_TABLES 10 + +void __init acpi_initrd_override(void *data, size_t size) +{ + int sig, no, table_nr = 0, total_offset = 0; + long offset = 0; + struct acpi_table_header *table; + char cpio_path[32] = "kernel/firmware/acpi/"; + struct cpio_data file; + struct cpio_data early_initrd_files[ACPI_OVERRIDE_TABLES]; + char *p; + + if (data == NULL || size == 0) + return; + + for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) { + file = find_cpio_data(cpio_path, data, size, ); + if (!file.data) + break; + + data += offset; + size -= offset; + + if (file.size < sizeof(struct acpi_table_header)) + INVALID_TABLE("Table smaller than ACPI header", + cpio_path, file.name); + + table = file.data; + + for (sig = 0; table_sigs[sig]; sig++) + if (!memcmp(table->signature, table_sigs[sig], 4)) + break; + + if (!table_sigs[sig]) + INVALID_TABLE("Unknown signature", + cpio_path, file.name);
[tip:x86/acpi] X86 ACPI: Introduce x86 arch specific arch_reserve_mem_area() for e820 handling
Commit-ID: 9e0a90cdff5b89599d73695b4d9971d1075c0b14 Gitweb: http://git.kernel.org/tip/9e0a90cdff5b89599d73695b4d9971d1075c0b14 Author: Thomas Renninger AuthorDate: Wed, 26 Sep 2012 14:18:57 +0200 Committer: H. Peter Anvin CommitDate: Thu, 27 Sep 2012 15:00:44 -0700 X86 ACPI: Introduce x86 arch specific arch_reserve_mem_area() for e820 handling This is needed for ACPI table overriding via initrd. Beside reserving memblocks, X86 also requires to flag the memory area to E820_RESERVED or E820_ACPI in the e820 mappings to be able to io(re)map it later. Signed-off-by: Thomas Renninger Link: http://lkml.kernel.org/r/1348661941-71287-3-git-send-email-tr...@suse.de Cc: Len Brown Cc: Robert Moore Cc: Yinghai Lu Cc: Eric Piel Signed-off-by: H. Peter Anvin --- arch/x86/kernel/acpi/boot.c |6 ++ include/linux/acpi.h|9 + 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index b2297e5..6b75777 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -1700,3 +1700,9 @@ int __acpi_release_global_lock(unsigned int *lock) } while (unlikely (val != old)); return old & 0x1; } + +void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size) +{ + e820_add_region(addr, size, E820_ACPI); + update_e820(); +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4f2a762..ebecc46 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -430,4 +430,13 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0) #endif +#if CONFIG_X86 +void arch_reserve_mem_area(acpi_physical_address addr, size_t size); +#else +static inline void arch_reserve_mem_area(acpi_physical_address addr, + size_t size) +{ +} +#endif /* CONFIG_X86 */ + #endif /*_LINUX_ACPI_H*/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] X86 ACPI: Introduce x86 arch specific arch_reserve_mem_area() for e820 handling
Commit-ID: 9e0a90cdff5b89599d73695b4d9971d1075c0b14 Gitweb: http://git.kernel.org/tip/9e0a90cdff5b89599d73695b4d9971d1075c0b14 Author: Thomas Renninger tr...@suse.de AuthorDate: Wed, 26 Sep 2012 14:18:57 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Thu, 27 Sep 2012 15:00:44 -0700 X86 ACPI: Introduce x86 arch specific arch_reserve_mem_area() for e820 handling This is needed for ACPI table overriding via initrd. Beside reserving memblocks, X86 also requires to flag the memory area to E820_RESERVED or E820_ACPI in the e820 mappings to be able to io(re)map it later. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1348661941-71287-3-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- arch/x86/kernel/acpi/boot.c |6 ++ include/linux/acpi.h|9 + 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index b2297e5..6b75777 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -1700,3 +1700,9 @@ int __acpi_release_global_lock(unsigned int *lock) } while (unlikely (val != old)); return old 0x1; } + +void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size) +{ + e820_add_region(addr, size, E820_ACPI); + update_e820(); +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4f2a762..ebecc46 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -430,4 +430,13 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0) #endif +#if CONFIG_X86 +void arch_reserve_mem_area(acpi_physical_address addr, size_t size); +#else +static inline void arch_reserve_mem_area(acpi_physical_address addr, + size_t size) +{ +} +#endif /* CONFIG_X86 */ + #endif /*_LINUX_ACPI_H*/ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas
Commit-ID: 9b17afd44dadf5065c46bc8e4df55b938d92c529 Gitweb: http://git.kernel.org/tip/9b17afd44dadf5065c46bc8e4df55b938d92c529 Author: Thomas Renninger tr...@suse.de AuthorDate: Wed, 26 Sep 2012 14:18:58 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Thu, 27 Sep 2012 15:01:22 -0700 ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas A later patch will compare them with ACPI tables that get loaded at boot or runtime and if criteria match, a stored one is loaded. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1348661941-71287-4-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- arch/x86/kernel/setup.c |2 + drivers/acpi/Kconfig|9 drivers/acpi/osl.c | 122 +++ include/linux/acpi.h|8 +++ 4 files changed, 141 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f4b9b80..764e543 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -941,6 +941,8 @@ void __init setup_arch(char **cmdline_p) reserve_initrd(); + acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start); + reserve_crashkernel(); vsmp_init(); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8099895..c461ca1 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -261,6 +261,15 @@ config ACPI_CUSTOM_DSDT bool default ACPI_CUSTOM_DSDT_FILE != +config ACPI_INITRD_TABLE_OVERRIDE + bool + default n + help + This option provides functionality to override arbitrary ACPI tables + via initrd. No functional change if no ACPI tables are passed via + initrd, therefore it's safe to say Y. + See Documentation/acpi/initrd_table_override.txt for details + config ACPI_BLACKLIST_YEAR int Disable ACPI for systems before Jan 1st this year if X86_32 default 0 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 9eaf708..b20b079 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -534,6 +534,128 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, return AE_OK; } +#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE +#include linux/earlycpio.h +#include linux/memblock.h + +static u64 acpi_tables_addr; +static int all_tables_size; + +/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ +u8 __init acpi_table_checksum(u8 *buffer, u32 length) +{ + u8 sum = 0; + u8 *end = buffer + length; + + while (buffer end) + sum = (u8) (sum + *(buffer++)); + return sum; +} + +/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ +static const char * const table_sigs[] = { + ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, + ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, + ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF, + ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET, + ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI, + ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA, + ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, + ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, + ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; + +/* Non-fatal errors: Affected tables/files are ignored */ +#define INVALID_TABLE(x, path, name) \ + { pr_err(ACPI OVERRIDE: x [%s%s]\n, path, name); continue; } + +#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) + +/* Must not increase 10 or needs code modification below */ +#define ACPI_OVERRIDE_TABLES 10 + +void __init acpi_initrd_override(void *data, size_t size) +{ + int sig, no, table_nr = 0, total_offset = 0; + long offset = 0; + struct acpi_table_header *table; + char cpio_path[32] = kernel/firmware/acpi/; + struct cpio_data file; + struct cpio_data early_initrd_files[ACPI_OVERRIDE_TABLES]; + char *p; + + if (data == NULL || size == 0) + return; + + for (no = 0; no ACPI_OVERRIDE_TABLES; no++) { + file = find_cpio_data(cpio_path, data, size, offset); + if (!file.data) + break; + + data += offset; + size -= offset; + + if (file.size sizeof(struct acpi_table_header)) + INVALID_TABLE(Table smaller than ACPI header, + cpio_path, file.name); + + table = file.data; + + for (sig = 0; table_sigs[sig]; sig++) + if (!memcmp(table-signature, table_sigs[sig], 4)) +
[tip:x86/acpi] ACPI: Implement physical address table override
Commit-ID: 6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc Gitweb: http://git.kernel.org/tip/6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc Author: Thomas Renninger tr...@suse.de AuthorDate: Wed, 26 Sep 2012 14:18:59 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Thu, 27 Sep 2012 15:01:30 -0700 ACPI: Implement physical address table override Previous patches stored ACPI tables provided via initrd in a memblock reserved area. If a table is loaded and the table type of an initrd provided one matches, the one from initrd is prefered. In case of a SSDT table, the OEM table id also has to match. ACPI tables can be loaded at boot time (static table pointers in XSDT), but also dynamically any time later via ASL commands load() or loadTable(). The override mechanism always works. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1348661941-71287-5-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- drivers/acpi/osl.c | 60 --- 1 files changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index b20b079..007224b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * existing_table, acpi_status acpi_os_physical_table_override(struct acpi_table_header *existing_table, - acpi_physical_address * new_address, - u32 *new_table_length) + acpi_physical_address *address, + u32 *table_length) { - return AE_SUPPORT; -} +#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE + *table_length = 0; + *address = 0; + return AE_OK; +#else + int table_offset = 0; + 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; + } + + 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; + } + table_offset += 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; + } + + table_offset -= table-length; + *table_length = table-length; + acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); + *address = acpi_tables_addr + table_offset; + break; + } while (table_offset + ACPI_HEADER_SIZE all_tables_size); + + return AE_OK; +#endif +} static irqreturn_t acpi_irq(int irq, void *dev_id) { -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Create acpi_table_taint() function to avoid code duplication
Commit-ID: 1fab0ef6149d6a036137ef5fa4d4ad18cb117227 Gitweb: http://git.kernel.org/tip/1fab0ef6149d6a036137ef5fa4d4ad18cb117227 Author: Thomas Renninger tr...@suse.de AuthorDate: Wed, 26 Sep 2012 14:19:00 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Thu, 27 Sep 2012 15:01:36 -0700 ACPI: Create acpi_table_taint() function to avoid code duplication There are two ways of overriding ACPI tables now, both need to taint the the kernel. Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1348661941-71287-6-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- drivers/acpi/osl.c | 20 +--- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 007224b..a2845ff 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -656,6 +656,15 @@ 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) +{ + 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); +} + + acpi_status acpi_os_table_override(struct acpi_table_header * existing_table, struct acpi_table_header ** new_table) @@ -669,13 +678,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, if (strncmp(existing_table-signature, DSDT, 4) == 0) *new_table = (struct acpi_table_header *)AmlCode; #endif - if (*new_table != NULL) { - printk(KERN_WARNING PREFIX Override [%4.4s-%8.8s], - this is unsafe: tainting kernel\n, - existing_table-signature, - existing_table-oem_table_id); - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); - } + if (*new_table != NULL) + acpi_table_taint(existing_table); return AE_OK; } @@ -736,6 +740,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table, break; } while (table_offset + ACPI_HEADER_SIZE all_tables_size); + if (*address != 0) + acpi_table_taint(existing_table); return AE_OK; #endif } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:x86/acpi] ACPI: Document ACPI table overriding via initrd
Commit-ID: 4901b402c957d4ebaff123ffc34fafe3cef99542 Gitweb: http://git.kernel.org/tip/4901b402c957d4ebaff123ffc34fafe3cef99542 Author: Thomas Renninger tr...@suse.de AuthorDate: Wed, 26 Sep 2012 14:19:01 +0200 Committer: H. Peter Anvin h...@linux.intel.com CommitDate: Thu, 27 Sep 2012 15:01:43 -0700 ACPI: Document ACPI table overriding via initrd Signed-off-by: Thomas Renninger tr...@suse.de Link: http://lkml.kernel.org/r/1348661941-71287-7-git-send-email-tr...@suse.de Cc: Len Brown l...@kernel.org Cc: Robert Moore robert.mo...@intel.com Cc: Yinghai Lu ying...@kernel.org Cc: Eric Piel eric.p...@tremplin-utc.net Signed-off-by: H. Peter Anvin h...@linux.intel.com --- Documentation/acpi/initrd_table_override.txt | 94 ++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/Documentation/acpi/initrd_table_override.txt b/Documentation/acpi/initrd_table_override.txt new file mode 100644 index 000..35c3f54 --- /dev/null +++ b/Documentation/acpi/initrd_table_override.txt @@ -0,0 +1,94 @@ +Overriding ACPI tables via initrd += + +1) Introduction (What is this about) +2) What is this for +3) How does it work +4) References (Where to retrieve userspace tools) + +1) What is this about +- + +If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible to +override nearly any ACPI table provided by the BIOS with an instrumented, +modified one. + +For a full list of ACPI tables that can be overridden, take a look at +the char *table_sigs[MAX_ACPI_SIGNATURE]; definition in drivers/acpi/osl.c +All ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should +be overridable, except: + - ACPI_SIG_RSDP (has a signature of 6 bytes) + - ACPI_SIG_FACS (does not have an ordinary ACPI table header) +Both could get implemented as well. + + +2) What is this for +--- + +Please keep in mind that this is a debug option. +ACPI tables should not get overridden for productive use. +If BIOS ACPI tables are overridden the kernel will get tainted with the +TAINT_OVERRIDDEN_ACPI_TABLE flag. +Complain to your platform/BIOS vendor if you find a bug which is so sever +that a workaround is not accepted in the Linux kernel. + +Still, it can and should be enabled in any kernel, because: + - There is no functional change with not instrumented initrds + - It provides a powerful feature to easily debug and test ACPI BIOS table +compatibility with the Linux kernel. + + +3) How does it work +--- + +# Extract the machine's ACPI tables: +cd /tmp +acpidump acpidump +acpixtract -a acpidump +# Disassemble, modify and recompile them: +iasl -d *.dat +# For example add this statement into a _PRT (PCI Routing Table) function +# of the DSDT: +Store(HELLO WORLD, debug) +iasl -sa dsdt.dsl +# Add the raw ACPI tables to an uncompressed cpio archive. +# They must be put into a /kernel/firmware/acpi directory inside the +# cpio archive. +# The uncompressed cpio archive must be the first. +# Other, typically compressed cpio archives, must be +# concatenated on top of the uncompressed one. +mkdir -p kernel/firmware/acpi +cp dsdt.aml kernel/firmware/acpi +# A maximum of: #define ACPI_OVERRIDE_TABLES 10 +# tables are currently allowed (see osl.c): +iasl -sa facp.dsl +iasl -sa ssdt1.dsl +cp facp.aml kernel/firmware/acpi +cp ssdt1.aml kernel/firmware/acpi +# Create the uncompressed cpio archive and concatenate the original initrd +# on top: +find kernel | cpio -H newc --create /boot/instrumented_initrd +cat /boot/initrd /boot/instrumented_initrd +# reboot with increased acpi debug level, e.g. boot params: +acpi.debug_level=0x2 acpi.debug_layer=0x +# and check your syslog: +[1.268089] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT] +[1.272091] [ACPI Debug] String [0x0B] HELLO WORLD + +iasl is able to disassemble and recompile quite a lot different, +also static ACPI tables. + + +4) Where to retrieve userspace tools + + +iasl and acpixtract are part of Intel's ACPICA project: +http://acpica.org/ +and should be packaged by distributions (for example in the acpica package +on SUSE). + +acpidump can be found in Len Browns pmtools: +ftp://kernel.org/pub/linux/kernel/people/lenb/acpi/utils/pmtools/acpidump +This tool is also part of the acpica package on SUSE. +Alternatively, used ACPI tables can be retrieved via sysfs in latest kernels: +/sys/firmware/acpi/tables -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/