From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn6X0-0003UH-CF for qemu-devel@nongnu.org; Thu, 22 Sep 2016 12:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn6Wz-0004ch-4j for qemu-devel@nongnu.org; Thu, 22 Sep 2016 12:07:26 -0400 Date: Thu, 22 Sep 2016 17:07:18 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20160922160717.GA24720@work-vm> References: <20160922052105.GD7915@in.ibm.com> <1474524441.2857.159.camel@kernel.crashing.org> <20160922061514.GF7915@in.ibm.com> <1474534046.2857.166.camel@kernel.crashing.org> <87d1jw5mr0.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> <1474538671.2857.169.camel@kernel.crashing.org> <8737ks5h1c.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <8737ks5h1c.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] pseries-2.6 migration from QEMU-2.6 to QEMU-2.7 broken List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: Benjamin Herrenschmidt , bharata@linux.vnet.ibm.com, aik@ozlabs.ru, clg@kaod.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au * Nikunj A Dadhania (nikunj@linux.vnet.ibm.com) wrote: > Benjamin Herrenschmidt writes: >=20 > > On Thu, 2016-09-22 at 14:34 +0530, Nikunj A Dadhania wrote: > >> Something like this works for KVM: > >>=20 > >> diff --git a/target-ppc/machine.c b/target-ppc/machine.c > >> index 4820f22..1cf3779 100644 > >> --- a/target-ppc/machine.c > >> +++ b/target-ppc/machine.c > >> @@ -563,8 +563,8 @@ const VMStateDescription vmstate_ppc_cpu =3D { > >> =A0 > >> =A0=A0=A0=A0=A0=A0=A0=A0 /* Sanity checking */ > >> =A0=A0=A0=A0=A0=A0=A0=A0 VMSTATE_UINTTL_EQUAL(env.msr_mask, PowerPCC= PU), > >> -=A0=A0=A0=A0=A0=A0=A0 VMSTATE_UINT64_EQUAL(env.insns_flags, PowerPC= CPU), > >> -=A0=A0=A0=A0=A0=A0=A0 VMSTATE_UINT64_EQUAL(env.insns_flags2, PowerP= CCPU), > >> +=A0=A0=A0=A0=A0=A0=A0 VMSTATE_UNUSED(sizeof(target_ulong)), /* was = _EQUAL(env.insns_flags) */ > >> +=A0=A0=A0=A0=A0=A0=A0 VMSTATE_UNUSED(sizeof(target_ulong)), /* was = _EQUAL(env.insns_flags2) */ > >> =A0=A0=A0=A0=A0=A0=A0=A0 VMSTATE_UINT32_EQUAL(env.nb_BATs, PowerPCCP= U), > >> =A0=A0=A0=A0=A0=A0=A0=A0 VMSTATE_END_OF_LIST() > >> =A0=A0=A0=A0 }, > >>=20 > >> TCG migration still remains broken with this. > > > > Can we have conditionally present flags and a post-load that does som= e > > matching ? >=20 > I think its possible like this: >=20 > diff --git a/target-ppc/machine.c b/target-ppc/machine.c > index 4820f22..dc4704e 100644 > --- a/target-ppc/machine.c > +++ b/target-ppc/machine.c > @@ -528,6 +528,42 @@ static const VMStateDescription vmstate_tlbmas =3D= { > } > }; > =20 > +static bool ppc_kvm_enabled(void *opaque, int version_id) > +{ > + printf("%s: is kvm enabled %d\n", __func__, kvm_enabled()); > + return !kvm_enabled(); > +} > + > +static int get_insns_equal(QEMUFile *f, void *pv, size_t size) > +{ > + uint64_t *v =3D pv; > + uint64_t v2; > + qemu_get_be64s(f, &v2); > + > + printf("%s: \n", __func__); > + > + if (*v =3D=3D v2) { > + return 0; > + } > + printf("Did not match, ignore %" PRIu64 " !=3D %" PRIu64 "\n", *v,= v2); > + return 0; > +} > + > +static void put_insns(QEMUFile *f, void *pv, size_t size) > +{ > + uint64_t *v =3D pv; > + qemu_put_be64s(f, v); > +} > + > +const VMStateInfo vmstate_info_insns_equal =3D { > + .name =3D "insns equal", > + .get =3D get_insns_equal, > + .put =3D put_insns, > +}; > + I'd prefer it if you can avoid adding qemu_get/put's unless really desperate; I'm trying to squash all the read/writing back into standard macros; but I understand it can be tricky. I'd agree that a post_load is the nicest way; it can return an error value. (Oh and ideally use error_report) Dave > +#define VMSTATE_INSNS_EQUAL(_f, _s, _t) = \ > + VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_insns_equal, uint6= 4_t) > + > const VMStateDescription vmstate_ppc_cpu =3D { > .name =3D "cpu", > .version_id =3D 5, > @@ -563,8 +599,8 @@ const VMStateDescription vmstate_ppc_cpu =3D { > =20 > /* Sanity checking */ > VMSTATE_UINTTL_EQUAL(env.msr_mask, PowerPCCPU), > - VMSTATE_UINT64_EQUAL(env.insns_flags, PowerPCCPU), > - VMSTATE_UINT64_EQUAL(env.insns_flags2, PowerPCCPU), > + VMSTATE_INSNS_EQUAL(env.insns_flags, PowerPCCPU, ppc_kvm_enabl= ed), > + VMSTATE_INSNS_EQUAL(env.insns_flags2, PowerPCCPU, ppc_kvm_enab= led), > VMSTATE_UINT32_EQUAL(env.nb_BATs, PowerPCCPU), > VMSTATE_END_OF_LIST() > }, >=20 >=20 > TCG migration succeeds and proceeds ahead. But fails somewhere ahead in > powerpc exception handler: >=20 > [qemu]$ ./ppc64-softmmu/qemu-system-ppc64 -machine pseries-2.6,usb=3Do= ff -vga none -nographic -m 2G ../../imgs/guest.disk -monitor pty --inco= ming tcp:localhost:4444=20 > char device redirected to /dev/pts/5 (label compat_monitor0) > ppc_kvm_enabled: is kvm enabled 0 > get_insns_equal:=20 > Did not match, ignore 9223477658187168481 !=3D 9223477658187151905 > ppc_kvm_enabled: is kvm enabled 0 > get_insns_equal:=20 > Did not match, ignore 331702 !=3D 69558 > Cannot open font file True > Cannot open font file True > qemu: fatal: Trying to deliver HV exception 4 with no HV support >=20 > NIP c0000000000795c8 LR d00000000074407c CTR c000000000079544 XER 000= 0000000000000 CPU#0 > MSR 8000000000009032 HID0 0000000000000000 HF 8000000000000030 iidx 1 = didx 1 > TB 00000007 32202510341 DECR 00596259 >=20 > Regards, > Nikunj >=20 >=20 -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK