From: Boris Ostrovsky Date: Tue, 9 Aug 2016 15:31:15 +0000 (+0200) Subject: hvmloader: move passthrough initialization from ACPI code X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~582 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=bea437908b27c751012abe14c4312dd4d159ff23;p=xen.git hvmloader: move passthrough initialization from ACPI code Initialize it in hvmloader, avoiding ACPI code's use of xenstore_read() Signed-off-by: Boris Ostrovsky Reviewed-by: Jan Beulich --- diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index e5a63bc181..360dd1c63d 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -287,37 +287,27 @@ static struct acpi_20_slit *construct_slit(void) } static int construct_passthrough_tables(unsigned long *table_ptrs, - int nr_tables) + int nr_tables, + struct acpi_config *config) { - const char *s; - uint8_t *acpi_pt_addr; - uint32_t acpi_pt_length; + unsigned long pt_addr; struct acpi_header *header; int nr_added; int nr_max = (ACPI_MAX_SECONDARY_TABLES - nr_tables - 1); uint32_t total = 0; uint8_t *buffer; - s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL); - if ( s == NULL ) - return 0; - - acpi_pt_addr = (uint8_t*)(uint32_t)strtoll(s, NULL, 0); - if ( acpi_pt_addr == NULL ) - return 0; - - s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL); - if ( s == NULL ) + if ( config->pt.addr == 0 ) return 0; - acpi_pt_length = (uint32_t)strtoll(s, NULL, 0); + pt_addr = config->pt.addr; for ( nr_added = 0; nr_added < nr_max; nr_added++ ) { - if ( (acpi_pt_length - total) < sizeof(struct acpi_header) ) + if ( (config->pt.length - total) < sizeof(struct acpi_header) ) break; - header = (struct acpi_header*)acpi_pt_addr; + header = (struct acpi_header*)pt_addr; buffer = mem_alloc(header->length, 16); if ( buffer == NULL ) @@ -326,7 +316,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs, table_ptrs[nr_tables++] = (unsigned long)buffer; total += header->length; - acpi_pt_addr += header->length; + pt_addr += header->length; } return nr_added; @@ -447,7 +437,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs, } /* Load any additional tables passed through. */ - nr_tables += construct_passthrough_tables(table_ptrs, nr_tables); + nr_tables += construct_passthrough_tables(table_ptrs, nr_tables, config); table_ptrs[nr_tables] = 0; return nr_tables; diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h index c2da152d8e..de4470a307 100644 --- a/tools/firmware/hvmloader/acpi/libacpi.h +++ b/tools/firmware/hvmloader/acpi/libacpi.h @@ -44,6 +44,11 @@ struct acpi_config { uint64_t vm_gid[2]; unsigned long vm_gid_addr; /* OUT parameter */ + struct { + uint32_t addr; + uint32_t length; + } pt; + /* * Address where acpi_info should be placed. * This must match the OperationRegion(BIOS, SystemMemory, ....) diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index f01a3fde3b..b2d3421884 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -27,6 +27,7 @@ #include #include #include +#include #include /* @@ -900,6 +901,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, config->vm_gid[1] = strtoll(end+1, NULL, 0); } + s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL); + if ( s ) + { + config->pt.addr = strtoll(s, NULL, 0); + + s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL); + if ( s ) + config->pt.length = strtoll(s, NULL, 0); + } + if ( battery_port_exists() ) config->table_flags |= ACPI_HAS_SSDT_PM; if ( !strncmp(xenstore_read("platform/acpi_s3", "1"), "1", 1) )