From patchwork Mon Jun 10 12:57:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fred Griffoul X-Patchwork-Id: 13691977 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8F90C27C5E for ; Mon, 10 Jun 2024 12:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=xBo598LEGVSSxzOMqKpkbV3uOwa6fmx+wa4U+gHzy04=; b=tCpfS/md6wkqAj SDD6bzRqz40AeRCf9zv52BW1VHEdPLrvV5xsbUvHR3smltSu4DXOYi8k8VNc7IDYNjngJCywswl9T 1/PIo89M+nZl4gtKO/MbewTU5cHM6BEs4pnN2FbtwXWC8vGF1W8Ox8covEx9ni2FjcXVOUR8hEEF1 6DT4TqDG3n+xAGC1Z/fqAHLPEkh5B4eDukXiDikJtiNBpJsopNJA5bIVkkYFQnlAx3kJD3AJFFhPf P7mkSK64Mxj72NiaSRuZNPTMYb8EOtk18BaODDxu9Vg1vHCbfIxqAtbPY07RdjQ7lzlqrWFnT4OMz UX68w7DWsUKHeC9ch8wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGead-000000055bn-0TEO; Mon, 10 Jun 2024 12:57:35 +0000 Received: from smtp-fw-52003.amazon.com ([52.119.213.152]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGeaZ-000000055ai-3lPh for linux-arm-kernel@lists.infradead.org; Mon, 10 Jun 2024 12:57:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.uk; i=@amazon.co.uk; q=dns/txt; s=amazon201209; t=1718024252; x=1749560252; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ib8x6MUsFnm8OLqTHSSQ95s+8p+vISoBQLrMEQteYyg=; b=ko4S20YCL2bFbmzSnxx3UOkKcm/RFBvbaemA9J5WHWDOFNEPGW0JS/xB U8teC7lH7yD9DEW5CTTuHM+2xNh71bX7/EKaz+F3Y8rt9bKf5bxXGcGzy k/O9OPBZisjlyGhsCCxStXvzqPIcQVDkCJVhlv7Qm5mHNZI8E/Os6KRPy Y=; X-IronPort-AV: E=Sophos;i="6.08,227,1712620800"; d="scan'208";a="3967790" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-52003.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 12:57:27 +0000 Received: from EX19MTAEUB001.ant.amazon.com [10.0.10.100:53360] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.26.236:2525] with esmtp (Farcaster) id 9d700111-131b-461d-9914-1613d0d80b56; Mon, 10 Jun 2024 12:57:25 +0000 (UTC) X-Farcaster-Flow-ID: 9d700111-131b-461d-9914-1613d0d80b56 Received: from EX19D007EUA004.ant.amazon.com (10.252.50.76) by EX19MTAEUB001.ant.amazon.com (10.252.51.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 10 Jun 2024 12:57:25 +0000 Received: from EX19MTAUWA001.ant.amazon.com (10.250.64.204) by EX19D007EUA004.ant.amazon.com (10.252.50.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 10 Jun 2024 12:57:24 +0000 Received: from dev-dsk-fgriffo-1c-69b51a13.eu-west-1.amazon.com (10.13.244.152) by mail-relay.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34 via Frontend Transport; Mon, 10 Jun 2024 12:57:20 +0000 From: Fred Griffoul To: CC: Fred Griffoul , Catalin Marinas , Will Deacon , Alex Williamson , Waiman Long , Zefan Li , Tejun Heo , Johannes Weiner , Mark Rutland , Marc Zyngier , Oliver Upton , Mark Brown , Ard Biesheuvel , Joey Gouly , Ryan Roberts , Jeremy Linton , Jason Gunthorpe , Yi Liu , Kevin Tian , Eric Auger , Stefan Hajnoczi , "Christian Brauner" , Ankit Agrawal , "Reinette Chatre" , Ye Bin , , , , Subject: [PATCH v5 0/2] vfio/pci: add msi interrupt affinity support Date: Mon, 10 Jun 2024 12:57:06 +0000 Message-ID: <20240610125713.86750-1-fgriffo@amazon.co.uk> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240610_055732_153552_1AC483F3 X-CRM114-Status: GOOD ( 21.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org v5: - vfio_pci_ioctl_set_irqs(): fix copy_from_user() check when copying the cpumask argument. Reported by Dan Carpenter - vfio_set_irqs_validate_and_prepare(): use size_mul() to compute the data size of a VFIO_IRQ_SET_DATA_EVENTFD ioctl() to avoid a possible overflow on 32-bit system. Reported by Dan Carpenter - export system_32bit_el0_cpumask() to fix yet another missing symbol for arm64 architecture. v4: - export arm64_mismatched_32bit_el0 to compile the vfio driver as a kernel module on arm64 if CONFIG_CPUSETS is not defined. - vfio_pci_ioctl_set_irqs(): free the cpumask_var_t only if data_size is not zero, otherwise it was not allocated. - vfio_pci_set_msi_trigger(): call the new function vfio_pci_set_msi_affinity() later, after the DATA_EVENTFD processing and the vdev index check. v3: - add a first patch to export cpuset_cpus_allowed() to be able to compile the vfio driver as a kernel module. v2: - change the ioctl() interface to use a cpu_set_t in vfio_irq_set 'data' to keep the 'start' and 'count' semantic, as suggested by David Woodhouse v1: The usual way to configure a device interrupt from userland is to write the /proc/irq//smp_affinity or smp_affinity_list files. When using vfio to implement a device driver or a virtual machine monitor, this may not be ideal: the process managing the vfio device interrupts may not be granted root privilege, for security reasons. Thus it cannot directly control the interrupt affinity and has to rely on an external command. This patch extends the VFIO_DEVICE_SET_IRQS ioctl() with a new data flag to specify the affinity of a vfio pci device interrupt. The affinity argument must be a subset of the process cpuset, otherwise an error -EPERM is returned. The vfio_irq_set argument shall be set-up in the following way: - the 'flags' field have the new flag VFIO_IRQ_SET_DATA_AFFINITY set as well as VFIO_IRQ_SET_ACTION_TRIGGER. - the 'start' field is the device interrupt index. Only one interrupt can be configured per ioctl(). - the variable-length array consists of one or more CPU index encoded as __u32, the number of entries in the array is specified in the 'count' field. Fred Griffoul (2): cgroup/cpuset: export cpuset_cpus_allowed() vfio/pci: add msi interrupt affinity support arch/arm64/kernel/cpufeature.c | 2 ++ drivers/vfio/pci/vfio_pci_core.c | 27 +++++++++++++++++---- drivers/vfio/pci/vfio_pci_intrs.c | 39 +++++++++++++++++++++++++++++++ drivers/vfio/vfio_main.c | 13 +++++++---- include/uapi/linux/vfio.h | 10 +++++++- kernel/cgroup/cpuset.c | 1 + 6 files changed, 83 insertions(+), 9 deletions(-) base-commit: cbb325e77fbe62a06184175aa98c9eb98736c3e8 --- 2.40.1