Skip to contentSkip to conversation

Misc patches for 2016-09-26

GIT PULL Applied Paolo Bonzini 2 participants 5 messages Sep 28, 2016

lore
Share & tools
lore
#0 lore raw

The following changes since commit 7cfdc02dae0d2ff58c897496cfdbbafc0eda0f3f:

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2016-09-26 19:47:00 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 6d0ceb80ffe18ad4b28aab7356f440636c0be7be:

replay: allow replay stopping and restarting (2016-09-27 11:57:30 +0200)

----------------------------------------------------------------
* thread-safe tb_flush (Fred, Alex, Sergey, me, Richard, Emilio,... :-)
* license clarification for compiler.h (Felipe)
* glib cflags improvement (Marc-André)
* checkpatch silencing (Paolo)
* SMRAM migration fix (Paolo)
* Replay improvements (Pavel)
* IOMMU notifier improvements (Peter)
* IOAPIC now defaults to version 0x20 (Peter)

----------------------------------------------------------------
Alex Bennée (1):
cpus: pass CPUState to run_on_cpu helpers

Felipe Franciosi (1):
compiler: Swap 'public domain' header for license

Marc-André Lureau (2):
build-sys: remove unused GLIB_CFLAGS
build-sys: put glib_cflags in QEMU_CFLAGS

Paolo Bonzini (11):
checkpatch: downgrade "architecture specific defines should be avoided"
migration: sync all address spaces
cpus-common: move CPU list management to common code
cpus-common: fix uninitialized variable use in run_on_cpu
cpus-common: move exclusive work infrastructure from linux-user
docs: include formal model for TCG exclusive sections
cpus-common: always defer async_run_on_cpu work items
cpus-common: remove redundant call to exclusive_idle()
cpus-common: simplify locking for start_exclusive/end_exclusive
cpus-common: Introduce async_safe_run_on_cpu()
cpus-common: lock-free fast path for cpu_exec_start/end

Pavel Dovgalyuk (3):
replay: move internal data to the structure
replay: vmstate for replay module
replay: allow replay stopping and restarting

Peter Xu (4):
memory: introduce IOMMUNotifier and its caps
memory: introduce IOMMUOps.notify_flag_changed intel_iommu, amd_iommu: allow UNMAP notifiers
x86: ioapic: boost default version to 0x20

Sergey Fedorov (6):
cpus: Move common code out of {async_, }run_on_cpu()
cpus: Rename flush_queued_work()
linux-user: Use QemuMutex and QemuCond
linux-user: Add qemu_cpu_is_self() and qemu_cpu_kick()
cpus-common: move CPU work item management to common code
tcg: Make tb_flush() thread safe

 Makefile.objs                 |   2 +-
 block/blkreplay.c             |  15 +-
 bsd-user/main.c               |  33 +---
 configure                     |   3 +-
 cpu-exec.c                    |  12 +-
 cpus-common.c                 | 352 ++++++++++++++++++++++++++++++++++++++++++
 cpus.c                        | 100 +-----------
 docs/tcg-exclusive.promela    | 225 +++++++++++++++++++++++++++
 exec.c                        |  37 +----
 hw/i386/amd_iommu.c           |  16 +-
 hw/i386/intel_iommu.c         |  18 ++-
 hw/i386/kvm/apic.c            |   5 +-
 hw/i386/kvmvapic.c            |   6 +-
 hw/intc/ioapic.c              |   2 +-
 hw/ppc/ppce500_spin.c         |  31 ++--
 hw/ppc/spapr.c                |   6 +-
 hw/ppc/spapr_hcall.c          |  17 +-
 hw/ppc/spapr_iommu.c          |  18 ++-
 hw/vfio/common.c              |   4 +-
 include/exec/cpu-common.h     |   5 +
 include/exec/exec-all.h       |  11 --
 include/exec/memory.h         |  63 ++++++--
 include/exec/tb-context.h     |   2 +-
 include/hw/compat.h           |   4 +
 include/hw/vfio/vfio-common.h |   2 +-
 include/qemu/compiler.h       |   6 +-
 include/qom/cpu.h             | 102 ++++++++++--
 include/sysemu/replay.h       |   4 +
 kvm-all.c                     |  21 +--
 linux-user/main.c             | 130 +++++-----------
 memory.c                      | 106 +++++++++----
 migration/ram.c               |   2 +-
 replay/Makefile.objs          |   1 +
 replay/replay-events.c        |  10 +-
 replay/replay-internal.c      |  20 ++-
 replay/replay-internal.h      |  23 ++-
 replay/replay-snapshot.c      |  61 ++++++++
 replay/replay-time.c          |   2 +-
 replay/replay.c               |  16 +-
 scripts/checkpatch.pl         |   2 +-
 stubs/replay.c                |   5 +
 target-i386/helper.c          |  19 +--
 target-i386/kvm.c             |   6 +-
 target-s390x/cpu.c            |   4 +-
 target-s390x/cpu.h            |   7 +-
 target-s390x/kvm.c            |  98 ++++++------
 target-s390x/misc_helper.c    |   4 +-
 translate-all.c               |  38 +++--
 vl.c                          |   2 +
 49 files changed, 1157 insertions(+), 521 deletions(-)
 create mode 100644 cpus-common.c
 create mode 100644 docs/tcg-exclusive.promela
 create mode 100644 replay/replay-snapshot.c
