ACPICA: ACPICA 20211217
Subsystems (2)
cover ACPICA: ACPICA 20211217
Hi All,
This series of patches is a set of ACPICA 20211217 changes described at
https://acpica.org/sites/acpica/files/changes_61.txt ported to Linux.
It contains the following material:
Bob Moore (7):
ACPICA: iASL/Disassembler: Additional support for NHLT table
ACPICA: iASL Table Compiler: Complete NHLT table support
ACPICA: Change a return_ACPI_STATUS (AE_BAD_PARAMETER)
ACPICA: Fixed a couple of warnings under MSVC
ACPICA: iASL: Add TDEL table to both compiler/disassembler
ACPICA: iASL/NHLT table: "Specific Data" field support
ACPICA: Update version to 20211217
Ilkka Koskinen (1):
ACPICA: iASL: Add suppport for AGDI table
Jessica Clarke (4):
ACPICA: Use original data_table_region pointer for accesses
ACPICA: Use original pointer for virtual origin tables
ACPICA: Macros: Remove ACPI_PHYSADDR_TO_PTR
ACPICA: Avoid subobject buffer overflow when validating RSDP signature
Kirill A. Shutemov (1):
ACPICA: Hardware: Do not flush CPU cache when entering S4 and S5
Mark Langsdorf (1):
ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions
Rafael J. Wysocki (2):
ACPICA: Utilities: Avoid deleting the same object twice in a row
ACPICA: Executer: Fix the REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R ()
Shuuichirou Ishii (1):
ACPICA: Fix AEST Processor generic resource substructure data field byte length
Sudeep Holla (2):
ACPICA: Fix wrong interpretation of PCC address
ACPICA: Add support for PCC Opregion special context data
Thanks!
PATCH 1/19 ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions
From: Mark Langsdorf <[email protected]>
ACPICA commit bc02c76d518135531483dfc276ed28b7ee632ce1
The current ACPI_ACCESS_*_WIDTH defines do not provide a way to test that size is small enough to not cause an overflow when applied to a 32-bit integer.
Rather than adding more magic numbers, add ACPI_ACCESS_*_SHIFT, ACPI_ACCESS_*_MAX, and ACPI_ACCESS_*_DEFAULT #defines and redefine ACPI_ACCESS_*_WIDTH in terms of the new #defines.
This was inititally reported on Linux where a size of 102 in ACPI_ACCESS_BIT_WIDTH caused an overflow error in the SPCR initialization code.
--- include/acpi/actypes.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
include/acpi/actypes.h +8 -2
@@ -536,8 +536,14 @@ typedef u64 acpi_integer;* Can be used with access_width of struct acpi_generic_address and access_size of * struct acpi_resource_generic_register. */ -#define ACPI_ACCESS_BIT_WIDTH (size) (1 << ((size) + 2)) -#define ACPI_ACCESS_BYTE_WIDTH (size) (1 << ((size) - 1)) +#define ACPI_ACCESS_BIT_SHIFT 2 +#define ACPI_ACCESS_BYTE_SHIFT -1 +#define ACPI_ACCESS_BIT_MAX (31 - ACPI_ACCESS_BIT_SHIFT) +#define ACPI_ACCESS_BYTE_MAX (31 - ACPI_ACCESS_BYTE_SHIFT) +#define ACPI_ACCESS_BIT_DEFAULT (8 - ACPI_ACCESS_BIT_SHIFT) +#define ACPI_ACCESS_BYTE_DEFAULT (8 - ACPI_ACCESS_BYTE_SHIFT) +#define ACPI_ACCESS_BIT_WIDTH (size) (1 << ((size) + ACPI_ACCESS_BIT_SHIFT)) +#define ACPI_ACCESS_BYTE_WIDTH (size) (1 << ((size) + ACPI_ACCESS_BYTE_SHIFT))/******************************************************************************* *
Signature · 1 line
2.26.2
PATCH 2/19 ACPICA: Use original data_table_region pointer for accesses
In reply to Rafael J. WysockiFrom: Jessica Clarke <[email protected]>
ACPICA commit d9eb82bd7515989f0b29d79deeeb758db4d6529c
Currently the pointer to the table is cast to acpi_physical_address and later cast back to a pointer to be dereferenced. Whether or not this is supported is implementation-defined.
On CHERI, and thus Arm's experimental Morello prototype architecture, pointers are represented as capabilities, which are unforgeable bounded pointers, providing always-on fine-grained spatial memory safety. This means that any pointer cast to a plain integer will lose all its associated metadata, and when cast back to a pointer it will give a null-derived pointer (one that has the same metadata as null but an address equal to the integer) that will trap on any dereference. As a result, this is an implementation where acpi_physical_address cannot be used as a hack to store real pointers.
Thus, add a new field to struct acpi_object_region to store the pointer for table regions, and propagate it to acpi_ex_data_table_space_handler via the region context, to use a more portable implementation that supports CHERI.
--- drivers/acpi/acpica/acevents.h | 5 ++++ drivers/acpi/acpica/acobject.h | 1 + drivers/acpi/acpica/dsopcode.c | 1 + drivers/acpi/acpica/evhandler.c | 2 +- drivers/acpi/acpica/evrgnini.c | 52 +++++++++++++++++++++++++++++++++ drivers/acpi/acpica/excreate.c | 1 + drivers/acpi/acpica/exregion.c | 15 +++++++--- include/acpi/actypes.h | 4 +++ 8 files changed, 76 insertions(+), 5 deletions(-)
drivers/acpi/acpica/acevents.h +5 -0
@@ -223,6 +223,11 @@ acpi_ev_pci_bar_region_setup(acpi_handle handle,u32 function, void *handler_context, void **region_context); +acpi_status +acpi_ev_data_table_region_setup (acpi_handle handle, +u32 function, +void *handler_context,void **region_context); + acpi_status acpi_ev_default_region_setup(acpi_handle handle, u32 function,
drivers/acpi/acpica/acobject.h +1 -0
@@ -138,6 +138,7 @@ struct acpi_object_region {union acpi_operand_object *next;acpi_physical_address address;u32 length; +void *pointer;/* Only for data table regions */ };struct acpi_object_method {
drivers/acpi/acpica/dsopcode.c +1 -0
@@ -531,6 +531,7 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state, obj_desc->region.address =ACPI_PTR_TO_PHYSADDR (table); obj_desc->region.length = table->length; + obj_desc->region.pointer = table; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", obj_desc,
drivers/acpi/acpica/evhandler.c +1 -1
@@ -386,7 +386,7 @@ acpi_ev_install_space_handler(struct acpi_namespace_node *node,case ACPI_ADR_SPACE_DATA_TABLE : handler = acpi_ex_data_table_space_handler; - setup =NULL ; + setup = acpi_ev_data_table_region_setup;break ;default :
drivers/acpi/acpica/evrgnini.c +52 -0
58 lines not on this page · raw message
drivers/acpi/acpica/excreate.c +1 -0
@@ -279,6 +279,7 @@ acpi_ex_create_region(u8 * aml_start, obj_desc->region.space_id = space_id; obj_desc->region.address =0 ; obj_desc->region.length =0 ; + obj_desc->region.pointer =NULL ; obj_desc->region.node = node; obj_desc->region.handler =NULL ; obj_desc->common.flags &=
drivers/acpi/acpica/exregion.c +11 -4
@@ -509,8 +509,15 @@ acpi_ex_data_table_space_handler(u32 function, u64 *value, void *handler_context, void *region_context) { +struct acpi_data_table_space_context *mapping; +char *pointer; +ACPI_FUNCTION_TRACE (ex_data_table_space_handler); + mapping = (struct acpi_data_table_space_context *) region_context; + pointer =ACPI_CAST_PTR (char, mapping->pointer) + + (address -ACPI_PTR_TO_PHYSADDR (mapping->pointer)); +/* * Perform the memory read or write. The bit_width was already * validated.
@@ -518,14 +525,14 @@ acpi_ex_data_table_space_handler(u32 function,switch (function) {case ACPI_READ : -memcpy (ACPI_CAST_PTR (char, value), -ACPI_PHYSADDR_TO_PTR (address),ACPI_DIV_8 (bit_width)); +memcpy (ACPI_CAST_PTR (char, value), pointer, +ACPI_DIV_8 (bit_width));break ;case ACPI_WRITE : -memcpy (ACPI_PHYSADDR_TO_PTR (address), -ACPI_CAST_PTR (char, value),ACPI_DIV_8 (bit_width)); +memcpy (pointer,ACPI_CAST_PTR (char, value), +ACPI_DIV_8 (bit_width));break ;default :
include/acpi/actypes.h +4 -0
@@ -1221,6 +1221,10 @@ struct acpi_mem_space_context {struct acpi_mem_mapping *first_mm; }; +struct acpi_data_table_space_context { +void *pointer; +}; +/* * struct acpi_memory_list is used only if the ACPICA local cache is enabled */
Signature · 1 line
2.26.2
PATCH 3/19 ACPICA: Use original pointer for virtual origin tables
In reply to Rafael J. WysockiFrom: Jessica Clarke <[email protected]>
ACPICA commit dfa3feffa8f760b686207d09dc880cd2f26c72af
Currently the pointer to the table is cast to acpi_physical_address and later cast back to a pointer to be dereferenced. Whether or not this is supported is implementation-defined.
On CHERI, and thus Arm's experimental Morello prototype architecture, pointers are represented as capabilities, which are unforgeable bounded pointers, providing always-on fine-grained spatial memory safety. This means that any pointer cast to a plain integer will lose all its associated metadata, and when cast back to a pointer it will give a null-derived pointer (one that has the same metadata as null but an address equal to the integer) that will trap on any dereference. As a result, this is an implementation where acpi_physical_address cannot be used as a hack to store real pointers.
Thus, alter the lifecycle of table descriptors. Internal physical tables keep the current behaviour where only the address is set on install, and the pointer is set on acquire. Virtual tables (internal and external) now store the pointer on initialisation and use that on acquire (which will redundantly set *table_ptr to itself, but changing that is both unnecessary and overly complicated as acpi_tb_acquire_table is called with both a pointer to a variable and a pointer to Table->Pointer itself).
This requires propagating the (possible) table pointer everywhere in order to make sure pointers make it through to acpi_tb_acquire_temp_table, which requires a change to the acpi_install_table interface. Instead of taking an ACPI_PHYSADDR_TYPE and a boolean indicating whether it's physical or virtual, it is now split into acpi_install_table (that takes an external virtual table pointer) and acpi_install_physical_table (that takes an ACPI_PHYSADDR_TYPE for an internal physical table address). This also has the benefit of providing a cleaner API.
--- drivers/acpi/acpica/actables.h | 8 ++- drivers/acpi/acpica/exconfig.c | 2 +- drivers/acpi/acpica/tbdata.c | 93 +++++++++++++++++++++++----------- drivers/acpi/acpica/tbfadt.c | 6 +-- drivers/acpi/acpica/tbinstal.c | 15 ++++-- drivers/acpi/acpica/tbutils.c | 2 +- drivers/acpi/acpica/tbxfload.c | 52 ++++++++++++++----- drivers/acpi/tables.c | 4 +- include/acpi/acpixf.h | 6 ++- 9 files changed, 129 insertions(+), 59 deletions(-)
drivers/acpi/acpica/actables.h +6 -2
@@ -35,7 +35,8 @@ acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,acpi_status acpi_tb_acquire_temp_table (struct acpi_table_desc *table_desc, -acpi_physical_address address,u8 flags); +acpi_physical_address address, +u8 flags,struct acpi_table_header *table);void acpi_tb_release_temp_table (struct acpi_table_desc *table_desc);
@@ -86,6 +87,7 @@ acpi_tb_release_table(struct acpi_table_header *table,acpi_status acpi_tb_install_standard_table (acpi_physical_address address,u8 flags, +struct acpi_table_header *table,u8 reload,u8 override,u32 *table_index);void acpi_tb_uninstall_table (struct acpi_table_desc *table_desc);
@@ -95,7 +97,9 @@ acpi_tb_load_table(u32 table_index, struct acpi_namespace_node *parent_node);acpi_status acpi_tb_install_and_load_table (acpi_physical_address address, -u8 flags,u8 override,u32 *table_index); +u8 flags, +struct acpi_table_header *table, +u8 override,u32 *table_index);acpi_status acpi_tb_unload_table (u32 table_index);
drivers/acpi/acpica/exconfig.c +1 -1
@@ -411,7 +411,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,acpi_ex_exit_interpreter (); status =acpi_tb_install_and_load_table (ACPI_PTR_TO_PHYSADDR (table),ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL , - TRUE, &table_index); + table, TRUE, &table_index);acpi_ex_enter_interpreter ();if (ACPI_FAILURE (status)) {
drivers/acpi/acpica/tbdata.c +63 -30
168 lines not on this page · raw message
drivers/acpi/acpica/tbfadt.c +3 -3
@@ -313,7 +313,7 @@ void acpi_tb_parse_fadt(void)acpi_tb_install_standard_table ((acpi_physical_address )acpi_gbl_FADT. Xdsdt,ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL , - FALSE, TRUE, &acpi_gbl_dsdt_index); +NULL , FALSE, TRUE, &acpi_gbl_dsdt_index);/* If Hardware Reduced flag is set, there is no FACS */
@@ -322,14 +322,14 @@ void acpi_tb_parse_fadt(void)acpi_tb_install_standard_table ((acpi_physical_address ) acpi_gbl_FADT.facs,ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL , - FALSE, TRUE, +NULL , FALSE, TRUE, &acpi_gbl_facs_index); }if (acpi_gbl_FADT.Xfacs) {acpi_tb_install_standard_table ((acpi_physical_address ) acpi_gbl_FADT.Xfacs,ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL , - FALSE, TRUE, +NULL , FALSE, TRUE, &acpi_gbl_xfacs_index); } }
drivers/acpi/acpica/tbinstal.c +11 -4
@@ -79,6 +79,8 @@ acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,* PARAMETERS: address - Address of the table (might be a virtual * address depending on the table_flags) * flags - Flags for the table +* table - Pointer to the table (required for virtual +* origins, optional for physical) * reload - Whether reload should be performed * override - Whether override should be performed * table_index - Where the table index is returned
@@ -96,6 +98,7 @@ acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,acpi_status acpi_tb_install_standard_table (acpi_physical_address address,u8 flags, +struct acpi_table_header *table,u8 reload,u8 override,u32 *table_index) {u32 i;
@@ -106,7 +109,8 @@ acpi_tb_install_standard_table(acpi_physical_address address,/* Acquire a temporary table descriptor for validation */ - status =acpi_tb_acquire_temp_table (&new_table_desc, address, flags); + status = +acpi_tb_acquire_temp_table (&new_table_desc, address, flags, table);if (ACPI_FAILURE (status)) { ACPI_ERROR((AE_INFO, "Could not acquire table length at %8.8X%8.8X",
@@ -209,7 +213,8 @@ void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)if (ACPI_SUCCESS (status) && table) {acpi_tb_acquire_temp_table (&new_table_desc,ACPI_PTR_TO_PHYSADDR (table), -ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL ); +ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL , + table);ACPI_ERROR_ONLY (override_type ="Logical" ); goto finish_override; }
@@ -220,7 +225,8 @@ void acpi_tb_override_table(struct acpi_table_desc *old_table_desc) &address, &length);if (ACPI_SUCCESS (status) && address && length) {acpi_tb_acquire_temp_table (&new_table_desc, address, -ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL ); +ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL , +NULL );ACPI_ERROR_ONLY (override_type ="Physical" ); goto finish_override; }
@@ -289,7 +295,8 @@ void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)if ((table_desc->flags &ACPI_TABLE_ORIGIN_MASK ) ==ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL ) { -ACPI_FREE (ACPI_PHYSADDR_TO_PTR (table_desc->address)); +ACPI_FREE (table_desc->pointer); + table_desc->pointer =NULL ; } table_desc->address =ACPI_PTR_TO_PHYSADDR (NULL );
drivers/acpi/acpica/tbutils.c +1 -1
@@ -328,7 +328,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address) status =acpi_tb_install_standard_table (address,ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL , - FALSE, TRUE, +NULL , FALSE, TRUE, &table_index); if (ACPI_SUCCESS(status) &&
drivers/acpi/acpica/tbxfload.c +38 -14
82 lines not on this page · raw message
drivers/acpi/tables.c +2 -2
@@ -723,7 +723,7 @@ static void __init acpi_table_initrd_scan(void)/* * Mark the table to avoid being used in * acpi_table_initrd_override(). Though this is not possible -* because override is disabled in acpi_install_table(). +* because override is disabled in acpi_install_physical_table(). */ if (test_and_set_bit (table_index, acpi_initrd_installed)) {acpi_os_unmap_memory (table,ACPI_HEADER_SIZE );
@@ -734,7 +734,7 @@ static void __init acpi_table_initrd_scan(void) table->signature, table->oem_id, table->oem_table_id);acpi_os_unmap_memory (table,ACPI_HEADER_SIZE ); -acpi_install_table (acpi_tables_addr + table_offset, TRUE); +acpi_install_physical_table (acpi_tables_addr + table_offset); next_table: table_offset += table_length; table_index++;
include/acpi/acpixf.h +4 -2
@@ -454,9 +454,11 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status* ACPI table load/unload interfaces */ ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION - acpi_install_table(acpi_physical_address address, -u8 physical)) + acpi_install_table(struct acpi_table_header *table)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION + acpi_install_physical_table(acpi_physical_address + address)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_load_table(struct acpi_table_header *table, u32 *table_idx))
Signature · 1 line
2.26.2
PATCH 4/19 ACPICA: Macros: Remove ACPI_PHYSADDR_TO_PTR
In reply to Rafael J. WysockiFrom: Jessica Clarke <[email protected]>
ACPICA commit 52abebd410945ec55afb4dd8b7150e8a39b5c960
This macro was only ever used when stuffing pointers into physical addresses and trying to later reconstruct the pointer, which is implementation-defined as to whether that can be done. Now that all such operations are gone, the macro is unused, and should be removed to avoid such practices being reintroduced.
--- include/acpi/actypes.h | 1 - 1 file changed, 1 deletion(-)
include/acpi/actypes.h +0 -1
@@ -509,7 +509,6 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0)#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) -#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)/* Optimizations for 4-character (32-bit) acpi_name manipulation */
Signature · 1 line
2.26.2
PATCH 5/19 ACPICA: Avoid subobject buffer overflow when validating RSDP signature
In reply to Rafael J. WysockiFrom: Jessica Clarke <[email protected]>
ACPICA commit 6bb72909c1e3d415aee214104a01bc9834b2d4ce
Since the Signature member is accessed through an struct acpi_table_header, the pointer to it is only to a 4-char array, and so trying to read past the 4th character, as will be done when it is an RSDP, reads beyond the bounds of the accessed member. On CHERI, and thus Arm's experimental Morello prototype architecture, pointers are represented as capabilities, which are unforgeable bounded pointers, providing always-on fine-grained spatial memory safety. By default, subobject bounds enforcement is not enabled, only bounds on allocations, but it is enabled in the cheri_BSD (a port of free_BSD) kernel as intra-object overflow attacks are common on operating system kernels, and so this overflow is detected there and traps.
--- drivers/acpi/acpica/tbprint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/acpica/tbprint.c +2 -1
@@ -101,7 +101,8 @@ acpi_tb_print_table_header(acpi_physical_address address,ACPI_INFO (("%-4.4s 0x%8.8X%8.8X %06X" , header->signature,ACPI_FORMAT_UINT64 (address), header->length)); - }else if (ACPI_VALIDATE_RSDP_SIG (header->signature)) { + } else if (ACPI_VALIDATE_RSDP_SIG(ACPI_CAST_PTR(struct acpi_table_rsdp, + header)->signature)) {/* RSDP has no common fields */
Signature · 1 line
2.26.2
PATCH 6/19 ACPICA: iASL/Disassembler: Additional support for NHLT table
In reply to Rafael J. WysockiFrom: Bob Moore <[email protected]>
ACPICA commit 0420852ffc520b81960e877852703b739c16025c
Added support for Vendor-defined microphone arrays and SNR (signal-to-noise) extension.
--- include/acpi/actbl2.h | 72 +++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 30 deletions(-)
include/acpi/actbl2.h +42 -30
@@ -1495,12 +1495,10 @@ struct acpi_nhlt_device_specific_config_a {/* Values for Config Type above */ -#define ACPI_NHLT_TYPE_MIC_ARRAY 0x01 -#define ACPI_NHLT_TYPE_GENERIC 0x00 - -/* Mask for Extension field of array_type */ - -#define ACPI_NHLT_ARRAY_TYPE_MASK 0x10 +#define ACPI_NHLT_CONFIG_TYPE_GENERIC 0x00 +#define ACPI_NHLT_CONFIG_TYPE_MIC_ARRAY 0x01 +#define ACPI_NHLT_CONFIG_TYPE_RENDER_FEEDBACK 0x03 +#define ACPI_NHLT_CONFIG_TYPE_RESERVED 0x04/* 4 and above are reserved */ struct acpi_nhlt_device_specific_config_b {u32 capabilities_size;
@@ -1511,6 +1509,11 @@ struct acpi_nhlt_device_specific_config_c {u8 virtual_slot; }; +struct acpi_nhlt_render_device_specific_config { +u32 capabilities_size; +u8 virtual_slot; +}; +struct acpi_nhlt_wave_extensible {u16 format_tag;u16 channel_count;
@@ -1573,17 +1576,22 @@ struct acpi_nhlt_mic_device_specific_config {/* Values for array_type_ext above */ -#define SMALL_LINEAR_2ELEMENT 0x0A -#define BIG_LINEAR_2ELEMENT 0x0B -#define FIRST_GEOMETRY_LINEAR_4ELEMENT 0x0C -#define PLANAR_LSHAPED_4ELEMENT 0x0D -#define SECOND_GEOMETRY_LINEAR_4ELEMENT 0x0E -#define VENDOR_DEFINED 0x0F -#define ARRAY_TYPE_MASK 0x0F -#define ARRAY_TYPE_EXT_MASK 0x10 +#define ACPI_NHLT_ARRAY_TYPE_RESERVED 0x09 // 9 and below are reserved +#define ACPI_NHLT_SMALL_LINEAR_2ELEMENT 0x0A +#define ACPI_NHLT_BIG_LINEAR_2ELEMENT 0x0B +#define ACPI_NHLT_FIRST_GEOMETRY_LINEAR_4ELEMENT 0x0C +#define ACPI_NHLT_PLANAR_LSHAPED_4ELEMENT 0x0D +#define ACPI_NHLT_SECOND_GEOMETRY_LINEAR_4ELEMENT 0x0E +#define ACPI_NHLT_VENDOR_DEFINED 0x0F +#define ACPI_NHLT_ARRAY_TYPE_MASK 0x0F +#define ACPI_NHLT_ARRAY_TYPE_EXT_MASK 0x10 + +#define ACPI_NHLT_NO_EXTENSION 0x0 +#define ACPI_NHLT_MIC_SNR_SENSITIVITY_EXT (1<<4) -#define NO_EXTENSION 0x0 -#define MIC_SNR_SENSITIVITY_EXT 0x1 +struct acpi_nhlt_vendor_mic_count { +u8 microphone_count; +};struct acpi_nhlt_vendor_mic_config {u8 type;
@@ -1603,22 +1611,25 @@ struct acpi_nhlt_vendor_mic_config {/* Values for Type field above */ -#define MIC_OMNIDIRECTIONAL 0 -#define MIC_SUBCARDIOID 1 -#define MIC_CARDIOID 2 -#define MIC_SUPER_CARDIOID 3 -#define MIC_HYPER_CARDIOID 4 -#define MIC_8_SHAPED 5 -#define MIC_VENDOR_DEFINED 7 +#define ACPI_NHLT_MIC_OMNIDIRECTIONAL 0 +#define ACPI_NHLT_MIC_SUBCARDIOID 1 +#define ACPI_NHLT_MIC_CARDIOID 2 +#define ACPI_NHLT_MIC_SUPER_CARDIOID 3 +#define ACPI_NHLT_MIC_HYPER_CARDIOID 4 +#define ACPI_NHLT_MIC_8_SHAPED 5 +#define ACPI_NHLT_MIC_RESERVED6 6 // 6 is reserved +#define ACPI_NHLT_MIC_VENDOR_DEFINED 7 +#define ACPI_NHLT_MIC_RESERVED 8 // 8 and above are reserved/* Values for Panel field above */ -#define MIC_TOP 0 -#define MIC_BOTTOM 1 -#define MIC_LEFT 2 -#define MIC_RIGHT 3 -#define MIC_FRONT 4 -#define MIC_REAR 5 +#define ACPI_NHLT_MIC_POSITION_TOP 0 +#define ACPI_NHLT_MIC_POSITION_BOTTOM 1 +#define ACPI_NHLT_MIC_POSITION_LEFT 2 +#define ACPI_NHLT_MIC_POSITION_RIGHT 3 +#define ACPI_NHLT_MIC_POSITION_FRONT 4 +#define ACPI_NHLT_MIC_POSITION_BACK 5 +#define ACPI_NHLT_MIC_POSITION_RESERVED 6 // 6 and above are reservedstruct acpi_nhlt_vendor_mic_device_specific_config {struct acpi_nhlt_mic_device_specific_config mic_array_device_config;
@@ -1633,8 +1644,9 @@ struct acpi_nhlt_mic_snr_sensitivity_extension {u32 sensitivity; }; +/* Render device with feedback */ +struct acpi_nhlt_render_feedback_device_specific_config { -struct acpi_nhlt_device_specific_config device_config;u8 feedback_virtual_slot;// render slot in case of capture u16 feedback_channels;// informative only u16 feedback_valid_bits_per_sample;
Signature · 1 line
2.26.2
PATCH 7/19 ACPICA: Fix AEST Processor generic resource substructure data field byte length
In reply to Rafael J. WysockiFrom: Shuuichirou Ishii <[email protected]>
ACPICA commit 13b9327761955f6e1e5dbf748b3112940c0dc539
The byte length of the Data field in the AEST Processor generic resource substructure defined in ACPI for the Armv8 RAS Extensions 1.1 is 4Byte. However, it is defined as a pointer type, and on a 64-bit machine, it is interpreted as 8 bytes. Therefore, it is changed from a pointer type unsigned integer 1 byte to an unsigned integer 4 bytes.
--- include/acpi/actbl2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/actbl2.h +1 -1
@@ -154,7 +154,7 @@ typedef struct acpi_aest_processor_tlb {/* 2R: Processor Generic Resource Substructure */ typedef struct acpi_aest_processor_generic { -u8 *resource; +u32 resource; }acpi_aest_processor_generic ;
Signature · 1 line
2.26.2
PATCH 8/19 ACPICA: Utilities: Avoid deleting the same object twice in a row
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
ACPICA commit c11af67d8f7e3d381068ce7771322f2b5324d687
If original_count is 0 in acpi_ut_update_ref_count (), acpi_ut_delete_internal_obj () is invoked for the target object, which is incorrect, because that object has been deleted once already and the memory allocated to store it may have been reclaimed and allocated for a different purpose by the host OS. Moreover, a confusing debug message following the "Reference Count is already zero, cannot decrement" warning is printed in that case.
To fix this issue, make acpi_ut_update_ref_count () return after finding that original_count is 0 and printing the above warning.
--- drivers/acpi/acpica/utdelete.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpica/utdelete.c +1 -0
@@ -422,6 +422,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)ACPI_WARNING ((AE_INFO ,"Obj %p, Reference Count is already zero, cannot decrement\n" , object)); +return ; } ACPI_DEBUG_PRINT_RAW((ACPI_DB_ALLOCATIONS,
Signature · 1 line
2.26.2
PATCH 9/19 ACPICA: Executer: Fix the REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R()
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
ACPICA commit d984f12041392fa4156b52e2f7e5c5e7bc38ad9e
If Operand[0] is a reference of the ACPI_REFCLASS_REFOF class, acpi_ex_opcode_1A_0T_1R () calls acpi_ns_get_attached_object () to obtain return_desc which may require additional resolution with the help of acpi_ex_read_data_from_field (). If the latter fails, the reference counter of the original return_desc is decremented which is incorrect, because acpi_ns_get_attached_object () does not increment the reference counter of the object returned by it.
This issue may lead to premature deletion of the attached object while it is still attached and a use-after-free and crash in the host OS. For example, this may happen when on evaluation of ref_of() a local region field where there is no registered handler for the given Operation Region.
Fix it by making acpi_ex_opcode_1A_0T_1R () return Status right away after a acpi_ex_read_data_from_field () failure.
--- drivers/acpi/acpica/exoparg1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/acpica/exoparg1.c +2 -1
@@ -1007,7 +1007,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) (walk_state, return_desc, &temp_desc);if (ACPI_FAILURE (status)) { - goto cleanup; +return_ACPI_STATUS + (status); } return_desc = temp_desc;
Signature · 1 line
2.26.2
PATCH 10/19 ACPICA: Fix wrong interpretation of PCC address
In reply to Rafael J. WysockiFrom: Sudeep Holla <[email protected]>
ACPICA commit 41be6afacfdaec2dba3a5ed368736babc2a7aa5c
With the PCC Opregion in the firmware and we are hitting below kernel crash:
-->8
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 Workqueue: pm pm_runtime_work pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : __memcpy+0x54/0x260 lr : acpi_ex_write_data_to_field+0xb8/0x194 Call trace: __memcpy+0x54/0x260 acpi_ex_store_object_to_node+0xa4/0x1d4 acpi_ex_store+0x44/0x164 acpi_ex_opcode_1A_1T_1R+0x25c/0x508 acpi_ds_exec_end_op+0x1b4/0x44c acpi_ps_parse_loop+0x3a8/0x614 acpi_ps_parse_aml+0x90/0x2f4 acpi_ps_execute_method+0x11c/0x19c acpi_ns_evaluate+0x1ec/0x2b0 acpi_evaluate_object+0x170/0x2b0 acpi_device_set_power+0x118/0x310 acpi_dev_suspend+0xd4/0x180 acpi_subsys_runtime_suspend+0x28/0x38 __rpm_callback+0x74/0x328 rpm_suspend+0x2d8/0x624 pm_runtime_work+0xa4/0xb8 process_one_work+0x194/0x25c worker_thread+0x260/0x49c kthread+0x14c/0x30c ret_from_fork+0x10/0x20 Code: f9000006 f81f80a7 d65f03c0 361000c2 (b9400026) ---[ end trace 24d8a032fa77b68a ]---
The reason for the crash is that the PCC channel index passed via region.address in acpi_ex_store_object_to_node is interpreted as the channel subtype incorrectly.
Assuming the PCC op_region support is not used by any other type, let us remove the subtype check as the AML has no access to the subtype information. Once we remove it, the kernel crash disappears and correctly complains about missing PCC Opregion handler.
ACPI Error: No handler for Region [PFRM] ((____ptrval____)) [PCC] (20210730/evregion-130) ACPI Error: Region PCC (ID=10) has no handler (20210730/exfldio-261)
ACPI Error: Aborting method \_SB.ETH0._PS3 due to previous error (AE_NOT_EXIST) (20210730/psparse-531)
--- drivers/acpi/acpica/exfield.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/acpi/acpica/exfield.c +1 -6
@@ -330,12 +330,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, obj_desc->field.base_byte_offset, source_desc->buffer.pointer, data_length); -if ((obj_desc->field.region_obj->region.address == -PCC_MASTER_SUBSPACE - &&MASTER_SUBSPACE_COMMAND (obj_desc->field. - base_byte_offset)) - ||GENERIC_SUBSPACE_COMMAND (obj_desc->field. - base_byte_offset)) { +if (MASTER_SUBSPACE_COMMAND (obj_desc->field.base_byte_offset)) {/* Perform the write */
Signature · 1 line
2.26.2
PATCH 11/19 ACPICA: Add support for PCC Opregion special context data
In reply to Rafael J. WysockiFrom: Sudeep Holla <[email protected]>
ACPICA commit 55526e8a6133cbf5a9cc0fb75a95dbbac6eb98e6
PCC Opregion added in ACPIC 6.3 requires special context data similar to GPIO and Generic Serial Bus as it needs to know the internal PCC buffer and its length as well as the PCC channel index when the opregion handler is being executed by the OSPM.
Lets add support for the special context data needed by PCC Opregion.
--- drivers/acpi/acpica/evregion.c | 10 ++++++++++ include/acpi/actypes.h | 8 ++++++++ 2 files changed, 18 insertions(+)
drivers/acpi/acpica/evregion.c +10 -0
@@ -162,6 +162,16 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,return_ACPI_STATUS (AE_NOT_EXIST ); } +if (region_obj->region.space_id ==ACPI_ADR_SPACE_PLATFORM_COMM ) { +struct acpi_pcc_info *ctx = + handler_desc->address_space.context; + + ctx->internal_buffer = + field_obj->field.internal_pcc_buffer; + ctx->length = region_obj->region.length; + ctx->subspace_id = region_obj->region.address; + } +/* * We must exit the interpreter because the region setup will * potentially execute control methods (for example, the _REG method
include/acpi/actypes.h +8 -0
@@ -1103,6 +1103,14 @@ struct acpi_connection_info {u8 access_length; }; +/* Special Context data for PCC Opregion (ACPI 6.3) */ + +struct acpi_pcc_info { +u8 subspace_id; +u16 length; +u8 *internal_buffer; +}; +typedef acpi_status (*acpi_adr_space_setup) (acpi_handle region_handle, u32 function,
Signature · 1 line
2.26.2
PATCH 12/19 ACPICA: Hardware: Do not flush CPU cache when entering S4 and S5
In reply to Rafael J. WysockiFrom: "Kirill A. Shutemov" <[email protected]>
ACPICA commit 3dd7e1f3996456ef81bfe14cba29860e8d42949e
According to ACPI 6.4, Section 16.2, the CPU cache flushing is required on entering to S1, S2, and S3, but the ACPICA code flushes the CPU cache regardless of the sleep state.
Blind cache flush on entering S5 causes problems for TDX.
Flushing happens with WBINVD that is not supported in the TDX environment.
TDX only supports S5 and adjusting ACPICA code to conform to the spec more strictly fixes the issue.
--- drivers/acpi/acpica/hwesleep.c | 4 +++- drivers/acpi/acpica/hwsleep.c | 4 +++- drivers/acpi/acpica/hwxfsleep.c | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/acpica/hwesleep.c +3 -1
@@ -104,7 +104,9 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)/* Flush caches, as per ACPI specification */ -ACPI_FLUSH_CPU_CACHE (); +if (sleep_state <ACPI_STATE_S4 ) { +ACPI_FLUSH_CPU_CACHE (); + } status =acpi_os_enter_sleep (sleep_state, sleep_control,0 );if (status ==AE_CTRL_TERMINATE ) {
drivers/acpi/acpica/hwsleep.c +3 -1
@@ -110,7 +110,9 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)/* Flush caches, as per ACPI specification */ -ACPI_FLUSH_CPU_CACHE (); +if (sleep_state <ACPI_STATE_S4 ) { +ACPI_FLUSH_CPU_CACHE (); + } status =acpi_os_enter_sleep (sleep_state, pm1a_control, pm1b_control);if (status ==AE_CTRL_TERMINATE ) {
drivers/acpi/acpica/hwxfsleep.c +0 -2
@@ -162,8 +162,6 @@ acpi_status acpi_enter_sleep_state_s4bios(void)return_ACPI_STATUS (status); } -ACPI_FLUSH_CPU_CACHE (); - status =acpi_hw_write_port (acpi_gbl_FADT.smi_command, (u32 )acpi_gbl_FADT.s4_bios_request,8 );if (ACPI_FAILURE (status)) {
Signature · 1 line
2.26.2
PATCH 14/19 ACPICA: Change a return_ACPI_STATUS (AE_BAD_PARAMETER)
In reply to Rafael J. WysockiFrom: Bob Moore <[email protected]>
ACPICA commit ff803279dde7a3e068a6a698d8c69503cd159ad7
To simply return (AE_BAD_PARAMETER); to fix compilation on MSVC.
--- drivers/acpi/acpica/tbdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/tbdata.c +1 -1
@@ -249,7 +249,7 @@ acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL :if (!table) { -return_ACPI_STATUS (AE_BAD_PARAMETER ); +return (AE_BAD_PARAMETER ); }break ;
Signature · 1 line
2.26.2
PATCH 15/19 ACPICA: Fixed a couple of warnings under MSVC
In reply to Rafael J. WysockiFrom: Bob Moore <[email protected]>
ACPICA commit 86c919d2bad08491fc91ffa53e9b169092de8622
Repaired with casts.
--- drivers/acpi/acpica/evregion.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpica/evregion.c +2 -2
@@ -168,8 +168,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, ctx->internal_buffer = field_obj->field.internal_pcc_buffer; - ctx->length = region_obj->region.length; - ctx->subspace_id = region_obj->region.address; + ctx->length = (u16 )region_obj->region.length; + ctx->subspace_id = (u8 )region_obj->region.address; }/*
Signature · 1 line
2.26.2
PATCH 16/19 ACPICA: iASL: Add TDEL table to both compiler/disassembler
In reply to Rafael J. WysockiFrom: Bob Moore <[email protected]>
ACPICA commit 403f9965aba7ff9d2ed5b41bbffdd2a1ed0f596f
Added struct acpi_pcc_info to acpi_src.
--- include/acpi/actbl2.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/acpi/actbl2.h +17 -0
@@ -48,6 +48,7 @@#define ACPI_SIG_SDEI "SDEI"/* Software Delegated Exception Interface Table */ #define ACPI_SIG_SDEV "SDEV"/* Secure Devices table */ #define ACPI_SIG_SVKL "SVKL"/* Storage Volume Key Location Table */ +#define ACPI_SIG_TDEL "TDEL"/* TD Event Log Table */ /* * All tables must be byte-packed to match the ACPI specification, since
@@ -2487,6 +2488,22 @@ enum acpi_svkl_format { ACPI_SVKL_FORMAT_RESERVED = 1 /* 1 and greater are reserved */ }; +/******************************************************************************* +* +* TDEL - TD-Event Log +* From: "Guest-Host-Communication Interface (GHCI) for Intel +* Trust Domain Extensions (Intel TDX)". +* September 2020 +* +******************************************************************************/ + +struct acpi_table_tdel { +struct acpi_table_header header;/* Common ACPI table header */ +u32 reserved; +u64 log_area_minimum_length; +u64 log_area_start_address; +}; +/* Reset to default packing */ #pragma pack()
Signature · 1 line
2.26.2
PATCH 17/19 ACPICA: iASL: Add suppport for AGDI table
In reply to Rafael J. WysockiFrom: Ilkka Koskinen <[email protected]>
ACPICA commit cf36a6d658ca5aa8c329c2edfc3322c095ffd844
Add support for Arm Generic Diagnostic Dump and Reset Interface, which is described by "ACPI for Arm Components 1.1 Platform Design Document" ARM DEN0093.
Add the necessary types in the ACPICA header files and support for compiling and decompiling the table.
--- include/acpi/actbl2.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/acpi/actbl2.h +20 -0
@@ -24,6 +24,7 @@* file. Useful because they make it more difficult to inadvertently type in * the wrong signature. */ +#define ACPI_SIG_AGDI "AGDI"/* Arm Generic Diagnostic Dump and Reset Device Interface */ #define ACPI_SIG_BDAT "BDAT"/* BIOS Data ACPI Table */ #define ACPI_SIG_IORT "IORT"/* IO Remapping Table */ #define ACPI_SIG_IVRS "IVRS"/* I/O Virtualization Reporting Structure */
@@ -238,6 +239,25 @@ typedef struct acpi_aest_node_interrupt {#define ACPI_AEST_NODE_ERROR_RECOVERY 1#define ACPI_AEST_XRUPT_RESERVED 2/* 2 and above are reserved */ +/******************************************************************************* +* AGDI - Arm Generic Diagnostic Dump and Reset Device Interface +* +* Conforms to "ACPI for Arm Components 1.1, Platform Design Document" +* ARM DEN0093 v1.1 +* +******************************************************************************/ +struct acpi_table_agdi { +struct acpi_table_header header;/* Common ACPI table header */ +u8 flags; +u8 reserved[3 ]; +u32 sdei_event; +u32 gsiv; +}; + +/* Mask for Flags field above */ + +#define ACPI_AGDI_SIGNALING_MODE (1) +/******************************************************************************* * * BDAT - BIOS Data ACPI Table
Signature · 1 line
2.26.2
PATCH 18/19 ACPICA: iASL/NHLT table: "Specific Data" field support
In reply to Rafael J. WysockiFrom: Bob Moore <[email protected]>
ACPICA commit 26f8c721fb01e4a26eec8c85dffcbe950d5e61a9
Add support for optional "Specific Data" field for the optional Linux-specific structure that appears at the end of an Endpoint Descriptor.
--- include/acpi/actbl2.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/acpi/actbl2.h +4 -1
@@ -1703,7 +1703,10 @@ struct acpi_nhlt_linux_specific_data {u8 device_id[16 ];u8 device_instance_id;u8 device_port_id; -u8 filler[18 ]; +}; + +struct acpi_nhlt_linux_specific_data_b { +u8 specific_data[18 ]; };struct acpi_nhlt_table_terminator {
Signature · 1 line
2.26.2
PATCH 19/19 ACPICA: Update version to 20211217
In reply to Rafael J. WysockiFrom: Bob Moore <[email protected]>
ACPICA commit 90088defcb99e122edf41038ae5c901206c86dc9
Version 20211217.
--- include/acpi/acpixf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/acpixf.h +1 -1
@@ -12,7 +12,7 @@/* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20210930 +#define ACPI_CA_VERSION 0x20211217#include <acpi/acconfig.h> #include <acpi/actypes.h>
Signature · 1 line
2.26.2