All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: DMA_ALIAS_DEVFN issue
@ 2014-11-15  4:25 ` Bjorn Helgaas
  0 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2014-11-15  4:25 UTC (permalink / raw)
  To: Allan, Bruce W; +Cc: linux-pci, iommu, alex.williamson

[+cc Alex, add a subject]

On Fri, Nov 14, 2014 at 6:49 PM, Allan, Bruce W <bruce.w.allan@intel.com> wrote:
> Let's try this again as plain text...
>
> For a PCIe device with SR-IOV support enabled (e.g. the PF device ID is 0xf001 at 0000:07:00.0 and the 16 VFs have device ID 0xf002 at 0000:07:01.0 through 0000:07:02.7), if the hardware attempts a DMA read/write of memory that was mapped by the PF devfn but instead uses a requester id of one of the VF devfns (enabled but not yet assigned to a VM) it fails and generates log messages similar to:
>
> [  416.800881] dmar: DRHD: handling fault status reg 2
> [  416.800887] dmar: DMAR:[DMA Read] Request device [07:02.2] fault addr ffff0000
> DMAR:[fault reason 02] Present bit in context entry is clear
>
> Shouldn't a DMA alias quirk that sets the PCI_DEV_FLAGS_DMA_ALIAS_DEVFN flag and dma_alias_devfn to the PF devfn for all VF devfns work-around this issue, or am I misunderstanding what a DMA alias quirk is supposed to do?  If a DMA alias quirk cannot resolve this, what is the most appropriate way to handle this?
>
> Thanks,
> Bruce.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: DMA_ALIAS_DEVFN issue
@ 2014-11-15  4:25 ` Bjorn Helgaas
  0 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2014-11-15  4:25 UTC (permalink / raw)
  To: Allan, Bruce W
  Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

[+cc Alex, add a subject]

On Fri, Nov 14, 2014 at 6:49 PM, Allan, Bruce W <bruce.w.allan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> Let's try this again as plain text...
>
> For a PCIe device with SR-IOV support enabled (e.g. the PF device ID is 0xf001 at 0000:07:00.0 and the 16 VFs have device ID 0xf002 at 0000:07:01.0 through 0000:07:02.7), if the hardware attempts a DMA read/write of memory that was mapped by the PF devfn but instead uses a requester id of one of the VF devfns (enabled but not yet assigned to a VM) it fails and generates log messages similar to:
>
> [  416.800881] dmar: DRHD: handling fault status reg 2
> [  416.800887] dmar: DMAR:[DMA Read] Request device [07:02.2] fault addr ffff0000
> DMAR:[fault reason 02] Present bit in context entry is clear
>
> Shouldn't a DMA alias quirk that sets the PCI_DEV_FLAGS_DMA_ALIAS_DEVFN flag and dma_alias_devfn to the PF devfn for all VF devfns work-around this issue, or am I misunderstanding what a DMA alias quirk is supposed to do?  If a DMA alias quirk cannot resolve this, what is the most appropriate way to handle this?
>
> Thanks,
> Bruce.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: DMA_ALIAS_DEVFN issue
  2014-11-15  4:25 ` Bjorn Helgaas
  (?)
@ 2014-11-15 15:23 ` Alex Williamson
  2014-11-15 17:10     ` Allan, Bruce W
  -1 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2014-11-15 15:23 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Allan, Bruce W, linux-pci, iommu

On Fri, 2014-11-14 at 21:25 -0700, Bjorn Helgaas wrote:
> [+cc Alex, add a subject]
> 
> On Fri, Nov 14, 2014 at 6:49 PM, Allan, Bruce W <bruce.w.allan@intel.com> wrote:
> > Let's try this again as plain text...
> >
> > For a PCIe device with SR-IOV support enabled (e.g. the PF device ID
> is 0xf001 at 0000:07:00.0 and the 16 VFs have device ID 0xf002 at
> 0000:07:01.0 through 0000:07:02.7), if the hardware attempts a DMA
> read/write of memory that was mapped by the PF devfn but instead uses
> a requester id of one of the VF devfns (enabled but not yet assigned
> to a VM) it fails and generates log messages similar to:
> >
> > [  416.800881] dmar: DRHD: handling fault status reg 2
> > [  416.800887] dmar: DMAR:[DMA Read] Request device [07:02.2] fault addr ffff0000
> > DMAR:[fault reason 02] Present bit in context entry is clear

This is exactly what IOMMU isolation is meant to do.  A buffer mapped
for one device should not be accessible from another device.  It really
doesn't matter if the devices are related as VF/PF, VF/VF, or PF/PF.

> > Shouldn't a DMA alias quirk that sets the
> PCI_DEV_FLAGS_DMA_ALIAS_DEVFN flag and dma_alias_devfn to the PF devfn
> for all VF devfns work-around this issue, or am I misunderstanding
> what a DMA alias quirk is supposed to do?  If a DMA alias quirk cannot
> resolve this, what is the most appropriate way to handle this?

The buffer needs to be mapped for each VF.  If for some reason the VF
needs implicit access to a PF mapped buffer then this devices is
completely broken from an isolation perspective and using DMA aliases to
fix it means that individual VFs will never be assignable to guests.
Thanks,

Alex


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

* RE: DMA_ALIAS_DEVFN issue
@ 2014-11-15 17:10     ` Allan, Bruce W
  0 siblings, 0 replies; 5+ messages in thread