Signature · 1 line
2.7.4
#1 lore raw

[Qemu-devel] [PULL 02/28] memory: introduce IOMMUOps.notify_flag_changed

From: Peter Xu <[email protected]>

The new interface can be used to replace the old notify_started() and notify_stopped(). Meanwhile it provides explicit flags so that IOMMUs can know what kind of notifications it is requested for.

Message-Id: <[email protected]>

---
 hw/i386/amd_iommu.c   |  6 ++++--
 hw/i386/intel_iommu.c |  6 ++++--
 hw/ppc/spapr_iommu.c  | 18 ++++++++++--------
 include/exec/memory.h |  9 +++++----
 memory.c              | 29 +++++++++++++++++++++--------
 5 files changed, 44 insertions(+), 24 deletions(-)
hw/i386/amd_iommu.c +4 -2
index a91a179..a868539 100644
@@ -1066,7 +1066,9 @@ static const MemoryRegionOps mmio_mem_ops = {
     }
 };
 
-static void amdvi_iommu_notify_started(MemoryRegion *iommu)
+static void amdvi_iommu_notify_flag_changed(MemoryRegion *iommu,
+                                            IOMMUNotifierFlag old,
+                                            IOMMUNotifierFlag new)
 {
     AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
 
@@ -1080,7 +1082,7 @@ static void amdvi_init(AMDVIState *s)
     amdvi_iotlb_reset(s);
 
     s->iommu_ops.translate = amdvi_translate;
-    s->iommu_ops.notify_started = amdvi_iommu_notify_started;
+    s->iommu_ops.notify_flag_changed = amdvi_iommu_notify_flag_changed;
     s->devtab_len = 0;
     s->cmdbuf_len = 0;
     s->cmdbuf_head = 0;
hw/i386/intel_iommu.c +4 -2
index d6e02c8..b6cc38c 100644
@@ -1974,7 +1974,9 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
     return ret;
 }
 
-static void vtd_iommu_notify_started(MemoryRegion *iommu)
+static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
+                                          IOMMUNotifierFlag old,
+                                          IOMMUNotifierFlag new)
 {
     VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
 
@@ -2348,7 +2350,7 @@ static void vtd_init(IntelIOMMUState *s)
     memset(s->womask, 0, DMAR_REG_SIZE);
 
     s->iommu_ops.translate = vtd_iommu_translate;
-    s->iommu_ops.notify_started = vtd_iommu_notify_started;
+    s->iommu_ops.notify_flag_changed = vtd_iommu_notify_flag_changed;
     s->root = 0;
     s->root_extended = false;
     s->dmar_enabled = false;
hw/ppc/spapr_iommu.c +10 -8
index f20b0b8..ae30bbe 100644
@@ -156,14 +156,17 @@ static uint64_t spapr_tce_get_min_page_size(MemoryRegion *iommu)
     return 1ULL << tcet->page_shift;
 }
 
-static void spapr_tce_notify_started(MemoryRegion *iommu)
+static void spapr_tce_notify_flag_changed(MemoryRegion *iommu,
+                                          IOMMUNotifierFlag old,
+                                          IOMMUNotifierFlag new)
 {
-    spapr_tce_set_need_vfio(container_of(iommu, sPAPRTCETable, iommu), true);
-}
+    struct sPAPRTCETable *tbl = container_of(iommu, sPAPRTCETable, iommu);
 
-static void spapr_tce_notify_stopped(MemoryRegion *iommu)
-{
-    spapr_tce_set_need_vfio(container_of(iommu, sPAPRTCETable, iommu), false);
+    if (old == IOMMU_NOTIFIER_NONE && new != IOMMU_NOTIFIER_NONE) {
+        spapr_tce_set_need_vfio(tbl, true);
+    } else if (old != IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_NONE) {
+        spapr_tce_set_need_vfio(tbl, false);
+    }
 }
 
 static int spapr_tce_table_post_load(void *opaque, int version_id)
