xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/acpi/initrd_table_override.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun================================
4*4882a593SmuzhiyunUpgrading ACPI tables via initrd
5*4882a593Smuzhiyun================================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunWhat is this about
8*4882a593Smuzhiyun==================
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunIf the ACPI_TABLE_UPGRADE compile option is true, it is possible to
11*4882a593Smuzhiyunupgrade the ACPI execution environment that is defined by the ACPI tables
12*4882a593Smuzhiyunvia upgrading the ACPI tables provided by the BIOS with an instrumented,
13*4882a593Smuzhiyunmodified, more recent version one, or installing brand new ACPI tables.
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunWhen building initrd with kernel in a single image, option
16*4882a593SmuzhiyunACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD should also be true for this
17*4882a593Smuzhiyunfeature to work.
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunFor a full list of ACPI tables that can be upgraded/installed, take a look
20*4882a593Smuzhiyunat the char `*table_sigs[MAX_ACPI_SIGNATURE];` definition in
21*4882a593Smuzhiyundrivers/acpi/tables.c.
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunAll ACPI tables iasl (Intel's ACPI compiler and disassembler) knows should
24*4882a593Smuzhiyunbe overridable, except:
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun  - ACPI_SIG_RSDP (has a signature of 6 bytes)
27*4882a593Smuzhiyun  - ACPI_SIG_FACS (does not have an ordinary ACPI table header)
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunBoth could get implemented as well.
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunWhat is this for
33*4882a593Smuzhiyun================
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunComplain to your platform/BIOS vendor if you find a bug which is so severe
36*4882a593Smuzhiyunthat a workaround is not accepted in the Linux kernel. And this facility
37*4882a593Smuzhiyunallows you to upgrade the buggy tables before your platform/BIOS vendor
38*4882a593Smuzhiyunreleases an upgraded BIOS binary.
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunThis facility can be used by platform/BIOS vendors to provide a Linux
41*4882a593Smuzhiyuncompatible environment without modifying the underlying platform firmware.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunThis facility also provides a powerful feature to easily debug and test
44*4882a593SmuzhiyunACPI BIOS table compatibility with the Linux kernel by modifying old
45*4882a593Smuzhiyunplatform provided ACPI tables or inserting new ACPI tables.
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunIt can and should be enabled in any kernel because there is no functional
48*4882a593Smuzhiyunchange with not instrumented initrds.
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunHow does it work
52*4882a593Smuzhiyun================
53*4882a593Smuzhiyun::
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun  # Extract the machine's ACPI tables:
56*4882a593Smuzhiyun  cd /tmp
57*4882a593Smuzhiyun  acpidump >acpidump
58*4882a593Smuzhiyun  acpixtract -a acpidump
59*4882a593Smuzhiyun  # Disassemble, modify and recompile them:
60*4882a593Smuzhiyun  iasl -d *.dat
61*4882a593Smuzhiyun  # For example add this statement into a _PRT (PCI Routing Table) function
62*4882a593Smuzhiyun  # of the DSDT:
63*4882a593Smuzhiyun  Store("HELLO WORLD", debug)
64*4882a593Smuzhiyun  # And increase the OEM Revision. For example, before modification:
65*4882a593Smuzhiyun  DefinitionBlock ("DSDT.aml", "DSDT", 2, "INTEL ", "TEMPLATE", 0x00000000)
66*4882a593Smuzhiyun  # After modification:
67*4882a593Smuzhiyun  DefinitionBlock ("DSDT.aml", "DSDT", 2, "INTEL ", "TEMPLATE", 0x00000001)
68*4882a593Smuzhiyun  iasl -sa dsdt.dsl
69*4882a593Smuzhiyun  # Add the raw ACPI tables to an uncompressed cpio archive.
70*4882a593Smuzhiyun  # They must be put into a /kernel/firmware/acpi directory inside the cpio
71*4882a593Smuzhiyun  # archive. Note that if the table put here matches a platform table
72*4882a593Smuzhiyun  # (similar Table Signature, and similar OEMID, and similar OEM Table ID)
73*4882a593Smuzhiyun  # with a more recent OEM Revision, the platform table will be upgraded by
74*4882a593Smuzhiyun  # this table. If the table put here doesn't match a platform table
75*4882a593Smuzhiyun  # (dissimilar Table Signature, or dissimilar OEMID, or dissimilar OEM Table
76*4882a593Smuzhiyun  # ID), this table will be appended.
77*4882a593Smuzhiyun  mkdir -p kernel/firmware/acpi
78*4882a593Smuzhiyun  cp dsdt.aml kernel/firmware/acpi
79*4882a593Smuzhiyun  # A maximum of "NR_ACPI_INITRD_TABLES (64)" tables are currently allowed
80*4882a593Smuzhiyun  # (see osl.c):
81*4882a593Smuzhiyun  iasl -sa facp.dsl
82*4882a593Smuzhiyun  iasl -sa ssdt1.dsl
83*4882a593Smuzhiyun  cp facp.aml kernel/firmware/acpi
84*4882a593Smuzhiyun  cp ssdt1.aml kernel/firmware/acpi
85*4882a593Smuzhiyun  # The uncompressed cpio archive must be the first. Other, typically
86*4882a593Smuzhiyun  # compressed cpio archives, must be concatenated on top of the uncompressed
87*4882a593Smuzhiyun  # one. Following command creates the uncompressed cpio archive and
88*4882a593Smuzhiyun  # concatenates the original initrd on top:
89*4882a593Smuzhiyun  find kernel | cpio -H newc --create > /boot/instrumented_initrd
90*4882a593Smuzhiyun  cat /boot/initrd >>/boot/instrumented_initrd
91*4882a593Smuzhiyun  # reboot with increased acpi debug level, e.g. boot params:
92*4882a593Smuzhiyun  acpi.debug_level=0x2 acpi.debug_layer=0xFFFFFFFF
93*4882a593Smuzhiyun  # and check your syslog:
94*4882a593Smuzhiyun  [    1.268089] ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT]
95*4882a593Smuzhiyun  [    1.272091] [ACPI Debug]  String [0x0B] "HELLO WORLD"
96*4882a593Smuzhiyun
97*4882a593Smuzhiyuniasl is able to disassemble and recompile quite a lot different,
98*4882a593Smuzhiyunalso static ACPI tables.
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunWhere to retrieve userspace tools
102*4882a593Smuzhiyun=================================
103*4882a593Smuzhiyun
104*4882a593Smuzhiyuniasl and acpixtract are part of Intel's ACPICA project:
105*4882a593Smuzhiyunhttps://acpica.org/
106*4882a593Smuzhiyun
107*4882a593Smuzhiyunand should be packaged by distributions (for example in the acpica package
108*4882a593Smuzhiyunon SUSE).
109*4882a593Smuzhiyun
110*4882a593Smuzhiyunacpidump can be found in Len Browns pmtools:
111*4882a593Smuzhiyunftp://kernel.org/pub/linux/kernel/people/lenb/acpi/utils/pmtools/acpidump
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunThis tool is also part of the acpica package on SUSE.
114*4882a593SmuzhiyunAlternatively, used ACPI tables can be retrieved via sysfs in latest kernels:
115*4882a593Smuzhiyun/sys/firmware/acpi/tables
116