qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/1] virtio-ccw: auto-manage VIRTIO_F_IOMMU_PLATFORM if PV


From: Cornelia Huck
Subject: Re: [PATCH v2 1/1] virtio-ccw: auto-manage VIRTIO_F_IOMMU_PLATFORM if PV
Date: Thu, 28 May 2020 13:21:12 +0200

On Fri, 22 May 2020 23:04:51 +0200
Halil Pasic <pasic@linux.ibm.com> wrote:

> On Wed, 20 May 2020 12:23:24 -0400
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Fri, May 15, 2020 at 12:11:55AM +0200, Halil Pasic wrote:  
> > > The virtio specification tells that the device is to present
> > > VIRTIO_F_ACCESS_PLATFORM (a.k.a. VIRTIO_F_IOMMU_PLATFORM) when the
> > > device "can only access certain memory addresses with said access
> > > specified and/or granted by the platform". This is the case for a
> > > protected VMs, as the device can access only memory addresses that are
> > > in pages that are currently shared (only the guest can share/unsare its
> > > pages).
> > > 
> > > No VM, however, starts out as a protected VM, but some VMs may be
> > > converted to protected VMs if the guest decides so.
> > > 
> > > Making the end user explicitly manage the VIRTIO_F_ACCESS_PLATFORM via
> > > the property iommu_on is a minor disaster. Since the correctness of the
> > > paravirtualized virtio devices depends (and thus in a sense the
> > > correctness of the hypervisor) it, then the hypervisor should have the
> > > last word about whether VIRTIO_F_ACCESS_PLATFORM is to be presented or
> > > not.  
> > 
> > So, how about this: switch iommu to on/off/auto.  
> 
> Many thanks for the reveiw, and sorry about the delay on my side. We
> have holidays here in Germany and I was not motivated enough up until
> now to check on my mails.
> 
> 
> I've actually played  with the thought of switching iommu_platform to 
> 'on/off/auto', but I didn't find an easy way to do it. I will look
> again. This would be the first property of this kind in QEMU, or?

virtio-pci uses it for 'disable-legacy'.

> 
> The 'on/off/auto' would be certainly much cleaner form user-interface
> perspective. The downsides are that it is more invasive, and more
> complicated. I'm afraid that it would also leave more possibilities for
> user error.

To me, on/off/auto sounds like a reasonable thing to do.

What possibilities of 'user error' do you see? Shouldn't we fence off
misconfigurations, if the consequences would be disastrous?

> 
> >  Add a property with a
> > reasonable name "allow protected"?  If set allow switch to protected
> > memory and also set iommu auto to on by default.  If not set then don't.
> >  
> 
> I think we have "allow protected" already expressed via cpu models. I'm
> also not sure how libvirt would react to the idea of a new machine
> property for this. You did mean "allow protected" as machine property,
> or?

"Unpack facility in cpu model" means "guest may transition into pv
mode", right? What does it look like when the guest actually has
transitioned?

> 
> AFAIU "allow protected" would be required for the !PV to PV switch, and
> we would have to reject paravirtualized devices with iommu_platform='off'
> on VM construction or hotplug (iommu_platform='auto/on' would be fine).
> 
> Could you please confirm that I understood this correctly?
> 
> 
> > This will come handy for other things like migrating to hosts without
> > protected memory support.
> >   
> 
> This is already covered by cpu model AFAIK.

I don't think we'd want to migrate between pv and non-pv anyway?

> 
> > 
> > Also, virtio now calls this PLATFORM_ACCESS, maybe we should rename
> > the property (keeping old one around for compat)?  
> 
> You mean the like rename 'iommu_platform' to 'platform_access'? I like
> the idea, but I'm not sure libvirt will like it as well. Boris any
> opinions?
> 
> > I feel this will address lots of complaints ...
> >   
> > > Currently presenting a PV guest with a (paravirtualized) virtio-ccw
> > > device has catastrophic consequences for the VM (after the hypervisors
> > > access to protected memory). This is especially grave in case of device
> > > hotplug (because in this case the guest is more likely to be in the
> > > middle of something important).
> > > 
> > > Let us manage the VIRTIO_F_ACCESS_PLATFORM virtio feature automatically
> > > for virtio-ccw devices, i.e. force it before we start the protected VM.
> > > If the VM should cease to be protected, the original value is restored.
> > > 
> > > Signed-off-by: Halil Pasic <pasic@linux.ibm.com>  
> > 
> > 
> > I don't really understand things fully but it looks like you are
> > changing features of a device.  If so this bothers me, resets
> > happen at random times while driver is active, and we never
> > expect features to change.
> >  
> 
> Changing the device features is IMHO all right because the features can
> change only immediately after a system reset and before the first vCPU
> is run. That is ensured by two facts.
> 
> 
> First, the feature can only change when ms->pv changes. That is on the
> first reset after the VM entered or left the "protected virtualization"
> mode of operation. And that switch requires a system reset. Because the
> PV switch is initiated by the guest, and the guest is rebooted as a
> consequence, the guest will never observe the change in features.

This really needs more comments, as it is not obvious to the casual
reader. (I also stumbled over the resets.)

But I wonder whether we are actually missing those subsystems resets
today?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]