diff options
Diffstat (limited to 'drivers/acpi/tables.c')
| -rw-r--r-- | drivers/acpi/tables.c | 165 | 
1 files changed, 86 insertions, 79 deletions
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index d67a1fe07f0..6d5a6cda073 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -23,6 +23,8 @@   *   */ +#define pr_fmt(fmt) "ACPI: " fmt +  #include <linux/init.h>  #include <linux/kernel.h>  #include <linux/smp.h> @@ -33,8 +35,6 @@  #include <linux/acpi.h>  #include <linux/bootmem.h> -#define PREFIX			"ACPI: " -  #define ACPI_MAX_TABLES		128  static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; @@ -44,6 +44,12 @@ static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;  static int acpi_apic_instance __initdata; +/* + * Disable table checksum verification for the early stage due to the size + * limitation of the current x86 early mapping implementation. + */ +static bool acpi_verify_table_checksum __initdata = false; +  void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  {  	if (!header) @@ -55,10 +61,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_local_apic *p =  			    (struct acpi_madt_local_apic *)header; -			printk(KERN_INFO PREFIX -			       "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", -			       p->processor_id, p->id, -			       (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); +			pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", +				p->processor_id, p->id, +				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");  		}  		break; @@ -66,11 +71,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_local_x2apic *p =  			    (struct acpi_madt_local_x2apic *)header; -			printk(KERN_INFO PREFIX -			       "X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", -			       p->local_apic_id, p->uid, -			       (p->lapic_flags & ACPI_MADT_ENABLED) ? -			       "enabled" : "disabled"); +			pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", +				p->local_apic_id, p->uid, +				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");  		}  		break; @@ -78,9 +81,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_io_apic *p =  			    (struct acpi_madt_io_apic *)header; -			printk(KERN_INFO PREFIX -			       "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", -			       p->id, p->address, p->global_irq_base); +			pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", +				p->id, p->address, p->global_irq_base);  		}  		break; @@ -88,18 +90,15 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_interrupt_override *p =  			    (struct acpi_madt_interrupt_override *)header; -			printk(KERN_INFO PREFIX -			       "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n", -			       p->bus, p->source_irq, p->global_irq, -			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], -			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2]); +			pr_info("INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n", +				p->bus, p->source_irq, p->global_irq, +				mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], +				mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2]);  			if (p->inti_flags  &  			    ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK)) -				printk(KERN_INFO PREFIX -				       "INT_SRC_OVR unexpected reserved flags: 0x%x\n", -				       p->inti_flags  & +				pr_info("INT_SRC_OVR unexpected reserved flags: 0x%x\n", +					p->inti_flags  &  					~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK)); -  		}  		break; @@ -107,11 +106,10 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_nmi_source *p =  			    (struct acpi_madt_nmi_source *)header; -			printk(KERN_INFO PREFIX -			       "NMI_SRC (%s %s global_irq %d)\n", -			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], -			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], -			       p->global_irq); +			pr_info("NMI_SRC (%s %s global_irq %d)\n", +				mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], +				mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], +				p->global_irq);  		}  		break; @@ -119,12 +117,11 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_local_apic_nmi *p =  			    (struct acpi_madt_local_apic_nmi *)header; -			printk(KERN_INFO PREFIX -			       "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n", -			       p->processor_id, -			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK	], -			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], -			       p->lint); +			pr_info("LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n", +				p->processor_id, +				mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK	], +				mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], +				p->lint);  		}  		break; @@ -137,12 +134,11 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  			polarity = p->inti_flags & ACPI_MADT_POLARITY_MASK;  			trigger = (p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2; -			printk(KERN_INFO PREFIX -			       "X2APIC_NMI (uid[0x%02x] %s %s lint[0x%x])\n", -			       p->uid, -			       mps_inti_flags_polarity[polarity], -			       mps_inti_flags_trigger[trigger], -			       p->lint); +			pr_info("X2APIC_NMI (uid[0x%02x] %s %s lint[0x%x])\n", +				p->uid, +				mps_inti_flags_polarity[polarity], +				mps_inti_flags_trigger[trigger], +				p->lint);  		}  		break; @@ -150,9 +146,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_local_apic_override *p =  			    (struct acpi_madt_local_apic_override *)header; -			printk(KERN_INFO PREFIX -			       "LAPIC_ADDR_OVR (address[%p])\n", -			       (void *)(unsigned long)p->address); +			pr_info("LAPIC_ADDR_OVR (address[%p])\n", +				(void *)(unsigned long)p->address);  		}  		break; @@ -160,10 +155,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_io_sapic *p =  			    (struct acpi_madt_io_sapic *)header; -			printk(KERN_INFO PREFIX -			       "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", -			       p->id, (void *)(unsigned long)p->address, -			       p->global_irq_base); +			pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", +				p->id, (void *)(unsigned long)p->address, +				p->global_irq_base);  		}  		break; @@ -171,10 +165,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_local_sapic *p =  			    (struct acpi_madt_local_sapic *)header; -			printk(KERN_INFO PREFIX -			       "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", -			       p->processor_id, p->id, p->eid, -			       (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); +			pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", +				p->processor_id, p->id, p->eid, +				(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");  		}  		break; @@ -182,19 +175,17 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)  		{  			struct acpi_madt_interrupt_source *p =  			    (struct acpi_madt_interrupt_source *)header; -			printk(KERN_INFO PREFIX -			       "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n", -			       mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], -			       mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], -			       p->type, p->id, p->eid, p->io_sapic_vector, -			       p->global_irq); +			pr_info("PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n", +				mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], +				mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], +				p->type, p->id, p->eid, p->io_sapic_vector, +				p->global_irq);  		}  		break;  	default: -		printk(KERN_WARNING PREFIX -		       "Found unsupported MADT entry (type = 0x%x)\n", -		       header->type); +		pr_warn("Found unsupported MADT entry (type = 0x%x)\n", +			header->type);  		break;  	}  } @@ -225,7 +216,7 @@ acpi_table_parse_entries(char *id,  		acpi_get_table_with_size(id, 0, &table_header, &tbl_size);  	if (!table_header) { -		printk(KERN_WARNING PREFIX "%4.4s not present\n", id); +		pr_warn("%4.4s not present\n", id);  		return -ENODEV;  	} @@ -248,7 +239,7 @@ acpi_table_parse_entries(char *id,  		 * infinite loop.  		 */  		if (entry->length == 0) { -			pr_err(PREFIX "[%4.4s:0x%02x] Invalid zero length\n", id, entry_id); +			pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);  			goto err;  		} @@ -256,8 +247,8 @@ acpi_table_parse_entries(char *id,  		    ((unsigned long)entry + entry->length);  	}  	if (max_entries && count > max_entries) { -		printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of " -		       "%i found\n", id, entry_id, count - max_entries, count); +		pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n", +			id, entry_id, count - max_entries, count);  	}  	early_acpi_os_unmap_memory((char *)table_header, tbl_size); @@ -278,12 +269,13 @@ acpi_table_parse_madt(enum acpi_madt_type id,  /**   * acpi_table_parse - find table with @id, run @handler on it - *   * @id: table id to find   * @handler: handler to run   *   * Scan the ACPI System Descriptor Table (STD) for a table matching @id, - * run @handler on it.  Return 0 if table found, return on if not. + * run @handler on it. + * + * Return 0 if table found, -errno if not.   */  int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)  { @@ -293,7 +285,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)  	if (acpi_disabled)  		return -ENODEV; -	if (!handler) +	if (!id || !handler)  		return -EINVAL;  	if (strncmp(id, ACPI_SIG_MADT, 4) == 0) @@ -306,7 +298,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)  		early_acpi_os_unmap_memory(table, tbl_size);  		return 0;  	} else -		return 1; +		return -ENODEV;  }  /*  @@ -321,13 +313,11 @@ static void __init check_multiple_madt(void)  	acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size);  	if (table) { -		printk(KERN_WARNING PREFIX -		       "BIOS bug: multiple APIC/MADT found," -		       " using %d\n", acpi_apic_instance); -		printk(KERN_WARNING PREFIX -		       "If \"acpi_apic_instance=%d\" works better, " -		       "notify linux-acpi@vger.kernel.org\n", -		       acpi_apic_instance ? 0 : 2); +		pr_warn("BIOS bug: multiple APIC/MADT found, using %d\n", +			acpi_apic_instance); +		pr_warn("If \"acpi_apic_instance=%d\" works better, " +			"notify linux-acpi@vger.kernel.org\n", +			acpi_apic_instance ? 0 : 2);  		early_acpi_os_unmap_memory(table, tbl_size);  	} else @@ -349,9 +339,17 @@ int __init acpi_table_init(void)  {  	acpi_status status; +	if (acpi_verify_table_checksum) { +		pr_info("Early table checksum verification enabled\n"); +		acpi_gbl_verify_table_checksum = TRUE; +	} else { +		pr_info("Early table checksum verification disabled\n"); +		acpi_gbl_verify_table_checksum = FALSE; +	} +  	status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);  	if (ACPI_FAILURE(status)) -		return 1; +		return -EINVAL;  	check_multiple_madt();  	return 0; @@ -362,12 +360,21 @@ static int __init acpi_parse_apic_instance(char *str)  	if (!str)  		return -EINVAL; -	acpi_apic_instance = simple_strtoul(str, NULL, 0); +	if (kstrtoint(str, 0, &acpi_apic_instance)) +		return -EINVAL; -	printk(KERN_NOTICE PREFIX "Shall use APIC/MADT table %d\n", -	       acpi_apic_instance); +	pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance);  	return 0;  }  early_param("acpi_apic_instance", acpi_parse_apic_instance); + +static int __init acpi_force_table_verification_setup(char *s) +{ +	acpi_verify_table_checksum = true; + +	return 0; +} + +early_param("acpi_force_table_verification", acpi_force_table_verification_setup);  | 
