From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaKWk-0007YK-VZ for qemu-devel@nongnu.org; Mon, 29 Feb 2016 04:54:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aaKWi-0006Le-37 for qemu-devel@nongnu.org; Mon, 29 Feb 2016 04:54:06 -0500 From: Gerd Hoffmann Date: Mon, 29 Feb 2016 10:53:58 +0100 Message-Id: <1456739638-20903-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1456739638-20903-1-git-send-email-kraxel@redhat.com> References: <1456739638-20903-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 1/1] fw_cfg: unbreak migration compatibility for 2.4 and earlier machines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc=20Mar=C3=AD?= , Laszlo Ersek , Gerd Hoffmann , Alexandre DERUMIER , qemu-stable@nongnu.org From: Laszlo Ersek When I reviewed Marc's fw_cfg DMA patches, I completely missed that the way we set dma_enabled would break migration. Gerd explained the right way (see reference below): dma_enabled should be set to true by default, and only true->false transitions should be possible: - when the user requests that with -global fw_cfg_mem.dma_enabled=3Doff or -global fw_cfg_io.dma_enabled=3Doff as appropriate for the platform, - when HW_COMPAT_2_4 dictates it, - when board code initializes fw_cfg without requesting DMA support. Cc: Marc Mar=C3=AD Cc: Gerd Hoffmann Cc: Alexandre DERUMIER Cc: qemu-stable@nongnu.org Ref: http://thread.gmane.org/gmane.comp.emulators.qemu/390272/focus=3D391= 042 Ref: https://bugs.launchpad.net/qemu/+bug/1536487 Suggested-by: Gerd Hoffmann Signed-off-by: Laszlo Ersek Message-id: 1455823860-22268-1-git-send-email-lersek@redhat.com Signed-off-by: Gerd Hoffmann --- hw/nvram/fw_cfg.c | 20 ++++++++++++-------- include/hw/compat.h | 8 ++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 79c5742..f3acb47 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -778,17 +778,19 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uin= t32_t dma_iobase, DeviceState *dev; FWCfgState *s; uint32_t version =3D FW_CFG_VERSION; - bool dma_enabled =3D dma_iobase && dma_as; + bool dma_requested =3D dma_iobase && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_IO); qdev_prop_set_uint32(dev, "iobase", iobase); qdev_prop_set_uint32(dev, "dma_iobase", dma_iobase); - qdev_prop_set_bit(dev, "dma_enabled", dma_enabled); + if (!dma_requested) { + qdev_prop_set_bit(dev, "dma_enabled", false); + } =20 fw_cfg_init1(dev); s =3D FW_CFG(dev); =20 - if (dma_enabled) { + if (s->dma_enabled) { /* 64 bits for the address field */ s->dma_as =3D dma_as; s->dma_addr =3D 0; @@ -814,11 +816,13 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, SysBusDevice *sbd; FWCfgState *s; uint32_t version =3D FW_CFG_VERSION; - bool dma_enabled =3D dma_addr && dma_as; + bool dma_requested =3D dma_addr && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_MEM); qdev_prop_set_uint32(dev, "data_width", data_width); - qdev_prop_set_bit(dev, "dma_enabled", dma_enabled); + if (!dma_requested) { + qdev_prop_set_bit(dev, "dma_enabled", false); + } =20 fw_cfg_init1(dev); =20 @@ -828,7 +832,7 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, =20 s =3D FW_CFG(dev); =20 - if (dma_enabled) { + if (s->dma_enabled) { s->dma_as =3D dma_as; s->dma_addr =3D 0; sysbus_mmio_map(sbd, 2, dma_addr); @@ -873,7 +877,7 @@ static Property fw_cfg_io_properties[] =3D { DEFINE_PROP_UINT32("iobase", FWCfgIoState, iobase, -1), DEFINE_PROP_UINT32("dma_iobase", FWCfgIoState, dma_iobase, -1), DEFINE_PROP_BOOL("dma_enabled", FWCfgIoState, parent_obj.dma_enabled= , - false), + true), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -913,7 +917,7 @@ static const TypeInfo fw_cfg_io_info =3D { static Property fw_cfg_mem_properties[] =3D { DEFINE_PROP_UINT32("data_width", FWCfgMemState, data_width, -1), DEFINE_PROP_BOOL("dma_enabled", FWCfgMemState, parent_obj.dma_enable= d, - false), + true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/compat.h b/include/hw/compat.h index 2ebe739..a5dbbf8 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -42,6 +42,14 @@ .driver =3D "virtio-pci",\ .property =3D "migrate-extra",\ .value =3D "off",\ + },{\ + .driver =3D "fw_cfg_mem",\ + .property =3D "dma_enabled",\ + .value =3D "off",\ + },{\ + .driver =3D "fw_cfg_io",\ + .property =3D "dma_enabled",\ + .value =3D "off",\ }, =20 #define HW_COMPAT_2_3 \ --=20 1.8.3.1