From nobody Tue Feb 10 05:27:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501482486292746.1287933155139; Sun, 30 Jul 2017 23:28:06 -0700 (PDT) Received: from localhost ([::1]:57675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc4BE-0006m4-SC for importer@patchew.org; Mon, 31 Jul 2017 02:27:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc49Z-0005tq-Rh for qemu-devel@nongnu.org; Mon, 31 Jul 2017 02:26:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc49W-0007QG-NH for qemu-devel@nongnu.org; Mon, 31 Jul 2017 02:26:09 -0400 Received: from mga01.intel.com ([192.55.52.88]:5627) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dc49W-0007NV-F1 for qemu-devel@nongnu.org; Mon, 31 Jul 2017 02:26:06 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2017 23:26:02 -0700 Received: from yzhang13-kvm.sh.intel.com ([10.239.36.121]) by fmsmga005.fm.intel.com with ESMTP; 30 Jul 2017 23:26:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,440,1496127600"; d="scan'208";a="133271089" From: Yulei Zhang To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 15:58:44 +0800 Message-Id: <1494316727-15518-2-git-send-email-yulei.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494316727-15518-1-git-send-email-yulei.zhang@intel.com> References: <1494316727-15518-1-git-send-email-yulei.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [RFC V2 1/4] vfio: introduce a new VFIO sub region for mdev device migration support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevin.tian@intel.com, joonas.lahtinen@linux.intel.com, zhenyuw@linux.intel.com, Yulei Zhang , alex.williamson@redhat.com, xiao.zheng@intel.com, zhi.a.wang@intel.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" New VFIO sub region VFIO_REGION_SUBTYPE_INTEL_IGD_DEVICE_STATE is added to fetch and restore the status of mdev device vGPU during the live migrati= on. Signed-off-by: Yulei Zhang --- hw/vfio/pci.c | 13 ++++++++++++- hw/vfio/pci.h | 1 + linux-headers/linux/vfio.h | 7 ++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 03a3d01..21a5cef 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -37,6 +37,7 @@ =20 static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); +static VMStateDescription vfio_pci_vmstate; =20 /* * Disabling BAR mmaping can be slow, but toggling it around INTx can @@ -2792,6 +2793,16 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) vfio_vga_quirk_setup(vdev); } =20 + struct vfio_region_info *device_state; + /* device state region setup */ + if (!vfio_get_dev_region_info(&vdev->vbasedev, + VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_INTEL, + VFIO_REGION_SUBTYPE_INTEL_IGD_DEVICE_STATE, &device_state)= ) { + memcpy(&vdev->device_state, device_state, sizeof(struct vfio_region_info)= ); + g_free(device_state); + vfio_pci_vmstate.unmigratable =3D 0; + } + for (i =3D 0; i < PCI_ROM_SLOT; i++) { vfio_bar_quirk_setup(vdev, i); } @@ -2973,7 +2984,7 @@ static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static const VMStateDescription vfio_pci_vmstate =3D { +static VMStateDescription vfio_pci_vmstate =3D { .name =3D "vfio-pci", .unmigratable =3D 1, }; diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index a8366bb..6a1d26e 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -116,6 +116,7 @@ typedef struct VFIOPCIDevice { VFIOBAR bars[PCI_NUM_REGIONS - 1]; /* No ROM */ VFIOVGA *vga; /* 0xa0000, 0x3b0, 0x3c0 */ void *igd_opregion; + struct vfio_region_info device_state; PCIHostDeviceAddress host; EventNotifier err_notifier; EventNotifier req_notifier; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index 531cb2e..e2c53bf 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -294,9 +294,10 @@ struct vfio_region_info_cap_type { #define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff) =20 /* 8086 Vendor sub-types */ -#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1) -#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2) -#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3) +#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1) +#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2) +#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3) +#define VFIO_REGION_SUBTYPE_INTEL_IGD_DEVICE_STATE (4) =20 /** * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9, --=20 2.7.4