Re: [PATCH v4 0/4] virtio: Clean up scatterlists and use the DMA API

Benjamin Herrenschmidt
2015-07-28T23:21:34Z

On Tue, 2015-07-28 at 15:43 -0700, Andy Lutomirski wrote:
> Let me try to summarize a proposal:
>
> Add a feature flag that indicates IOMMU support.
>
> New kernels acknowledge that flag on any device that advertises it.
>
> New kernels always respect the IOMMU (except on PowerPC).

Why ? I disagree, the flag should be honored when set in any
architecture. PowerPC is no different than any other platform in that
regard.

> New kernels
> optionally refuse to talk to devices that don't have that feature flag
> if the device appears to be behind an IOMMU. (This presumably
> includes any device whatsoever on an x86 platform with an IOMMU,
> including Xen's fake IOMMU.)
>
> New QEMU always respects the IOMMU, if any, except on PPC.

This is just a matter of what is the default of the flag, ie we
should have a machine flag that indicates what the default is for
new virtio devices, otherwise, it should be specified per device
as an attribute of the device instance.

I would argue that we should default to "bypass IOMMU" on *all*
architecture due to the performance impact, and to essentially
default to the same behaviour as today. With things like DDW even
powerpc might be able to mostly alleviate the performance impact
so we might to change in the long term, but I tend to prefer
more incremental approaches.

> New QEMU
> always advertises this feature flag. If iommu=on, QEMU's virtio
> devices refuse to work unless the driver acknowledges the flag.

This should be configurable.

> On PPC, new QEMU will not respect the IOMMU and will not set the flag.
> New kernels will not talk to devices that set the flag. If someone
> wants to fix that, then they get to figure out how.

I disagree with the kernel bit and I disagree with special casing PPC in
any shape or form in the code. The only difference should be a default
value for the iommu mode of virtio in qemu set per machine.

You can then feel free to change that default (in a separate patch for
bisectability) on x86 for the sake of Xen.

Ben.

> This results in:
>
> New kernels work fine with old QEMU unless iommu=on.
>
> New kernels work with new devices (QEMU and physical devices that set
> the flag) under all circumstances, except on PPC where physical
> devices are and remain broken.
>
> Xen works work new QEMU and cleanly refuses to interoperate with old
> QEMU. (This is worse than with just my patches, but it's better than
> the status quo in which the Xen guest corrupts itself and possibly
> corrupts the Xen hypervisor.)
>
> New kernels with old QEMU with iommu=on optionally refuses to interoperate.
>
> Old kernels are oblivious. They work exactly the same as they do
> today except that they fail cleanly with new QEMU with iommu=on. Old
> kernels continue to fail with physical virtio devices if they're
> behind an iommu.
>
> Old physical virtio devices that don't advertise the flag fail cleanly
> if the host uses an iommu. The driver could optionally whitelist such
> devices.
>
> PPC works as well as it currently does.
>
> I'm unsure about the arm64 situation.
>
>
> Did I get this right?
>
> --Andy