Skip to content

Commit

Permalink
Cleanup of invalid ACPI name handling and repair
Browse files Browse the repository at this point in the history
 Implemented a change/cleanup for the handling of invalid ACPI names.
 Names are now validated and repaired only when
 1) entering a new name into the namespace and
 2) disassembling a named AML opcode. A warning is only displayed in
    debug mode or when the interpreter is in "strict" mode, since some
    working machines do in fact contain invalid ACPI names.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Bob Moore authored and Rafael J. Wysocki committed Nov 14, 2012
1 parent 77b6706 commit 45dcd31
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void acpi_ut_print_string(char *string, u8 max_length);

u8 acpi_ut_valid_acpi_name(u32 name);

acpi_name acpi_ut_repair_name(char *name);
void acpi_ut_repair_name(char *name);

u8 acpi_ut_valid_acpi_char(char character, u32 position);

Expand Down
8 changes: 0 additions & 8 deletions drivers/acpi/acpica/nsdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,6 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
"Invalid ACPI Object Type 0x%08X", type));
}

if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
this_node->name.integer =
acpi_ut_repair_name(this_node->name.ascii);

ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
this_node->name.integer));
}

acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
}

Expand Down
17 changes: 1 addition & 16 deletions drivers/acpi/acpica/nssearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,7 @@ acpi_ns_search_and_enter(u32 target_name,
* this problem, and we want to be able to enable ACPI support for them,
* even though there are a few bad names.
*/
if (!acpi_ut_valid_acpi_name(target_name)) {
target_name =
acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name));

/* Report warning only if in strict mode or debug mode */

if (!acpi_gbl_enable_interpreter_slack) {
ACPI_WARNING((AE_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
ACPI_CAST_PTR(char, &target_name)));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
ACPI_CAST_PTR(char, &target_name)));
}
}
acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name));

/* Try to find the name in the namespace level specified by the caller */

Expand Down
34 changes: 26 additions & 8 deletions drivers/acpi/acpica/utmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,25 +642,43 @@ u8 acpi_ut_valid_acpi_name(u32 name)
*
******************************************************************************/

acpi_name acpi_ut_repair_name(char *name)
void acpi_ut_repair_name(char *name)
{
u32 i;
char new_name[ACPI_NAME_SIZE];
u32 i;
u8 found_bad_char = FALSE;

ACPI_FUNCTION_NAME(ut_repair_name);

/* Check each character in the name */

for (i = 0; i < ACPI_NAME_SIZE; i++) {
new_name[i] = name[i];
if (acpi_ut_valid_acpi_char(name[i], i)) {
continue;
}

/*
* Replace a bad character with something printable, yet technically
* still invalid. This prevents any collisions with existing "good"
* names in the namespace.
*/
if (!acpi_ut_valid_acpi_char(name[i], i)) {
new_name[i] = '*';
}
name[i] = '*';
found_bad_char = TRUE;
}

return (*(u32 *) new_name);
if (found_bad_char) {

/* Report warning only if in strict mode or debug mode */

if (!acpi_gbl_enable_interpreter_slack) {
ACPI_WARNING((AE_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
name));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
name));
}
}
}

/*******************************************************************************
Expand Down

0 comments on commit 45dcd31

Please sign in to comment.