qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: nikunj@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com,
	thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC 15/17] ppc: Check that CPU model stays consistent across migration
Date: Wed, 9 Nov 2016 17:40:41 +1100	[thread overview]
Message-ID: <20161109064041.GG427@umbus.fritz.box> (raw)
In-Reply-To: <74024fe8-dde4-07a3-201d-ce6249411ab3@ozlabs.ru>

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

On Wed, Nov 09, 2016 at 05:06:23PM +1100, Alexey Kardashevskiy wrote:
> On 09/11/16 15:24, David Gibson wrote:
> > On Tue, Nov 08, 2016 at 05:03:49PM +1100, Alexey Kardashevskiy wrote:
> >> On 08/11/16 16:29, David Gibson wrote:
> >>> On Fri, Nov 04, 2016 at 06:54:48PM +1100, Alexey Kardashevskiy wrote:
> >>>> On 30/10/16 22:12, David Gibson wrote:
> >>>>> When a vmstate for the ppc cpu was first introduced (a90db15 "target-ppc:
> >>>>> Convert ppc cpu savevm to VMStateDescription"), a VMSTATE_EQUAL was used
> >>>>> to ensure that identical CPU models were used at source and destination
> >>>>> as based on the PVR (Processor Version Register).
> >>>>>
> >>>>> However this was a problem for HV KVM, where due to hardware limitations
> >>>>> we always need to use the real PVR of the host CPU.  So, to allow
> >>>>> migration between hosts with "similar enough" CPUs, the PVR check was
> >>>>> removed in 569be9f0 "target-ppc: Remove PVR check from migration".  This
> >>>>> left the onus on user / management to only attempt migration between
> >>>>> compatible CPUs.
> >>>>>
> >>>>> Now that we've reworked the handling of compatiblity modes, we have the
> >>>>> information to actually determine if we're making a compatible migration.
> >>>>> So this patch partially restores the PVR check.  If the source was running
> >>>>> in a compatibility mode, we just make sure that the destination cpu can
> >>>>> also run in that compatibility mode.  However, if the source was running
> >>>>> in "raw" mode, we verify that the destination has the same PVR value.
> >>>>>
> >>>>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> >>>>> ---
> >>>>>  target-ppc/machine.c | 15 +++++++++++----
> >>>>>  1 file changed, 11 insertions(+), 4 deletions(-)
> >>>>>
> >>>>> diff --git a/target-ppc/machine.c b/target-ppc/machine.c
> >>>>> index 5d87ff6..62b9e94 100644
> >>>>> --- a/target-ppc/machine.c
> >>>>> +++ b/target-ppc/machine.c
> >>>>> @@ -173,10 +173,12 @@ static int cpu_post_load(void *opaque, int version_id)
> >>>>>      target_ulong msr;
> >>>>>  
> >>>>>      /*
> >>>>> -     * We always ignore the source PVR. The user or management
> >>>>> -     * software has to take care of running QEMU in a compatible mode.
> >>>>> +     * If we're operating in compat mode, we should be ok as long as
> >>>>> +     * the destination supports the same compatiblity mode.
> >>>>> +     *
> >>>>> +     * Otherwise, however, we require that the destination has exactly
> >>>>> +     * the same CPU model as the source.
> >>>>>       */
> >>>>> -    env->spr[SPR_PVR] = env->spr_cb[SPR_PVR].default_value;
> >>>>>  
> >>>>>  #if defined(TARGET_PPC64)
> >>>>>      if (cpu->compat_pvr) {
> >>>>> @@ -188,8 +190,13 @@ static int cpu_post_load(void *opaque, int version_id)
> >>>>>              error_free(local_err);
> >>>>>              return -1;
> >>>>>          }
> >>>>> -    }
> >>>>> +    } else
> >>>>>  #endif
> >>>>> +    {
> >>>>> +        if (env->spr[SPR_PVR] != env->spr_cb[SPR_PVR].default_value) {
> >>>>> +            return -1;
> >>>>> +        }
> >>>>> +    }
> >>>>
> >>>> This should break migration from host with PVR=004d0200 to host with
> >>>> PVR=004d0201, what is the benefit of such limitation?
> >>>
> >>> There probably isn't one.  But the point is it also blocks migration
> >>> from a host with PVR=004B0201 (POWER8) to one with PVR=00201400
> >>> (403GCX) and *that* has a clear benefit.  I don't see a way to block
> >>> the second without the first, except by creating a huge compatibility
> >>> matrix table, which would require inordinate amounts of time to
> >>> research carefully.
> >>
> >>
> >> This is pcc->pvr_match() for this purpose.
> > 
> > Hmm.. thinking about this.  Obviously requiring an exactly matching
> > PVR is the architecturally "safest" approach.  For TCG and PR KVM, it
> > really should be sufficient - if you can select "close" PVRs at each
> > end, you should be able to select exactly matching ones just as well.
> > 
> > For HV KVM, we should generally be using compatibility modes to allow
> > migration between a relatively wide range of CPUs.  My intention was
> > basically to require moving to that model, rather than "approximate
> > matching" real PVRs.
> 
> So the management stack (libvirt) will need to know that if it is HV KVM,
> then -cpu host,compat=xxxx; if it is PR KVM, then -cpu XXXX and no compat.
> That was really annoying when we had exact PVR matching.
> 
> 
> > I'm still convinced using compat modes is the right way to go medium
> > to long term.  However, allowing the approximate matches could make
> > for a more forgiving transition, if people have existing hosts in
> > "raw" mode.
> 
> Within the family, CPUs behave exactly (not slightly but exactly) the same
> even though 3 of 4 bytes of the PVR value are different so enforcing PVR to
> match or enforcing compatibility (which as a feature was not a great idea
> from the day one) does not sound compelling.

