From ef42e53f271b99fe9eb853df5661edeac8a277f6 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Mon, 31 Dec 2012 00:07:18 +0000 Subject: ACPICA: Interpreter: Add warning if 64-bit constant appears in 32-bit table. Some ASL compilers allow 64-bit constants within a 32-bit table (DSDT version == 1). When encountered, emit a warning that the constant will be truncated to 32 bits. This is potentially a serious problem in the ACPI table(s). Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/exutils.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers/acpi/acpica/exutils.c') diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c index 02ddc4ceca37..e624958f33b8 100644 --- a/drivers/acpi/acpica/exutils.c +++ b/drivers/acpi/acpica/exutils.c @@ -202,35 +202,39 @@ void acpi_ex_relinquish_interpreter(void) * * PARAMETERS: obj_desc - Object to be truncated * - * RETURN: none + * RETURN: TRUE if a truncation was performed, FALSE otherwise. * * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is * 32-bit, as determined by the revision of the DSDT. * ******************************************************************************/ -void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) +u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) { ACPI_FUNCTION_ENTRY(); /* * Object must be a valid number and we must be executing - * a control method. NS node could be there for AML_INT_NAMEPATH_OP. + * a control method. Object could be NS node for AML_INT_NAMEPATH_OP. */ if ((!obj_desc) || (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) || (obj_desc->common.type != ACPI_TYPE_INTEGER)) { - return; + return (FALSE); } - if (acpi_gbl_integer_byte_width == 4) { + if ((acpi_gbl_integer_byte_width == 4) && + (obj_desc->integer.value > (u64)ACPI_UINT32_MAX)) { /* - * We are running a method that exists in a 32-bit ACPI table. + * We are executing in a 32-bit ACPI table. * Truncate the value to 32 bits by zeroing out the upper 32-bit field */ - obj_desc->integer.value &= (u64) ACPI_UINT32_MAX; + obj_desc->integer.value &= (u64)ACPI_UINT32_MAX; + return (TRUE); } + + return (FALSE); } /******************************************************************************* -- cgit v1.2.3