All of lore.kernel.org
 help / color / mirror / Atom feed
From: Halil Pasic <pasic@linux.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
	Boris Fiuczynski <fiuczy@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Pierre Morel <pmorel@linux.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	qemu-devel@nongnu.org,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	qemu-s390x@nongnu.org,
	Viktor Mihajlovski <mihajlov@linux.ibm.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v2 1/1] virtio-ccw: auto-manage VIRTIO_F_IOMMU_PLATFORM if PV
Date: Thu, 28 May 2020 19:52:51 +0200	[thread overview]
Message-ID: <20200528195251.3f17a70e.pasic@linux.ibm.com> (raw)
In-Reply-To: <20200528132112.2a1fdf45.cohuck@redhat.com>

On Thu, 28 May 2020 13:21:12 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> 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:
[..]
> > > 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'.
> 

Thank you very much! This makes tinging about 'on/off/auto' much easier.

> > 
> > 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? 

I will whip up a prototype first and then come back to you with more
details.

The short answer is if the user isn't very careful about all the whistles
and bells, I understand that the user will end up with a partially or
fully non-PV-compatible VM.

I had an internal bugreport where there was a nic generated by default
that of course did not have iommu_platform='on'.



> Shouldn't we fence off
> misconfigurations, if the consequences would be disastrous?
> 

I fully agree! This is unfortunately currently not the case. My patch
takes the approach of avoiding miss-configuration in the first place,
instead of sapping the user for it.

> > 
> > >  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?

Janosch has answered these. Will add my thoughts there.

> 
> > 
> > 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?
> 

ditto

[..]
> > > 
> > > 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.)

Sorry, where exactly would you like to have those extra comments?

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

If I have to settle for yes or no, my answer is no.

We need at least one subsystem reset during the conversion. Without
my patch applied things look like this

$ git grep -p -B 5 -e subsystem_reset HEAD~1 -- hw/s390x/s390-virtio-ccw.c
HEAD~1:hw/s390x/s390-virtio-ccw.c=static const char *const reset_dev_types[] = {
--
HEAD~1:hw/s390x/s390-virtio-ccw.c-    "s390-sclp-event-facility",
HEAD~1:hw/s390x/s390-virtio-ccw.c-    "s390-flic",
HEAD~1:hw/s390x/s390-virtio-ccw.c-    "diag288",
HEAD~1:hw/s390x/s390-virtio-ccw.c-};
HEAD~1:hw/s390x/s390-virtio-ccw.c-
HEAD~1:hw/s390x/s390-virtio-ccw.c:static void subsystem_reset(void)
--
HEAD~1:hw/s390x/s390-virtio-ccw.c=static void s390_machine_reset(MachineState *machine)
--
HEAD~1:hw/s390x/s390-virtio-ccw.c-    case S390_RESET_MODIFIED_CLEAR:
HEAD~1:hw/s390x/s390-virtio-ccw.c-        /*
HEAD~1:hw/s390x/s390-virtio-ccw.c-         * Susbsystem reset needs to be done before we unshare memory
HEAD~1:hw/s390x/s390-virtio-ccw.c-         * and lose access to VIRTIO structures in guest memory.
HEAD~1:hw/s390x/s390-virtio-ccw.c-         */
HEAD~1:hw/s390x/s390-virtio-ccw.c:        subsystem_reset();
--
HEAD~1:hw/s390x/s390-virtio-ccw.c-    case S390_RESET_LOAD_NORMAL:
HEAD~1:hw/s390x/s390-virtio-ccw.c-        /*
HEAD~1:hw/s390x/s390-virtio-ccw.c-         * Susbsystem reset needs to be done before we unshare memory
HEAD~1:hw/s390x/s390-virtio-ccw.c-         * and lose access to VIRTIO structures in guest memory.
HEAD~1:hw/s390x/s390-virtio-ccw.c-         */
HEAD~1:hw/s390x/s390-virtio-ccw.c:        subsystem_reset();
--
HEAD~1:hw/s390x/s390-virtio-ccw.c-        }
HEAD~1:hw/s390x/s390-virtio-ccw.c-        run_on_cpu(cs, s390_do_cpu_initial_reset, RUN_ON_CPU_NULL);
HEAD~1:hw/s390x/s390-virtio-ccw.c-        run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
HEAD~1:hw/s390x/s390-virtio-ccw.c-        break;
HEAD~1:hw/s390x/s390-virtio-ccw.c-    case S390_RESET_PV: /* Subcode 10 */
HEAD~1:hw/s390x/s390-virtio-ccw.c:        subsystem_reset();

