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

ACPICA: New: Validation for predefined ACPI methods/objects

Validates predefined ACPI objects that appear in the namespace,
at the time they are evaluated. The argument count and the type of
the returned object are validated. The purpose of this validation
is to detect problems with the BIOS-exposed predefined ACPI objects
before the results are returned to the ACPI-related drivers.
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent b9d1312a
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \ obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \
nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \ nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \ nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
nsparse.o nsparse.o nspredef.o
obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
......
...@@ -78,6 +78,7 @@ ACPI_MODULE_NAME("nseval") ...@@ -78,6 +78,7 @@ ACPI_MODULE_NAME("nseval")
acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
{ {
acpi_status status; acpi_status status;
struct acpi_namespace_node *node;
ACPI_FUNCTION_TRACE(ns_evaluate); ACPI_FUNCTION_TRACE(ns_evaluate);
...@@ -117,6 +118,8 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) ...@@ -117,6 +118,8 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
info->resolved_node, info->resolved_node,
acpi_ns_get_attached_object(info->resolved_node))); acpi_ns_get_attached_object(info->resolved_node)));
node = info->resolved_node;
/* /*
* Two major cases here: * Two major cases here:
* *
...@@ -261,9 +264,35 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) ...@@ -261,9 +264,35 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
} }
} }
/* Validation of return values for ACPI-predefined methods and objects */
if ((status == AE_OK) || (status == AE_CTRL_RETURN_VALUE)) {
/*
* If this is the first evaluation, check the return value. This
* ensures that any warnings will only be emitted during the very
* first evaluation of the object.
*/
if (!(node->flags & ANOBJ_EVALUATED)) {
/* /*
* Check if there is a return value that must be dealt with * Check for a predefined ACPI name. If found, validate the
* returned object.
*
* Note: Ignore return status for now, emit warnings if there are
* problems with the returned object. May change later to abort
* the method on invalid return object.
*/ */
(void)acpi_ns_check_predefined_names(node,
info->
return_object);
}
/* Mark the node as having been evaluated */
node->flags |= ANOBJ_EVALUATED;
}
/* Check if there is a return value that must be dealt with */
if (status == AE_CTRL_RETURN_VALUE) { if (status == AE_CTRL_RETURN_VALUE) {
/* If caller does not want the return value, delete it */ /* If caller does not want the return value, delete it */
......
...@@ -115,7 +115,6 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node, ...@@ -115,7 +115,6 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
return (AE_OK); return (AE_OK);
} }
#ifdef ACPI_DEBUG_OUTPUT
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_get_external_pathname * FUNCTION: acpi_ns_get_external_pathname
...@@ -163,7 +162,6 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) ...@@ -163,7 +162,6 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
return_PTR(name_buffer); return_PTR(name_buffer);
} }
#endif
/******************************************************************************* /*******************************************************************************
* *
......
This diff is collapsed.
...@@ -154,6 +154,10 @@ void ...@@ -154,6 +154,10 @@ void
acpi_db_display_argument_object(union acpi_operand_object *obj_desc, acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state); struct acpi_walk_state *walk_state);
void acpi_db_check_predefined_names(void);
void acpi_db_batch_execute(void);
/* /*
* dbexec - debugger control method execution * dbexec - debugger control method execution
*/ */
......
...@@ -208,6 +208,7 @@ struct acpi_namespace_node { ...@@ -208,6 +208,7 @@ struct acpi_namespace_node {
#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */
#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */
#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */
#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */
#define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */ #define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */
#define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */ #define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */
...@@ -340,6 +341,82 @@ acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state); ...@@ -340,6 +341,82 @@ acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
/*
* Information structure for ACPI predefined names.
* Each entry in the table contains the following items:
*
* Name - The ACPI reserved name
* param_count - Number of arguments to the method
* expected_return_btypes - Allowed type(s) for the return value
*/
struct acpi_name_info {
char name[ACPI_NAME_SIZE];
u8 param_count;
u8 expected_btypes;
};
/*
* Secondary information structures for ACPI predefined objects that return
* package objects. This structure appears as the next entry in the table
* after the NAME_INFO structure above.
*
* The reason for this is to minimize the size of the predefined name table.
*/
/*
* Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
* ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT
*/
struct acpi_package_info {
u8 type;
u8 object_type1;
u8 count1;
u8 object_type2;
u8 count2;
u8 reserved;
};
/* Used for ACPI_PTYPE2_FIXED */
struct acpi_package_info2 {
u8 type;
u8 count;
u8 object_type[4];
};
/* Used for ACPI_PTYPE1_OPTION */
struct acpi_package_info3 {
u8 type;
u8 count;
u8 object_type[2];
u8 tail_object_type;
u8 reserved;
};
union acpi_predefined_info {
struct acpi_name_info info;
struct acpi_package_info ret_info;
struct acpi_package_info2 ret_info2;
struct acpi_package_info3 ret_info3;
};
/*
* Bitmapped return value types
* Note: the actual data types must be contiguous, a loop in nspredef.c
* depends on this.
*/
#define ACPI_RTYPE_ANY 0x00
#define ACPI_RTYPE_NONE 0x01
#define ACPI_RTYPE_INTEGER 0x02
#define ACPI_RTYPE_STRING 0x04
#define ACPI_RTYPE_BUFFER 0x08
#define ACPI_RTYPE_PACKAGE 0x10
#define ACPI_RTYPE_REFERENCE 0x20
#define ACPI_RTYPE_ALL 0x3F
#define ACPI_NUM_RTYPES 5 /* Number of actual object types */
/***************************************************************************** /*****************************************************************************
* *
* Event typedefs and structs * Event typedefs and structs
......
...@@ -177,6 +177,22 @@ acpi_ns_dump_objects(acpi_object_type type, ...@@ -177,6 +177,22 @@ acpi_ns_dump_objects(acpi_object_type type,
*/ */
acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info); acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
/*
* nspredef - Support for predefined/reserved names
*/
acpi_status
acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
union acpi_operand_object *return_object);
const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
acpi_namespace_node
*node);
void
acpi_ns_check_parameter_count(char *pathname,
struct acpi_namespace_node *node,
const union acpi_predefined_info *info);
/* /*
* nsnames - Name and Scope manipulation * nsnames - Name and Scope manipulation
*/ */
......
This diff is collapsed.
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