From: Allan, Bruce W @ 2014-11-15 17:10 UTC (permalink / raw)
  To: Alex Williamson, Bjorn Helgaas; +Cc: linux-pci, iommu

PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBBbGV4IFdpbGxpYW1zb24gW21h
aWx0bzphbGV4LndpbGxpYW1zb25AcmVkaGF0LmNvbV0NCj4gU2VudDogU2F0dXJkYXksIE5vdmVt
YmVyIDE1LCAyMDE0IDc6MjMgQU0NCj4gVG86IEJqb3JuIEhlbGdhYXMNCj4gQ2M6IEFsbGFuLCBC
cnVjZSBXOyBsaW51eC1wY2lAdmdlci5rZXJuZWwub3JnOyBpb21tdUBsaXN0cy5saW51eC0NCj4g
Zm91bmRhdGlvbi5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FwcGVkIGZvciBlYWNoIFZGLiAgSWYgZm9yIHNvbWUgcmVhc29uIHRo
ZSBWRg0KPiBuZWVkcyBpbXBsaWNpdCBhY2Nlc3MgdG8gYSBQRiBtYXBwZWQgYnVmZmVyIHRoZW4g
dGhpcyBkZXZpY2VzIGlzDQo+IGNvbXBsZXRlbHkgYnJva2VuIGZyb20gYW4gaXNvbGF0aW9uIHBl
cnNwZWN0aXZlIGFuZCB1c2luZyBETUEgYWxpYXNlcyB0bw0KPiBmaXggaXQgbWVhbnMgdGhhdCBp
bmRpdmlkdWFsIFZGcyB3aWxsIG5ldmVyIGJlIGFzc2lnbmFibGUgdG8gZ3Vlc3RzLg0KPiBUaGFu
a3MsDQo+IA0KPiBBbGV4DQoNCkhtbSwgdGhhdC4uLmlzIHVuZm9ydHVuYXRlLiAgVGhhbmtzIEFs
ZXggZm9yIHRoZSBjbGFyaWZpY2F0aW9uLCBhbmQgdGhhbmtzIEJqb3JuIGZvcg0KYWRkaW5nIEFs
ZXggYW5kIGEgcHJvcGVyIHN1YmplY3QgdG8gdGhlIHRocmVhZC4NCg0KQnJ1Y2UuDQoNCg==

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

* RE: DMA_ALIAS_DEVFN issue
@ 2014-11-15 17:10     ` Allan, Bruce W
  0 siblings, 0 replies; 5+ messages in thread
From: Allan, Bruce W @ 2014-11-15 17:10 UTC (permalink / raw)
  To: Alex Williamson, Bjorn Helgaas
  Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

> -----Original Message-----
> From: Alex Williamson [mailto:alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org]
> Sent: Saturday, November 15, 2014 7:23 AM
> To: Bjorn Helgaas
> Cc: Allan, Bruce W; linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; iommu-cunTk1MwBs/ROKNJybVBZg@public.gmane.org
> foundation.org
> Subject: Re: DMA_ALIAS_DEVFN issue
> 
> On Fri, 2014-11-14 at 21:25 -0700, Bjorn Helgaas wrote:
> > [+cc Alex, add a subject]
> >
> > On Fri, Nov 14, 2014 at 6:49 PM, Allan, Bruce W <bruce.w.allan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> wrote:
> > > Let's try this again as plain text...
> > >
> > > For a PCIe device with SR-IOV support enabled (e.g. the PF device ID
> > is 0xf001 at 0000:07:00.0 and the 16 VFs have device ID 0xf002 at
> > 0000:07:01.0 through 0000:07:02.7), if the hardware attempts a DMA
> > read/write of memory that was mapped by the PF devfn but instead uses
> > a requester id of one of the VF devfns (enabled but not yet assigned
> > to a VM) it fails and generates log messages similar to:
> > >
> > > [  416.800881] dmar: DRHD: handling fault status reg 2
> > > [  416.800887] dmar: DMAR:[DMA Read] Request device [07:02.2] fault
> addr ffff0000
> > > DMAR:[fault reason 02] Present bit in context entry is clear
> 
> This is exactly what IOMMU isolation is meant to do.  A buffer mapped
> for one device should not be accessible from another device.  It really
> doesn't matter if the devices are related as VF/PF, VF/VF, or PF/PF.
> 
> > > Shouldn't a DMA alias quirk that sets the
> > PCI_DEV_FLAGS_DMA_ALIAS_DEVFN flag and dma_alias_devfn to the PF
> devfn
> > for all VF devfns work-around this issue, or am I misunderstanding
> > what a DMA alias quirk is supposed to do?  If a DMA alias quirk cannot
> > resolve this, what is the most appropriate way to handle this?
> 
> The buffer needs to be mapped for each VF.  If for some reason the VF
> needs implicit access to a PF mapped buffer then this devices is
> completely broken from an isolation perspective and using DMA aliases to
> fix it means that individual VFs will never be assignable to guests.
> Thanks,
> 
> Alex

Hmm, that...is unfortunate.  Thanks Alex for the clarification, and thanks Bjorn for
adding Alex and a proper subject to the thread.

Bruce.

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

end of thread, other threads:[~2014-11-15 17:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15  4:25 DMA_ALIAS_DEVFN issue Bjorn Helgaas
2014-11-15  4:25 ` Bjorn Helgaas
2014-11-15 15:23 ` Alex Williamson
2014-11-15 17:10   ` Allan, Bruce W
2014-11-15 17:10     ` Allan, Bruce W

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.