[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 04/16] libxl/arm: Estimate the size of ACPI tables
From: Shannon Zhao <shannon.zhao@xxxxxxxxxx> Estimate the size of ACPI tables and reserve a memory map space for ACPI tables. Signed-off-by: Shannon Zhao <shannon.zhao@xxxxxxxxxx> --- tools/libxl/libxl_arm_acpi.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 087d028..6be9eb0 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -33,12 +33,95 @@ extern const unsigned char dsdt_anycpu_arm[]; _hidden extern const int dsdt_anycpu_arm_len; +enum { + RSDP, + XSDT, + GTDT, + MADT, + FADT, + DSDT, + NUMS, +}; + +struct acpitable { + uint64_t addr; + size_t size; +}; + +static int libxl__estimate_acpi_size(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_dom_image *dom, + xc_domain_configuration_t *xc_config, + struct acpitable acpitables[]) +{ + uint64_t size; + int rc = 0; + + acpitables[RSDP].addr = GUEST_ACPI_BASE; + acpitables[RSDP].size = sizeof(struct acpi_table_rsdp); + dom->acpi_modules[0].length += ROUNDUP(acpitables[RSDP].size, 3); + + acpitables[XSDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length; + /* + * Currently only 3 tables(GTDT, FADT, MADT) are pointed by XSDT. Alloc + * entries for them. + */ + acpitables[XSDT].size = sizeof(struct acpi_table_xsdt) + + sizeof(uint64_t) * 2; + dom->acpi_modules[0].length += ROUNDUP(acpitables[XSDT].size, 3); + + acpitables[GTDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length; + acpitables[GTDT].size = sizeof(struct acpi_table_gtdt); + dom->acpi_modules[0].length += ROUNDUP(acpitables[GTDT].size, 3); + + acpitables[MADT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length; + + switch (xc_config->gic_version) { + case XEN_DOMCTL_CONFIG_GIC_V2: + size = sizeof(struct acpi_table_madt) + + sizeof(struct acpi_madt_generic_interrupt) * info->max_vcpus + + sizeof(struct acpi_madt_generic_distributor); + break; + case XEN_DOMCTL_CONFIG_GIC_V3: + size = sizeof(struct acpi_table_madt) + + sizeof(struct acpi_madt_generic_interrupt) * info->max_vcpus + + sizeof(struct acpi_madt_generic_distributor) + + sizeof(struct acpi_madt_generic_redistributor); + break; + default: + LOG(ERROR, "Unknown GIC version"); + rc = ERROR_FAIL; + goto out; + } + + acpitables[MADT].size = size; + dom->acpi_modules[0].length += ROUNDUP(acpitables[MADT].size, 3); + + acpitables[FADT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length; + acpitables[FADT].size = sizeof(struct acpi_table_fadt); + dom->acpi_modules[0].length += ROUNDUP(acpitables[FADT].size, 3); + + acpitables[DSDT].addr = GUEST_ACPI_BASE + dom->acpi_modules[0].length; + acpitables[DSDT].size = dsdt_anycpu_arm_len; + dom->acpi_modules[0].length += ROUNDUP(acpitables[DSDT].size, 3); + + assert(dom->acpi_modules[0].length <= GUEST_ACPI_SIZE); + dom->acpi_modules[0].data = libxl__zalloc(gc, dom->acpi_modules[0].length); + +out: + return rc; +} + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) { const libxl_version_info *vers; int rc = 0; + struct acpitable acpitables[NUMS]; + + /* convenience aliases */ + xc_domain_configuration_t *xc_config = &state->config; vers = libxl_get_version_info(CTX); if (vers == NULL) { @@ -53,6 +136,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, dom->acpi_modules[0].length = 0; dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE; + rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables); + out: return rc; } -- 2.0.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |