From c647eb98b0852367752ab22dbf97e9ff146f0c21 Mon Sep 17 00:00:00 2001 From: Erik Schmauss Date: Mon, 5 Nov 2018 09:43:51 -0800 Subject: ACPICA: Debugger: refactor to fix unused variable warning When building ACPICA in the Linux kernel with Clang with ACPI_DISASSEMBLER not defined, we get a the following warning on variable display_op: warning: variable 'display_op' set but not used [-Wunused-but-set-variable] Fix this by refactoring display_op and parent_op code in a separate function. Suggested-by: Colin Ian King Signed-off-by: Erik Schmauss Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/dbxface.c | 118 ++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 44 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c index f2526726daf6..3eb45ea93e5e 100644 --- a/drivers/acpi/acpica/dbxface.c +++ b/drivers/acpi/acpica/dbxface.c @@ -24,6 +24,13 @@ acpi_db_start_command(struct acpi_walk_state *walk_state, void acpi_db_method_end(struct acpi_walk_state *walk_state); #endif +#ifdef ACPI_DISASSEMBLER +static union acpi_parse_object *acpi_db_get_display_op(struct acpi_walk_state + *walk_state, + union acpi_parse_object + *op); +#endif + /******************************************************************************* * * FUNCTION: acpi_db_start_command @@ -113,6 +120,70 @@ void acpi_db_signal_break_point(struct acpi_walk_state *walk_state) acpi_os_printf("**break** Executed AML BreakPoint opcode\n"); } +#ifdef ACPI_DISASSEMBLER +/******************************************************************************* + * + * FUNCTION: acpi_db_get_display_op + * + * PARAMETERS: walk_state - Current walk + * op - Current executing op (from aml interpreter) + * + * RETURN: Opcode to display + * + * DESCRIPTION: Find the opcode to display during single stepping + * + ******************************************************************************/ + +static union acpi_parse_object *acpi_db_get_display_op(struct acpi_walk_state + *walk_state, + union acpi_parse_object + *op) +{ + union acpi_parse_object *display_op; + union acpi_parse_object *parent_op; + + display_op = op; + parent_op = op->common.parent; + if (parent_op) { + if ((walk_state->control_state) && + (walk_state->control_state->common.state == + ACPI_CONTROL_PREDICATE_EXECUTING)) { + /* + * We are executing the predicate of an IF or WHILE statement + * Search upwards for the containing IF or WHILE so that the + * entire predicate can be displayed. + */ + while (parent_op) { + if ((parent_op->common.aml_opcode == AML_IF_OP) + || (parent_op->common.aml_opcode == + AML_WHILE_OP)) { + display_op = parent_op; + break; + } + parent_op = parent_op->common.parent; + } + } else { + while (parent_op) { + if ((parent_op->common.aml_opcode == AML_IF_OP) + || (parent_op->common.aml_opcode == + AML_ELSE_OP) + || (parent_op->common.aml_opcode == + AML_SCOPE_OP) + || (parent_op->common.aml_opcode == + AML_METHOD_OP) + || (parent_op->common.aml_opcode == + AML_WHILE_OP)) { + break; + } + display_op = parent_op; + parent_op = parent_op->common.parent; + } + } + } + return display_op; +} +#endif + /******************************************************************************* * * FUNCTION: acpi_db_single_step @@ -134,8 +205,6 @@ acpi_db_single_step(struct acpi_walk_state *walk_state, union acpi_parse_object *next; acpi_status status = AE_OK; u32 original_debug_level; - union acpi_parse_object *display_op; - union acpi_parse_object *parent_op; u32 aml_offset; ACPI_FUNCTION_ENTRY(); @@ -222,51 +291,12 @@ acpi_db_single_step(struct acpi_walk_state *walk_state, next = op->common.next; op->common.next = NULL; - display_op = op; - parent_op = op->common.parent; - if (parent_op) { - if ((walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_PREDICATE_EXECUTING)) { - /* - * We are executing the predicate of an IF or WHILE statement - * Search upwards for the containing IF or WHILE so that the - * entire predicate can be displayed. - */ - while (parent_op) { - if ((parent_op->common.aml_opcode == - AML_IF_OP) - || (parent_op->common.aml_opcode == - AML_WHILE_OP)) { - display_op = parent_op; - break; - } - parent_op = parent_op->common.parent; - } - } else { - while (parent_op) { - if ((parent_op->common.aml_opcode == - AML_IF_OP) - || (parent_op->common.aml_opcode == - AML_ELSE_OP) - || (parent_op->common.aml_opcode == - AML_SCOPE_OP) - || (parent_op->common.aml_opcode == - AML_METHOD_OP) - || (parent_op->common.aml_opcode == - AML_WHILE_OP)) { - break; - } - display_op = parent_op; - parent_op = parent_op->common.parent; - } - } - } - /* Now we can disassemble and display it */ #ifdef ACPI_DISASSEMBLER - acpi_dm_disassemble(walk_state, display_op, ACPI_UINT32_MAX); + acpi_dm_disassemble(walk_state, + acpi_db_get_display_op(walk_state, op), + ACPI_UINT32_MAX); #else /* * The AML Disassembler is not configured - at least we can -- cgit v1.2.3 From 927a6abf023b1a8c6940880802fc17026be6a351 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 5 Nov 2018 09:43:54 -0800 Subject: ACPICA: iASL: Enhance error detection Enhance error detection by validating that all name_seg elements within a name_path actually exist. The previous behavior was spotty at best, and such errors could be improperly ignored at compile time (never at runtime, however). There are two new error messages. Signed-off-by: Bob Moore Signed-off-by: Erik Schmauss Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/acnamesp.h | 1 + drivers/acpi/acpica/dswload2.c | 8 ++++++++ drivers/acpi/acpica/nsaccess.c | 23 +++++++++++++++++++++-- drivers/acpi/acpica/psloop.c | 8 +++----- drivers/acpi/acpica/psobject.c | 3 +-- 5 files changed, 34 insertions(+), 9 deletions(-) (limited to 'drivers/acpi/acpica') diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index bbb3b4d1e796..9bd25f36c608 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h @@ -34,6 +34,7 @@ #define ACPI_NS_TEMPORARY 0x0040 #define ACPI_NS_OVERRIDE_IF_FOUND 0x0080 #define ACPI_NS_EARLY_INIT 0x0100 +#define ACPI_NS_PREFIX_MUST_EXIST 0x0200 /* Flags for acpi_ns_walk_namespace */ diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c index b4685bb5f071..fa38bb3009d5 100644 --- a/drivers/acpi/acpica/dswload2.c +++ b/drivers/acpi/acpica/dswload2.c @@ -296,6 +296,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, } #endif + /* + * For name creation opcodes, the full namepath prefix must + * exist, except for the final (new) nameseg. + */ + if (walk_state->op_info->flags & AML_NAMED) { + flags |= ACPI_NS_PREFIX_MUST_EXIST; + } + /* Add new entry or lookup existing entry */ status = diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index e3f10afde5ff..75192b958544 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c @@ -267,6 +267,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, acpi_object_type this_search_type; u32 search_parent_flag = ACPI_NS_SEARCH_PARENT; u32 local_flags; + acpi_interpreter_mode local_interpreter_mode; ACPI_FUNCTION_TRACE(ns_lookup); @@ -506,6 +507,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, */ this_search_type = ACPI_TYPE_ANY; current_node = this_node; + while (num_segments && current_node) { num_segments--; if (!num_segments) { @@ -536,6 +538,16 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, } } + /* Handle opcodes that create a new name_seg via a full name_path */ + + local_interpreter_mode = interpreter_mode; + if ((flags & ACPI_NS_PREFIX_MUST_EXIST) && (num_segments > 0)) { + + /* Every element of the path must exist (except for the final name_seg) */ + + local_interpreter_mode = ACPI_IMODE_EXECUTE; + } + /* Extract one ACPI name from the front of the pathname */ ACPI_MOVE_32_TO_32(&simple_name, path); @@ -544,12 +556,19 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, status = acpi_ns_search_and_enter(simple_name, walk_state, - current_node, interpreter_mode, + current_node, + local_interpreter_mode, this_search_type, local_flags, &this_node); if (ACPI_FAILURE(status)) { if (status == AE_NOT_FOUND) { - +#if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */ + if (flags & ACPI_NS_PREFIX_MUST_EXIST) { + acpi_os_printf(ACPI_MSG_BIOS_ERROR + "Object does not exist: %4.4s\n", + &simple_name); + } +#endif /* Name not found in ACPI namespace */ ACPI_DEBUG_PRINT((ACPI_DB_NAMES, diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c index 0fa01c9e353e..60ece8e48667 100644 --- a/drivers/acpi/acpica/psloop.c +++ b/drivers/acpi/acpica/psloop.c @@ -508,7 +508,8 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) */ if ((walk_state-> parse_flags & ACPI_PARSE_MODULE_LEVEL) - && status == AE_ALREADY_EXISTS) { + && ((status == AE_ALREADY_EXISTS) + || (status == AE_NOT_FOUND))) { status = AE_OK; } if (status == AE_CTRL_PARSE_CONTINUE) { @@ -537,10 +538,7 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) * the scope op because the parse failure indicates that * the device may not exist. */ - ACPI_ERROR((AE_INFO, - "Skip parsing opcode %s", - acpi_ps_get_opcode_name - (walk_state->opcode))); + ACPI_INFO(("Skipping parse of AML opcode: %s (0x%4.4X)", acpi_ps_get_opcode_name(walk_state->opcode), walk_state->opcode)); /* * Determine the opcode length before skipping the opcode. diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c index 3138e7a00da8..e1fd819a2955 100644 --- a/drivers/acpi/acpica/psobject.c +++ b/drivers/acpi/acpica/psobject.c @@ -600,8 +600,7 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state, * because there could be correct AML beyond the parts that caused * the runtime error. */ - ACPI_ERROR((AE_INFO, - "Ignore error and continue table load")); + ACPI_INFO(("Ignoring error and continuing table load")); return_ACPI_STATUS(AE_OK); } return_ACPI_STATUS(status); -- cgit v1.2.3