Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3FFDC6FD19 for ; Thu, 16 Mar 2023 12:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjCPMmU (ORCPT ); Thu, 16 Mar 2023 08:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjCPMmT (ORCPT ); Thu, 16 Mar 2023 08:42:19 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77AD9B0B92; Thu, 16 Mar 2023 05:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678970538; x=1710506538; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kBVDCZo5ppkLKXbsECV/EdBkx1cCs/f3fhiyJ7QusD8=; b=mBZVVJ/vAE4BpGhU6oKGeJfisuz6+6OVyIsVdvOMUmrtO3NUh3fG7lHA tzMoxsjrW8N7ICeBQRI5mF5DWtt6eBUsPJuXaprS5zrJH1puASYs40n41 oUviMSOZcjzHz0gvjg9RE9xFY+zRcV5me3ydi5UDAWhpicC7BiZJbUdQl o9qPLnJcC99up8kkxlDkRHUEaznAfjBUPC8JVDm7PPfxRstgN6BoitAPg ctxc6oovydN/ciIZs7ecLDdsOpBL6DiopOT2btkTcLOmGmRhLNR3ohNgV x+H7wNpGa+kwugDK7HQxYYdxFX/0e0C4oJtpwmu7NcjI5gmGP/gdano8/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10650"; a="321811975" X-IronPort-AV: E=Sophos;i="5.98,265,1673942400"; d="scan'208";a="321811975" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 05:41:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10650"; a="1009207801" X-IronPort-AV: E=Sophos;i="5.98,265,1673942400"; d="scan'208";a="1009207801" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by fmsmga005.fm.intel.com with ESMTP; 16 Mar 2023 05:41:57 -0700 From: Yi Liu To: alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com Cc: joro@8bytes.org, robin.murphy@arm.com, cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-s390@vger.kernel.org, xudong.hao@intel.com, yan.y.zhao@intel.com, terrence.xu@intel.com Subject: [PATCH 0/7] Introduce new methods for verifying ownership in vfio PCI hot reset Date: Thu, 16 Mar 2023 05:41:49 -0700 Message-Id: <20230316124156.12064-1-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org VFIO_DEVICE_PCI_HOT_RESET requires user to pass an array of group fds to prove that it owns all devices affected by resetting the calling device. This series introduces several extensions to allow the ownership check better aligned with iommufd and coming vfio device cdev support. First, resetting an unopened device is always safe given nobody is using it. So relax the check to allow such devices not covered by group fd array. [1] When iommufd is used we can simply verify that all affected devices are bound to a same iommufd then no need for the user to provide extra fd information. This is enabled by the user passing a zero-length fd array and moving forward this should be the preferred way for hot reset. [2] However the iommufd method has difficulty working with noiommu devices since those devices don't have a valid iommufd, unless the noiommu device is in a singleton dev_set hence no ownership check is required. [3] For noiommu backward compatibility a 3rd method is introduced by allowing the user to pass an array of device fds to prove ownership. [4] As suggested by Jason [5], we have this series to introduce the above stuffs to the vfio PCI hot reset. [1] https://lore.kernel.org/kvm/Y%2FdobS6gdSkxnPH7@nvidia.com/ [2] https://lore.kernel.org/kvm/Y%2FZOOClu8nXy2toX@nvidia.com/#t [3] https://lore.kernel.org/kvm/ZACX+Np%2FIY7ygqL5@nvidia.com/ [4] https://lore.kernel.org/kvm/DS0PR11MB7529BE88460582BD599DC1F7C3B19@DS0PR11MB7529.namprd11.prod.outlook.com/#t [5] https://lore.kernel.org/kvm/ZAcvzvhkt9QhCmdi@nvidia.com/ Regards, Yi Liu Yi Liu (7): vfio/pci: Update comment around group_fd get in vfio_pci_ioctl_pci_hot_reset() vfio/pci: Only check ownership of opened devices in hot reset vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET vfio/pci: Renaming for accepting device fd in hot reset path vfio: Refine vfio file kAPIs for vfio PCI hot reset vfio: Accpet device file from vfio PCI hot reset path vfio/pci: Accept device fd in VFIO_DEVICE_PCI_HOT_RESET ioctl drivers/iommu/iommufd/device.c | 6 ++ drivers/vfio/group.c | 32 +++---- drivers/vfio/iommufd.c | 8 ++ drivers/vfio/pci/vfio_pci_core.c | 146 ++++++++++++++++++++----------- drivers/vfio/vfio.h | 2 + drivers/vfio/vfio_main.c | 44 ++++++++++ include/linux/iommufd.h | 1 + include/linux/vfio.h | 4 + include/uapi/linux/vfio.h | 18 +++- 9 files changed, 193 insertions(+), 68 deletions(-) -- 2.34.1