Skip to content

Commit

Permalink
ACPICA: Tables: Add mechanism to control early table checksum verific…
Browse files Browse the repository at this point in the history
…ation.

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: 86dfc6f
 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.

Tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Lv Zheng authored and Rafael J. Wysocki committed May 31, 2014
1 parent 2947c1d commit 47d68c7
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 26 deletions.
8 changes: 5 additions & 3 deletions drivers/acpi/acpica/actables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
67 changes: 52 additions & 15 deletions drivers/acpi/acpica/tbdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/acpica/tbinstal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -424,7 +424,7 @@ void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)

/* 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;
}
Expand All @@ -446,7 +446,7 @@ void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
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 */

Expand Down
4 changes: 0 additions & 4 deletions drivers/acpi/acpica/tbutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,6 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
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);
Expand Down
9 changes: 9 additions & 0 deletions include/acpi/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,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.
*/
Expand Down

0 comments on commit 47d68c7

Please sign in to comment.