@@ -246,8 +249,7 @@ static const VMStateDescription vmstate_spapr_tce_table = {
 static MemoryRegionIOMMUOps spapr_iommu_ops = {
     .translate = spapr_tce_translate_iommu,
     .get_min_page_size = spapr_tce_get_min_page_size,
-    .notify_started = spapr_tce_notify_started,
-    .notify_stopped = spapr_tce_notify_stopped,
+    .notify_flag_changed = spapr_tce_notify_flag_changed,
 };
 
 static int spapr_tce_table_realize(DeviceState *dev)
include/exec/memory.h +5 -4
index 14cda67..a3f988b 100644
@@ -174,10 +174,10 @@ struct MemoryRegionIOMMUOps {
     IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool is_write);
     /* Returns minimum supported page size */
     uint64_t (*get_min_page_size)(MemoryRegion *iommu);
-    /* Called when the first notifier is set */
-    void (*notify_started)(MemoryRegion *iommu);
-    /* Called when the last notifier is removed */
-    void (*notify_stopped)(MemoryRegion *iommu);
+    /* Called when IOMMU Notifier flag changed */
+    void (*notify_flag_changed)(MemoryRegion *iommu,
+                                IOMMUNotifierFlag old_flags,
+                                IOMMUNotifierFlag new_flags);
 };
 
 typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -223,6 +223,7 @@ struct MemoryRegion {
     unsigned ioeventfd_nb;
     MemoryRegionIoeventfd *ioeventfds;
     QLIST_HEAD(, IOMMUNotifier) iommu_notify;
+    IOMMUNotifierFlag iommu_notify_flags;
 };
 
 /**
memory.c +21 -8
index 69d9d9a..27a3f2f 100644
@@ -1414,6 +1414,7 @@ void memory_region_init_iommu(MemoryRegion *mr,
     mr->iommu_ops = ops,
     mr->terminates = true;  /* then re-forwards */
     QLIST_INIT(&mr->iommu_notify);
+    mr->iommu_notify_flags = IOMMU_NOTIFIER_NONE;
 }
 
 static void memory_region_finalize(Object *obj)
@@ -1508,16 +1509,31 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8_t client)
     return memory_region_get_dirty_log_mask(mr) & (1 << client);
 }
 
+static void memory_region_update_iommu_notify_flags(MemoryRegion *mr)
+{
+    IOMMUNotifierFlag flags = IOMMU_NOTIFIER_NONE;
+    IOMMUNotifier *iommu_notifier;
+
+    QLIST_FOREACH(iommu_notifier, &mr->iommu_notify, node) {
+        flags |= iommu_notifier->notifier_flags;
+    }
+
+    if (flags != mr->iommu_notify_flags &&
+        mr->iommu_ops->notify_flag_changed) {
+        mr->iommu_ops->notify_flag_changed(mr, mr->iommu_notify_flags,
+                                           flags);
+    }
+
+    mr->iommu_notify_flags = flags;
+}
+
 void memory_region_register_iommu_notifier(MemoryRegion *mr,
                                            IOMMUNotifier *n)
 {
     /* We need to register for at least one bitfield */
     assert(n->notifier_flags != IOMMU_NOTIFIER_NONE);
-    if (mr->iommu_ops->notify_started &&
-        QLIST_EMPTY(&mr->iommu_notify)) {
-        mr->iommu_ops->notify_started(mr);
-    }
     QLIST_INSERT_HEAD(&mr->iommu_notify, n, node);
+    memory_region_update_iommu_notify_flags(mr);
 }
 
 uint64_t memory_region_iommu_get_min_page_size(MemoryRegion *mr)
@@ -1555,10 +1571,7 @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr,
                                              IOMMUNotifier *n)
 {
     QLIST_REMOVE(n, node);
-    if (mr->iommu_ops->notify_stopped &&
-        QLIST_EMPTY(&mr->iommu_notify)) {
-        mr->iommu_ops->notify_stopped(mr);
-    }
+    memory_region_update_iommu_notify_flags(mr);
 }
 
 void memory_region_notify_iommu(MemoryRegion *mr,
Signature · 1 line
2.7.4
#2 lore raw

[Qemu-devel] [PULL 03/28] intel_iommu, amd_iommu: allow UNMAP notifiers

In reply to Paolo Bonzini

From: Peter Xu <[email protected]>

x86 vIOMMUs still lack of a complete IOMMU notifier mechanism. Before that is achieved, let's open a door for vhost DMAR support, which only requires cache invalidations (UNMAP operations).

Meanwhile, convert hw_error() to error_report() and exit(1), to make the error messages cleaner and obvious (no CPU registers will be dumped).

Message-Id: <[email protected]>

---
 hw/i386/amd_iommu.c   | 10 +++++++---
 hw/i386/intel_iommu.c | 12 ++++++++----
 2 files changed, 15 insertions(+), 7 deletions(-)
hw/i386/amd_iommu.c +7 -3
index a868539..023de52 100644
@@ -21,6 +21,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/i386/amd_iommu.h"
+#include "qemu/error-report.h"
 #include "trace.h"
 
 /* used AMD-Vi MMIO registers */
@@ -1072,9 +1073,12 @@ static void amdvi_iommu_notify_flag_changed(MemoryRegion *iommu,
 {
     AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
 
-    hw_error("device %02x.%02x.%x requires iommu notifier which is not "
-             "currently supported", as->bus_num, PCI_SLOT(as->devfn),
-             PCI_FUNC(as->devfn));
+    if (new & IOMMU_NOTIFIER_MAP) {
+        error_report("device %02x.%02x.%x requires iommu notifier which is not "
+                     "currently supported", as->bus_num, PCI_SLOT(as->devfn),
+                     PCI_FUNC(as->devfn));
+        exit(1);
+    }
 }
 
 static void amdvi_init(AMDVIState *s)
hw/i386/intel_iommu.c +8 -4
index b6cc38c..9f4e64a 100644
@@ -1980,10 +1980,14 @@ static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
 {
     VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
 
-    hw_error("Device at bus %s addr %02x.%d requires iommu notifier which "
-             "is currently not supported by intel-iommu emulation",
-             vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
-             PCI_FUNC(vtd_as->devfn));
+    if (new & IOMMU_NOTIFIER_MAP) {
+        error_report("Device at bus %s addr %02x.%d requires iommu "
+                     "notifier which is currently not supported by "
+                     "intel-iommu emulation",
+                     vtd_as->bus->qbus.name, PCI_SLOT(vtd_as->devfn),
+                     PCI_FUNC(vtd_as->devfn));
+        exit(1);
+    }
 }
 
 static const VMStateDescription vtd_vmstate = {
Signature · 1 line
2.7.4
#3 lore raw

[Qemu-devel] [PULL 27/28] replay: vmstate for replay module

In reply to Paolo Bonzini

From: Pavel Dovgalyuk <[email protected]>

This patch introduces vmstate for replay data structures. It allows saving and loading vmstate while replaying.

Message-Id: <20160926080810.6992.68420.stgit@PASHA-ISP>

---
 replay/Makefile.objs     |  1 +
 replay/replay-internal.h |  9 ++++++++
 replay/replay-snapshot.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 replay/replay.c          |  1 +
 4 files changed, 71 insertions(+)
 create mode 100644 replay/replay-snapshot.c
replay/Makefile.objs +1 -0
index fcb3f74..c8ad3eb 100644
@@ -4,3 +4,4 @@ common-obj-y += replay-events.o
 common-obj-y += replay-time.o
 common-obj-y += replay-input.o
 common-obj-y += replay-char.o
+common-obj-y += replay-snapshot.o
replay/replay-internal.h +9 -0
index 9b02d7d..e07eb7d 100644
@@ -66,6 +66,8 @@ typedef struct ReplayState {
     unsigned int data_kind;
     /*! Flag which indicates that event is not processed yet. */
     unsigned int has_unread_data;
+    /*! Temporary variable for saving current log offset. */
+    uint64_t file_offset;
 } ReplayState;
 extern ReplayState replay_state;
 
@@ -157,4 +159,11 @@ void replay_event_char_read_save(void *opaque);
 /*! Reads char event read from the file. */
 void *replay_event_char_read_load(void);
 
+/* VMState-related functions */
+
+/* Registers replay VMState.
+   Should be called before virtual devices initialization
+   to make cached timers available for post_load functions. */
+void replay_vmstate_register(void);
+
 #endif
replay/replay-snapshot.c new file +60 -0

60 lines not on this page · raw message

replay/replay.c +1 -0
index cc2238d..c797aea 100644
@@ -292,6 +292,7 @@ void replay_configure(QemuOpts *opts)
         exit(1);
     }
 
+    replay_vmstate_register();
     replay_enable(fname, mode);
 
 out:
Signature · 1 line
2.7.4
#4 lore raw
In reply to Paolo Bonzini
Quoted 12 lines · Paolo Bonzini

The following changes since commit 7cfdc02dae0d2ff58c897496cfdbbafc0eda0f3f:

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2016-09-26 19:47:00 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 6d0ceb80ffe18ad4b28aab7356f440636c0be7be:

replay: allow replay stopping and restarting (2016-09-27 11:57:30 +0200)

Quoted 9 lines

----------------------------------------------------------------
* thread-safe tb_flush (Fred, Alex, Sergey, me, Richard, Emilio,... :-)
* license clarification for compiler.h (Felipe)
* glib cflags improvement (Marc-André)
* checkpatch silencing (Paolo)
* SMRAM migration fix (Paolo)
* Replay improvements (Pavel)
* IOMMU notifier improvements (Peter)
* IOAPIC now defaults to version 0x20 (Peter)

Applied, thanks.

-- PMM