From: Pavel Fedin <p.fedin@samsung.com>
To: qemu-devel@nongnu.org
Cc: 'Alex Williamson' <alex.williamson@redhat.com>
Subject: [Qemu-devel] [PATCH] vfio: Align iova also to IOMMU page size
Date: Tue, 17 Nov 2015 10:46:44 +0300 [thread overview]
Message-ID: <00fe01d1210c$1be12880$53a37980$@samsung.com> (raw)
On some architectures TARGET_PAGE_ALIGN() is not enough to get the right
alignment. For example on ARM TARGET_PAGE_BITS is 10 because some old CPUs
support 1K page size, while minimum SMMU page size is 4K.
This fixes problems like:
2015-11-17T07:37:42.892265Z qemu-system-aarch64: VFIO_MAP_DMA: -22
2015-11-17T07:37:42.892309Z qemu-system-aarch64: vfio_dma_map(0x223da230, 0x80002f0400, 0x10fc00, 0x7f89b40400) = -22 (Invalid
argument)
qemu: hardware error: vfio: DMA mapping failed, unable to continue
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
hw/vfio/common.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index ff5a89a..328140c 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -326,7 +326,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
- hwaddr iova, end;
+ hwaddr iova, end, iommu_page_size;
Int128 llend;
void *vaddr;
int ret;
@@ -346,6 +346,8 @@ static void vfio_listener_region_add(MemoryListener *listener,
}
iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
+ iommu_page_size = vfio_container_granularity(container);
+ iova = (iova + iommu_page_size - 1) & ~(iommu_page_size - 1);
llend = int128_make64(section->offset_within_address_space);
llend = int128_add(llend, section->size);
llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
@@ -390,8 +392,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
memory_region_register_iommu_notifier(giommu->iommu, &giommu->n);
- memory_region_iommu_replay(giommu->iommu, &giommu->n,
- vfio_container_granularity(container),
+ memory_region_iommu_replay(giommu->iommu, &giommu->n, iommu_page_size,
false);
return;
--
1.9.5.msysgit.0
next reply other threads:[~2015-11-17 7:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 7:46 Pavel Fedin [this message]
2015-11-18 22:04 ` [Qemu-devel] [PATCH] vfio: Align iova also to IOMMU page size Alex Williamson
2015-11-19 10:29 ` Pavel Fedin
2015-11-19 23:33 ` Alex Williamson
2015-11-24 15:24 ` Pavel Fedin
2015-12-02 19:40 ` Alex Williamson
2015-12-03 9:02 ` Pavel Fedin
2015-12-03 16:26 ` Alex Williamson
2015-12-03 16:33 ` Peter Maydell
2015-12-03 17:19 ` Alex Williamson
2015-12-03 17:36 ` Peter Maydell
2015-12-03 17:58 ` Alex Williamson
2015-12-07 10:53 ` Pavel Fedin
2015-12-07 11:20 ` Peter Maydell
2015-12-08 23:42 ` Alex Williamson
2015-12-09 8:08 ` Pavel Fedin
2015-12-09 10:09 ` Alex Bennée
2015-11-24 15:34 ` Peter Maydell
2015-11-25 7:00 ` Pavel Fedin
2015-12-02 19:05 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00fe01d1210c$1be12880$53a37980$@samsung.com' \
--to=p.fedin@samsung.com \
--cc=alex.williamson@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.