Ah, ok.  pvr_match sounds reasonable then - I've already implemented
that.

> Does x86 have anything like this compatibility thingy?

It's better thought out on x86.  AIUI compatibility options are set in
the VM control block, so it is under host control even though the
guest is not para-virtualized.  I believe CPUID (unlike mfpvr) *is*
virtualized so the guest simply sees the compatible CPU, not something
else running in a compatibility mode.  So, there's no need for
compatibility modes as such, you just set the CPU to an older one, and
qemu and KVM between them make it appear that way to the guest.

It helps that compatibility is 1 dimensional on x86 - basically
any model can be run to be compatible with any older model.  That's
true for sufficiently recent Power server CPUs, but not across Power
in general.

Actually, I'm not sure where Atom and AMD vs. Intel fit into that
picture, but at any rate, I believe they're closer to 1 dimensional
compatibility than Power / PowerPC is.

> > Ok, I'll add pvr_match checking to this.
> > 
> 
> 




-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

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

  reply	other threads:[~2016-11-09 12:03 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-30 11:11 [Qemu-devel] [RFC 00/17] Clean up compatibility mode handling David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 01/17] ppc: Remove some stub POWER6 models David Gibson
2016-10-31  7:38   ` Thomas Huth
2016-10-31  8:37     ` David Gibson
2016-11-08  3:40   ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 02/17] powernv: CPU compatibility modes don't make sense for powernv David Gibson
2016-10-31  7:46   ` Thomas Huth
2016-10-31  8:38     ` David Gibson
2016-10-31 10:35   ` Greg Kurz
2016-10-30 11:11 ` [Qemu-devel] [RFC 03/17] pseries: Always use core objects for CPU construction David Gibson
2016-11-03  8:11   ` Alexey Kardashevskiy
2016-11-04  9:51     ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-11-08  5:34       ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 04/17] pseries: Make cpu_update during CAS unconditional David Gibson
2016-11-03  8:24   ` Alexey Kardashevskiy
2016-11-04 10:45   ` Thomas Huth
2016-11-08  3:44     ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 05/17] ppc: Clean up and QOMify hypercall emulation David Gibson
2016-11-03  8:50   ` Alexey Kardashevskiy
2016-10-30 11:11 ` [Qemu-devel] [RFC 06/17] ppc: Rename cpu_version to compat_pvr David Gibson
2016-11-04  2:26   ` Alexey Kardashevskiy
2016-11-08  3:48     ` David Gibson
2016-11-04 10:51   ` Thomas Huth
2016-10-30 11:11 ` [Qemu-devel] [RFC 07/17] ppc: Rewrite ppc_set_compat() David Gibson
2016-11-04  2:57   ` Alexey Kardashevskiy
2016-11-08  3:49     ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 08/17] ppc: Rewrite ppc_get_compat_smt_threads() David Gibson
2016-11-04  3:37   ` Alexey Kardashevskiy
2016-11-08  5:13     ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 09/17] ppc: Validate compatibility modes when setting David Gibson
2016-10-31  5:55   ` Alexey Kardashevskiy
2016-10-31  8:39     ` David Gibson
2016-11-04  3:45       ` Alexey Kardashevskiy
2016-11-08  5:14         ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 10/17] pseries: Rewrite CAS PVR compatibility logic David Gibson
2016-10-31  5:00   ` Alexey Kardashevskiy
2016-10-31  5:44     ` David Gibson
2016-11-10 17:54   ` Michael Roth
2016-11-10 23:50     ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 11/17] ppc: Add ppc_set_compat_all() David Gibson
2016-11-04  4:01   ` Alexey Kardashevskiy
2016-11-08  5:18     ` David Gibson
2016-11-09  1:27       ` Alexey Kardashevskiy
2016-11-09  3:52         ` David Gibson
2016-11-09  5:18           ` Alexey Kardashevskiy
2016-11-10  3:13             ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 12/17] ppc: Migrate compatibility mode David Gibson
2016-11-04  5:58   ` Alexey Kardashevskiy
2016-11-08  5:19     ` David Gibson
2016-11-08  5:51       ` Alexey Kardashevskiy
2016-11-10  1:59         ` David Gibson
2016-11-10 23:55           ` Michael Roth
2016-11-14  1:15             ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 13/17] pseries: Move CPU compatibility property to machine David Gibson
2016-11-04  7:43   ` Alexey Kardashevskiy
2016-11-08  5:26     ` David Gibson
2016-11-08  5:56       ` Alexey Kardashevskiy
2016-11-09  4:41         ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 14/17] pseries: Reset CPU compatibility mode David Gibson
2016-11-04  7:50   ` Alexey Kardashevskiy
2016-10-30 11:12 ` [Qemu-devel] [RFC 15/17] ppc: Check that CPU model stays consistent across migration David Gibson
2016-11-04  7:54   ` Alexey Kardashevskiy
2016-11-08  5:29     ` David Gibson
2016-11-08  6:03       ` Alexey Kardashevskiy
2016-11-09  4:24         ` David Gibson
2016-11-09  6:06           ` Alexey Kardashevskiy
2016-11-09  6:40             ` David Gibson [this message]
2016-10-30 11:12 ` [Qemu-devel] [RFC 16/17] ppc: Remove counter-productive "sanity checks" in migration David Gibson
2016-11-04  5:52   ` Alexey Kardashevskiy
2016-11-08  5:31     ` David Gibson
2016-11-11 18:13       ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-11-14  2:34         ` Alexey Kardashevskiy
2016-11-14  6:08           ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 17/17] pseries: Default to POWER8 compatibility mode David Gibson
2016-10-30 11:58   ` David Gibson

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=20161109064041.GG427@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=aik@ozlabs.ru \
    --cc=lvivier@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).