linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Shunsuke Mie <mie@igel.co.jp>,
	linux-pci@vger.kernel.org, virtualization@lists.linux.dev,
	jasowang@redhat.com, xuanzhuo@linux.alibaba.com
Subject: Re: [RFC] Legacy Virtio Driver with Device Has Limited Memory Access
Date: Tue, 18 Jun 2024 06:09:02 -0400	[thread overview]
Message-ID: <20240618060649-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20240614095033.GA59574@thinkpad>

On Fri, Jun 14, 2024 at 03:20:33PM +0530, Manivannan Sadhasivam wrote:
> On Mon, May 20, 2024 at 09:22:54AM -0400, Michael S. Tsirkin wrote:
> > On Thu, May 16, 2024 at 02:59:13PM +0200, Manivannan Sadhasivam wrote:
> > > On Thu, May 16, 2024 at 01:38:40PM +0900, Shunsuke Mie wrote:
> > > > Hi virtio folks,
> > > > 
> > > 
> > > You forgot to CC the actual Virtio folks. I've CCed them now.
> > > 
> > > > I'm writing to discuss finding a workaround with Virtio drivers and legacy
> > > > devices with limited memory access.
> > > > 
> > > > # Background
> > > > The Virtio specification defines a feature (VIRTIO_F_ACCESS_PLATFORM) to
> > > > indicate devices requiring restricted memory access or IOMMU translation. This
> > > > feature bit resides at position 33 in the 64-bit Features register on modern
> > > > interfaces. When the linux virtio driver finds the flag, the driver uses DMA
> > > > API that handles to use of appropriate memory.
> > > > 
> > > > # Problem
> > > > However, legacy devices only have a 32-bit register for the features bits.
> > > > Consequently, these devices cannot represent the ACCESS_PLATFORM bit. As a
> > > > result, legacy devices with restricted memory access cannot function
> > > > properly[1]. This is a legacy spec issue, but I'd like to find a workaround.
> > > > 
> > > > # Proposed Solutions
> > > > I know these are not ideal, but I propose the following solution.
> > > > Driver-side:
> > > >     - Implement special handling similar to xen_domain.
> > > > In xen_domain, linux virtio driver enables to use the DMA API.
> > > >     - Introduce a CONFIG option to adjust the DMA API behavior.
> > > > Device-side:
> > > > Due to indistinguishability from the guest's perspective, a device-side
> > > > solution might be difficult.
> > > > 
> > > > I'm open to any comments or suggestions you may have on this issue or
> > > > alternative approaches.
> > > > 
> > > > [1] virtio-net PCI endpoint function using PCIe Endpoint Framework,
> > > > https://lore.kernel.org/lkml/54ee46c3-c845-3df3-8ba0-0ee79a2acab1@igel.co.jp/t/
> > > > The Linux PCIe endpoint framework is used to implement the virtio-net device on
> > > > a legacy interface. This is necessary because of the framework and hardware
> > > > limitation.
> > > > 
> > > 
> > > We can fix the endpoint framework limitation, but the problem lies with some
> > > platforms where we cannot write to vendor capability registers and still have
> > > IOMMU.
> > > 
> > > - Mani
> > 
> > What are vendor capability registers and what do they have to do
> > with the IOMMU?
> > 
> 
> Virtio spec v1.2, sec 4.1.4 says,
> 
> "Each structure can be mapped by a Base Address register (BAR) belonging to the
> function, or accessed via the special VIRTIO_PCI_CAP_PCI_CFG field in the PCI
> configuration space.
> 
> The location of each structure is specified using a vendor-specific PCI
> capability located on the capability list in PCI configuration space of the
> device."
> 
> So this means the device has to expose the virtio structures through vendor
> specific capability isn't it?

The location of the structures within BAR is specified through
a vendor specific PCI capability, yes.

Why is that a problem?

People have been asking for alternative ways to do that,
so if you can point out what your issue is specifically,
it can be fixable.

> And only in that case, it can expose VIRTIO_F_ACCESS_PLATFORM bit for making
> use of IOMMU translation.
> 
> - Mani

virtio drivers won't even know where to access the features
without the capability.


> -- 
> மணிவண்ணன் சதாசிவம்


  parent reply	other threads:[~2024-06-18 10:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16  4:38 [RFC] Legacy Virtio Driver with Device Has Limited Memory Access Shunsuke Mie
2024-05-16 12:59 ` Manivannan Sadhasivam
2024-05-16 13:13   ` Michael S. Tsirkin
2024-05-20 10:24   ` Shunsuke Mie
2024-05-30 15:07     ` Manivannan Sadhasivam
2024-05-20 13:22   ` Michael S. Tsirkin
2024-06-14  9:50     ` Manivannan Sadhasivam
2024-06-17 23:41       ` Shunsuke Mie
2024-06-18  6:54         ` Manivannan Sadhasivam
2024-06-18  9:47         ` Michael S. Tsirkin
2024-06-18 10:15           ` Shunsuke Mie
2024-06-18 10:33             ` Michael S. Tsirkin
2024-06-18 10:40               ` Shunsuke Mie
2024-06-18 10:47                 ` Michael S. Tsirkin
2024-06-18 12:51                   ` Shunsuke Mie
2024-06-19  7:32                     ` Michael S. Tsirkin
2024-06-19  7:39                       ` Manivannan Sadhasivam
2024-06-19  7:58                         ` Michael S. Tsirkin
2024-06-19  8:28                           ` Manivannan Sadhasivam
2024-06-19  7:07         ` Christoph Hellwig
2024-06-18 10:09       ` Michael S. Tsirkin [this message]
2024-05-30 16:43   ` Michael S. Tsirkin

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=20240618060649-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mie@igel.co.jp \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /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).