Received: from eggs.gnu.org ([2001:4830:134:3::10]:42998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2ZL0-0003nG-SN for qemu-devel@nongnu.org; Fri, 04 Nov 2016 03:54:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2ZKx-0002av-Qk for qemu-devel@nongnu.org; Fri, 04 Nov 2016 03:54:58 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2ZKx-0002ZG-I6 for qemu-devel@nongnu.org; Fri, 04 Nov 2016 03:54:55 -0400 Received: by mail-pf0-x242.google.com with SMTP id i88so7172549pfk.2 for ; Fri, 04 Nov 2016 00:54:55 -0700 (PDT) References: <1477825928-10803-1-git-send-email-david@gibson.dropbear.id.au> <1477825928-10803-16-git-send-email-david@gibson.dropbear.id.au> From: Alexey Kardashevskiy Message-ID: Date: Fri, 4 Nov 2016 18:54:48 +1100 MIME-Version: 1.0 In-Reply-To: <1477825928-10803-16-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 15/17] ppc: Check that CPU model stays consistent across migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , nikunj@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com Cc: thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org 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 > --- > 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? > > env->lr = env->spr[SPR_LR]; > env->ctr = env->spr[SPR_CTR]; > -- Alexey