From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4zCA-00045z-Ty for qemu-devel@nongnu.org; Thu, 10 Nov 2016 18:55:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4zC7-0000wi-It for qemu-devel@nongnu.org; Thu, 10 Nov 2016 18:55:50 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51427 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4zC7-0000wU-Df for qemu-devel@nongnu.org; Thu, 10 Nov 2016 18:55:47 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAANrcoq143503 for ; Thu, 10 Nov 2016 18:55:46 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 26n0730a49-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 10 Nov 2016 18:55:46 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Nov 2016 16:55:45 -0700 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <20161110015937.GD18060@umbus.fritz.box> References: <1477825928-10803-1-git-send-email-david@gibson.dropbear.id.au> <1477825928-10803-13-git-send-email-david@gibson.dropbear.id.au> <761e90db-fce0-1533-d5db-e97d188bb949@ozlabs.ru> <20161108051950.GT28688@umbus.fritz.box> <22849a41-ef7c-636a-85ac-a445b04eed68@ozlabs.ru> <20161110015937.GD18060@umbus.fritz.box> Date: Thu, 10 Nov 2016 17:55:36 -0600 Message-Id: <20161110235536.21247.22235@loki> Subject: Re: [Qemu-devel] [RFC 12/17] ppc: Migrate compatibility mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , Alexey Kardashevskiy Cc: nikunj@linux.vnet.ibm.com, thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Quoting David Gibson (2016-11-09 19:59:37) > On Tue, Nov 08, 2016 at 04:51:10PM +1100, Alexey Kardashevskiy wrote: > > On 08/11/16 16:19, David Gibson wrote: > > > On Fri, Nov 04, 2016 at 04:58:47PM +1100, Alexey Kardashevskiy wrote: > > >> On 30/10/16 22:12, David Gibson wrote: > > >>> Server-class POWER CPUs can be put into several compatibility modes= . These > > >>> can be specified on the command line, or negotiated by the guest du= ring > > >>> boot. > > >>> > > >>> Currently we don't migrate the compatibility mode, which means afte= r a > > >>> migration the guest will revert to running with whatever compatibil= ity > > >>> mode (or none) specified on the command line. > > >>> > > >>> With the limited range of CPUs currently used, this doesn't usually= cause > > >>> a problem, but it could. Fix this by adding the compatibility mode= (if > > >>> set) to the migration stream. > > >>> > > >>> Signed-off-by: David Gibson > > >>> --- > > >>> target-ppc/machine.c | 34 ++++++++++++++++++++++++++++++++++ > > >>> 1 file changed, 34 insertions(+) > > >>> > > >>> diff --git a/target-ppc/machine.c b/target-ppc/machine.c > > >>> index 4820f22..5d87ff6 100644 > > >>> --- a/target-ppc/machine.c > > >>> +++ b/target-ppc/machine.c > > >>> @@ -9,6 +9,7 @@ > > >>> #include "mmu-hash64.h" > > >>> #include "migration/cpu.h" > > >>> #include "exec/exec-all.h" > > >>> +#include "qapi/error.h" > > >>> = > > >>> static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) > > >>> { > > >>> @@ -176,6 +177,20 @@ static int cpu_post_load(void *opaque, int ver= sion_id) > > >>> * software has to take care of running QEMU in a compatible m= ode. > > >>> */ > > >>> env->spr[SPR_PVR] =3D env->spr_cb[SPR_PVR].default_value; > > >>> + > > >>> +#if defined(TARGET_PPC64) > > >>> + if (cpu->compat_pvr) { > > >>> + Error *local_err =3D NULL; > > >>> + > > >>> + ppc_set_compat(cpu, cpu->compat_pvr, &local_err); > > >>> + if (local_err) { > > >>> + error_report_err(local_err); > > >>> + error_free(local_err); > > >>> + return -1; > > >>> + } > > >>> + } > > >>> +#endif > > >>> + > > >>> env->lr =3D env->spr[SPR_LR]; > > >>> env->ctr =3D env->spr[SPR_CTR]; > > >>> cpu_write_xer(env, env->spr[SPR_XER]); > > >>> @@ -528,6 +543,24 @@ static const VMStateDescription vmstate_tlbmas= =3D { > > >>> } > > >>> }; > > >>> = > > >>> +static bool compat_needed(void *opaque) > > >>> +{ > > >>> + PowerPCCPU *cpu =3D opaque; > > >>> + > > >>> + return cpu->compat_pvr !=3D 0; > > >> > > >> > > >> Finally got to trying how this affects migration :) > > >> > > >> This breaks migration to QEMU <=3D2.7, and it should not at least wh= en both > > >> source and destination are running with -cpu host,compat=3Dpower7. > > > = > > > IIUC, we don't generally try to maintain backwards migration, even for > > > old machine types. > > = > > = > > I thought the opposite - we generally try to maintain it, this is pretty > > much why we use these subsections in cases like this; otherwise you cou= ld > > just add a new field and bump the vmstate_ppc_cpu.version. > = > Hm, I guess that's true. We do at least try to allow backwards > migration, we just don't insist on it. The example here partially > suceeds - it will allow backwards migration for CPUs in raw mode. What if we changed the condition to cpu->compat_pvr !=3D cpu->max_compat? Assuming each end sets compat=3DpowerX (which seems like a reasonable requirement for migration), it seems like in most cases the guest would end up negotiating max_compat anyway. It's only in cases where it doesn't that = we end up in an ambiguous state. Newer QEMU would guard against this by migrating it's compat_pvr accordingly (which will probably become more important with p9 guests potentially running older kernels), but otherwise it seems like we could maintain backwards migration in most cases. Although with the proposed version bump for vmstate_spapr_pci I guess the discussion is somewhat moot unless we decide we rely want to maintain backward migration... > = > I'll look at just bumping the version instead. > = > > = > > = > > > = > > >> > > >> > > >>> +} > > >>> + > > >>> +static const VMStateDescription vmstate_compat =3D { > > >>> + .name =3D "cpu/compat", > > >>> + .version_id =3D 1, > > >>> + .minimum_version_id =3D 1, > > >>> + .needed =3D compat_needed, > > >>> + .fields =3D (VMStateField[]) { > > >>> + VMSTATE_UINT32(compat_pvr, PowerPCCPU), > > >>> + VMSTATE_END_OF_LIST() > > >>> + } > > >>> +}; > > >>> + > > >>> const VMStateDescription vmstate_ppc_cpu =3D { > > >>> .name =3D "cpu", > > >>> .version_id =3D 5, > > >>> @@ -580,6 +613,7 @@ const VMStateDescription vmstate_ppc_cpu =3D { > > >>> &vmstate_tlb6xx, > > >>> &vmstate_tlbemb, > > >>> &vmstate_tlbmas, > > >>> + &vmstate_compat, > > >>> NULL > > >>> } > > >>> }; > > >>> > > >> > > >> > > > = > > = > > = > = > = > = > = > -- = > David Gibson | I'll have my music baroque, and my code > david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _othe= r_ > | _way_ _around_! > http://www.ozlabs.org/~dgibson