That is except for 
hw/s390x/s390-virtio-ccw.c-    case S390_RESET_EXTERNAL:
hw/s390x/s390-virtio-ccw.c-    case S390_RESET_REIPL:
hw/s390x/s390-virtio-ccw.c-        if (s390_is_pv()) {
hw/s390x/s390-virtio-ccw.c-            s390_machine_unprotect(ms);
hw/s390x/s390-virtio-ccw.c-        }
hw/s390x/s390-virtio-ccw.c-
hw/s390x/s390-virtio-ccw.c-        qemu_devices_reset();

Which does a qemu_devices_reset(), we already have a subsystem_reset(),
but for the cases with a PV transition this reset happens before mc->pv
is changed, so I can't react properly in the callback. For my purposes
the qemu_devices_reset() is sufficient, but I'm not sure.

The qemu_devices_reset() seems to come form db3b2566e0 ("s390x: machine
reset function with new ipl cpu handling") authored by David and reviewed by
you.

The subsystem reset from 4e872a3fb0 ("s390: provide I/O subsystem
reset") authored by Christian.

From I quick look, I believe what is done by subsystem_reset() should
be a real subset of what is done by qemu_devices_reset().

Maybe the subsystem_reset() can be just moved and the extra
subsystem_reset() calls added by me can be removed. I didn't look into
that, because it would have been wasted effort if the community rejects this
approach.

I hope this answers your questions!

Thanks for having a look!

Regards,
Halil


  parent reply	other threads:[~2020-05-28 17:54 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 22:11 [PATCH v2 1/1] virtio-ccw: auto-manage VIRTIO_F_IOMMU_PLATFORM if PV Halil Pasic
2020-05-20 12:16 ` Halil Pasic
2020-05-20 16:23 ` Michael S. Tsirkin
2020-05-22 21:04   ` Halil Pasic
2020-05-28 11:21     ` Cornelia Huck
2020-05-28 14:42       ` Janosch Frank
2020-05-28 18:49         ` Halil Pasic
2020-05-28 17:52       ` Halil Pasic [this message]
2020-06-05 23:32   ` Halil Pasic
2020-06-08 16:14     ` Cornelia Huck
2020-06-08 17:00       ` Halil Pasic
2020-06-09  6:44         ` Cornelia Huck
2020-06-09  9:41           ` Halil Pasic
2020-06-09 14:02             ` Pierre Morel
2020-06-09 15:47             ` Claudio Imbrenda
2020-06-09 16:05               ` Cornelia Huck
2020-06-09 16:41                 ` Halil Pasic
2020-06-10 13:34                 ` Halil Pasic
2020-06-09 16:28               ` Halil Pasic
2020-06-09 16:44                 ` Michael S. Tsirkin
2020-06-10  4:31                   ` David Gibson
2020-06-10  7:22                     ` David Hildenbrand
2020-06-10 10:07                       ` David Gibson
2020-06-10 10:24                         ` David Hildenbrand
2020-06-10 13:00                           ` Halil Pasic
2020-06-10 13:19                           ` Viktor Mihajlovski
2020-06-10 14:00                             ` David Hildenbrand
2020-06-19  0:36                             ` David Gibson
2020-06-19  0:33                           ` David Gibson
2020-06-10 13:15                   ` Halil Pasic
2020-06-10  4:29                 ` David Gibson
2020-06-10 13:57                   ` Halil Pasic
2020-06-19  0:59                     ` David Gibson
2020-06-09 16:41               ` Michael S. Tsirkin
2020-06-10  4:25           ` David Gibson
2020-06-10 21:37             ` Halil Pasic
2020-06-19  1:01               ` David Gibson
2020-06-08 16:53     ` 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=20200528195251.3f17a70e.pasic@linux.ibm.com \
    --to=pasic@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=fiuczy@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=mihajlov@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=pmorel@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.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 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.