qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 698feb: memory: add section range info for IO


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 698feb: memory: add section range info for IOMMU notifier
Date: Fri, 21 Apr 2017 03:34:47 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 698feb5e13a2d763369909ce33f2bd7a7c1c11c0
      
https://github.com/qemu/qemu/commit/698feb5e13a2d763369909ce33f2bd7a7c1c11c0
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/vfio/common.c
    M hw/virtio/vhost.c
    M include/exec/memory.h
    M memory.c

  Log Message:
  -----------
  memory: add section range info for IOMMU notifier

In this patch, IOMMUNotifier.{start|end} are introduced to store section
information for a specific notifier. When notification occurs, we not
only check the notification type (MAP|UNMAP), but also check whether the
notified iova range overlaps with the range of specific IOMMU notifier,
and skip those notifiers if not in the listened range.

When removing an region, we need to make sure we removed the correct
VFIOGuestIOMMU by checking the IOMMUNotifier.start address as well.

This patch is solving the problem that vfio-pci devices receive
duplicated UNMAP notification on x86 platform when vIOMMU is there. The
issue is that x86 IOMMU has a (0, 2^64-1) IOMMU region, which is
splitted by the (0xfee00000, 0xfeefffff) IRQ region. AFAIK
this (splitted IOMMU region) is only happening on x86.

This patch also helps vhost to leverage the new interface as well, so
that vhost won't get duplicated cache flushes. In that sense, it's an
slight performance improvement.

Suggested-by: David Gibson <address@hidden>
Reviewed-by: Eric Auger <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Acked-by: Alex Williamson <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
[ehabkost: included extra vhost_iommu_region_del() change from Peter Xu]
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 512fa40867e6118568756a81ddaf476a0fef0f32
      
https://github.com/qemu/qemu/commit/512fa40867e6118568756a81ddaf476a0fef0f32
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M include/exec/memory.h
    M memory.c

  Log Message:
  -----------
  memory: provide IOMMU_NOTIFIER_FOREACH macro

A new macro is provided to iterate all the IOMMU notifiers hooked
under specific IOMMU memory region.

Reviewed-by: David Gibson <address@hidden>
Reviewed-by: Eric Auger <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: de472e4a92f780d02b894001e004f4b4a350ec38
      
https://github.com/qemu/qemu/commit/de472e4a92f780d02b894001e004f4b4a350ec38
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M include/exec/memory.h
    M memory.c

  Log Message:
  -----------
  memory: provide iommu_replay_all()

This is an "global" version of existing memory_region_iommu_replay() -
we announce the translations to all the registered notifiers, instead of
a specific one.

Reviewed-by: David Gibson <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: bd2bfa4c52e5f4dc6dbaa5be0521aedc31cb53d9
      
https://github.com/qemu/qemu/commit/bd2bfa4c52e5f4dc6dbaa5be0521aedc31cb53d9
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M include/exec/memory.h
    M memory.c

  Log Message:
  -----------
  memory: introduce memory_region_notify_one()

Generalizing the notify logic in memory_region_notify_iommu() into a
single function. This can be further used in customized replay()
functions for IOMMUs.

Reviewed-by: David Gibson <address@hidden>
Reviewed-by: Eric Auger <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: faa362e3cc94bf739a89b457693e3fbd7a4b95c4
      
https://github.com/qemu/qemu/commit/faa362e3cc94bf739a89b457693e3fbd7a4b95c4
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M include/exec/memory.h
    M memory.c

  Log Message:
  -----------
  memory: add MemoryRegionIOMMUOps.replay() callback

Originally we have one memory_region_iommu_replay() function, which is
the default behavior to replay the translations of the whole IOMMU
region. However, on some platform like x86, we may want our own replay
logic for IOMMU regions. This patch adds one more hook for IOMMUOps for
the callback, and it'll override the default if set.

Reviewed-by: David Gibson <address@hidden>
Reviewed-by: Eric Auger <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 10315b9b28c28655ce64500281f4a028d0f8c5ff
      
https://github.com/qemu/qemu/commit/10315b9b28c28655ce64500281f4a028d0f8c5ff
  Author: Jason Wang <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/i386/intel_iommu.c

  Log Message:
  -----------
  intel_iommu: use the correct memory region for device IOTLB notification

We have a specific memory region for DMAR now, so it's wrong to
trigger the notifier with the root region.

Cc: Michael S. Tsirkin <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Richard Henderson <address@hidden>
Cc: Eduardo Habkost <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
Reviewed-by: Peter Xu <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: f06a696dc958dd80f7eaf5be66fdefac77741ee0
      
https://github.com/qemu/qemu/commit/f06a696dc958dd80f7eaf5be66fdefac77741ee0
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/i386/intel_iommu.c
    M hw/i386/trace-events
    M include/exec/memory.h

  Log Message:
  -----------
  intel_iommu: provide its own replay() callback

