Misc patches for 2018-02-05
Subsystems (2)
The following changes since commit f24ee107a07f093bd7ed475dd48d7ba57ea3d8fe:
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180202-pull-request' into staging (2018-02-02 18:54:11 +0000)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to d2eac10f23a071ddbd2970ed139c6ca077ff2e48:
Add the WHPX acceleration enlightenments (2018-02-05 18:30:55 +0100)
----------------------------------------------------------------
* socket option parsing fix (Daniel)
* SCSI fixes (Fam)
* Readline double-free fix (Greg)
* More HVF attribution fixes (Izik)
* WHPX (Windows Hypervisor Platform Extensions) support (Justin)
* POLLHUP handler (Klim)
* ivshmem fixes (Ladi)
* memfd memory backend (Marc-André)
* improved error message (Marcelo)
* Memory fixes (Peter Xu, Zhecheng)
* Remove obsolete code and comments (Peter M.)
* qdev API improvements (Philippe)
* Add CONFIG_I2C switch (Thomas)
----------------------------------------------------------------
Alexey Kardashevskiy (1):
kvm: Add kvm_set_user_memory tracepoint
Daniel P. Berrange (1):
sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
Fam Zheng (1):
scsi-generic: Simplify error handling code
Greg Kurz (2):
readline: don't free completions in readline_free() scripts/qemu-gdb/timers.py: define encoding in header comment
Izik Eidus (1):
Add missing hvdos public domain attribution:
Jay Zhou (1):
memory: update comments and fix some typos
Justin Terry (VM) (4):
Add the Windows Hypervisor Platform accelerator. Add the WHPX vcpu API
Introduce the WHPX impl
Add the WHPX acceleration enlightenments
Klim Kireev (2):
chardev/char-socket: add POLLHUP handler
tests/test-filter-redirector: move close()
Ladi Prosek (4):
ivshmem: Don't update non-existent MSI routes
ivshmem: Always remove irqfd notifiers
ivshmem: Improve MSI irqfd error handling
ivshmem: Disable irqfd on device reset
Marc-André Lureau (10):
exynos4210: workaround UBSAN compilation error
build-sys: add --enable-sanitizers
ucontext: annotate coroutine stack for ASAN
memfd: add error argument, instead of perror()
memfd: add hugetlb support
memfd: add hugetlbsize argument
Add memfd based hostmem
tests: keep compiling failing vhost-user tests
vhost-user-test: make read-guest-mem setup its own qemu
tests: use memfd in vhost-user-test
Marcelo Tosatti (1):
qemu: improve hugepage allocation failure message
Paolo Bonzini (7):
hvf: ept_emulation_fault() needs NetApp BSD attribution
cpus: hax: register/unregister thread with RCU, exit loop on unplug
cpus: kvm: unregister thread with RCU
cpus: dummy: unregister thread with RCU, exit loop on unplug
cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug
cpus: hvf: unregister thread with RCU
cpus: join thread when removing a vCPU
Peter Maydell (2):
memory-internal.h: Remove obsolete claim that header is obsolete Drop remaining bits of ia64 host support
Peter Xu (5):
chardev: fix incorrect unref of source
vhost: add traces for memory listeners
arm: postpone device listener unregister
vfio: listener unregister before unset container
memory: do explicit cleanup when remove listeners
Philippe Mathieu-Daudé (3):
qdev: rename typedef qdev_resetfn() -> DeviceReset()
qdev: add helpers to be more explicit when using abstract QOM parent functions
qdev: use device_class_set_parent_realize/unrealize/reset()
Thomas Huth (1):
i2c: Add a CONFIG_I2C master switch to the configuration files
linzhecheng (1):
memory: set ioeventfd_update_pending after address_space_update_ioeventfds
.travis.yml | 3 +- accel/kvm/kvm-all.c | 6 +- accel/kvm/trace-events | 1 + accel/stubs/Makefile.objs | 9 +- accel/stubs/whpx-stub.c | 48 ++ accel/tcg/user-exec.c | 33 - backends/Makefile.objs | 2 + backends/hostmem-memfd.c | 170 ++++ chardev/char-pty.c | 38 +- chardev/char-socket.c | 22 + configure | 118 ++- cpus.c | 109 ++- default-configs/arm-softmmu.mak | 1 + default-configs/i386-softmmu.mak | 1 + default-configs/mips-softmmu-common.mak | 1 + default-configs/ppc-softmmu.mak | 1 + default-configs/ppcemb-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/core/qdev.c | 24 + hw/display/exynos4210_fimd.c | 2 +- hw/i2c/Makefile.objs | 2 +- hw/i386/kvm/i8254.c | 4 +- hw/i386/kvm/i8259.c | 3 +- hw/input/adb-kbd.c | 4 +- hw/input/adb-mouse.c | 4 +- hw/intc/arm_gic.c | 3 +- hw/intc/arm_gic_kvm.c | 7 +- hw/intc/arm_gicv3.c | 3 +- hw/intc/arm_gicv3_its_kvm.c | 3 +- hw/intc/arm_gicv3_kvm.c | 7 +- hw/intc/i8259.c | 3 +- hw/misc/ivshmem.c | 79 +- hw/net/vmxnet3.c | 4 +- hw/nvram/Makefile.objs | 2 +- hw/pci-bridge/gen_pcie_root_port.c | 3 +- hw/scsi/scsi-generic.c | 9 +- hw/scsi/vmw_pvscsi.c | 4 +- hw/timer/i8254.c | 3 +- hw/vfio/amd-xgbe.c | 4 +- hw/vfio/calxeda-xgmac.c | 4 +- hw/vfio/common.c | 16 +- hw/virtio/trace-events | 6 + hw/virtio/vhost.c | 19 +- hw/virtio/virtio-pci.c | 4 +- include/exec/memory-internal.h | 7 +- include/exec/memory.h | 27 +- include/hw/qdev-core.h | 14 +- include/qemu/compiler.h | 4 + include/qemu/memfd.h | 5 +- include/qemu/processor.h | 3 - include/qemu/timer.h | 9 - include/sysemu/hw_accel.h | 13 + include/sysemu/whpx.h | 40 + linux-user/syscall.c | 7 +- memory.c | 28 + numa.c | 1 + qemu-options.hx | 30 +- scripts/qemugdb/timers.py | 1 + target/alpha/cpu.c | 4 +- target/arm/cpu.c | 4 +- target/arm/kvm.c | 2 +- target/cris/cpu.c | 4 +- target/hppa/cpu.c | 4 +- target/i386/Makefile.objs | 1 + target/i386/cpu.c | 8 +- target/i386/helper.c | 2 +- target/i386/hvf/hvf.c | 27 + target/i386/hvf/vmx.h | 3 + target/i386/whpx-all.c | 1366 +++++++++++++++++++++++++++++++ target/lm32/cpu.c | 5 +- target/m68k/cpu.c | 5 +- target/microblaze/cpu.c | 5 +- target/mips/cpu.c | 5 +- target/moxie/cpu.c | 5 +- target/nios2/cpu.c | 4 +- target/openrisc/cpu.c | 5 +- target/ppc/translate_init.c | 8 +- target/s390x/cpu.c | 4 +- target/sh4/cpu.c | 4 +- target/sparc/cpu.c | 4 +- target/tilegx/cpu.c | 4 +- target/tricore/cpu.c | 4 +- target/unicore32/cpu.c | 4 +- target/xtensa/cpu.c | 4 +- tests/test-filter-redirector.c | 2 +- tests/vhost-user-test.c | 128 ++- util/coroutine-ucontext.c | 48 ++ util/memfd.c | 78 +- util/qemu-sockets.c | 44 +- util/readline.c | 3 - 90 files changed, 2450 insertions(+), 328 deletions(-) create mode 100644 accel/stubs/whpx-stub.c create mode 100644 backends/hostmem-memfd.c create mode 100644 include/sysemu/whpx.h create mode 100644 target/i386/whpx-all.c
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 02/47] qdev: rename typedef qdev_resetfn() -> DeviceReset()
From: Philippe Mathieu-Daudé <[email protected]>
following the DeviceRealize and DeviceUnrealize typedefs, this unify a bit the new QOM API.
Message-Id: <[email protected]>
--- include/hw/qdev-core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/hw/qdev-core.h +2 -2
@@ -32,9 +32,9 @@ typedef enum DeviceCategory {typedef int (*qdev_initfn )(DeviceState *dev);typedef int (*qdev_event )(DeviceState *dev); -typedef void (*qdev_resetfn )(DeviceState *dev);typedef void (*DeviceRealize )(DeviceState *dev,Error **errp);typedef void (*DeviceUnrealize )(DeviceState *dev,Error **errp); +typedef void (*DeviceReset )(DeviceState *dev);typedef void (*BusRealize )(BusState *bus,Error **errp);typedef void (*BusUnrealize )(BusState *bus,Error **errp);
@@ -117,7 +117,7 @@ typedef struct DeviceClass {bool hotpluggable;/* callbacks */ -void (*reset)(DeviceState *dev); +DeviceReset reset;DeviceRealize realize;DeviceUnrealize unrealize;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 01/47] memory: update comments and fix some typos
In reply to Paolo BonziniFrom: Jay Zhou <[email protected]>
Message-Id: <[email protected]>
--- include/exec/memory.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
include/exec/memory.h +15 -12
@@ -324,7 +324,7 @@ FlatView *address_space_to_flatview(AddressSpace *as);* MemoryRegionSection: describes a fragment of a #MemoryRegion * * @mr: the region, or %NULL if empty -* @address_space: the address space the region is mapped in +* @fv: the flat view of the address space the region is mapped in * @offset_within_region: the beginning of the section, relative to @mr's start * @size: the size of the section; will not exceed @mr's boundaries * @offset_within_address_space: the address of the first byte of the section
@@ -610,6 +610,7 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr,* @mr: the #MemoryRegion to be initialized. * @owner: the object that tracks the region's reference count * @ops: callbacks for write access handling (must not be NULL). +* @opaque: passed to the read and write callbacks of the @ops structure. * @name: Region name, becomes part of RAMBlock name used in migration stream * must be unique within any device * @size: size of the region.
@@ -653,11 +654,10 @@ static inline void memory_region_init_reservation(MemoryRegion *mr,* An IOMMU region translates addresses and forwards accesses to a target * memory region. * -* @typename: QOM class name * @_iommu_mr: the #IOMMUMemoryRegion to be initialized * @instance_size: the IOMMUMemoryRegion subclass instance size +* @mrtypename: the type name of the #IOMMUMemoryRegion * @owner: the object that tracks the region's reference count -* @ops: a function that translates addresses into the @target region * @name: used for debugging; not visible to the user or ABI * @size: size of the region. */
@@ -827,8 +827,8 @@ static inline IOMMUMemoryRegion *memory_region_get_iommu(MemoryRegion *mr)* memory_region_get_iommu_class_nocheck: returns iommu memory region class * if an iommu or NULL if not * -* Returns pointer to IOMMUMemoryRegioniClass if a memory region is an iommu, -* otherwise NULL. This is fast path avoinding QOM checking, use with caution. +* Returns pointer to IOMMUMemoryRegionClass if a memory region is an iommu, +* otherwise NULL. This is fast path avoiding QOM checking, use with caution. * * @mr: the memory region being queried */
@@ -993,7 +993,8 @@ int memory_region_get_fd(MemoryRegion *mr);* protecting the pointer, such as a reference to the region that includes * the incoming ram_addr_t. * -* @mr: the memory region being queried. +* @ptr: the host pointer to be converted +* @offset: the offset within memory region */ MemoryRegion *memory_region_from_host (void *ptr,ram_addr_t *offset);
@@ -1270,7 +1271,7 @@ void memory_region_clear_global_locking(MemoryRegion *mr);* @size: the size of the access to trigger the eventfd * @match_data: whether to match against @data, instead of just @addr * @data: the data to match against the guest write -* @fd: the eventfd to be triggered when @addr, @size, and @data all match. +* @e: event notifier to be triggered when @addr, @size, and @data all match. **/ void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr,
@@ -1290,7 +1291,7 @@ void memory_region_add_eventfd(MemoryRegion *mr,* @size: the size of the access to trigger the eventfd * @match_data: whether to match against @data, instead of just @addr * @data: the data to match against the guest write -* @fd: the eventfd to be triggered when @addr, @size, and @data all match. +* @e: event notifier to be triggered when @addr, @size, and @data all match. */ void memory_region_del_eventfd(MemoryRegion *mr, hwaddr addr,
@@ -1526,7 +1527,7 @@ bool memory_region_request_mmio_ptr(MemoryRegion *mr, hwaddr addr);* will need to request the pointer again. * * @mr: #MemoryRegion associated to the pointer. -* @addr: address within that region +* @offset: offset within the memory region * @size: size of that area. */ void memory_region_invalidate_mmio_ptr(MemoryRegion *mr, hwaddr offset,
@@ -1595,6 +1596,7 @@ void address_space_destroy(AddressSpace *as);* @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred +* @len: the number of bytes to read or write * @is_write: indicates the transfer direction */ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,
@@ -1612,6 +1614,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,* @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred +* @len: the number of bytes to write */ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
@@ -1810,7 +1813,7 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,* called from an RCU critical section, to avoid that the last reference * to the returned region disappears after address_space_translate returns. * -* @as: #AddressSpace to be accessed +* @fv: #FlatView to be accessed * @addr: address within that address space * @xlat: pointer to address within the returned memory region section's * #MemoryRegion.
@@ -1868,7 +1871,7 @@ void *address_space_map(AddressSpace *as, hwaddr addr,* the amount of memory that was actually read or written by the caller. * * @as: #AddressSpace used -* @addr: address within that address space +* @buffer: host pointer as returned by address_space_map() * @len: buffer length as returned by address_space_map() * @access_len: amount of data actually transferred * @is_write: indicates the transfer direction
@@ -1905,7 +1908,7 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)* or failed (eg unassigned memory, device rejected the transaction, * IOMMU fault). * -* @as: #AddressSpace to be accessed +* @fv: #FlatView to be accessed * @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 03/47] qdev: add helpers to be more explicit when using abstract QOM parent functions
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
QOM API learning curve is quite hard, in particular when devices inherit from abstract parent.
To be more explicit about when a device class change the parent hooks, add few helpers hoping a device class_init() will be easier to understand.
Message-Id: <[email protected]>
--- hw/core/qdev.c | 24 ++++++++++++++++++++++++ include/hw/qdev-core.h | 10 ++++++++++ 2 files changed, 34 insertions(+)
hw/core/qdev.c +24 -0
@@ -1075,6 +1075,30 @@ static void device_class_init(ObjectClass *class, void *data) dc->user_creatable = true; } +void device_class_set_parent_reset (DeviceClass *dc, +DeviceReset dev_reset, +DeviceReset *parent_reset) +{ + *parent_reset = dc->reset; + dc->reset = dev_reset; +} + +void device_class_set_parent_realize (DeviceClass *dc, +DeviceRealize dev_realize, +DeviceRealize *parent_realize) +{ + *parent_realize = dc->realize; + dc->realize = dev_realize; +} + +void device_class_set_parent_unrealize (DeviceClass *dc, +DeviceUnrealize dev_unrealize, +DeviceUnrealize *parent_unrealize) +{ + *parent_unrealize = dc->unrealize; + dc->unrealize = dev_unrealize; +} +void device_reset (DeviceState *dev) {DeviceClass *klass =DEVICE_GET_CLASS (dev);
include/hw/qdev-core.h +10 -0
@@ -382,6 +382,16 @@ void qdev_machine_init(void);*/ void device_reset (DeviceState *dev); +void device_class_set_parent_reset (DeviceClass *dc, +DeviceReset dev_reset, +DeviceReset *parent_reset); +void device_class_set_parent_realize (DeviceClass *dc, +DeviceRealize dev_realize, +DeviceRealize *parent_realize); +void device_class_set_parent_unrealize (DeviceClass *dc, +DeviceUnrealize dev_unrealize, +DeviceUnrealize *parent_unrealize); +const struct VMStateDescription *qdev_get_vmsd (DeviceState *dev);const char *qdev_fw_name (DeviceState *dev);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 05/47] kvm: Add kvm_set_user_memory tracepoint
In reply to Paolo BonziniFrom: Alexey Kardashevskiy <[email protected]>
This adds a tracepoint to trace the KVM_SET_USER_MEMORY_REGION ioctl parameters which is quite useful for debugging VFIO memory regions being actually registered with KVM.
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 6 +++++- accel/kvm/trace-events | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
accel/kvm/kvm-all.c +5 -1
@@ -235,6 +235,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener *kml, KVMSlot *slot) {KVMState *s = kvm_state;struct kvm_userspace_memory_region mem; +int ret; mem.slot = slot->slot | (kml->as_id <<16 ); mem.guest_phys_addr = slot->start_addr;
@@ -248,7 +249,10 @@ static int kvm_set_user_memory_region(KVMMemoryListener *kml, KVMSlot *slot)kvm_vm_ioctl (s,KVM_SET_USER_MEMORY_REGION , &mem); } mem.memory_size = slot->memory_size; -return kvm_vm_ioctl (s,KVM_SET_USER_MEMORY_REGION , &mem); + ret =kvm_vm_ioctl (s,KVM_SET_USER_MEMORY_REGION , &mem); +trace_kvm_set_user_memory (mem.slot, mem.flags, mem.guest_phys_addr, + mem.memory_size, mem.userspace_addr, ret); +return ret; }int kvm_destroy_vcpu (CPUState *cpu)
accel/kvm/trace-events +1 -0
@@ -12,4 +12,5 @@ kvm_irqchip_commit_routes(void) "" kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector %d virq %d" kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d" kvm_irqchip_release_virq(int virq) "virq %d" +kvm_set_user_memory(uint32_t slot, uint32_t flags, uint64_t guest_phys_addr, uint64_t memory_size, uint64_t userspace_addr, int ret) "Slot#%d flags=0x%x gpa=0x%"PRIx64 " size=0x%"PRIx64 " ua=0x%"PRIx64 " ret=%d"
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 06/47] qemu: improve hugepage allocation failure message
In reply to Paolo BonziniFrom: Marcelo Tosatti <[email protected]>
Improve hugepage allocation failure message, indicating what is happening to the user.
Message-Id: <[email protected]>
--- numa.c | 1 + 1 file changed, 1 insertion(+)
numa.c +1 -0
@@ -463,6 +463,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,if (mem_prealloc) {exit (1 ); } +error_report ("falling back to regular RAM allocation." );/* Legacy behavior: if allocation failed, fall back to * regular RAM allocation.
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 04/47] qdev: use device_class_set_parent_realize/unrealize/reset()
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
changes generated using the following Coccinelle patch:
@@ type DeviceParentClass; DeviceParentClass *pc; DeviceClass *dc; identifier parent_fn; identifier child_fn; @@ ( +device_class_set_parent_realize(dc, child_fn, &pc->parent_fn); -pc->parent_fn = dc->realize; ... -dc->realize = child_fn; | +device_class_set_parent_unrealize(dc, child_fn, &pc->parent_fn); -pc->parent_fn = dc->unrealize; ... -dc->unrealize = child_fn; | +device_class_set_parent_reset(dc, child_fn, &pc->parent_fn); -pc->parent_fn = dc->reset; ... -dc->reset = child_fn; )
Message-Id: <[email protected]>
--- hw/i386/kvm/i8254.c | 4 ++-- hw/i386/kvm/i8259.c | 3 +-- hw/input/adb-kbd.c | 4 ++-- hw/input/adb-mouse.c | 4 ++-- hw/intc/arm_gic.c | 3 +-- hw/intc/arm_gic_kvm.c | 7 +++---- hw/intc/arm_gicv3.c | 3 +-- hw/intc/arm_gicv3_its_kvm.c | 3 +-- hw/intc/arm_gicv3_kvm.c | 7 +++---- hw/intc/i8259.c | 3 +-- hw/net/vmxnet3.c | 4 ++-- hw/pci-bridge/gen_pcie_root_port.c | 3 +-- hw/scsi/vmw_pvscsi.c | 4 ++-- hw/timer/i8254.c | 3 +-- hw/vfio/amd-xgbe.c | 4 ++-- hw/vfio/calxeda-xgmac.c | 4 ++-- hw/virtio/virtio-pci.c | 4 ++-- target/alpha/cpu.c | 4 ++-- target/arm/cpu.c | 4 ++-- target/cris/cpu.c | 4 ++-- target/hppa/cpu.c | 4 ++-- target/i386/cpu.c | 8 ++++---- target/lm32/cpu.c | 5 ++--- target/m68k/cpu.c | 5 ++--- target/microblaze/cpu.c | 5 ++--- target/mips/cpu.c | 5 ++--- target/moxie/cpu.c | 5 ++--- target/nios2/cpu.c | 4 ++-- target/openrisc/cpu.c | 5 ++--- target/ppc/translate_init.c | 8 ++++---- target/s390x/cpu.c | 4 ++-- target/sh4/cpu.c | 4 ++-- target/sparc/cpu.c | 4 ++-- target/tilegx/cpu.c | 4 ++-- target/tricore/cpu.c | 4 ++-- target/unicore32/cpu.c | 4 ++-- target/xtensa/cpu.c | 4 ++-- 37 files changed, 73 insertions(+), 88 deletions(-)
hw/i386/kvm/i8254.c +2 -2
@@ -315,8 +315,8 @@ static void kvm_pit_class_init(ObjectClass *klass, void *data)PITCommonClass *k =PIT_COMMON_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); - kpc->parent_realize = dc->realize; - dc->realize = kvm_pit_realizefn; +device_class_set_parent_realize (dc, kvm_pit_realizefn, + &kpc->parent_realize); k->set_channel_gate = kvm_pit_set_gate; k->get_channel_info = kvm_pit_get_channel_info; dc->reset = kvm_pit_reset;
hw/i386/kvm/i8259.c +1 -2
@@ -142,8 +142,7 @@ static void kvm_i8259_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass); dc->reset = kvm_pic_reset; - kpc->parent_realize = dc->realize; - dc->realize = kvm_pic_realize; +device_class_set_parent_realize (dc, kvm_pic_realize, &kpc->parent_realize); k->pre_save = kvm_pic_get; k->post_load = kvm_pic_put; }
hw/input/adb-kbd.c +2 -2
@@ -374,8 +374,8 @@ static void adb_kbd_class_init(ObjectClass *oc, void *data)ADBDeviceClass *adc =ADB_DEVICE_CLASS (oc);ADBKeyboardClass *akc =ADB_KEYBOARD_CLASS (oc); - akc->parent_realize = dc->realize; - dc->realize = adb_kbd_realizefn; +device_class_set_parent_realize (dc, adb_kbd_realizefn, + &akc->parent_realize);set_bit (DEVICE_CATEGORY_INPUT , dc->categories); adc->devreq = adb_kbd_request;
hw/input/adb-mouse.c +2 -2
@@ -228,8 +228,8 @@ static void adb_mouse_class_init(ObjectClass *oc, void *data)ADBDeviceClass *adc =ADB_DEVICE_CLASS (oc);ADBMouseClass *amc =ADB_MOUSE_CLASS (oc); - amc->parent_realize = dc->realize; - dc->realize = adb_mouse_realizefn; +device_class_set_parent_realize (dc, adb_mouse_realizefn, + &amc->parent_realize);set_bit (DEVICE_CATEGORY_INPUT , dc->categories); adc->devreq = adb_mouse_request;
hw/intc/arm_gic.c +1 -2
@@ -1461,8 +1461,7 @@ static void arm_gic_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);ARMGICClass *agc =ARM_GIC_CLASS (klass); - agc->parent_realize = dc->realize; - dc->realize = arm_gic_realize; +device_class_set_parent_realize (dc, arm_gic_realize, &agc->parent_realize); }static const TypeInfo arm_gic_info = {
hw/intc/arm_gic_kvm.c +3 -4
@@ -591,10 +591,9 @@ static void kvm_arm_gic_class_init(ObjectClass *klass, void *data) agcc->pre_save = kvm_arm_gic_get; agcc->post_load = kvm_arm_gic_put; - kgc->parent_realize = dc->realize; - kgc->parent_reset = dc->reset; - dc->realize = kvm_arm_gic_realize; - dc->reset = kvm_arm_gic_reset; +device_class_set_parent_realize (dc, kvm_arm_gic_realize, + &kgc->parent_realize); +device_class_set_parent_reset (dc, kvm_arm_gic_reset, &kgc->parent_reset); }static const TypeInfo kvm_arm_gic_info = {
hw/intc/arm_gicv3.c +1 -2
@@ -385,8 +385,7 @@ static void arm_gicv3_class_init(ObjectClass *klass, void *data)ARMGICv3Class *agc =ARM_GICV3_CLASS (klass); agcc->post_load = arm_gicv3_post_load; - agc->parent_realize = dc->realize; - dc->realize = arm_gic_realize; +device_class_set_parent_realize (dc, arm_gic_realize, &agc->parent_realize); }static const TypeInfo arm_gicv3_info = {
hw/intc/arm_gicv3_its_kvm.c +1 -2
@@ -245,11 +245,10 @@ static void kvm_arm_its_class_init(ObjectClass *klass, void *data) dc->realize = kvm_arm_its_realize; dc->props = kvm_arm_its_props; - ic->parent_reset = dc->reset; +device_class_set_parent_reset (dc, kvm_arm_its_reset, &ic->parent_reset); icc->send_msi = kvm_its_send_msi; icc->pre_save = kvm_arm_its_pre_save; icc->post_load = kvm_arm_its_post_load; - dc->reset = kvm_arm_its_reset; }static const TypeInfo kvm_arm_its_info = {
hw/intc/arm_gicv3_kvm.c +3 -4
@@ -795,10 +795,9 @@ static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data) agcc->pre_save = kvm_arm_gicv3_get; agcc->post_load = kvm_arm_gicv3_put; - kgc->parent_realize = dc->realize; - kgc->parent_reset = dc->reset; - dc->realize = kvm_arm_gicv3_realize; - dc->reset = kvm_arm_gicv3_reset; +device_class_set_parent_realize (dc, kvm_arm_gicv3_realize, + &kgc->parent_realize); +device_class_set_parent_reset (dc, kvm_arm_gicv3_reset, &kgc->parent_reset); }static const TypeInfo kvm_arm_gicv3_info = {
hw/intc/i8259.c +1 -2
@@ -443,8 +443,7 @@ static void i8259_class_init(ObjectClass *klass, void *data)PICClass *k =PIC_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); - k->parent_realize = dc->realize; - dc->realize = pic_realize; +device_class_set_parent_realize (dc, pic_realize, &k->parent_realize); dc->reset = pic_reset; }
hw/net/vmxnet3.c +2 -2
@@ -2664,8 +2664,8 @@ static void vmxnet3_class_init(ObjectClass *class, void *data) c->class_id =PCI_CLASS_NETWORK_ETHERNET ; c->subsystem_vendor_id =PCI_VENDOR_ID_VMWARE ; c->subsystem_id =PCI_DEVICE_ID_VMWARE_VMXNET3 ; - vc->parent_dc_realize = dc->realize; - dc->realize = vmxnet3_realize; +device_class_set_parent_realize (dc, vmxnet3_realize, + &vc->parent_dc_realize); dc->desc ="VMWare Paravirtualized Ethernet v3" ; dc->reset = vmxnet3_qdev_reset; dc->vmsd = &vmstate_vmxnet3;
hw/pci-bridge/gen_pcie_root_port.c +1 -2
@@ -137,8 +137,7 @@ static void gen_rp_dev_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_rp_dev; dc->props = gen_rp_props; - rpc->parent_realize = dc->realize; - dc->realize = gen_rp_realize; +device_class_set_parent_realize (dc, gen_rp_realize, &rpc->parent_realize); rpc->aer_vector = gen_rp_aer_vector; rpc->interrupts_init = gen_rp_interrupts_init;
hw/scsi/vmw_pvscsi.c +2 -2
@@ -1284,8 +1284,8 @@ static void pvscsi_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_VMWARE_PVSCSI ; k->class_id =PCI_CLASS_STORAGE_SCSI ; k->subsystem_id =0x1000 ; - pvs_k->parent_dc_realize = dc->realize; - dc->realize = pvscsi_realize; +device_class_set_parent_realize (dc, pvscsi_realize, + &pvs_k->parent_dc_realize); dc->reset = pvscsi_reset; dc->vmsd = &vmstate_pvscsi; dc->props = pvscsi_properties;
hw/timer/i8254.c +1 -2
@@ -358,8 +358,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data)PITCommonClass *k =PIT_COMMON_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); - pc->parent_realize = dc->realize; - dc->realize = pit_realizefn; +device_class_set_parent_realize (dc, pit_realizefn, &pc->parent_realize); k->set_channel_gate = pit_set_channel_gate; k->get_channel_info = pit_get_channel_info_common; k->post_load = pit_post_load;
hw/vfio/amd-xgbe.c +2 -2
@@ -34,8 +34,8 @@ static void vfio_amd_xgbe_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);VFIOAmdXgbeDeviceClass *vcxc =VFIO_AMD_XGBE_DEVICE_CLASS (klass); - vcxc->parent_realize = dc->realize; - dc->realize = amd_xgbe_realize; +device_class_set_parent_realize (dc, amd_xgbe_realize, + &vcxc->parent_realize); dc->desc ="VFIO AMD XGBE" ; dc->vmsd = &vfio_platform_amd_xgbe_vmstate;/* Supported by TYPE_VIRT_MACHINE */
hw/vfio/calxeda-xgmac.c +2 -2
@@ -34,8 +34,8 @@ static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);VFIOCalxedaXgmacDeviceClass *vcxc =VFIO_CALXEDA_XGMAC_DEVICE_CLASS (klass); - vcxc->parent_realize = dc->realize; - dc->realize = calxeda_xgmac_realize; +device_class_set_parent_realize (dc, calxeda_xgmac_realize, + &vcxc->parent_realize); dc->desc ="VFIO Calxeda XGMAC" ; dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate;/* Supported by TYPE_VIRT_MACHINE */
hw/virtio/virtio-pci.c +2 -2
@@ -1907,8 +1907,8 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data) k->vendor_id =PCI_VENDOR_ID_REDHAT_QUMRANET ; k->revision =VIRTIO_PCI_ABI_VERSION ; k->class_id =PCI_CLASS_OTHERS ; - vpciklass->parent_dc_realize = dc->realize; - dc->realize = virtio_pci_dc_realize; +device_class_set_parent_realize (dc, virtio_pci_dc_realize, + &vpciklass->parent_dc_realize); dc->reset = virtio_pci_reset; }
target/alpha/cpu.c +2 -2
@@ -233,8 +233,8 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);AlphaCPUClass *acc =ALPHA_CPU_CLASS (oc); - acc->parent_realize = dc->realize; - dc->realize = alpha_cpu_realizefn; +device_class_set_parent_realize (dc, alpha_cpu_realizefn, + &acc->parent_realize); cc->class_by_name = alpha_cpu_class_by_name; cc->has_work = alpha_cpu_has_work;
target/arm/cpu.c +2 -2
@@ -1722,8 +1722,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (acc);DeviceClass *dc =DEVICE_CLASS (oc); - acc->parent_realize = dc->realize; - dc->realize = arm_cpu_realizefn; +device_class_set_parent_realize (dc, arm_cpu_realizefn, + &acc->parent_realize); dc->props = arm_cpu_properties; acc->parent_reset = cc->reset;
target/cris/cpu.c +2 -2
@@ -260,8 +260,8 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);CRISCPUClass *ccc =CRIS_CPU_CLASS (oc); - ccc->parent_realize = dc->realize; - dc->realize = cris_cpu_realizefn; +device_class_set_parent_realize (dc, cris_cpu_realizefn, + &ccc->parent_realize); ccc->parent_reset = cc->reset; cc->reset = cris_cpu_reset;
target/hppa/cpu.c +2 -2
@@ -168,8 +168,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);HPPACPUClass *acc =HPPA_CPU_CLASS (oc); - acc->parent_realize = dc->realize; - dc->realize = hppa_cpu_realizefn; +device_class_set_parent_realize (dc, hppa_cpu_realizefn, + &acc->parent_realize); cc->class_by_name = hppa_cpu_class_by_name; cc->has_work = hppa_cpu_has_work;
target/i386/cpu.c +4 -4
@@ -4705,10 +4705,10 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);DeviceClass *dc =DEVICE_CLASS (oc); - xcc->parent_realize = dc->realize; - xcc->parent_unrealize = dc->unrealize; - dc->realize = x86_cpu_realizefn; - dc->unrealize = x86_cpu_unrealizefn; +device_class_set_parent_realize (dc, x86_cpu_realizefn, + &xcc->parent_realize); +device_class_set_parent_unrealize (dc, x86_cpu_unrealizefn, + &xcc->parent_unrealize); dc->props = x86_cpu_properties; xcc->parent_reset = cc->reset;
target/lm32/cpu.c +2 -3
@@ -236,9 +236,8 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);DeviceClass *dc =DEVICE_CLASS (oc); - lcc->parent_realize = dc->realize; - dc->realize = lm32_cpu_realizefn; - +device_class_set_parent_realize (dc, lm32_cpu_realizefn, + &lcc->parent_realize); lcc->parent_reset = cc->reset; cc->reset = lm32_cpu_reset;
target/m68k/cpu.c +2 -3
@@ -255,9 +255,8 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)CPUClass *cc =CPU_CLASS (c);DeviceClass *dc =DEVICE_CLASS (c); - mcc->parent_realize = dc->realize; - dc->realize = m68k_cpu_realizefn; - +device_class_set_parent_realize (dc, m68k_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset = cc->reset; cc->reset = m68k_cpu_reset;
target/microblaze/cpu.c +2 -3
@@ -258,9 +258,8 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);MicroBlazeCPUClass *mcc =MICROBLAZE_CPU_CLASS (oc); - mcc->parent_realize = dc->realize; - dc->realize = mb_cpu_realizefn; - +device_class_set_parent_realize (dc, mb_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset = cc->reset; cc->reset = mb_cpu_reset;
target/mips/cpu.c +2 -3
@@ -174,9 +174,8 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)CPUClass *cc =CPU_CLASS (c);DeviceClass *dc =DEVICE_CLASS (c); - mcc->parent_realize = dc->realize; - dc->realize = mips_cpu_realizefn; - +device_class_set_parent_realize (dc, mips_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset = cc->reset; cc->reset = mips_cpu_reset;
target/moxie/cpu.c +2 -3
@@ -102,9 +102,8 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);MoxieCPUClass *mcc =MOXIE_CPU_CLASS (oc); - mcc->parent_realize = dc->realize; - dc->realize = moxie_cpu_realizefn; - +device_class_set_parent_realize (dc, moxie_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset = cc->reset; cc->reset = moxie_cpu_reset;
target/nios2/cpu.c +2 -2
@@ -187,8 +187,8 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);Nios2CPUClass *ncc =NIOS2_CPU_CLASS (oc); - ncc->parent_realize = dc->realize; - dc->realize = nios2_cpu_realizefn; +device_class_set_parent_realize (dc, nios2_cpu_realizefn, + &ncc->parent_realize); dc->props = nios2_properties; ncc->parent_reset = cc->reset; cc->reset = nios2_cpu_reset;
target/openrisc/cpu.c +2 -3
@@ -132,9 +132,8 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (occ);DeviceClass *dc =DEVICE_CLASS (oc); - occ->parent_realize = dc->realize; - dc->realize = openrisc_cpu_realizefn; - +device_class_set_parent_realize (dc, openrisc_cpu_realizefn, + &occ->parent_realize); occ->parent_reset = cc->reset; cc->reset = openrisc_cpu_reset;
target/ppc/translate_init.c +4 -4
@@ -10556,12 +10556,12 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);DeviceClass *dc =DEVICE_CLASS (oc); - pcc->parent_realize = dc->realize; - pcc->parent_unrealize = dc->unrealize; +device_class_set_parent_realize (dc, ppc_cpu_realizefn, + &pcc->parent_realize); +device_class_set_parent_unrealize (dc, ppc_cpu_unrealizefn, + &pcc->parent_unrealize); pcc->pvr_match = ppc_pvr_match_default; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_always; - dc->realize = ppc_cpu_realizefn; - dc->unrealize = ppc_cpu_unrealizefn; dc->props = ppc_cpu_properties; pcc->parent_reset = cc->reset;
target/s390x/cpu.c +2 -2
@@ -464,8 +464,8 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (scc);DeviceClass *dc =DEVICE_CLASS (oc); - scc->parent_realize = dc->realize; - dc->realize = s390_cpu_realizefn; +device_class_set_parent_realize (dc, s390_cpu_realizefn, + &scc->parent_realize); dc->props = s390x_cpu_properties; dc->user_creatable = true;
target/sh4/cpu.c +2 -2
@@ -236,8 +236,8 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);SuperHCPUClass *scc =SUPERH_CPU_CLASS (oc); - scc->parent_realize = dc->realize; - dc->realize = superh_cpu_realizefn; +device_class_set_parent_realize (dc, superh_cpu_realizefn, + &scc->parent_realize); scc->parent_reset = cc->reset; cc->reset = superh_cpu_reset;
target/sparc/cpu.c +2 -2
@@ -858,8 +858,8 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);DeviceClass *dc =DEVICE_CLASS (oc); - scc->parent_realize = dc->realize; - dc->realize = sparc_cpu_realizefn; +device_class_set_parent_realize (dc, sparc_cpu_realizefn, + &scc->parent_realize); dc->props = sparc_cpu_properties; scc->parent_reset = cc->reset;
target/tilegx/cpu.c +2 -2
@@ -141,8 +141,8 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);TileGXCPUClass *tcc =TILEGX_CPU_CLASS (oc); - tcc->parent_realize = dc->realize; - dc->realize = tilegx_cpu_realizefn; +device_class_set_parent_realize (dc, tilegx_cpu_realizefn, + &tcc->parent_realize); tcc->parent_reset = cc->reset; cc->reset = tilegx_cpu_reset;
target/tricore/cpu.c +2 -2
@@ -153,8 +153,8 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)CPUClass *cc =CPU_CLASS (c);DeviceClass *dc =DEVICE_CLASS (c); - mcc->parent_realize = dc->realize; - dc->realize = tricore_cpu_realizefn; +device_class_set_parent_realize (dc, tricore_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset = cc->reset; cc->reset = tricore_cpu_reset;
target/unicore32/cpu.c +2 -2
@@ -132,8 +132,8 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);UniCore32CPUClass *ucc =UNICORE32_CPU_CLASS (oc); - ucc->parent_realize = dc->realize; - dc->realize = uc32_cpu_realizefn; +device_class_set_parent_realize (dc, uc32_cpu_realizefn, + &ucc->parent_realize); cc->class_by_name = uc32_cpu_class_by_name; cc->has_work = uc32_cpu_has_work;
target/xtensa/cpu.c +2 -2
@@ -151,8 +151,8 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc);XtensaCPUClass *xcc =XTENSA_CPU_CLASS (cc); - xcc->parent_realize = dc->realize; - dc->realize = xtensa_cpu_realizefn; +device_class_set_parent_realize (dc, xtensa_cpu_realizefn, + &xcc->parent_realize); xcc->parent_reset = cc->reset; cc->reset = xtensa_cpu_reset;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 07/47] memory: set ioeventfd_update_pending after address_space_update_ioeventfds
In reply to Paolo BonziniFrom: linzhecheng <[email protected]>
We should set ioeventfd_update_pending same as memory_region_update_pending.
Message-Id: <[email protected]>
--- memory.c | 1 + 1 file changed, 1 insertion(+)
memory.c +1 -0
@@ -1091,6 +1091,7 @@ void memory_region_transaction_commit(void)address_space_update_ioeventfds (as); } memory_region_update_pending = false; + ioeventfd_update_pending = false;MEMORY_LISTENER_CALL_GLOBAL (commit, Forward); }else if (ioeventfd_update_pending) { QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 09/47] chardev: fix incorrect unref of source
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
glib reported error when pty chardev used:
$ ./qemu-system-x86_64 -chardev pty,id=foo -device isa-serial,chardev=foo qemu-system-x86_64: -chardev pty,id=foo: char device redirected to /dev/pts/2 (label foo) (qemu-system-x86_64:27885): GLib-CRITICAL **: g_source_unref: assertion 'source != NULL' failed (qemu-system-x86_64:27885): GLib-CRITICAL **: g_source_unref: assertion 'source != NULL' failed
This patch fixes that.
Message-Id: <[email protected]>
--- chardev/char-pty.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-)
chardev/char-pty.c +21 -17
@@ -51,15 +51,32 @@ typedef struct {static void pty_chr_update_read_handler_locked (Chardev *chr);static void pty_chr_state (Chardev *chr,int connected); +static void pty_chr_timer_cancel (PtyChardev *s) +{ +if (s->timer_src) { +g_source_destroy (s->timer_src); +g_source_unref (s->timer_src); + s->timer_src =NULL ; + } +} + +static void pty_chr_open_src_cancel (PtyChardev *s) +{ +if (s->open_source) { +g_source_destroy (s->open_source); +g_source_unref (s->open_source); + s->open_source =NULL ; + } +} +static gboolean pty_chr_timer (gpointer opaque) {struct Chardev *chr =CHARDEV (opaque);PtyChardev *s =PTY_CHARDEV (opaque);qemu_mutex_lock (&chr->chr_write_lock); - s->timer_src =NULL ; -g_source_unref (s->open_source); - s->open_source =NULL ; +pty_chr_timer_cancel (s); +pty_chr_open_src_cancel (s);if (!s->connected) {/* Next poll ... */ pty_chr_update_read_handler_locked (chr);
@@ -68,15 +85,6 @@ static gboolean pty_chr_timer(gpointer opaque)return FALSE; } -static void pty_chr_timer_cancel (PtyChardev *s) -{ -if (s->timer_src) { -g_source_destroy (s->timer_src); -g_source_unref (s->timer_src); - s->timer_src =NULL ; - } -} -/* Called with chr_write_lock held. */ static void pty_chr_rearm_timer (Chardev *chr,int ms) {
@@ -195,11 +203,7 @@ static void pty_chr_state(Chardev *chr, int connected)PtyChardev *s =PTY_CHARDEV (chr);if (!connected) { -if (s->open_source) { -g_source_destroy (s->open_source); -g_source_unref (s->open_source); - s->open_source =NULL ; - } +pty_chr_open_src_cancel (s);remove_fd_in_watch (chr); s->connected =0 ;/* (re-)connect poll interval for idle guests: once per second.
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 10/47] readline: don't free completions in readline_free()
In reply to Paolo BonziniFrom: Greg Kurz <[email protected]>
Since commit e5dc1a6c6c43, QEMU aborts on exit if completion was used in the monitor:
*** Error in `obj/ppc64-softmmu/qemu-system-ppc64': double free or
corruption (fasttop): 0x00000100331069d0 ***
/home/greg/Work/qemu/qemu-spapr/util/readline.c:514 /home/greg/Work/qemu/qemu-spapr/monitor.c:586 /home/greg/Work/qemu/qemu-spapr/monitor.c:4125 argv=<optimized out>, envp=<optimized out>) at /home/greg/Work/qemu/qemu-spapr/vl.c:4795
Completion strings are not persistent accross completions (why would they?). They are allocated under readline_completion(), which already takes care of freeing them before returning.
Maybe all completion related bits should be moved out of ReadLineState to a dedicated structure ?
In the meantime, let's drop the offending lines from readline_free() to fix the crash.
Message-Id: <[email protected]>
--- util/readline.c | 3 --- 1 file changed, 3 deletions(-)
util/readline.c +0 -3
@@ -510,9 +510,6 @@ void readline_free(ReadLineState *rs)for (i =0 ; i <READLINE_MAX_CMDS ; i++) {g_free (rs->history[i]); } -for (i =0 ; i <READLINE_MAX_COMPLETIONS ; i++) { -g_free (rs->completions[i]); - }g_free (rs); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 08/47] scsi-generic: Simplify error handling code
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Coverity doesn't like the ignored return value introduced in 9d3b155186c278 (hw/block: Fix the return type), and other callers are converted already in ceff3e1f01.
This one was added lately in d9bcd6f7f23a and missed the train. Do it now.
Message-Id: <[email protected]>
--- hw/scsi/scsi-generic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
hw/scsi/scsi-generic.c +3 -6
@@ -482,7 +482,6 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp)int rc;int sg_version;struct sg_scsi_id scsiid; -Error *local_err =NULL ;if (!s->conf.blk) {error_setg (errp,"drive property not set" );
@@ -516,11 +515,9 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp)error_setg (errp,"SG_GET_SCSI_ID ioctl failed" );return ; } -blkconf_apply_backend_options (&s->conf, -blk_is_read_only (s->conf.blk), - true, &local_err); -if (local_err) { -error_propagate (errp, local_err); +if (!blkconf_apply_backend_options (&s->conf, +blk_is_read_only (s->conf.blk), + true, errp)) {return ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 11/47] scripts/qemu-gdb/timers.py: define encoding in header comment
In reply to Paolo BonziniFrom: Greg Kurz <[email protected]>
This is required otherwise python complains because of the accentuated letter in Alex's last name:
Traceback (most recent call last):
File "scripts/qemu-gdb.py", line 29, in <module>
from qemugdb import aio, mtree, coroutine, tcg, timers
File "scripts/qemugdb/timers.py", line 1
SyntaxError: Non-ASCII character '\xc3' in file scripts/qemugdb/timers.py
on line 1, but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details
Message-Id: <[email protected]>
--- scripts/qemugdb/timers.py | 1 + 1 file changed, 1 insertion(+)
scripts/qemugdb/timers.py +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # GDB debugging support # # Copyright 2017 Linaro Ltd
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 12/47] memory-internal.h: Remove obsolete claim that header is obsolete
In reply to Paolo BonziniFrom: Peter Maydell <[email protected]>
The memory-internal.h header claims that it is for "obsolete exec.c functions" which "will be removed soon". This statement was added in 2011, six years ago, but the header is still here. (Admittedly none of the prototypes added in commit 67d95c153bef55f6 are still in the header.)
It's convenient to have a place to put prototypes for functions which are used internally to the various .c files of the memory system or by the accel/tcg code, which is inevitably fairly closely coupled. So keep the header but update the comments to reflect what we're actually using it for.
Message-Id: <[email protected]>
--- include/exec/memory-internal.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
include/exec/memory-internal.h +4 -3
@@ -1,5 +1,5 @@/* -* Declarations for obsolete exec.c functions +* Declarations for functions which are internal to the memory subsystem. * * Copyright 2011 Red Hat, Inc. and/or its affiliates *
@@ -12,8 +12,9 @@*/ /* -* This header is for use by exec.c and memory.c ONLY. Do not include it. -* The functions declared here will be removed soon. +* This header is for use by exec.c, memory.c and accel/tcg/cputlb.c ONLY, +* for declarations which are shared between the memory subsystem's +* internals and the TCG TLB code. Do not include it from elsewhere. */ #ifndef MEMORY_INTERNAL_H
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 13/47] i2c: Add a CONFIG_I2C master switch to the configuration files
In reply to Paolo BonziniFrom: Thomas Huth <[email protected]>
The i2c core and the at24c EEPROM should only be compiled and linked on the machines that support i2c. Otherwise it's quite strange to see the at24c-eeprom to be "available" on qemu-system-s390x for example.
Message-Id: <[email protected]>
--- default-configs/arm-softmmu.mak | 1 + default-configs/i386-softmmu.mak | 1 + default-configs/mips-softmmu-common.mak | 1 + default-configs/ppc-softmmu.mak | 1 + default-configs/ppcemb-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/i2c/Makefile.objs | 2 +- hw/nvram/Makefile.objs | 2 +- 8 files changed, 8 insertions(+), 2 deletions(-)
default-configs/arm-softmmu.mak +1 -0
@@ -67,6 +67,7 @@ CONFIG_CADENCE=y CONFIG_XGMAC=y CONFIG_EXYNOS4=y CONFIG_PXA2XX=y +CONFIG_I2C=y CONFIG_BITBANG_I2C=y CONFIG_FRAMEBUFFER=y CONFIG_XILINX_SPIPS=y
default-configs/i386-softmmu.mak +1 -0
@@ -62,3 +62,4 @@ CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM) CONFIG_PXB=y CONFIG_ACPI_VMGENID=y CONFIG_FW_CFG_DMA=y +CONFIG_I2C=y
default-configs/mips-softmmu-common.mak +1 -0
@@ -34,3 +34,4 @@ CONFIG_ISA_TESTDEV=y CONFIG_EMPTY_SLOT=y CONFIG_MIPS_CPS=y CONFIG_MIPS_ITU=y +CONFIG_I2C=y
default-configs/ppc-softmmu.mak +1 -0
@@ -23,6 +23,7 @@ CONFIG_PLATFORM_BUS=y CONFIG_ETSEC=y CONFIG_SM501=y CONFIG_IDE_SII3112=y +CONFIG_I2C=y # For Macs CONFIG_MAC=y
default-configs/ppcemb-softmmu.mak +1 -0
@@ -17,3 +17,4 @@ CONFIG_XILINX=y CONFIG_XILINX_ETHLITE=y CONFIG_SM501=y CONFIG_IDE_SII3112=y +CONFIG_I2C=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -62,3 +62,4 @@ CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM) CONFIG_PXB=y CONFIG_ACPI_VMGENID=y CONFIG_FW_CFG_DMA=y +CONFIG_I2C=y
hw/i2c/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -common-obj-y += core.o smbus.o smbus_eeprom.o +common-obj-$(CONFIG_I2C) += core.o smbus.o smbus_eeprom.o common-obj-$(CONFIG_DDC) += i2c-ddc.o common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o common-obj-$(CONFIG_ACPI_X86) += smbus_ich9.o
hw/nvram/Makefile.objs +1 -1
@@ -1,6 +1,6 @@ common-obj-$(CONFIG_DS1225Y) += ds1225y.o common-obj-y += eeprom93xx.o -common-obj-y += eeprom_at24c.o +common-obj-$(CONFIG_I2C) += eeprom_at24c.o common-obj-y += fw_cfg.o common-obj-y += chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 14/47] Add missing hvdos public domain attribution:
In reply to Paolo BonziniFrom: Izik Eidus <[email protected]>
hvf.c and vmx.h contain code from hvdos.c that is released as public domain:
from hvdos github: https://github.com/mist64/hvdos
"License
See LICENSE.txt (2-clause-BSD).
In order to simplify use of this code as a template, you can consider any parts from "hvdos.c" and "interface.h" as being in the public domain."
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 3 +++ target/i386/hvf/vmx.h | 3 +++ 2 files changed, 6 insertions(+)
target/i386/hvf/hvf.c +3 -0
@@ -17,6 +17,9 @@* * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* This file contain code under public domain from the hvdos project: +* https://github.com/mist64/hvdos */ #include "qemu/osdep.h" #include "qemu-common.h"
target/i386/hvf/vmx.h +3 -0
@@ -17,6 +17,9 @@* * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* This file contain code under public domain from the hvdos project: +* https://github.com/mist64/hvdos */ #ifndef VMX_H
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 15/47] hvf: ept_emulation_fault() needs NetApp BSD attribution
In reply to Paolo BonziniAdd the BSD license there.
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
target/i386/hvf/hvf.c +24 -0
@@ -20,6 +20,30 @@* * This file contain code under public domain from the hvdos project: * https://github.com/mist64/hvdos +* +* Parts Copyright (c) 2011 NetApp, Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. */ #include "qemu/osdep.h" #include "qemu-common.h"
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 16/47] Drop remaining bits of ia64 host support
In reply to Paolo BonziniFrom: Peter Maydell <[email protected]>
We dropped support for ia64 host CPUs in the 2.11 release (removing the TCG backend for it, and advertising the support as being completely removed in the changelog). However there are a few bits and pieces of code still floating about. Remove those, too.
We can drop the check in configure for "ia64 or hppa host?" entirely, because we don't support hppa hosts either any more.
Message-Id: <[email protected]>
--- accel/tcg/user-exec.c | 33 --------------------------------- configure | 5 ----- include/qemu/processor.h | 3 --- include/qemu/timer.h | 9 --------- linux-user/syscall.c | 7 +------ 5 files changed, 1 insertion(+), 56 deletions(-)
accel/tcg/user-exec.c +0 -33
@@ -503,39 +503,6 @@ int cpu_signal_handler(int host_signum, void *pinfo, void *puc)return handle_cpu_signal (pc, info, is_write, &uc->uc_sigmask); } -#elif defined(__ia64) - -#ifndef __ISR_VALID -/* This ought to be in <bits/siginfo.h>... */ -# define __ISR_VALID 1 -#endif - -int cpu_signal_handler (int host_signum,void *pinfo,void *puc) -{ -siginfo_t *info = pinfo; -ucontext_t *uc = puc; -unsigned long ip; -int is_write =0 ; - - ip = uc->uc_mcontext.sc_ip; -switch (host_signum) { -case SIGILL : -case SIGFPE : -case SIGSEGV : -case SIGBUS : -case SIGTRAP : -if (info->si_code && (info->si_segvflags & __ISR_VALID)) { -/* ISR.W (write-access) is bit 33: */ - is_write = (info->si_isr >>33 ) &1 ; - } -break ; - -default : -break ; - } -return handle_cpu_signal (ip, info, is_write, (sigset_t *)&uc->uc_sigmask); -} -#elif defined(__s390__) int cpu_signal_handler(int host_signum, void *pinfo,
configure +0 -5
@@ -636,8 +636,6 @@ elif check_define _ARCH_PPC ; then fi elif check_define __mips__ ; then cpu="mips" -elif check_define __ia64__ ; then - cpu="ia64" elif check_define __s390__ ; then if check_define __s390x__ ; then cpu="s390x"
@@ -4744,9 +4742,6 @@ if test "$coroutine_pool" = ""; then fi if test "$debug_stack_usage" = "yes"; then - if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then - error_exit "stack usage debugging is not supported for $cpu" - fi if test "$coroutine_pool" = "yes"; then echo "WARN: disabling coroutine pool for stack usage debugging" coroutine_pool=no
include/qemu/processor.h +0 -3
@@ -12,9 +12,6 @@#if defined(__i386__) || defined(__x86_64__)# define cpu_relax () asm volatile("rep; nop" ::: "memory") -#elif defined(__ia64__) -# define cpu_relax () asm volatile("hint @pause" ::: "memory") -#elif defined(__aarch64__)# define cpu_relax () asm volatile("yield" ::: "memory")
include/qemu/timer.h +0 -9
@@ -931,15 +931,6 @@ static inline int64_t cpu_get_host_ticks(void) return val; } -#elif defined(__ia64) - -static inline int64_t cpu_get_host_ticks (void ) -{ -int64_t val; - asmvolatile ("mov %0 = ar.itc" :"=r" (val) ::"memory" ); -return val; -} -#elif defined(__s390__)static inline int64_t cpu_get_host_ticks (void )
linux-user/syscall.c +1 -6
@@ -36,10 +36,6 @@#include <linux/capability.h> #include <sched.h> #include <sys/timex.h> -#ifdef __ia64__ -int __clone2 (int (*fn)(void *),void *child_stack_base, -size_t stack_size,int flags,void *arg, ...); -#endif #include <sys/socket.h> #include <sys/un.h> #include <sys/uio.h>
@@ -246,8 +242,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \#define __NR_sys_inotify_add_watch __NR_inotify_add_watch#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch -#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) || \ - defined(__s390x__) +#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__)#define __NR__llseek __NR_lseek#endif
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 17/47] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The inet_parse() function looks for 'ipv4' and 'ipv6' flags, but only treats them as bare bool flags. The normal QemuOpts parsing would allow on/off values to be set too.
This updates inet_parse() so that its handling of the 'ipv4' and 'ipv6' flags matches that done by QemuOpts.
This impacts the NBD block driver parsing the legacy filename syntax and the migration code parsing the socket scheme.
Message-Id: <[email protected]>
--- util/qemu-sockets.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
util/qemu-sockets.c +40 -4
@@ -554,6 +554,33 @@ err: }/* compatibility wrapper */ +static int inet_parse_flag (const char *flagname,const char *optstr,bool *val, +Error **errp) +{ +char *end; +size_t len; + + end =strstr (optstr,"," ); +if (end) { +if (end[1 ] ==',' ) {/* Reject 'ipv6=on,,foo' */ +error_setg (errp,"error parsing '%s' flag '%s'" , flagname, optstr); +return -1 ; + } + len = end - optstr; + }else { + len =strlen (optstr); + } +if (len ==0 || (len ==3 &&strncmp (optstr,"=on" , len) ==0 )) { + *val = true; + }else if (len ==4 &&strncmp (optstr,"=off" , len) ==0 ) { + *val = false; + }else { +error_setg (errp,"error parsing '%s' flag '%s'" , flagname, optstr); +return -1 ; + } +return 0 ; +} +int inet_parse (InetSocketAddress *addr,const char *str,Error **errp) {const char *optstr, *h;
@@ -561,6 +588,7 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)char port[33 ];int to;int pos; +char *begin;memset (addr,0 ,sizeof (*addr));
@@ -602,11 +630,19 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp) addr->has_to = true; addr->to = to; } -if (strstr (optstr,",ipv4" )) { - addr->ipv4 = addr->has_ipv4 = true; + begin =strstr (optstr,",ipv4" ); +if (begin) { +if (inet_parse_flag ("ipv4" , begin +5 , &addr->ipv4, errp) <0 ) { +return -1 ; + } + addr->has_ipv4 = true; } -if (strstr (optstr,",ipv6" )) { - addr->ipv6 = addr->has_ipv6 = true; + begin =strstr (optstr,",ipv6" ); +if (begin) { +if (inet_parse_flag ("ipv6" , begin +5 , &addr->ipv6, errp) <0 ) { +return -1 ; + } + addr->has_ipv6 = true; }return 0 ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 18/47] exynos4210: workaround UBSAN compilation error
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
gcc 5.4.0-6ubuntu1~16.04.5 build with UBSAN enabled error:
CC hw/display/exynos4210_fimd.o/home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c: In function ‘fimd_get_buffer_id’:/home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c:1105:5:
error: case label does not reduce to an integer constant
case FIMD_WINCON_BUF2_STAT:
Because FIMD_WINCON_BUF2_STAT case contains an integer overflow, use U suffix to get the unsigned type.
Message-Id: <[email protected]>
--- hw/display/exynos4210_fimd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/exynos4210_fimd.c +1 -1
@@ -98,7 +98,7 @@#define FIMD_WINCON_BUFSTATUS ((1 << 21) | (1 << 31))#define FIMD_WINCON_BUF0_STAT ((0 << 21) | (0 << 31))#define FIMD_WINCON_BUF1_STAT ((1 << 21) | (0 << 31)) -#define FIMD_WINCON_BUF2_STAT ((0 << 21) | (1 << 31)) +#define FIMD_WINCON_BUF2_STAT ((0 << 21) | (1U << 31))#define FIMD_WINCON_BUFSELECT ((1 << 20) | (1 << 30))#define FIMD_WINCON_BUF0_SEL ((0 << 20) | (0 << 30))#define FIMD_WINCON_BUF1_SEL ((1 << 20) | (0 << 30))
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 19/47] build-sys: add --enable-sanitizers
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Typical slowdown introduced by AddressSanitizer is 2x. UBSan shouldn't have much impact on runtime cost.
Enable it by default when --enable-debug, unless --disable-sanitizers.
Message-Id: <[email protected]>
--- configure | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
configure +35 -0
@@ -342,6 +342,7 @@ rdma="" gprof="no" debug_tcg="no" debug="no" +sanitizers="" fortify_source="" strip_opt="yes" tcg_interpreter="no"
@@ -993,6 +994,10 @@ for opt do strip_opt="no" fortify_source="no" ;; + --enable-sanitizers) sanitizers="yes" + ;; + --disable-sanitizers) sanitizers="no" + ;; --enable-sparse) sparse="yes" ;; --disable-sparse) sparse="no"
@@ -1474,6 +1479,7 @@ Advanced options (experts only): --firmwarepath=PATH search PATH for firmware files --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix] --enable-debug enable common debug build options + --enable-sanitizers enable default sanitizers --disable-strip disable stripping binaries --disable-werror disable compilation abort on warning --disable-stack-protector disable compiler-provided stack protection
@@ -5201,6 +5207,28 @@ if compile_prog "" "" ; then fi ########################################## +# checks for sanitizers + +write_c_skeleton + +have_asan=no +have_ubsan=no + +# enable sanitizers by default if --enable-debug +if test "$sanitizers" = "" -a "$debug" = "yes"; then + sanitizers=yes +fi + +if test "$sanitizers" = "yes" ; then + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then + have_asan=yes + fi + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then + have_ubsan=yes + fi +fi + +########################################## # End of CC checks # After here, no more $cc or $ld runs
@@ -5224,6 +5252,13 @@ else CFLAGS="-O2 $CFLAGS" fi +if test "$have_asan" = "yes"; then + CFLAGS="-fsanitize=address $CFLAGS" +fi +if test "$have_ubsan" = "yes"; then + CFLAGS="-fsanitize=undefined $CFLAGS" +fi + ########################################## # Do we have libnfs if test "$libnfs" != "no" ; then
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 20/47] ucontext: annotate coroutine stack for ASAN
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
It helps ASAN to detect more leaks on coroutine stacks, and to get rid of some extra warnings.
Before:
tests/test-coroutine -p
/basic/lifecycle
/basic/lifecycle: ==20781==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==20781==WARNING: ASan is ignoring requested __asan_handle_no_return:
stack top: 0x7ffcb184d000; bottom 0x7ff6c4cfd000; size: 0x0005ecb50000 (25446121472)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
OK
After:
tests/test-coroutine -p /basic/lifecycle /basic/lifecycle: ==21110==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
OK
A similar work would need to be done for sigaltstack & windows fibers to have similar coverage. Since ucontext is preferred, I didn't bother checking the other coroutine implementations for now.
Update travis to fix the build with ASAN annotations.
Message-Id: <[email protected]>
--- .travis.yml | 3 ++- configure | 30 +++++++++++++++++++++++++++++ include/qemu/compiler.h | 4 ++++ util/coroutine-ucontext.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-)
.travis.yml +2 -1
@@ -13,12 +13,13 @@ addons: - libattr1-dev - libbrlapi-dev - libcap-ng-dev + - libgcc-6-dev - libgnutls-dev - libgtk-3-dev - libiscsi-dev - liblttng-ust-dev - - libnfs-dev - libncurses5-dev + - libnfs-dev - libnss3-dev - libpixman-1-dev - libpng12-dev
configure +30 -0
@@ -5213,6 +5213,8 @@ write_c_skeleton have_asan=no have_ubsan=no +have_asan_iface_h=no +have_asan_iface_fiber=no # enable sanitizers by default if --enable-debug if test "$sanitizers" = "" -a "$debug" = "yes"; then
@@ -5226,12 +5228,29 @@ if test "$sanitizers" = "yes" ; then if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then have_ubsan=yes fi + + if check_include "sanitizer/asan_interface.h" ; then + have_asan_iface_h=yes + fi + + cat > $TMPC << EOF +#include <sanitizer/asan_interface.h> +int main(void) { + __sanitizer_start_switch_fiber(0, 0, 0); + return 0; +} +EOF + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then + have_asan_iface_fiber=yes + fi fi ########################################## # End of CC checks # After here, no more $cc or $ld runs +write_c_skeleton + if test "$gcov" = "yes" ; then CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS" LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
@@ -5254,6 +5273,13 @@ fi if test "$have_asan" = "yes"; then CFLAGS="-fsanitize=address $CFLAGS" + if test "$have_asan_iface_h" = "no" ; then + echo "ASAN build enabled, but ASAN header missing." \ + "Without code annotation, the report may be inferior." + elif test "$have_asan_iface_fiber" = "no" ; then + echo "ASAN build enabled, but ASAN header is too old." \ + "Without code annotation, the report may be inferior." + fi fi if test "$have_ubsan" = "yes"; then CFLAGS="-fsanitize=undefined $CFLAGS"
@@ -6242,6 +6268,10 @@ if test "$valgrind_h" = "yes" ; then echo "CONFIG_VALGRIND_H=y" >> $config_host_mak fi +if test "$have_asan_iface_fiber" = "yes" ; then + echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak +fi + if test "$has_environ" = "yes" ; then echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak fi
include/qemu/compiler.h +4 -0
@@ -111,4 +111,8 @@#define GCC_FMT_ATTR (n, m)#endif +#ifndef __has_feature +#define __has_feature (x) 0/* compatibility with non-clang compilers */ +#endif +#endif /* COMPILER_H */
util/coroutine-ucontext.c +48 -0
101 lines not on this page · raw message
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 21/47] vhost: add traces for memory listeners
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
Trace these operations on two memory listeners. It helps to verify the new memory listener fix, and good to keep them there.
Message-Id: <[email protected]>
--- hw/virtio/trace-events | 6 ++++++ hw/virtio/vhost.c | 7 +++++++ 2 files changed, 13 insertions(+)
hw/virtio/trace-events +6 -0
@@ -25,3 +25,9 @@ virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d" virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d" virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 0x%"PRIx64" num_pages: %d" + +# hw/virtio/vhost.c +vhost_region_add(void *p, const char *mr) "dev %p mr %s" +vhost_region_del(void *p, const char *mr) "dev %p mr %s" +vhost_iommu_region_add(void *p, const char *mr) "dev %p mr %s" +vhost_iommu_region_del(void *p, const char *mr) "dev %p mr %s"
hw/virtio/vhost.c +7 -0
@@ -27,6 +27,7 @@#include "hw/virtio/virtio-access.h" #include "migration/blocker.h" #include "sysemu/dma.h" +#include "trace.h" /* enabled until disconnected backend stabilizes */ #define _VHOST_DEBUG 1
@@ -687,6 +688,7 @@ static void vhost_region_add(MemoryListener *listener,return ; } +trace_vhost_region_add (dev, section->mr->name ?:NULL ); ++dev->n_mem_sections; dev->mem_sections =g_renew (MemoryRegionSection, dev->mem_sections, dev->n_mem_sections);
@@ -706,6 +708,7 @@ static void vhost_region_del(MemoryListener *listener,return ; } +trace_vhost_region_del (dev, section->mr->name ?:NULL );vhost_set_memory (listener, section, false);memory_region_unref (section->mr);for (i =0 ; i < dev->n_mem_sections; ++i) {
@@ -743,6 +746,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,return ; } +trace_vhost_iommu_region_add (dev, section->mr->name ?:NULL ); + iommu =g_malloc0 (sizeof (*iommu)); end =int128_add (int128_make64 (section->offset_within_region), section->size);
@@ -771,6 +776,8 @@ static void vhost_iommu_region_del(MemoryListener *listener,return ; } +trace_vhost_iommu_region_del (dev, section->mr->name ?:NULL ); + QLIST_FOREACH(iommu, &dev->iommu_list, iommu_next) {if (iommu->mr == section->mr && iommu->n.start == section->offset_within_region) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 22/47] arm: postpone device listener unregister
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
It's a preparation for follow-up patch to call region_del() in memory_listener_unregister(), otherwise all device addr attached with kvm_devices_head will be reset before calling kvm_arm_set_device_addr.
Message-Id: <[email protected]>
--- target/arm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/kvm.c +1 -1
@@ -266,7 +266,6 @@ static void kvm_arm_machine_init_done(Notifier *notifier, void *data) {KVMDevice *kd, *tkd; -memory_listener_unregister (&devlistener); QSLIST_FOREACH_SAFE(kd, &kvm_devices_head, entries, tkd) {if (kd->kda.addr !=-1 ) {kvm_arm_set_device_addr (kd);
@@ -274,6 +273,7 @@ static void kvm_arm_machine_init_done(Notifier *notifier, void *data)memory_region_unref (kd->mr);g_free (kd); } +memory_listener_unregister (&devlistener); }static Notifier notify = {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 23/47] vfio: listener unregister before unset container
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
After next patch, listener unregister will need the container to be alive. Let's move this unregister phase to be before unset container, since that operation will free the backend container in kernel, otherwise we'll get these after next patch:
qemu-system-x86_64: VFIO_UNMAP_DMA: -22
qemu-system-x86_64: vfio_dma_unmap(0x559bf53a4590, 0x0, 0xa0000) = -22 (Invalid argument)
Message-Id: <[email protected]>
--- hw/vfio/common.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
hw/vfio/common.c +12 -4
@@ -1161,19 +1161,27 @@ static void vfio_disconnect_container(VFIOGroup *group) {VFIOContainer *container = group->container; +QLIST_REMOVE (group, container_next); + group->container =NULL ; + +/* +* Explicitly release the listener first before unset container, +* since unset may destroy the backend container if it's the last +* group. +*/ +if (QLIST_EMPTY (&container->group_list)) { +vfio_listener_release (container); + } +if (ioctl (group->fd,VFIO_GROUP_UNSET_CONTAINER , &container->fd)) {error_report ("vfio: error disconnecting group %d from container" , group->groupid); } -QLIST_REMOVE (group, container_next); - group->container =NULL ; -if (QLIST_EMPTY (&container->group_list)) {VFIOAddressSpace *space = container->space;VFIOGuestIOMMU *giommu, *tmp; -vfio_listener_release (container);QLIST_REMOVE (container, next); QLIST_FOREACH_SAFE(giommu, &container->giommu_list, giommu_next, tmp) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 24/47] memory: do explicit cleanup when remove listeners
In reply to Paolo BonziniFrom: Peter Xu <[email protected]>
When unregister memory listeners, we should call, e.g., region_del() (and possibly other undo operations) on every existing memory region sections there, otherwise we may leak resources that are held during the region_add(). This patch undo the stuff for the listeners, which emulates the case when the address space is set from current to an empty state.
I found this problem when debugging a refcount leak issue that leads to a device unplug event lost (please see the "Bug:" line below). In that case, the leakage of resource is the PCI BAR memory region refcount. And since memory regions are not keeping their own refcount but onto their owners, so the vfio-pci device's (who is the owner of the PCI BAR memory regions) refcount is leaked, and event missing.
We had encountered similar issues before and fixed in other way (ee4c112846, "vhost: Release memory references on cleanup"). This patch can be seen as a more high-level fix of similar problems that are caused by the resource leaks from memory listeners. So now we can remove the explicit unref of memory regions since that'll be done altogether during unregistering of listeners now.
Message-Id: <[email protected]>
--- hw/virtio/vhost.c | 4 ---- memory.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-)
hw/virtio/vhost.c +0 -4
@@ -1368,10 +1368,6 @@ void vhost_dev_cleanup(struct vhost_dev *hdev)if (hdev->mem) {/* those are only safe after successful init */ memory_listener_unregister (&hdev->memory_listener); -for (i =0 ; i < hdev->n_mem_sections; ++i) { -MemoryRegionSection *section = &hdev->mem_sections[i]; -memory_region_unref (section->mr); - }QLIST_REMOVE (hdev, entry); }if (hdev->migration_blocker) {
memory.c +27 -0
@@ -2612,6 +2612,32 @@ static void listener_add_address_space(MemoryListener *listener,flatview_unref (view); } +static void listener_del_address_space (MemoryListener *listener, +AddressSpace *as) +{ +FlatView *view; +FlatRange *fr; + +if (listener->begin) { + listener->begin (listener); + } + view =address_space_get_flatview (as); + FOR_EACH_FLAT_RANGE(fr, view) { +MemoryRegionSection section =section_from_flat_range (fr, view); + +if (fr->dirty_log_mask && listener->log_stop) { + listener->log_stop (listener, §ion, fr->dirty_log_mask,0 ); + } +if (listener->region_del) { + listener->region_del (listener, §ion); + } + } +if (listener->commit) { + listener->commit (listener); + } +flatview_unref (view); +} +void memory_listener_register (MemoryListener *listener,AddressSpace *as) {MemoryListener *other =NULL ;
@@ -2652,6 +2678,7 @@ void memory_listener_unregister(MemoryListener *listener)return ; } +listener_del_address_space (listener, listener->address_space);QTAILQ_REMOVE (&memory_listeners, listener, link);QTAILQ_REMOVE (&listener->address_space->listeners, listener, link_as); listener->address_space =NULL ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 25/47] chardev/char-socket: add POLLHUP handler
In reply to Paolo BonziniFrom: Klim Kireev <[email protected]>
The following behavior was observed for QEMU configured by libvirt to use guest agent as usual for the guests without virtio-serial driver (Windows or the guest remaining in BIOS stage).
In QEMU on first connect to listen character device socket the listen socket is removed from poll just after the accept(). virtio_serial_guest_ready() returns 0 and the descriptor of the connected Unix socket is removed from poll and it will not be present in poll() until the guest will initialize the driver and change the state of the serial to "guest connected".
In libvirt connect() to guest agent is performed on restart and is run under VM state lock. Connect() is blocking and can wait forever.
In this case libvirt can not perform ANY operation on that VM.
The bug can be easily reproduced this way:
Terminal 1:
qemu-system-x86_64 -m 512 -device pci-serial,chardev=serial1 -chardev socket,id=serial1,path=/tmp/console.sock,server,nowait (virtio-serial and isa-serial also fit)
Terminal 2:
minicom -D unix\#/tmp/console.sock
(type something and press enter)
C-a x (to exit)
Do 3 times:
minicom -D unix\#/tmp/console.sock
C-a x
It needs 4 connections, because the first one is accepted by QEMU, then two are queued by the kernel, and the 4th blocks.
The problem is that QEMU doesn't add a read watcher after succesful read until the guest device wants to acquire recieved data, so
I propose to install a separate pullhup watcher regardless of whether the device waits for data or not.
Message-Id: <[email protected]>
--- chardev/char-socket.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
chardev/char-socket.c +22 -0
@@ -42,6 +42,7 @@ typedef struct {QIOChannel *ioc;/* Client I/O channel */ QIOChannelSocket *sioc;/* Client master channel */ QIONetListener *listener; +GSource *hup_source;QCryptoTLSCreds *tls_creds;int connected;int max_size;
@@ -352,6 +353,12 @@ static void tcp_chr_free_connection(Chardev *chr) s->read_msgfds_num =0 ; } +if (s->hup_source !=NULL ) { +g_source_destroy (s->hup_source); +g_source_unref (s->hup_source); + s->hup_source =NULL ; + } +tcp_set_msgfds (chr,NULL ,0 );remove_fd_in_watch (chr);object_unref (OBJECT (s->sioc));
@@ -455,6 +462,15 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)return TRUE; } +static gboolean tcp_chr_hup (QIOChannel *channel, +GIOCondition cond, +void *opaque) +{ +Chardev *chr =CHARDEV (opaque); +tcp_chr_disconnect (chr); +return G_SOURCE_REMOVE ; +} +static int tcp_chr_sync_read (Chardev *chr,const uint8_t *buf,int len) {SocketChardev *s =SOCKET_CHARDEV (chr);
@@ -528,6 +544,12 @@ static void tcp_chr_connect(void *opaque) tcp_chr_read, chr, chr->gcontext); } + + s->hup_source =qio_channel_create_watch (s->ioc,G_IO_HUP ); +g_source_set_callback (s->hup_source, (GSourceFunc )tcp_chr_hup, + chr,NULL ); +g_source_attach (s->hup_source, chr->gcontext); +qemu_chr_be_event (chr,CHR_EVENT_OPENED ); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 26/47] ivshmem: Don't update non-existent MSI routes
In reply to Paolo BonziniFrom: Ladi Prosek <[email protected]>
As of commit 660c97eef6f8 ("ivshmem: use kvm irqfd for msi notifications"), QEMU crashes with:
kvm_irqchip_commit_routes: Assertion `ret == 0' failed.
if the ivshmem device is configured with more vectors than what the server supports. This is caused by the ivshmem_vector_unmask() being called on vectors that have not been initialized by ivshmem_add_kvm_msi_virq().
This commit fixes it by adding a simple check to the mask and unmask callbacks.
Note that the opposite mismatch, if the server supplies more vectors than what the device is configured for, is already handled and leads to output like:
Too many eventfd received, device has 1 vectors
To reproduce the assert, run:
ivshmem-server -n 0
and QEMU with:
-device ivshmem-doorbell,chardev=iv
-chardev socket,path=/tmp/ivshmem_socket,id=iv
then load the Windows driver, at the time of writing available at:
https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem
The issue is believed to have been masked by other guest drivers, notably Linux ones, not enabling MSI-X on the device.
Message-Id: <[email protected]>
--- hw/misc/ivshmem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/misc/ivshmem.c +10 -2
@@ -316,6 +316,10 @@ static int ivshmem_vector_unmask(PCIDevice *dev, unsigned vector,int ret;IVSHMEM_DPRINTF ("vector unmask %p %d\n" , dev, vector); +if (!v->pdev) { +error_report ("ivshmem: vector %d route does not exist" , vector); +return -EINVAL ; + } ret =kvm_irqchip_update_msi_route (kvm_state, v->virq, msg, dev);if (ret <0 ) {
@@ -330,12 +334,16 @@ static void ivshmem_vector_mask(PCIDevice *dev, unsigned vector) {IVShmemState *s =IVSHMEM_COMMON (dev);EventNotifier *n = &s->peers[s->vm_id].eventfds[vector]; +MSIVector *v = &s->msi_vectors[vector];int ret;IVSHMEM_DPRINTF ("vector mask %p %d\n" , dev, vector); +if (!v->pdev) { +error_report ("ivshmem: vector %d route does not exist" , vector); +return ; + } - ret =kvm_irqchip_remove_irqfd_notifier_gsi (kvm_state, n, - s->msi_vectors[vector].virq); + ret =kvm_irqchip_remove_irqfd_notifier_gsi (kvm_state, n, v->virq);if (ret !=0 ) {error_report ("remove_irqfd_notifier_gsi failed" ); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 27/47] ivshmem: Always remove irqfd notifiers
In reply to Paolo BonziniFrom: Ladi Prosek <[email protected]>
As of commit 660c97eef6f8 ("ivshmem: use kvm irqfd for msi notifications"), QEMU crashes with:
ivshmem: msix_set_vector_notifiers failedmsix_unset_vector_notifiers: Assertion `dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed.
if MSI-X is repeatedly enabled and disabled on the ivshmem device, for example by loading and unloading the Windows ivshmem driver. This is because msix_unset_vector_notifiers() doesn't call any of the release notifier callbacks since MSI-X is already disabled at that point (msix_enabled() returning false is how this transition is detected in the first place). Thus ivshmem_vector_mask() doesn't run and when MSI-X is subsequently enabled again ivshmem_vector_unmask() fails.
This is fixed by keeping track of unmasked vectors and making sure that ivshmem_vector_mask() always runs on MSI-X disable.
Message-Id: <[email protected]>
--- hw/misc/ivshmem.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
hw/misc/ivshmem.c +23 -3
@@ -76,6 +76,7 @@ typedef struct Peer {typedef struct MSIVector {PCIDevice *pdev;int virq; +bool unmasked; }MSIVector ; typedef struct IVShmemState {
@@ -320,6 +321,7 @@ static int ivshmem_vector_unmask(PCIDevice *dev, unsigned vector,error_report ("ivshmem: vector %d route does not exist" , vector);return -EINVAL ; } +assert (!v->unmasked); ret =kvm_irqchip_update_msi_route (kvm_state, v->virq, msg, dev);if (ret <0 ) {
@@ -327,7 +329,13 @@ static int ivshmem_vector_unmask(PCIDevice *dev, unsigned vector, }kvm_irqchip_commit_routes (kvm_state); -return kvm_irqchip_add_irqfd_notifier_gsi (kvm_state, n,NULL , v->virq); + ret =kvm_irqchip_add_irqfd_notifier_gsi (kvm_state, n,NULL , v->virq); +if (ret <0 ) { +return ret; + } + v->unmasked = true; + +return 0 ; }static void ivshmem_vector_mask (PCIDevice *dev,unsigned vector)
@@ -342,11 +350,14 @@ static void ivshmem_vector_mask(PCIDevice *dev, unsigned vector)error_report ("ivshmem: vector %d route does not exist" , vector);return ; } +assert (v->unmasked); ret =kvm_irqchip_remove_irqfd_notifier_gsi (kvm_state, n, v->virq); -if (ret !=0 ) { +if (ret <0 ) {error_report ("remove_irqfd_notifier_gsi failed" ); +return ; } + v->unmasked = false; } static void ivshmem_vector_poll(PCIDevice *dev,
@@ -816,11 +827,20 @@ static void ivshmem_disable_irqfd(IVShmemState *s)PCIDevice *pdev =PCI_DEVICE (s);int i; +msix_unset_vector_notifiers (pdev); +for (i =0 ; i < s->peers[s->vm_id].nb_eventfds; i++) { +/* +* MSI-X is already disabled here so msix_unset_vector_notifiers() +* didn't call our release notifier. Do it now to keep our masks and +* unmasks balanced. +*/ +if (s->msi_vectors[i].unmasked) { +ivshmem_vector_mask (pdev, i); + }ivshmem_remove_kvm_msi_virq (s, i); } -msix_unset_vector_notifiers (pdev); } static void ivshmem_write_config(PCIDevice *pdev, uint32_t address,
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 28/47] ivshmem: Improve MSI irqfd error handling
In reply to Paolo BonziniFrom: Ladi Prosek <[email protected]>
Adds a rollback path to ivshmem_enable_irqfd() and fixes ivshmem_disable_irqfd() to bail if irqfd has not been enabled.
To reproduce, run:
ivshmem-server -n 0
and QEMU with:
-device ivshmem-doorbell,chardev=iv
-chardev socket,path=/tmp/ivshmem_socket,id=iv
then load, unload, and load again the Windows driver, at the time of writing available at:
https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem
The issue is believed to have been masked by other guest drivers, notably Linux ones, not enabling MSI-X on the device.
Message-Id: <[email protected]>
--- hw/misc/ivshmem.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)
hw/misc/ivshmem.c +24 -13
@@ -785,6 +785,20 @@ static int ivshmem_setup_interrupts(IVShmemState *s, Error **errp)return 0 ; } +static void ivshmem_remove_kvm_msi_virq (IVShmemState *s,int vector) +{ +IVSHMEM_DPRINTF ("ivshmem_remove_kvm_msi_virq vector:%d\n" , vector); + +if (s->msi_vectors[vector].pdev ==NULL ) { +return ; + } + +/* it was cleaned when masked in the frontend. */ +kvm_irqchip_release_virq (kvm_state, s->msi_vectors[vector].virq); + + s->msi_vectors[vector].pdev =NULL ; +} +static void ivshmem_enable_irqfd (IVShmemState *s) {PCIDevice *pdev =PCI_DEVICE (s);
@@ -796,7 +810,7 @@ static void ivshmem_enable_irqfd(IVShmemState *s)ivshmem_add_kvm_msi_virq (s, i, &err);if (err) {error_report_err (err); -/* TODO do we need to handle the error? */ + goto undo; } }
@@ -805,21 +819,14 @@ static void ivshmem_enable_irqfd(IVShmemState *s) ivshmem_vector_mask, ivshmem_vector_poll)) {error_report ("ivshmem: msix_set_vector_notifiers failed" ); + goto undo; } -} +return ; -static void ivshmem_remove_kvm_msi_virq (IVShmemState *s,int vector) -{ -IVSHMEM_DPRINTF ("ivshmem_remove_kvm_msi_virq vector:%d\n" , vector); - -if (s->msi_vectors[vector].pdev ==NULL ) { -return ; +undo: +while (--i >=0 ) { +ivshmem_remove_kvm_msi_virq (s, i); } - -/* it was cleaned when masked in the frontend. */ -kvm_irqchip_release_virq (kvm_state, s->msi_vectors[vector].virq); - - s->msi_vectors[vector].pdev =NULL ; }static void ivshmem_disable_irqfd (IVShmemState *s)
@@ -827,6 +834,10 @@ static void ivshmem_disable_irqfd(IVShmemState *s)PCIDevice *pdev =PCI_DEVICE (s);int i; +if (!pdev->msix_vector_use_notifier) { +return ; + } +msix_unset_vector_notifiers (pdev);for (i =0 ; i < s->peers[s->vm_id].nb_eventfds; i++) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 29/47] ivshmem: Disable irqfd on device reset
In reply to Paolo BonziniFrom: Ladi Prosek <[email protected]>
The effects of ivshmem_enable_irqfd() was not undone on device reset.
This manifested as:ivshmem_add_kvm_msi_virq: Assertion `!s->msi_vectors[vector].pdev' failed.
when irqfd was enabled before reset and then enabled again after reset, making ivshmem_enable_irqfd() run for the second time.
To reproduce, run:
ivshmem-server
and QEMU with:
-device ivshmem-doorbell,chardev=iv
-chardev socket,path=/tmp/ivshmem_socket,id=iv
then install the Windows driver, at the time of writing available at:
https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem
and crash-reboot the guest by inducing a BSOD.
Message-Id: <[email protected]>
--- hw/misc/ivshmem.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/misc/ivshmem.c +4 -0
@@ -757,10 +757,14 @@ static void ivshmem_msix_vector_use(IVShmemState *s) } } +static void ivshmem_disable_irqfd (IVShmemState *s); +static void ivshmem_reset (DeviceState *d) {IVShmemState *s =IVSHMEM_COMMON (d); +ivshmem_disable_irqfd (s); + s->intrstatus =0 ; s->intrmask =0 ;if (ivshmem_has_feature (s,IVSHMEM_MSI )) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 30/47] cpus: hax: register/unregister thread with RCU, exit loop on unplug
In reply to Paolo Bonzini--- cpus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
cpus.c +4 -2
@@ -1473,6 +1473,7 @@ static void *qemu_hax_cpu_thread_fn(void *arg)CPUState *cpu = arg;int r; +rcu_register_thread ();qemu_mutex_lock_iothread ();qemu_thread_get_self (cpu->thread);
@@ -1484,7 +1485,7 @@ static void *qemu_hax_cpu_thread_fn(void *arg)hax_init_vcpu (cpu);qemu_cond_signal (&qemu_cpu_cond); -while (1 ) { + do { if (cpu_can_run(cpu)) { r = hax_smp_cpu_exec(cpu); if (r == EXCP_DEBUG) {
@@ -1493,7 +1494,8 @@ static void *qemu_hax_cpu_thread_fn(void *arg) }qemu_wait_io_event (cpu); - } + }while (!cpu->unplug ||cpu_can_run (cpu)); +rcu_unregister_thread ();return NULL ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 31/47] cpus: kvm: unregister thread with RCU
In reply to Paolo Bonzini--- cpus.c | 1 + 1 file changed, 1 insertion(+)
cpus.c +1 -0
@@ -1205,6 +1205,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) cpu->created = false;qemu_cond_signal (&qemu_cpu_cond);qemu_mutex_unlock_iothread (); +rcu_unregister_thread ();return NULL ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 32/47] cpus: dummy: unregister thread with RCU, exit loop on unplug
In reply to Paolo Bonzini--- cpus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
cpus.c +3 -2
@@ -1234,7 +1234,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) cpu->created = true;qemu_cond_signal (&qemu_cpu_cond); -while (1 ) { + do { qemu_mutex_unlock_iothread(); do { int sig;
@@ -1246,8 +1246,9 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) }qemu_mutex_lock_iothread ();qemu_wait_io_event (cpu); - } + }while (!cpu->unplug); +rcu_unregister_thread ();return NULL ;#endif }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 33/47] cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug
In reply to Paolo BonziniKeep running until cpu_can_run(cpu) becomes false, for consistency with other acceslerators.
--- cpus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
cpus.c +7 -7
@@ -1467,6 +1467,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)deal_with_unplugged_cpus (); } +rcu_unregister_thread ();return NULL ; }
@@ -1603,18 +1604,17 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)/* Ignore everything else? */ break ; } - }else if (cpu->unplug) { -qemu_tcg_destroy_vcpu (cpu); - cpu->created = false; -qemu_cond_signal (&qemu_cpu_cond); -qemu_mutex_unlock_iothread (); -return NULL ; }atomic_mb_set (&cpu->exit_request,0 );qemu_wait_io_event (cpu); - } + }while (!cpu->unplug ||cpu_can_run (cpu)); +qemu_tcg_destroy_vcpu (cpu); + cpu->created = false; +qemu_cond_signal (&qemu_cpu_cond); +qemu_mutex_unlock_iothread (); +rcu_unregister_thread ();return NULL ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 34/47] cpus: hvf: unregister thread with RCU
In reply to Paolo Bonzini--- cpus.c | 1 + 1 file changed, 1 insertion(+)
cpus.c +1 -0
@@ -1541,6 +1541,7 @@ static void *qemu_hvf_cpu_thread_fn(void *arg) cpu->created = false;qemu_cond_signal (&qemu_cpu_cond);qemu_mutex_unlock_iothread (); +rcu_unregister_thread ();return NULL ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 35/47] cpus: join thread when removing a vCPU
In reply to Paolo BonziniIf no one joins the thread, its associated memory is leaked.
--- cpus.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
cpus.c +4 -9
@@ -1752,19 +1752,14 @@ void resume_all_vcpus(void) } } -void cpu_remove (CPUState *cpu) +void cpu_remove_sync (CPUState *cpu) { cpu->stop = true; cpu->unplug = true;qemu_cpu_kick (cpu); -} - -void cpu_remove_sync (CPUState *cpu) -{ -cpu_remove (cpu); -while (cpu->created) { -qemu_cond_wait (&qemu_cpu_cond, &qemu_global_mutex); - } +qemu_mutex_unlock_iothread (); +qemu_thread_join (cpu->thread); +qemu_mutex_lock_iothread (); }/* For temporary buffers for forming a name */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 36/47] memfd: add error argument, instead of perror()
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
This will allow callers to silence error report when the call is allowed to failed.
Message-Id: <[email protected]>
--- hw/virtio/vhost.c | 8 +++++++- include/qemu/memfd.h | 5 +++-- util/memfd.c | 57 +++++++++++++++++++++++++++------------------------- 3 files changed, 40 insertions(+), 30 deletions(-)
hw/virtio/vhost.c +7 -1
@@ -330,6 +330,7 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)static struct vhost_log *vhost_log_alloc (uint64_t size,bool share) { +Error *err =NULL ;struct vhost_log *log;uint64_t logsize = size *sizeof (*(log->log));int fd =-1 ;
@@ -338,7 +339,12 @@ static struct vhost_log *vhost_log_alloc(uint64_t size, bool share)if (share) { log->log =qemu_memfd_alloc ("vhost-log" , logsize,F_SEAL_GROW |F_SEAL_SHRINK |F_SEAL_SEAL , - &fd); + &fd, &err); +if (err) { +error_report_err (err); +g_free (log); +return NULL ; + }memset (log->log,0 , logsize); }else { log->log =g_malloc0 (logsize);
include/qemu/memfd.h +3 -2
@@ -16,9 +16,10 @@#define F_SEAL_WRITE 0x0008/* prevent writes */ #endif -int qemu_memfd_create (const char *name,size_t size,unsigned int seals); +int qemu_memfd_create (const char *name,size_t size,unsigned int seals, +Error **errp);void *qemu_memfd_alloc (const char *name,size_t size,unsigned int seals, -int *fd); +int *fd,Error **errp);void qemu_memfd_free (void *ptr,size_t size,int fd);bool qemu_memfd_check (void );
util/memfd.c +30 -27
118 lines not on this page · raw message
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 37/47] memfd: add hugetlb support
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Linux commit 749df87bd7bee5a79cef073f5d032ddb2b211de8 (v4.14-rc1) added a new flag MFD_HUGETLB to memfd_create() that specify the file to be created resides in the hugetlbfs filesystem. This is the generic hugetlbfs filesystem not associated with any specific mount point.
hugetlbfs does not support sealing operations in v4.14, therefore specifying MFD_ALLOW_SEALING with MFD_HUGETLB will result in EINVAL.
However, I added sealing support in "[PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory" series, queued in -mm tree for v4.16.
Message-Id: <[email protected]>
--- include/qemu/memfd.h | 4 ++-- util/memfd.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-)
include/qemu/memfd.h +2 -2
@@ -16,8 +16,8 @@#define F_SEAL_WRITE 0x0008/* prevent writes */ #endif -int qemu_memfd_create (const char *name,size_t size,unsigned int seals, -Error **errp); +int qemu_memfd_create (const char *name,size_t size,bool hugetlb, +unsigned int seals,Error **errp);void *qemu_memfd_alloc (const char *name,size_t size,unsigned int seals,int *fd,Error **errp);void qemu_memfd_free (void *ptr,size_t size,int fd);
util/memfd.c +10 -3
@@ -52,7 +52,11 @@ static int memfd_create(const char *name, unsigned int flags)#define MFD_ALLOW_SEALING 0x0002U#endif -int qemu_memfd_create (const char *name,size_t size, +#ifndef MFD_HUGETLB +#define MFD_HUGETLB 0x0004U +#endif + +int qemu_memfd_create (const char *name,size_t size,bool hugetlb,unsigned int seals,Error **errp) {#ifdef CONFIG_LINUX
@@ -62,6 +66,9 @@ int qemu_memfd_create(const char *name, size_t size,if (seals) { flags |=MFD_ALLOW_SEALING ; } +if (hugetlb) { + flags |=MFD_HUGETLB ; + } mfd =memfd_create (name, flags);if (mfd <0 ) {
@@ -97,11 +104,11 @@ void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, int *fd, Error **errp) { void *ptr; -int mfd =qemu_memfd_create (name, size, seals,NULL ); +int mfd =qemu_memfd_create (name, size, false, seals,NULL );/* some systems have memfd without sealing */ if (mfd ==-1 ) { - mfd =qemu_memfd_create (name, size,0 ,NULL ); + mfd =qemu_memfd_create (name, size, false,0 ,NULL ); }if (mfd ==-1 ) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 38/47] memfd: add hugetlbsize argument
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Learn to specificy hugetlb size as qemu_memfd_create() argument.
Message-Id: <[email protected]>
--- include/qemu/memfd.h | 2 +- util/memfd.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)
include/qemu/memfd.h +1 -1
@@ -17,7 +17,7 @@#endif int qemu_memfd_create (const char *name,size_t size,bool hugetlb, -unsigned int seals,Error **errp); +uint64_t hugetlbsize,unsigned int seals,Error **errp);void *qemu_memfd_alloc (const char *name,size_t size,unsigned int seals,int *fd,Error **errp);void qemu_memfd_free (void *ptr,size_t size,int fd);
util/memfd.c +18 -4
@@ -29,6 +29,7 @@#include "qapi/error.h" #include "qemu/memfd.h" +#include "qemu/host-utils.h" #if definedCONFIG_LINUX && !definedCONFIG_MEMFD #include <sys/syscall.h>
@@ -56,9 +57,22 @@ static int memfd_create(const char *name, unsigned int flags)#define MFD_HUGETLB 0x0004U#endif +#ifndef MFD_HUGE_SHIFT +#define MFD_HUGE_SHIFT 26 +#endif +int qemu_memfd_create (const char *name,size_t size,bool hugetlb, -unsigned int seals,Error **errp) +uint64_t hugetlbsize,unsigned int seals,Error **errp) { +int htsize = hugetlbsize ?ctz64 (hugetlbsize) :0 ; + +if (htsize &&1 << htsize != hugetlbsize) { +error_setg (errp,"Hugepage size must be a power of 2" ); +return -1 ; + } + + htsize = htsize <<MFD_HUGE_SHIFT ; +#ifdef CONFIG_LINUX int mfd =-1 ;unsigned int flags =MFD_CLOEXEC ;
@@ -68,8 +82,8 @@ int qemu_memfd_create(const char *name, size_t size, bool hugetlb, }if (hugetlb) { flags |=MFD_HUGETLB ; + flags |= htsize; } - mfd =memfd_create (name, flags);if (mfd <0 ) { goto err;
@@ -104,11 +118,11 @@ void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, int *fd, Error **errp) { void *ptr; -int mfd =qemu_memfd_create (name, size, false, seals,NULL ); +int mfd =qemu_memfd_create (name, size, false,0 , seals,NULL );/* some systems have memfd without sealing */ if (mfd ==-1 ) { - mfd =qemu_memfd_create (name, size, false,0 ,NULL ); + mfd =qemu_memfd_create (name, size, false,0 ,0 ,NULL ); }if (mfd ==-1 ) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PULL 38/47] memfd: add hugetlbsize argument
Quoted 6 lines · Paolo Bonzini
From: Marc-André Lureau <[email protected]>
Learn to specificy hugetlb size as
qemu_memfd_create()argument.int qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,util/memfd.c +0
-1- unsigned int seals, Error **errp)
util/memfd.c static int memfd_create(const char *name, unsigned int flags) · line 74
Quoted 10 lines
util/memfd.c +9
-0+ uint64_t hugetlbsize, unsigned int seals, Error **errp) { + int htsize = hugetlbsize ? ctz64(hugetlbsize) : 0; + +if (htsize &&1 << htsize != hugetlbsize) { +error_setg (errp,"Hugepage size must be a power of 2" ); +return -1 ; + } + + htsize = htsize <<MFD_HUGE_SHIFT ;
Hi; Coverity complains about this function (CID 1385858) because we calculate a bit poisition htsize which could be up to 63, but then use it in "1 << htsize" which is a 32-bit integer calculation and could push the 1 off the top of the value.
This should be "1ULL", though of course a hugetlbsize of 4GB is not very plausible.
PS: the variable name is "hugetlbsize" but the error message says "hugepage size" -- is it a TLB size or a page size ?
thanks
-- PMM
[Qemu-devel] [PULL 39/47] Add memfd based hostmem
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Add a new memory backend, similar to hostmem-file, except that it doesn't need to create files. It also enforces memory sealing.
This backend is mainly useful for sharing the memory with other processes.
Note that Linux supports transparent huge-pages of shmem/memfd memory since 4.8. It is relatively easier to set up THP than a dedicate hugepage mount point by using "madvise" in /sys/kernel/mm/transparent_hugepage/shmem_enabled.
Since 4.14, memfd allows to set hugetlb requirement explicitly.
Pending for merge in 4.16 is memfd sealing support for hugetlb backed memory.
Usage:
-object memory-backend-memfd,id=mem1,size=1G
Message-Id: <[email protected]>
--- backends/Makefile.objs | 2 + backends/hostmem-memfd.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 22 ++++++ 3 files changed, 194 insertions(+) create mode 100644 backends/hostmem-memfd.c
backends/Makefile.objs +2 -0
@@ -8,3 +8,5 @@ common-obj-$(CONFIG_LINUX) += hostmem-file.o common-obj-y += cryptodev.o common-obj-y += cryptodev-builtin.o + +common-obj-$(CONFIG_LINUX) += hostmem-memfd.o
backends/hostmem-memfd.c new file +170 -0
170 lines not on this page · raw message
qemu-options.hx +22 -0
@@ -4024,6 +4024,28 @@ Memory backend objects offer more control than the @option{-m} option that is traditionally used to define guest RAM. Please refer to @option{memory-backend-file} for a description of the options. +@item -object memory-backend-memfd,id=@var{id},merge=@var{on|off},dump=@var{on|off},prealloc=@var{on|off},size=@var{size},host-nodes=@var{host-nodes},policy=@var{default|preferred|bind|interleave},seal=@var{on|off},hugetlb=@var{on|off},hugetlbsize=@var{size} + +Creates an anonymous memory file backend object, which allows QEMU to +share the memory with an external process (e.g. when using +vhost-user). The memory is allocated with memfd and optional +sealing. (Linux only) + +The @option{seal} option creates a sealed-file, that will block +further resizing the memory ('on' by default). + +The @option{hugetlb} option specify the file to be created resides in +the hugetlbfs filesystem (since Linux 4.14). Used in conjunction with +the @option{hugetlb} option, the @option{hugetlbsize} option specify +the hugetlb page size on systems that support multiple hugetlb page +sizes (it must be a power of 2 value supported by the system). + +In some versions of Linux, the @option{hugetlb} option is incompatible +with the @option{seal} option (requires at least Linux 4.16). + +Please refer to @option{memory-backend-file} for a description of the +other options. + @item -object rng-random,id=@var{id},filename=@var{/dev/random} Creates a random number generator backend which obtains entropy from
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 40/47] tests: keep compiling failing vhost-user tests
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Let's protect the failing tests under a QTEST_VHOST_USER_FIXME environment variable, so we keep compiling the tests and we can easily run them.
Message-Id: <[email protected]>
--- tests/vhost-user-test.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
tests/vhost-user-test.c +14 -13
@@ -30,8 +30,6 @@#include <linux/virtio_net.h> #include <sys/vfs.h> -#define VHOST_USER_NET_TESTS_WORKING 0/* broken as of 2.10.0 */ -/* GLIB version compatibility flags */ #if !GLIB_CHECK_VERSION (2 ,26 ,0 )#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000))
@@ -765,7 +763,7 @@ static void wait_for_rings_started(TestServer *s, size_t count)g_mutex_unlock (&s->data_mutex); } -#if VHOST_USER_NET_TESTS_WORKING && defined(CONFIG_HAS_GLIB_SUBPROCESS_TESTS ) +#if defined(CONFIG_HAS_GLIB_SUBPROCESS_TESTS )static inline void test_server_connect (TestServer *server) {test_server_create_chr (server,",reconnect=1" );
@@ -956,16 +954,19 @@ int main(int argc, char **argv)qtest_add_func ("/vhost-user/migrate" , test_migrate);qtest_add_func ("/vhost-user/multiqueue" , test_multiqueue); -#if VHOST_USER_NET_TESTS_WORKING && defined(CONFIG_HAS_GLIB_SUBPROCESS_TESTS ) -qtest_add_func ("/vhost-user/reconnect/subprocess" , - test_reconnect_subprocess); -qtest_add_func ("/vhost-user/reconnect" , test_reconnect); -qtest_add_func ("/vhost-user/connect-fail/subprocess" , - test_connect_fail_subprocess); -qtest_add_func ("/vhost-user/connect-fail" , test_connect_fail); -qtest_add_func ("/vhost-user/flags-mismatch/subprocess" , - test_flags_mismatch_subprocess); -qtest_add_func ("/vhost-user/flags-mismatch" , test_flags_mismatch); +#if defined(CONFIG_HAS_GLIB_SUBPROCESS_TESTS ) +/* keeps failing on build-system since Aug 15 2017 */ +if (getenv ("QTEST_VHOST_USER_FIXME" )) { +qtest_add_func ("/vhost-user/reconnect/subprocess" , + test_reconnect_subprocess); +qtest_add_func ("/vhost-user/reconnect" , test_reconnect); +qtest_add_func ("/vhost-user/connect-fail/subprocess" , + test_connect_fail_subprocess); +qtest_add_func ("/vhost-user/connect-fail" , test_connect_fail); +qtest_add_func ("/vhost-user/flags-mismatch/subprocess" , + test_flags_mismatch_subprocess); +qtest_add_func ("/vhost-user/flags-mismatch" , test_flags_mismatch); + }#endif ret =g_test_run ();
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 41/47] vhost-user-test: make read-guest-mem setup its own qemu
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
--- tests/vhost-user-test.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
tests/vhost-user-test.c +15 -12
@@ -48,6 +48,14 @@#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ QEMU_CMD_NETDEV QEMU_CMD_NET +#define GET_QEMU_CMD (s) \ + g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ + (s)->socket_path, "", (s)->chr_name) + +#define GET_QEMU_CMDE (s, mem, chr_opts, extra, ...) \ + g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ + (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__) +#define HUGETLBFS_MAGIC 0x958458f6/*********** FROM hw/virtio/vhost-user.c *************************************/
@@ -159,6 +167,10 @@ typedef struct TestServer {QGuestAllocator *alloc; } TestServer; +static TestServer *test_server_new (const gchar *name); +static void test_server_free (TestServer *server); +static void test_server_listen (TestServer *server); +static const char *tmpfs;static const char *root;
@@ -225,9 +237,8 @@ static void wait_for_fds(TestServer *s)g_mutex_unlock (&s->data_mutex); } -static void read_guest_mem (const void *data) +static void read_guest_mem_server (TestServer *s) { -TestServer *s = (void *)data;uint32_t *guest_mem;int i, j;size_t size;
@@ -492,14 +503,6 @@ static void test_server_listen(TestServer *server)test_server_create_chr (server,",server,nowait" ); } -#define GET_QEMU_CMD (s) \ - g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ - (s)->socket_path, "", (s)->chr_name) - -#define GET_QEMU_CMDE (s, mem, chr_opts, extra, ...) \ - g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ - (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__) -static gboolean _test_server_free (TestServer *server) {int i;
@@ -652,7 +655,7 @@ static void test_read_guest_mem(void)init_virtio_dev (server,1u <<VIRTIO_NET_F_MAC ); -read_guest_mem (server); +read_guest_mem_server (server);uninit_virtio_dev (server);
@@ -730,7 +733,7 @@ static void test_migrate(void) global_qtest = to;qmp_eventwait ("RESUME" ); -read_guest_mem (dest); +read_guest_mem_server (dest);uninit_virtio_dev (s);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 42/47] tests: use memfd in vhost-user-test
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
This will exercise the memfd memory backend and should generally be better for testing than memory-backend-file (thanks to anonymous files and sealing).
If memfd is available, it is preferred.
However, in order to check that file & memfd backends both work correctly, the read-guest-mem test is checked explicitly for each.
Message-Id: <[email protected]>
--- tests/vhost-user-test.c | 90 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 26 deletions(-)
tests/vhost-user-test.c +64 -26
@@ -17,6 +17,7 @@#include "qemu/range.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" +#include "qemu/memfd.h" #include "sysemu/sysemu.h" #include "libqos/libqos.h" #include "libqos/pci-pc.h"
@@ -39,23 +40,14 @@#define HAVE_MONOTONIC_TIME #endif -#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM,"\ +#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM," \ "mem-path=%s,share=on -numa node,memdev=mem" +#define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \ + " -numa node,memdev=mem"#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s"#define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=%s,vhostforce"#define QEMU_CMD_NET " -device virtio-net-pci,netdev=net0" -#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ - QEMU_CMD_NETDEV QEMU_CMD_NET - -#define GET_QEMU_CMD (s) \ - g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ - (s)->socket_path, "", (s)->chr_name) - -#define GET_QEMU_CMDE (s, mem, chr_opts, extra, ...) \ - g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ - (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__) -#define HUGETLBFS_MAGIC 0x958458f6/*********** FROM hw/virtio/vhost-user.c *************************************/
@@ -174,6 +166,33 @@ static void test_server_listen(TestServer *server);static const char *tmpfs;static const char *root; +enum test_memfd { +TEST_MEMFD_AUTO , +TEST_MEMFD_YES , +TEST_MEMFD_NO , +}; + +static char *get_qemu_cmd (TestServer *s, +int mem,enum test_memfd memfd,const char *mem_path, +const char *chr_opts,const char *extra) +{ +if (memfd ==TEST_MEMFD_AUTO &&qemu_memfd_check ()) { + memfd =TEST_MEMFD_YES ; + } + +if (memfd ==TEST_MEMFD_YES ) { + return g_strdup_printf(QEMU_CMD_MEMFD QEMU_CMD_CHR + QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, + s->chr_name, s->socket_path, + chr_opts, s->chr_name, extra); + }else { + return g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR + QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, + mem_path, s->chr_name, s->socket_path, + chr_opts, s->chr_name, extra); + } +} +static void init_virtio_dev (TestServer *s,uint32_t features_mask) {uint32_t features;
@@ -639,8 +658,9 @@ GSourceFuncs test_migrate_source_funcs = { .check = test_migrate_source_check, }; -static void test_read_guest_mem (void ) +static void test_read_guest_mem (const void *arg) { +enum test_memfd memfd =GPOINTER_TO_INT (arg);TestServer *server =NULL ;char *qemu_cmd =NULL ;QTestState *s =NULL ;
@@ -648,7 +668,7 @@ static void test_read_guest_mem(void) server =test_server_new ("test" );test_server_listen (server); - qemu_cmd =GET_QEMU_CMD (server); + qemu_cmd =get_qemu_cmd (server,512 , memfd, root,"" ,"" ); s =qtest_start (qemu_cmd);g_free (qemu_cmd);
@@ -670,7 +690,7 @@ static void test_migrate(void)char *uri =g_strdup_printf ("%s%s" ,"unix:" , dest->mig_path);QTestState *global = global_qtest, *from, *to;GSource *source; -gchar *cmd; +gchar *cmd, *tmp;QDict *rsp;guint8 *log;guint64 size;
@@ -678,7 +698,7 @@ static void test_migrate(void)test_server_listen (s);test_server_listen (dest); - cmd =GET_QEMU_CMDE (s,2 ,"" ,"" ); + cmd =get_qemu_cmd (s,2 ,TEST_MEMFD_AUTO , root,"" ,"" ); from =qtest_start (cmd);g_free (cmd);
@@ -687,7 +707,9 @@ static void test_migrate(void) size =get_log_size (s); g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)); - cmd =GET_QEMU_CMDE (dest,2 ,"" ," -incoming %s" , uri); + tmp =g_strdup_printf (" -incoming %s" , uri); + cmd =get_qemu_cmd (dest,2 ,TEST_MEMFD_AUTO , root,"" , tmp); +g_free (tmp); to =qtest_init (cmd);g_free (cmd);
@@ -800,7 +822,7 @@ static void test_reconnect_subprocess(void)char *cmd;g_thread_new ("connect" , connect_thread, s); - cmd =GET_QEMU_CMDE (s,2 ,",server" ,"" ); + cmd =get_qemu_cmd (s,2 ,TEST_MEMFD_AUTO , root,",server" ,"" );qtest_start (cmd);g_free (cmd);
@@ -838,7 +860,7 @@ static void test_connect_fail_subprocess(void) s->test_fail = true;g_thread_new ("connect" , connect_thread, s); - cmd =GET_QEMU_CMDE (s,2 ,",server" ,"" ); + cmd =get_qemu_cmd (s,2 ,TEST_MEMFD_AUTO , root,",server" ,"" );qtest_start (cmd);g_free (cmd);
@@ -868,7 +890,7 @@ static void test_flags_mismatch_subprocess(void) s->test_flags =TEST_FLAGS_DISCONNECT ;g_thread_new ("connect" , connect_thread, s); - cmd =GET_QEMU_CMDE (s,2 ,",server" ,"" ); + cmd =get_qemu_cmd (s,2 ,TEST_MEMFD_AUTO , root,",server" ,"" );qtest_start (cmd);g_free (cmd);
@@ -903,11 +925,21 @@ static void test_multiqueue(void) s->queues =2 ;test_server_listen (s); - cmd = g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " -"-device virtio-net-pci,netdev=net0,mq=on,vectors=%d" , -512 ,512 , root, s->chr_name, - s->socket_path,"" , s->chr_name, - s->queues, s->queues *2 +2 ); +if (qemu_memfd_check ()) { + cmd =g_strdup_printf ( + QEMU_CMD_MEMFD QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " +"-device virtio-net-pci,netdev=net0,mq=on,vectors=%d" , +512 ,512 , s->chr_name, + s->socket_path,"" , s->chr_name, + s->queues, s->queues *2 +2 ); + }else { + cmd =g_strdup_printf ( + QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " +"-device virtio-net-pci,netdev=net0,mq=on,vectors=%d" , +512 ,512 , root, s->chr_name, + s->socket_path,"" , s->chr_name, + s->queues, s->queues *2 +2 ); + }qtest_start (cmd);g_free (cmd);
@@ -953,7 +985,13 @@ int main(int argc, char **argv)/* run the main loop thread so the chardev may operate */ thread =g_thread_new (NULL , thread_function, loop); -qtest_add_func ("/vhost-user/read-guest-mem" , test_read_guest_mem); +if (qemu_memfd_check ()) { +qtest_add_data_func ("/vhost-user/read-guest-mem/memfd" , +GINT_TO_POINTER (TEST_MEMFD_YES ), + test_read_guest_mem); + } +qtest_add_data_func ("/vhost-user/read-guest-mem/memfile" , +GINT_TO_POINTER (TEST_MEMFD_NO ), test_read_guest_mem);qtest_add_func ("/vhost-user/migrate" , test_migrate);qtest_add_func ("/vhost-user/multiqueue" , test_multiqueue);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 43/47] tests/test-filter-redirector: move close()
In reply to Paolo BonziniFrom: Klim Kireev <[email protected]>
Since we have separate handler on POLLHUP, which drops data after closing the connection we need to fix this test, because it sends data and instantly close the socket creating race condition. In some cases on other end of socket client closes it faster than reads data. To prevent it I suggest to close socket after recieving.
Message-Id: <[email protected]>
--- tests/test-filter-redirector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/test-filter-redirector.c +1 -1
@@ -186,7 +186,6 @@ static void test_redirector_rx(void) ret =iov_send (send_sock, iov,2 ,0 ,sizeof (size) +sizeof (send_buf)); g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size)); -close (send_sock); ret =qemu_recv (backend_sock[0 ], &len,sizeof (len),0 ); g_assert_cmpint(ret, ==, sizeof(len));
@@ -197,6 +196,7 @@ static void test_redirector_rx(void) ret =qemu_recv (backend_sock[0 ], recv_buf, len,0 ); g_assert_cmpstr(recv_buf, ==, send_buf); +close (send_sock);g_free (recv_buf);unlink (sock_path0);unlink (sock_path1);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 44/47] Add the Windows Hypervisor Platform accelerator.
In reply to Paolo BonziniFrom: "Justin Terry (VM)" <[email protected]>
Introduces the configure support for the new Windows Hypervisor Platform that allows for hypervisor acceleration from usermode components on the Windows platform.
Message-Id: <[email protected]>
--- configure | 48 +++++++++++++++++++++++++++++++++++++++++++++++- qemu-options.hx | 8 ++++---- 2 files changed, 51 insertions(+), 5 deletions(-)
configure +47 -1
@@ -222,6 +222,17 @@ supported_hvf_target() { return 1 } +supported_whpx_target() { + test "$whpx" = "yes" || return 1 + glob "$1" "*-softmmu" || return 1 + case "${1%-softmmu}" in + i386|x86_64) + return 0 + ;; + esac + return 1 +} + supported_target() { case "$1" in *-softmmu)
@@ -248,6 +259,7 @@ supported_target() { supported_xen_target "$1" && return 0 supported_hax_target "$1" && return 0 supported_hvf_target "$1" && return 0 + supported_whpx_target "$1" && return 0 print_error "TCG disabled, but hardware accelerator not available for '$target'" return 1 }
@@ -338,6 +350,7 @@ vhost_user="" kvm="no" hax="no" hvf="no" +whpx="no" rdma="" gprof="no" debug_tcg="no"
@@ -1058,6 +1071,10 @@ for opt do ;; --enable-hvf) hvf="yes" ;; + --disable-whpx) whpx="no" + ;; + --enable-whpx) whpx="yes" + ;; --disable-tcg-interpreter) tcg_interpreter="no" ;; --enable-tcg-interpreter) tcg_interpreter="yes"
@@ -1557,6 +1574,7 @@ disabled with --disable-FEATURE, default is enabled if available: kvm KVM acceleration support hax HAX acceleration support hvf Hypervisor.framework acceleration support + whpx Windows Hypervisor Platform acceleration support rdma RDMA-based migration support vde support for vde network netmap support for netmap network
@@ -2456,6 +2474,30 @@ if test "$xen_pv_domain_build" = "yes" && fi ########################################## +# Windows Hypervisor Platform accelerator (WHPX) check +if test "$whpx" != "no" ; then + cat > $TMPC << EOF +#include <windows.h> +#include <winhvplatform.h> +#include <winhvemulation.h> +int main(void) { + WHV_CAPABILITY whpx_cap; + WHvGetCapability(WHvCapabilityCodeFeatures, &whpx_cap, sizeof(whpx_cap)); + return 0; +} +EOF + if compile_prog "" "-lwinhvplatform -lwinhvemulation" ; then + libs_softmmu="$libs_softmmu -lwinhvplatform -lwinhvemulation" + whpx="yes" + else + if test "$whpx" = "yes"; then + feature_not_found "winhvplatform" "winhvemulation is not installed" + fi + whpx="no" + fi +fi + +########################################## # Sparse probe if test "$sparse" != "no" ; then if has cgcc; then
@@ -5653,6 +5695,7 @@ echo "Install blobs $blobs" echo "KVM support $kvm" echo "HAX support $hax" echo "HVF support $hvf" +echo "WHPX support $whpx" echo "TCG support $tcg" if test "$tcg" = "yes" ; then echo "TCG debug enabled $debug_tcg"
@@ -5820,7 +5863,7 @@ if test "$mingw32" = "yes" ; then echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak fi if test "$guest_agent_msi" = "yes"; then - echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak + echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
@@ -6753,6 +6796,9 @@ fi if supported_hvf_target $target; then echo "CONFIG_HVF=y" >> $config_target_mak fi +if supported_whpx_target $target; then + echo "CONFIG_WHPX=y" >> $config_target_mak +fi if test "$target_bigendian" = "yes" ; then echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak fi
qemu-options.hx +4 -4
@@ -31,7 +31,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=]name[,prop[=value][,...]]\n" " selects emulated machine ('-machine help' for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" - " supported accelerators are kvm, xen, hax, hvf or tcg (default: tcg)\n" + " supported accelerators are kvm, xen, hax, hvf, whpx or tcg (default: tcg)\n" " kernel_irqchip=on|off|split controls accelerated irqchip support (default=off)\n" " vmport=on|off|auto controls emulation of vmport (default: auto)\n" " kvm_shadow_mem=size of KVM shadow MMU in bytes\n"
@@ -66,7 +66,7 @@ Supported machine properties are: @table @option @item accel=@var{accels1}[:@var{accels2}[:...]] This is used to enable an accelerator. Depending on the target architecture, -kvm, xen, hax, hvf or tcg can be available. By default, tcg is used. If there is +kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize. @item kernel_irqchip=on|off
@@ -126,13 +126,13 @@ ETEXI DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=]accelerator[,thread=single|multi]\n" - " select accelerator (kvm, xen, hax, hvf or tcg; use 'help' for a list)\n" + " select accelerator (kvm, xen, hax, hvf, whpx or tcg; use 'help' for a list)\n" " thread=single|multi (enable multi-threaded TCG)", QEMU_ARCH_ALL) STEXI @item -accel @var{name}[,prop=@var{value}[,...]] @findex -accel This is used to enable an accelerator. Depending on the target architecture, -kvm, xen, hax, hvf or tcg can be available. By default, tcg is used. If there is +kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize. @table @option
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 45/47] Add the WHPX vcpu API
In reply to Paolo BonziniFrom: "Justin Terry (VM)" <[email protected]>
Adds support for the Windows Hypervisor Platform accelerator (WHPX) stubs and introduces the whpx.h sysemu API for managing the vcpu scheduling and management.
Message-Id: <[email protected]>
--- accel/stubs/Makefile.objs | 9 +++++---- accel/stubs/whpx-stub.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ include/sysemu/whpx.h | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 accel/stubs/whpx-stub.c create mode 100644 include/sysemu/whpx.h
accel/stubs/Makefile.objs +5 -4
@@ -1,4 +1,5 @@ -obj-$(call lnot,$(CONFIG_HAX)) += hax-stub.o -obj-$(call lnot,$(CONFIG_HVF)) += hvf-stub.o -obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o -obj-$(call lnot,$(CONFIG_TCG)) += tcg-stub.o +obj-$(call lnot,$(CONFIG_HAX)) += hax-stub.o +obj-$(call lnot,$(CONFIG_HVF)) += hvf-stub.o +obj-$(call lnot,$(CONFIG_WHPX)) += whpx-stub.o +obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o +obj-$(call lnot,$(CONFIG_TCG)) += tcg-stub.o
accel/stubs/whpx-stub.c new file +48 -0
48 lines not on this page · raw message
include/sysemu/whpx.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* QEMU Windows Hypervisor Platform accelerator (WHPX) support +* +* Copyright Microsoft, Corp. 2017 +* +* Authors: +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#ifndef QEMU_WHPX_H +#define QEMU_WHPX_H + +#include "config-host.h" +#include "qemu-common.h" + +int whpx_init_vcpu (CPUState *cpu); +int whpx_vcpu_exec (CPUState *cpu); +void whpx_destroy_vcpu (CPUState *cpu); +void whpx_vcpu_kick (CPUState *cpu); + + +void whpx_cpu_synchronize_state (CPUState *cpu); +void whpx_cpu_synchronize_post_reset (CPUState *cpu); +void whpx_cpu_synchronize_post_init (CPUState *cpu); +void whpx_cpu_synchronize_pre_loadvm (CPUState *cpu); + +#ifdef CONFIG_WHPX + +int whpx_enabled (void ); + +#else /* CONFIG_WHPX */ + +#define whpx_enabled () (0) + +#endif /* CONFIG_WHPX */ + +#endif /* QEMU_WHPX_H */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 47/47] Add the WHPX acceleration enlightenments
In reply to Paolo BonziniFrom: "Justin Terry (VM)" <[email protected]>
Implements the WHPX accelerator cpu enlightenments to actually use the whpx-all accelerator on Windows platforms.
Message-Id: <[email protected]>
--- cpus.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++- include/sysemu/hw_accel.h | 13 +++++++++ target/i386/helper.c | 2 +- 3 files changed, 82 insertions(+), 2 deletions(-)
cpus.c +68 -1
@@ -38,6 +38,7 @@#include "sysemu/kvm.h" #include "sysemu/hax.h" #include "sysemu/hvf.h" +#include "sysemu/whpx.h" #include "qmp-commands.h" #include "exec/exec-all.h"
@@ -1545,6 +1546,49 @@ static void *qemu_hvf_cpu_thread_fn(void *arg)return NULL ; } +static void *qemu_whpx_cpu_thread_fn (void *arg) +{ +CPUState *cpu = arg; +int r; + +rcu_register_thread (); + +qemu_mutex_lock_iothread (); +qemu_thread_get_self (cpu->thread); + cpu->thread_id =qemu_get_thread_id (); + current_cpu = cpu; + + r =whpx_init_vcpu (cpu); +if (r <0 ) { +fprintf (stderr,"whpx_init_vcpu failed: %s\n" ,strerror (-r)); +exit (1 ); + } + +/* signal CPU creation */ + cpu->created = true; +qemu_cond_signal (&qemu_cpu_cond); + +do { +if (cpu_can_run (cpu)) { + r =whpx_vcpu_exec (cpu); +if (r ==EXCP_DEBUG ) { +cpu_handle_guest_debug (cpu); + } + } +while (cpu_thread_is_idle (cpu)) { +qemu_cond_wait (cpu->halt_cond, &qemu_global_mutex); + } +qemu_wait_io_event_common (cpu); + }while (!cpu->unplug ||cpu_can_run (cpu)); + +whpx_destroy_vcpu (cpu); + cpu->created = false; +qemu_cond_signal (&qemu_cpu_cond); +qemu_mutex_unlock_iothread (); +rcu_unregister_thread (); +return NULL ; +} +#ifdef _WIN32 static void CALLBACK dummy_apc_func(ULONG_PTR unused) {
@@ -1635,7 +1679,9 @@ static void qemu_cpu_kick_thread(CPUState *cpu) }#else /* _WIN32 */ if (!qemu_cpu_is_self (cpu)) { -if (!QueueUserAPC (dummy_apc_func, cpu->hThread,0 )) { +if (whpx_enabled ()) { +whpx_vcpu_kick (cpu); + }else if (!QueueUserAPC (dummy_apc_func, cpu->hThread,0 )) {fprintf (stderr,"%s: QueueUserAPC failed with error %lu\n" , __func__,GetLastError ());exit (1 );
@@ -1877,6 +1923,25 @@ static void qemu_hvf_start_vcpu(CPUState *cpu) } } +static void qemu_whpx_start_vcpu (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; + + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"CPU %d/WHPX" , + cpu->cpu_index); +qemu_thread_create (cpu->thread, thread_name, qemu_whpx_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); +#ifdef _WIN32 + cpu->hThread =qemu_thread_get_handle (cpu->thread); +#endif +while (!cpu->created) { +qemu_cond_wait (&qemu_cpu_cond, &qemu_global_mutex); + } +} +static void qemu_dummy_start_vcpu (CPUState *cpu) {char thread_name[VCPU_THREAD_NAME_SIZE ];
@@ -1915,6 +1980,8 @@ void qemu_init_vcpu(CPUState *cpu)qemu_hvf_start_vcpu (cpu); }else if (tcg_enabled ()) {qemu_tcg_init_vcpu (cpu); + }else if (whpx_enabled ()) { +qemu_whpx_start_vcpu (cpu); }else {qemu_dummy_start_vcpu (cpu); }
include/sysemu/hw_accel.h +13 -0
@@ -14,6 +14,7 @@#include "qom/cpu.h" #include "sysemu/hax.h" #include "sysemu/kvm.h" +#include "sysemu/whpx.h" static inline void cpu_synchronize_state (CPUState *cpu) {
@@ -23,6 +24,9 @@ static inline void cpu_synchronize_state(CPUState *cpu)if (hax_enabled ()) {hax_cpu_synchronize_state (cpu); } +if (whpx_enabled ()) { +whpx_cpu_synchronize_state (cpu); + } }static inline void cpu_synchronize_post_reset (CPUState *cpu)
@@ -33,6 +37,9 @@ static inline void cpu_synchronize_post_reset(CPUState *cpu)if (hax_enabled ()) {hax_cpu_synchronize_post_reset (cpu); } +if (whpx_enabled ()) { +whpx_cpu_synchronize_post_reset (cpu); + } }static inline void cpu_synchronize_post_init (CPUState *cpu)
@@ -43,6 +50,9 @@ static inline void cpu_synchronize_post_init(CPUState *cpu)if (hax_enabled ()) {hax_cpu_synchronize_post_init (cpu); } +if (whpx_enabled ()) { +whpx_cpu_synchronize_post_init (cpu); + } }static inline void cpu_synchronize_pre_loadvm (CPUState *cpu)
@@ -53,6 +63,9 @@ static inline void cpu_synchronize_pre_loadvm(CPUState *cpu)if (hax_enabled ()) {hax_cpu_synchronize_pre_loadvm (cpu); } +if (whpx_enabled ()) { +whpx_cpu_synchronize_pre_loadvm (cpu); + } }#endif /* QEMU_HW_ACCEL_H */
target/i386/helper.c +1 -1
@@ -986,7 +986,7 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access)X86CPU *cpu =x86_env_get_cpu (env);CPUState *cs =CPU (cpu); -if (kvm_enabled ()) { +if (kvm_enabled () ||whpx_enabled ()) { env->tpr_access_type = access;cpu_interrupt (cs,CPU_INTERRUPT_TPR );
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 46/47] Introduce the WHPX impl
In reply to Paolo BonziniFrom: "Justin Terry (VM)" <[email protected]>
Implements the Windows Hypervisor Platform accelerator (WHPX) target. Which acts as a hypervisor accelerator for QEMU on the Windows platform. This enables QEMU much greater speed over the emulated x86_64 path's that are taken on Windows today.
1. Adds support for vPartition management.
2. Adds support for vCPU management.
3. Adds support for MMIO/PortIO.
4. Registers the WHPX ACCEL_CLASS.
Message-Id: <[email protected]>
--- target/i386/Makefile.objs | 1 + target/i386/whpx-all.c | 1366 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1367 insertions(+) create mode 100644 target/i386/whpx-all.c
target/i386/Makefile.objs +1 -0
@@ -14,3 +14,4 @@ ifdef CONFIG_DARWIN obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-darwin.o obj-$(CONFIG_HVF) += hvf/ endif +obj-$(CONFIG_WHPX) += whpx-all.o
target/i386/whpx-all.c new file +1366 -0
1,366 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 28 lines · Paolo Bonzini
The following changes since commit
f24ee107a07f093bd7ed475dd48d7ba57ea3d8fe:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180202-pull-request' into staging (2018-02-02 18:54:11 +0000)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
d2eac10f23a071ddbd2970ed139c6ca077ff2e48:Add the WHPX acceleration enlightenments (2018-02-05 18:30:55 +0100)
----------------------------------------------------------------
* socket option parsing fix (Daniel)
* SCSI fixes (Fam)
* Readline double-free fix (Greg)
* More HVF attribution fixes (Izik)
* WHPX (Windows Hypervisor Platform Extensions) support (Justin)
* POLLHUP handler (Klim)
* ivshmem fixes (Ladi)
* memfd memory backend (Marc-André)
* improved error message (Marcelo)
* Memory fixes (Peter Xu, Zhecheng)
* Remove obsolete code and comments (Peter M.)
* qdev API improvements (Philippe)
* AddCONFIG_I2Cswitch (Thomas)
Quoted 1 line
----------------------------------------------------------------
Hi. I'm afraid this fails to build the all-linux-static config:
LINK ivshmem-client
[usual linker gripes about getpwuid &c in static binaries deleted] /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::SetEnv(cha
r const*, char const*)':
(.text+0x41b): undefined reference to `dlsym' /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::InitTlsSize()':
(.text+0x553): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
thanks
-- PMM
Quoted 13 lines · Peter Maydell
Hi. I'm afraid this fails to build the all-linux-static config:
LINK ivshmem-client
[usual linker gripes about getpwuid &c in static binaries deleted] /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::SetEnv(cha
r const*, char const*)':
(.text+0x41b): undefined reference to `dlsym' /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::InitTlsSize()':
(.text+0x553): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
Uhm, what is all-linux-static? Is it using --enable-debug?
Paolo
Quoted 15 lines · Paolo Bonzini
Quoted 13 lines · Peter Maydell
Hi. I'm afraid this fails to build the all-linux-static config:
LINK ivshmem-client
[usual linker gripes about getpwuid &c in static binaries deleted] /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::SetEnv(cha
r const*, char const*)':
(.text+0x41b): undefined reference to `dlsym' /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::InitTlsSize()':
(.text+0x553): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
Quoted 1 line
Uhm, what is all-linux-static? Is it using --enable-debug?
Yeah, it's a config with --enable-debug --static --disable-system
thanks
-- PMM
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Paolo Bonzini
Quoted 13 lines · Peter Maydell
Hi. I'm afraid this fails to build the all-linux-static config:
LINK ivshmem-client
[usual linker gripes about getpwuid &c in static binaries deleted] /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::SetEnv(cha
r const*, char const*)':
(.text+0x41b): undefined reference to `dlsym' /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::InitTlsSize()':
(.text+0x553): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
Quoted 3 lines
Quoted 1 line
Uhm, what is all-linux-static? Is it using --enable-debug?
Yeah, it's a config with --enable-debug --static --disable-system
Ok, I'll drop the change to enable --enable-sanitizers when you give --enable-debug. It's premature.
Paolo
Hi
Quoted 17 lines · Paolo Bonzini
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Paolo Bonzini
Quoted 13 lines · Peter Maydell
Hi. I'm afraid this fails to build the all-linux-static config:
LINK ivshmem-client
[usual linker gripes about getpwuid &c in static binaries deleted] /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::SetEnv(cha
r const*, char const*)':
(.text+0x41b): undefined reference to `dlsym' /usr/lib/gcc/x86_64-linux-gnu/5/libubsan.a(sanitizer_linux_libcdep.o):
In function `__sanitizer::InitTlsSize()':
(.text+0x553): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Uhm, what is all-linux-static? Is it using --enable-debug?
Yeah, it's a config with --enable-debug --static --disable-system
Ok, I'll drop the change to enable --enable-sanitizers when you give --enable-debug. It's premature.
It is a bit weird that this is not caught during configure time, that does check static compilation (when --static) with the sanitizers. What is the host? is there a docker check to reproduce?
Signature · 1 line
Marc-André Lureau
Quoted 3 lines · Marc-André Lureau
It is a bit weird that this is not caught during configure time, that does check static compilation (when --static) with the sanitizers. What is the host? is there a docker check to reproduce?
The host is x86-64 ubuntu xenial.
thanks
-- PMM