diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-12-29 01:03:08 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-31 21:47:38 -0500 |
commit | efaed9be998b5ae0afb7458e057e5f4402b43fa0 (patch) | |
tree | 3a3e2cf962955b0ec491aa534e3de2659d2050ad | |
parent | 849c25719ac6acc7420515c7b6324f4248a13790 (diff) |
ACPICA: Events: Enhance acpi_ev_execute_reg_method() to ensure no _REG evaluations can happen during OS early boot stages
ACPICA commit 31178590dde82368fdb0f6b0e466b6c0add96c57
We can ensure no early _REG evaluations by ensuring the following rules in
acpi_ev_execute_reg_method():
1. If an address space handler is installed during early stage,
_REG(CONNECT) evaluations are blocked. This is achieved using
acpi_gbl_reg_methods_enabled which is renamed from
acpi_gbl_reg_methods_executed.
2. If _REG(CONNECT) has never been evalauted for the region object,
_REG(DISCONNECT) evaluations are blocked. This is achieved by a new
region object flag: AOPOBJ_REG_CONNECTED.
Note that, after applying this patch, we can ensure _REG(DISCONNECT) is
always paired to _REG(CONNECT). Lv Zheng
Link: https://github.com/acpica/acpica/commit/31178590
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>
-rw-r--r-- | drivers/acpi/acpica/acglobal.h | 2 | ||||
-rw-r--r-- | drivers/acpi/acpica/acobject.h | 7 | ||||
-rw-r--r-- | drivers/acpi/acpica/evregion.c | 25 | ||||
-rw-r--r-- | drivers/acpi/acpica/evxfregn.c | 33 | ||||
-rw-r--r-- | drivers/acpi/acpica/excreate.c | 3 | ||||
-rw-r--r-- | drivers/acpi/acpica/utinit.c | 1 | ||||
-rw-r--r-- | drivers/acpi/acpica/utxfinit.c | 1 |
7 files changed, 30 insertions, 42 deletions
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index ef0abf4ef9ac..73462cac41d2 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -165,7 +165,7 @@ ACPI_GLOBAL(u8, acpi_gbl_next_owner_id_offset); | |||
165 | 165 | ||
166 | /* Initialization sequencing */ | 166 | /* Initialization sequencing */ |
167 | 167 | ||
168 | ACPI_GLOBAL(u8, acpi_gbl_reg_methods_executed); | 168 | ACPI_INIT_GLOBAL(u8, acpi_gbl_reg_methods_enabled, FALSE); |
169 | 169 | ||
170 | /* Misc */ | 170 | /* Misc */ |
171 | 171 | ||
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h index 0bd02c4a5f75..2b154cfbe136 100644 --- a/drivers/acpi/acpica/acobject.h +++ b/drivers/acpi/acpica/acobject.h | |||
@@ -93,9 +93,10 @@ | |||
93 | #define AOPOBJ_AML_CONSTANT 0x01 /* Integer is an AML constant */ | 93 | #define AOPOBJ_AML_CONSTANT 0x01 /* Integer is an AML constant */ |
94 | #define AOPOBJ_STATIC_POINTER 0x02 /* Data is part of an ACPI table, don't delete */ | 94 | #define AOPOBJ_STATIC_POINTER 0x02 /* Data is part of an ACPI table, don't delete */ |
95 | #define AOPOBJ_DATA_VALID 0x04 /* Object is initialized and data is valid */ | 95 | #define AOPOBJ_DATA_VALID 0x04 /* Object is initialized and data is valid */ |
96 | #define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized, _REG was run */ | 96 | #define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized */ |
97 | #define AOPOBJ_SETUP_COMPLETE 0x10 /* Region setup is complete */ | 97 | #define AOPOBJ_REG_CONNECTED 0x10 /* _REG was run */ |
98 | #define AOPOBJ_INVALID 0x20 /* Host OS won't allow a Region address */ | 98 | #define AOPOBJ_SETUP_COMPLETE 0x20 /* Region setup is complete */ |
99 | #define AOPOBJ_INVALID 0x40 /* Host OS won't allow a Region address */ | ||
99 | 100 | ||
100 | /****************************************************************************** | 101 | /****************************************************************************** |
101 | * | 102 | * |
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 432b81080369..cf6e8785491c 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c | |||
@@ -104,8 +104,6 @@ acpi_status acpi_ev_initialize_op_regions(void) | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | acpi_gbl_reg_methods_executed = TRUE; | ||
108 | |||
109 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 107 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
110 | return_ACPI_STATUS(status); | 108 | return_ACPI_STATUS(status); |
111 | } | 109 | } |
@@ -601,7 +599,18 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) | |||
601 | return_ACPI_STATUS(AE_NOT_EXIST); | 599 | return_ACPI_STATUS(AE_NOT_EXIST); |
602 | } | 600 | } |
603 | 601 | ||
604 | if (region_obj2->extra.method_REG == NULL) { | 602 | if (region_obj2->extra.method_REG == NULL || |
603 | region_obj->region.handler == NULL || | ||
604 | !acpi_gbl_reg_methods_enabled) { | ||
605 | return_ACPI_STATUS(AE_OK); | ||
606 | } | ||
607 | |||
608 | /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */ | ||
609 | |||
610 | if ((function == ACPI_REG_CONNECT && | ||
611 | region_obj->common.flags & AOPOBJ_REG_CONNECTED) || | ||
612 | (function == ACPI_REG_DISCONNECT && | ||
613 | !(region_obj->common.flags & AOPOBJ_REG_CONNECTED))) { | ||
605 | return_ACPI_STATUS(AE_OK); | 614 | return_ACPI_STATUS(AE_OK); |
606 | } | 615 | } |
607 | 616 | ||
@@ -650,6 +659,16 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) | |||
650 | status = acpi_ns_evaluate(info); | 659 | status = acpi_ns_evaluate(info); |
651 | acpi_ut_remove_reference(args[1]); | 660 | acpi_ut_remove_reference(args[1]); |
652 | 661 | ||
662 | if (ACPI_FAILURE(status)) { | ||
663 | goto cleanup2; | ||
664 | } | ||
665 | |||
666 | if (function == ACPI_REG_CONNECT) { | ||
667 | region_obj->common.flags |= AOPOBJ_REG_CONNECTED; | ||
668 | } else { | ||
669 | region_obj->common.flags &= ~AOPOBJ_REG_CONNECTED; | ||
670 | } | ||
671 | |||
653 | cleanup2: | 672 | cleanup2: |
654 | acpi_ut_remove_reference(args[0]); | 673 | acpi_ut_remove_reference(args[0]); |
655 | 674 | ||
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c index 3c905085fe5a..29f9f3999dfc 100644 --- a/drivers/acpi/acpica/evxfregn.c +++ b/drivers/acpi/acpica/evxfregn.c | |||
@@ -112,39 +112,6 @@ acpi_install_address_space_handler(acpi_handle device, | |||
112 | goto unlock_and_exit; | 112 | goto unlock_and_exit; |
113 | } | 113 | } |
114 | 114 | ||
115 | /* | ||
116 | * For the default space_IDs, (the IDs for which there are default region handlers | ||
117 | * installed) Only execute the _REG methods if the global initialization _REG | ||
118 | * methods have already been run (via acpi_initialize_objects). In other words, | ||
119 | * we will defer the execution of the _REG methods for these space_IDs until | ||
120 | * execution of acpi_initialize_objects. This is done because we need the handlers | ||
121 | * for the default spaces (mem/io/pci/table) to be installed before we can run | ||
122 | * any control methods (or _REG methods). There is known BIOS code that depends | ||
123 | * on this. | ||
124 | * | ||
125 | * For all other space_IDs, we can safely execute the _REG methods immediately. | ||
126 | * This means that for IDs like embedded_controller, this function should be called | ||
127 | * only after acpi_enable_subsystem has been called. | ||
128 | */ | ||
129 | switch (space_id) { | ||
130 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
131 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
132 | case ACPI_ADR_SPACE_PCI_CONFIG: | ||
133 | case ACPI_ADR_SPACE_DATA_TABLE: | ||
134 | |||
135 | if (!acpi_gbl_reg_methods_executed) { | ||
136 | |||
137 | /* We will defer execution of the _REG methods for this space */ | ||
138 | |||
139 | goto unlock_and_exit; | ||
140 | } | ||
141 | break; | ||
142 | |||
143 | default: | ||
144 | |||
145 | break; | ||
146 | } | ||
147 | |||
148 | /* Run all _REG methods for this address space */ | 115 | /* Run all _REG methods for this address space */ |
149 | 116 | ||
150 | status = acpi_ev_execute_reg_methods(node, space_id); | 117 | status = acpi_ev_execute_reg_methods(node, space_id); |
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c index 6a1396e313b1..46be5a276863 100644 --- a/drivers/acpi/acpica/excreate.c +++ b/drivers/acpi/acpica/excreate.c | |||
@@ -345,7 +345,8 @@ acpi_ex_create_region(u8 * aml_start, | |||
345 | obj_desc->region.node = node; | 345 | obj_desc->region.node = node; |
346 | obj_desc->region.handler = NULL; | 346 | obj_desc->region.handler = NULL; |
347 | obj_desc->common.flags &= | 347 | obj_desc->common.flags &= |
348 | ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_OBJECT_INITIALIZED); | 348 | ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED | |
349 | AOPOBJ_OBJECT_INITIALIZED); | ||
349 | 350 | ||
350 | /* Install the new region object in the parent Node */ | 351 | /* Install the new region object in the parent Node */ |
351 | 352 | ||
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c index ccd0745f011e..fd82a122785e 100644 --- a/drivers/acpi/acpica/utinit.c +++ b/drivers/acpi/acpica/utinit.c | |||
@@ -206,7 +206,6 @@ acpi_status acpi_ut_init_globals(void) | |||
206 | acpi_gbl_next_owner_id_offset = 0; | 206 | acpi_gbl_next_owner_id_offset = 0; |
207 | acpi_gbl_debugger_configuration = DEBUGGER_THREADING; | 207 | acpi_gbl_debugger_configuration = DEBUGGER_THREADING; |
208 | acpi_gbl_osi_mutex = NULL; | 208 | acpi_gbl_osi_mutex = NULL; |
209 | acpi_gbl_reg_methods_executed = FALSE; | ||
210 | acpi_gbl_max_loop_iterations = 0xFFFF; | 209 | acpi_gbl_max_loop_iterations = 0xFFFF; |
211 | 210 | ||
212 | /* Hardware oriented */ | 211 | /* Hardware oriented */ |
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c index 7d8eb602bbbe..1c7ed4986963 100644 --- a/drivers/acpi/acpica/utxfinit.c +++ b/drivers/acpi/acpica/utxfinit.c | |||
@@ -267,6 +267,7 @@ acpi_status __init acpi_initialize_objects(u32 flags) | |||
267 | * initialized, even if they contain executable AML (see the call to | 267 | * initialized, even if they contain executable AML (see the call to |
268 | * acpi_ns_initialize_objects below). | 268 | * acpi_ns_initialize_objects below). |
269 | */ | 269 | */ |
270 | acpi_gbl_reg_methods_enabled = TRUE; | ||
270 | if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { | 271 | if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { |
271 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 272 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
272 | "[Init] Executing _REG OpRegion methods\n")); | 273 | "[Init] Executing _REG OpRegion methods\n")); |