The default replay() don't work for VT-d since vt-d will have a huge
default memory region which covers address range 0-(2^64-1). This will
normally consumes a lot of time (which looks like a dead loop).

The solution is simple - we don't walk over all the regions. Instead, we
jump over the regions when we found that the page directories are empty.
It'll greatly reduce the time to walk the whole region.

To achieve this, we provided a page walk helper to do that, invoking
corresponding hook function when we found an page we are interested in.
vtd_page_walk_level() is the core logic for the page walking. It's
interface is designed to suite further use case, e.g., to invalidate a
range of addresses.

Reviewed-by: Jason Wang <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 558e0024a428a8f21605dc8aa026612ccc0f14cd
      
https://github.com/qemu/qemu/commit/558e0024a428a8f21605dc8aa026612ccc0f14cd
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/i386/intel_iommu.c
    M hw/i386/trace-events
    M include/hw/i386/intel_iommu.h

  Log Message:
  -----------
  intel_iommu: allow dynamic switch of IOMMU region

This is preparation work to finally enabled dynamic switching ON/OFF for
VT-d protection. The old VT-d codes is using static IOMMU address space,
and that won't satisfy vfio-pci device listeners.

Let me explain.

vfio-pci devices depend on the memory region listener and IOMMU replay
mechanism to make sure the device mapping is coherent with the guest
even if there are domain switches. And there are two kinds of domain
switches:

  (1) switch from domain A -> B
  (2) switch from domain A -> no domain (e.g., turn DMAR off)

Case (1) is handled by the context entry invalidation handling by the
VT-d replay logic. What the replay function should do here is to replay
the existing page mappings in domain B.

However for case (2), we don't want to replay any domain mappings - we
just need the default GPA->HPA mappings (the address_space_memory
mapping). And this patch helps on case (2) to build up the mapping
automatically by leveraging the vfio-pci memory listeners.

Another important thing that this patch does is to seperate
IR (Interrupt Remapping) from DMAR (DMA Remapping). IR region should not
depend on the DMAR region (like before this patch). It should be a
standalone region, and it should be able to be activated without
DMAR (which is a common behavior of Linux kernel - by default it enables
IR while disabled DMAR).

Reviewed-by: Jason Wang <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: dd4d607e40dcd2cb7646b510504880a70939d91b
      
https://github.com/qemu/qemu/commit/dd4d607e40dcd2cb7646b510504880a70939d91b
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/i386/intel_iommu.c
    M hw/i386/intel_iommu_internal.h
    M hw/i386/trace-events
    M include/hw/i386/intel_iommu.h

  Log Message:
  -----------
  intel_iommu: enable remote IOTLB

This patch is based on Aviv Ben-David (<address@hidden>)'s patch
upstream:

  "IOMMU: enable intel_iommu map and unmap notifiers"
  https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg01453.html

However I removed/fixed some content, and added my own codes.

Instead of translate() every page for iotlb invalidations (which is
slower), we walk the pages when needed and notify in a hook function.

This patch enables vfio devices for VT-d emulation.

And, since we already have vhost DMAR support via device-iotlb, a
natural benefit that this patch brings is that vt-d enabled vhost can
live even without ATS capability now. Though more tests are needed.

Signed-off-by: Aviv Ben-David <address@hidden>
Reviewed-by: Jason Wang <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Reviewed-by: \"Michael S. Tsirkin\" <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 36cccb8c575b74a691f685911fbb0301af19f924
      
https://github.com/qemu/qemu/commit/36cccb8c575b74a691f685911fbb0301af19f924
  Author: Eduardo Habkost <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/core/qdev.c

  Log Message:
  -----------
  qdev: Make "hotplugged" property read-only

The "hotplugged" property is user visible, but it was never meant
to be set by the user. There are probably multiple ways to break
or crash device code by overriding the property. For example, we
recently fixed a crash in rtc_set_memory() related to the
property (commit 26ef65beab852caf2b1ef4976e3473f2d525164d).

There has been some discussion about making management software
use "hotplugged=on" on migration, to indicate devices that were
hotplugged in the migration source. There were other suggestions
to address this, like including the "hotplugged" field in the
migration stream instead of requiring it to be set explicitly.

Whatever solution we choose in the future, this patch disables
setting "hotplugged" explicitly in the command-line by now,
because the ability to set the property is unused, untested, and
undocumented.

Signed-off-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 991db247745c1de161d665f847fd28618212f2e8
      
https://github.com/qemu/qemu/commit/991db247745c1de161d665f847fd28618212f2e8
  Author: Thomas Huth <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/core/null-machine.c

  Log Message:
  -----------
  hw/core/null-machine: Print error message when using the -kernel parameter

