[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] libxl, hvmloader: Don't relocate memory for MMIO hole
At the moment, qemu-xen can't handle memory being relocated by hvmloader. This may happen if a device with a large enough memory region is passed through to the guest. At the moment, if this happens, then at some point in the future qemu will crash and the domain will hang. (qemu-traditional is fine.) It's too late in the release to do a proper fix, so we try to do damage control. hvmloader already has mechanisms to relocate memory to 64-bit space if it can't make a big enough MMIO hole. By default this is 2GiB; if we just refuse to make the hole bigger if it will overlap with guest memory, then this codepath will be taken by default. Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx> CC: Ian Campbell <ian.campbell@xxxxxxxxxx> CC: Ian Jackson <ian.jackson@xxxxxxxxxx> CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx> CC: Hanweidong <hanweidong@xxxxxxxxxx> --- tools/firmware/hvmloader/pci.c | 24 +++++++++++++++++++++--- tools/libxl/libxl_dm.c | 7 +++++++ xen/include/public/hvm/hvm_xs_strings.h | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c index c78d4d3..9682a1f 100644 --- a/tools/firmware/hvmloader/pci.c +++ b/tools/firmware/hvmloader/pci.c @@ -27,6 +27,7 @@ #include <xen/memory.h> #include <xen/hvm/ioreq.h> +#include <xen/hvm/hvm_xs_strings.h> unsigned long pci_mem_start = PCI_MEM_START; unsigned long pci_mem_end = PCI_MEM_END; @@ -58,6 +59,15 @@ void pci_setup(void) } *bars = (struct bars *)scratch_start; unsigned int i, nr_bars = 0; + const char *s; + uint8_t allow_memory_relocate=1; + + s = xenstore_read(HVM_XS_ALLOW_MEMORY_RELOCATE, NULL); + if (s) + allow_memory_relocate=(uint8_t)strtoll(s, NULL, 0); + printf("allow_memory_relocate %u\n", + __func__, allow_memory_relocate); + /* Program PCI-ISA bridge with appropriate link routes. */ isa_irq = 0; for ( link = 0; link < 4; link++ ) @@ -209,11 +219,19 @@ void pci_setup(void) pci_writew(devfn, PCI_COMMAND, cmd); } - while ( (mmio_total > (pci_mem_end - pci_mem_start)) && - ((pci_mem_start << 1) != 0) ) + /* + * At the moment qemu-xen can't deal with relocated memory regions. + * It's too close to the release to make a proper fix; for now, + * if we're using qemu-xen, just crash and tell people to switch + * to qemu-traditional. + */ + while ((mmio_total > (pci_mem_end - pci_mem_start)) + && ((pci_mem_start << 1) != 0) + && ( allow_memory_relocate + || (((pci_mem_start << 1)>>PAGE_SHIFT )<hvm_info->low_mem_pgend)) pci_mem_start <<= 1; - if ( (pci_mem_start << 1) != 0 ) + if (mmio_total > (pci_mem_end - pci_mem_start)) bar64_relocate = 1; /* Relocate RAM that overlaps PCI space (in 64k-page chunks). */ diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index ac1f90e..5167ee0 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1154,6 +1154,13 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/hvmloader/bios", path), "%s", libxl_bios_type_to_string(b_info->u.hvm.bios)); + /* Disable relocating memory to make the MMIO hole larger unless we're + * running qemu-traditional */ + libxl__xs_write(gc, XBT_NULL, + libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate", path), + "%s", + (b_info->device_model_version==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL)? + "1":"0"); free(path); } diff --git a/xen/include/public/hvm/hvm_xs_strings.h b/xen/include/public/hvm/hvm_xs_strings.h index 9042303..4de5881 100644 --- a/xen/include/public/hvm/hvm_xs_strings.h +++ b/xen/include/public/hvm/hvm_xs_strings.h @@ -28,6 +28,7 @@ #define HVM_XS_HVMLOADER "hvmloader" #define HVM_XS_BIOS "hvmloader/bios" #define HVM_XS_GENERATION_ID_ADDRESS "hvmloader/generation-id-address" +#define HVM_XS_ALLOW_MEMORY_RELOCATE "hvmloader/allow-memory-relocate" /* The following values allow additional ACPI tables to be added to the * virtual ACPI BIOS that hvmloader constructs. The values specify the guest -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |