From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Lsq-0007BF-Ie for qemu-devel@nongnu.org; Tue, 22 Nov 2016 19:57:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Lsn-0008TS-F5 for qemu-devel@nongnu.org; Tue, 22 Nov 2016 19:57:56 -0500 Date: Wed, 23 Nov 2016 11:17:41 +1100 From: David Gibson Message-ID: <20161123001741.GG28479@umbus.fritz.box> References: <1479706302-2251-1-git-send-email-david@gibson.dropbear.id.au> <1479706302-2251-6-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zGQnqpIoxlsbsOfg" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCHv2 5/5] spapr: Fix 2.7<->2.8 migration of PCI host bridge List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: mdroth@linux.vnet.ibm.com, dgilbert@redhat.com, agraf@suse.de, thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org --zGQnqpIoxlsbsOfg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 22, 2016 at 07:17:27PM +1100, Alexey Kardashevskiy wrote: > On 21/11/16 16:31, David Gibson wrote: > > daa2369 "spapr_pci: Add a 64-bit MMIO window" subtly broke migration > > from qemu-2.7 to the current version. It split the device's MMIO > > window into two pieces for 32-bit and 64-bit MMIO. > >=20 > > The patch included backwards compatibility code to convert the old > > property into the new format. However, the property value was also > > transferred in the migration stream and compared with a (probably > > unwise) VMSTATE_EQUAL. So, the "raw" value from 2.7 is compared to > > the new style converted value from (pre-)2.8 giving a mismatch and > > migration failure. > >=20 > > Along with the actual field that caused the breakage, there are > > several other ill-advised VMSTATE_EQUAL()s. To fix forwards > > migration, we read the values in the stream into scratch variables and > > ignore them, instead of comparing for equality. To fix backwards > > migration, we populate those scratch variables in pre_save() with > > adjusted values to match the old behaviour. > >=20 > > To permit the eventual possibility of removing this cruft from the > > stream, we only include these compatibility fields if a new > > 'pre-2.8-migration' property is set. We clear it on the pseries-2.8 > > machine type, which obviously can't be migrated backwards, but set it > > on earlier machine type versions. > >=20 > > Signed-off-by: David Gibson > > --- > > hw/ppc/spapr.c | 5 +++++ > > hw/ppc/spapr_pci.c | 33 ++++++++++++++++++++++++++++----- > > include/hw/pci-host/spapr.h | 6 ++++++ > > 3 files changed, 39 insertions(+), 5 deletions(-) > >=20 > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > index 775ad2e..c3269c7 100644 > > --- a/hw/ppc/spapr.c > > +++ b/hw/ppc/spapr.c > > @@ -2772,6 +2772,11 @@ DEFINE_SPAPR_MACHINE(2_8, "2.8", true); > > .driver =3D TYPE_POWERPC_CPU, \ > > .property =3D "pre-2.8-migration", \ > > .value =3D "on", \ > > + }, \ > > + { \ > > + .driver =3D TYPE_SPAPR_PCI_HOST_BRIDGE, \ > > + .property =3D "pre-2.8-migration", \ > > + .value =3D "on", \ > > }, > > =20 > > static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index, > > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c > > index e429c94..c62c1cb 100644 > > --- a/hw/ppc/spapr_pci.c > > +++ b/hw/ppc/spapr_pci.c > > @@ -1590,6 +1590,8 @@ static Property spapr_phb_properties[] =3D { > > DEFINE_PROP_UINT64("pgsz", sPAPRPHBState, page_size_mask, > > (1ULL << 12) | (1ULL << 16)), > > DEFINE_PROP_UINT32("numa_node", sPAPRPHBState, numa_node, -1), > > + DEFINE_PROP_BOOL("pre-2.8-migration", sPAPRPHBState, > > + pre_2_8_migration, false), > > DEFINE_PROP_END_OF_LIST(), > > }; > > =20 > > @@ -1636,6 +1638,20 @@ static void spapr_pci_pre_save(void *opaque) > > sphb->msi_devs[i].key =3D *(uint32_t *) key; > > sphb->msi_devs[i].value =3D *(spapr_pci_msi *) value; > > } > > + > > + if (sphb->pre_2_8_migration) { >=20 >=20 > You check for pre_2_8_migration here but you do not in 3/5, what is the > difference? Uh.. where don't I in 3/5? > Also this chunk did not apply on top of dwg/master or qemu.org/master (so= me > whitespace issue? not sure) so I tested dwg/ppc-for-2.8, it works. Yes, the series was based on ppc-for-2.8 >=20 >=20 > Reviewed-by: Alexey Kardashevskiy >=20 >=20 >=20 > > + sphb->mig_liobn =3D sphb->dma_liobn[0]; > > + sphb->mig_mem_win_addr =3D sphb->mem_win_addr; > > + sphb->mig_mem_win_size =3D sphb->mem_win_size; > > + sphb->mig_io_win_addr =3D sphb->io_win_addr; > > + sphb->mig_io_win_size =3D sphb->io_win_size; > > + > > + if ((sphb->mem64_win_size !=3D 0) > > + && (sphb->mem64_win_addr > > + =3D=3D (sphb->mem_win_addr + sphb->mem_win_size))) { > > + sphb->mig_mem_win_size +=3D sphb->mem64_win_size; > > + } > > + } > > } > > =20 > > /* > > @@ -1680,6 +1696,13 @@ static int spapr_pci_post_load(void *opaque, int= version_id) > > return 0; > > } > > =20 > > +static bool pre_2_8_migration(void *opaque, int version_id) > > +{ > > + sPAPRPHBState *sphb =3D opaque; > > + > > + return sphb->pre_2_8_migration; > > +} > > + > > static const VMStateDescription vmstate_spapr_pci =3D { > > .name =3D "spapr_pci", > > .version_id =3D 2, > > @@ -1688,11 +1711,11 @@ static const VMStateDescription vmstate_spapr_p= ci =3D { > > .post_load =3D spapr_pci_post_load, > > .fields =3D (VMStateField[]) { > > VMSTATE_UINT64_EQUAL(buid, sPAPRPHBState), > > - VMSTATE_UINT32_EQUAL(dma_liobn[0], sPAPRPHBState), > > - VMSTATE_UINT64_EQUAL(mem_win_addr, sPAPRPHBState), > > - VMSTATE_UINT64_EQUAL(mem_win_size, sPAPRPHBState), > > - VMSTATE_UINT64_EQUAL(io_win_addr, sPAPRPHBState), > > - VMSTATE_UINT64_EQUAL(io_win_size, sPAPRPHBState), > > + VMSTATE_UINT32_TEST(mig_liobn, sPAPRPHBState, pre_2_8_migratio= n), > > + VMSTATE_UINT64_TEST(mig_mem_win_addr, sPAPRPHBState, pre_2_8_m= igration), > > + VMSTATE_UINT64_TEST(mig_mem_win_size, sPAPRPHBState, pre_2_8_m= igration), > > + VMSTATE_UINT64_TEST(mig_io_win_addr, sPAPRPHBState, pre_2_8_mi= gration), > > + VMSTATE_UINT64_TEST(mig_io_win_size, sPAPRPHBState, pre_2_8_mi= gration), > > VMSTATE_STRUCT_ARRAY(lsi_table, sPAPRPHBState, PCI_NUM_PINS, 0, > > vmstate_spapr_pci_lsi, struct spapr_pci_l= si), > > VMSTATE_INT32(msi_devs_num, sPAPRPHBState), > > diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h > > index b92c1b5..092294e 100644 > > --- a/include/hw/pci-host/spapr.h > > +++ b/include/hw/pci-host/spapr.h > > @@ -79,6 +79,12 @@ struct sPAPRPHBState { > > uint64_t dma64_win_addr; > > =20 > > uint32_t numa_node; > > + > > + /* Fields for migration compatibility hacks */ > > + bool pre_2_8_migration; > > + uint32_t mig_liobn; > > + hwaddr mig_mem_win_addr, mig_mem_win_size; > > + hwaddr mig_io_win_addr, mig_io_win_size; > > }; > > =20 > > #define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL > >=20 >=20 >=20 --=20 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 --zGQnqpIoxlsbsOfg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYNOAiAAoJEGw4ysog2bOSQXEP/3WwJXiuogX5swB1cSwjsV1X JeL4Lpuvyd0uZrVCBEgqFCXD2lEVdW14Zp5Qp5xdWidfSkcpTtZKKIE6I1ibhoH1 B5rcAoI4ixTnLaM5zP0oN+yJuHbTYvafv5I0W4yWirnisRnEe3fChYoVXsTFuEsA HLOGsZP2h9RRM9Blpl53gH1oD+blO77vCBSKzp6pQ18zUPPrCHPJvdhDkPzSYlMf YcQRyeLHYhOK76ZRGLn0Xf2a0oZBDp+tkM+CDji74IqWKBNgHsGAVUmq6y9/T+Lj 6Ah9gB+65oGg7MokvsdRWDrWEcgRLNepYyVfvWnUVZxc/cOiXCwQTNb/IBCAHjLU TQOO59BnQ7/jOB9npXpC149YH8zoRDE8RKHtGaLw1Lwk+9AzxMiFxY+E0leq8wky KMtKvrMZ0Qjn74/E2MOYn/PTnkYgcQwSmMic8mFphA1FjPim+nS8shuAUQoNVYnA DaEUKm1CHo6LQl0uGqMgu7DPqptunEMiY1jb5Z9Qzh1wdwLBQ8juosK8ellKEafq SyJPcdnx9NRUdTCZvMJXvSBSEVZgF6utzkt28uvd3s7UxowIHc+KH9kG8tI2Oycu wEPTy4rlriIXkJOgeTJ9DlqCQZckTk2iMuSi5Wso886ZbNCST+/m4tO8OzIvtwXp mQ/fV5JpZCyNAd5vDAyU =edqC -----END PGP SIGNATURE----- --zGQnqpIoxlsbsOfg--