All of lore.kernel.org
 help / color / mirror / Atom feed
* why is iommu_platform set to off by default?
@ 2021-11-30 14:32 Peter Maydell
  2021-11-30 16:38 ` Stefan Hajnoczi
  2021-11-30 23:44 ` Michael S. Tsirkin
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2021-11-30 14:32 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Eric Auger, Stefan Hajnoczi, Michael S. Tsirkin

I've just spent a day or so trying to track down why PCI passthrough
of a virtio-blk-pci device wasn't working. The problem turns out to be
that by default virtio pci devices don't use the IOMMU, even when the
machine model has created an IOMMU and arranged for the PCI bus to
be underneath it. So when the L2 guest tries to program the virtio device,
the virtio device treats the IPAs it writes as if they were PAs and
of course the data structures it's looking for aren't there.

Why do we default this to 'off'? It seems pretty unhelpful not to
honour the existence of the IOMMU, and the failure mode is pretty
opaque (L2 guest just hangs)...

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why is iommu_platform set to off by default?
  2021-11-30 14:32 why is iommu_platform set to off by default? Peter Maydell
@ 2021-11-30 16:38 ` Stefan Hajnoczi
  2021-12-01  0:00   ` Michael S. Tsirkin
  2021-11-30 23:44 ` Michael S. Tsirkin
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2021-11-30 16:38 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Eric Auger, QEMU Developers, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

On Tue, Nov 30, 2021 at 02:32:49PM +0000, Peter Maydell wrote:
> I've just spent a day or so trying to track down why PCI passthrough
> of a virtio-blk-pci device wasn't working. The problem turns out to be
> that by default virtio pci devices don't use the IOMMU, even when the
> machine model has created an IOMMU and arranged for the PCI bus to
> be underneath it. So when the L2 guest tries to program the virtio device,
> the virtio device treats the IPAs it writes as if they were PAs and
> of course the data structures it's looking for aren't there.
> 
> Why do we default this to 'off'? It seems pretty unhelpful not to
> honour the existence of the IOMMU, and the failure mode is pretty
> opaque (L2 guest just hangs)...

Historically VIRTIO used guest physical addresses instead of bus
addresses (IOVA). I think when IOMMU support was added, a QEMU -device
virtio-* parameter was added and it's simply off by default:

  iommu_platform=<bool>  - on/off (default: false)

Maybe this behavior is for backwards compatibility? Existing guests with
IOMMUs shouldn't change behavior, although this could be fixed with
machine type compat properties.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why is iommu_platform set to off by default?
  2021-11-30 14:32 why is iommu_platform set to off by default? Peter Maydell
  2021-11-30 16:38 ` Stefan Hajnoczi
@ 2021-11-30 23:44 ` Michael S. Tsirkin
  1 sibling, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2021-11-30 23:44 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Eric Auger, QEMU Developers, Stefan Hajnoczi

On Tue, Nov 30, 2021 at 02:32:49PM +0000, Peter Maydell wrote:
> I've just spent a day or so trying to track down why PCI passthrough
> of a virtio-blk-pci device wasn't working. The problem turns out to be
> that by default virtio pci devices don't use the IOMMU, even when the
> machine model has created an IOMMU and arranged for the PCI bus to
> be underneath it. So when the L2 guest tries to program the virtio device,
> the virtio device treats the IPAs it writes as if they were PAs and
> of course the data structures it's looking for aren't there.

Because this is what legacy guests expect, and legacy configs are
much more common than nested.

> Why do we default this to 'off'? It seems pretty unhelpful not to
> honour the existence of the IOMMU, and the failure mode is pretty
> opaque (L2 guest just hangs)...
> 
> thanks
> -- PMM

This should be handled by VFIO in L1 really, it can check for a
device quirk and refuse binding if the feature bit
is disabled.


-- 
MST



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why is iommu_platform set to off by default?
  2021-11-30 16:38 ` Stefan Hajnoczi
@ 2021-12-01  0:00   ` Michael S. Tsirkin
  0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2021-12-01  0:00 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Peter Maydell, QEMU Developers, Eric Auger

On Tue, Nov 30, 2021 at 04:38:11PM +0000, Stefan Hajnoczi wrote:
> On Tue, Nov 30, 2021 at 02:32:49PM +0000, Peter Maydell wrote:
> > I've just spent a day or so trying to track down why PCI passthrough
> > of a virtio-blk-pci device wasn't working. The problem turns out to be
> > that by default virtio pci devices don't use the IOMMU, even when the
> > machine model has created an IOMMU and arranged for the PCI bus to
> > be underneath it. So when the L2 guest tries to program the virtio device,
> > the virtio device treats the IPAs it writes as if they were PAs and
> > of course the data structures it's looking for aren't there.
> > 
> > Why do we default this to 'off'? It seems pretty unhelpful not to
> > honour the existence of the IOMMU, and the failure mode is pretty
> > opaque (L2 guest just hangs)...
> 
> Historically VIRTIO used guest physical addresses instead of bus
> addresses (IOVA). I think when IOMMU support was added, a QEMU -device
> virtio-* parameter was added and it's simply off by default:
> 
>   iommu_platform=<bool>  - on/off (default: false)
> 
> Maybe this behavior is for backwards compatibility? Existing guests with
> IOMMUs shouldn't change behavior, although this could be fixed with
> machine type compat properties.
> 
> Stefan

Unfortunately iommu is special. Bypassing it makes the config
insecure for nested virt, so it's important that we do not
allow guest driver to disable the iommu through the
feature bit.
This means normal compat machinery (make feature on by default
but disable for legacy drivers) does not work here.

-- 
MST



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-01  0:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 14:32 why is iommu_platform set to off by default? Peter Maydell
2021-11-30 16:38 ` Stefan Hajnoczi
2021-12-01  0:00   ` Michael S. Tsirkin
2021-11-30 23:44 ` Michael S. Tsirkin

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.