qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH V2 2/4] pc: acpi-build: place RSDT at fixed offset a


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH V2 2/4] pc: acpi-build: place RSDT at fixed offset across reboots
Date: Thu, 11 Dec 2014 15:36:59 +0000

Fixing RSDT location allows pointer to RSDP
be constant and we can keep RSDP file immutable
for the whole instance lifetime.

Which makes this fix suitable for stable, since
migration format doesn't change in addition it
fixes old machine types as well without breaking
compatibility.

Signed-off-by: Igor Mammedov <address@hidden>
---
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4d2b3b9..4b0bc44 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1431,16 +1431,23 @@ build_dsdt(GArray *table_data, GArray *linker, 
AcpiMiscInfo *misc)
                  misc->dsdt_size, 1);
 }
 
-/* Build final rsdt table */
-static void
-build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
+/* reserve space for RSDT */
+static void alloc_rsdt(GArray *table_data, int tables_count)
 {
-    AcpiRsdtDescriptorRev1 *rsdt;
     size_t rsdt_len;
+
+    rsdt_len = sizeof(AcpiRsdtDescriptorRev1) + sizeof(uint32_t) * 
tables_count;
+    acpi_data_push(table_data, rsdt_len);
+}
+
+/* fill final rsdt table */
+static void fill_rsdt(GArray *table_data, GArray *linker,
+                      unsigned rsdt_offset, GArray *table_offsets)
+{
     int i;
+    AcpiRsdtDescriptorRev1 *rsdt = (void *)(table_data->data + rsdt_offset);
+    size_t rsdt_len = sizeof(*rsdt) + sizeof(uint32_t) * table_offsets->len;
 
-    rsdt_len = sizeof(*rsdt) + sizeof(uint32_t) * table_offsets->len;
-    rsdt = acpi_data_push(table_data, rsdt_len);
     memcpy(rsdt->table_offset_entry, table_offsets->data,
            sizeof(uint32_t) * table_offsets->len);
     for (i = 0; i < table_offsets->len; ++i) {
@@ -1562,6 +1569,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables 
*tables)
     PcPciInfo pci;
     uint8_t *u;
     size_t aml_len = 0;
+    int tables_count = 0;
 
     acpi_get_cpu_info(&cpu);
     acpi_get_pm_info(&pm);
@@ -1594,6 +1602,23 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables 
*tables)
      */
     aml_len += tables->table_data->len - dsdt;
 
+    /* preallocate RSDT at fixed position to keep its offset
+     * constant accorss reboots since FACS and DSDT are static.
+     * This way RSDP referencing it could be kept immutable.
+     */
+    tables_count = 1 /* FADT */ + 1 /* SSDT */ + 1 /* MADT */
+        + (misc.has_hpet ? 1 : 0)
+        + (misc.has_tpm ? 2 : 0)
+        + (guest_info->numa_nodes ? 1 : 0)
+        + (acpi_get_mcfg(&mcfg) ? 1 : 0)
+        + (acpi_has_iommu() ? 1 : 0);
+    for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
+        tables_count++;
+    }
+    rsdt = tables->table_data->len;
+    alloc_rsdt(tables->table_data, tables_count);
+
+
     /* ACPI tables pointed to by RSDT */
     acpi_add_table(table_offsets, tables->table_data);
     build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt);
@@ -1640,8 +1665,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables 
*tables)
     }
 
     /* RSDT is pointed to by RSDP */
-    rsdt = tables->table_data->len;
-    build_rsdt(tables->table_data, tables->linker, table_offsets);
+    fill_rsdt(tables->table_data, tables->linker, rsdt, table_offsets);
 
     /* RSDP is in FSEG memory, so allocate it separately */
     build_rsdp(tables->rsdp, tables->linker, rsdt);
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]