initrd_table_override.rst 4.3 KB

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