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 17*f17068c1SStefano Stabellini #include "hw/i386/pc.h" 18*f17068c1SStefano Stabellini #include "hw/irq.h" 19*f17068c1SStefano Stabellini #include "hw/i386/apic-msidef.h" 20*f17068c1SStefano Stabellini #include "hw/xen/xen-x86.h" 21*f17068c1SStefano Stabellini #include "qemu/range.h" 22*f17068c1SStefano Stabellini 23*f17068c1SStefano Stabellini #include "hw/xen/xen-hvm-common.h" 24*f17068c1SStefano Stabellini #include "hw/xen/arch_hvm.h" 2593d43e7eSAnthony Xu #include <xen/hvm/e820.h> 2693d43e7eSAnthony Xu 27*f17068c1SStefano 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 55*f17068c1SStefano 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 } 15298a99ce0SPeter Maydell memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len, 15393d43e7eSAnthony Xu &error_fatal); 15493d43e7eSAnthony Xu *ram_memory_p = &ram_memory; 15593d43e7eSAnthony Xu 15693d43e7eSAnthony Xu memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k", 15793d43e7eSAnthony Xu &ram_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", 16693d43e7eSAnthony Xu &ram_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", 17193d43e7eSAnthony Xu &ram_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 17704a8f72eSIgor Druzhinin static XenPhysmap *get_physmapping(hwaddr start_addr, ram_addr_t size) 17893d43e7eSAnthony Xu { 17993d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 18093d43e7eSAnthony Xu 18193d43e7eSAnthony Xu start_addr &= TARGET_PAGE_MASK; 18293d43e7eSAnthony Xu 18304a8f72eSIgor Druzhinin QLIST_FOREACH(physmap, &xen_physmap, list) { 18493d43e7eSAnthony Xu if (range_covers_byte(physmap->start_addr, physmap->size, start_addr)) { 18593d43e7eSAnthony Xu return physmap; 18693d43e7eSAnthony Xu } 18793d43e7eSAnthony Xu } 18893d43e7eSAnthony Xu return NULL; 18993d43e7eSAnthony Xu } 19093d43e7eSAnthony Xu 19104a8f72eSIgor Druzhinin static hwaddr xen_phys_offset_to_gaddr(hwaddr phys_offset, ram_addr_t size) 19293d43e7eSAnthony Xu { 19304a8f72eSIgor Druzhinin hwaddr addr = phys_offset & TARGET_PAGE_MASK; 19493d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 19593d43e7eSAnthony Xu 19604a8f72eSIgor Druzhinin QLIST_FOREACH(physmap, &xen_physmap, list) { 19793d43e7eSAnthony Xu if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) { 19804a8f72eSIgor Druzhinin return physmap->start_addr + (phys_offset - physmap->phys_offset); 19993d43e7eSAnthony Xu } 20093d43e7eSAnthony Xu } 20193d43e7eSAnthony Xu 20204a8f72eSIgor Druzhinin return phys_offset; 20393d43e7eSAnthony Xu } 20493d43e7eSAnthony Xu 20504a8f72eSIgor Druzhinin #ifdef XEN_COMPAT_PHYSMAP 206697b66d0SIgor Druzhinin static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) 207697b66d0SIgor Druzhinin { 208697b66d0SIgor Druzhinin char path[80], value[17]; 209697b66d0SIgor Druzhinin 210697b66d0SIgor Druzhinin snprintf(path, sizeof(path), 211697b66d0SIgor Druzhinin "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr", 212697b66d0SIgor Druzhinin xen_domid, (uint64_t)physmap->phys_offset); 213697b66d0SIgor Druzhinin snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->start_addr); 214697b66d0SIgor Druzhinin if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { 215697b66d0SIgor Druzhinin return -1; 216697b66d0SIgor Druzhinin } 217697b66d0SIgor Druzhinin snprintf(path, sizeof(path), 218697b66d0SIgor Druzhinin "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size", 219697b66d0SIgor Druzhinin xen_domid, (uint64_t)physmap->phys_offset); 220697b66d0SIgor Druzhinin snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->size); 221697b66d0SIgor Druzhinin if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { 222697b66d0SIgor Druzhinin return -1; 223697b66d0SIgor Druzhinin } 224697b66d0SIgor Druzhinin if (physmap->name) { 225697b66d0SIgor Druzhinin snprintf(path, sizeof(path), 226697b66d0SIgor Druzhinin "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name", 227697b66d0SIgor Druzhinin xen_domid, (uint64_t)physmap->phys_offset); 228697b66d0SIgor Druzhinin if (!xs_write(state->xenstore, 0, path, 229697b66d0SIgor Druzhinin physmap->name, strlen(physmap->name))) { 230697b66d0SIgor Druzhinin return -1; 231697b66d0SIgor Druzhinin } 232697b66d0SIgor Druzhinin } 233697b66d0SIgor Druzhinin return 0; 234697b66d0SIgor Druzhinin } 235331b5189SIgor Druzhinin #else 236331b5189SIgor Druzhinin static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) 237331b5189SIgor Druzhinin { 238331b5189SIgor Druzhinin return 0; 239331b5189SIgor Druzhinin } 240331b5189SIgor Druzhinin #endif 241697b66d0SIgor Druzhinin 24293d43e7eSAnthony Xu static int xen_add_to_physmap(XenIOState *state, 24393d43e7eSAnthony Xu hwaddr start_addr, 24493d43e7eSAnthony Xu ram_addr_t size, 24593d43e7eSAnthony Xu MemoryRegion *mr, 24693d43e7eSAnthony Xu hwaddr offset_within_region) 24793d43e7eSAnthony Xu { 2482cbf8903SRoss Lagerwall unsigned long nr_pages; 24993d43e7eSAnthony Xu int rc = 0; 25093d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 25193d43e7eSAnthony Xu hwaddr pfn, start_gpfn; 25293d43e7eSAnthony Xu hwaddr phys_offset = memory_region_get_ram_addr(mr); 25393d43e7eSAnthony Xu const char *mr_name; 25493d43e7eSAnthony Xu 25504a8f72eSIgor Druzhinin if (get_physmapping(start_addr, size)) { 25693d43e7eSAnthony Xu return 0; 25793d43e7eSAnthony Xu } 25893d43e7eSAnthony Xu if (size <= 0) { 25993d43e7eSAnthony Xu return -1; 26093d43e7eSAnthony Xu } 26193d43e7eSAnthony Xu 26293d43e7eSAnthony Xu /* Xen can only handle a single dirty log region for now and we want 26393d43e7eSAnthony Xu * the linear framebuffer to be that region. 26493d43e7eSAnthony Xu * Avoid tracking any regions that is not videoram and avoid tracking 26593d43e7eSAnthony Xu * the legacy vga region. */ 26693d43e7eSAnthony Xu if (mr == framebuffer && start_addr > 0xbffff) { 26793d43e7eSAnthony Xu goto go_physmap; 26893d43e7eSAnthony Xu } 26993d43e7eSAnthony Xu return -1; 27093d43e7eSAnthony Xu 27193d43e7eSAnthony Xu go_physmap: 27293d43e7eSAnthony Xu DPRINTF("mapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx"\n", 27393d43e7eSAnthony Xu start_addr, start_addr + size); 27493d43e7eSAnthony Xu 275331b5189SIgor Druzhinin mr_name = memory_region_name(mr); 276331b5189SIgor Druzhinin 277b21e2380SMarkus Armbruster physmap = g_new(XenPhysmap, 1); 278331b5189SIgor Druzhinin 279331b5189SIgor Druzhinin physmap->start_addr = start_addr; 280331b5189SIgor Druzhinin physmap->size = size; 281331b5189SIgor Druzhinin physmap->name = mr_name; 282331b5189SIgor Druzhinin physmap->phys_offset = phys_offset; 283331b5189SIgor Druzhinin 28404a8f72eSIgor Druzhinin QLIST_INSERT_HEAD(&xen_physmap, physmap, list); 285331b5189SIgor Druzhinin 286331b5189SIgor Druzhinin if (runstate_check(RUN_STATE_INMIGRATE)) { 287331b5189SIgor Druzhinin /* Now when we have a physmap entry we can replace a dummy mapping with 288331b5189SIgor Druzhinin * a real one of guest foreign memory. */ 289331b5189SIgor Druzhinin uint8_t *p = xen_replace_cache_entry(phys_offset, start_addr, size); 290331b5189SIgor Druzhinin assert(p && p == memory_region_get_ram_ptr(mr)); 291331b5189SIgor Druzhinin 292331b5189SIgor Druzhinin return 0; 293331b5189SIgor Druzhinin } 294331b5189SIgor Druzhinin 29593d43e7eSAnthony Xu pfn = phys_offset >> TARGET_PAGE_BITS; 29693d43e7eSAnthony Xu start_gpfn = start_addr >> TARGET_PAGE_BITS; 2972cbf8903SRoss Lagerwall nr_pages = size >> TARGET_PAGE_BITS; 2982cbf8903SRoss Lagerwall rc = xendevicemodel_relocate_memory(xen_dmod, xen_domid, nr_pages, pfn, 2992cbf8903SRoss Lagerwall start_gpfn); 30093d43e7eSAnthony Xu if (rc) { 3012cbf8903SRoss Lagerwall int saved_errno = errno; 3022cbf8903SRoss Lagerwall 3032cbf8903SRoss Lagerwall error_report("relocate_memory %lu pages from GFN %"HWADDR_PRIx 3042cbf8903SRoss Lagerwall " to GFN %"HWADDR_PRIx" failed: %s", 3052cbf8903SRoss Lagerwall nr_pages, pfn, start_gpfn, strerror(saved_errno)); 3062cbf8903SRoss Lagerwall errno = saved_errno; 3072cbf8903SRoss Lagerwall return -1; 30893d43e7eSAnthony Xu } 30993d43e7eSAnthony Xu 3102cbf8903SRoss Lagerwall rc = xendevicemodel_pin_memory_cacheattr(xen_dmod, xen_domid, 31193d43e7eSAnthony Xu start_addr >> TARGET_PAGE_BITS, 31293d43e7eSAnthony Xu (start_addr + size - 1) >> TARGET_PAGE_BITS, 31393d43e7eSAnthony Xu XEN_DOMCTL_MEM_CACHEATTR_WB); 3142cbf8903SRoss Lagerwall if (rc) { 3152cbf8903SRoss Lagerwall error_report("pin_memory_cacheattr failed: %s", strerror(errno)); 3162cbf8903SRoss Lagerwall } 317697b66d0SIgor Druzhinin return xen_save_physmap(state, physmap); 31893d43e7eSAnthony Xu } 31993d43e7eSAnthony Xu 32093d43e7eSAnthony Xu static int xen_remove_from_physmap(XenIOState *state, 32193d43e7eSAnthony Xu hwaddr start_addr, 32293d43e7eSAnthony Xu ram_addr_t size) 32393d43e7eSAnthony Xu { 32493d43e7eSAnthony Xu int rc = 0; 32593d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 32693d43e7eSAnthony Xu hwaddr phys_offset = 0; 32793d43e7eSAnthony Xu 32804a8f72eSIgor Druzhinin physmap = get_physmapping(start_addr, size); 32993d43e7eSAnthony Xu if (physmap == NULL) { 33093d43e7eSAnthony Xu return -1; 33193d43e7eSAnthony Xu } 33293d43e7eSAnthony Xu 33393d43e7eSAnthony Xu phys_offset = physmap->phys_offset; 33493d43e7eSAnthony Xu size = physmap->size; 33593d43e7eSAnthony Xu 33693d43e7eSAnthony Xu DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", at " 33793d43e7eSAnthony Xu "%"HWADDR_PRIx"\n", start_addr, start_addr + size, phys_offset); 33893d43e7eSAnthony Xu 33993d43e7eSAnthony Xu size >>= TARGET_PAGE_BITS; 34093d43e7eSAnthony Xu start_addr >>= TARGET_PAGE_BITS; 34193d43e7eSAnthony Xu phys_offset >>= TARGET_PAGE_BITS; 3422cbf8903SRoss Lagerwall rc = xendevicemodel_relocate_memory(xen_dmod, xen_domid, size, start_addr, 3432cbf8903SRoss Lagerwall phys_offset); 34493d43e7eSAnthony Xu if (rc) { 3452cbf8903SRoss Lagerwall int saved_errno = errno; 3462cbf8903SRoss Lagerwall 3472cbf8903SRoss Lagerwall error_report("relocate_memory "RAM_ADDR_FMT" pages" 3482cbf8903SRoss Lagerwall " from GFN %"HWADDR_PRIx 3492cbf8903SRoss Lagerwall " to GFN %"HWADDR_PRIx" failed: %s", 3502cbf8903SRoss Lagerwall size, start_addr, phys_offset, strerror(saved_errno)); 3512cbf8903SRoss Lagerwall errno = saved_errno; 3522cbf8903SRoss Lagerwall return -1; 35393d43e7eSAnthony Xu } 35493d43e7eSAnthony Xu 35593d43e7eSAnthony Xu QLIST_REMOVE(physmap, list); 3569269b9d1SStefano Stabellini if (log_for_dirtybit == physmap) { 3579269b9d1SStefano Stabellini log_for_dirtybit = NULL; 3589269b9d1SStefano Stabellini g_free(dirty_bitmap); 3599269b9d1SStefano Stabellini dirty_bitmap = NULL; 36093d43e7eSAnthony Xu } 36193d43e7eSAnthony Xu g_free(physmap); 36293d43e7eSAnthony Xu 36393d43e7eSAnthony Xu return 0; 36493d43e7eSAnthony Xu } 36593d43e7eSAnthony Xu 36693d43e7eSAnthony Xu static void xen_sync_dirty_bitmap(XenIOState *state, 36793d43e7eSAnthony Xu hwaddr start_addr, 36893d43e7eSAnthony Xu ram_addr_t size) 36993d43e7eSAnthony Xu { 37093d43e7eSAnthony Xu hwaddr npages = size >> TARGET_PAGE_BITS; 37193d43e7eSAnthony Xu const int width = sizeof(unsigned long) * 8; 37234fbbc16SAnthony PERARD size_t bitmap_size = DIV_ROUND_UP(npages, width); 37393d43e7eSAnthony Xu int rc, i, j; 37493d43e7eSAnthony Xu const XenPhysmap *physmap = NULL; 37593d43e7eSAnthony Xu 37604a8f72eSIgor Druzhinin physmap = get_physmapping(start_addr, size); 37793d43e7eSAnthony Xu if (physmap == NULL) { 37893d43e7eSAnthony Xu /* not handled */ 37993d43e7eSAnthony Xu return; 38093d43e7eSAnthony Xu } 38193d43e7eSAnthony Xu 3829269b9d1SStefano Stabellini if (log_for_dirtybit == NULL) { 3839269b9d1SStefano Stabellini log_for_dirtybit = physmap; 3849269b9d1SStefano Stabellini dirty_bitmap = g_new(unsigned long, bitmap_size); 3859269b9d1SStefano Stabellini } else if (log_for_dirtybit != physmap) { 38693d43e7eSAnthony Xu /* Only one range for dirty bitmap can be tracked. */ 38793d43e7eSAnthony Xu return; 38893d43e7eSAnthony Xu } 38993d43e7eSAnthony Xu 39093d43e7eSAnthony Xu rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS, 3919269b9d1SStefano Stabellini npages, dirty_bitmap); 39293d43e7eSAnthony Xu if (rc < 0) { 39393d43e7eSAnthony Xu #ifndef ENODATA 39493d43e7eSAnthony Xu #define ENODATA ENOENT 39593d43e7eSAnthony Xu #endif 39693d43e7eSAnthony Xu if (errno == ENODATA) { 39793d43e7eSAnthony Xu memory_region_set_dirty(framebuffer, 0, size); 398883f2c59SPhilippe Mathieu-Daudé DPRINTF("xen: track_dirty_vram failed (0x" HWADDR_FMT_plx 399883f2c59SPhilippe Mathieu-Daudé ", 0x" HWADDR_FMT_plx "): %s\n", 40093d43e7eSAnthony Xu start_addr, start_addr + size, strerror(errno)); 40193d43e7eSAnthony Xu } 40293d43e7eSAnthony Xu return; 40393d43e7eSAnthony Xu } 40493d43e7eSAnthony Xu 40534fbbc16SAnthony PERARD for (i = 0; i < bitmap_size; i++) { 4069269b9d1SStefano Stabellini unsigned long map = dirty_bitmap[i]; 40793d43e7eSAnthony Xu while (map != 0) { 40893d43e7eSAnthony Xu j = ctzl(map); 40993d43e7eSAnthony Xu map &= ~(1ul << j); 41093d43e7eSAnthony Xu memory_region_set_dirty(framebuffer, 41193d43e7eSAnthony Xu (i * width + j) * TARGET_PAGE_SIZE, 41293d43e7eSAnthony Xu TARGET_PAGE_SIZE); 41393d43e7eSAnthony Xu }; 41493d43e7eSAnthony Xu } 41593d43e7eSAnthony Xu } 41693d43e7eSAnthony Xu 41793d43e7eSAnthony Xu static void xen_log_start(MemoryListener *listener, 41893d43e7eSAnthony Xu MemoryRegionSection *section, 41993d43e7eSAnthony Xu int old, int new) 42093d43e7eSAnthony Xu { 42193d43e7eSAnthony Xu XenIOState *state = container_of(listener, XenIOState, memory_listener); 42293d43e7eSAnthony Xu 42393d43e7eSAnthony Xu if (new & ~old & (1 << DIRTY_MEMORY_VGA)) { 42493d43e7eSAnthony Xu xen_sync_dirty_bitmap(state, section->offset_within_address_space, 42593d43e7eSAnthony Xu int128_get64(section->size)); 42693d43e7eSAnthony Xu } 42793d43e7eSAnthony Xu } 42893d43e7eSAnthony Xu 42993d43e7eSAnthony Xu static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section, 43093d43e7eSAnthony Xu int old, int new) 43193d43e7eSAnthony Xu { 43293d43e7eSAnthony Xu if (old & ~new & (1 << DIRTY_MEMORY_VGA)) { 4339269b9d1SStefano Stabellini log_for_dirtybit = NULL; 4349269b9d1SStefano Stabellini g_free(dirty_bitmap); 4359269b9d1SStefano Stabellini dirty_bitmap = NULL; 43693d43e7eSAnthony Xu /* Disable dirty bit tracking */ 43793d43e7eSAnthony Xu xen_track_dirty_vram(xen_domid, 0, 0, NULL); 43893d43e7eSAnthony Xu } 43993d43e7eSAnthony Xu } 44093d43e7eSAnthony Xu 44193d43e7eSAnthony Xu static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section) 44293d43e7eSAnthony Xu { 44393d43e7eSAnthony Xu XenIOState *state = container_of(listener, XenIOState, memory_listener); 44493d43e7eSAnthony Xu 44593d43e7eSAnthony Xu xen_sync_dirty_bitmap(state, section->offset_within_address_space, 44693d43e7eSAnthony Xu int128_get64(section->size)); 44793d43e7eSAnthony Xu } 44893d43e7eSAnthony Xu 44993d43e7eSAnthony Xu static void xen_log_global_start(MemoryListener *listener) 45093d43e7eSAnthony Xu { 45193d43e7eSAnthony Xu if (xen_enabled()) { 45293d43e7eSAnthony Xu xen_in_migration = true; 45393d43e7eSAnthony Xu } 45493d43e7eSAnthony Xu } 45593d43e7eSAnthony Xu 45693d43e7eSAnthony Xu static void xen_log_global_stop(MemoryListener *listener) 45793d43e7eSAnthony Xu { 45893d43e7eSAnthony Xu xen_in_migration = false; 45993d43e7eSAnthony Xu } 46093d43e7eSAnthony Xu 46193d43e7eSAnthony Xu static MemoryListener xen_memory_listener = { 462142518bdSPeter Xu .name = "xen-memory", 46393d43e7eSAnthony Xu .region_add = xen_region_add, 46493d43e7eSAnthony Xu .region_del = xen_region_del, 46593d43e7eSAnthony Xu .log_start = xen_log_start, 46693d43e7eSAnthony Xu .log_stop = xen_log_stop, 46793d43e7eSAnthony Xu .log_sync = xen_log_sync, 46893d43e7eSAnthony Xu .log_global_start = xen_log_global_start, 46993d43e7eSAnthony Xu .log_global_stop = xen_log_global_stop, 47093d43e7eSAnthony Xu .priority = 10, 47193d43e7eSAnthony Xu }; 47293d43e7eSAnthony Xu 47393d43e7eSAnthony Xu static void regs_to_cpu(vmware_regs_t *vmport_regs, ioreq_t *req) 47493d43e7eSAnthony Xu { 47593d43e7eSAnthony Xu X86CPU *cpu; 47693d43e7eSAnthony Xu CPUX86State *env; 47793d43e7eSAnthony Xu 47893d43e7eSAnthony Xu cpu = X86_CPU(current_cpu); 47993d43e7eSAnthony Xu env = &cpu->env; 48093d43e7eSAnthony Xu env->regs[R_EAX] = req->data; 48193d43e7eSAnthony Xu env->regs[R_EBX] = vmport_regs->ebx; 48293d43e7eSAnthony Xu env->regs[R_ECX] = vmport_regs->ecx; 48393d43e7eSAnthony Xu env->regs[R_EDX] = vmport_regs->edx; 48493d43e7eSAnthony Xu env->regs[R_ESI] = vmport_regs->esi; 48593d43e7eSAnthony Xu env->regs[R_EDI] = vmport_regs->edi; 48693d43e7eSAnthony Xu } 48793d43e7eSAnthony Xu 48893d43e7eSAnthony Xu static void regs_from_cpu(vmware_regs_t *vmport_regs) 48993d43e7eSAnthony Xu { 49093d43e7eSAnthony Xu X86CPU *cpu = X86_CPU(current_cpu); 49193d43e7eSAnthony Xu CPUX86State *env = &cpu->env; 49293d43e7eSAnthony Xu 49393d43e7eSAnthony Xu vmport_regs->ebx = env->regs[R_EBX]; 49493d43e7eSAnthony Xu vmport_regs->ecx = env->regs[R_ECX]; 49593d43e7eSAnthony Xu vmport_regs->edx = env->regs[R_EDX]; 49693d43e7eSAnthony Xu vmport_regs->esi = env->regs[R_ESI]; 49793d43e7eSAnthony Xu vmport_regs->edi = env->regs[R_EDI]; 49893d43e7eSAnthony Xu } 49993d43e7eSAnthony Xu 50093d43e7eSAnthony Xu static void handle_vmport_ioreq(XenIOState *state, ioreq_t *req) 50193d43e7eSAnthony Xu { 50293d43e7eSAnthony Xu vmware_regs_t *vmport_regs; 50393d43e7eSAnthony Xu 5049269b9d1SStefano Stabellini assert(shared_vmport_page); 50593d43e7eSAnthony Xu vmport_regs = 5069269b9d1SStefano Stabellini &shared_vmport_page->vcpu_vmport_regs[state->send_vcpu]; 50793d43e7eSAnthony Xu QEMU_BUILD_BUG_ON(sizeof(*req) < sizeof(*vmport_regs)); 50893d43e7eSAnthony Xu 50993d43e7eSAnthony Xu current_cpu = state->cpu_by_vcpu_id[state->send_vcpu]; 51093d43e7eSAnthony Xu regs_to_cpu(vmport_regs, req); 51193d43e7eSAnthony Xu cpu_ioreq_pio(req); 51293d43e7eSAnthony Xu regs_from_cpu(vmport_regs); 51393d43e7eSAnthony Xu current_cpu = NULL; 51493d43e7eSAnthony Xu } 51593d43e7eSAnthony Xu 516331b5189SIgor Druzhinin #ifdef XEN_COMPAT_PHYSMAP 51793d43e7eSAnthony Xu static void xen_read_physmap(XenIOState *state) 51893d43e7eSAnthony Xu { 51993d43e7eSAnthony Xu XenPhysmap *physmap = NULL; 52093d43e7eSAnthony Xu unsigned int len, num, i; 52193d43e7eSAnthony Xu char path[80], *value = NULL; 52293d43e7eSAnthony Xu char **entries = NULL; 52393d43e7eSAnthony Xu 52493d43e7eSAnthony Xu snprintf(path, sizeof(path), 52593d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap", xen_domid); 52693d43e7eSAnthony Xu entries = xs_directory(state->xenstore, 0, path, &num); 52793d43e7eSAnthony Xu if (entries == NULL) 52893d43e7eSAnthony Xu return; 52993d43e7eSAnthony Xu 53093d43e7eSAnthony Xu for (i = 0; i < num; i++) { 531b21e2380SMarkus Armbruster physmap = g_new(XenPhysmap, 1); 53293d43e7eSAnthony Xu physmap->phys_offset = strtoull(entries[i], NULL, 16); 53393d43e7eSAnthony Xu snprintf(path, sizeof(path), 53493d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap/%s/start_addr", 53593d43e7eSAnthony Xu xen_domid, entries[i]); 53693d43e7eSAnthony Xu value = xs_read(state->xenstore, 0, path, &len); 53793d43e7eSAnthony Xu if (value == NULL) { 53893d43e7eSAnthony Xu g_free(physmap); 53993d43e7eSAnthony Xu continue; 54093d43e7eSAnthony Xu } 54193d43e7eSAnthony Xu physmap->start_addr = strtoull(value, NULL, 16); 54293d43e7eSAnthony Xu free(value); 54393d43e7eSAnthony Xu 54493d43e7eSAnthony Xu snprintf(path, sizeof(path), 54593d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap/%s/size", 54693d43e7eSAnthony Xu xen_domid, entries[i]); 54793d43e7eSAnthony Xu value = xs_read(state->xenstore, 0, path, &len); 54893d43e7eSAnthony Xu if (value == NULL) { 54993d43e7eSAnthony Xu g_free(physmap); 55093d43e7eSAnthony Xu continue; 55193d43e7eSAnthony Xu } 55293d43e7eSAnthony Xu physmap->size = strtoull(value, NULL, 16); 55393d43e7eSAnthony Xu free(value); 55493d43e7eSAnthony Xu 55593d43e7eSAnthony Xu snprintf(path, sizeof(path), 55693d43e7eSAnthony Xu "/local/domain/0/device-model/%d/physmap/%s/name", 55793d43e7eSAnthony Xu xen_domid, entries[i]); 55893d43e7eSAnthony Xu physmap->name = xs_read(state->xenstore, 0, path, &len); 55993d43e7eSAnthony Xu 56004a8f72eSIgor Druzhinin QLIST_INSERT_HEAD(&xen_physmap, physmap, list); 56193d43e7eSAnthony Xu } 56293d43e7eSAnthony Xu free(entries); 56393d43e7eSAnthony Xu } 564331b5189SIgor Druzhinin #else 565331b5189SIgor Druzhinin static void xen_read_physmap(XenIOState *state) 566331b5189SIgor Druzhinin { 567331b5189SIgor Druzhinin } 568331b5189SIgor Druzhinin #endif 56993d43e7eSAnthony Xu 57093d43e7eSAnthony Xu static void xen_wakeup_notifier(Notifier *notifier, void *data) 57193d43e7eSAnthony Xu { 57293d43e7eSAnthony Xu xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); 57393d43e7eSAnthony Xu } 57493d43e7eSAnthony Xu 5755650ac00SPhilippe Mathieu-Daudé void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) 57693d43e7eSAnthony Xu { 5770e11fc69SLike Xu MachineState *ms = MACHINE(pcms); 5780e11fc69SLike Xu unsigned int max_cpus = ms->smp.max_cpus; 579*f17068c1SStefano Stabellini int rc; 58093d43e7eSAnthony Xu xen_pfn_t ioreq_pfn; 58193d43e7eSAnthony Xu XenIOState *state; 58293d43e7eSAnthony Xu 583b21e2380SMarkus Armbruster state = g_new0(XenIOState, 1); 58493d43e7eSAnthony Xu 585*f17068c1SStefano Stabellini xen_register_ioreq(state, max_cpus, xen_memory_listener); 58604a8f72eSIgor Druzhinin 58704a8f72eSIgor Druzhinin QLIST_INIT(&xen_physmap); 58893d43e7eSAnthony Xu xen_read_physmap(state); 58993d43e7eSAnthony Xu 5909269b9d1SStefano Stabellini suspend.notify = xen_suspend_notifier; 5919269b9d1SStefano Stabellini qemu_register_suspend_notifier(&suspend); 59233087aacSVikram Garhwal 5939269b9d1SStefano Stabellini wakeup.notify = xen_wakeup_notifier; 5949269b9d1SStefano Stabellini qemu_register_wakeup_notifier(&wakeup); 59533087aacSVikram Garhwal 59633087aacSVikram Garhwal rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn); 59733087aacSVikram Garhwal if (!rc) { 59833087aacSVikram Garhwal DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn); 5999269b9d1SStefano Stabellini shared_vmport_page = 60033087aacSVikram Garhwal xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ|PROT_WRITE, 60133087aacSVikram Garhwal 1, &ioreq_pfn, NULL); 6029269b9d1SStefano Stabellini if (shared_vmport_page == NULL) { 60333087aacSVikram Garhwal error_report("map shared vmport IO page returned error %d handle=%p", 60433087aacSVikram Garhwal errno, xen_xc); 60533087aacSVikram Garhwal goto err; 60633087aacSVikram Garhwal } 60733087aacSVikram Garhwal } else if (rc != -ENOSYS) { 60833087aacSVikram Garhwal error_report("get vmport regs pfn returned error %d, rc=%d", 60933087aacSVikram Garhwal errno, rc); 61033087aacSVikram Garhwal goto err; 61133087aacSVikram Garhwal } 61233087aacSVikram Garhwal 61333087aacSVikram Garhwal xen_ram_init(pcms, ms->ram_size, ram_memory); 61433087aacSVikram Garhwal 61593d43e7eSAnthony Xu /* Disable ACPI build because Xen handles it */ 61693d43e7eSAnthony Xu pcms->acpi_build_enabled = false; 61793d43e7eSAnthony Xu 61893d43e7eSAnthony Xu return; 61993d43e7eSAnthony Xu 62093d43e7eSAnthony Xu err: 62193d43e7eSAnthony Xu error_report("xen hardware virtual machine initialisation failed"); 62293d43e7eSAnthony Xu exit(1); 62393d43e7eSAnthony Xu } 62493d43e7eSAnthony Xu 62593d43e7eSAnthony Xu void xen_register_framebuffer(MemoryRegion *mr) 62693d43e7eSAnthony Xu { 62793d43e7eSAnthony Xu framebuffer = mr; 62893d43e7eSAnthony Xu } 62993d43e7eSAnthony Xu 63093d43e7eSAnthony Xu void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) 63193d43e7eSAnthony Xu { 63293d43e7eSAnthony Xu if (unlikely(xen_in_migration)) { 63393d43e7eSAnthony Xu int rc; 63493d43e7eSAnthony Xu ram_addr_t start_pfn, nb_pages; 63593d43e7eSAnthony Xu 63604a8f72eSIgor Druzhinin start = xen_phys_offset_to_gaddr(start, length); 63704a8f72eSIgor Druzhinin 63893d43e7eSAnthony Xu if (length == 0) { 63993d43e7eSAnthony Xu length = TARGET_PAGE_SIZE; 64093d43e7eSAnthony Xu } 64193d43e7eSAnthony Xu start_pfn = start >> TARGET_PAGE_BITS; 64293d43e7eSAnthony Xu nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS) 64393d43e7eSAnthony Xu - start_pfn; 64493d43e7eSAnthony Xu rc = xen_modified_memory(xen_domid, start_pfn, nb_pages); 64593d43e7eSAnthony Xu if (rc) { 64693d43e7eSAnthony Xu fprintf(stderr, 64793d43e7eSAnthony Xu "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n", 6487cdcca72SRoss Lagerwall __func__, start, nb_pages, errno, strerror(errno)); 64993d43e7eSAnthony Xu } 65093d43e7eSAnthony Xu } 65193d43e7eSAnthony Xu } 65293d43e7eSAnthony Xu 65393d43e7eSAnthony Xu void qmp_xen_set_global_dirty_log(bool enable, Error **errp) 65493d43e7eSAnthony Xu { 65593d43e7eSAnthony Xu if (enable) { 65663b41db4SHyman Huang(黄勇) memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION); 65793d43e7eSAnthony Xu } else { 65863b41db4SHyman Huang(黄勇) memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION); 65993d43e7eSAnthony Xu } 66093d43e7eSAnthony Xu } 661*f17068c1SStefano Stabellini 662*f17068c1SStefano Stabellini void arch_xen_set_memory(XenIOState *state, MemoryRegionSection *section, 663*f17068c1SStefano Stabellini bool add) 664*f17068c1SStefano Stabellini { 665*f17068c1SStefano Stabellini hwaddr start_addr = section->offset_within_address_space; 666*f17068c1SStefano Stabellini ram_addr_t size = int128_get64(section->size); 667*f17068c1SStefano Stabellini bool log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); 668*f17068c1SStefano Stabellini hvmmem_type_t mem_type; 669*f17068c1SStefano Stabellini 670*f17068c1SStefano Stabellini if (!memory_region_is_ram(section->mr)) { 671*f17068c1SStefano Stabellini return; 672*f17068c1SStefano Stabellini } 673*f17068c1SStefano Stabellini 674*f17068c1SStefano Stabellini if (log_dirty != add) { 675*f17068c1SStefano Stabellini return; 676*f17068c1SStefano Stabellini } 677*f17068c1SStefano Stabellini 678*f17068c1SStefano Stabellini trace_xen_client_set_memory(start_addr, size, log_dirty); 679*f17068c1SStefano Stabellini 680*f17068c1SStefano Stabellini start_addr &= TARGET_PAGE_MASK; 681*f17068c1SStefano Stabellini size = TARGET_PAGE_ALIGN(size); 682*f17068c1SStefano Stabellini 683*f17068c1SStefano Stabellini if (add) { 684*f17068c1SStefano Stabellini if (!memory_region_is_rom(section->mr)) { 685*f17068c1SStefano Stabellini xen_add_to_physmap(state, start_addr, size, 686*f17068c1SStefano Stabellini section->mr, section->offset_within_region); 687*f17068c1SStefano Stabellini } else { 688*f17068c1SStefano Stabellini mem_type = HVMMEM_ram_ro; 689*f17068c1SStefano Stabellini if (xen_set_mem_type(xen_domid, mem_type, 690*f17068c1SStefano Stabellini start_addr >> TARGET_PAGE_BITS, 691*f17068c1SStefano Stabellini size >> TARGET_PAGE_BITS)) { 692*f17068c1SStefano Stabellini DPRINTF("xen_set_mem_type error, addr: "HWADDR_FMT_plx"\n", 693*f17068c1SStefano Stabellini start_addr); 694*f17068c1SStefano Stabellini } 695*f17068c1SStefano Stabellini } 696*f17068c1SStefano Stabellini } else { 697*f17068c1SStefano Stabellini if (xen_remove_from_physmap(state, start_addr, size) < 0) { 698*f17068c1SStefano Stabellini DPRINTF("physmapping does not exist at "HWADDR_FMT_plx"\n", start_addr); 699*f17068c1SStefano Stabellini } 700*f17068c1SStefano Stabellini } 701*f17068c1SStefano Stabellini } 702*f17068c1SStefano Stabellini 703*f17068c1SStefano Stabellini void arch_handle_ioreq(XenIOState *state, ioreq_t *req) 704*f17068c1SStefano Stabellini { 705*f17068c1SStefano Stabellini switch (req->type) { 706*f17068c1SStefano Stabellini case IOREQ_TYPE_VMWARE_PORT: 707*f17068c1SStefano Stabellini handle_vmport_ioreq(state, req); 708*f17068c1SStefano Stabellini break; 709*f17068c1SStefano Stabellini default: 710*f17068c1SStefano Stabellini hw_error("Invalid ioreq type 0x%x\n", req->type); 711*f17068c1SStefano Stabellini } 712*f17068c1SStefano Stabellini 713*f17068c1SStefano Stabellini return; 714*f17068c1SStefano Stabellini } 715