193d43e7eSAnthony Xu /* 293d43e7eSAnthony Xu * Copyright (C) 2010 Citrix Ltd. 393d43e7eSAnthony Xu * 493d43e7eSAnthony Xu * This work is licensed under the terms of the GNU GPL, version 2. See 593d43e7eSAnthony Xu * the COPYING file in the top-level directory. 693d43e7eSAnthony Xu * 793d43e7eSAnthony Xu * Contributions after 2012-01-13 are licensed under the terms of the 893d43e7eSAnthony Xu * GNU GPL, version 2 or (at your option) any later version. 993d43e7eSAnthony Xu */ 1093d43e7eSAnthony Xu 1193d43e7eSAnthony Xu #include "qemu/osdep.h" 12039a93b0SPhilippe Mathieu-Daudé #include "qemu/units.h" 13e688df6bSMarkus Armbruster #include "qapi/error.h" 1428af9ba2SPhilippe Mathieu-Daudé #include "qapi/qapi-commands-migration.h" 1593d43e7eSAnthony Xu #include "trace.h" 1693d43e7eSAnthony Xu 17f17068c1SStefano Stabellini #include "hw/i386/pc.h" 18f17068c1SStefano Stabellini #include "hw/irq.h" 19f17068c1SStefano Stabellini #include "hw/i386/apic-msidef.h" 20f17068c1SStefano Stabellini #include "hw/xen/xen-x86.h" 21f17068c1SStefano Stabellini #include "qemu/range.h" 22f17068c1SStefano Stabellini 23f17068c1SStefano Stabellini #include "hw/xen/xen-hvm-common.h" 24f17068c1SStefano Stabellini #include "hw/xen/arch_hvm.h" 2593d43e7eSAnthony Xu #include <xen/hvm/e820.h> 2693d43e7eSAnthony Xu 27f17068c1SStefano Stabellini static MemoryRegion ram_640k, ram_lo, ram_hi; 2893d43e7eSAnthony Xu static MemoryRegion *framebuffer; 2993d43e7eSAnthony Xu static bool xen_in_migration; 3093d43e7eSAnthony Xu 3193d43e7eSAnthony Xu /* Compatibility with older version */ 3293d43e7eSAnthony Xu 33e2abfe5eSDavid Woodhouse /* 34e2abfe5eSDavid Woodhouse * This allows QEMU to build on a system that has Xen 4.5 or earlier installed. 35e2abfe5eSDavid Woodhouse * This is here (not in hw/xen/xen_native.h) because xen/hvm/ioreq.h needs to 36e2abfe5eSDavid Woodhouse * be included before this block and hw/xen/xen_native.h needs to be included 37e2abfe5eSDavid Woodhouse * before xen/hvm/ioreq.h 3893d43e7eSAnthony Xu */ 3993d43e7eSAnthony Xu #ifndef IOREQ_TYPE_VMWARE_PORT 4093d43e7eSAnthony Xu #define IOREQ_TYPE_VMWARE_PORT 3 4193d43e7eSAnthony Xu struct vmware_regs { 4293d43e7eSAnthony Xu uint32_t esi; 4393d43e7eSAnthony Xu uint32_t edi; 4493d43e7eSAnthony Xu uint32_t ebx; 4593d43e7eSAnthony Xu uint32_t ecx; 4693d43e7eSAnthony Xu uint32_t edx; 4793d43e7eSAnthony Xu }; 4893d43e7eSAnthony Xu typedef struct vmware_regs vmware_regs_t; 4993d43e7eSAnthony Xu 5093d43e7eSAnthony Xu struct shared_vmport_iopage { 5193d43e7eSAnthony Xu struct vmware_regs vcpu_vmport_regs[1]; 5293d43e7eSAnthony Xu }; 5393d43e7eSAnthony Xu typedef struct shared_vmport_iopage shared_vmport_iopage_t; 5493d43e7eSAnthony Xu #endif 55f17068c1SStefano Stabellini 569269b9d1SStefano Stabellini static shared_vmport_iopage_t *shared_vmport_page; 5793d43e7eSAnthony Xu 5804a8f72eSIgor Druzhinin static QLIST_HEAD(, XenPhysmap) xen_physmap; 599269b9d1SStefano Stabellini static const XenPhysmap *log_for_dirtybit; 609269b9d1SStefano Stabellini /* Buffer used by xen_sync_dirty_bitmap */ 619269b9d1SStefano Stabellini static unsigned long *dirty_bitmap; 629269b9d1SStefano Stabellini static Notifier suspend; 639269b9d1SStefano Stabellini static Notifier wakeup; 6404a8f72eSIgor Druzhinin 6593d43e7eSAnthony Xu /* Xen specific function for piix pci */ 6693d43e7eSAnthony Xu 6793d43e7eSAnthony Xu int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) 6893d43e7eSAnthony Xu { 698d40def6SPhilippe Mathieu-Daudé return irq_num + (PCI_SLOT(pci_dev->devfn) << 2); 7093d43e7eSAnthony Xu } 7193d43e7eSAnthony Xu 7227047bd2SBernhard Beschow void xen_intx_set_irq(void *opaque, int irq_num, int level) 7393d43e7eSAnthony Xu { 7493d43e7eSAnthony Xu xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2, 7593d43e7eSAnthony Xu irq_num & 3, level); 7693d43e7eSAnthony Xu } 7793d43e7eSAnthony Xu 7821d87050SBernhard Beschow int xen_set_pci_link_route(uint8_t link, uint8_t irq) 7921d87050SBernhard Beschow { 8021d87050SBernhard Beschow return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, irq); 8121d87050SBernhard Beschow } 8221d87050SBernhard Beschow 8393d43e7eSAnthony Xu int xen_is_pirq_msi(uint32_t msi_data) 8493d43e7eSAnthony Xu { 8593d43e7eSAnthony Xu /* If vector is 0, the msi is remapped into a pirq, passed as 8693d43e7eSAnthony Xu * dest_id. 8793d43e7eSAnthony Xu */ 8893d43e7eSAnthony Xu return ((msi_data & MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT) == 0; 8993d43e7eSAnthony Xu } 9093d43e7eSAnthony Xu 9193d43e7eSAnthony Xu void xen_hvm_inject_msi(uint64_t addr, uint32_t data) 9293d43e7eSAnthony Xu { 9393d43e7eSAnthony Xu xen_inject_msi(xen_domid, addr, data); 9493d43e7eSAnthony Xu } 9593d43e7eSAnthony Xu 9693d43e7eSAnthony Xu static void xen_suspend_notifier(Notifier *notifier, void *data) 9793d43e7eSAnthony Xu { 9893d43e7eSAnthony Xu xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 3); 9993d43e7eSAnthony Xu } 10093d43e7eSAnthony Xu 10193d43e7eSAnthony Xu /* Xen Interrupt Controller */ 10293d43e7eSAnthony Xu 10393d43e7eSAnthony Xu static void xen_set_irq(void *opaque, int irq, int level) 10493d43e7eSAnthony Xu { 10593d43e7eSAnthony Xu xen_set_isa_irq_level(xen_domid, irq, level); 10693d43e7eSAnthony Xu } 10793d43e7eSAnthony Xu 10893d43e7eSAnthony Xu qemu_irq *xen_interrupt_controller_init(void) 10993d43e7eSAnthony Xu { 11093d43e7eSAnthony Xu return qemu_allocate_irqs(xen_set_irq, NULL, 16); 11193d43e7eSAnthony Xu } 11293d43e7eSAnthony Xu 11393d43e7eSAnthony Xu /* Memory Ops */ 11493d43e7eSAnthony Xu 11593d43e7eSAnthony Xu static void xen_ram_init(PCMachineState *pcms, 11693d43e7eSAnthony Xu ram_addr_t ram_size, MemoryRegion **ram_memory_p) 11793d43e7eSAnthony Xu { 118f0bb276bSPaolo Bonzini X86MachineState *x86ms = X86_MACHINE(pcms); 11993d43e7eSAnthony Xu MemoryRegion *sysmem = get_system_memory(); 12093d43e7eSAnthony Xu ram_addr_t block_len; 121f0bb276bSPaolo Bonzini uint64_t user_lowmem = 122f0bb276bSPaolo Bonzini object_property_get_uint(qdev_get_machine(), 1239a45729dSGerd Hoffmann PC_MACHINE_MAX_RAM_BELOW_4G, 12493d43e7eSAnthony Xu &error_abort); 12593d43e7eSAnthony Xu 12693d43e7eSAnthony Xu /* Handle the machine opt max-ram-below-4g. It is basically doing 12793d43e7eSAnthony Xu * min(xen limit, user limit). 12893d43e7eSAnthony Xu */ 12993d43e7eSAnthony Xu if (!user_lowmem) { 13093d43e7eSAnthony Xu user_lowmem = HVM_BELOW_4G_RAM_END; /* default */ 13193d43e7eSAnthony Xu } 13293d43e7eSAnthony Xu if (HVM_BELOW_4G_RAM_END <= user_lowmem) { 13393d43e7eSAnthony Xu user_lowmem = HVM_BELOW_4G_RAM_END; 13493d43e7eSAnthony Xu } 13593d43e7eSAnthony Xu 13693d43e7eSAnthony Xu if (ram_size >= user_lowmem) { 137f0bb276bSPaolo Bonzini x86ms->above_4g_mem_size = ram_size - user_lowmem; 138f0bb276bSPaolo Bonzini x86ms->below_4g_mem_size = user_lowmem; 13993d43e7eSAnthony Xu } else { 140f0bb276bSPaolo Bonzini x86ms->above_4g_mem_size = 0; 141f0bb276bSPaolo Bonzini x86ms->below_4g_mem_size = ram_size; 14293d43e7eSAnthony Xu } 143f0bb276bSPaolo Bonzini if (!x86ms->above_4g_mem_size) { 14493d43e7eSAnthony Xu block_len = ram_size; 14593d43e7eSAnthony Xu } else { 14693d43e7eSAnthony Xu /* 14793d43e7eSAnthony Xu * Xen does not allocate the memory continuously, it keeps a 14893d43e7eSAnthony Xu * hole of the size computed above or passed in. 14993d43e7eSAnthony Xu */ 150039a93b0SPhilippe Mathieu-Daudé block_len = (4 * GiB) + x86ms->above_4g_mem_size; 15193d43e7eSAnthony Xu } 152b934c3faSPhilippe Mathieu-Daudé memory_region_init_ram(&xen_memory, NULL, "xen.ram", block_len, 15393d43e7eSAnthony Xu &error_fatal); 154b934c3faSPhilippe Mathieu-Daudé *ram_memory_p = &xen_memory; 15593d43e7eSAnthony Xu 15693d43e7eSAnthony Xu memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k", 157b934c3faSPhilippe Mathieu-Daudé &xen_memory, 0, 0xa0000); 15893d43e7eSAnthony Xu memory_region_add_subregion(sysmem, 0, &ram_640k); 15993d43e7eSAnthony Xu /* Skip of the VGA IO memory space, it will be registered later by the VGA 16093d43e7eSAnthony Xu * emulated device. 16193d43e7eSAnthony Xu * 16293d43e7eSAnthony Xu * The area between 0xc0000 and 0x100000 will be used by SeaBIOS to load 16393d43e7eSAnthony Xu * the Options ROM, so it is registered here as RAM. 16493d43e7eSAnthony Xu */ 16593d43e7eSAnthony Xu memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", 166b934c3faSPhilippe Mathieu-Daudé &xen_memory, 0xc0000, 167f0bb276bSPaolo Bonzini x86ms->below_4g_mem_size - 0xc0000); 16893d43e7eSAnthony Xu memory_region_add_subregion(sysmem, 0xc0000, &ram_lo); 169f0bb276bSPaolo Bonzini if (x86ms->above_4g_mem_size > 0) { 17093d43e7eSAnthony Xu memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", 171b934c3faSPhilippe Mathieu-Daudé &xen_memory, 0x100000000ULL, 172f0bb276bSPaolo Bonzini x86ms->above_4g_mem_size); 17393d43e7eSAnthony Xu memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi); 17493d43e7eSAnthony Xu } 17593d43e7eSAnthony Xu } 17693d43e7eSAnthony Xu 177*8ebb8682SPhilippe Mathieu-Daudé static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size, 178*8ebb8682SPhilippe Mathieu-Daudé int page_mask) 17993d43e7eSAnthony Xu { 18093d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 18193d43e7eSAnthony Xu 182*8ebb8682SPhilippe Mathieu-Daudé start_addr &= page_mask; 18393d43e7eSAnthony Xu 18404a8f72eSIgor Druzhinin QLIST_FOREACH(physmap, &xen_physmap, list) { 18593d43e7eSAnthony Xu if (range_covers_byte(physmap->start_addr, physmap->size, start_addr)) { 18693d43e7eSAnthony Xu return physmap; 18793d43e7eSAnthony Xu } 18893d43e7eSAnthony Xu } 18993d43e7eSAnthony Xu return NULL; 19093d43e7eSAnthony Xu } 19193d43e7eSAnthony Xu 192*8ebb8682SPhilippe Mathieu-Daudé static hwaddr xen_phys_offset_to_gaddr(hwaddr phys_offset, ram_addr_t size, 193*8ebb8682SPhilippe Mathieu-Daudé int page_mask) 19493d43e7eSAnthony Xu { 195*8ebb8682SPhilippe Mathieu-Daudé hwaddr addr = phys_offset & page_mask; 19693d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 19793d43e7eSAnthony Xu 19804a8f72eSIgor Druzhinin QLIST_FOREACH(physmap, &xen_physmap, list) { 19993d43e7eSAnthony Xu if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) { 20004a8f72eSIgor Druzhinin return physmap->start_addr + (phys_offset - physmap->phys_offset); 20193d43e7eSAnthony Xu } 20293d43e7eSAnthony Xu } 20393d43e7eSAnthony Xu 20404a8f72eSIgor Druzhinin return phys_offset; 20593d43e7eSAnthony Xu } 20693d43e7eSAnthony Xu 20704a8f72eSIgor Druzhinin #ifdef XEN_COMPAT_PHYSMAP 208697b66d0SIgor Druzhinin static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) 209697b66d0SIgor Druzhinin { 210697b66d0SIgor Druzhinin char path[80], value[17]; 211697b66d0SIgor Druzhinin 212697b66d0SIgor Druzhinin snprintf(path, sizeof(path), 213697b66d0SIgor Druzhinin "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr", 214697b66d0SIgor Druzhinin xen_domid, (uint64_t)physmap->phys_offset); 215697b66d0SIgor Druzhinin snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->start_addr); 216697b66d0SIgor Druzhinin if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { 217697b66d0SIgor Druzhinin return -1; 218697b66d0SIgor Druzhinin } 219697b66d0SIgor Druzhinin snprintf(path, sizeof(path), 220697b66d0SIgor Druzhinin "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size", 221697b66d0SIgor Druzhinin xen_domid, (uint64_t)physmap->phys_offset); 222697b66d0SIgor Druzhinin snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->size); 223697b66d0SIgor Druzhinin if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { 224697b66d0SIgor Druzhinin return -1; 225697b66d0SIgor Druzhinin } 226697b66d0SIgor Druzhinin if (physmap->name) { 227697b66d0SIgor Druzhinin snprintf(path, sizeof(path), 228697b66d0SIgor Druzhinin "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name", 229697b66d0SIgor Druzhinin xen_domid, (uint64_t)physmap->phys_offset); 230697b66d0SIgor Druzhinin if (!xs_write(state->xenstore, 0, path, 231697b66d0SIgor Druzhinin physmap->name, strlen(physmap->name))) { 232697b66d0SIgor Druzhinin return -1; 233697b66d0SIgor Druzhinin } 234697b66d0SIgor Druzhinin } 235697b66d0SIgor Druzhinin return 0; 236697b66d0SIgor Druzhinin } 237331b5189SIgor Druzhinin #else 238331b5189SIgor Druzhinin static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) 239331b5189SIgor Druzhinin { 240331b5189SIgor Druzhinin return 0; 241331b5189SIgor Druzhinin } 242331b5189SIgor Druzhinin #endif 243697b66d0SIgor Druzhinin 24493d43e7eSAnthony Xu static int xen_add_to_physmap(XenIOState *state, 24593d43e7eSAnthony Xu hwaddr start_addr, 24693d43e7eSAnthony Xu ram_addr_t size, 24793d43e7eSAnthony Xu MemoryRegion *mr, 24893d43e7eSAnthony Xu hwaddr offset_within_region) 24993d43e7eSAnthony Xu { 2502cbf8903SRoss Lagerwall unsigned long nr_pages; 25193d43e7eSAnthony Xu int rc = 0; 25293d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 25393d43e7eSAnthony Xu hwaddr pfn, start_gpfn; 25493d43e7eSAnthony Xu hwaddr phys_offset = memory_region_get_ram_addr(mr); 25593d43e7eSAnthony Xu const char *mr_name; 25693d43e7eSAnthony Xu 257*8ebb8682SPhilippe Mathieu-Daudé if (get_physmapping(start_addr, size, TARGET_PAGE_MASK)) { 25893d43e7eSAnthony Xu return 0; 25993d43e7eSAnthony Xu } 26093d43e7eSAnthony Xu if (size <= 0) { 26193d43e7eSAnthony Xu return -1; 26293d43e7eSAnthony Xu } 26393d43e7eSAnthony Xu 26493d43e7eSAnthony Xu /* Xen can only handle a single dirty log region for now and we want 26593d43e7eSAnthony Xu * the linear framebuffer to be that region. 26693d43e7eSAnthony Xu * Avoid tracking any regions that is not videoram and avoid tracking 26793d43e7eSAnthony Xu * the legacy vga region. */ 26893d43e7eSAnthony Xu if (mr == framebuffer && start_addr > 0xbffff) { 26993d43e7eSAnthony Xu goto go_physmap; 27093d43e7eSAnthony Xu } 27193d43e7eSAnthony Xu return -1; 27293d43e7eSAnthony Xu 27393d43e7eSAnthony Xu go_physmap: 27493d43e7eSAnthony Xu DPRINTF("mapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx"\n", 27593d43e7eSAnthony Xu start_addr, start_addr + size); 27693d43e7eSAnthony Xu 277331b5189SIgor Druzhinin mr_name = memory_region_name(mr); 278331b5189SIgor Druzhinin 279b21e2380SMarkus Armbruster physmap = g_new(XenPhysmap, 1); 280331b5189SIgor Druzhinin 281331b5189SIgor Druzhinin physmap->start_addr = start_addr; 282331b5189SIgor Druzhinin physmap->size = size; 283331b5189SIgor Druzhinin physmap->name = mr_name; 284331b5189SIgor Druzhinin physmap->phys_offset = phys_offset; 285331b5189SIgor Druzhinin 28604a8f72eSIgor Druzhinin QLIST_INSERT_HEAD(&xen_physmap, physmap, list); 287331b5189SIgor Druzhinin 288331b5189SIgor Druzhinin if (runstate_check(RUN_STATE_INMIGRATE)) { 289331b5189SIgor Druzhinin /* Now when we have a physmap entry we can replace a dummy mapping with 290331b5189SIgor Druzhinin * a real one of guest foreign memory. */ 291331b5189SIgor Druzhinin uint8_t *p = xen_replace_cache_entry(phys_offset, start_addr, size); 292331b5189SIgor Druzhinin assert(p && p == memory_region_get_ram_ptr(mr)); 293331b5189SIgor Druzhinin 294331b5189SIgor Druzhinin return 0; 295331b5189SIgor Druzhinin } 296331b5189SIgor Druzhinin 29793d43e7eSAnthony Xu pfn = phys_offset >> TARGET_PAGE_BITS; 29893d43e7eSAnthony Xu start_gpfn = start_addr >> TARGET_PAGE_BITS; 2992cbf8903SRoss Lagerwall nr_pages = size >> TARGET_PAGE_BITS; 3002cbf8903SRoss Lagerwall rc = xendevicemodel_relocate_memory(xen_dmod, xen_domid, nr_pages, pfn, 3012cbf8903SRoss Lagerwall start_gpfn); 30293d43e7eSAnthony Xu if (rc) { 3032cbf8903SRoss Lagerwall int saved_errno = errno; 3042cbf8903SRoss Lagerwall 3052cbf8903SRoss Lagerwall error_report("relocate_memory %lu pages from GFN %"HWADDR_PRIx 3062cbf8903SRoss Lagerwall " to GFN %"HWADDR_PRIx" failed: %s", 3072cbf8903SRoss Lagerwall nr_pages, pfn, start_gpfn, strerror(saved_errno)); 3082cbf8903SRoss Lagerwall errno = saved_errno; 3092cbf8903SRoss Lagerwall return -1; 31093d43e7eSAnthony Xu } 31193d43e7eSAnthony Xu 3122cbf8903SRoss Lagerwall rc = xendevicemodel_pin_memory_cacheattr(xen_dmod, xen_domid, 31393d43e7eSAnthony Xu start_addr >> TARGET_PAGE_BITS, 31493d43e7eSAnthony Xu (start_addr + size - 1) >> TARGET_PAGE_BITS, 31593d43e7eSAnthony Xu XEN_DOMCTL_MEM_CACHEATTR_WB); 3162cbf8903SRoss Lagerwall if (rc) { 3172cbf8903SRoss Lagerwall error_report("pin_memory_cacheattr failed: %s", strerror(errno)); 3182cbf8903SRoss Lagerwall } 319697b66d0SIgor Druzhinin return xen_save_physmap(state, physmap); 32093d43e7eSAnthony Xu } 32193d43e7eSAnthony Xu 32293d43e7eSAnthony Xu static int xen_remove_from_physmap(XenIOState *state, 32393d43e7eSAnthony Xu hwaddr start_addr, 32493d43e7eSAnthony Xu ram_addr_t size) 32593d43e7eSAnthony Xu { 32693d43e7eSAnthony Xu int rc = 0; 32793d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 32893d43e7eSAnthony Xu hwaddr phys_offset = 0; 32993d43e7eSAnthony Xu 330*8ebb8682SPhilippe Mathieu-Daudé physmap = get_physmapping(start_addr, size, TARGET_PAGE_MASK); 33193d43e7eSAnthony Xu if (physmap == NULL) { 33293d43e7eSAnthony Xu return -1; 33393d43e7eSAnthony Xu } 33493d43e7eSAnthony Xu 33593d43e7eSAnthony Xu phys_offset = physmap->phys_offset; 33693d43e7eSAnthony Xu size = physmap->size; 33793d43e7eSAnthony Xu 33893d43e7eSAnthony Xu DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", at " 33993d43e7eSAnthony Xu "%"HWADDR_PRIx"\n", start_addr, start_addr + size, phys_offset); 34093d43e7eSAnthony Xu 34193d43e7eSAnthony Xu size >>= TARGET_PAGE_BITS; 34293d43e7eSAnthony Xu start_addr >>= TARGET_PAGE_BITS; 34393d43e7eSAnthony Xu phys_offset >>= TARGET_PAGE_BITS; 3442cbf8903SRoss Lagerwall rc = xendevicemodel_relocate_memory(xen_dmod, xen_domid, size, start_addr, 3452cbf8903SRoss Lagerwall phys_offset); 34693d43e7eSAnthony Xu if (rc) { 3472cbf8903SRoss Lagerwall int saved_errno = errno; 3482cbf8903SRoss Lagerwall 3492cbf8903SRoss Lagerwall error_report("relocate_memory "RAM_ADDR_FMT" pages" 3502cbf8903SRoss Lagerwall " from GFN %"HWADDR_PRIx 3512cbf8903SRoss Lagerwall " to GFN %"HWADDR_PRIx" failed: %s", 3522cbf8903SRoss Lagerwall size, start_addr, phys_offset, strerror(saved_errno)); 3532cbf8903SRoss Lagerwall errno = saved_errno; 3542cbf8903SRoss Lagerwall return -1; 35593d43e7eSAnthony Xu } 35693d43e7eSAnthony Xu 35793d43e7eSAnthony Xu QLIST_REMOVE(physmap, list); 3589269b9d1SStefano Stabellini if (log_for_dirtybit == physmap) { 3599269b9d1SStefano Stabellini log_for_dirtybit = NULL; 3609269b9d1SStefano Stabellini g_free(dirty_bitmap); 3619269b9d1SStefano Stabellini dirty_bitmap = NULL; 36293d43e7eSAnthony Xu } 36393d43e7eSAnthony Xu g_free(physmap); 36493d43e7eSAnthony Xu 36593d43e7eSAnthony Xu return 0; 36693d43e7eSAnthony Xu } 36793d43e7eSAnthony Xu 36893d43e7eSAnthony Xu static void xen_sync_dirty_bitmap(XenIOState *state, 36993d43e7eSAnthony Xu hwaddr start_addr, 37093d43e7eSAnthony Xu ram_addr_t size) 37193d43e7eSAnthony Xu { 37293d43e7eSAnthony Xu hwaddr npages = size >> TARGET_PAGE_BITS; 37393d43e7eSAnthony Xu const int width = sizeof(unsigned long) * 8; 37434fbbc16SAnthony PERARD size_t bitmap_size = DIV_ROUND_UP(npages, width); 37593d43e7eSAnthony Xu int rc, i, j; 37693d43e7eSAnthony Xu const XenPhysmap *physmap = NULL; 37793d43e7eSAnthony Xu 378*8ebb8682SPhilippe Mathieu-Daudé physmap = get_physmapping(start_addr, size, TARGET_PAGE_MASK); 37993d43e7eSAnthony Xu if (physmap == NULL) { 38093d43e7eSAnthony Xu /* not handled */ 38193d43e7eSAnthony Xu return; 38293d43e7eSAnthony Xu } 38393d43e7eSAnthony Xu 3849269b9d1SStefano Stabellini if (log_for_dirtybit == NULL) { 3859269b9d1SStefano Stabellini log_for_dirtybit = physmap; 3869269b9d1SStefano Stabellini dirty_bitmap = g_new(unsigned long, bitmap_size); 3879269b9d1SStefano Stabellini } else if (log_for_dirtybit != physmap) { 38893d43e7eSAnthony Xu /* Only one range for dirty bitmap can be tracked. */ 38993d43e7eSAnthony Xu return; 39093d43e7eSAnthony Xu } 39193d43e7eSAnthony Xu 39293d43e7eSAnthony Xu rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS, 3939269b9d1SStefano Stabellini npages, dirty_bitmap); 39493d43e7eSAnthony Xu if (rc < 0) { 39593d43e7eSAnthony Xu #ifndef ENODATA 39693d43e7eSAnthony Xu #define ENODATA ENOENT 39793d43e7eSAnthony Xu #endif 39893d43e7eSAnthony Xu if (errno == ENODATA) { 39993d43e7eSAnthony Xu memory_region_set_dirty(framebuffer, 0, size); 400883f2c59SPhilippe Mathieu-Daudé DPRINTF("xen: track_dirty_vram failed (0x" HWADDR_FMT_plx 401883f2c59SPhilippe Mathieu-Daudé ", 0x" HWADDR_FMT_plx "): %s\n", 40293d43e7eSAnthony Xu start_addr, start_addr + size, strerror(errno)); 40393d43e7eSAnthony Xu } 40493d43e7eSAnthony Xu return; 40593d43e7eSAnthony Xu } 40693d43e7eSAnthony Xu 40734fbbc16SAnthony PERARD for (i = 0; i < bitmap_size; i++) { 4089269b9d1SStefano Stabellini unsigned long map = dirty_bitmap[i]; 40993d43e7eSAnthony Xu while (map != 0) { 41093d43e7eSAnthony Xu j = ctzl(map); 41193d43e7eSAnthony Xu map &= ~(1ul << j); 41293d43e7eSAnthony Xu memory_region_set_dirty(framebuffer, 41393d43e7eSAnthony Xu (i * width + j) * TARGET_PAGE_SIZE, 41493d43e7eSAnthony Xu TARGET_PAGE_SIZE); 41593d43e7eSAnthony Xu }; 41693d43e7eSAnthony Xu } 41793d43e7eSAnthony Xu } 41893d43e7eSAnthony Xu 41993d43e7eSAnthony Xu static void xen_log_start(MemoryListener *listener, 42093d43e7eSAnthony Xu MemoryRegionSection *section, 42193d43e7eSAnthony Xu int old, int new) 42293d43e7eSAnthony Xu { 42393d43e7eSAnthony Xu XenIOState *state = container_of(listener, XenIOState, memory_listener); 42493d43e7eSAnthony Xu 42593d43e7eSAnthony Xu if (new & ~old & (1 << DIRTY_MEMORY_VGA)) { 42693d43e7eSAnthony Xu xen_sync_dirty_bitmap(state, section->offset_within_address_space, 42793d43e7eSAnthony Xu int128_get64(section->size)); 42893d43e7eSAnthony Xu } 42993d43e7eSAnthony Xu } 43093d43e7eSAnthony Xu 43193d43e7eSAnthony Xu static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section, 43293d43e7eSAnthony Xu int old, int new) 43393d43e7eSAnthony Xu { 43493d43e7eSAnthony Xu if (old & ~new & (1 << DIRTY_MEMORY_VGA)) { 4359269b9d1SStefano Stabellini log_for_dirtybit = NULL; 4369269b9d1SStefano Stabellini g_free(dirty_bitmap); 4379269b9d1SStefano Stabellini dirty_bitmap = NULL; 43893d43e7eSAnthony Xu /* Disable dirty bit tracking */ 43993d43e7eSAnthony Xu xen_track_dirty_vram(xen_domid, 0, 0, NULL); 44093d43e7eSAnthony Xu } 44193d43e7eSAnthony Xu } 44293d43e7eSAnthony Xu 44393d43e7eSAnthony Xu static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section) 44493d43e7eSAnthony Xu { 44593d43e7eSAnthony Xu XenIOState *state = container_of(listener, XenIOState, memory_listener); 44693d43e7eSAnthony Xu 44793d43e7eSAnthony Xu xen_sync_dirty_bitmap(state, section->offset_within_address_space, 44893d43e7eSAnthony Xu int128_get64(section->size)); 44993d43e7eSAnthony Xu } 45093d43e7eSAnthony Xu 45193d43e7eSAnthony Xu static void xen_log_global_start(MemoryListener *listener) 45293d43e7eSAnthony Xu { 45393d43e7eSAnthony Xu if (xen_enabled()) { 45493d43e7eSAnthony Xu xen_in_migration = true; 45593d43e7eSAnthony Xu } 45693d43e7eSAnthony Xu } 45793d43e7eSAnthony Xu 45893d43e7eSAnthony Xu static void xen_log_global_stop(MemoryListener *listener) 45993d43e7eSAnthony Xu { 46093d43e7eSAnthony Xu xen_in_migration = false; 46193d43e7eSAnthony Xu } 46293d43e7eSAnthony Xu 463bcb40db0SPeter Maydell static const MemoryListener xen_memory_listener = { 464142518bdSPeter Xu .name = "xen-memory", 46593d43e7eSAnthony Xu .region_add = xen_region_add, 46693d43e7eSAnthony Xu .region_del = xen_region_del, 46793d43e7eSAnthony Xu .log_start = xen_log_start, 46893d43e7eSAnthony Xu .log_stop = xen_log_stop, 46993d43e7eSAnthony Xu .log_sync = xen_log_sync, 47093d43e7eSAnthony Xu .log_global_start = xen_log_global_start, 47193d43e7eSAnthony Xu .log_global_stop = xen_log_global_stop, 4725369a36cSIsaku Yamahata .priority = MEMORY_LISTENER_PRIORITY_ACCEL, 47393d43e7eSAnthony Xu }; 47493d43e7eSAnthony Xu 47593d43e7eSAnthony Xu static void regs_to_cpu(vmware_regs_t *vmport_regs, ioreq_t *req) 47693d43e7eSAnthony Xu { 47793d43e7eSAnthony Xu X86CPU *cpu; 47893d43e7eSAnthony Xu CPUX86State *env; 47993d43e7eSAnthony Xu 48093d43e7eSAnthony Xu cpu = X86_CPU(current_cpu); 48193d43e7eSAnthony Xu env = &cpu->env; 48293d43e7eSAnthony Xu env->regs[R_EAX] = req->data; 48393d43e7eSAnthony Xu env->regs[R_EBX] = vmport_regs->ebx; 48493d43e7eSAnthony Xu env->regs[R_ECX] = vmport_regs->ecx; 48593d43e7eSAnthony Xu env->regs[R_EDX] = vmport_regs->edx; 48693d43e7eSAnthony Xu env->regs[R_ESI] = vmport_regs->esi; 48793d43e7eSAnthony Xu env->regs[R_EDI] = vmport_regs->edi; 48893d43e7eSAnthony Xu } 48993d43e7eSAnthony Xu 49093d43e7eSAnthony Xu static void regs_from_cpu(vmware_regs_t *vmport_regs) 49193d43e7eSAnthony Xu { 49293d43e7eSAnthony Xu X86CPU *cpu = X86_CPU(current_cpu); 49393d43e7eSAnthony Xu CPUX86State *env = &cpu->env; 49493d43e7eSAnthony Xu 49593d43e7eSAnthony Xu vmport_regs->ebx = env->regs[R_EBX]; 49693d43e7eSAnthony Xu vmport_regs->ecx = env->regs[R_ECX]; 49793d43e7eSAnthony Xu vmport_regs->edx = env->regs[R_EDX]; 49893d43e7eSAnthony Xu vmport_regs->esi = env->regs[R_ESI]; 49993d43e7eSAnthony Xu vmport_regs->edi = env->regs[R_EDI]; 50093d43e7eSAnthony Xu } 50193d43e7eSAnthony Xu 50293d43e7eSAnthony Xu static void handle_vmport_ioreq(XenIOState *state, ioreq_t *req) 50393d43e7eSAnthony Xu { 50493d43e7eSAnthony Xu vmware_regs_t *vmport_regs; 50593d43e7eSAnthony Xu 5069269b9d1SStefano Stabellini assert(shared_vmport_page); 50793d43e7eSAnthony Xu vmport_regs = 5089269b9d1SStefano Stabellini &shared_vmport_page->vcpu_vmport_regs[state->send_vcpu]; 50993d43e7eSAnthony Xu QEMU_BUILD_BUG_ON(sizeof(*req) < sizeof(*vmport_regs)); 51093d43e7eSAnthony Xu 51193d43e7eSAnthony Xu current_cpu = state->cpu_by_vcpu_id[state->send_vcpu]; 51293d43e7eSAnthony Xu regs_to_cpu(vmport_regs, req); 51393d43e7eSAnthony Xu cpu_ioreq_pio(req); 51493d43e7eSAnthony Xu regs_from_cpu(vmport_regs); 51593d43e7eSAnthony Xu current_cpu = NULL; 51693d43e7eSAnthony Xu } 51793d43e7eSAnthony Xu 518331b5189SIgor Druzhinin #ifdef XEN_COMPAT_PHYSMAP 51993d43e7eSAnthony Xu static void xen_read_physmap(XenIOState *state) 52093d43e7eSAnthony Xu { 52193d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 52293d43e7eSAnthony Xu unsigned int len, num, i; 52393d43e7eSAnthony Xu char path[80], *value = NULL; 52493d43e7eSAnthony Xu char **entries = NULL; 52593d43e7eSAnthony Xu 52693d43e7eSAnthony Xu snprintf(path, sizeof(path), 52793d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap", xen_domid); 52893d43e7eSAnthony Xu entries = xs_directory(state->xenstore, 0, path, &num); 52993d43e7eSAnthony Xu if (entries == NULL) 53093d43e7eSAnthony Xu return; 53193d43e7eSAnthony Xu 53293d43e7eSAnthony Xu for (i = 0; i < num; i++) { 533b21e2380SMarkus Armbruster physmap = g_new(XenPhysmap, 1); 53493d43e7eSAnthony Xu physmap->phys_offset = strtoull(entries[i], NULL, 16); 53593d43e7eSAnthony Xu snprintf(path, sizeof(path), 53693d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap/%s/start_addr", 53793d43e7eSAnthony Xu xen_domid, entries[i]); 53893d43e7eSAnthony Xu value = xs_read(state->xenstore, 0, path, &len); 53993d43e7eSAnthony Xu if (value == NULL) { 54093d43e7eSAnthony Xu g_free(physmap); 54193d43e7eSAnthony Xu continue; 54293d43e7eSAnthony Xu } 54393d43e7eSAnthony Xu physmap->start_addr = strtoull(value, NULL, 16); 54493d43e7eSAnthony Xu free(value); 54593d43e7eSAnthony Xu 54693d43e7eSAnthony Xu snprintf(path, sizeof(path), 54793d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap/%s/size", 54893d43e7eSAnthony Xu xen_domid, entries[i]); 54993d43e7eSAnthony Xu value = xs_read(state->xenstore, 0, path, &len); 55093d43e7eSAnthony Xu if (value == NULL) { 55193d43e7eSAnthony Xu g_free(physmap); 55293d43e7eSAnthony Xu continue; 55393d43e7eSAnthony Xu } 55493d43e7eSAnthony Xu physmap->size = strtoull(value, NULL, 16); 55593d43e7eSAnthony Xu free(value); 55693d43e7eSAnthony Xu 55793d43e7eSAnthony Xu snprintf(path, sizeof(path), 55893d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap/%s/name", 55993d43e7eSAnthony Xu xen_domid, entries[i]); 56093d43e7eSAnthony Xu physmap->name = xs_read(state->xenstore, 0, path, &len); 56193d43e7eSAnthony Xu 56204a8f72eSIgor Druzhinin QLIST_INSERT_HEAD(&xen_physmap, physmap, list); 56393d43e7eSAnthony Xu } 56493d43e7eSAnthony Xu free(entries); 56593d43e7eSAnthony Xu } 566331b5189SIgor Druzhinin #else 567331b5189SIgor Druzhinin static void xen_read_physmap(XenIOState *state) 568331b5189SIgor Druzhinin { 569331b5189SIgor Druzhinin } 570331b5189SIgor Druzhinin #endif 57193d43e7eSAnthony Xu 57293d43e7eSAnthony Xu static void xen_wakeup_notifier(Notifier *notifier, void *data) 57393d43e7eSAnthony Xu { 57493d43e7eSAnthony Xu xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); 57593d43e7eSAnthony Xu } 57693d43e7eSAnthony Xu 5775650ac00SPhilippe Mathieu-Daudé void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) 57893d43e7eSAnthony Xu { 5790e11fc69SLike Xu MachineState *ms = MACHINE(pcms); 5800e11fc69SLike Xu unsigned int max_cpus = ms->smp.max_cpus; 581f17068c1SStefano Stabellini int rc; 58293d43e7eSAnthony Xu xen_pfn_t ioreq_pfn; 58393d43e7eSAnthony Xu XenIOState *state; 58493d43e7eSAnthony Xu 585b21e2380SMarkus Armbruster state = g_new0(XenIOState, 1); 58693d43e7eSAnthony Xu 587bcb40db0SPeter Maydell xen_register_ioreq(state, max_cpus, &xen_memory_listener); 58804a8f72eSIgor Druzhinin 58904a8f72eSIgor Druzhinin QLIST_INIT(&xen_physmap); 59093d43e7eSAnthony Xu xen_read_physmap(state); 59193d43e7eSAnthony Xu 5929269b9d1SStefano Stabellini suspend.notify = xen_suspend_notifier; 5939269b9d1SStefano Stabellini qemu_register_suspend_notifier(&suspend); 59433087aacSVikram Garhwal 5959269b9d1SStefano Stabellini wakeup.notify = xen_wakeup_notifier; 5969269b9d1SStefano Stabellini qemu_register_wakeup_notifier(&wakeup); 59733087aacSVikram Garhwal 59833087aacSVikram Garhwal rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); 59933087aacSVikram Garhwal if (!rc) { 60033087aacSVikram Garhwal DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); 6019269b9d1SStefano Stabellini shared_vmport_page = 60233087aacSVikram Garhwal xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, 60333087aacSVikram Garhwal 1, &ioreq_pfn, NULL); 6049269b9d1SStefano Stabellini if (shared_vmport_page == NULL) { 60533087aacSVikram Garhwal error_report("map shared vmport IO page returned error %d handle=%p", 60633087aacSVikram Garhwal errno, xen_xc); 60733087aacSVikram Garhwal goto err; 60833087aacSVikram Garhwal } 60933087aacSVikram Garhwal } else if (rc != -ENOSYS) { 61033087aacSVikram Garhwal error_report("get vmport regs pfn returned error %d, rc=%d", 61133087aacSVikram Garhwal errno, rc); 61233087aacSVikram Garhwal goto err; 61333087aacSVikram Garhwal } 61433087aacSVikram Garhwal 61533087aacSVikram Garhwal xen_ram_init(pcms, ms->ram_size, ram_memory); 61633087aacSVikram Garhwal 61793d43e7eSAnthony Xu /* Disable ACPI build because Xen handles it */ 61893d43e7eSAnthony Xu pcms->acpi_build_enabled = false; 61993d43e7eSAnthony Xu 62093d43e7eSAnthony Xu return; 62193d43e7eSAnthony Xu 62293d43e7eSAnthony Xu err: 62393d43e7eSAnthony Xu error_report("xen hardware virtual machine initialisation failed"); 62493d43e7eSAnthony Xu exit(1); 62593d43e7eSAnthony Xu } 62693d43e7eSAnthony Xu 62793d43e7eSAnthony Xu void xen_register_framebuffer(MemoryRegion *mr) 62893d43e7eSAnthony Xu { 62993d43e7eSAnthony Xu framebuffer = mr; 63093d43e7eSAnthony Xu } 63193d43e7eSAnthony Xu 63293d43e7eSAnthony Xu void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) 63393d43e7eSAnthony Xu { 63493d43e7eSAnthony Xu if (unlikely(xen_in_migration)) { 63593d43e7eSAnthony Xu int rc; 63693d43e7eSAnthony Xu ram_addr_t start_pfn, nb_pages; 63793d43e7eSAnthony Xu 638*8ebb8682SPhilippe Mathieu-Daudé start = xen_phys_offset_to_gaddr(start, length, TARGET_PAGE_MASK); 63904a8f72eSIgor Druzhinin 64093d43e7eSAnthony Xu if (length == 0) { 64193d43e7eSAnthony Xu length = TARGET_PAGE_SIZE; 64293d43e7eSAnthony Xu } 64393d43e7eSAnthony Xu start_pfn = start >> TARGET_PAGE_BITS; 64493d43e7eSAnthony Xu nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS) 64593d43e7eSAnthony Xu - start_pfn; 64693d43e7eSAnthony Xu rc = xen_modified_memory(xen_domid, start_pfn, nb_pages); 64793d43e7eSAnthony Xu if (rc) { 64893d43e7eSAnthony Xu fprintf(stderr, 64993d43e7eSAnthony Xu "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n", 6507cdcca72SRoss Lagerwall __func__, start, nb_pages, errno, strerror(errno)); 65193d43e7eSAnthony Xu } 65293d43e7eSAnthony Xu } 65393d43e7eSAnthony Xu } 65493d43e7eSAnthony Xu 65593d43e7eSAnthony Xu void qmp_xen_set_global_dirty_log(bool enable, Error **errp) 65693d43e7eSAnthony Xu { 65793d43e7eSAnthony Xu if (enable) { 65863b41db4SHyman Huang(黄勇) memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION); 65993d43e7eSAnthony Xu } else { 66063b41db4SHyman Huang(黄勇) memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION); 66193d43e7eSAnthony Xu } 66293d43e7eSAnthony Xu } 663f17068c1SStefano Stabellini 664f17068c1SStefano Stabellini void arch_xen_set_memory(XenIOState *state, MemoryRegionSection *section, 665f17068c1SStefano Stabellini bool add) 666f17068c1SStefano Stabellini { 667f17068c1SStefano Stabellini hwaddr start_addr = section->offset_within_address_space; 668f17068c1SStefano Stabellini ram_addr_t size = int128_get64(section->size); 669f17068c1SStefano Stabellini bool log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); 670f17068c1SStefano Stabellini hvmmem_type_t mem_type; 671f17068c1SStefano Stabellini 672f17068c1SStefano Stabellini if (!memory_region_is_ram(section->mr)) { 673f17068c1SStefano Stabellini return; 674f17068c1SStefano Stabellini } 675f17068c1SStefano Stabellini 676f17068c1SStefano Stabellini if (log_dirty != add) { 677f17068c1SStefano Stabellini return; 678f17068c1SStefano Stabellini } 679f17068c1SStefano Stabellini 680f17068c1SStefano Stabellini trace_xen_client_set_memory(start_addr, size, log_dirty); 681f17068c1SStefano Stabellini 682f17068c1SStefano Stabellini start_addr &= TARGET_PAGE_MASK; 68362d6cf9dSPhilippe Mathieu-Daudé size = ROUND_UP(size, TARGET_PAGE_SIZE); 684f17068c1SStefano Stabellini 685f17068c1SStefano Stabellini if (add) { 686f17068c1SStefano Stabellini if (!memory_region_is_rom(section->mr)) { 687f17068c1SStefano Stabellini xen_add_to_physmap(state, start_addr, size, 688f17068c1SStefano Stabellini section->mr, section->offset_within_region); 689f17068c1SStefano Stabellini } else { 690f17068c1SStefano Stabellini mem_type = HVMMEM_ram_ro; 691f17068c1SStefano Stabellini if (xen_set_mem_type(xen_domid, mem_type, 692f17068c1SStefano Stabellini start_addr >> TARGET_PAGE_BITS, 693f17068c1SStefano Stabellini size >> TARGET_PAGE_BITS)) { 694f17068c1SStefano Stabellini DPRINTF("xen_set_mem_type error, addr: "HWADDR_FMT_plx"\n", 695f17068c1SStefano Stabellini start_addr); 696f17068c1SStefano Stabellini } 697f17068c1SStefano Stabellini } 698f17068c1SStefano Stabellini } else { 699f17068c1SStefano Stabellini if (xen_remove_from_physmap(state, start_addr, size) < 0) { 700f17068c1SStefano Stabellini DPRINTF("physmapping does not exist at "HWADDR_FMT_plx"\n", start_addr); 701f17068c1SStefano Stabellini } 702f17068c1SStefano Stabellini } 703f17068c1SStefano Stabellini } 704f17068c1SStefano Stabellini 705f17068c1SStefano Stabellini void arch_handle_ioreq(XenIOState *state, ioreq_t *req) 706f17068c1SStefano Stabellini { 707f17068c1SStefano Stabellini switch (req->type) { 708f17068c1SStefano Stabellini case IOREQ_TYPE_VMWARE_PORT: 709f17068c1SStefano Stabellini handle_vmport_ioreq(state, req); 710f17068c1SStefano Stabellini break; 711f17068c1SStefano Stabellini default: 712f17068c1SStefano Stabellini hw_error("Invalid ioreq type 0x%x\n", req->type); 713f17068c1SStefano Stabellini } 714f17068c1SStefano Stabellini 715f17068c1SStefano Stabellini return; 716f17068c1SStefano Stabellini } 717