ia64/xen-unstable

changeset 17553:806e7fa30264

x86: Fix FADT parsing for PM event blocks.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 01 13:16:32 2008 +0100 (2008-05-01)
parents 9fd00ff95068
children b2a036d390db
files xen/arch/x86/acpi/boot.c
line diff
     1.1 --- a/xen/arch/x86/acpi/boot.c	Thu May 01 11:34:56 2008 +0100
     1.2 +++ b/xen/arch/x86/acpi/boot.c	Thu May 01 13:16:32 2008 +0100
     1.3 @@ -465,15 +465,18 @@ bad:
     1.4  static void __init
     1.5  acpi_fadt_parse_reg(struct acpi_table_fadt *fadt)
     1.6  {
     1.7 -	memcpy(&acpi_gbl_FADT, fadt, sizeof(acpi_gbl_FADT));
     1.8 +	unsigned int len = min(fadt->header.length, sizeof(*fadt));
     1.9 +
    1.10 +	memcpy(&acpi_gbl_FADT, fadt, len);
    1.11  
    1.12 -	memcpy(&acpi_gbl_xpm1a_enable, &(fadt->xpm1a_event_block),
    1.13 -		sizeof(acpi_gbl_xpm1a_enable));
    1.14 -	memcpy(&acpi_gbl_xpm1b_enable, &(fadt->xpm1b_event_block),
    1.15 -		sizeof(acpi_gbl_xpm1b_enable));
    1.16 -
    1.17 -	acpi_gbl_xpm1a_enable.address += 2;
    1.18 -	acpi_gbl_xpm1b_enable.address += 2;
    1.19 +	if (len > offsetof(struct acpi_table_fadt, xpm1b_event_block)) {
    1.20 +		memcpy(&acpi_gbl_xpm1a_enable, &fadt->xpm1a_event_block,
    1.21 +		       sizeof(acpi_gbl_xpm1a_enable));
    1.22 +		memcpy(&acpi_gbl_xpm1b_enable, &fadt->xpm1b_event_block,
    1.23 +		       sizeof(acpi_gbl_xpm1b_enable));
    1.24 +		acpi_gbl_xpm1a_enable.address += 2;
    1.25 +		acpi_gbl_xpm1b_enable.address += 2;
    1.26 +	}
    1.27  }
    1.28  
    1.29  static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
    1.30 @@ -523,12 +526,12 @@ static int __init acpi_parse_fadt(unsign
    1.31  	acpi_enable_value  = fadt->acpi_enable;
    1.32  	acpi_disable_value = fadt->acpi_disable;
    1.33  
    1.34 +	acpi_fadt_parse_reg(fadt);
    1.35 +
    1.36  #ifdef CONFIG_ACPI_SLEEP
    1.37  	acpi_fadt_parse_sleep_info(fadt);
    1.38  #endif
    1.39  
    1.40 -	acpi_fadt_parse_reg(fadt);
    1.41 -
    1.42  	return 0;
    1.43  }
    1.44