From: Alex Williamson <alex.williamson@redhat.com>
To: Pavel Fedin <p.fedin@samsung.com>
Cc: 'Peter Maydell' <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vfio: Align iova also to IOMMU page size
Date: Thu, 19 Nov 2015 16:33:57 -0700 [thread overview]
Message-ID: <1447976037.4697.205.camel@redhat.com> (raw)
In-Reply-To: <013101d122b5$240ef500$6c2cdf00$@samsung.com>
On Thu, 2015-11-19 at 13:29 +0300, Pavel Fedin wrote:
> Hello!
>
> > > 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
>
> [skip]
>
> > I don't understand how this is supposed to work, if we align to a larger
> > size than the processor, then there are processor size pages of RAM than
> > could be handed out as DMA targets for devices, but we can't map them
> > through the IOMMU. Thus if the guest tries to use them, we get IOMMU
> > faults in the host and likely memory corruption in the guest because the
> > device can't read or write to the page it's supposed to. This doesn't
> > seem like the right solution.
>
> Well, this was my first try on the problem. I've got your idea. But i guess we should discuss the proper solution then.
> So, i've got this problem on ARM64. On ARM64 we actually can never have 1K pages. This page size was supported only by old 32-bit ARM CPUs, up to ARMv5 IIRC, then it was dropped. Linux OS never even used it.
> But, since qemu can emulate those ancient CPUs, TARGET_PAGE_BITS is defined to 10 for ARM. And, ARM64 and ARM32 is actually the same target for qemu, so this is why we still get it.
> Perhaps, TARGET_PAGE_BITS should be a variable for ARM, and we should set it according to the actual used CPU. Then this IOMMU alignment problem would disappear automatically. What do you think?
> Cc'ed Peter since he is the main ARM guy here.
Do we only see these alignments when we're emulating those old 1k page
processors? If not, should we really be telling a 4k page VM about 1k
aligned memory? If that's all legit, maybe we should be aligning down
rather than up, we know the host memory is at least 4k pages, so
anything in the gap between those alignments should be backed by memory,
right? The device could theoretically get to up to 3k of memory on the
edges of each mapping, but it shouldn't touch it, the memory should be
allocated and part of the VM, could there be anything bad there?
Thanks,
Alex
next prev parent reply other threads:[~2015-11-19 23:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 7:46 [Qemu-devel] [PATCH] vfio: Align iova also to IOMMU page size Pavel Fedin
2015-11-18 22:04 ` Alex Williamson
2015-11-19 10:29 ` Pavel Fedin
2015-11-19 23:33 ` Alex Williamson [this message]
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=1447976037.4697.205.camel@redhat.com \
--to=alex.williamson@redhat.com \
--cc=p.fedin@samsung.com \
--cc=peter.maydell@linaro.org \
--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 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).