diff options
author | Bob Moore <robert.moore@intel.com> | 2012-10-30 22:24:51 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:31:21 -0500 |
commit | 45dcd31547fcd58273423799b12efe0e8371127e (patch) | |
tree | fc89c938a91796caa1ee581f45581a05d806aa16 /drivers/acpi/acpica | |
parent | 77b67063bb6bce6d475e910d3b886a606d0d91f7 (diff) |
Cleanup of invalid ACPI name handling and repair
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>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/acutils.h | 2 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsdump.c | 8 | ||||
-rw-r--r-- | drivers/acpi/acpica/nssearch.c | 17 | ||||
-rw-r--r-- | drivers/acpi/acpica/utmisc.c | 34 |
4 files changed, 28 insertions, 33 deletions
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 5035327ebccc..68cb6de26d13 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
@@ -483,7 +483,7 @@ void acpi_ut_print_string(char *string, u8 max_length); | |||
483 | 483 | ||
484 | u8 acpi_ut_valid_acpi_name(u32 name); | 484 | u8 acpi_ut_valid_acpi_name(u32 name); |
485 | 485 | ||
486 | acpi_name acpi_ut_repair_name(char *name); | 486 | void acpi_ut_repair_name(char *name); |
487 | 487 | ||
488 | u8 acpi_ut_valid_acpi_char(char character, u32 position); | 488 | u8 acpi_ut_valid_acpi_char(char character, u32 position); |
489 | 489 | ||
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index 2526aaf945ee..993b12417e7f 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c | |||
@@ -209,14 +209,6 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, | |||
209 | "Invalid ACPI Object Type 0x%08X", type)); | 209 | "Invalid ACPI Object Type 0x%08X", type)); |
210 | } | 210 | } |
211 | 211 | ||
212 | if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { | ||
213 | this_node->name.integer = | ||
214 | acpi_ut_repair_name(this_node->name.ascii); | ||
215 | |||
216 | ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X", | ||
217 | this_node->name.integer)); | ||
218 | } | ||
219 | |||
220 | acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); | 212 | acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); |
221 | } | 213 | } |
222 | 214 | ||
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c index 456cc859f869..1d2d8ffc1bc5 100644 --- a/drivers/acpi/acpica/nssearch.c +++ b/drivers/acpi/acpica/nssearch.c | |||
@@ -314,22 +314,7 @@ acpi_ns_search_and_enter(u32 target_name, | |||
314 | * this problem, and we want to be able to enable ACPI support for them, | 314 | * this problem, and we want to be able to enable ACPI support for them, |
315 | * even though there are a few bad names. | 315 | * even though there are a few bad names. |
316 | */ | 316 | */ |
317 | if (!acpi_ut_valid_acpi_name(target_name)) { | 317 | acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name)); |
318 | target_name = | ||
319 | acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name)); | ||
320 | |||
321 | /* Report warning only if in strict mode or debug mode */ | ||
322 | |||
323 | if (!acpi_gbl_enable_interpreter_slack) { | ||
324 | ACPI_WARNING((AE_INFO, | ||
325 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
326 | ACPI_CAST_PTR(char, &target_name))); | ||
327 | } else { | ||
328 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
329 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
330 | ACPI_CAST_PTR(char, &target_name))); | ||
331 | } | ||
332 | } | ||
333 | 318 | ||
334 | /* Try to find the name in the namespace level specified by the caller */ | 319 | /* Try to find the name in the namespace level specified by the caller */ |
335 | 320 | ||
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index 33c6cf7ff467..d91d88df2a96 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c | |||
@@ -642,25 +642,43 @@ u8 acpi_ut_valid_acpi_name(u32 name) | |||
642 | * | 642 | * |
643 | ******************************************************************************/ | 643 | ******************************************************************************/ |
644 | 644 | ||
645 | acpi_name acpi_ut_repair_name(char *name) | 645 | void acpi_ut_repair_name(char *name) |
646 | { | 646 | { |
647 | u32 i; | 647 | u32 i; |
648 | char new_name[ACPI_NAME_SIZE]; | 648 | u8 found_bad_char = FALSE; |
649 | |||
650 | ACPI_FUNCTION_NAME(ut_repair_name); | ||
651 | |||
652 | /* Check each character in the name */ | ||
649 | 653 | ||
650 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | 654 | for (i = 0; i < ACPI_NAME_SIZE; i++) { |
651 | new_name[i] = name[i]; | 655 | if (acpi_ut_valid_acpi_char(name[i], i)) { |
656 | continue; | ||
657 | } | ||
652 | 658 | ||
653 | /* | 659 | /* |
654 | * Replace a bad character with something printable, yet technically | 660 | * Replace a bad character with something printable, yet technically |
655 | * still invalid. This prevents any collisions with existing "good" | 661 | * still invalid. This prevents any collisions with existing "good" |
656 | * names in the namespace. | 662 | * names in the namespace. |
657 | */ | 663 | */ |
658 | if (!acpi_ut_valid_acpi_char(name[i], i)) { | 664 | name[i] = '*'; |
659 | new_name[i] = '*'; | 665 | found_bad_char = TRUE; |
660 | } | ||
661 | } | 666 | } |
662 | 667 | ||
663 | return (*(u32 *) new_name); | 668 | if (found_bad_char) { |
669 | |||
670 | /* Report warning only if in strict mode or debug mode */ | ||
671 | |||
672 | if (!acpi_gbl_enable_interpreter_slack) { | ||
673 | ACPI_WARNING((AE_INFO, | ||
674 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
675 | name)); | ||
676 | } else { | ||
677 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
678 | "Found bad character(s) in name, repaired: [%4.4s]\n", | ||
679 | name)); | ||
680 | } | ||
681 | } | ||
664 | } | 682 | } |
665 | 683 | ||
666 | /******************************************************************************* | 684 | /******************************************************************************* |