linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification.
@ 2014-05-30  2:07 Lv Zheng
  2014-05-30  2:07 ` [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Lv Zheng @ 2014-05-30  2:07 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: Lv Zheng, Lv Zheng, linux-acpi, lkp, x86

The following regression is reported when the table length is very large:
 WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:136 __early_ioremap+0x11f/0x1f2()
 Modules linked in:
 CPU: 0 PID: 0 Comm: swapper Not tainted 3.15.0-rc1-00017-g86dfc6f3-dirty #298
 Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.99.99.x036.091920111209 09/19/2011
  0000000000000009 ffffffff81b75c40 ffffffff817c627b 0000000000000000
  ffffffff81b75c78 ffffffff81067b5d 000000000000007b 8000000000000563
  00000000b96b20dc 0000000000000001 ffffffffff300e0c ffffffff81b75c88
 Call Trace:
  [<ffffffff817c627b>] dump_stack+0x45/0x56
  [<ffffffff81067b5d>] warn_slowpath_common+0x7d/0xa0
  [<ffffffff81067c3a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff81d4b9d5>] __early_ioremap+0x11f/0x1f2
  [<ffffffff81d4bc5b>] early_ioremap+0x13/0x15
  [<ffffffff81d2b8f3>] __acpi_map_table+0x13/0x18
  [<ffffffff817b8d1a>] acpi_os_map_memory+0x26/0x14e
  [<ffffffff813ff018>] acpi_tb_acquire_table+0x42/0x70
  [<ffffffff813ff086>] acpi_tb_validate_table+0x27/0x37
  [<ffffffff813ff0e5>] acpi_tb_verify_table+0x22/0xd8
  [<ffffffff813ff6a8>] acpi_tb_install_non_fixed_table+0x60/0x1c9
  [<ffffffff81d61024>] acpi_tb_parse_root_table+0x218/0x26a
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d610cd>] acpi_initialize_tables+0x57/0x59
  [<ffffffff81d5f25d>] acpi_table_init+0x1b/0x99
  [<ffffffff81d2bca0>] acpi_boot_table_init+0x1e/0x85
  [<ffffffff81d23043>] setup_arch+0x99d/0xcc6
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d1bbbe>] start_kernel+0x8b/0x415
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d1b5ee>] x86_64_start_reservations+0x2a/0x2c
  [<ffffffff81d1b72e>] x86_64_start_kernel+0x13e/0x14d
 ---[ end trace 11ae599a1898f4e7 ]---
This is due to the size limitation of the x86 early IO mapping.
There is a large SSDT table on such platform that exceeds this limitation:
 ACPI: SSDT 0x00000000B9638018 07A0C4 (v02 INTEL  S2600CP  00004000 INTL 20100331)

It sounds strange that in the 64-bit virtual memory address space, we
cannot map a single ACPI table to do checksum verification. The root cause
is:
1. ACPICA doesn't split IO memory mapping and table mapping;
2. Linux x86 OSL implements acpi_os_map_memory() using a size limited fix-map
   mechanism during early boot stage, which is more suitable for only IO
   mappings.

ACPICA originally only mapped table header for signature validation, and
this header mapping is required by OSL override mechanism. There was no
checksum verification because we could not map the whole table using this
OSL. While the following ACPICA commit enforces checksum verification by
mapping the whole table during Linux boot stage and it finally triggers
this issue on some platforms:
  Commit: 86dfc6f339886559d80ee0d4bd20fe5ee90450f0
  Subject: ACPICA: Tables: Fix table checksums verification before installation.

Before doing further cleanups for the OSL table mapping and override
implementation, this patch introduces an option for such OSPMs to
temporarily discard the checksum verification feature. It then can be
re-enabled easily when the ACPICA and the underlying OSL is ready.

This patch also deletes a comment around the limitation of mappings because
it is not correct. The limitation is not how many times we can map in the
early stage, but the OSL mapping facility may not be suitable for mapping
the ACPI tables and thus may complain us the size limitation.

The acpi_tb_verify_table() is renamed to acpi_tb_verify_temp_table() due to the
work around added, it now only applies to the table descriptor that hasn't
been installed and cannot be used in other cases. Lv Zheng.

[zetalog: on top of linux-pm.git/linux-next]
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: <lkp@vger.linux-kernel.cn>
Cc: <x86@kernel.org>
---
 drivers/acpi/acpica/actables.h |    8 +++--
 drivers/acpi/acpica/tbdata.c   |   67 +++++++++++++++++++++++++++++++---------
 drivers/acpi/acpica/tbinstal.c |    8 ++---
 drivers/acpi/acpica/tbutils.c  |    4 ---
 include/acpi/acpixf.h          |    8 +++++
 5 files changed, 69 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index bda9a7e..f148827 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -69,6 +69,11 @@ acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
 
 void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc);
 
+acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc);
+
+acpi_status
+acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature);
+
 u8 acpi_tb_is_table_loaded(u32 table_index);
 
 void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
@@ -96,9 +101,6 @@ acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc);
 
 void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc);
 
-acpi_status
-acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature);
-
 void acpi_tb_override_table(struct acpi_table_desc *old_table_desc);
 
 acpi_status
diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c
index cbe2994..f499c10 100644
--- a/drivers/acpi/acpica/tbdata.c
+++ b/drivers/acpi/acpica/tbdata.c
@@ -322,7 +322,39 @@ void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
 
 /******************************************************************************
  *
- * FUNCTION:    acpi_tb_verify_table
+ * FUNCTION:    acpi_tb_validate_temp_table
+ *
+ * PARAMETERS:  table_desc          - Table descriptor
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function is called to validate the table, the returned
+ *              table descriptor is in "VALIDATED" state.
+ *
+ *****************************************************************************/
+
+acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
+{
+
+	if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) {
+		/*
+		 * Only validates the header of the table.
+		 * Note that Length contains the size of the mapping after invoking
+		 * this work around, this value is required by
+		 * acpi_tb_release_temp_table().
+		 * We can do this because in acpi_init_table_descriptor(), the Length
+		 * field of the installed descriptor is filled with the actual
+		 * table length obtaining from the table header.
+		 */
+		table_desc->length = sizeof(struct acpi_table_header);
+	}
+
+	return (acpi_tb_validate_table(table_desc));
+}
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_verify_temp_table
  *
  * PARAMETERS:  table_desc          - Table descriptor
  *              signature           - Table signature to verify
@@ -335,15 +367,15 @@ void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
  *****************************************************************************/
 
 acpi_status
-acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature)
+acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature)
 {
 	acpi_status status = AE_OK;
 
-	ACPI_FUNCTION_TRACE(tb_verify_table);
+	ACPI_FUNCTION_TRACE(tb_verify_temp_table);
 
 	/* Validate the table */
 
-	status = acpi_tb_validate_table(table_desc);
+	status = acpi_tb_validate_temp_table(table_desc);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(AE_NO_MEMORY);
 	}
@@ -360,17 +392,22 @@ acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature)
 
 	/* Verify the checksum */
 
-	status =
-	    acpi_tb_verify_checksum(table_desc->pointer, table_desc->length);
-	if (ACPI_FAILURE(status)) {
-		ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
-				"%4.4s " ACPI_PRINTF_UINT
-				" Attempted table install failed",
-				acpi_ut_valid_acpi_name(table_desc->signature.
-							ascii) ? table_desc->
-				signature.ascii : "????",
-				ACPI_FORMAT_TO_UINT(table_desc->address)));
-		goto invalidate_and_exit;
+	if (acpi_gbl_verify_table_checksum) {
+		status =
+		    acpi_tb_verify_checksum(table_desc->pointer,
+					    table_desc->length);
+		if (ACPI_FAILURE(status)) {
+			ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
+					"%4.4s " ACPI_PRINTF_UINT
+					" Attempted table install failed",
+					acpi_ut_valid_acpi_name(table_desc->
+								signature.
+								ascii) ?
+					table_desc->signature.ascii : "????",
+					ACPI_FORMAT_TO_UINT(table_desc->
+							    address)));
+			goto invalidate_and_exit;
+		}
 	}
 
 	return_ACPI_STATUS(AE_OK);
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index d4d6029..755b90c 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -194,7 +194,7 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
 
 	/* Validate and verify a table before installation */
 
-	status = acpi_tb_verify_table(&new_table_desc, signature);
+	status = acpi_tb_verify_temp_table(&new_table_desc, signature);
 	if (ACPI_FAILURE(status)) {
 		goto release_and_exit;
 	}
@@ -266,7 +266,7 @@ acpi_tb_install_standard_table(acpi_physical_address address,
 
 	/* Validate and verify a table before installation */
 
-	status = acpi_tb_verify_table(&new_table_desc, NULL);
+	status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
 	if (ACPI_FAILURE(status)) {
 		goto release_and_exit;
 	}
@@ -424,7 +424,7 @@ finish_override:
 
 	/* Validate and verify a table before overriding */
 
-	status = acpi_tb_verify_table(&new_table_desc, NULL);
+	status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
 	if (ACPI_FAILURE(status)) {
 		return;
 	}
@@ -446,7 +446,7 @@ finish_override:
 	acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
 				      new_table_desc.flags,
 				      new_table_desc.pointer);
-	acpi_tb_validate_table(old_table_desc);
+	acpi_tb_validate_temp_table(old_table_desc);
 
 	/* Release the temporary table descriptor */
 
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index e37a103..6b1ca99 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -395,10 +395,6 @@ next_table:
 		table_entry += table_entry_size;
 	}
 
-	/*
-	 * It is not possible to map more than one entry in some environments,
-	 * so unmap the root table here before mapping other tables
-	 */
 	acpi_os_unmap_memory(table, length);
 
 	return_ACPI_STATUS(AE_OK);
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index b5f7132..380828d 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -162,6 +162,14 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_create_osi_method, TRUE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_use_default_register_widths, TRUE);
 
 /*
+ * Optionally verify the table checksum before installation. Set this to
+ * TRUE to verify the table checksum before install it to the table
+ * manager. Note that some OSPMs cannot do large mappings during the
+ * certain stages. Default is behavior is to do such verification.
+ */
+ACPI_INIT_GLOBAL(u8, acpi_gbl_verify_table_checksum, TRUE);
+
+/*
  * Optionally enable output from the AML Debug Object.
  */
 ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_aml_debug_object, FALSE);
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation.
  2014-05-30  2:07 [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Lv Zheng
@ 2014-05-30  2:07 ` Lv Zheng
  2014-05-30 22:33   ` Rafael J. Wysocki
  2014-05-30 22:29 ` [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Rafael J. Wysocki
  2014-05-31  0:14 ` [PATCH v2 0/2] ACPI: Fix a regression of the " Lv Zheng
  2 siblings, 1 reply; 10+ messages in thread
From: Lv Zheng @ 2014-05-30  2:07 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: Lv Zheng, Lv Zheng, linux-acpi, lkp, x86

The following regression is reported when the table length is very large:
 WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:136 __early_ioremap+0x11f/0x1f2()
 Modules linked in:
 CPU: 0 PID: 0 Comm: swapper Not tainted 3.15.0-rc1-00017-g86dfc6f3-dirty #298
 Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.99.99.x036.091920111209 09/19/2011
  0000000000000009 ffffffff81b75c40 ffffffff817c627b 0000000000000000
  ffffffff81b75c78 ffffffff81067b5d 000000000000007b 8000000000000563
  00000000b96b20dc 0000000000000001 ffffffffff300e0c ffffffff81b75c88
 Call Trace:
  [<ffffffff817c627b>] dump_stack+0x45/0x56
  [<ffffffff81067b5d>] warn_slowpath_common+0x7d/0xa0
  [<ffffffff81067c3a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff81d4b9d5>] __early_ioremap+0x11f/0x1f2
  [<ffffffff81d4bc5b>] early_ioremap+0x13/0x15
  [<ffffffff81d2b8f3>] __acpi_map_table+0x13/0x18
  [<ffffffff817b8d1a>] acpi_os_map_memory+0x26/0x14e
  [<ffffffff813ff018>] acpi_tb_acquire_table+0x42/0x70
  [<ffffffff813ff086>] acpi_tb_validate_table+0x27/0x37
  [<ffffffff813ff0e5>] acpi_tb_verify_table+0x22/0xd8
  [<ffffffff813ff6a8>] acpi_tb_install_non_fixed_table+0x60/0x1c9
  [<ffffffff81d61024>] acpi_tb_parse_root_table+0x218/0x26a
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d610cd>] acpi_initialize_tables+0x57/0x59
  [<ffffffff81d5f25d>] acpi_table_init+0x1b/0x99
  [<ffffffff81d2bca0>] acpi_boot_table_init+0x1e/0x85
  [<ffffffff81d23043>] setup_arch+0x99d/0xcc6
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d1bbbe>] start_kernel+0x8b/0x415
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d1b5ee>] x86_64_start_reservations+0x2a/0x2c
  [<ffffffff81d1b72e>] x86_64_start_kernel+0x13e/0x14d
 ---[ end trace 11ae599a1898f4e7 ]---
This is due to the size limitation of the x86 early IO mapping.

This patch fixes this issue by utilizing acpi_gbl_verify_table_checksum to
disable table mapping during early stage and enabling it again for the late
stage. In this way, the normal code path is not affected.

A new boot parameter - acpi_force_verify_table is introduced for platforms
that require checksum verification to stop loading bad tables.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: <lkp@vger.linux-kernel.cn>
Cc: <x86@kernel.org>
---
 Documentation/kernel-parameters.txt |    5 +++++
 drivers/acpi/bus.c                  |    3 +++
 drivers/acpi/tables.c               |   23 +++++++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 7a4802d..e5c3274 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -214,6 +214,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			unusable.  The "log_buf_len" parameter may be useful
 			if you need to capture more output.
 
+	acpi_force_verify_table	[HW,ACPI]
+			Enable table checksum verification during early stage.
+			By default, this is disabled due to x86 early mapping
+			size limitation.
+
 	acpi_irq_balance [HW,ACPI]
 			ACPI will balance active IRQs
 			default in APIC mode
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4ce0ea1..c5bc8cf 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -489,6 +489,9 @@ void __init acpi_early_init(void)
 
 	printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
 
+	/* It's safe to verify table checksums during late stage */
+	acpi_gbl_verify_table_checksum = TRUE;
+
 	/* enable workarounds, unless strict ACPI spec. compliance */
 	if (!acpi_strict)
 		acpi_gbl_enable_interpreter_slack = TRUE;
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 2178229..204b746 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -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)
@@ -333,6 +339,14 @@ int __init acpi_table_init(void)
 {
 	acpi_status status;
 
+	if (!acpi_verify_table_checksum) {
+		pr_info("Early table checksum verification disabled\n");
+		acpi_gbl_verify_table_checksum = FALSE;
+	} else {
+		pr_info("Early table checksum verification enabled\n");
+		acpi_gbl_verify_table_checksum = TRUE;
+	}
+
 	status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
 	if (ACPI_FAILURE(status))
 		return -EINVAL;
@@ -354,3 +368,12 @@ static int __init acpi_parse_apic_instance(char *str)
 }
 
 early_param("acpi_apic_instance", acpi_parse_apic_instance);
+
+static int __init acpi_force_verify_table_setup(char *s)
+{
+	acpi_verify_table_checksum = true;
+
+	return 0;
+}
+
+early_param("acpi_force_verify_table", acpi_force_verify_table_setup);
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification.
  2014-05-30  2:07 [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Lv Zheng
  2014-05-30  2:07 ` [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
@ 2014-05-30 22:29 ` Rafael J. Wysocki
  2014-05-31  0:14 ` [PATCH v2 0/2] ACPI: Fix a regression of the " Lv Zheng
  2 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30 22:29 UTC (permalink / raw)
  To: Lv Zheng; +Cc: Rafael J. Wysocki, Len Brown, Lv Zheng, linux-acpi, lkp, x86

On Friday, May 30, 2014 10:07:31 AM Lv Zheng wrote:

[cut]

> diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
> index b5f7132..380828d 100644
> --- a/include/acpi/acpixf.h
> +++ b/include/acpi/acpixf.h
> @@ -162,6 +162,14 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_create_osi_method, TRUE);
>  ACPI_INIT_GLOBAL(u8, acpi_gbl_use_default_register_widths, TRUE);
>  
>  /*
> + * Optionally verify the table checksum before installation. Set this to

What about "Whether or not to verify ..." instead of "Optionally verify ..."?

> + * TRUE to verify the table checksum before install it to the table
> + * manager. Note that some OSPMs cannot do large mappings during the
> + * certain stages.

The "Note that ..." thing is completely unuseful here, because it is not
particularly clear why being unable to use large mappings is related to
this option (I know it is, but a casual reader may not know that).

What about "Note that enabling this option causes errors to happen in
some OSPMs during early initialization stages" instead?

> Default is behavior is to do such verification.
> + */

Please fix the double "is".

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation.
  2014-05-30  2:07 ` [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
@ 2014-05-30 22:33   ` Rafael J. Wysocki
  0 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30 22:33 UTC (permalink / raw)
  To: Lv Zheng; +Cc: Rafael J. Wysocki, Len Brown, Lv Zheng, linux-acpi, lkp, x86

On Friday, May 30, 2014 10:07:46 AM Lv Zheng wrote:
> The following regression is reported when the table length is very large:
>  WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:136 __early_ioremap+0x11f/0x1f2()
>  Modules linked in:
>  CPU: 0 PID: 0 Comm: swapper Not tainted 3.15.0-rc1-00017-g86dfc6f3-dirty #298
>  Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.99.99.x036.091920111209 09/19/2011
>   0000000000000009 ffffffff81b75c40 ffffffff817c627b 0000000000000000
>   ffffffff81b75c78 ffffffff81067b5d 000000000000007b 8000000000000563
>   00000000b96b20dc 0000000000000001 ffffffffff300e0c ffffffff81b75c88
>  Call Trace:
>   [<ffffffff817c627b>] dump_stack+0x45/0x56
>   [<ffffffff81067b5d>] warn_slowpath_common+0x7d/0xa0
>   [<ffffffff81067c3a>] warn_slowpath_null+0x1a/0x20
>   [<ffffffff81d4b9d5>] __early_ioremap+0x11f/0x1f2
>   [<ffffffff81d4bc5b>] early_ioremap+0x13/0x15
>   [<ffffffff81d2b8f3>] __acpi_map_table+0x13/0x18
>   [<ffffffff817b8d1a>] acpi_os_map_memory+0x26/0x14e
>   [<ffffffff813ff018>] acpi_tb_acquire_table+0x42/0x70
>   [<ffffffff813ff086>] acpi_tb_validate_table+0x27/0x37
>   [<ffffffff813ff0e5>] acpi_tb_verify_table+0x22/0xd8
>   [<ffffffff813ff6a8>] acpi_tb_install_non_fixed_table+0x60/0x1c9
>   [<ffffffff81d61024>] acpi_tb_parse_root_table+0x218/0x26a
>   [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
>   [<ffffffff81d610cd>] acpi_initialize_tables+0x57/0x59
>   [<ffffffff81d5f25d>] acpi_table_init+0x1b/0x99
>   [<ffffffff81d2bca0>] acpi_boot_table_init+0x1e/0x85
>   [<ffffffff81d23043>] setup_arch+0x99d/0xcc6
>   [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
>   [<ffffffff81d1bbbe>] start_kernel+0x8b/0x415
>   [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
>   [<ffffffff81d1b5ee>] x86_64_start_reservations+0x2a/0x2c
>   [<ffffffff81d1b72e>] x86_64_start_kernel+0x13e/0x14d
>  ---[ end trace 11ae599a1898f4e7 ]---
> This is due to the size limitation of the x86 early IO mapping.
> 
> This patch fixes this issue by utilizing acpi_gbl_verify_table_checksum to
> disable table mapping during early stage and enabling it again for the late
> stage. In this way, the normal code path is not affected.
> 
> A new boot parameter - acpi_force_verify_table is introduced for platforms
> that require checksum verification to stop loading bad tables.
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Reported-and-tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Cc: <lkp@vger.linux-kernel.cn>
> Cc: <x86@kernel.org>
> ---
>  Documentation/kernel-parameters.txt |    5 +++++
>  drivers/acpi/bus.c                  |    3 +++
>  drivers/acpi/tables.c               |   23 +++++++++++++++++++++++
>  3 files changed, 31 insertions(+)
> 
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index 7a4802d..e5c3274 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -214,6 +214,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
>  			unusable.  The "log_buf_len" parameter may be useful
>  			if you need to capture more output.
>  
> +	acpi_force_verify_table	[HW,ACPI]

What about acpi_force_table_verification?

> +			Enable table checksum verification during early stage.
> +			By default, this is disabled due to x86 early mapping
> +			size limitation.
> +
>  	acpi_irq_balance [HW,ACPI]
>  			ACPI will balance active IRQs
>  			default in APIC mode
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 4ce0ea1..c5bc8cf 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -489,6 +489,9 @@ void __init acpi_early_init(void)
>  
>  	printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
>  
> +	/* It's safe to verify table checksums during late stage */
> +	acpi_gbl_verify_table_checksum = TRUE;
> +
>  	/* enable workarounds, unless strict ACPI spec. compliance */
>  	if (!acpi_strict)
>  		acpi_gbl_enable_interpreter_slack = TRUE;
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index 2178229..204b746 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -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)
> @@ -333,6 +339,14 @@ int __init acpi_table_init(void)
>  {
>  	acpi_status status;
>  
> +	if (!acpi_verify_table_checksum) {
> +		pr_info("Early table checksum verification disabled\n");
> +		acpi_gbl_verify_table_checksum = FALSE;
> +	} else {
> +		pr_info("Early table checksum verification enabled\n");
> +		acpi_gbl_verify_table_checksum = TRUE;
> +	}

It's better to write this condition as

	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 -EINVAL;
> @@ -354,3 +368,12 @@ static int __init acpi_parse_apic_instance(char *str)
>  }
>  
>  early_param("acpi_apic_instance", acpi_parse_apic_instance);
> +
> +static int __init acpi_force_verify_table_setup(char *s)
> +{
> +	acpi_verify_table_checksum = true;
> +
> +	return 0;
> +}
> +
> +early_param("acpi_force_verify_table", acpi_force_verify_table_setup);
> 

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification.
  2014-05-30  2:07 [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Lv Zheng
  2014-05-30  2:07 ` [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
  2014-05-30 22:29 ` [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Rafael J. Wysocki
@ 2014-05-31  0:14 ` Lv Zheng
  2014-05-31  0:14   ` [PATCH v2 1/2] ACPICA: Tables: Add mechanism to control early " Lv Zheng
                     ` (2 more replies)
  2 siblings, 3 replies; 10+ messages in thread
From: Lv Zheng @ 2014-05-31  0:14 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: Lv Zheng, Lv Zheng, linux-acpi

From: Lv Zheng <lv.zheng@intel.com>

There is a warning message triggered by the early table chekcusm
verification during boot. Large tables cannot be installed on x86 platforms
due to this failure. The root cause is the size limitation of the current
x86 early mapping implementation, it's thus not suitable to be used to map
ACPI tables.

This patchset fixes this regression by stopping verifying table checksums
during the early boot stage.

Lv Zheng (2):
  ACPICA: Tables: Add mechanism to control early table checksum
    verification.
  ACPI: Fix regressions that x86 Linux kernel suffers from early
    mapping size limitation.

 Documentation/kernel-parameters.txt |    5 +++
 drivers/acpi/acpica/actables.h      |    8 +++--
 drivers/acpi/acpica/tbdata.c        |   67 +++++++++++++++++++++++++++--------
 drivers/acpi/acpica/tbinstal.c      |    8 ++---
 drivers/acpi/acpica/tbutils.c       |    4 ---
 drivers/acpi/bus.c                  |    3 ++
 drivers/acpi/tables.c               |   23 ++++++++++++
 include/acpi/acpixf.h               |    9 +++++
 8 files changed, 101 insertions(+), 26 deletions(-)

-- 
1.7.10


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification.
  2014-05-31  0:14 ` [PATCH v2 0/2] ACPI: Fix a regression of the " Lv Zheng
@ 2014-05-31  0:14   ` Lv Zheng
  2014-05-31  0:15   ` [PATCH v2 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
  2014-05-31 22:49   ` [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification Rafael J. Wysocki
  2 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2014-05-31  0:14 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: Lv Zheng, Lv Zheng, linux-acpi, lkp, x86

From: Lv Zheng <lv.zheng@intel.com>

It is reported that Linux x86 kernel cannot map large tables. The following
large SSDT table on such platform fails to pass checksum verification and
cannot be installed:
 ACPI: SSDT 0x00000000B9638018 07A0C4 (v02 INTEL  S2600CP  00004000 INTL 20100331)

It sounds strange that in the 64-bit virtual memory address space, we
cannot map a single ACPI table to do checksum verification. The root cause
is:
1. ACPICA doesn't split IO memory mapping and table mapping;
2. Linux x86 OSL implements acpi_os_map_memory() using a size limited fix-map
   mechanism during early boot stage, which is more suitable for only IO
   mappings.

ACPICA originally only mapped table header for signature validation, and
this header mapping is required by OSL override mechanism. There was no
checksum verification because we could not map the whole table using this
OSL. While the following ACPICA commit enforces checksum verification by
mapping the whole table during Linux boot stage and it finally triggers
this issue on some platforms:
 Commit: 86dfc6f339886559d80ee0d4bd20fe5ee90450f0
 Subject: ACPICA: Tables: Fix table checksums verification before installation.

Before doing further cleanups for the OSL table mapping and override
implementation, this patch introduces an option for such OSPMs to
temporarily discard the checksum verification feature. It then can be
re-enabled easily when the ACPICA and the underlying OSL is ready.

This patch also deletes a comment around the limitation of mappings because
it is not correct. The limitation is not how many times we can map in the
early stage, but the OSL mapping facility may not be suitable for mapping
the ACPI tables and thus may complain us the size limitation.

The acpi_tb_verify_table() is renamed to acpi_tb_verify_temp_table() due to the
work around added, it now only applies to the table descriptor that hasn't
been installed and cannot be used in other cases. Lv Zheng.

[zetalog: on top of linux-pm.git/linux-next]
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Bisected-and-tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: <lkp@vger.linux-kernel.cn>
Cc: <x86@kernel.org>
---
 drivers/acpi/acpica/actables.h |    8 +++--
 drivers/acpi/acpica/tbdata.c   |   67 +++++++++++++++++++++++++++++++---------
 drivers/acpi/acpica/tbinstal.c |    8 ++---
 drivers/acpi/acpica/tbutils.c  |    4 ---
 include/acpi/acpixf.h          |    9 ++++++
 5 files changed, 70 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index bda9a7e..f148827 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -69,6 +69,11 @@ acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
 
 void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc);
 
+acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc);
+
+acpi_status
+acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature);
+
 u8 acpi_tb_is_table_loaded(u32 table_index);
 
 void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
@@ -96,9 +101,6 @@ acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc);
 
 void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc);
 
-acpi_status
-acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature);
-
 void acpi_tb_override_table(struct acpi_table_desc *old_table_desc);
 
 acpi_status
diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c
index cbe2994..f499c10 100644
--- a/drivers/acpi/acpica/tbdata.c
+++ b/drivers/acpi/acpica/tbdata.c
@@ -322,7 +322,39 @@ void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
 
 /******************************************************************************
  *
- * FUNCTION:    acpi_tb_verify_table
+ * FUNCTION:    acpi_tb_validate_temp_table
+ *
+ * PARAMETERS:  table_desc          - Table descriptor
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function is called to validate the table, the returned
+ *              table descriptor is in "VALIDATED" state.
+ *
+ *****************************************************************************/
+
+acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
+{
+
+	if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) {
+		/*
+		 * Only validates the header of the table.
+		 * Note that Length contains the size of the mapping after invoking
+		 * this work around, this value is required by
+		 * acpi_tb_release_temp_table().
+		 * We can do this because in acpi_init_table_descriptor(), the Length
+		 * field of the installed descriptor is filled with the actual
+		 * table length obtaining from the table header.
+		 */
+		table_desc->length = sizeof(struct acpi_table_header);
+	}
+
+	return (acpi_tb_validate_table(table_desc));
+}
+
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_tb_verify_temp_table
  *
  * PARAMETERS:  table_desc          - Table descriptor
  *              signature           - Table signature to verify
@@ -335,15 +367,15 @@ void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
  *****************************************************************************/
 
 acpi_status
-acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature)
+acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature)
 {
 	acpi_status status = AE_OK;
 
-	ACPI_FUNCTION_TRACE(tb_verify_table);
+	ACPI_FUNCTION_TRACE(tb_verify_temp_table);
 
 	/* Validate the table */
 
-	status = acpi_tb_validate_table(table_desc);
+	status = acpi_tb_validate_temp_table(table_desc);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(AE_NO_MEMORY);
 	}
@@ -360,17 +392,22 @@ acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature)
 
 	/* Verify the checksum */
 
-	status =
-	    acpi_tb_verify_checksum(table_desc->pointer, table_desc->length);
-	if (ACPI_FAILURE(status)) {
-		ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
-				"%4.4s " ACPI_PRINTF_UINT
-				" Attempted table install failed",
-				acpi_ut_valid_acpi_name(table_desc->signature.
-							ascii) ? table_desc->
-				signature.ascii : "????",
-				ACPI_FORMAT_TO_UINT(table_desc->address)));
-		goto invalidate_and_exit;
+	if (acpi_gbl_verify_table_checksum) {
+		status =
+		    acpi_tb_verify_checksum(table_desc->pointer,
+					    table_desc->length);
+		if (ACPI_FAILURE(status)) {
+			ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
+					"%4.4s " ACPI_PRINTF_UINT
+					" Attempted table install failed",
+					acpi_ut_valid_acpi_name(table_desc->
+								signature.
+								ascii) ?
+					table_desc->signature.ascii : "????",
+					ACPI_FORMAT_TO_UINT(table_desc->
+							    address)));
+			goto invalidate_and_exit;
+		}
 	}
 
 	return_ACPI_STATUS(AE_OK);
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index d4d6029..755b90c 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -194,7 +194,7 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
 
 	/* Validate and verify a table before installation */
 
-	status = acpi_tb_verify_table(&new_table_desc, signature);
+	status = acpi_tb_verify_temp_table(&new_table_desc, signature);
 	if (ACPI_FAILURE(status)) {
 		goto release_and_exit;
 	}
@@ -266,7 +266,7 @@ acpi_tb_install_standard_table(acpi_physical_address address,
 
 	/* Validate and verify a table before installation */
 
-	status = acpi_tb_verify_table(&new_table_desc, NULL);
+	status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
 	if (ACPI_FAILURE(status)) {
 		goto release_and_exit;
 	}
@@ -424,7 +424,7 @@ finish_override:
 
 	/* Validate and verify a table before overriding */
 
-	status = acpi_tb_verify_table(&new_table_desc, NULL);
+	status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
 	if (ACPI_FAILURE(status)) {
 		return;
 	}
@@ -446,7 +446,7 @@ finish_override:
 	acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
 				      new_table_desc.flags,
 				      new_table_desc.pointer);
-	acpi_tb_validate_table(old_table_desc);
+	acpi_tb_validate_temp_table(old_table_desc);
 
 	/* Release the temporary table descriptor */
 
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index e37a103..6b1ca99 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -395,10 +395,6 @@ next_table:
 		table_entry += table_entry_size;
 	}
 
-	/*
-	 * It is not possible to map more than one entry in some environments,
-	 * so unmap the root table here before mapping other tables
-	 */
 	acpi_os_unmap_memory(table, length);
 
 	return_ACPI_STATUS(AE_OK);
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index b5f7132..35b525c 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -162,6 +162,15 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_create_osi_method, TRUE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_use_default_register_widths, TRUE);
 
 /*
+ * Whether or not to verify the table checksum before installation. Set
+ * this to TRUE to verify the table checksum before install it to the table
+ * manager. Note that enabling this option causes errors to happen in some
+ * OSPMs during early initialization stages. Default behavior is to do such
+ * verification.
+ */
+ACPI_INIT_GLOBAL(u8, acpi_gbl_verify_table_checksum, TRUE);
+
+/*
  * Optionally enable output from the AML Debug Object.
  */
 ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_aml_debug_object, FALSE);
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation.
  2014-05-31  0:14 ` [PATCH v2 0/2] ACPI: Fix a regression of the " Lv Zheng
  2014-05-31  0:14   ` [PATCH v2 1/2] ACPICA: Tables: Add mechanism to control early " Lv Zheng
@ 2014-05-31  0:15   ` Lv Zheng
  2014-05-31 22:49   ` [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification Rafael J. Wysocki
  2 siblings, 0 replies; 10+ messages in thread
From: Lv Zheng @ 2014-05-31  0:15 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: Lv Zheng, Lv Zheng, linux-acpi, lkp, x86

From: Lv Zheng <lv.zheng@intel.com>

The following warning message is triggered:
 WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:136 __early_ioremap+0x11f/0x1f2()
 Modules linked in:
 CPU: 0 PID: 0 Comm: swapper Not tainted 3.15.0-rc1-00017-g86dfc6f3-dirty #298
 Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.99.99.x036.091920111209 09/19/2011
  0000000000000009 ffffffff81b75c40 ffffffff817c627b 0000000000000000
  ffffffff81b75c78 ffffffff81067b5d 000000000000007b 8000000000000563
  00000000b96b20dc 0000000000000001 ffffffffff300e0c ffffffff81b75c88
 Call Trace:
  [<ffffffff817c627b>] dump_stack+0x45/0x56
  [<ffffffff81067b5d>] warn_slowpath_common+0x7d/0xa0
  [<ffffffff81067c3a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff81d4b9d5>] __early_ioremap+0x11f/0x1f2
  [<ffffffff81d4bc5b>] early_ioremap+0x13/0x15
  [<ffffffff81d2b8f3>] __acpi_map_table+0x13/0x18
  [<ffffffff817b8d1a>] acpi_os_map_memory+0x26/0x14e
  [<ffffffff813ff018>] acpi_tb_acquire_table+0x42/0x70
  [<ffffffff813ff086>] acpi_tb_validate_table+0x27/0x37
  [<ffffffff813ff0e5>] acpi_tb_verify_table+0x22/0xd8
  [<ffffffff813ff6a8>] acpi_tb_install_non_fixed_table+0x60/0x1c9
  [<ffffffff81d61024>] acpi_tb_parse_root_table+0x218/0x26a
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d610cd>] acpi_initialize_tables+0x57/0x59
  [<ffffffff81d5f25d>] acpi_table_init+0x1b/0x99
  [<ffffffff81d2bca0>] acpi_boot_table_init+0x1e/0x85
  [<ffffffff81d23043>] setup_arch+0x99d/0xcc6
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d1bbbe>] start_kernel+0x8b/0x415
  [<ffffffff81d1b120>] ? early_idt_handlers+0x120/0x120
  [<ffffffff81d1b5ee>] x86_64_start_reservations+0x2a/0x2c
  [<ffffffff81d1b72e>] x86_64_start_kernel+0x13e/0x14d
 ---[ end trace 11ae599a1898f4e7 ]---
when installing the following table during early stage:
 ACPI: SSDT 0x00000000B9638018 07A0C4 (v02 INTEL  S2600CP  00004000 INTL 20100331)
The regression is caused by the size limitation of the x86 early IO mapping.

The root cause is:
1. ACPICA doesn't split IO memory mapping and table mapping;
2. Linux x86 OSL implements acpi_os_map_memory() using a size limited fix-map
   mechanism during early boot stage, which is more suitable for only IO
   mappings.

This patch fixes this issue by utilizing acpi_gbl_verify_table_checksum to
disable the table mapping during early stage and enabling it again for the
late stage. In this way, the normal code path is not affected. Then after
the code related to the root cause is cleaned up, the early checksum
verification can be easily re-enabled.

A new boot parameter - acpi_force_table_verification is introduced for
the platforms that require the checksum verification to stop loading bad
tables.

This fix also covers the checksum verification for the table overrides. Now
large tables can also be overridden using the initrd override mechanism.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Bisected-and-tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: <lkp@vger.linux-kernel.cn>
Cc: <x86@kernel.org>
---
 Documentation/kernel-parameters.txt |    5 +++++
 drivers/acpi/bus.c                  |    3 +++
 drivers/acpi/tables.c               |   23 +++++++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 7a4802d..0933ec4 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -214,6 +214,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			unusable.  The "log_buf_len" parameter may be useful
 			if you need to capture more output.
 
+	acpi_force_table_verification	[HW,ACPI]
+			Enable table checksum verification during early stage.
+			By default, this is disabled due to x86 early mapping
+			size limitation.
+
 	acpi_irq_balance [HW,ACPI]
 			ACPI will balance active IRQs
 			default in APIC mode
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4ce0ea1..c5bc8cf 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -489,6 +489,9 @@ void __init acpi_early_init(void)
 
 	printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
 
+	/* It's safe to verify table checksums during late stage */
+	acpi_gbl_verify_table_checksum = TRUE;
+
 	/* enable workarounds, unless strict ACPI spec. compliance */
 	if (!acpi_strict)
 		acpi_gbl_enable_interpreter_slack = TRUE;
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 2178229..05550ba 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -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)
@@ -333,6 +339,14 @@ 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 -EINVAL;
@@ -354,3 +368,12 @@ static int __init acpi_parse_apic_instance(char *str)
 }
 
 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);
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification.
  2014-05-31  0:14 ` [PATCH v2 0/2] ACPI: Fix a regression of the " Lv Zheng
  2014-05-31  0:14   ` [PATCH v2 1/2] ACPICA: Tables: Add mechanism to control early " Lv Zheng
  2014-05-31  0:15   ` [PATCH v2 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
@ 2014-05-31 22:49   ` Rafael J. Wysocki
  2014-06-03  2:36     ` Zheng, Lv
  2 siblings, 1 reply; 10+ messages in thread
From: Rafael J. Wysocki @ 2014-05-31 22:49 UTC (permalink / raw)
  To: Lv Zheng; +Cc: Rafael J. Wysocki, Len Brown, Lv Zheng, linux-acpi

On Saturday, May 31, 2014 08:14:26 AM Lv Zheng wrote:
> From: Lv Zheng <lv.zheng@intel.com>
> 
> There is a warning message triggered by the early table chekcusm
> verification during boot. Large tables cannot be installed on x86 platforms
> due to this failure. The root cause is the size limitation of the current
> x86 early mapping implementation, it's thus not suitable to be used to map
> ACPI tables.
> 
> This patchset fixes this regression by stopping verifying table checksums
> during the early boot stage.

Both queued up for 3.16.

If they are needed in -stable, please take care of sending an appropriate
inclusion request to stable@vger.kernel.org after they have been merged into
the Linus' tree.

Thanks!

> Lv Zheng (2):
>   ACPICA: Tables: Add mechanism to control early table checksum
>     verification.
>   ACPI: Fix regressions that x86 Linux kernel suffers from early
>     mapping size limitation.
> 
>  Documentation/kernel-parameters.txt |    5 +++
>  drivers/acpi/acpica/actables.h      |    8 +++--
>  drivers/acpi/acpica/tbdata.c        |   67 +++++++++++++++++++++++++++--------
>  drivers/acpi/acpica/tbinstal.c      |    8 ++---
>  drivers/acpi/acpica/tbutils.c       |    4 ---
>  drivers/acpi/bus.c                  |    3 ++
>  drivers/acpi/tables.c               |   23 ++++++++++++
>  include/acpi/acpixf.h               |    9 +++++
>  8 files changed, 101 insertions(+), 26 deletions(-)
> 
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification.
  2014-05-31 22:49   ` [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification Rafael J. Wysocki
@ 2014-06-03  2:36     ` Zheng, Lv
  2014-06-03 14:10       ` Rafael J. Wysocki
  0 siblings, 1 reply; 10+ messages in thread
From: Zheng, Lv @ 2014-06-03  2:36 UTC (permalink / raw)
  To: Rafael J. Wysocki, Lv Zheng
  Cc: Wysocki, Rafael J, Brown, Len, linux-acpi@vger.kernel.org

Hi, Rafael

> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> Sent: Sunday, June 01, 2014 6:50 AM
> 
> On Saturday, May 31, 2014 08:14:26 AM Lv Zheng wrote:
> > From: Lv Zheng <lv.zheng@intel.com>
> >
> > There is a warning message triggered by the early table chekcusm
> > verification during boot. Large tables cannot be installed on x86 platforms
> > due to this failure. The root cause is the size limitation of the current
> > x86 early mapping implementation, it's thus not suitable to be used to map
> > ACPI tables.
> >
> > This patchset fixes this regression by stopping verifying table checksums
> > during the early boot stage.
> 
> Both queued up for 3.16.
> 
> If they are needed in -stable, please take care of sending an appropriate
> inclusion request to stable@vger.kernel.org after they have been merged into
> the Linus' tree.

I checked.
The affected code can only be found in linux-pm.git/linux-next.
So they are not needed in -stable.

Thanks and best regards
-Lv

> 
> Thanks!
> 
> > Lv Zheng (2):
> >   ACPICA: Tables: Add mechanism to control early table checksum
> >     verification.
> >   ACPI: Fix regressions that x86 Linux kernel suffers from early
> >     mapping size limitation.
> >
> >  Documentation/kernel-parameters.txt |    5 +++
> >  drivers/acpi/acpica/actables.h      |    8 +++--
> >  drivers/acpi/acpica/tbdata.c        |   67 +++++++++++++++++++++++++++--------
> >  drivers/acpi/acpica/tbinstal.c      |    8 ++---
> >  drivers/acpi/acpica/tbutils.c       |    4 ---
> >  drivers/acpi/bus.c                  |    3 ++
> >  drivers/acpi/tables.c               |   23 ++++++++++++
> >  include/acpi/acpixf.h               |    9 +++++
> >  8 files changed, 101 insertions(+), 26 deletions(-)
> >
> >
> 
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification.
  2014-06-03  2:36     ` Zheng, Lv
@ 2014-06-03 14:10       ` Rafael J. Wysocki
  0 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2014-06-03 14:10 UTC (permalink / raw)
  To: Zheng, Lv, Rafael J. Wysocki, Lv Zheng
  Cc: Brown, Len, linux-acpi@vger.kernel.org

On 6/3/2014 4:36 AM, Zheng, Lv wrote:
> Hi, Rafael
>
>> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
>> Sent: Sunday, June 01, 2014 6:50 AM
>>
>> On Saturday, May 31, 2014 08:14:26 AM Lv Zheng wrote:
>>> From: Lv Zheng <lv.zheng@intel.com>
>>>
>>> There is a warning message triggered by the early table chekcusm
>>> verification during boot. Large tables cannot be installed on x86 platforms
>>> due to this failure. The root cause is the size limitation of the current
>>> x86 early mapping implementation, it's thus not suitable to be used to map
>>> ACPI tables.
>>>
>>> This patchset fixes this regression by stopping verifying table checksums
>>> during the early boot stage.
>> Both queued up for 3.16.
>>
>> If they are needed in -stable, please take care of sending an appropriate
>> inclusion request to stable@vger.kernel.org after they have been merged into
>> the Linus' tree.
> I checked.
> The affected code can only be found in linux-pm.git/linux-next.
> So they are not needed in -stable.

Thanks for checking!

Rafael


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-03 14:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-30  2:07 [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Lv Zheng
2014-05-30  2:07 ` [PATCH 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
2014-05-30 22:33   ` Rafael J. Wysocki
2014-05-30 22:29 ` [PATCH 1/2] ACPICA: Tables: Add mechanism to control early table checksum verification Rafael J. Wysocki
2014-05-31  0:14 ` [PATCH v2 0/2] ACPI: Fix a regression of the " Lv Zheng
2014-05-31  0:14   ` [PATCH v2 1/2] ACPICA: Tables: Add mechanism to control early " Lv Zheng
2014-05-31  0:15   ` [PATCH v2 2/2] ACPI: Fix regressions that x86 Linux kernel suffers from early mapping size limitation Lv Zheng
2014-05-31 22:49   ` [PATCH v2 0/2] ACPI: Fix a regression of the table checksum verification Rafael J. Wysocki
2014-06-03  2:36     ` Zheng, Lv
2014-06-03 14:10       ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).