x86/ACPI: invalidate BGRT if necessary
PATCH v2 1/1 x86/ACPI: invalidate BGRT if necessary
Since the image pointed to may live in boot services memory (which we add to the global memory pool long before ACPI tables get looked at), we should prevent Dom0 from trying to retrieve the image data in that case.
The alternatives would be to
- not add boot services memory to the global pool at all, or
- defer adding boot services memory until Dom0 indicates it is safe to do so, or
- find and parse the BGRT table in xen/arch/x86/efi/boot.c, and avoid adding that specific region to the E820 table.
None of these are really attractive, and as Xen commonly prints to the video console anyway (without trying to avoid any regions on the screen), the invalidation would need to be done conditionally anyway.
(xen/include/acpi/actbl3.h is a verbatim copy from Linux 3.7-rc4)
---
v2: Only invalidate if the image lives in RAM, and do the invalidation
by clearing both the valid bit and the image address.
xen/arch/x86/acpi/boot.c +24 -0
@@ -28,6 +28,7 @@#include <xen/init.h> #include <xen/acpi.h> #include <xen/irq.h> +#include <xen/mm.h> #include <xen/dmi.h> #include <asm/fixmap.h> #include <asm/page.h>
@@ -286,6 +287,27 @@ static int __init acpi_parse_hpet(struct#define acpi_parse_hpet NULL#endif +static int __init acpi_invalidate_bgrt (struct acpi_table_header *table) +{ +struct acpi_table_bgrt *bgrt_tbl = + container_of(table, struct acpi_table_bgrt, header); + +if (table->length <sizeof (*bgrt_tbl)) +return -1 ; + +if (bgrt_tbl->version ==1 && bgrt_tbl->image_address + && !page_is_ram_type (PFN_DOWN (bgrt_tbl->image_address), +RAM_TYPE_CONVENTIONAL )) +return 0 ; + + printk(KERN_INFO PREFIX "BGRT: invalidating v%d image at %#"PRIx64"\n", + bgrt_tbl->version, bgrt_tbl->image_address); + bgrt_tbl->image_address =0 ; + bgrt_tbl->status &= ~1 ; + +return 0 ; +} +#ifdef CONFIG_ACPI_SLEEP #define acpi_fadt_copy_address (dst, src, len) do { \ if (fadt->header.revision >= FADT2_REVISION_ID) \
@@ -653,5 +675,7 @@ int __init acpi_boot_init(void)erst_init (); +acpi_table_parse (ACPI_SIG_BGRT , acpi_invalidate_bgrt); +return 0 ; }
xen/include/acpi/actbl.h +1 -0
@@ -314,6 +314,7 @@ enum acpi_prefered_pm_profiles {#include <acpi/actbl1.h> #include <acpi/actbl2.h> +#include <acpi/actbl3.h> /* * Sizes of the various flavors of FADT. We need to look closely
xen/include/acpi/actbl3.h new file +557 -0
557 lines not on this page · raw message
x86/ACPI: invalidate BGRT if necessary
Since the image pointed to may live in boot services memory (which we add to the global memory pool long before ACPI tables get looked at), we should prevent Dom0 from trying to retrieve the image data in that case.
The alternatives would be to
- not add boot services memory to the global pool at all, or
- defer adding boot services memory until Dom0 indicates it is safe to do so, or
- find and parse the BGRT table in xen/arch/x86/efi/boot.c, and avoid adding that specific region to the E820 table.
None of these are really attractive, and as Xen commonly prints to the video console anyway (without trying to avoid any regions on the screen), the invalidation would need to be done conditionally anyway.
(xen/include/acpi/actbl3.h is a verbatim copy from Linux 3.7-rc4)
---
v2: Only invalidate if the image lives in RAM, and do the invalidation
by clearing both the valid bit and the image address.
xen/arch/x86/acpi/boot.c +24 -0
@@ -28,6 +28,7 @@#include <xen/init.h> #include <xen/acpi.h> #include <xen/irq.h> +#include <xen/mm.h> #include <xen/dmi.h> #include <asm/fixmap.h> #include <asm/page.h>
@@ -286,6 +287,27 @@ static int __init acpi_parse_hpet(struct#define acpi_parse_hpet NULL#endif +static int __init acpi_invalidate_bgrt (struct acpi_table_header *table) +{ +struct acpi_table_bgrt *bgrt_tbl = + container_of(table, struct acpi_table_bgrt, header); + +if (table->length <sizeof (*bgrt_tbl)) +return -1 ; + +if (bgrt_tbl->version ==1 && bgrt_tbl->image_address + && !page_is_ram_type (PFN_DOWN (bgrt_tbl->image_address), +RAM_TYPE_CONVENTIONAL )) +return 0 ; + + printk(KERN_INFO PREFIX "BGRT: invalidating v%d image at %#"PRIx64"\n", + bgrt_tbl->version, bgrt_tbl->image_address); + bgrt_tbl->image_address =0 ; + bgrt_tbl->status &= ~1 ; + +return 0 ; +} +#ifdef CONFIG_ACPI_SLEEP #define acpi_fadt_copy_address (dst, src, len) do { \ if (fadt->header.revision >= FADT2_REVISION_ID) \
@@ -653,5 +675,7 @@ int __init acpi_boot_init(void)erst_init (); +acpi_table_parse (ACPI_SIG_BGRT , acpi_invalidate_bgrt); +return 0 ; }
xen/include/acpi/actbl.h +1 -0
@@ -314,6 +314,7 @@ enum acpi_prefered_pm_profiles {#include <acpi/actbl1.h> #include <acpi/actbl2.h> +#include <acpi/actbl3.h> /* * Sizes of the various flavors of FADT. We need to look closely
xen/include/acpi/actbl3.h new file +557 -0
557 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel