qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes
@ 2019-04-05 23:12 Michael S. Tsirkin
  2019-04-05 23:12 ` Michael S. Tsirkin
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit 436960c95946007aca713330e7a488a6f2e0696f:

  Merge remote-tracking branch 'remotes/berrange/tags/filemon-next-pull-request' into staging (2019-04-02 14:52:17 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 81fb1e646e4da29f8e1639022241323b956b67e4:

  intel_iommu: Drop extended root field (2019-04-02 11:49:14 -0400)

----------------------------------------------------------------
pci, pc, virtio: fixes

intel-iommu fixes
virtio typo fixes
linker: a couple of asserts for consistency/security

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Alex Williamson (1):
      intel_iommu: Correct caching-mode error message

Liam Merwick (1):
      acpi: verify file entries in bios_linker_loader_add_pointer()

Peter Xu (2):
      intel_iommu: Fix root_scalable migration breakage
      intel_iommu: Drop extended root field

Yuval Shaia (1):
      virtio-net: Fix typo in comment

 hw/i386/intel_iommu_internal.h |  1 -
 include/hw/i386/intel_iommu.h  |  1 -
 hw/acpi/bios-linker-loader.c   |  2 ++
 hw/i386/intel_iommu.c          | 32 +++++++++++++++++++++++---------
 hw/net/virtio-net.c            |  2 +-
 hw/i386/trace-events           |  2 +-
 6 files changed, 27 insertions(+), 13 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
@ 2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12 ` [Qemu-devel] [PULL 1/5] acpi: verify file entries in bios_linker_loader_add_pointer() Michael S. Tsirkin
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit 436960c95946007aca713330e7a488a6f2e0696f:

  Merge remote-tracking branch 'remotes/berrange/tags/filemon-next-pull-request' into staging (2019-04-02 14:52:17 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 81fb1e646e4da29f8e1639022241323b956b67e4:

  intel_iommu: Drop extended root field (2019-04-02 11:49:14 -0400)

----------------------------------------------------------------
pci, pc, virtio: fixes

intel-iommu fixes
virtio typo fixes
linker: a couple of asserts for consistency/security

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Alex Williamson (1):
      intel_iommu: Correct caching-mode error message

Liam Merwick (1):
      acpi: verify file entries in bios_linker_loader_add_pointer()

Peter Xu (2):
      intel_iommu: Fix root_scalable migration breakage
      intel_iommu: Drop extended root field

Yuval Shaia (1):
      virtio-net: Fix typo in comment

 hw/i386/intel_iommu_internal.h |  1 -
 include/hw/i386/intel_iommu.h  |  1 -
 hw/acpi/bios-linker-loader.c   |  2 ++
 hw/i386/intel_iommu.c          | 32 +++++++++++++++++++++++---------
 hw/net/virtio-net.c            |  2 +-
 hw/i386/trace-events           |  2 +-
 6 files changed, 27 insertions(+), 13 deletions(-)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 1/5] acpi: verify file entries in bios_linker_loader_add_pointer()
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
  2019-04-05 23:12 ` Michael S. Tsirkin
@ 2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12   ` Michael S. Tsirkin
  2019-04-05 23:12 ` [Qemu-devel] [PULL 2/5] intel_iommu: Correct caching-mode error message Michael S. Tsirkin
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Liam Merwick, Igor Mammedov

From: Liam Merwick <liam.merwick@oracle.com>

The callers to bios_linker_find_file() assert that the file entry returned
is not NULL, except for those in bios_linker_loader_add_pointer().  Add two
asserts in that case for completeness and to facilitate static code analysis.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
Message-Id: <1553199229-25318-1-git-send-email-liam.merwick@oracle.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/acpi/bios-linker-loader.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c
index d16b8bbcb1..626c04a39f 100644
--- a/hw/acpi/bios-linker-loader.c
+++ b/hw/acpi/bios-linker-loader.c
@@ -283,6 +283,8 @@ void bios_linker_loader_add_pointer(BIOSLinker *linker,
     const BiosLinkerFileEntry *source_file =
         bios_linker_find_file(linker, src_file);
 
+    assert(dst_file);
+    assert(source_file);
     assert(dst_patched_offset < dst_file->blob->len);
     assert(dst_patched_offset + dst_patched_size <= dst_file->blob->len);
     assert(src_offset < source_file->blob->len);
-- 
MST

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 1/5] acpi: verify file entries in bios_linker_loader_add_pointer()
  2019-04-05 23:12 ` [Qemu-devel] [PULL 1/5] acpi: verify file entries in bios_linker_loader_add_pointer() Michael S. Tsirkin
@ 2019-04-05 23:12   ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Igor Mammedov

From: Liam Merwick <liam.merwick@oracle.com>

The callers to bios_linker_find_file() assert that the file entry returned
is not NULL, except for those in bios_linker_loader_add_pointer().  Add two
asserts in that case for completeness and to facilitate static code analysis.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
Message-Id: <1553199229-25318-1-git-send-email-liam.merwick@oracle.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/acpi/bios-linker-loader.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c
index d16b8bbcb1..626c04a39f 100644
--- a/hw/acpi/bios-linker-loader.c
+++ b/hw/acpi/bios-linker-loader.c
@@ -283,6 +283,8 @@ void bios_linker_loader_add_pointer(BIOSLinker *linker,
     const BiosLinkerFileEntry *source_file =
         bios_linker_find_file(linker, src_file);
 
+    assert(dst_file);
+    assert(source_file);
     assert(dst_patched_offset < dst_file->blob->len);
     assert(dst_patched_offset + dst_patched_size <= dst_file->blob->len);
     assert(src_offset < source_file->blob->len);
-- 
MST



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 2/5] intel_iommu: Correct caching-mode error message
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
  2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12 ` [Qemu-devel] [PULL 1/5] acpi: verify file entries in bios_linker_loader_add_pointer() Michael S. Tsirkin
@ 2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12   ` Michael S. Tsirkin
  2019-04-05 23:12 ` [Qemu-devel] [PULL 3/5] virtio-net: Fix typo in comment Michael S. Tsirkin
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Alex Williamson, Peter Xu, Laurent Vivier,
	Philippe Mathieu-Daudé, Alex, Williamson, &lt,
	Eric Auger, Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Marcel Apfelbaum

From: Alex Williamson <alex.williamson@redhat.com>

If we try to use the intel-iommu device with vfio-pci devices without
caching mode enabled, we're told:

  qemu-system-x86_64: We need to set caching-mode=1 for intel-iommu to enable
  device assignment with IOMMU protection.

But to enable caching mode, the option is actually "caching-mode=on".

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <155364147432.16467.15898335025013220939.stgit@gimli.home>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Alex Williamson &lt;<a href="mailto:alex.williamson@redhat.com" target="_blank" rel="noreferrer">alex.williamson@redhat.com</a>&gt;<br>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 055a1e865d..146cd16dd2 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2919,7 +2919,7 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
     IntelIOMMUState *s = vtd_as->iommu_state;
 
     if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) {
-        error_report("We need to set caching-mode=1 for intel-iommu to enable "
+        error_report("We need to set caching-mode=on for intel-iommu to enable "
                      "device assignment with IOMMU protection.");
         exit(1);
     }
-- 
MST

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 2/5] intel_iommu: Correct caching-mode error message
  2019-04-05 23:12 ` [Qemu-devel] [PULL 2/5] intel_iommu: Correct caching-mode error message Michael S. Tsirkin
@ 2019-04-05 23:12   ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, &lt, Laurent Vivier, Peter Xu,
	Philippe Mathieu-Daudé, Eric Auger, Alex Williamson,
	Paolo Bonzini, Williamson, Alex, Richard Henderson

From: Alex Williamson <alex.williamson@redhat.com>

If we try to use the intel-iommu device with vfio-pci devices without
caching mode enabled, we're told:

  qemu-system-x86_64: We need to set caching-mode=1 for intel-iommu to enable
  device assignment with IOMMU protection.

But to enable caching mode, the option is actually "caching-mode=on".

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <155364147432.16467.15898335025013220939.stgit@gimli.home>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Alex Williamson &lt;<a href="mailto:alex.williamson@redhat.com" target="_blank" rel="noreferrer">alex.williamson@redhat.com</a>&gt;<br>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 055a1e865d..146cd16dd2 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2919,7 +2919,7 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
     IntelIOMMUState *s = vtd_as->iommu_state;
 
     if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) {
-        error_report("We need to set caching-mode=1 for intel-iommu to enable "
+        error_report("We need to set caching-mode=on for intel-iommu to enable "
                      "device assignment with IOMMU protection.");
         exit(1);
     }
-- 
MST



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 3/5] virtio-net: Fix typo in comment
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2019-04-05 23:12 ` [Qemu-devel] [PULL 2/5] intel_iommu: Correct caching-mode error message Michael S. Tsirkin
@ 2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12   ` Michael S. Tsirkin
  2019-04-05 23:12 ` [Qemu-devel] [PULL 4/5] intel_iommu: Fix root_scalable migration breakage Michael S. Tsirkin
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Yuval Shaia, Jason Wang

From: Yuval Shaia <yuval.shaia@oracle.com>

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
Message-Id: <20190321161832.10533-1-yuval.shaia@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/net/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 7e2c2a6f6a..ffe0872fff 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -2281,7 +2281,7 @@ static void virtio_net_change_num_queues(VirtIONet *n, int new_max_queues)
     /*
      * We always need to remove and add ctrl vq if
      * old_num_queues != new_num_queues. Remove ctrl_vq first,
-     * and then we only enter one of the following too loops.
+     * and then we only enter one of the following two loops.
      */
     virtio_del_queue(vdev, old_num_queues - 1);
 
-- 
MST

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 3/5] virtio-net: Fix typo in comment
  2019-04-05 23:12 ` [Qemu-devel] [PULL 3/5] virtio-net: Fix typo in comment Michael S. Tsirkin
@ 2019-04-05 23:12   ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Jason Wang, Yuval Shaia

From: Yuval Shaia <yuval.shaia@oracle.com>

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
Message-Id: <20190321161832.10533-1-yuval.shaia@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/net/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 7e2c2a6f6a..ffe0872fff 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -2281,7 +2281,7 @@ static void virtio_net_change_num_queues(VirtIONet *n, int new_max_queues)
     /*
      * We always need to remove and add ctrl vq if
      * old_num_queues != new_num_queues. Remove ctrl_vq first,
-     * and then we only enter one of the following too loops.
+     * and then we only enter one of the following two loops.
      */
     virtio_del_queue(vdev, old_num_queues - 1);
 
-- 
MST



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 4/5] intel_iommu: Fix root_scalable migration breakage
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2019-04-05 23:12 ` [Qemu-devel] [PULL 3/5] virtio-net: Fix typo in comment Michael S. Tsirkin
@ 2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12   ` Michael S. Tsirkin
  2019-04-05 23:12 ` [Qemu-devel] [PULL 5/5] intel_iommu: Drop extended root field Michael S. Tsirkin
  2019-04-08  9:49 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Peter Maydell
  6 siblings, 1 reply; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Peter Xu, Yi Sun, Paolo Bonzini, Richard Henderson,
	Eduardo Habkost, Marcel Apfelbaum

From: Peter Xu <peterx@redhat.com>

When introducing the initial support for scalable mode we added a
new field into vmstate however we blindly migrate that field without
notice.  That'll break migration no matter forward or backward.

The normal way should be that we use something like
VMSTATE_UINT32_TEST() or subsections for the new vmstate field however
for this case of vt-d we can even make it simpler because we've
already migrated all the registers and it'll be fairly simple that we
re-generate root_scalable field from the register values during post
load of the device.

Fixes: fb43cf739e ("intel_iommu: scalable mode emulation")
Reviewed-by: Yi Sun <yi.y.sun@linux.intel.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20190329061422.7926-2-peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 146cd16dd2..9318854c51 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -162,6 +162,15 @@ static inline void vtd_iommu_unlock(IntelIOMMUState *s)
     qemu_mutex_unlock(&s->iommu_lock);
 }
 
+static void vtd_update_scalable_state(IntelIOMMUState *s)
+{
+    uint64_t val = vtd_get_quad_raw(s, DMAR_RTADDR_REG);
+
+    if (s->scalable_mode) {
+        s->root_scalable = val & VTD_RTADDR_SMT;
+    }
+}
+
 /* Whether the address space needs to notify new mappings */
 static inline gboolean vtd_as_has_map_notifier(VTDAddressSpace *as)
 {
@@ -1710,11 +1719,10 @@ static void vtd_root_table_setup(IntelIOMMUState *s)
 {
     s->root = vtd_get_quad_raw(s, DMAR_RTADDR_REG);
     s->root_extended = s->root & VTD_RTADDR_RTT;
-    if (s->scalable_mode) {
-        s->root_scalable = s->root & VTD_RTADDR_SMT;
-    }
     s->root &= VTD_RTADDR_ADDR_MASK(s->aw_bits);
 
+    vtd_update_scalable_state(s);
+
     trace_vtd_reg_dmar_root(s->root, s->root_extended);
 }
 
@@ -2945,6 +2953,15 @@ static int vtd_post_load(void *opaque, int version_id)
      */
     vtd_switch_address_space_all(iommu);
 
+    /*
+     * We don't need to migrate the root_scalable because we can
+     * simply do the calculation after the loading is complete.  We
+     * can actually do similar things with root, dmar_enabled, etc.
+     * however since we've had them already so we'd better keep them
+     * for compatibility of migration.
+     */
+    vtd_update_scalable_state(iommu);
+
     return 0;
 }
 
@@ -2966,7 +2983,6 @@ static const VMStateDescription vtd_vmstate = {
         VMSTATE_UINT8_ARRAY(csr, IntelIOMMUState, DMAR_REG_SIZE),
         VMSTATE_UINT8(iq_last_desc_type, IntelIOMMUState),
         VMSTATE_BOOL(root_extended, IntelIOMMUState),
-        VMSTATE_BOOL(root_scalable, IntelIOMMUState),
         VMSTATE_BOOL(dmar_enabled, IntelIOMMUState),
         VMSTATE_BOOL(qi_enabled, IntelIOMMUState),
         VMSTATE_BOOL(intr_enabled, IntelIOMMUState),
-- 
MST

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 4/5] intel_iommu: Fix root_scalable migration breakage
  2019-04-05 23:12 ` [Qemu-devel] [PULL 4/5] intel_iommu: Fix root_scalable migration breakage Michael S. Tsirkin
@ 2019-04-05 23:12   ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Yi Sun, Eduardo Habkost, Peter Xu, Paolo Bonzini,
	Richard Henderson

From: Peter Xu <peterx@redhat.com>

When introducing the initial support for scalable mode we added a
new field into vmstate however we blindly migrate that field without
notice.  That'll break migration no matter forward or backward.

The normal way should be that we use something like
VMSTATE_UINT32_TEST() or subsections for the new vmstate field however
for this case of vt-d we can even make it simpler because we've
already migrated all the registers and it'll be fairly simple that we
re-generate root_scalable field from the register values during post
load of the device.

Fixes: fb43cf739e ("intel_iommu: scalable mode emulation")
Reviewed-by: Yi Sun <yi.y.sun@linux.intel.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20190329061422.7926-2-peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 146cd16dd2..9318854c51 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -162,6 +162,15 @@ static inline void vtd_iommu_unlock(IntelIOMMUState *s)
     qemu_mutex_unlock(&s->iommu_lock);
 }
 
+static void vtd_update_scalable_state(IntelIOMMUState *s)
+{
+    uint64_t val = vtd_get_quad_raw(s, DMAR_RTADDR_REG);
+
+    if (s->scalable_mode) {
+        s->root_scalable = val & VTD_RTADDR_SMT;
+    }
+}
+
 /* Whether the address space needs to notify new mappings */
 static inline gboolean vtd_as_has_map_notifier(VTDAddressSpace *as)
 {
@@ -1710,11 +1719,10 @@ static void vtd_root_table_setup(IntelIOMMUState *s)
 {
     s->root = vtd_get_quad_raw(s, DMAR_RTADDR_REG);
     s->root_extended = s->root & VTD_RTADDR_RTT;
-    if (s->scalable_mode) {
-        s->root_scalable = s->root & VTD_RTADDR_SMT;
-    }
     s->root &= VTD_RTADDR_ADDR_MASK(s->aw_bits);
 
+    vtd_update_scalable_state(s);
+
     trace_vtd_reg_dmar_root(s->root, s->root_extended);
 }
 
@@ -2945,6 +2953,15 @@ static int vtd_post_load(void *opaque, int version_id)
      */
     vtd_switch_address_space_all(iommu);
 
+    /*
+     * We don't need to migrate the root_scalable because we can
+     * simply do the calculation after the loading is complete.  We
+     * can actually do similar things with root, dmar_enabled, etc.
+     * however since we've had them already so we'd better keep them
+     * for compatibility of migration.
+     */
+    vtd_update_scalable_state(iommu);
+
     return 0;
 }
 
@@ -2966,7 +2983,6 @@ static const VMStateDescription vtd_vmstate = {
         VMSTATE_UINT8_ARRAY(csr, IntelIOMMUState, DMAR_REG_SIZE),
         VMSTATE_UINT8(iq_last_desc_type, IntelIOMMUState),
         VMSTATE_BOOL(root_extended, IntelIOMMUState),
-        VMSTATE_BOOL(root_scalable, IntelIOMMUState),
         VMSTATE_BOOL(dmar_enabled, IntelIOMMUState),
         VMSTATE_BOOL(qi_enabled, IntelIOMMUState),
         VMSTATE_BOOL(intr_enabled, IntelIOMMUState),
-- 
MST



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 5/5] intel_iommu: Drop extended root field
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2019-04-05 23:12 ` [Qemu-devel] [PULL 4/5] intel_iommu: Fix root_scalable migration breakage Michael S. Tsirkin
@ 2019-04-05 23:12 ` Michael S. Tsirkin
  2019-04-05 23:12   ` Michael S. Tsirkin
  2019-04-08  9:49 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Peter Maydell
  6 siblings, 1 reply; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Peter Xu, Liu, Yi L, Dr . David Alan Gilbert,
	Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Marcel Apfelbaum

From: Peter Xu <peterx@redhat.com>

VTD_RTADDR_RTT is dropped even by the VT-d spec, so QEMU should
probably do the same thing (after all we never really implemented it).
Since we've had a field for that in the migration stream, to keep
compatibility we need to fill the hole up.

Please refer to VT-d spec 10.4.6.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20190329061422.7926-3-peterx@redhat.com>
Reviewed-by: Liu, Yi L <yi.l.liu@intel.com>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu_internal.h | 1 -
 include/hw/i386/intel_iommu.h  | 1 -
 hw/i386/intel_iommu.c          | 6 ++----
 hw/i386/trace-events           | 2 +-
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
index 1160618177..c1235a7063 100644
--- a/hw/i386/intel_iommu_internal.h
+++ b/hw/i386/intel_iommu_internal.h
@@ -171,7 +171,6 @@
 #define VTD_CCMD_FM(val)            (((val) >> 32) & 3ULL)
 
 /* RTADDR_REG */
-#define VTD_RTADDR_RTT              (1ULL << 11)
 #define VTD_RTADDR_SMT              (1ULL << 10)
 #define VTD_RTADDR_ADDR_MASK(aw)    (VTD_HAW_MASK(aw) ^ 0xfffULL)
 
diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h
index 536f62667b..12f3d266e2 100644
--- a/include/hw/i386/intel_iommu.h
+++ b/include/hw/i386/intel_iommu.h
@@ -234,7 +234,6 @@ struct IntelIOMMUState {
     bool scalable_mode;             /* RO - is Scalable Mode supported? */
 
     dma_addr_t root;                /* Current root table pointer */
-    bool root_extended;             /* Type of root table (extended or not) */
     bool root_scalable;             /* Type of root table (scalable or not) */
     bool dmar_enabled;              /* Set if DMA remapping is enabled */
 
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 9318854c51..2558f48fe6 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -1718,12 +1718,11 @@ error:
 static void vtd_root_table_setup(IntelIOMMUState *s)
 {
     s->root = vtd_get_quad_raw(s, DMAR_RTADDR_REG);
-    s->root_extended = s->root & VTD_RTADDR_RTT;
     s->root &= VTD_RTADDR_ADDR_MASK(s->aw_bits);
 
     vtd_update_scalable_state(s);
 
-    trace_vtd_reg_dmar_root(s->root, s->root_extended);
+    trace_vtd_reg_dmar_root(s->root, s->root_scalable);
 }
 
 static void vtd_iec_notify_all(IntelIOMMUState *s, bool global,
@@ -2982,7 +2981,7 @@ static const VMStateDescription vtd_vmstate = {
         VMSTATE_UINT16(next_frcd_reg, IntelIOMMUState),
         VMSTATE_UINT8_ARRAY(csr, IntelIOMMUState, DMAR_REG_SIZE),
         VMSTATE_UINT8(iq_last_desc_type, IntelIOMMUState),
-        VMSTATE_BOOL(root_extended, IntelIOMMUState),
+        VMSTATE_UNUSED(1),      /* bool root_extended is obsolete by VT-d */
         VMSTATE_BOOL(dmar_enabled, IntelIOMMUState),
         VMSTATE_BOOL(qi_enabled, IntelIOMMUState),
         VMSTATE_BOOL(intr_enabled, IntelIOMMUState),
@@ -3503,7 +3502,6 @@ static void vtd_init(IntelIOMMUState *s)
     memset(s->womask, 0, DMAR_REG_SIZE);
 
     s->root = 0;
-    s->root_extended = false;
     s->root_scalable = false;
     s->dmar_enabled = false;
     s->intr_enabled = false;
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index 83f8369778..c8bc464bc5 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -45,7 +45,7 @@ vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIu16" %d"
 vtd_irq_generate(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0x%"PRIx64
 vtd_reg_read(uint64_t addr, uint64_t size) "addr 0x%"PRIx64" size 0x%"PRIx64
 vtd_reg_write(uint64_t addr, uint64_t size, uint64_t val) "addr 0x%"PRIx64" size 0x%"PRIx64" value 0x%"PRIx64
-vtd_reg_dmar_root(uint64_t addr, bool extended) "addr 0x%"PRIx64" extended %d"
+vtd_reg_dmar_root(uint64_t addr, bool scalable) "addr 0x%"PRIx64" scalable %d"
 vtd_reg_ir_root(uint64_t addr, uint32_t size) "addr 0x%"PRIx64" size 0x%"PRIx32
 vtd_reg_write_gcmd(uint32_t status, uint32_t val) "status 0x%"PRIx32" value 0x%"PRIx32
 vtd_reg_write_fectl(uint32_t value) "value 0x%"PRIx32
-- 
MST

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PULL 5/5] intel_iommu: Drop extended root field
  2019-04-05 23:12 ` [Qemu-devel] [PULL 5/5] intel_iommu: Drop extended root field Michael S. Tsirkin
@ 2019-04-05 23:12   ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2019-04-05 23:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Yi L, Eduardo Habkost, Liu,
	Dr . David Alan Gilbert, Peter Xu, Paolo Bonzini,
	Richard Henderson

From: Peter Xu <peterx@redhat.com>

