2018-03-14 23:13:07 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
|
|
|
|
*
|
2022-04-11 18:54:22 +00:00
|
|
|
* Copyright (C) 2000 - 2022, Intel Corp.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2018-03-14 23:13:07 +00:00
|
|
|
*****************************************************************************/
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 05:30:03 +00:00
|
|
|
#include "accommon.h"
|
|
|
|
#include "acinterp.h"
|
|
|
|
#include "acnamesp.h"
|
|
|
|
#include "actables.h"
|
|
|
|
#include "acdispat.h"
|
2009-05-21 02:51:53 +00:00
|
|
|
#include "acevents.h"
|
2012-12-31 00:05:09 +00:00
|
|
|
#include "amlcode.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_EXECUTER
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_MODULE_NAME("exconfig")
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-04-19 02:49:35 +00:00
|
|
|
/* Local prototypes */
|
|
|
|
static acpi_status
|
2016-09-07 06:07:24 +00:00
|
|
|
acpi_ex_add_table(u32 table_index, union acpi_operand_object **ddb_handle);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-05-21 02:51:53 +00:00
|
|
|
static acpi_status
|
|
|
|
acpi_ex_region_read(union acpi_operand_object *obj_desc,
|
|
|
|
u32 length, u8 *buffer);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_add_table
|
|
|
|
*
|
2012-07-12 01:40:10 +00:00
|
|
|
* PARAMETERS: table - Pointer to raw table
|
2005-04-16 22:20:36 +00:00
|
|
|
* parent_node - Where to load the table (scope)
|
|
|
|
* ddb_handle - Where to return the table handle.
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Common function to Install and Load an ACPI table with a
|
|
|
|
* returned table handle.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-19 02:49:35 +00:00
|
|
|
static acpi_status
|
2016-09-07 06:07:24 +00:00
|
|
|
acpi_ex_add_table(u32 table_index, union acpi_operand_object **ddb_handle)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *obj_desc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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>
2006-04-21 21:15:00 +00:00
|
|
|
ACPI_FUNCTION_TRACE(ex_add_table);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Create an object to be the table handle */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!obj_desc) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-07-29 22:15:00 +00:00
|
|
|
/* Init the table handle */
|
|
|
|
|
2009-05-21 02:32:02 +00:00
|
|
|
obj_desc->common.flags |= AOPOBJ_DATA_VALID;
|
2008-09-27 03:08:41 +00:00
|
|
|
obj_desc->reference.class = ACPI_REFCLASS_TABLE;
|
2008-09-27 02:40:39 +00:00
|
|
|
obj_desc->reference.value = table_index;
|
2016-09-07 06:07:24 +00:00
|
|
|
*ddb_handle = obj_desc;
|
2010-04-27 03:32:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_load_table_op
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current state with operands
|
|
|
|
* return_desc - Where to store the return object
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2007-02-02 16:48:22 +00:00
|
|
|
* DESCRIPTION: Load an ACPI table from the RSDT/XSDT
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
|
|
|
|
union acpi_operand_object **return_desc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status status;
|
|
|
|
union acpi_operand_object **operand = &walk_state->operands[0];
|
|
|
|
struct acpi_namespace_node *parent_node;
|
|
|
|
struct acpi_namespace_node *start_node;
|
|
|
|
struct acpi_namespace_node *parameter_node = NULL;
|
2022-04-11 18:52:26 +00:00
|
|
|
union acpi_operand_object *return_obj;
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *ddb_handle;
|
2008-06-10 05:42:13 +00:00
|
|
|
u32 table_index;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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>
2006-04-21 21:15:00 +00:00
|
|
|
ACPI_FUNCTION_TRACE(ex_load_table_op);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-04-11 18:52:26 +00:00
|
|
|
/* Create the return object */
|
|
|
|
|
|
|
|
return_obj = acpi_ut_create_integer_object((u64)0);
|
|
|
|
if (!return_obj) {
|
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
*return_desc = return_obj;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
/* Find the ACPI table in the RSDT/XSDT */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-09-07 06:07:24 +00:00
|
|
|
acpi_ex_exit_interpreter();
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_tb_find_table(operand[0]->string.pointer,
|
|
|
|
operand[1]->string.pointer,
|
2007-02-02 16:48:18 +00:00
|
|
|
operand[2]->string.pointer, &table_index);
|
2016-09-07 06:07:24 +00:00
|
|
|
acpi_ex_enter_interpreter();
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (status != AE_NOT_FOUND) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Table not found, return an Integer=0 and AE_OK */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Default nodes */
|
|
|
|
|
|
|
|
start_node = walk_state->scope_info->scope.node;
|
|
|
|
parent_node = acpi_gbl_root_node;
|
|
|
|
|
|
|
|
/* root_path (optional parameter) */
|
|
|
|
|
|
|
|
if (operand[3]->string.length > 0) {
|
|
|
|
/*
|
|
|
|
* Find the node referenced by the root_path_string. This is the
|
|
|
|
* location within the namespace where the table will be loaded.
|
|
|
|
*/
|
ACPICA: Namespace: Fix dynamic table loading issues
ACPICA commit 767ee53354e0c4b7e8e7c57c6dd7bf569f0d52bb
There are issues related to the namespace/interpreter locks, which causes
several ACPI functionalities not specification compliant. The lock issues
were detectec when we were trying to fix the functionalities (please see
Link # [1] for the details).
What's the lock issues? Let's first look into the namespace/interpreter
lock usages inside of the object evaluation and the table loading which are
the key AML interpretion code paths:
Table loading:
acpi_ns_load_table
L(Namespace)
acpi_ns_parse_table
acpi_ns_one_complete_parse(LOAD_PASS1/LOAD_PASS2)
acpi_ds_load1_begion_op
acpi_ds_load1_end_op
acpi_ds_load2_begion_op
acpi_ds_load2_end_op
U(Namespace)
Object evaluation:
acpi_ns_evaluate
L(Interpreter)
acpi_ps_execute_method
acpi_ds_exec_begin_op
acpi_ds_exec_end_op
U(Interpreter)
acpi_ns_load_table
L(Namespace)
U(Namespace)
acpi_ev_initialize_region
L(Namespace)
U(Namespace)
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
L(Interpreter)
U(Interpreter)
L(Interpreter)
acpi_ex_resolve_node_to_value
U(Interpreter)
acpi_ns_check_return_value
Where:
1. L(Interpreter) means acquire(MTX_INTERPRETER);
2. U(Interpreter) means release(MTX_INTERPRETER);
3. L(Namespace) means acquire(MTX_NAMESPACE);
4. U(Namespace) means release(MTX_NAMESPACE);
We can see that acpi_ns_exec_module_code() (which invokes acpi_ns_evaluate) is
implemented in a deferred way just in order to avoid to reacquire the
namespace lock. This is in fact the root cause of many other ACPICA issues:
1. We now know for sure that the module code should be executed right in
place by the Windows AML interpreter. So in the current design, if
the region initializations/accesses or the table loadings (where the
namespace surely should be locked again) happening during the table
loading period, dead lock could happen because ACPICA never unlocks the
namespace during the AML interpretion.
2. ACPICA interpreter just ensures that all static namespace nodes (named
objects created during the acpi_load_tables()) are created
(acpi_ns_lookup()) with the correct lock held, but doesn't ensure that
the named objects created by the control method are created with the
same correct lock held. It requires the control methods to be executed
in a serial way after "loading a table", that's why ACPICA requires
method auto serialization.
This patch fixes these software design issues by extending interpreter
enter/exit APIs to hold both interpreter/namespace locks to ensure the lock
order correctness, so that we can get these code paths:
Table loading:
acpi_ns_load_table
E(Interpreter)
acpi_ns_parse_table
acpi_ns_one_complete_parse
acpi_ns_execute_table
X(Interpreter)
acpi_ns_load_table
acpi_ev_initialize_region
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
E(Interpreter)
X(Interpreter)
Object evaluation:
acpi_ns_evaluate
E(Interpreter)
acpi_ps_execute_method
X(Interpreter)
acpi_ns_load_table
acpi_ev_initialize_region
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
E(Interpreter)
X(Interpreter)
Where:
1. E(Interpreter) means acquire(MTX_INTERPRETER, MTX_NAMESPACE);
2. X(Interpreter) means release(MTX_NAMESPACE, MTX_INTERPRETER);
After this change, we can see:
1. All namespace nodes creations are locked by the namespace lock.
2. All namespace nodes referencing are locked with the same lock.
3. But we also can notice a defact that, all namespace nodes deletions
could be affected by this change. As a consequence,
acpi_ns_delete_namespace_subtree() may delete a static namespace node that
is still referenced by the interpreter (for example, the parser scopes).
Currently, we needn't worry about the last defact because in ACPICA, table
unloading is not fully functioning, its design strictly relies on the fact
that when the namespace deletion happens, either the AML table or the OSPMs
should have been notified and thus either the AML table or the OSPMs
shouldn't reference deletion-related namespace nodes during the namespace
deletion. And this change still works with the above restrictions applied.
While making this a-step-forward helps us to correct the wrong grammar to
pull many things back to the correct rail. And pulling things back to the
correct rail in return makes it possible for us to support fully
functioning table unloading after doing many cleanups.
While this patch is generated, all namespace locks are examined to ensure
that they can meet either of the following pattens:
1. L(Namespace)
U(Namespace)
2. E(Interpreter)
X(Interpreter)
3. E(Interpreter)
X(Interpreter)
L(Namespace)
U(Namespace)
E(Interpreter)
X(Interpreter)
We ensure this by adding X(Interpreter)/E(Interpreter) or removing
U(Namespace)/L(Namespace) for those currently are executed in the following
order:
E(Interpreter)
L(Namespace)
U(Namespace)
X(Interpreter)
And adding E(Interpreter)/X(Interpreter) for those currently are executed
in the following order:
X(Interpreter)
E(Interpreter)
Originally, the interpreter lock is held for the execution AML opcodes, the
namespace lock is held for the named object creation AML opcodes. Since
they are actually same in MS interpreter (can all be executed during the
table loading), we can combine the 2 locks and tune the locking code better
in this way. Lv Zheng.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=153541 # [1]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=121701 # [1]
Link: https://bugs.acpica.org/show_bug.cgi?id=1323
Link: https://github.com/acpica/acpica/commit/767ee533
Reported-and-tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reported-and-tested-by: Greg White <gwhite@kupulau.com>
Reported-and-tested-by: Dutch Guy <lucht_piloot@gmx.net>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-09-07 06:07:10 +00:00
|
|
|
status = acpi_ns_get_node_unlocked(start_node,
|
|
|
|
operand[3]->string.pointer,
|
|
|
|
ACPI_NS_SEARCH_PARENT,
|
|
|
|
&parent_node);
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parameter_path (optional parameter) */
|
|
|
|
|
|
|
|
if (operand[4]->string.length > 0) {
|
2012-12-31 00:05:09 +00:00
|
|
|
if ((operand[4]->string.pointer[0] != AML_ROOT_PREFIX) &&
|
|
|
|
(operand[4]->string.pointer[0] != AML_PARENT_PREFIX)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Path is not absolute, so it will be relative to the node
|
|
|
|
* referenced by the root_path_string (or the NS root if omitted)
|
|
|
|
*/
|
|
|
|
start_node = parent_node;
|
|
|
|
}
|
|
|
|
|
2005-04-19 02:49:35 +00:00
|
|
|
/* Find the node referenced by the parameter_path_string */
|
|
|
|
|
ACPICA: Namespace: Fix dynamic table loading issues
ACPICA commit 767ee53354e0c4b7e8e7c57c6dd7bf569f0d52bb
There are issues related to the namespace/interpreter locks, which causes
several ACPI functionalities not specification compliant. The lock issues
were detectec when we were trying to fix the functionalities (please see
Link # [1] for the details).
What's the lock issues? Let's first look into the namespace/interpreter
lock usages inside of the object evaluation and the table loading which are
the key AML interpretion code paths:
Table loading:
acpi_ns_load_table
L(Namespace)
acpi_ns_parse_table
acpi_ns_one_complete_parse(LOAD_PASS1/LOAD_PASS2)
acpi_ds_load1_begion_op
acpi_ds_load1_end_op
acpi_ds_load2_begion_op
acpi_ds_load2_end_op
U(Namespace)
Object evaluation:
acpi_ns_evaluate
L(Interpreter)
acpi_ps_execute_method
acpi_ds_exec_begin_op
acpi_ds_exec_end_op
U(Interpreter)
acpi_ns_load_table
L(Namespace)
U(Namespace)
acpi_ev_initialize_region
L(Namespace)
U(Namespace)
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
L(Interpreter)
U(Interpreter)
L(Interpreter)
acpi_ex_resolve_node_to_value
U(Interpreter)
acpi_ns_check_return_value
Where:
1. L(Interpreter) means acquire(MTX_INTERPRETER);
2. U(Interpreter) means release(MTX_INTERPRETER);
3. L(Namespace) means acquire(MTX_NAMESPACE);
4. U(Namespace) means release(MTX_NAMESPACE);
We can see that acpi_ns_exec_module_code() (which invokes acpi_ns_evaluate) is
implemented in a deferred way just in order to avoid to reacquire the
namespace lock. This is in fact the root cause of many other ACPICA issues:
1. We now know for sure that the module code should be executed right in
place by the Windows AML interpreter. So in the current design, if
the region initializations/accesses or the table loadings (where the
namespace surely should be locked again) happening during the table
loading period, dead lock could happen because ACPICA never unlocks the
namespace during the AML interpretion.
2. ACPICA interpreter just ensures that all static namespace nodes (named
objects created during the acpi_load_tables()) are created
(acpi_ns_lookup()) with the correct lock held, but doesn't ensure that
the named objects created by the control method are created with the
same correct lock held. It requires the control methods to be executed
in a serial way after "loading a table", that's why ACPICA requires
method auto serialization.
This patch fixes these software design issues by extending interpreter
enter/exit APIs to hold both interpreter/namespace locks to ensure the lock
order correctness, so that we can get these code paths:
Table loading:
acpi_ns_load_table
E(Interpreter)
acpi_ns_parse_table
acpi_ns_one_complete_parse
acpi_ns_execute_table
X(Interpreter)
acpi_ns_load_table
acpi_ev_initialize_region
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
E(Interpreter)
X(Interpreter)
Object evaluation:
acpi_ns_evaluate
E(Interpreter)
acpi_ps_execute_method
X(Interpreter)
acpi_ns_load_table
acpi_ev_initialize_region
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
E(Interpreter)
X(Interpreter)
Where:
1. E(Interpreter) means acquire(MTX_INTERPRETER, MTX_NAMESPACE);
2. X(Interpreter) means release(MTX_NAMESPACE, MTX_INTERPRETER);
After this change, we can see:
1. All namespace nodes creations are locked by the namespace lock.
2. All namespace nodes referencing are locked with the same lock.
3. But we also can notice a defact that, all namespace nodes deletions
could be affected by this change. As a consequence,
acpi_ns_delete_namespace_subtree() may delete a static namespace node that
is still referenced by the interpreter (for example, the parser scopes).
Currently, we needn't worry about the last defact because in ACPICA, table
unloading is not fully functioning, its design strictly relies on the fact
that when the namespace deletion happens, either the AML table or the OSPMs
should have been notified and thus either the AML table or the OSPMs
shouldn't reference deletion-related namespace nodes during the namespace
deletion. And this change still works with the above restrictions applied.
While making this a-step-forward helps us to correct the wrong grammar to
pull many things back to the correct rail. And pulling things back to the
correct rail in return makes it possible for us to support fully
functioning table unloading after doing many cleanups.
While this patch is generated, all namespace locks are examined to ensure
that they can meet either of the following pattens:
1. L(Namespace)
U(Namespace)
2. E(Interpreter)
X(Interpreter)
3. E(Interpreter)
X(Interpreter)
L(Namespace)
U(Namespace)
E(Interpreter)
X(Interpreter)
We ensure this by adding X(Interpreter)/E(Interpreter) or removing
U(Namespace)/L(Namespace) for those currently are executed in the following
order:
E(Interpreter)
L(Namespace)
U(Namespace)
X(Interpreter)
And adding E(Interpreter)/X(Interpreter) for those currently are executed
in the following order:
X(Interpreter)
E(Interpreter)
Originally, the interpreter lock is held for the execution AML opcodes, the
namespace lock is held for the named object creation AML opcodes. Since
they are actually same in MS interpreter (can all be executed during the
table loading), we can combine the 2 locks and tune the locking code better
in this way. Lv Zheng.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=153541 # [1]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=121701 # [1]
Link: https://bugs.acpica.org/show_bug.cgi?id=1323
Link: https://github.com/acpica/acpica/commit/767ee533
Reported-and-tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reported-and-tested-by: Greg White <gwhite@kupulau.com>
Reported-and-tested-by: Dutch Guy <lucht_piloot@gmx.net>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-09-07 06:07:10 +00:00
|
|
|
status = acpi_ns_get_node_unlocked(start_node,
|
|
|
|
operand[4]->string.pointer,
|
|
|
|
ACPI_NS_SEARCH_PARENT,
|
|
|
|
¶meter_node);
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load the table into the namespace */
|
|
|
|
|
2016-09-07 06:07:24 +00:00
|
|
|
ACPI_INFO(("Dynamic OEM Table Load:"));
|
|
|
|
acpi_ex_exit_interpreter();
|
|
|
|
status = acpi_tb_load_table(table_index, parent_node);
|
|
|
|
acpi_ex_enter_interpreter();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
status = acpi_ex_add_table(table_index, &ddb_handle);
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 16:58:21 +00:00
|
|
|
/* Complete the initialization/resolution of new objects */
|
2018-05-08 21:06:15 +00:00
|
|
|
|
2019-07-11 16:58:21 +00:00
|
|
|
acpi_ex_exit_interpreter();
|
|
|
|
acpi_ns_initialize_objects();
|
|
|
|
acpi_ex_enter_interpreter();
|
2018-05-08 21:06:15 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Parameter Data (optional) */
|
|
|
|
|
|
|
|
if (parameter_node) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Store the parameter data into the optional parameter object */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ex_store(operand[5],
|
|
|
|
ACPI_CAST_PTR(union acpi_operand_object,
|
|
|
|
parameter_node),
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
(void)acpi_ex_unload_table(ddb_handle);
|
2009-05-21 02:29:28 +00:00
|
|
|
|
|
|
|
acpi_ut_remove_reference(ddb_handle);
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-11 18:52:26 +00:00
|
|
|
/* Remove the reference to ddb_handle created by acpi_ex_add_table above */
|
|
|
|
|
|
|
|
acpi_ut_remove_reference(ddb_handle);
|
|
|
|
|
|
|
|
/* Return -1 (non-zero) indicates success */
|
|
|
|
|
|
|
|
return_obj->integer.value = 0xFFFFFFFFFFFFFFFF;
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-05-21 02:51:53 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_region_read
|
|
|
|
*
|
|
|
|
* PARAMETERS: obj_desc - Region descriptor
|
2012-07-12 01:40:10 +00:00
|
|
|
* length - Number of bytes to read
|
|
|
|
* buffer - Pointer to where to put the data
|
2009-05-21 02:51:53 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Read data from an operation region. The read starts from the
|
|
|
|
* beginning of the region.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static acpi_status
|
|
|
|
acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
2010-01-21 02:06:32 +00:00
|
|
|
u64 value;
|
2009-05-21 02:56:52 +00:00
|
|
|
u32 region_offset = 0;
|
2009-05-21 02:51:53 +00:00
|
|
|
u32 i;
|
|
|
|
|
|
|
|
/* Bytewise reads */
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
2011-11-16 05:39:07 +00:00
|
|
|
status =
|
|
|
|
acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ,
|
|
|
|
region_offset, 8, &value);
|
2009-05-21 02:51:53 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2012-12-19 05:37:21 +00:00
|
|
|
return (status);
|
2009-05-21 02:51:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*buffer = (u8)value;
|
|
|
|
buffer++;
|
2009-05-21 02:56:52 +00:00
|
|
|
region_offset++;
|
2009-05-21 02:51:53 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 05:37:21 +00:00
|
|
|
return (AE_OK);
|
2009-05-21 02:51:53 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_load_op
|
|
|
|
*
|
2007-02-02 16:48:22 +00:00
|
|
|
* PARAMETERS: obj_desc - Region or Buffer/Field where the table will be
|
2005-04-16 22:20:36 +00:00
|
|
|
* obtained
|
2022-04-11 18:51:27 +00:00
|
|
|
* target - Where the status of the load will be stored
|
2005-04-16 22:20:36 +00:00
|
|
|
* walk_state - Current state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Load an ACPI table from a field or operation region
|
|
|
|
*
|
2007-02-02 16:48:22 +00:00
|
|
|
* NOTE: Region Fields (Field, bank_field, index_fields) are resolved to buffer
|
|
|
|
* objects before this code is reached.
|
|
|
|
*
|
|
|
|
* If source is an operation region, it must refer to system_memory, as
|
|
|
|
* per the ACPI specification.
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ex_load_op(union acpi_operand_object *obj_desc,
|
|
|
|
union acpi_operand_object *target,
|
|
|
|
struct acpi_walk_state *walk_state)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *ddb_handle;
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
struct acpi_table_header *table_header;
|
2008-08-15 01:37:58 +00:00
|
|
|
struct acpi_table_header *table;
|
2008-06-10 05:42:13 +00:00
|
|
|
u32 table_index;
|
2007-02-02 16:48:22 +00:00
|
|
|
acpi_status status;
|
2008-04-10 15:06:39 +00:00
|
|
|
u32 length;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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>
2006-04-21 21:15:00 +00:00
|
|
|
ACPI_FUNCTION_TRACE(ex_load_op);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-04-11 18:51:27 +00:00
|
|
|
if (target->common.descriptor_type == ACPI_DESC_TYPE_NAMED) {
|
|
|
|
target =
|
|
|
|
acpi_ns_get_attached_object(ACPI_CAST_PTR
|
|
|
|
(struct acpi_namespace_node,
|
|
|
|
target));
|
|
|
|
}
|
|
|
|
if (target->common.type != ACPI_TYPE_INTEGER) {
|
|
|
|
ACPI_EXCEPTION((AE_INFO, AE_TYPE,
|
|
|
|
"Type not integer: %X\n", target->common.type));
|
|
|
|
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
target->integer.value = 0;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
/* Source Object can be either an op_region or a Buffer/Field */
|
|
|
|
|
2009-02-18 06:44:03 +00:00
|
|
|
switch (obj_desc->common.type) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case ACPI_TYPE_REGION:
|
|
|
|
|
2008-08-15 01:37:58 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"Load table from Region %p\n", obj_desc));
|
2008-04-10 15:06:39 +00:00
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
/* Region must be system_memory (from ACPI spec) */
|
|
|
|
|
|
|
|
if (obj_desc->region.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
|
|
|
|
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2015-12-29 05:54:36 +00:00
|
|
|
* If the Region Address and Length have not been previously
|
|
|
|
* evaluated, evaluate them now and save the results.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ds_get_region_arguments(obj_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-21 02:51:53 +00:00
|
|
|
/* Get the table header first so we can get the table length */
|
|
|
|
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
table_header = ACPI_ALLOCATE(sizeof(struct acpi_table_header));
|
|
|
|
if (!table_header) {
|
2008-08-15 01:37:58 +00:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
2009-05-21 02:51:53 +00:00
|
|
|
status =
|
|
|
|
acpi_ex_region_read(obj_desc,
|
|
|
|
sizeof(struct acpi_table_header),
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
ACPI_CAST_PTR(u8, table_header));
|
|
|
|
length = table_header->length;
|
|
|
|
ACPI_FREE(table_header);
|
2009-05-21 02:51:53 +00:00
|
|
|
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
2008-08-15 01:37:58 +00:00
|
|
|
|
|
|
|
/* Must have at least an ACPI table header */
|
|
|
|
|
|
|
|
if (length < sizeof(struct acpi_table_header)) {
|
|
|
|
return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-05-21 02:51:53 +00:00
|
|
|
* The original implementation simply mapped the table, with no copy.
|
|
|
|
* However, the memory region is not guaranteed to remain stable and
|
|
|
|
* we must copy the table to a local buffer. For example, the memory
|
|
|
|
* region is corrupted after suspend on some machines. Dynamically
|
|
|
|
* loaded tables are usually small, so this overhead is minimal.
|
|
|
|
*
|
|
|
|
* The latest implementation (5/2009) does not use a mapping at all.
|
|
|
|
* We use the low-level operation region interface to read the table
|
|
|
|
* instead of the obvious optimization of using a direct mapping.
|
|
|
|
* This maintains a consistent use of operation regions across the
|
|
|
|
* entire subsystem. This is important if additional processing must
|
|
|
|
* be performed in the (possibly user-installed) operation region
|
|
|
|
* handler. For example, acpi_exec and ASLTS depend on this.
|
2008-04-10 15:06:39 +00:00
|
|
|
*/
|
2008-08-15 01:37:58 +00:00
|
|
|
|
|
|
|
/* Allocate a buffer for the table */
|
|
|
|
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
table = ACPI_ALLOCATE(length);
|
|
|
|
if (!table) {
|
2008-08-15 01:37:58 +00:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
2009-05-21 02:51:53 +00:00
|
|
|
/* Read the entire table */
|
2008-08-15 01:37:58 +00:00
|
|
|
|
2009-05-21 02:51:53 +00:00
|
|
|
status = acpi_ex_region_read(obj_desc, length,
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
ACPI_CAST_PTR(u8, table));
|
2009-05-21 02:51:53 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
ACPI_FREE(table);
|
2009-05-21 02:51:53 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2008-08-15 01:37:58 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
2008-08-15 01:37:58 +00:00
|
|
|
"Load table from Buffer or Field %p\n",
|
|
|
|
obj_desc));
|
2008-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
/* Must have at least an ACPI table header */
|
|
|
|
|
2008-08-15 01:37:58 +00:00
|
|
|
if (obj_desc->buffer.length < sizeof(struct acpi_table_header)) {
|
2008-04-10 15:06:39 +00:00
|
|
|
return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
|
|
|
|
}
|
|
|
|
|
2008-08-15 01:37:58 +00:00
|
|
|
/* Get the actual table length from the table header */
|
2008-04-10 15:06:39 +00:00
|
|
|
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
table_header =
|
2008-08-15 01:37:58 +00:00
|
|
|
ACPI_CAST_PTR(struct acpi_table_header,
|
|
|
|
obj_desc->buffer.pointer);
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
length = table_header->length;
|
2008-08-15 01:37:58 +00:00
|
|
|
|
|
|
|
/* Table cannot extend beyond the buffer */
|
|
|
|
|
|
|
|
if (length > obj_desc->buffer.length) {
|
|
|
|
return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
|
|
|
|
}
|
|
|
|
if (length < sizeof(struct acpi_table_header)) {
|
|
|
|
return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
|
2008-04-10 15:06:39 +00:00
|
|
|
}
|
|
|
|
|
2008-04-10 15:06:39 +00:00
|
|
|
/*
|
2015-12-29 05:54:36 +00:00
|
|
|
* Copy the table from the buffer because the buffer could be
|
|
|
|
* modified or even deleted in the future
|
2008-04-10 15:06:39 +00:00
|
|
|
*/
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
table = ACPI_ALLOCATE(length);
|
|
|
|
if (!table) {
|
2008-04-10 15:06:39 +00:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-07-01 06:45:11 +00:00
|
|
|
memcpy(table, table_header, length);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-06-08 00:58:14 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-08-15 01:37:58 +00:00
|
|
|
/* Install the new table into the local data structures */
|
|
|
|
|
2016-02-19 06:16:42 +00:00
|
|
|
ACPI_INFO(("Dynamic OEM Table Load:"));
|
2016-09-07 06:07:24 +00:00
|
|
|
acpi_ex_exit_interpreter();
|
2016-11-30 07:21:19 +00:00
|
|
|
status = acpi_tb_install_and_load_table(ACPI_PTR_TO_PHYSADDR(table),
|
|
|
|
ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
|
ACPICA: Use original pointer for virtual origin tables
ACPICA commit dfa3feffa8f760b686207d09dc880cd2f26c72af
Currently the pointer to the table is cast to acpi_physical_address and
later cast back to a pointer to be dereferenced. Whether or not this is
supported is implementation-defined.
On CHERI, and thus Arm's experimental Morello prototype architecture,
pointers are represented as capabilities, which are unforgeable bounded
pointers, providing always-on fine-grained spatial memory safety. This
means that any pointer cast to a plain integer will lose all its
associated metadata, and when cast back to a pointer it will give a
null-derived pointer (one that has the same metadata as null but an
address equal to the integer) that will trap on any dereference. As a
result, this is an implementation where acpi_physical_address cannot be
used as a hack to store real pointers.
Thus, alter the lifecycle of table descriptors. Internal physical tables
keep the current behaviour where only the address is set on install, and
the pointer is set on acquire. Virtual tables (internal and external)
now store the pointer on initialisation and use that on acquire (which
will redundantly set *table_ptr to itself, but changing that is both
unnecessary and overly complicated as acpi_tb_acquire_table is called with
both a pointer to a variable and a pointer to Table->Pointer itself).
This requires propagating the (possible) table pointer everywhere in
order to make sure pointers make it through to acpi_tb_acquire_temp_table,
which requires a change to the acpi_install_table interface. Instead of
taking an ACPI_PHYSADDR_TYPE and a boolean indicating whether it's
physical or virtual, it is now split into acpi_install_table (that takes
an external virtual table pointer) and acpi_install_physical_table (that
takes an ACPI_PHYSADDR_TYPE for an internal physical table address).
This also has the benefit of providing a cleaner API.
Link: https://github.com/acpica/acpica/commit/dfa3feff
Signed-off-by: Bob Moore <robert.moore@intel.com>
[ rjw: Adjust the code in tables.c to match interface changes ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-12-22 16:22:28 +00:00
|
|
|
table, TRUE, &table_index);
|
2016-09-07 06:07:24 +00:00
|
|
|
acpi_ex_enter_interpreter();
|
2007-02-02 16:48:18 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2010-01-21 01:08:31 +00:00
|
|
|
|
|
|
|
/* Delete allocated table buffer */
|
|
|
|
|
ACPICA: Tables: Fix table checksums verification before installation.
The original table handling code does not always verify checksums before
installing a table, this is because code to achieve this must be
implemented here and there in the redundant code blocks.
There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(),
struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used
during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is
ensured to be not NULL. This must not be used during OSPM's early boot
stage.
This patch changes acpi_tb_add_table() into an early boot safe API to reduce
code redundancies by changing the table state that is returned by this
function from "VALIDATED" to "INSTALLED". Then the table verification
code can be done in a single place. Originally, the acpi_tb_add_table() can
only be used by dynamic table loadings that are executed after early boot
stage, it cannot be used by static table loadings that are executed in
early boot stage as:
1. The address of the table is a virtual address either maintained by
OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or
"LoadTable" opcodes are executed, while during early boot stage,
physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED"
while during early boot stage, tables maintained by root table list
should be kept as "INSTALLED".
To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only
applies to DSDT/FACS installation. Rename acpi_tb_add_table() to
acpi_tb_install_non_fixed_table() as it will be applied to the installation
of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect
redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the
table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary
overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc
to acpi_physical_address to allow it to be invoked by static table
loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate
to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than
DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability
(logics are collected in the single function). Also delete useless code
from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and
acpi_tb_install_fixed_table() so that the table descriptor is kept in the
state of "INSTALLED" but not "VALIDATED" after returning from these
functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into
the functions to indicate a table descriptor that is not maintained by
acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and
acpi_tb_release_temporal_table() to handle the use cases of such temporal
tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table
checksum, also remove table checksum verification from
acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions
that will convert a table into "LOADED" state or invoke it from
acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary
struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc
will be overridden before installtion, this makes code simpler.
After applying the patch, tables are always installed after being
overridden and the table checksums are always verified before installation.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-04-04 04:38:57 +00:00
|
|
|
ACPI_FREE(table);
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
2008-06-10 06:14:17 +00:00
|
|
|
/*
|
|
|
|
* Add the table to the namespace.
|
|
|
|
*
|
2008-08-15 01:37:58 +00:00
|
|
|
* Note: Load the table objects relative to the root of the namespace.
|
2008-06-10 06:14:17 +00:00
|
|
|
* This appears to go against the ACPI specification, but we do it for
|
|
|
|
* compatibility with other ACPI implementations.
|
|
|
|
*/
|
2016-09-07 06:07:24 +00:00
|
|
|
status = acpi_ex_add_table(table_index, &ddb_handle);
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 16:58:21 +00:00
|
|
|
/* Complete the initialization/resolution of new objects */
|
2018-05-08 21:06:15 +00:00
|
|
|
|
2019-07-11 16:58:21 +00:00
|
|
|
acpi_ex_exit_interpreter();
|
|
|
|
acpi_ns_initialize_objects();
|
|
|
|
acpi_ex_enter_interpreter();
|
2018-05-08 21:06:15 +00:00
|
|
|
|
2022-04-11 18:51:27 +00:00
|
|
|
/* Remove the reference to ddb_handle created by acpi_ex_add_table above */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-04-11 18:51:27 +00:00
|
|
|
acpi_ut_remove_reference(ddb_handle);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-04-11 18:51:27 +00:00
|
|
|
/* Return -1 (non-zero) indicates success */
|
2009-05-21 02:29:28 +00:00
|
|
|
|
2022-04-11 18:51:27 +00:00
|
|
|
target->integer.value = 0xFFFFFFFFFFFFFFFF;
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_unload_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: ddb_handle - Handle to a previously loaded table
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Unload an ACPI table
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status status = AE_OK;
|
|
|
|
union acpi_operand_object *table_desc = ddb_handle;
|
2008-06-10 05:42:13 +00:00
|
|
|
u32 table_index;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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>
2006-04-21 21:15:00 +00:00
|
|
|
ACPI_FUNCTION_TRACE(ex_unload_table);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-04-04 04:37:26 +00:00
|
|
|
/*
|
|
|
|
* Temporarily emit a warning so that the ASL for the machine can be
|
|
|
|
* hopefully obtained. This is to say that the Unload() operator is
|
|
|
|
* extremely rare if not completely unused.
|
|
|
|
*/
|
|
|
|
ACPI_WARNING((AE_INFO, "Received request to unload an ACPI table"));
|
|
|
|
|
2018-06-01 19:06:44 +00:00
|
|
|
/*
|
|
|
|
* May 2018: Unload is no longer supported for the following reasons:
|
|
|
|
* 1) A correct implementation on some hosts may not be possible.
|
|
|
|
* 2) Other ACPI implementations do not correctly/fully support it.
|
|
|
|
* 3) It requires host device driver support which does not exist.
|
|
|
|
* (To properly support namespace unload out from underneath.)
|
|
|
|
* 4) This AML operator has never been seen in the field.
|
|
|
|
*/
|
|
|
|
ACPI_EXCEPTION((AE_INFO, AE_NOT_IMPLEMENTED,
|
|
|
|
"AML Unload operator is not supported"));
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Validate the handle
|
2009-05-21 02:32:02 +00:00
|
|
|
* Although the handle is partially validated in acpi_ex_reconfiguration()
|
2005-04-16 22:20:36 +00:00
|
|
|
* when it calls acpi_ex_resolve_operands(), the handle is more completely
|
|
|
|
* validated here.
|
2009-05-21 02:32:02 +00:00
|
|
|
*
|
|
|
|
* Handle must be a valid operand object of type reference. Also, the
|
|
|
|
* ddb_handle must still be marked valid (table has not been previously
|
|
|
|
* unloaded)
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
if ((!ddb_handle) ||
|
2005-08-05 04:44:28 +00:00
|
|
|
(ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
|
2009-05-21 02:32:02 +00:00
|
|
|
(ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE) ||
|
|
|
|
(!(ddb_handle->common.flags & AOPOBJ_DATA_VALID))) {
|
2013-05-30 01:59:00 +00:00
|
|
|
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-09-27 02:40:39 +00:00
|
|
|
/* Get the table index from the ddb_handle */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-09-27 02:40:39 +00:00
|
|
|
table_index = table_desc->reference.value;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-09-23 03:26:35 +00:00
|
|
|
/*
|
|
|
|
* Release the interpreter lock so that the table lock won't have
|
|
|
|
* strict order requirement against it.
|
|
|
|
*/
|
|
|
|
acpi_ex_exit_interpreter();
|
2016-11-30 07:21:26 +00:00
|
|
|
status = acpi_tb_unload_table(table_index);
|
2016-09-23 03:26:35 +00:00
|
|
|
acpi_ex_enter_interpreter();
|
|
|
|
|
2009-05-21 02:32:02 +00:00
|
|
|
/*
|
|
|
|
* Invalidate the handle. We do this because the handle may be stored
|
|
|
|
* in a named object and may not be actually deleted until much later.
|
|
|
|
*/
|
2016-09-23 03:26:35 +00:00
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
ddb_handle->common.flags &= ~AOPOBJ_DATA_VALID;
|
|
|
|
}
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|