aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-01-12 17:45:43 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-01-12 17:45:43 -0500
commit3e7cc142c1e040fd4629ad34a54b1c5b46dc3dd3 (patch)
treebbb7a1e440caa0df16da2b05d6a443a752b8b171 /drivers/acpi
parent25d412d932fb3289ae5b510845d523330b80bb71 (diff)
parentc14ced0464bf5ef3a3fad6d69bbf07c80bfbaf5b (diff)
Merge branch 'acpica'
* acpica: (21 commits) ACPICA: Update version to 20131218. ACPICA: Utilities: Cleanup declarations of the acpi_gbl_debug_file global. ACPICA: Linuxize: Cleanup spaces after special macro invocations. ACPICA: Interpreter: Add additional debug info for an error case. ACPICA: Update ACPI example code to make it an actual working program. ACPICA: Add an error message if the Debugger fails initialization. ACPICA: Conditionally define a local variable that is used for debug only. ACPICA: Parser: Updates/fixes for debug output. ACPICA: Enhance ACPI warning for memory/IO address conflicts. ACPICA: Update several debug statements - no functional change. ACPICA: Improve exception handling for GPE block installation. ACPICA: Add helper macros to extract bus/segment numbers from HEST table. ACPICA: Tables: Add full support for the PCCT table, update table definition. ACPICA: Tables: Add full support for the DBG2 table. ACPICA: Add option to favor 32-bit FADT addresses. ACPICA: Cleanup the option of forcing the use of the RSDT. ACPICA: Back port and refine validation of the XSDT root table. ACPICA: Linux Header: Remove unused OSL prototypes. ACPICA: Remove unused ACPI_FREE_BUFFER macro. No functional change. ACPICA: Disassembler: Improve pathname support for emitted External() statements. ...
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/acdebug.h1
-rw-r--r--drivers/acpi/acpica/acevents.h9
-rw-r--r--drivers/acpi/acpica/acglobal.h30
-rw-r--r--drivers/acpi/acpica/aclocal.h9
-rw-r--r--drivers/acpi/acpica/dsfield.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c19
-rw-r--r--drivers/acpi/acpica/dswload.c4
-rw-r--r--drivers/acpi/acpica/evgpeblk.c8
-rw-r--r--drivers/acpi/acpica/evgpeutil.c24
-rw-r--r--drivers/acpi/acpica/exresnte.c3
-rw-r--r--drivers/acpi/acpica/nsxfeval.c23
-rw-r--r--drivers/acpi/acpica/psopinfo.c51
-rw-r--r--drivers/acpi/acpica/tbfadt.c335
-rw-r--r--drivers/acpi/acpica/tbutils.c214
-rw-r--r--drivers/acpi/acpica/utaddress.c19
-rw-r--r--drivers/acpi/acpica/utalloc.c10
-rw-r--r--drivers/acpi/acpica/utcache.c12
-rw-r--r--drivers/acpi/acpica/utdebug.c4
-rw-r--r--drivers/acpi/acpica/utglobal.c4
-rw-r--r--drivers/acpi/acpica/utxfinit.c12
20 files changed, 478 insertions, 315 deletions
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index a9fd0b872062..2bf3ca2b8a7a 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -113,7 +113,6 @@ void acpi_db_display_handlers(void);
113ACPI_HW_DEPENDENT_RETURN_VOID(void 113ACPI_HW_DEPENDENT_RETURN_VOID(void
114 acpi_db_generate_gpe(char *gpe_arg, 114 acpi_db_generate_gpe(char *gpe_arg,
115 char *block_arg)) 115 char *block_arg))
116
117ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void)) 116ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void))
118 117
119/* 118/*
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 41abe552c7a3..0fb0adf435d6 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -71,9 +71,8 @@ acpi_status acpi_ev_init_global_lock_handler(void);
71 71
72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status
73 acpi_ev_acquire_global_lock(u16 timeout)) 73 acpi_ev_acquire_global_lock(u16 timeout))
74
75ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) 74ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void))
76 acpi_status acpi_ev_remove_global_lock_handler(void); 75acpi_status acpi_ev_remove_global_lock_handler(void);
77 76
78/* 77/*
79 * evgpe - Low-level GPE support 78 * evgpe - Low-level GPE support
@@ -133,7 +132,7 @@ acpi_status acpi_ev_gpe_initialize(void);
133ACPI_HW_DEPENDENT_RETURN_VOID(void 132ACPI_HW_DEPENDENT_RETURN_VOID(void
134 acpi_ev_update_gpes(acpi_owner_id table_owner_id)) 133 acpi_ev_update_gpes(acpi_owner_id table_owner_id))
135 134
136 acpi_status 135acpi_status
137acpi_ev_match_gpe_method(acpi_handle obj_handle, 136acpi_ev_match_gpe_method(acpi_handle obj_handle,
138 u32 level, void *context, void **return_value); 137 u32 level, void *context, void **return_value);
139 138
@@ -149,7 +148,9 @@ acpi_status
149acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 148acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
150 struct acpi_gpe_block_info *gpe_block, void *context); 149 struct acpi_gpe_block_info *gpe_block, void *context);
151 150
152struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number); 151acpi_status
152acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
153 struct acpi_gpe_xrupt_info **gpe_xrupt_block);
153 154
154acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); 155acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt);
155 156
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index e9f1fc7f99c7..24db8e153bf0 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -119,6 +119,24 @@ bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
119u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); 119u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE);
120 120
121/* 121/*
122 * Optionally ignore an XSDT if present and use the RSDT instead.
123 * Although the ACPI specification requires that an XSDT be used instead
124 * of the RSDT, the XSDT has been found to be corrupt or ill-formed on
125 * some machines. Default behavior is to use the XSDT if present.
126 */
127u8 ACPI_INIT_GLOBAL(acpi_gbl_do_not_use_xsdt, FALSE);
128
129/*
130 * Optionally use 32-bit FADT addresses if and when there is a conflict
131 * (address mismatch) between the 32-bit and 64-bit versions of the
132 * address. Although ACPICA adheres to the ACPI specification which
133 * requires the use of the corresponding 64-bit address if it is non-zero,
134 * some machines have been found to have a corrupted non-zero 64-bit
135 * address. Default is FALSE, do not favor the 32-bit addresses.
136 */
137u8 ACPI_INIT_GLOBAL(acpi_gbl_use32_bit_fadt_addresses, FALSE);
138
139/*
122 * Optionally truncate I/O addresses to 16 bits. Provides compatibility 140 * Optionally truncate I/O addresses to 16 bits. Provides compatibility
123 * with other ACPI implementations. NOTE: During ACPICA initialization, 141 * with other ACPI implementations. NOTE: During ACPICA initialization,
124 * this value is set to TRUE if any Windows OSI strings have been 142 * this value is set to TRUE if any Windows OSI strings have been
@@ -484,6 +502,18 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
484 502
485/***************************************************************************** 503/*****************************************************************************
486 * 504 *
505 * Application globals
506 *
507 ****************************************************************************/
508
509#ifdef ACPI_APPLICATION
510
511ACPI_FILE ACPI_INIT_GLOBAL(acpi_gbl_debug_file, NULL);
512
513#endif /* ACPI_APPLICATION */
514
515/*****************************************************************************
516 *
487 * Info/help support 517 * Info/help support
488 * 518 *
489 ****************************************************************************/ 519 ****************************************************************************/
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 53ed1a8ba4f0..d95ca5449ace 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -1038,15 +1038,16 @@ struct acpi_external_list {
1038 struct acpi_external_list *next; 1038 struct acpi_external_list *next;
1039 u32 value; 1039 u32 value;
1040 u16 length; 1040 u16 length;
1041 u16 flags;
1041 u8 type; 1042 u8 type;
1042 u8 flags;
1043 u8 resolved;
1044 u8 emitted;
1045}; 1043};
1046 1044
1047/* Values for Flags field above */ 1045/* Values for Flags field above */
1048 1046
1049#define ACPI_IPATH_ALLOCATED 0x01 1047#define ACPI_EXT_RESOLVED_REFERENCE 0x01 /* Object was resolved during cross ref */
1048#define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */
1049#define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */
1050#define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */
1050 1051
1051struct acpi_external_file { 1052struct acpi_external_file {
1052 char *path; 1053 char *path;
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 2d4c07322576..e7a57c554e84 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -105,7 +105,7 @@ acpi_ds_create_external_region(acpi_status lookup_status,
105 * operation_region not found. Generate an External for it, and 105 * operation_region not found. Generate an External for it, and
106 * insert the name into the namespace. 106 * insert the name into the namespace.
107 */ 107 */
108 acpi_dm_add_to_external_list(op, path, ACPI_TYPE_REGION, 0); 108 acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0);
109 status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION, 109 status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION,
110 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 110 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
111 walk_state, node); 111 walk_state, node);
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index ade44e49deb4..d7f53fb2979a 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -727,27 +727,26 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
727 index++; 727 index++;
728 } 728 }
729 729
730 index--; 730 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
731 "NumOperands %d, ArgCount %d, Index %d\n",
732 walk_state->num_operands, arg_count, index));
731 733
732 /* It is the appropriate order to get objects from the Result stack */ 734 /* Create the interpreter arguments, in reverse order */
733 735
736 index--;
734 for (i = 0; i < arg_count; i++) { 737 for (i = 0; i < arg_count; i++) {
735 arg = arguments[index]; 738 arg = arguments[index];
736 739 walk_state->operand_index = (u8)index;
737 /* Force the filling of the operand stack in inverse order */
738
739 walk_state->operand_index = (u8) index;
740 740
741 status = acpi_ds_create_operand(walk_state, arg, index); 741 status = acpi_ds_create_operand(walk_state, arg, index);
742 if (ACPI_FAILURE(status)) { 742 if (ACPI_FAILURE(status)) {
743 goto cleanup; 743 goto cleanup;
744 } 744 }
745 745
746 index--;
747
748 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 746 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
749 "Arg #%u (%p) done, Arg1=%p\n", index, arg, 747 "Created Arg #%u (%p) %u args total\n",
750 first_arg)); 748 index, arg, arg_count));
749 index--;
751 } 750 }
752 751
753 return_ACPI_STATUS(status); 752 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 95e681a36f9c..2dbe109727c8 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -181,8 +181,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
181 * Target of Scope() not found. Generate an External for it, and 181 * Target of Scope() not found. Generate an External for it, and
182 * insert the name into the namespace. 182 * insert the name into the namespace.
183 */ 183 */
184 acpi_dm_add_to_external_list(op, path, ACPI_TYPE_DEVICE, 184 acpi_dm_add_op_to_external_list(op, path,
185 0); 185 ACPI_TYPE_DEVICE, 0, 0);
186 status = 186 status =
187 acpi_ns_lookup(walk_state->scope_info, path, 187 acpi_ns_lookup(walk_state->scope_info, path,
188 object_type, ACPI_IMODE_LOAD_PASS1, 188 object_type, ACPI_IMODE_LOAD_PASS1,
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index a9e76bc4ad97..a31e549e64cc 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -87,9 +87,9 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
87 return_ACPI_STATUS(status); 87 return_ACPI_STATUS(status);
88 } 88 }
89 89
90 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number); 90 status =
91 if (!gpe_xrupt_block) { 91 acpi_ev_get_gpe_xrupt_block(interrupt_number, &gpe_xrupt_block);
92 status = AE_NO_MEMORY; 92 if (ACPI_FAILURE(status)) {
93 goto unlock_and_exit; 93 goto unlock_and_exit;
94 } 94 }
95 95
@@ -112,7 +112,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
112 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 112 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
113 113
114unlock_and_exit: 114unlock_and_exit:
115 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); 115 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
116 return_ACPI_STATUS(status); 116 return_ACPI_STATUS(status);
117} 117}
118 118
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index d3f5e1e2a2b1..4d764e847a08 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -197,8 +197,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
197 * FUNCTION: acpi_ev_get_gpe_xrupt_block 197 * FUNCTION: acpi_ev_get_gpe_xrupt_block
198 * 198 *
199 * PARAMETERS: interrupt_number - Interrupt for a GPE block 199 * PARAMETERS: interrupt_number - Interrupt for a GPE block
200 * gpe_xrupt_block - Where the block is returned
200 * 201 *
201 * RETURN: A GPE interrupt block 202 * RETURN: Status
202 * 203 *
203 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 204 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
204 * block per unique interrupt level used for GPEs. Should be 205 * block per unique interrupt level used for GPEs. Should be
@@ -207,7 +208,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
207 * 208 *
208 ******************************************************************************/ 209 ******************************************************************************/
209 210
210struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) 211acpi_status
212acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
213 struct acpi_gpe_xrupt_info ** gpe_xrupt_block)
211{ 214{
212 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 215 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
213 struct acpi_gpe_xrupt_info *gpe_xrupt; 216 struct acpi_gpe_xrupt_info *gpe_xrupt;
@@ -221,7 +224,8 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
221 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 224 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
222 while (next_gpe_xrupt) { 225 while (next_gpe_xrupt) {
223 if (next_gpe_xrupt->interrupt_number == interrupt_number) { 226 if (next_gpe_xrupt->interrupt_number == interrupt_number) {
224 return_PTR(next_gpe_xrupt); 227 *gpe_xrupt_block = next_gpe_xrupt;
228 return_ACPI_STATUS(AE_OK);
225 } 229 }
226 230
227 next_gpe_xrupt = next_gpe_xrupt->next; 231 next_gpe_xrupt = next_gpe_xrupt->next;
@@ -231,7 +235,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
231 235
232 gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); 236 gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info));
233 if (!gpe_xrupt) { 237 if (!gpe_xrupt) {
234 return_PTR(NULL); 238 return_ACPI_STATUS(AE_NO_MEMORY);
235 } 239 }
236 240
237 gpe_xrupt->interrupt_number = interrupt_number; 241 gpe_xrupt->interrupt_number = interrupt_number;
@@ -250,6 +254,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
250 } else { 254 } else {
251 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; 255 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
252 } 256 }
257
253 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 258 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
254 259
255 /* Install new interrupt handler if not SCI_INT */ 260 /* Install new interrupt handler if not SCI_INT */
@@ -259,14 +264,15 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
259 acpi_ev_gpe_xrupt_handler, 264 acpi_ev_gpe_xrupt_handler,
260 gpe_xrupt); 265 gpe_xrupt);
261 if (ACPI_FAILURE(status)) { 266 if (ACPI_FAILURE(status)) {
262 ACPI_ERROR((AE_INFO, 267 ACPI_EXCEPTION((AE_INFO, status,
263 "Could not install GPE interrupt handler at level 0x%X", 268 "Could not install GPE interrupt handler at level 0x%X",
264 interrupt_number)); 269 interrupt_number));
265 return_PTR(NULL); 270 return_ACPI_STATUS(status);
266 } 271 }
267 } 272 }
268 273
269 return_PTR(gpe_xrupt); 274 *gpe_xrupt_block = gpe_xrupt;
275 return_ACPI_STATUS(AE_OK);
270} 276}
271 277
272/******************************************************************************* 278/*******************************************************************************
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index acd34f599313..7ca6925a87ca 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -124,7 +124,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
124 } 124 }
125 125
126 if (!source_desc) { 126 if (!source_desc) {
127 ACPI_ERROR((AE_INFO, "No object attached to node %p", node)); 127 ACPI_ERROR((AE_INFO, "No object attached to node [%4.4s] %p",
128 node->name.ascii, node));
128 return_ACPI_STATUS(AE_AML_NO_OPERAND); 129 return_ACPI_STATUS(AE_AML_NO_OPERAND);
129 } 130 }
130 131
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index e973e311f856..1f0c28ba50df 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -84,7 +84,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
84 acpi_object_type return_type) 84 acpi_object_type return_type)
85{ 85{
86 acpi_status status; 86 acpi_status status;
87 u8 must_free = FALSE; 87 u8 free_buffer_on_error = FALSE;
88 88
89 ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed); 89 ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
90 90
@@ -95,14 +95,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
95 } 95 }
96 96
97 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { 97 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
98 must_free = TRUE; 98 free_buffer_on_error = TRUE;
99 } 99 }
100 100
101 /* Evaluate the object */ 101 /* Evaluate the object */
102 102
103 status = 103 status = acpi_evaluate_object(handle, pathname,
104 acpi_evaluate_object(handle, pathname, external_params, 104 external_params, return_buffer);
105 return_buffer);
106 if (ACPI_FAILURE(status)) { 105 if (ACPI_FAILURE(status)) {
107 return_ACPI_STATUS(status); 106 return_ACPI_STATUS(status);
108 } 107 }
@@ -135,11 +134,15 @@ acpi_evaluate_object_typed(acpi_handle handle,
135 pointer)->type), 134 pointer)->type),
136 acpi_ut_get_type_name(return_type))); 135 acpi_ut_get_type_name(return_type)));
137 136
138 if (must_free) { 137 if (free_buffer_on_error) {
139 138 /*
140 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 139 * Free a buffer created via ACPI_ALLOCATE_BUFFER.
141 140 * Note: We use acpi_os_free here because acpi_os_allocate was used
142 ACPI_FREE_BUFFER(*return_buffer); 141 * to allocate the buffer. This purposefully bypasses the
142 * (optionally enabled) allocation tracking mechanism since we
143 * only want to track internal allocations.
144 */
145 acpi_os_free(return_buffer->pointer);
143 return_buffer->pointer = NULL; 146 return_buffer->pointer = NULL;
144 } 147 }
145 148
diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c
index 9ba5301e5751..b0c9787dbe61 100644
--- a/drivers/acpi/acpica/psopinfo.c
+++ b/drivers/acpi/acpica/psopinfo.c
@@ -71,6 +71,10 @@ static const u8 acpi_gbl_argument_count[] =
71 71
72const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) 72const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
73{ 73{
74#ifdef ACPI_DEBUG_OUTPUT
75 const char *opcode_name = "Unknown AML opcode";
76#endif
77
74 ACPI_FUNCTION_NAME(ps_get_opcode_info); 78 ACPI_FUNCTION_NAME(ps_get_opcode_info);
75 79
76 /* 80 /*
@@ -92,11 +96,54 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
92 return (&acpi_gbl_aml_op_info 96 return (&acpi_gbl_aml_op_info
93 [acpi_gbl_long_op_index[(u8)opcode]]); 97 [acpi_gbl_long_op_index[(u8)opcode]]);
94 } 98 }
99#if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT
100#include "asldefine.h"
101
102 switch (opcode) {
103 case AML_RAW_DATA_BYTE:
104 opcode_name = "-Raw Data Byte-";
105 break;
106
107 case AML_RAW_DATA_WORD:
108 opcode_name = "-Raw Data Word-";
109 break;
110
111 case AML_RAW_DATA_DWORD:
112 opcode_name = "-Raw Data Dword-";
113 break;
114
115 case AML_RAW_DATA_QWORD:
116 opcode_name = "-Raw Data Qword-";
117 break;
118
119 case AML_RAW_DATA_BUFFER:
120 opcode_name = "-Raw Data Buffer-";
121 break;
122
123 case AML_RAW_DATA_CHAIN:
124 opcode_name = "-Raw Data Buffer Chain-";
125 break;
126
127 case AML_PACKAGE_LENGTH:
128 opcode_name = "-Package Length-";
129 break;
130
131 case AML_UNASSIGNED_OPCODE:
132 opcode_name = "-Unassigned Opcode-";
133 break;
134
135 case AML_DEFAULT_ARG_OP:
136 opcode_name = "-Default Arg-";
137 break;
138
139 default:
140 break;
141 }
142#endif
95 143
96 /* Unknown AML opcode */ 144 /* Unknown AML opcode */
97 145
98 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 146 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%4.4X]\n", opcode_name, opcode));
99 "Unknown AML opcode [%4.4X]\n", opcode));
100 147
101 return (&acpi_gbl_aml_op_info[_UNK]); 148 return (&acpi_gbl_aml_op_info[_UNK]);
102} 149}
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 9d99f2189693..8f89263ac47e 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -56,10 +56,11 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
56 56
57static void acpi_tb_convert_fadt(void); 57static void acpi_tb_convert_fadt(void);
58 58
59static void acpi_tb_validate_fadt(void);
60
61static void acpi_tb_setup_fadt_registers(void); 59static void acpi_tb_setup_fadt_registers(void);
62 60
61static u64
62acpi_tb_select_address(char *register_name, u32 address32, u64 address64);
63
63/* Table for conversion of FADT to common internal format and FADT validation */ 64/* Table for conversion of FADT to common internal format and FADT validation */
64 65
65typedef struct acpi_fadt_info { 66typedef struct acpi_fadt_info {
@@ -175,6 +176,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
175 * space_id - ACPI Space ID for this register 176 * space_id - ACPI Space ID for this register
176 * byte_width - Width of this register 177 * byte_width - Width of this register
177 * address - Address of the register 178 * address - Address of the register
179 * register_name - ASCII name of the ACPI register
178 * 180 *
179 * RETURN: None 181 * RETURN: None
180 * 182 *
@@ -220,6 +222,68 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
220 222
221/******************************************************************************* 223/*******************************************************************************
222 * 224 *
225 * FUNCTION: acpi_tb_select_address
226 *
227 * PARAMETERS: register_name - ASCII name of the ACPI register
228 * address32 - 32-bit address of the register
229 * address64 - 64-bit address of the register
230 *
231 * RETURN: The resolved 64-bit address
232 *
233 * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within
234 * the FADT. Used for the FACS and DSDT addresses.
235 *
236 * NOTES:
237 *
238 * Check for FACS and DSDT address mismatches. An address mismatch between
239 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
240 * DSDT/X_DSDT) could be a corrupted address field or it might indicate
241 * the presence of two FACS or two DSDT tables.
242 *
243 * November 2013:
244 * By default, as per the ACPICA specification, a valid 64-bit address is
245 * used regardless of the value of the 32-bit address. However, this
246 * behavior can be overridden via the acpi_gbl_use32_bit_fadt_addresses flag.
247 *
248 ******************************************************************************/
249
250static u64
251acpi_tb_select_address(char *register_name, u32 address32, u64 address64)
252{
253
254 if (!address64) {
255
256 /* 64-bit address is zero, use 32-bit address */
257
258 return ((u64)address32);
259 }
260
261 if (address32 && (address64 != (u64)address32)) {
262
263 /* Address mismatch between 32-bit and 64-bit versions */
264
265 ACPI_BIOS_WARNING((AE_INFO,
266 "32/64X %s address mismatch in FADT: "
267 "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
268 register_name, address32,
269 ACPI_FORMAT_UINT64(address64),
270 acpi_gbl_use32_bit_fadt_addresses ? 32 :
271 64));
272
273 /* 32-bit address override */
274
275 if (acpi_gbl_use32_bit_fadt_addresses) {
276 return ((u64)address32);
277 }
278 }
279
280 /* Default is to use the 64-bit address */
281
282 return (address64);
283}
284
285/*******************************************************************************
286 *
223 * FUNCTION: acpi_tb_parse_fadt 287 * FUNCTION: acpi_tb_parse_fadt
224 * 288 *
225 * PARAMETERS: table_index - Index for the FADT 289 * PARAMETERS: table_index - Index for the FADT
@@ -331,10 +395,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
331 395
332 acpi_tb_convert_fadt(); 396 acpi_tb_convert_fadt();
333 397
334 /* Validate FADT values now, before we make any changes */
335
336 acpi_tb_validate_fadt();
337
338 /* Initialize the global ACPI register structures */ 398 /* Initialize the global ACPI register structures */
339 399
340 acpi_tb_setup_fadt_registers(); 400 acpi_tb_setup_fadt_registers();
@@ -344,66 +404,55 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
344 * 404 *
345 * FUNCTION: acpi_tb_convert_fadt 405 * FUNCTION: acpi_tb_convert_fadt
346 * 406 *
347 * PARAMETERS: None, uses acpi_gbl_FADT 407 * PARAMETERS: none - acpi_gbl_FADT is used.
348 * 408 *
349 * RETURN: None 409 * RETURN: None
350 * 410 *
351 * DESCRIPTION: Converts all versions of the FADT to a common internal format. 411 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
352 * Expand 32-bit addresses to 64-bit as necessary. 412 * Expand 32-bit addresses to 64-bit as necessary. Also validate
413 * important fields within the FADT.
353 * 414 *
354 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), 415 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must
355 * and must contain a copy of the actual FADT. 416 * contain a copy of the actual BIOS-provided FADT.
356 * 417 *
357 * Notes on 64-bit register addresses: 418 * Notes on 64-bit register addresses:
358 * 419 *
359 * After this FADT conversion, later ACPICA code will only use the 64-bit "X" 420 * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
360 * fields of the FADT for all ACPI register addresses. 421 * fields of the FADT for all ACPI register addresses.
361 * 422 *
362 * The 64-bit "X" fields are optional extensions to the original 32-bit FADT 423 * The 64-bit X fields are optional extensions to the original 32-bit FADT
363 * V1.0 fields. Even if they are present in the FADT, they are optional and 424 * V1.0 fields. Even if they are present in the FADT, they are optional and
364 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand 425 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
365 * 32-bit V1.0 fields if the corresponding X field is zero. 426 * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is
427 * originally zero.
366 * 428 *
367 * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the 429 * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address
368 * corresponding "X" fields in the internal FADT. 430 * fields are expanded to the corresponding 64-bit X fields in the internal
431 * common FADT.
369 * 432 *
370 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded 433 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
371 * to the corresponding 64-bit X fields. For compatibility with other ACPI 434 * to the corresponding 64-bit X fields, if the 64-bit field is originally
372 * implementations, we ignore the 64-bit field if the 32-bit field is valid, 435 * zero. Adhering to the ACPI specification, we completely ignore the 32-bit
373 * regardless of whether the host OS is 32-bit or 64-bit. 436 * field if the 64-bit field is valid, regardless of whether the host OS is
437 * 32-bit or 64-bit.
438 *
439 * Possible additional checks:
440 * (acpi_gbl_FADT.pm1_event_length >= 4)
441 * (acpi_gbl_FADT.pm1_control_length >= 2)
442 * (acpi_gbl_FADT.pm_timer_length >= 4)
443 * Gpe block lengths must be multiple of 2
374 * 444 *
375 ******************************************************************************/ 445 ******************************************************************************/
376 446
377static void acpi_tb_convert_fadt(void) 447static void acpi_tb_convert_fadt(void)
378{ 448{
449 char *name;
379 struct acpi_generic_address *address64; 450 struct acpi_generic_address *address64;
380 u32 address32; 451 u32 address32;
452 u8 length;
381 u32 i; 453 u32 i;
382 454
383 /* 455 /*
384 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
385 * Later code will always use the X 64-bit field. Also, check for an
386 * address mismatch between the 32-bit and 64-bit address fields
387 * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate
388 * the presence of two FACS or two DSDT tables.
389 */
390 if (!acpi_gbl_FADT.Xfacs) {
391 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
392 } else if (acpi_gbl_FADT.facs &&
393 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
394 ACPI_WARNING((AE_INFO,
395 "32/64 FACS address mismatch in FADT - two FACS tables!"));
396 }
397
398 if (!acpi_gbl_FADT.Xdsdt) {
399 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
400 } else if (acpi_gbl_FADT.dsdt &&
401 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
402 ACPI_WARNING((AE_INFO,
403 "32/64 DSDT address mismatch in FADT - two DSDT tables!"));
404 }
405
406 /*
407 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which 456 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
408 * should be zero are indeed zero. This will workaround BIOSs that 457 * should be zero are indeed zero. This will workaround BIOSs that
409 * inadvertently place values in these fields. 458 * inadvertently place values in these fields.
@@ -421,119 +470,24 @@ static void acpi_tb_convert_fadt(void)
421 acpi_gbl_FADT.boot_flags = 0; 470 acpi_gbl_FADT.boot_flags = 0;
422 } 471 }
423 472
424 /* Update the local FADT table header length */
425
426 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
427
428 /* 473 /*
429 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" 474 * Now we can update the local FADT length to the length of the
430 * generic address structures as necessary. Later code will always use 475 * current FADT version as defined by the ACPI specification.
431 * the 64-bit address structures. 476 * Thus, we will have a common FADT internally.
432 *
433 * March 2009:
434 * We now always use the 32-bit address if it is valid (non-null). This
435 * is not in accordance with the ACPI specification which states that
436 * the 64-bit address supersedes the 32-bit version, but we do this for
437 * compatibility with other ACPI implementations. Most notably, in the
438 * case where both the 32 and 64 versions are non-null, we use the 32-bit
439 * version. This is the only address that is guaranteed to have been
440 * tested by the BIOS manufacturer.
441 */ 477 */
442 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 478 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
443 address32 = *ACPI_ADD_PTR(u32,
444 &acpi_gbl_FADT,
445 fadt_info_table[i].address32);
446
447 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
448 &acpi_gbl_FADT,
449 fadt_info_table[i].address64);
450
451 /*
452 * If both 32- and 64-bit addresses are valid (non-zero),
453 * they must match.
454 */
455 if (address64->address && address32 &&
456 (address64->address != (u64)address32)) {
457 ACPI_BIOS_ERROR((AE_INFO,
458 "32/64X address mismatch in FADT/%s: "
459 "0x%8.8X/0x%8.8X%8.8X, using 32",
460 fadt_info_table[i].name, address32,
461 ACPI_FORMAT_UINT64(address64->
462 address)));
463 }
464
465 /* Always use 32-bit address if it is valid (non-null) */
466
467 if (address32) {
468 /*
469 * Copy the 32-bit address to the 64-bit GAS structure. The
470 * Space ID is always I/O for 32-bit legacy address fields
471 */
472 acpi_tb_init_generic_address(address64,
473 ACPI_ADR_SPACE_SYSTEM_IO,
474 *ACPI_ADD_PTR(u8,
475 &acpi_gbl_FADT,
476 fadt_info_table
477 [i].length),
478 (u64) address32,
479 fadt_info_table[i].name);
480 }
481 }
482}
483
484/*******************************************************************************
485 *
486 * FUNCTION: acpi_tb_validate_fadt
487 *
488 * PARAMETERS: table - Pointer to the FADT to be validated
489 *
490 * RETURN: None
491 *
492 * DESCRIPTION: Validate various important fields within the FADT. If a problem
493 * is found, issue a message, but no status is returned.
494 * Used by both the table manager and the disassembler.
495 *
496 * Possible additional checks:
497 * (acpi_gbl_FADT.pm1_event_length >= 4)
498 * (acpi_gbl_FADT.pm1_control_length >= 2)
499 * (acpi_gbl_FADT.pm_timer_length >= 4)
500 * Gpe block lengths must be multiple of 2
501 *
502 ******************************************************************************/
503
504static void acpi_tb_validate_fadt(void)
505{
506 char *name;
507 struct acpi_generic_address *address64;
508 u8 length;
509 u32 i;
510 479
511 /* 480 /*
512 * Check for FACS and DSDT address mismatches. An address mismatch between 481 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
513 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and 482 * Later ACPICA code will always use the X 64-bit field.
514 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
515 */ 483 */
516 if (acpi_gbl_FADT.facs && 484 acpi_gbl_FADT.Xfacs = acpi_tb_select_address("FACS",
517 (acpi_gbl_FADT.Xfacs != (u64)acpi_gbl_FADT.facs)) { 485 acpi_gbl_FADT.facs,
518 ACPI_BIOS_WARNING((AE_INFO, 486 acpi_gbl_FADT.Xfacs);
519 "32/64X FACS address mismatch in FADT - "
520 "0x%8.8X/0x%8.8X%8.8X, using 32",
521 acpi_gbl_FADT.facs,
522 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
523
524 acpi_gbl_FADT.Xfacs = (u64)acpi_gbl_FADT.facs;
525 }
526
527 if (acpi_gbl_FADT.dsdt &&
528 (acpi_gbl_FADT.Xdsdt != (u64)acpi_gbl_FADT.dsdt)) {
529 ACPI_BIOS_WARNING((AE_INFO,
530 "32/64X DSDT address mismatch in FADT - "
531 "0x%8.8X/0x%8.8X%8.8X, using 32",
532 acpi_gbl_FADT.dsdt,
533 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
534 487
535 acpi_gbl_FADT.Xdsdt = (u64)acpi_gbl_FADT.dsdt; 488 acpi_gbl_FADT.Xdsdt = acpi_tb_select_address("DSDT",
536 } 489 acpi_gbl_FADT.dsdt,
490 acpi_gbl_FADT.Xdsdt);
537 491
538 /* If Hardware Reduced flag is set, we are all done */ 492 /* If Hardware Reduced flag is set, we are all done */
539 493
@@ -545,18 +499,95 @@ static void acpi_tb_validate_fadt(void)
545 499
546 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 500 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
547 /* 501 /*
548 * Generate pointer to the 64-bit address, get the register 502 * Get the 32-bit and 64-bit addresses, as well as the register
549 * length (width) and the register name 503 * length and register name.
550 */ 504 */
505 address32 = *ACPI_ADD_PTR(u32,
506 &acpi_gbl_FADT,
507 fadt_info_table[i].address32);
508
551 address64 = ACPI_ADD_PTR(struct acpi_generic_address, 509 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
552 &acpi_gbl_FADT, 510 &acpi_gbl_FADT,
553 fadt_info_table[i].address64); 511 fadt_info_table[i].address64);
554 length = 512
555 *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, 513 length = *ACPI_ADD_PTR(u8,
556 fadt_info_table[i].length); 514 &acpi_gbl_FADT,
515 fadt_info_table[i].length);
516
557 name = fadt_info_table[i].name; 517 name = fadt_info_table[i].name;
558 518
559 /* 519 /*
520 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
521 * generic address structures as necessary. Later code will always use
522 * the 64-bit address structures.
523 *
524 * November 2013:
525 * Now always use the 64-bit address if it is valid (non-zero), in
526 * accordance with the ACPI specification which states that a 64-bit
527 * address supersedes the 32-bit version. This behavior can be
528 * overridden by the acpi_gbl_use32_bit_fadt_addresses flag.
529 *
530 * During 64-bit address construction and verification,
531 * these cases are handled:
532 *
533 * Address32 zero, Address64 [don't care] - Use Address64
534 *
535 * Address32 non-zero, Address64 zero - Copy/use Address32
536 * Address32 non-zero == Address64 non-zero - Use Address64
537 * Address32 non-zero != Address64 non-zero - Warning, use Address64
538 *
539 * Override: if acpi_gbl_use32_bit_fadt_addresses is TRUE, and:
540 * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
541 *
542 * Note: space_id is always I/O for 32-bit legacy address fields
543 */
544 if (address32) {
545 if (!address64->address) {
546
547 /* 64-bit address is zero, use 32-bit address */
548
549 acpi_tb_init_generic_address(address64,
550 ACPI_ADR_SPACE_SYSTEM_IO,
551 *ACPI_ADD_PTR(u8,
552 &acpi_gbl_FADT,
553 fadt_info_table
554 [i].
555 length),
556 (u64)address32,
557 name);
558 } else if (address64->address != (u64)address32) {
559
560 /* Address mismatch */
561
562 ACPI_BIOS_WARNING((AE_INFO,
563 "32/64X address mismatch in FADT/%s: "
564 "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
565 name, address32,
566 ACPI_FORMAT_UINT64
567 (address64->address),
568 acpi_gbl_use32_bit_fadt_addresses
569 ? 32 : 64));
570
571 if (acpi_gbl_use32_bit_fadt_addresses) {
572
573 /* 32-bit address override */
574
575 acpi_tb_init_generic_address(address64,
576 ACPI_ADR_SPACE_SYSTEM_IO,
577 *ACPI_ADD_PTR
578 (u8,
579 &acpi_gbl_FADT,
580 fadt_info_table
581 [i].
582 length),
583 (u64)
584 address32,
585 name);
586 }
587 }
588 }
589
590 /*
560 * For each extended field, check for length mismatch between the 591 * For each extended field, check for length mismatch between the
561 * legacy length field and the corresponding 64-bit X length field. 592 * legacy length field and the corresponding 64-bit X length field.
562 * Note: If the legacy length field is > 0xFF bits, ignore this 593 * Note: If the legacy length field is > 0xFF bits, ignore this
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 3d6bb83aa7e7..6412d3c301cb 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -49,69 +49,11 @@
49ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52static acpi_status acpi_tb_validate_xsdt(acpi_physical_address address);
53
52static acpi_physical_address 54static acpi_physical_address
53acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); 55acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
54 56
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_tb_check_xsdt
58 *
59 * PARAMETERS: address - Pointer to the XSDT
60 *
61 * RETURN: status
62 * AE_OK - XSDT is okay
63 * AE_NO_MEMORY - can't map XSDT
64 * AE_INVALID_TABLE_LENGTH - invalid table length
65 * AE_NULL_ENTRY - XSDT has NULL entry
66 *
67 * DESCRIPTION: validate XSDT
68******************************************************************************/
69
70static acpi_status
71acpi_tb_check_xsdt(acpi_physical_address address)
72{
73 struct acpi_table_header *table;
74 u32 length;
75 u64 xsdt_entry_address;
76 u8 *table_entry;
77 u32 table_count;
78 int i;
79
80 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
81 if (!table)
82 return AE_NO_MEMORY;
83
84 length = table->length;
85 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
86 if (length < sizeof(struct acpi_table_header))
87 return AE_INVALID_TABLE_LENGTH;
88
89 table = acpi_os_map_memory(address, length);
90 if (!table)
91 return AE_NO_MEMORY;
92
93 /* Calculate the number of tables described in XSDT */
94 table_count =
95 (u32) ((table->length -
96 sizeof(struct acpi_table_header)) / sizeof(u64));
97 table_entry =
98 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
99 for (i = 0; i < table_count; i++) {
100 ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry);
101 if (!xsdt_entry_address) {
102 /* XSDT has NULL entry */
103 break;
104 }
105 table_entry += sizeof(u64);
106 }
107 acpi_os_unmap_memory(table, length);
108
109 if (i < table_count)
110 return AE_NULL_ENTRY;
111 else
112 return AE_OK;
113}
114
115#if (!ACPI_REDUCED_HARDWARE) 57#if (!ACPI_REDUCED_HARDWARE)
116/******************************************************************************* 58/*******************************************************************************
117 * 59 *
@@ -383,7 +325,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
383 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): 325 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
384 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT 326 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
385 */ 327 */
386 if (table_entry_size == sizeof(u32)) { 328 if (table_entry_size == ACPI_RSDT_ENTRY_SIZE) {
387 /* 329 /*
388 * 32-bit platform, RSDT: Return 32-bit table entry 330 * 32-bit platform, RSDT: Return 32-bit table entry
389 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return 331 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
@@ -415,6 +357,87 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
415 357
416/******************************************************************************* 358/*******************************************************************************
417 * 359 *
360 * FUNCTION: acpi_tb_validate_xsdt
361 *
362 * PARAMETERS: address - Physical address of the XSDT (from RSDP)
363 *
364 * RETURN: Status. AE_OK if the table appears to be valid.
365 *
366 * DESCRIPTION: Validate an XSDT to ensure that it is of minimum size and does
367 * not contain any NULL entries. A problem that is seen in the
368 * field is that the XSDT exists, but is actually useless because
369 * of one or more (or all) NULL entries.
370 *
371 ******************************************************************************/
372
373static acpi_status acpi_tb_validate_xsdt(acpi_physical_address xsdt_address)
374{
375 struct acpi_table_header *table;
376 u8 *next_entry;
377 acpi_physical_address address;
378 u32 length;
379 u32 entry_count;
380 acpi_status status;
381 u32 i;
382
383 /* Get the XSDT length */
384
385 table =
386 acpi_os_map_memory(xsdt_address, sizeof(struct acpi_table_header));
387 if (!table) {
388 return (AE_NO_MEMORY);
389 }
390
391 length = table->length;
392 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
393
394 /*
395 * Minimum XSDT length is the size of the standard ACPI header
396 * plus one physical address entry
397 */
398 if (length < (sizeof(struct acpi_table_header) + ACPI_XSDT_ENTRY_SIZE)) {
399 return (AE_INVALID_TABLE_LENGTH);
400 }
401
402 /* Map the entire XSDT */
403
404 table = acpi_os_map_memory(xsdt_address, length);
405 if (!table) {
406 return (AE_NO_MEMORY);
407 }
408
409 /* Get the number of entries and pointer to first entry */
410
411 status = AE_OK;
412 next_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
413 entry_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
414 ACPI_XSDT_ENTRY_SIZE);
415
416 /* Validate each entry (physical address) within the XSDT */
417
418 for (i = 0; i < entry_count; i++) {
419 address =
420 acpi_tb_get_root_table_entry(next_entry,
421 ACPI_XSDT_ENTRY_SIZE);
422 if (!address) {
423
424 /* Detected a NULL entry, XSDT is invalid */
425
426 status = AE_NULL_ENTRY;
427 break;
428 }
429
430 next_entry += ACPI_XSDT_ENTRY_SIZE;
431 }
432
433 /* Unmap table */
434
435 acpi_os_unmap_memory(table, length);
436 return (status);
437}
438
439/*******************************************************************************
440 *
418 * FUNCTION: acpi_tb_parse_root_table 441 * FUNCTION: acpi_tb_parse_root_table
419 * 442 *
420 * PARAMETERS: rsdp - Pointer to the RSDP 443 * PARAMETERS: rsdp - Pointer to the RSDP
@@ -438,16 +461,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
438 u32 table_count; 461 u32 table_count;
439 struct acpi_table_header *table; 462 struct acpi_table_header *table;
440 acpi_physical_address address; 463 acpi_physical_address address;
441 acpi_physical_address uninitialized_var(rsdt_address);
442 u32 length; 464 u32 length;
443 u8 *table_entry; 465 u8 *table_entry;
444 acpi_status status; 466 acpi_status status;
445 467
446 ACPI_FUNCTION_TRACE(tb_parse_root_table); 468 ACPI_FUNCTION_TRACE(tb_parse_root_table);
447 469
448 /* 470 /* Map the entire RSDP and extract the address of the RSDT or XSDT */
449 * Map the entire RSDP and extract the address of the RSDT or XSDT 471
450 */
451 rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); 472 rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
452 if (!rsdp) { 473 if (!rsdp) {
453 return_ACPI_STATUS(AE_NO_MEMORY); 474 return_ACPI_STATUS(AE_NO_MEMORY);
@@ -457,24 +478,22 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
457 ACPI_CAST_PTR(struct acpi_table_header, 478 ACPI_CAST_PTR(struct acpi_table_header,
458 rsdp)); 479 rsdp));
459 480
460 /* Differentiate between RSDT and XSDT root tables */ 481 /* Use XSDT if present and not overridden. Otherwise, use RSDT */
461 482
462 if (rsdp->revision > 1 && rsdp->xsdt_physical_address 483 if ((rsdp->revision > 1) &&
463 && !acpi_rsdt_forced) { 484 rsdp->xsdt_physical_address && !acpi_gbl_do_not_use_xsdt) {
464 /* 485 /*
465 * Root table is an XSDT (64-bit physical addresses). We must use the 486 * RSDP contains an XSDT (64-bit physical addresses). We must use
466 * XSDT if the revision is > 1 and the XSDT pointer is present, as per 487 * the XSDT if the revision is > 1 and the XSDT pointer is present,
467 * the ACPI specification. 488 * as per the ACPI specification.
468 */ 489 */
469 address = (acpi_physical_address) rsdp->xsdt_physical_address; 490 address = (acpi_physical_address) rsdp->xsdt_physical_address;
470 table_entry_size = sizeof(u64); 491 table_entry_size = ACPI_XSDT_ENTRY_SIZE;
471 rsdt_address = (acpi_physical_address)
472 rsdp->rsdt_physical_address;
473 } else { 492 } else {
474 /* Root table is an RSDT (32-bit physical addresses) */ 493 /* Root table is an RSDT (32-bit physical addresses) */
475 494
476 address = (acpi_physical_address) rsdp->rsdt_physical_address; 495 address = (acpi_physical_address) rsdp->rsdt_physical_address;
477 table_entry_size = sizeof(u32); 496 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
478 } 497 }
479 498
480 /* 499 /*
@@ -483,15 +502,25 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
483 */ 502 */
484 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); 503 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
485 504
486 if (table_entry_size == sizeof(u64)) { 505 /*
487 if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) { 506 * If it is present and used, validate the XSDT for access/size
488 /* XSDT has NULL entry, RSDT is used */ 507 * and ensure that all table entries are at least non-NULL
489 address = rsdt_address; 508 */
490 table_entry_size = sizeof(u32); 509 if (table_entry_size == ACPI_XSDT_ENTRY_SIZE) {
491 ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " 510 status = acpi_tb_validate_xsdt(address);
492 "using RSDT")); 511 if (ACPI_FAILURE(status)) {
512 ACPI_BIOS_WARNING((AE_INFO,
513 "XSDT is invalid (%s), using RSDT",
514 acpi_format_exception(status)));
515
516 /* Fall back to the RSDT */
517
518 address =
519 (acpi_physical_address) rsdp->rsdt_physical_address;
520 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
493 } 521 }
494 } 522 }
523
495 /* Map the RSDT/XSDT table header to get the full table length */ 524 /* Map the RSDT/XSDT table header to get the full table length */
496 525
497 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 526 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
@@ -501,12 +530,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
501 530
502 acpi_tb_print_table_header(address, table); 531 acpi_tb_print_table_header(address, table);
503 532
504 /* Get the length of the full table, verify length and map entire table */ 533 /*
505 534 * Validate length of the table, and map entire table.
535 * Minimum length table must contain at least one entry.
536 */
506 length = table->length; 537 length = table->length;
507 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); 538 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
508 539
509 if (length < sizeof(struct acpi_table_header)) { 540 if (length < (sizeof(struct acpi_table_header) + table_entry_size)) {
510 ACPI_BIOS_ERROR((AE_INFO, 541 ACPI_BIOS_ERROR((AE_INFO,
511 "Invalid table length 0x%X in RSDT/XSDT", 542 "Invalid table length 0x%X in RSDT/XSDT",
512 length)); 543 length));
@@ -526,22 +557,21 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
526 return_ACPI_STATUS(status); 557 return_ACPI_STATUS(status);
527 } 558 }
528 559
529 /* Calculate the number of tables described in the root table */ 560 /* Get the number of entries and pointer to first entry */
530 561
531 table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / 562 table_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
532 table_entry_size); 563 table_entry_size);
564 table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
565
533 /* 566 /*
534 * First two entries in the table array are reserved for the DSDT 567 * First two entries in the table array are reserved for the DSDT
535 * and FACS, which are not actually present in the RSDT/XSDT - they 568 * and FACS, which are not actually present in the RSDT/XSDT - they
536 * come from the FADT 569 * come from the FADT
537 */ 570 */
538 table_entry =
539 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
540 acpi_gbl_root_table_list.current_table_count = 2; 571 acpi_gbl_root_table_list.current_table_count = 2;
541 572
542 /* 573 /* Initialize the root table array from the RSDT/XSDT */
543 * Initialize the root table array from the RSDT/XSDT 574
544 */
545 for (i = 0; i < table_count; i++) { 575 for (i = 0; i < table_count; i++) {
546 if (acpi_gbl_root_table_list.current_table_count >= 576 if (acpi_gbl_root_table_list.current_table_count >=
547 acpi_gbl_root_table_list.max_table_count) { 577 acpi_gbl_root_table_list.max_table_count) {
@@ -584,7 +614,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
584 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. 614 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
585 address, NULL, i); 615 address, NULL, i);
586 616
587 /* Special case for FADT - get the DSDT and FACS */ 617 /* Special case for FADT - validate it then get the DSDT and FACS */
588 618
589 if (ACPI_COMPARE_NAME 619 if (ACPI_COMPARE_NAME
590 (&acpi_gbl_root_table_list.tables[i].signature, 620 (&acpi_gbl_root_table_list.tables[i].signature,
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
index e0a2e2779c2e..2c2b6ae5dfc4 100644
--- a/drivers/acpi/acpica/utaddress.c
+++ b/drivers/acpi/acpica/utaddress.c
@@ -224,10 +224,11 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
224 224
225 while (range_info) { 225 while (range_info) {
226 /* 226 /*
227 * Check if the requested Address/Length overlaps this address_range. 227 * Check if the requested address/length overlaps this
228 * Four cases to consider: 228 * address range. There are four cases to consider:
229 * 229 *
230 * 1) Input address/length is contained completely in the address range 230 * 1) Input address/length is contained completely in the
231 * address range
231 * 2) Input address/length overlaps range at the range start 232 * 2) Input address/length overlaps range at the range start
232 * 3) Input address/length overlaps range at the range end 233 * 3) Input address/length overlaps range at the range end
233 * 4) Input address/length completely encompasses the range 234 * 4) Input address/length completely encompasses the range
@@ -244,11 +245,17 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
244 region_node); 245 region_node);
245 246
246 ACPI_WARNING((AE_INFO, 247 ACPI_WARNING((AE_INFO,
247 "0x%p-0x%p %s conflicts with Region %s %d", 248 "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)",
249 acpi_ut_get_region_name(space_id),
248 ACPI_CAST_PTR(void, address), 250 ACPI_CAST_PTR(void, address),
249 ACPI_CAST_PTR(void, end_address), 251 ACPI_CAST_PTR(void, end_address),
250 acpi_ut_get_region_name(space_id), 252 ACPI_CAST_PTR(void,
251 pathname, overlap_count)); 253 range_info->
254 start_address),
255 ACPI_CAST_PTR(void,
256 range_info->
257 end_address),
258 pathname));
252 ACPI_FREE(pathname); 259 ACPI_FREE(pathname);
253 } 260 }
254 } 261 }
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 814267f52715..1851762fc5b5 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -302,9 +302,13 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
302 return (AE_BUFFER_OVERFLOW); 302 return (AE_BUFFER_OVERFLOW);
303 303
304 case ACPI_ALLOCATE_BUFFER: 304 case ACPI_ALLOCATE_BUFFER:
305 305 /*
306 /* Allocate a new buffer */ 306 * Allocate a new buffer. We directectly call acpi_os_allocate here to
307 307 * purposefully bypass the (optionally enabled) internal allocation
308 * tracking mechanism since we only want to track internal
309 * allocations. Note: The caller should use acpi_os_free to free this
310 * buffer created via ACPI_ALLOCATE_BUFFER.
311 */
308 buffer->pointer = acpi_os_allocate(required_length); 312 buffer->pointer = acpi_os_allocate(required_length);
309 break; 313 break;
310 314
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c
index 366bfec4b770..cacd2fd9e665 100644
--- a/drivers/acpi/acpica/utcache.c
+++ b/drivers/acpi/acpica/utcache.c
@@ -248,12 +248,12 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
248 ACPI_FUNCTION_NAME(os_acquire_object); 248 ACPI_FUNCTION_NAME(os_acquire_object);
249 249
250 if (!cache) { 250 if (!cache) {
251 return (NULL); 251 return_PTR(NULL);
252 } 252 }
253 253
254 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); 254 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
255 if (ACPI_FAILURE(status)) { 255 if (ACPI_FAILURE(status)) {
256 return (NULL); 256 return_PTR(NULL);
257 } 257 }
258 258
259 ACPI_MEM_TRACKING(cache->requests++); 259 ACPI_MEM_TRACKING(cache->requests++);
@@ -276,7 +276,7 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
276 276
277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES); 277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
278 if (ACPI_FAILURE(status)) { 278 if (ACPI_FAILURE(status)) {
279 return (NULL); 279 return_PTR(NULL);
280 } 280 }
281 281
282 /* Clear (zero) the previously used Object */ 282 /* Clear (zero) the previously used Object */
@@ -299,15 +299,15 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
299 299
300 status = acpi_ut_release_mutex(ACPI_MTX_CACHES); 300 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
301 if (ACPI_FAILURE(status)) { 301 if (ACPI_FAILURE(status)) {
302 return (NULL); 302 return_PTR(NULL);
303 } 303 }
304 304
305 object = ACPI_ALLOCATE_ZEROED(cache->object_size); 305 object = ACPI_ALLOCATE_ZEROED(cache->object_size);
306 if (!object) { 306 if (!object) {
307 return (NULL); 307 return_PTR(NULL);
308 } 308 }
309 } 309 }
310 310
311 return (object); 311 return_PTR(object);
312} 312}
313#endif /* ACPI_USE_LOCAL_CACHE */ 313#endif /* ACPI_USE_LOCAL_CACHE */
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 03ae8affe48f..d971c8631263 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -194,9 +194,9 @@ acpi_debug_print(u32 requested_debug_level,
194 */ 194 */
195 acpi_os_printf("%9s-%04ld ", module_name, line_number); 195 acpi_os_printf("%9s-%04ld ", module_name, line_number);
196 196
197#ifdef ACPI_EXEC_APP 197#ifdef ACPI_APPLICATION
198 /* 198 /*
199 * For acpi_exec only, emit the thread ID and nesting level. 199 * For acpi_exec/iASL only, emit the thread ID and nesting level.
200 * Note: nesting level is really only useful during a single-thread 200 * Note: nesting level is really only useful during a single-thread
201 * execution. Otherwise, multiple threads will keep resetting the 201 * execution. Otherwise, multiple threads will keep resetting the
202 * level. 202 * level.
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 81f9a9584451..030cb0dc673c 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -388,11 +388,7 @@ acpi_status acpi_ut_init_globals(void)
388/* Public globals */ 388/* Public globals */
389 389
390ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) 390ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
391
392ACPI_EXPORT_SYMBOL(acpi_dbg_level) 391ACPI_EXPORT_SYMBOL(acpi_dbg_level)
393
394ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 392ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
395
396ACPI_EXPORT_SYMBOL(acpi_gpe_count) 393ACPI_EXPORT_SYMBOL(acpi_gpe_count)
397
398ACPI_EXPORT_SYMBOL(acpi_current_gpe_count) 394ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 75efea0539c1..246ef68681f4 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -122,8 +122,16 @@ acpi_status __init acpi_initialize_subsystem(void)
122 122
123 /* If configured, initialize the AML debugger */ 123 /* If configured, initialize the AML debugger */
124 124
125 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); 125#ifdef ACPI_DEBUGGER
126 return_ACPI_STATUS(status); 126 status = acpi_db_initialize();
127 if (ACPI_FAILURE(status)) {
128 ACPI_EXCEPTION((AE_INFO, status,
129 "During Debugger initialization"));
130 return_ACPI_STATUS(status);
131 }
132#endif
133
134 return_ACPI_STATUS(AE_OK);
127} 135}
128 136
129ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem) 137ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)