aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2009-02-07 18:39:41 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-09 07:35:07 -0500
commit7d97277b754d3ee098a5ec69b6aaafb00c94e2f2 (patch)
tree457ff6256a2da2f39f93500453a6a643ab29ef2b /drivers/acpi
parent05876f88ed9a66b26af613e222795ae790616252 (diff)
acpi/x86: introduce __apci_map_table, v4
to prevent wrongly overwriting fixmap that still want to use. ACPI used to rely on low mappings being all linearly mapped and grew a habit: it never really unmapped certain kinds of tables after use. This can cause problems - for example the hypothetical case when some spurious access still references it. v2: remove prev_map and prev_size in __apci_map_table v3: let acpi_os_unmap_memory() call early_iounmap too, so remove extral calling to early_acpi_os_unmap_memory v4: fix typo in one acpi_get_table_with_size calling Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Acked-by: Len Brown <len.brown@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/tbxface.c17
-rw-r--r--drivers/acpi/bus.c6
-rw-r--r--drivers/acpi/osl.c11
-rw-r--r--drivers/acpi/tables.c20
4 files changed, 37 insertions, 17 deletions
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index c3e841f3cde9..ab0aff3c7d6a 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -365,7 +365,7 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
365 365
366/******************************************************************************* 366/*******************************************************************************
367 * 367 *
368 * FUNCTION: acpi_get_table 368 * FUNCTION: acpi_get_table_with_size
369 * 369 *
370 * PARAMETERS: Signature - ACPI signature of needed table 370 * PARAMETERS: Signature - ACPI signature of needed table
371 * Instance - Which instance (for SSDTs) 371 * Instance - Which instance (for SSDTs)
@@ -377,8 +377,9 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
377 * 377 *
378 *****************************************************************************/ 378 *****************************************************************************/
379acpi_status 379acpi_status
380acpi_get_table(char *signature, 380acpi_get_table_with_size(char *signature,
381 u32 instance, struct acpi_table_header **out_table) 381 u32 instance, struct acpi_table_header **out_table,
382 acpi_size *tbl_size)
382{ 383{
383 u32 i; 384 u32 i;
384 u32 j; 385 u32 j;
@@ -408,6 +409,7 @@ acpi_get_table(char *signature,
408 acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]); 409 acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
409 if (ACPI_SUCCESS(status)) { 410 if (ACPI_SUCCESS(status)) {
410 *out_table = acpi_gbl_root_table_list.tables[i].pointer; 411 *out_table = acpi_gbl_root_table_list.tables[i].pointer;
412 *tbl_size = acpi_gbl_root_table_list.tables[i].length;
411 } 413 }
412 414
413 if (!acpi_gbl_permanent_mmap) { 415 if (!acpi_gbl_permanent_mmap) {
@@ -420,6 +422,15 @@ acpi_get_table(char *signature,
420 return (AE_NOT_FOUND); 422 return (AE_NOT_FOUND);
421} 423}
422 424
425acpi_status
426acpi_get_table(char *signature,
427 u32 instance, struct acpi_table_header **out_table)
428{
429 acpi_size tbl_size;
430
431 return acpi_get_table_with_size(signature,
432 instance, out_table, &tbl_size);
433}
423ACPI_EXPORT_SYMBOL(acpi_get_table) 434ACPI_EXPORT_SYMBOL(acpi_get_table)
424 435
425/******************************************************************************* 436/*******************************************************************************
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index fb1be7b5dbc1..765fd1c56cd6 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -694,12 +694,6 @@ void __init acpi_early_init(void)
694 if (!acpi_strict) 694 if (!acpi_strict)
695 acpi_gbl_enable_interpreter_slack = TRUE; 695 acpi_gbl_enable_interpreter_slack = TRUE;
696 696
697 /*
698 * Doing a zero-sized mapping will clear out the previous
699 * __acpi_map_table() mapping, if any.
700 */
701 __acpi_map_table(0, 0);
702
703 acpi_gbl_permanent_mmap = 1; 697 acpi_gbl_permanent_mmap = 1;
704 698
705 status = acpi_reallocate_root_table(); 699 status = acpi_reallocate_root_table();
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b3193ec0a2ef..d1dd5160daa9 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -274,12 +274,19 @@ EXPORT_SYMBOL_GPL(acpi_os_map_memory);
274 274
275void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) 275void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
276{ 276{
277 if (acpi_gbl_permanent_mmap) { 277 if (acpi_gbl_permanent_mmap)
278 iounmap(virt); 278 iounmap(virt);
279 } 279 else
280 __acpi_unmap_table(virt, size);
280} 281}
281EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); 282EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
282 283
284void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
285{
286 if (!acpi_gbl_permanent_mmap)
287 __acpi_unmap_table(virt, size);
288}
289
283#ifdef ACPI_FUTURE_USAGE 290#ifdef ACPI_FUTURE_USAGE
284acpi_status 291acpi_status
285acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) 292acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index a8852952fac4..fec1ae36d431 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -181,14 +181,15 @@ acpi_table_parse_entries(char *id,
181 struct acpi_subtable_header *entry; 181 struct acpi_subtable_header *entry;
182 unsigned int count = 0; 182 unsigned int count = 0;
183 unsigned long table_end; 183 unsigned long table_end;
184 acpi_size tbl_size;
184 185
185 if (!handler) 186 if (!handler)
186 return -EINVAL; 187 return -EINVAL;
187 188
188 if (strncmp(id, ACPI_SIG_MADT, 4) == 0) 189 if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
189 acpi_get_table(id, acpi_apic_instance, &table_header); 190 acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size);
190 else 191 else
191 acpi_get_table(id, 0, &table_header); 192 acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
192 193
193 if (!table_header) { 194 if (!table_header) {
194 printk(KERN_WARNING PREFIX "%4.4s not present\n", id); 195 printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
@@ -206,8 +207,10 @@ acpi_table_parse_entries(char *id,
206 table_end) { 207 table_end) {
207 if (entry->type == entry_id 208 if (entry->type == entry_id
208 && (!max_entries || count++ < max_entries)) 209 && (!max_entries || count++ < max_entries))
209 if (handler(entry, table_end)) 210 if (handler(entry, table_end)) {
211 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
210 return -EINVAL; 212 return -EINVAL;
213 }
211 214
212 entry = (struct acpi_subtable_header *) 215 entry = (struct acpi_subtable_header *)
213 ((unsigned long)entry + entry->length); 216 ((unsigned long)entry + entry->length);
@@ -217,6 +220,7 @@ acpi_table_parse_entries(char *id,
217 "%i found\n", id, entry_id, count - max_entries, count); 220 "%i found\n", id, entry_id, count - max_entries, count);
218 } 221 }
219 222
223 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
220 return count; 224 return count;
221} 225}
222 226
@@ -241,17 +245,19 @@ acpi_table_parse_madt(enum acpi_madt_type id,
241int __init acpi_table_parse(char *id, acpi_table_handler handler) 245int __init acpi_table_parse(char *id, acpi_table_handler handler)
242{ 246{
243 struct acpi_table_header *table = NULL; 247 struct acpi_table_header *table = NULL;
248 acpi_size tbl_size;
244 249
245 if (!handler) 250 if (!handler)
246 return -EINVAL; 251 return -EINVAL;
247 252
248 if (strncmp(id, ACPI_SIG_MADT, 4) == 0) 253 if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
249 acpi_get_table(id, acpi_apic_instance, &table); 254 acpi_get_table_with_size(id, acpi_apic_instance, &table, &tbl_size);
250 else 255 else
251 acpi_get_table(id, 0, &table); 256 acpi_get_table_with_size(id, 0, &table, &tbl_size);
252 257
253 if (table) { 258 if (table) {
254 handler(table); 259 handler(table);
260 early_acpi_os_unmap_memory(table, tbl_size);
255 return 0; 261 return 0;
256 } else 262 } else
257 return 1; 263 return 1;
@@ -265,8 +271,9 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler)
265static void __init check_multiple_madt(void) 271static void __init check_multiple_madt(void)
266{ 272{
267 struct acpi_table_header *table = NULL; 273 struct acpi_table_header *table = NULL;
274 acpi_size tbl_size;
268 275
269 acpi_get_table(ACPI_SIG_MADT, 2, &table); 276 acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size);
270 if (table) { 277 if (table) {
271 printk(KERN_WARNING PREFIX 278 printk(KERN_WARNING PREFIX
272 "BIOS bug: multiple APIC/MADT found," 279 "BIOS bug: multiple APIC/MADT found,"
@@ -275,6 +282,7 @@ static void __init check_multiple_madt(void)
275 "If \"acpi_apic_instance=%d\" works better, " 282 "If \"acpi_apic_instance=%d\" works better, "
276 "notify linux-acpi@vger.kernel.org\n", 283 "notify linux-acpi@vger.kernel.org\n",
277 acpi_apic_instance ? 0 : 2); 284 acpi_apic_instance ? 0 : 2);
285 early_acpi_os_unmap_memory(table, tbl_size);
278 286
279 } else 287 } else
280 acpi_apic_instance = 0; 288 acpi_apic_instance = 0;