If the user currently tries to use the -kernel parameter, simply nothing
happens, and the user might get confused that there is nothing loaded
to memory, but also no error message has been issued. Since there is no
real generic way to load a kernel on all CPU types (but on some targets,
the generic loader can be used instead), issue an appropriate error
message here now to avoid the possible confusion.

Signed-off-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Marcel Apfelbaum <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 4728b5741040df8bd02a5ad8fd3c2beefae3dcb1
      
https://github.com/qemu/qemu/commit/4728b5741040df8bd02a5ad8fd3c2beefae3dcb1
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M backends/hostmem.c
    M include/sysemu/hostmem.h

  Log Message:
  -----------
  hostmem: introduce host_memory_backend_mr_inited()

We were checking this against memory region size of host memory
backend's mr field to see whether the mr has been inited. This is
efficient but less elegant. Let's make a helper for it to avoid
confusions, along with some notes.

Suggested-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 6f4c60e47fdb39848eb40804f54e53d8ccaa0f2e
      
https://github.com/qemu/qemu/commit/6f4c60e47fdb39848eb40804f54e53d8ccaa0f2e
  Author: Peter Xu <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M backends/hostmem-file.c
    M backends/hostmem.c

  Log Message:
  -----------
  hostmem: use host_memory_backend_mr_inited() where proper

Use the new interface to boost readability.

Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 606fd0e20600ad0756fdfd2165a105f576ce43a9
      
https://github.com/qemu/qemu/commit/606fd0e20600ad0756fdfd2165a105f576ce43a9
  Author: Krzysztof Kozlowski <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/core/qdev-properties.c
    M include/hw/qdev-properties.h

  Log Message:
  -----------
  qdev: Constify value passed to qdev_prop_set_macaddr

The 'value' argument is not modified so this can be made const for code
safeness.

Signed-off-by: Krzysztof Kozlowski <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: be9721f400f7e5395bb2a257c291557df8f3f833
      
https://github.com/qemu/qemu/commit/be9721f400f7e5395bb2a257c291557df8f3f833
  Author: Krzysztof Kozlowski <address@hidden>
  Date:   2017-04-20 (Thu, 20 Apr 2017)

  Changed paths:
    M hw/core/qdev-properties-system.c

  Log Message:
  -----------
  qdev: Constify local variable returned by blk_bs

Inside qdev_prop_set_drive() the value returned by blk_bs() is passed
only as pointer to const to bdrv_get_node_name() and pointed values is
not modified in other places so this can be made const for code
safeness.

Signed-off-by: Krzysztof Kozlowski <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 7cd37925a17768c0ddef62ffadcb93e9e590d406
      
https://github.com/qemu/qemu/commit/7cd37925a17768c0ddef62ffadcb93e9e590d406
  Author: Peter Maydell <address@hidden>
  Date:   2017-04-21 (Fri, 21 Apr 2017)

  Changed paths:
    M backends/hostmem-file.c
    M backends/hostmem.c
    M hw/core/null-machine.c
    M hw/core/qdev-properties-system.c
    M hw/core/qdev-properties.c
    M hw/core/qdev.c
    M hw/i386/intel_iommu.c
    M hw/i386/intel_iommu_internal.h
    M hw/i386/trace-events
    M hw/vfio/common.c
    M hw/virtio/vhost.c
    M include/exec/memory.h
    M include/hw/i386/intel_iommu.h
    M include/hw/qdev-properties.h
    M include/sysemu/hostmem.h
    M memory.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/ehabkost/tags/machine-pull-request' 
into staging

Machine queue for 2.10

# gpg: Signature made Thu 20 Apr 2017 19:44:27 BST
# gpg:                using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <address@hidden>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/machine-pull-request:
  qdev: Constify local variable returned by blk_bs
  qdev: Constify value passed to qdev_prop_set_macaddr
  hostmem: use host_memory_backend_mr_inited() where proper
  hostmem: introduce host_memory_backend_mr_inited()
  hw/core/null-machine: Print error message when using the -kernel parameter
  qdev: Make "hotplugged" property read-only
  intel_iommu: enable remote IOTLB
  intel_iommu: allow dynamic switch of IOMMU region
  intel_iommu: provide its own replay() callback
  intel_iommu: use the correct memory region for device IOTLB notification
  memory: add MemoryRegionIOMMUOps.replay() callback
  memory: introduce memory_region_notify_one()
  memory: provide iommu_replay_all()
  memory: provide IOMMU_NOTIFIER_FOREACH macro
  memory: add section range info for IOMMU notifier

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/fa54abb8c298...7cd37925a177

reply via email to

[Prev in Thread] Current Thread [Next in Thread]