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

[Xen-devel] [RFC QEMU PATCH 4/8] nvdimm acpi: build and copy NFIT to guest on Xen



Build and copy NFIT to guest when QEMU is used as the device model of
Xen. The checksum of NFIT is left blank and will be filled by Xen
hvmloader.

Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
---
Cc: "Michael S. Tsirkin" <mst@xxxxxxxxxx>
Cc: Igor Mammedov <imammedo@xxxxxxxxxx>
Cc: Xiao Guangrong <guangrong.xiao@xxxxxxxxxxxxxxx>
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: Richard Henderson <rth@xxxxxxxxxxx>
Cc: Eduardo Habkost <ehabkost@xxxxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
---
 hw/acpi/aml-build.c  |  9 ++++++---
 hw/acpi/nvdimm.c     |  8 ++++++++
 hw/i386/pc.c         | 12 ++++++++----
 include/hw/xen/xen.h |  2 ++
 xen-hvm.c            | 21 ++++++++++++++++++++-
 5 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index b2a1e40..a749b62 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1530,9 +1530,12 @@ build_header(BIOSLinker *linker, GArray *table_data,
     h->oem_revision = cpu_to_le32(1);
     memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
     h->asl_compiler_revision = cpu_to_le32(1);
-    /* Checksum to be filled in by Guest linker */
-    bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
-        tbl_offset, len, checksum_offset);
+    /* No linker is provided when running on Xen */
+    if (linker) {
+        /* Checksum to be filled in by Guest linker */
+        bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
+                                        tbl_offset, len, checksum_offset);
+    }
 }
 
 void *acpi_data_push(GArray *table_data, unsigned size)
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index c9c2a84..6de2301 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -32,6 +32,7 @@
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/mem/nvdimm.h"
+#include "hw/xen/xen.h"
 
 static int nvdimm_plugged_device_list(Object *obj, void *opaque)
 {
@@ -389,6 +390,13 @@ static void nvdimm_build_nfit(GSList *device_list, GArray 
*table_offsets,
     build_header(linker, table_data,
                  (void *)(table_data->data + header), "NFIT",
                  sizeof(NvdimmNfitHeader) + structures->len, 1, NULL, NULL);
+
+    if (xen_enabled()) {
+        xen_acpi_copy_to_guest("NFIT", table_data->data + header,
+                               sizeof(NvdimmNfitHeader) + structures->len,
+                               XEN_ACPI_TABLE);
+    }
+
     g_array_free(structures, true);
 }
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2d6d792..33be032 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1269,10 +1269,14 @@ void pc_machine_done(Notifier *notifier, void *data)
         }
     }
 
-    acpi_setup();
-    if (pcms->fw_cfg) {
-        pc_build_smbios(pcms->fw_cfg);
-        pc_build_feature_control_file(pcms);
+    if (xen_enabled()) {
+        xen_acpi_setup(pcms);
+    } else {
+        acpi_setup();
+        if (pcms->fw_cfg) {
+            pc_build_smbios(pcms->fw_cfg);
+            pc_build_feature_control_file(pcms);
+        }
     }
 }
 
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 79273da..60344f9 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -47,6 +47,8 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length);
 
 void xen_register_framebuffer(struct MemoryRegion *mr);
 
+void xen_acpi_setup(PCMachineState *pcms);
+
 #define XEN_ACPI_TABLE 0
 #define XEN_ACPI_NSDEV 1
 
diff --git a/xen-hvm.c b/xen-hvm.c
index 168a9ec..768c4c2 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -1244,7 +1244,7 @@ static ram_addr_t guest_acpi_buf_alloc(size_t length)
 
 static int xen_acpi_needed(PCMachineState *pcms)
 {
-    return 0;
+    return pcms->acpi_nvdimm_state.is_enabled;
 }
 
 static int xen_acpi_init(PCMachineState *pcms, XenIOState *state)
@@ -1256,6 +1256,25 @@ static int xen_acpi_init(PCMachineState *pcms, 
XenIOState *state)
     return guest_acpi_buf_init(state);
 }
 
+static void xen_acpi_nvdimm_setup(PCMachineState *pcms)
+{
+    GArray *table_offsets = g_array_new(false, true /* clear */,
+                                        sizeof(uint32_t));
+    GArray *table_data = g_array_new(false, true /* clear */, 1);
+
+    nvdimm_build_acpi(table_offsets, table_data,
+                      NULL, pcms->acpi_nvdimm_state.dsm_mem);
+    g_array_free(table_offsets, true);
+    g_array_free(table_data, true);
+}
+
+void xen_acpi_setup(PCMachineState *pcms)
+{
+    if (pcms->acpi_nvdimm_state.is_enabled) {
+        xen_acpi_nvdimm_setup(pcms);
+    }
+}
+
 void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
 {
     int i, rc;
-- 
2.10.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®.