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

[Xen-devel] [PATCH v2 05/23] acpi/hvmloader: Move passthrough initialization from ACPI code



Initialize it in hvmloader, avoiding ACPI code's use of xenstore_read()

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
v2:
* Dropped pt_ prefix
* Slight change in construct_passthrough_tables() code (thus dropped Jan's R-b)

 tools/firmware/hvmloader/acpi/build.c   | 28 +++++++++-------------------
 tools/firmware/hvmloader/acpi/libacpi.h |  5 +++++
 tools/firmware/hvmloader/util.c         | 11 +++++++++++
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c 
b/tools/firmware/hvmloader/acpi/build.c
index a5750eb..8ca7e69 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -285,37 +285,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 )
@@ -324,7 +314,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;
@@ -445,7 +435,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 f397a93..22fd5f6 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 61fc211..d61aea6 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -27,6 +27,7 @@
 #include <xen/xen.h>
 #include <xen/memory.h>
 #include <xen/sched.h>
+#include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
 /*
@@ -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)  )
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.