From: Will Deacon <will.deacon@arm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio_pci: Limit DMA mask to 44 bits for legacy virtio devices
Date: Mon, 12 Sep 2016 16:57:27 +0100 [thread overview]
Message-ID: <20160912155727.GD4792@arm.com> (raw)
In-Reply-To: <20160912182203-mutt-send-email-mst@kernel.org>
On Mon, Sep 12, 2016 at 06:33:43PM +0300, Michael S. Tsirkin wrote:
> On Mon, Sep 12, 2016 at 01:10:41PM +0100, Will Deacon wrote:
> > Legacy virtio defines the virtqueue base using a 32-bit PFN field, with
> > a read-only register indicating a fixed page size of 4k.
> >
> > This can cause problems for DMA allocators that allocate top down from
> > the DMA mask, which is set to 64 bits. In this case, the addresses are
> > silently truncated to 44-bit, leading to IOMMU faults, failure to read
> > from the queue or data corruption.
> >
> > This patch restricts the DMA mask for legacy PCI virtio devices to
> > 44 bits, which matches the specification.
> >
> > Cc: Andy Lutomirski <luto@kernel.org>
> > Cc: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
>
> Hmm - IIUC it's actually only the case for the virtio rings
> themselves. The buffer addresses put in the rings are full 64 bit ones.
I think that's right, yes.
> It so happens that virtio doesn't use coherent allocs except
> for the rings.
> So I'm inclined to say the coherent mask should be set to 44,
> with a comment explaning that this is for the rings.
I can certainly add that in v2, along with your suggestion to use
32 + VIRTIO_PCI_QUEUE_ADDR_SHIFT instead of the 44.
> In case we start using coherent allocations in virtio,
> it might be cleaner to relax the mask after allocating
> the rings, but I'm not sure that's allowed by the DMA API.
> thoughts?
Hmm, that *might* work, but I could certainly imagine some DMA
implementations going wrong if they assume the mask is fixed.
Will
next prev parent reply other threads:[~2016-09-12 15:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-12 12:10 [PATCH] virtio_pci: Limit DMA mask to 44 bits for legacy virtio devices Will Deacon
2016-09-12 15:33 ` Michael S. Tsirkin
2016-09-12 15:57 ` Will Deacon [this message]
2016-09-13 6:11 ` Benjamin Serebrin
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=20160912155727.GD4792@arm.com \
--to=will.deacon@arm.com \
--cc=kvm@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.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