VTD_RTADDR_RTT is dropped even by the VT-d spec, so QEMU should
probably do the same thing (after all we never really implemented it).
Since we've had a field for that in the migration stream, to keep
compatibility we need to fill the hole up.

Please refer to VT-d spec 10.4.6.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20190329061422.7926-3-peterx@redhat.com>
Reviewed-by: Liu, Yi L <yi.l.liu@intel.com>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu_internal.h | 1 -
 include/hw/i386/intel_iommu.h  | 1 -
 hw/i386/intel_iommu.c          | 6 ++----
 hw/i386/trace-events           | 2 +-
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
index 1160618177..c1235a7063 100644
--- a/hw/i386/intel_iommu_internal.h
+++ b/hw/i386/intel_iommu_internal.h
@@ -171,7 +171,6 @@
 #define VTD_CCMD_FM(val)            (((val) >> 32) & 3ULL)
 
 /* RTADDR_REG */
-#define VTD_RTADDR_RTT              (1ULL << 11)
 #define VTD_RTADDR_SMT              (1ULL << 10)
 #define VTD_RTADDR_ADDR_MASK(aw)    (VTD_HAW_MASK(aw) ^ 0xfffULL)
 
diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h
index 536f62667b..12f3d266e2 100644
--- a/include/hw/i386/intel_iommu.h
+++ b/include/hw/i386/intel_iommu.h
@@ -234,7 +234,6 @@ struct IntelIOMMUState {
     bool scalable_mode;             /* RO - is Scalable Mode supported? */
 
     dma_addr_t root;                /* Current root table pointer */
-    bool root_extended;             /* Type of root table (extended or not) */
     bool root_scalable;             /* Type of root table (scalable or not) */
     bool dmar_enabled;              /* Set if DMA remapping is enabled */
 
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 9318854c51..2558f48fe6 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -1718,12 +1718,11 @@ error:
 static void vtd_root_table_setup(IntelIOMMUState *s)
 {
     s->root = vtd_get_quad_raw(s, DMAR_RTADDR_REG);
-    s->root_extended = s->root & VTD_RTADDR_RTT;
     s->root &= VTD_RTADDR_ADDR_MASK(s->aw_bits);
 
     vtd_update_scalable_state(s);
 
-    trace_vtd_reg_dmar_root(s->root, s->root_extended);
+    trace_vtd_reg_dmar_root(s->root, s->root_scalable);
 }
 
 static void vtd_iec_notify_all(IntelIOMMUState *s, bool global,
@@ -2982,7 +2981,7 @@ static const VMStateDescription vtd_vmstate = {
         VMSTATE_UINT16(next_frcd_reg, IntelIOMMUState),
         VMSTATE_UINT8_ARRAY(csr, IntelIOMMUState, DMAR_REG_SIZE),
         VMSTATE_UINT8(iq_last_desc_type, IntelIOMMUState),
-        VMSTATE_BOOL(root_extended, IntelIOMMUState),
+        VMSTATE_UNUSED(1),      /* bool root_extended is obsolete by VT-d */
         VMSTATE_BOOL(dmar_enabled, IntelIOMMUState),
         VMSTATE_BOOL(qi_enabled, IntelIOMMUState),
         VMSTATE_BOOL(intr_enabled, IntelIOMMUState),
@@ -3503,7 +3502,6 @@ static void vtd_init(IntelIOMMUState *s)
     memset(s->womask, 0, DMAR_REG_SIZE);
 
     s->root = 0;
-    s->root_extended = false;
     s->root_scalable = false;
     s->dmar_enabled = false;
     s->intr_enabled = false;
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index 83f8369778..c8bc464bc5 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -45,7 +45,7 @@ vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIu16" %d"
 vtd_irq_generate(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0x%"PRIx64
 vtd_reg_read(uint64_t addr, uint64_t size) "addr 0x%"PRIx64" size 0x%"PRIx64
 vtd_reg_write(uint64_t addr, uint64_t size, uint64_t val) "addr 0x%"PRIx64" size 0x%"PRIx64" value 0x%"PRIx64
-vtd_reg_dmar_root(uint64_t addr, bool extended) "addr 0x%"PRIx64" extended %d"
+vtd_reg_dmar_root(uint64_t addr, bool scalable) "addr 0x%"PRIx64" scalable %d"
 vtd_reg_ir_root(uint64_t addr, uint32_t size) "addr 0x%"PRIx64" size 0x%"PRIx32
 vtd_reg_write_gcmd(uint32_t status, uint32_t val) "status 0x%"PRIx32" value 0x%"PRIx32
 vtd_reg_write_fectl(uint32_t value) "value 0x%"PRIx32
-- 
MST



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes
  2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
                   ` (5 preceding siblings ...)
  2019-04-05 23:12 ` [Qemu-devel] [PULL 5/5] intel_iommu: Drop extended root field Michael S. Tsirkin
@ 2019-04-08  9:49 ` Peter Maydell
  2019-04-08  9:49   ` Peter Maydell
  6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2019-04-08  9:49 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: QEMU Developers

On Sat, 6 Apr 2019 at 00:12, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> The following changes since commit 436960c95946007aca713330e7a488a6f2e0696f:
>
>   Merge remote-tracking branch 'remotes/berrange/tags/filemon-next-pull-request' into staging (2019-04-02 14:52:17 +0100)
>
> are available in the Git repository at:
>
>   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
>
> for you to fetch changes up to 81fb1e646e4da29f8e1639022241323b956b67e4:
>
>   intel_iommu: Drop extended root field (2019-04-02 11:49:14 -0400)
>
> ----------------------------------------------------------------
> pci, pc, virtio: fixes
>
> intel-iommu fixes
> virtio typo fixes
> linker: a couple of asserts for consistency/security
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.

-- PMM

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes
  2019-04-08  9:49 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Peter Maydell
@ 2019-04-08  9:49   ` Peter Maydell
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Maydell @ 2019-04-08  9:49 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: QEMU Developers

On Sat, 6 Apr 2019 at 00:12, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> The following changes since commit 436960c95946007aca713330e7a488a6f2e0696f:
>
>   Merge remote-tracking branch 'remotes/berrange/tags/filemon-next-pull-request' into staging (2019-04-02 14:52:17 +0100)
>
> are available in the Git repository at:
>
>   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
>
> for you to fetch changes up to 81fb1e646e4da29f8e1639022241323b956b67e4:
>
>   intel_iommu: Drop extended root field (2019-04-02 11:49:14 -0400)
>
> ----------------------------------------------------------------
> pci, pc, virtio: fixes
>
> intel-iommu fixes
> virtio typo fixes
> linker: a couple of asserts for consistency/security
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-04-08  9:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-05 23:12 [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Michael S. Tsirkin
2019-04-05 23:12 ` Michael S. Tsirkin
2019-04-05 23:12 ` [Qemu-devel] [PULL 1/5] acpi: verify file entries in bios_linker_loader_add_pointer() Michael S. Tsirkin
2019-04-05 23:12   ` Michael S. Tsirkin
2019-04-05 23:12 ` [Qemu-devel] [PULL 2/5] intel_iommu: Correct caching-mode error message Michael S. Tsirkin
2019-04-05 23:12   ` Michael S. Tsirkin
2019-04-05 23:12 ` [Qemu-devel] [PULL 3/5] virtio-net: Fix typo in comment Michael S. Tsirkin
2019-04-05 23:12   ` Michael S. Tsirkin
2019-04-05 23:12 ` [Qemu-devel] [PULL 4/5] intel_iommu: Fix root_scalable migration breakage Michael S. Tsirkin
2019-04-05 23:12   ` Michael S. Tsirkin
2019-04-05 23:12 ` [Qemu-devel] [PULL 5/5] intel_iommu: Drop extended root field Michael S. Tsirkin
2019-04-05 23:12   ` Michael S. Tsirkin
2019-04-08  9:49 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio: fixes Peter Maydell
2019-04-08  9:49   ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).