On Fri, 7 Apr 2017 15:41:38 +0100 Ard Biesheuvel <ard.biesheu...@linaro.org> wrote:
> Our current ACPI table generation code limits the placement of ACPI > tables to 32-bit addressable memory, in order to be able to emit the > root pointer (RSDP) and root table (RSDT) using table types from the > ACPI 1.0 days. > > Since ARM was not supported by ACPI before version 5.0, it makes sense > to lift this restriction. This is not crucial for mach-virt, which is > guaranteed to have some memory available below the 4 GB mark, but it > is a nice to have for QEMU machines that do not have any 32-bit > addressable memory, which is not uncommon for real world 64-bit ARM > systems. > > Since we already emit a version of the RSDP root pointer that has a > secondary 64-bit wide address field for the 64-bit root table (XSDT), > all we need to do is replace the RSDT generation with the generation > of an XSDT table, and use a different slot in the FADT table to refer > to the DSDT. > > Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org> > Reviewed-by: Andrew Jones <drjo...@redhat.com> > Acked-by: Laszlo Ersek <ler...@redhat.com> > --- > v2: - move new build_xsdt() function to hw/acpi/aml-build.c > - tweak commit log text > - add Drew's and Laszlo's acks > > hw/acpi/aml-build.c | 27 ++++++++++++++++++++ > hw/arm/virt-acpi-build.c | 26 +++++++++---------- > include/hw/acpi/acpi-defs.h | 11 ++++++++ > include/hw/acpi/aml-build.h | 3 +++ > 4 files changed, 54 insertions(+), 13 deletions(-) > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c > index c6f2032decb1..4ddfb68b247f 100644 > --- a/hw/acpi/aml-build.c > +++ b/hw/acpi/aml-build.c > @@ -1599,6 +1599,33 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, > GArray *table_offsets, > (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id); > } > > +/* Build xsdt table */ > +void > +build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, > + const char *oem_id, const char *oem_table_id) > +{ > + int i; > + unsigned xsdt_entries_offset; > + AcpiXsdtDescriptorRev2 *xsdt; > + const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len); > + const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]); nit, I know it was mostly copy/paste but how about: const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]); const unsigned table_data_len = xsdt_entry_size * table_offsets->len; > + const size_t xsdt_len = sizeof(*xsdt) + table_data_len; > + > + xsdt = acpi_data_push(table_data, xsdt_len); > + xsdt_entries_offset = (char *)xsdt->table_offset_entry - > table_data->data; > + for (i = 0; i < table_offsets->len; ++i) { > + uint64_t ref_tbl_offset = g_array_index(table_offsets, uint32_t, i); > + uint64_t xsdt_entry_offset = xsdt_entries_offset + xsdt_entry_size * > i; > + > + /* xsdt->table_offset_entry to be filled by Guest linker */ > + bios_linker_loader_add_pointer(linker, > + ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, xsdt_entry_size, > + ACPI_BUILD_TABLE_FILE, ref_tbl_offset); > + } > + build_header(linker, table_data, > + (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id); > +} > + The rest looks fine to me, so with above fixup Reviewed-by: Igor Mammedov <imamm...@redhat.com>