Commit 24058054 authored by Bob Moore's avatar Bob Moore Committed by Len Brown

ACPICA: Handle mis-matched package length

Implement support within the AML interpreter for
package objects that contain a mismatch between the AML
length and package element count. In this case, the lesser
of the two is used. Some BIOS code apparently modifies
the package length on the fly, and this change supports
this. Provides compatibility with the MS AML interpreter.
Signed-off-by: default avatarAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent c9e3ba2c
...@@ -318,9 +318,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, ...@@ -318,9 +318,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
obj_desc->package.node = parent->common.node; obj_desc->package.node = parent->common.node;
} }
obj_desc->package.count = package_length; /* Count the *actual* number of items in the package list */
/* Count the number of items in the package list */
arg = op->common.value.arg; arg = op->common.value.arg;
arg = arg->common.next; arg = arg->common.next;
...@@ -329,12 +327,25 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, ...@@ -329,12 +327,25 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
} }
/* /*
* The package length (number of elements) will be the greater * The number of elements in the package will be the lesser of the
* of the specified length and the length of the initializer list * specified element count and the length of the initializer list.
*
* Even though the ASL compilers do not allow this to happen (for the
* fixed length package opcode), some BIOS code modifies the AML on the
* fly to adjust the package length, and this code compensates for that.
* This also provides compatibility with other AML interpreters.
*/ */
if (package_list_length > package_length) { obj_desc->package.count = package_length;
if (package_list_length != package_length) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Package length mismatch, using lesser of %X(Length Arg) and %X(AML Length)\n",
package_length, package_list_length));
if (package_list_length < package_length) {
obj_desc->package.count = package_list_length; obj_desc->package.count = package_list_length;
} }
}
/* /*
* Allocate the pointer array (array of pointers to the * Allocate the pointer array (array of pointers to the
...@@ -356,7 +367,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, ...@@ -356,7 +367,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
*/ */
arg = op->common.value.arg; arg = op->common.value.arg;
arg = arg->common.next; arg = arg->common.next;
for (i = 0; arg; i++) { for (i = 0; i < obj_desc->package.count; i++) {
if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
/* Object (package or buffer) is already built */ /* Object (package or buffer) is already built */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment