@@ -98,6 +98,7 @@ struct xc_dom_image {
xen_pfn_t xenstore_pfn;
xen_pfn_t shared_info_pfn;
xen_pfn_t bootstack_pfn;
+ xen_pfn_t dm_acpi_pfn;
xen_pfn_t pfn_alloc_end;
xen_vaddr_t virt_alloc_end;
xen_vaddr_t bsd_symtab_start;
@@ -674,6 +674,13 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
ioreq_server_pfn(0));
xc_hvm_param_set(xch, domid, HVM_PARAM_NR_IOREQ_SERVER_PAGES,
NR_IOREQ_SERVER_PAGES);
+
+ dom->dm_acpi_pfn = xc_dom_alloc_page(dom, "DM ACPI");
+ if ( dom->dm_acpi_pfn == INVALID_PFN )
+ {
+ DOMPRINTF("Could not allocate page for device model ACPI.");
+ goto error_out;
+ }
}
rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
@@ -865,6 +865,28 @@ static int hvm_build_set_xs_values(libxl__gc *gc,
goto err;
}
+ if (dom->dm_acpi_pfn) {
+ uint64_t guest_addr_out = dom->dm_acpi_pfn * XC_DOM_PAGE_SIZE(dom);
+
+ if (guest_addr_out >= 0x100000000ULL) {
+ LOG(ERROR,
+ "Guest address of DM ACPI is 0x%"PRIx64", but expected below 4G",
+ guest_addr_out);
+ goto err;
+ }
+
+ path = GCSPRINTF("/local/domain/%d/"HVM_XS_DM_ACPI_ADDRESS, domid);
+ ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%"PRIx64, guest_addr_out);
+ if (ret)
+ goto err;
+
+ path = GCSPRINTF("/local/domain/%d/"HVM_XS_DM_ACPI_LENGTH, domid);
+ ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%"PRIx64,
+ (uint64_t)XC_DOM_PAGE_SIZE(dom));
+ if (ret)
+ goto err;
+ }
+
return 0;
err:
@@ -79,4 +79,15 @@
*/
#define HVM_XS_OEM_STRINGS "bios-strings/oem-%d"
+/* Follows are XenStore keys for DM ACPI (ACPI built by device model,
+ * e.g. QEMU).
+ *
+ * A reserved area of guest physical memory is used to pass DM
+ * ACPI. Values of following two keys specify the base physical
+ * address and length (in bytes) of the reserved area.
+ */
+#define HVM_XS_DM_ACPI_ROOT "hvmloader/dm-acpi"
+#define HVM_XS_DM_ACPI_ADDRESS HVM_XS_DM_ACPI_ROOT"/address"
+#define HVM_XS_DM_ACPI_LENGTH HVM_XS_DM_ACPI_ROOT"/length"
+
#endif /* __XEN_PUBLIC_HVM_HVM_XS_STRINGS_H__ */
Some virtual devices (e.g. NVDIMM) require complex ACPI tables and definition blocks (in AML), which a device model (e.g. QEMU) has already been able to construct. Instead of introducing the similar implementation to Xen, we would like to reuse the device model to provide those ACPI stuffs. This commit reserves an area in the guest memory for the device model to pass its ACPI tables and definition blocks to guest, which will be loaded by hvmloader. The base guest physical address and the size of the reserved area are passed to the device model via XenStore keys hvmloader/dm-acpi/{address, length}. Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> --- Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> --- tools/libxc/include/xc_dom.h | 1 + tools/libxc/xc_dom_x86.c | 7 +++++++ tools/libxl/libxl_dom.c | 22 ++++++++++++++++++++++ xen/include/public/hvm/hvm_xs_strings.h | 11 +++++++++++ 4 files changed, 41 insertions(+)