ACPI: ACPICA 20060421

Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)

Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)

Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.

Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)

Defined and deployed a new OSL interface,
acpi_os_validate_address().  This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)

Defined and deployed a new OSL interface,
acpi_os_validate_interface().  This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)

Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)

Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.

The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 8a690a9..5b974a8 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -91,7 +91,7 @@
 	union acpi_parse_object *op;
 	struct acpi_walk_state *walk_state;
 
-	ACPI_FUNCTION_TRACE("ds_execute_arguments");
+	ACPI_FUNCTION_TRACE(ds_execute_arguments);
 
 	/*
 	 * Allocate a new parser op to be the root of the parsed tree
@@ -193,7 +193,7 @@
 	struct acpi_namespace_node *node;
 	acpi_status status;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_field_arguments", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
 
 	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
 		return_ACPI_STATUS(AE_OK);
@@ -206,7 +206,7 @@
 
 	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
 			(ACPI_TYPE_BUFFER_FIELD, node, NULL));
-	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n",
+	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
 			  acpi_ut_get_node_name(node)));
 
 	/* Execute the AML code for the term_arg arguments */
@@ -235,7 +235,7 @@
 	struct acpi_namespace_node *node;
 	acpi_status status;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_arguments", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
 
 	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
 		return_ACPI_STATUS(AE_OK);
@@ -279,7 +279,7 @@
 	struct acpi_namespace_node *node;
 	acpi_status status;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_get_package_arguments", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
 
 	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
 		return_ACPI_STATUS(AE_OK);
@@ -324,7 +324,7 @@
 	acpi_status status;
 	union acpi_operand_object *extra_desc;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_get_region_arguments", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
 
 	if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
 		return_ACPI_STATUS(AE_OK);
@@ -342,8 +342,7 @@
 	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
 			(ACPI_TYPE_REGION, node, NULL));
 
-	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-			  "[%4.4s] op_region Arg Init at AML %p\n",
+	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
 			  acpi_ut_get_node_name(node),
 			  extra_desc->extra.aml_start));
 
@@ -352,6 +351,28 @@
 	status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
 					   extra_desc->extra.aml_length,
 					   extra_desc->extra.aml_start);
+	if (ACPI_FAILURE(status)) {
+		return_ACPI_STATUS(status);
+	}
+
+	/* Validate the region address/length via the host OS */
+
+	status = acpi_os_validate_address(obj_desc->region.space_id,
+					  obj_desc->region.address,
+					  (acpi_size) obj_desc->region.length);
+	if (ACPI_FAILURE(status)) {
+		/*
+		 * Invalid address/length. We will emit an error message and mark
+		 * the region as invalid, so that it will cause an additional error if
+		 * it is ever used. Then return AE_OK.
+		 */
+		ACPI_EXCEPTION((AE_INFO, status,
+				"During address validation of OpRegion [%4.4s]",
+				node->name.ascii));
+		obj_desc->common.flags |= AOPOBJ_INVALID;
+		status = AE_OK;
+	}
+
 	return_ACPI_STATUS(status);
 }
 
@@ -411,7 +432,7 @@
 	u8 field_flags;
 	acpi_status status;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_init_buffer_field", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc);
 
 	/* Host object must be a Buffer */
 
@@ -457,7 +478,7 @@
 
 		if (bit_count == 0) {
 			ACPI_ERROR((AE_INFO,
-				    "Attempt to create_field of length zero"));
+				    "Attempt to CreateField of length zero"));
 			status = AE_AML_OPERAND_VALUE;
 			goto cleanup;
 		}
@@ -595,7 +616,7 @@
 	struct acpi_namespace_node *node;
 	union acpi_parse_object *next_op;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_eval_buffer_field_operands", op);
+	ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
 
 	/*
 	 * This is where we evaluate the address and length fields of the
@@ -627,7 +648,7 @@
 	ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
 			   acpi_ps_get_opcode_name(op->common.aml_opcode),
 			   walk_state->num_operands,
-			   "after acpi_ex_resolve_operands");
+			   "after AcpiExResolveOperands");
 
 	if (ACPI_FAILURE(status)) {
 		ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)",
@@ -686,7 +707,7 @@
 	struct acpi_namespace_node *node;
 	union acpi_parse_object *next_op;
 
-	ACPI_FUNCTION_TRACE_PTR("ds_eval_region_operands", op);
+	ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
 
 	/*
 	 * This is where we evaluate the address and length fields of the
@@ -719,7 +740,7 @@
 
 	ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
 			   acpi_ps_get_opcode_name(op->common.aml_opcode),
-			   1, "after acpi_ex_resolve_operands");
+			   1, "after AcpiExResolveOperands");
 
 	obj_desc = acpi_ns_get_attached_object(node);
 	if (!obj_desc) {
@@ -745,7 +766,7 @@
 	    operand_desc->integer.value;
 	acpi_ut_remove_reference(operand_desc);
 
-	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
+	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
 			  obj_desc,
 			  ACPI_FORMAT_UINT64(obj_desc->region.address),
 			  obj_desc->region.length));
@@ -781,7 +802,7 @@
 	union acpi_operand_object *arg_desc;
 	u32 length;
 
-	ACPI_FUNCTION_TRACE("ds_eval_data_object_operands");
+	ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
 
 	/* The first operand (for all of these data objects) is the length */
 
@@ -875,7 +896,7 @@
 	acpi_status status = AE_OK;
 	union acpi_generic_state *control_state;
 
-	ACPI_FUNCTION_NAME("ds_exec_begin_control_op");
+	ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
 
 	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
 			  op->common.aml_opcode, walk_state));
@@ -953,7 +974,7 @@
 	acpi_status status = AE_OK;
 	union acpi_generic_state *control_state;
 
-	ACPI_FUNCTION_NAME("ds_exec_end_control_op");
+	ACPI_FUNCTION_NAME(ds_exec_end_control_op);
 
 	switch (op->common.aml_opcode) {
 	case AML_IF_OP:
@@ -1099,7 +1120,7 @@
 		}
 
 		ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
-				  "Completed RETURN_OP State=%p, ret_val=%p\n",
+				  "Completed RETURN_OP State=%p, RetVal=%p\n",
 				  walk_state, walk_state->return_desc));
 
 		/* End the control method execution right now */