159bcdcccSChangbin Du.. SPDX-License-Identifier: GPL-2.0 259bcdcccSChangbin Du 359bcdcccSChangbin Du================================ 459bcdcccSChangbin DuUpgrading ACPI tables via initrd 559bcdcccSChangbin Du================================ 659bcdcccSChangbin Du 759bcdcccSChangbin DuWhat is this about 859bcdcccSChangbin Du================== 959bcdcccSChangbin Du 1059bcdcccSChangbin DuIf the ACPI_TABLE_UPGRADE compile option is true, it is possible to 1159bcdcccSChangbin Duupgrade the ACPI execution environment that is defined by the ACPI tables 1259bcdcccSChangbin Duvia upgrading the ACPI tables provided by the BIOS with an instrumented, 1359bcdcccSChangbin Dumodified, more recent version one, or installing brand new ACPI tables. 1459bcdcccSChangbin Du 1559bcdcccSChangbin DuWhen building initrd with kernel in a single image, option 1659bcdcccSChangbin DuACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD should also be true for this 1759bcdcccSChangbin Dufeature to work. 1859bcdcccSChangbin Du 1959bcdcccSChangbin DuFor a full list of ACPI tables that can be upgraded/installed, take a look 2059bcdcccSChangbin Duat the char `*table_sigs[MAX_ACPI_SIGNATURE];` definition in 2159bcdcccSChangbin Dudrivers/acpi/tables.c. 2259bcdcccSChangbin Du 2359bcdcccSChangbin DuAll ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should 2459bcdcccSChangbin Dube overridable, except: 2559bcdcccSChangbin Du 2659bcdcccSChangbin Du - ACPI_SIG_RSDP (has a signature of 6 bytes) 2759bcdcccSChangbin Du - ACPI_SIG_FACS (does not have an ordinary ACPI table header) 2859bcdcccSChangbin Du 2959bcdcccSChangbin DuBoth could get implemented as well. 3059bcdcccSChangbin Du 3159bcdcccSChangbin Du 3259bcdcccSChangbin DuWhat is this for 3359bcdcccSChangbin Du================ 3459bcdcccSChangbin Du 3559bcdcccSChangbin DuComplain to your platform/BIOS vendor if you find a bug which is so severe 3659bcdcccSChangbin Duthat a workaround is not accepted in the Linux kernel. And this facility 3759bcdcccSChangbin Duallows you to upgrade the buggy tables before your platform/BIOS vendor 3859bcdcccSChangbin Dureleases an upgraded BIOS binary. 3959bcdcccSChangbin Du 4059bcdcccSChangbin DuThis facility can be used by platform/BIOS vendors to provide a Linux 4159bcdcccSChangbin Ducompatible environment without modifying the underlying platform firmware. 4259bcdcccSChangbin Du 4359bcdcccSChangbin DuThis facility also provides a powerful feature to easily debug and test 4459bcdcccSChangbin DuACPI BIOS table compatibility with the Linux kernel by modifying old 4559bcdcccSChangbin Duplatform provided ACPI tables or inserting new ACPI tables. 4659bcdcccSChangbin Du 4759bcdcccSChangbin DuIt can and should be enabled in any kernel because there is no functional 4859bcdcccSChangbin Duchange with not instrumented initrds. 4959bcdcccSChangbin Du 5059bcdcccSChangbin Du 5159bcdcccSChangbin DuHow does it work 5259bcdcccSChangbin Du================ 5359bcdcccSChangbin Du:: 5459bcdcccSChangbin Du 5559bcdcccSChangbin Du # Extract the machine's ACPI tables: 5659bcdcccSChangbin Du cd /tmp 5759bcdcccSChangbin Du acpidump >acpidump 5859bcdcccSChangbin Du acpixtract -a acpidump 5959bcdcccSChangbin Du # Disassemble, modify and recompile them: 6059bcdcccSChangbin Du iasl -d *.dat 6159bcdcccSChangbin Du # For example add this statement into a _PRT (PCI Routing Table) function 6259bcdcccSChangbin Du # of the DSDT: 6359bcdcccSChangbin Du Store("HELLO WORLD", debug) 6459bcdcccSChangbin Du # And increase the OEM Revision. For example, before modification: 6559bcdcccSChangbin Du DefinitionBlock ("DSDT.aml", "DSDT", 2, "INTEL ", "TEMPLATE", 0x00000000) 6659bcdcccSChangbin Du # After modification: 6759bcdcccSChangbin Du DefinitionBlock ("DSDT.aml", "DSDT", 2, "INTEL ", "TEMPLATE", 0x00000001) 6859bcdcccSChangbin Du iasl -sa dsdt.dsl 6959bcdcccSChangbin Du # Add the raw ACPI tables to an uncompressed cpio archive. 7059bcdcccSChangbin Du # They must be put into a /kernel/firmware/acpi directory inside the cpio 7159bcdcccSChangbin Du # archive. Note that if the table put here matches a platform table 7259bcdcccSChangbin Du # (similar Table Signature, and similar OEMID, and similar OEM Table ID) 7359bcdcccSChangbin Du # with a more recent OEM Revision, the platform table will be upgraded by 7459bcdcccSChangbin Du # this table. If the table put here doesn't match a platform table 7559bcdcccSChangbin Du # (dissimilar Table Signature, or dissimilar OEMID, or dissimilar OEM Table 7659bcdcccSChangbin Du # ID), this table will be appended. 7759bcdcccSChangbin Du mkdir -p kernel/firmware/acpi 7859bcdcccSChangbin Du cp dsdt.aml kernel/firmware/acpi 7959bcdcccSChangbin Du # A maximum of "NR_ACPI_INITRD_TABLES (64)" tables are currently allowed 8059bcdcccSChangbin Du # (see osl.c): 8159bcdcccSChangbin Du iasl -sa facp.dsl 8259bcdcccSChangbin Du iasl -sa ssdt1.dsl 8359bcdcccSChangbin Du cp facp.aml kernel/firmware/acpi 8459bcdcccSChangbin Du cp ssdt1.aml kernel/firmware/acpi 8559bcdcccSChangbin Du # The uncompressed cpio archive must be the first. Other, typically 8659bcdcccSChangbin Du # compressed cpio archives, must be concatenated on top of the uncompressed 8759bcdcccSChangbin Du # one. Following command creates the uncompressed cpio archive and 8859bcdcccSChangbin Du # concatenates the original initrd on top: 8959bcdcccSChangbin Du find kernel | cpio -H newc --create > /boot/instrumented_initrd 9059bcdcccSChangbin Du cat /boot/initrd >>/boot/instrumented_initrd 9159bcdcccSChangbin Du # reboot with increased acpi debug level, e.g. boot params: 9259bcdcccSChangbin Du acpi.debug_level=0x2 acpi.debug_layer=0xFFFFFFFF 9359bcdcccSChangbin Du # and check your syslog: 9459bcdcccSChangbin Du [ 1.268089] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT] 9559bcdcccSChangbin Du [ 1.272091] [ACPI Debug] String [0x0B] "HELLO WORLD" 9659bcdcccSChangbin Du 9759bcdcccSChangbin Duiasl is able to disassemble and recompile quite a lot different, 9859bcdcccSChangbin Dualso static ACPI tables. 9959bcdcccSChangbin Du 10059bcdcccSChangbin Du 10159bcdcccSChangbin DuWhere to retrieve userspace tools 10259bcdcccSChangbin Du================================= 10359bcdcccSChangbin Du 10459bcdcccSChangbin Duiasl and acpixtract are part of Intel's ACPICA project: 105*93431e06SAlexander A. Klimovhttps://acpica.org/ 10659bcdcccSChangbin Du 10759bcdcccSChangbin Duand should be packaged by distributions (for example in the acpica package 10859bcdcccSChangbin Duon SUSE). 10959bcdcccSChangbin Du 11059bcdcccSChangbin Duacpidump can be found in Len Browns pmtools: 11159bcdcccSChangbin Duftp://kernel.org/pub/linux/kernel/people/lenb/acpi/utils/pmtools/acpidump 11259bcdcccSChangbin Du 11359bcdcccSChangbin DuThis tool is also part of the acpica package on SUSE. 11459bcdcccSChangbin DuAlternatively, used ACPI tables can be retrieved via sysfs in latest kernels: 11559bcdcccSChangbin Du/sys/firmware/acpi/tables 116