[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 10/18] memory: add section range info for IOM
From: |
Alex Williamson |
Subject: |
Re: [Qemu-devel] [PATCH v6 10/18] memory: add section range info for IOMMU notifier |
Date: |
Fri, 3 Feb 2017 10:22:13 -0700 |
On Fri, 3 Feb 2017 16:22:36 +0800
Peter Xu <address@hidden> wrote:
> 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.
>
> Suggested-by: David Gibson <address@hidden>
> Signed-off-by: Peter Xu <address@hidden>
> ---
> hw/vfio/common.c | 12 +++++++++---
> hw/virtio/vhost.c | 4 ++--
> include/exec/memory.h | 19 ++++++++++++++++++-
> memory.c | 9 +++++++++
> 4 files changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index f3ba9b9..6b33b9f 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -478,8 +478,13 @@ static void vfio_listener_region_add(MemoryListener
> *listener,
> giommu->iommu_offset = section->offset_within_address_space -
> section->offset_within_region;
> giommu->container = container;
> - giommu->n.notify = vfio_iommu_map_notify;
> - giommu->n.notifier_flags = IOMMU_NOTIFIER_ALL;
> + llend = int128_add(int128_make64(section->offset_within_region),
> + section->size);
> + llend = int128_sub(llend, int128_one());
> + iommu_notifier_init(&giommu->n, vfio_iommu_map_notify,
> + IOMMU_NOTIFIER_ALL,
> + section->offset_within_region,
> + int128_get64(llend));
> QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
>
> memory_region_register_iommu_notifier(giommu->iommu, &giommu->n);
> @@ -550,7 +555,8 @@ static void vfio_listener_region_del(MemoryListener
> *listener,
> VFIOGuestIOMMU *giommu;
>
> QLIST_FOREACH(giommu, &container->giommu_list, giommu_next) {
> - if (giommu->iommu == section->mr) {
> + if (giommu->iommu == section->mr &&
> + giommu->n.start == section->offset_within_region) {
> memory_region_unregister_iommu_notifier(giommu->iommu,
> &giommu->n);
> QLIST_REMOVE(giommu, giommu_next);
Acked-by: Alex Williamson <address@hidden>
- Re: [Qemu-devel] [PATCH v6 07/18] intel_iommu: fix trace for inv desc handling, (continued)
[Qemu-devel] [PATCH v6 08/18] intel_iommu: fix trace for addr translation, Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 09/18] intel_iommu: vtd_slpt_level_shift check level, Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 10/18] memory: add section range info for IOMMU notifier, Peter Xu, 2017/02/03
- Re: [Qemu-devel] [PATCH v6 10/18] memory: add section range info for IOMMU notifier,
Alex Williamson <=
[Qemu-devel] [PATCH v6 11/18] memory: provide IOMMU_NOTIFIER_FOREACH macro, Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 12/18] memory: provide iommu_replay_all(), Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 13/18] memory: introduce memory_region_notify_one(), Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 14/18] memory: add MemoryRegionIOMMUOps.replay() callback, Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 15/18] intel_iommu: provide its own replay() callback, Peter Xu, 2017/02/03
[Qemu-devel] [PATCH v6 16/18] intel_iommu: do replay when context invalidate, Peter Xu, 2017/02/03