Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1246192lqt; Fri, 7 Jun 2024 12:10:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaovOyPiRiu/wwit0V0G93eRpuknmthZUY2SJIoHi04NWbIu5U8oMPP1HqZPX1mGIF3WEPgqYMwSjsc3CL4FKBPMRWPGiykasdtd44rQ== X-Google-Smtp-Source: AGHT+IEJh+/VBmeL9f6UDE7YZH1L8WgIK6/KXsXMk/NEv2ce+9NkvSDe6FXJqEAidtURqpMSM0B1 X-Received: by 2002:a05:6830:411a:b0:6f9:41a3:ee47 with SMTP id 46e09a7af769-6f95731dac7mr4223924a34.36.1717787425159; Fri, 07 Jun 2024 12:10:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717787425; cv=pass; d=google.com; s=arc-20160816; b=fQ8Gw2zn+dVyd8epK8yJQSfMTERvR6cEHQcMIf3FEeQsedNN9pC6L7HsJsFBAeg3u5 ZAAnej7NZzmXgZMnqRHdFQ0l7SQ8yyQ+MkVXRE3o34+QinJNo3oatJfvvr1C6rXrVR7a wStWvOhEZCCQSXg5riaCYMJNLC8JFiPCrCxQokbx9NdUsbwGT2imlX97dyEwIZiBkfcB BGADeHx9I4pH3JtTRK+FXZzRSDyVjLGA9bfkxbF90frTtGM/wYjOfXh94Croutbs0ycA mh7Q8x9/55W7xJxXLCwuHbqS+dpbXpi0lR/AhroCd9JaWhRGS77EHi/xHQwTZPko1Y2o nQTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=cSxRdA7CtZqMH5AHnu0pjbjgm4y83TDi1I22kwsZmWA=; fh=TA6TgDg0WGl2oW0vh3MH6XcFa/78QWX/Hk301p7gWXQ=; b=D7uptm7Fvs9W8amQ1wczTYAVQJHM0DxhdYTDrZaFFbJGSanHh3FjTHjNX0i7I3JJ/F Qv1VfMXN+Xi5QmpmH7kr8/TdAxS/9r7o9JllWV9KNq9iB+u0ybTaGuFrc4JoB3+Mh78q HpiB2hR11rXagz6wLxKaTqtEU3wVzsFfxSINKTi/dP6zsJc5uElv0aPVgfxKfO8b3s0U +lRowPY4b18jkfmdwLTMswTbg6WprHa9mHZ82T6oEAFjQTmlf4t7eN/Q1XnuwQkbjk9c hnYKz0hMXBS8GsDLW10LLX12BezulsgRaYLv4PiXEIQzQrjMm0TM7eKq2nTd6PwVdQv3 RK/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.co.uk header.s=amazon201209 header.b=G+zWQtHX; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.co.uk dmarc=pass fromdomain=amazon.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-206646-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206646-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-795331d11c2si433268985a.380.2024.06.07.12.10.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 12:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206646-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.co.uk header.s=amazon201209 header.b=G+zWQtHX; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.co.uk dmarc=pass fromdomain=amazon.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-206646-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206646-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D79331C215F0 for ; Fri, 7 Jun 2024 19:10:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44752149C65; Fri, 7 Jun 2024 19:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.co.uk header.i=@amazon.co.uk header.b="G+zWQtHX" Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C42D1D2E5; Fri, 7 Jun 2024 19:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=99.78.197.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717787413; cv=none; b=ChTu6hJmL5NYbB7swGYDTxV4F/JFld3jCrSZ1V+w6q5UnhvLHD/iLOHWfMzVWYFoP46qID4JCKdpogl8HHHqqUHFnDwi7/E67fE8oEsMwFgPIJCTuRBAVMP7p4lwjpT8iFDNgAT/vHDbECoCjaN3PLCcakIJmKEIvEon8qIi9zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717787413; c=relaxed/simple; bh=Z4QAKAxa4Z6eA8Xk0RNt4/hYgvYzXEdnVXDs3bnsvGw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=JMChvbGVBurWAC5p0paSGB+UFCiohFxs5YsDaVFDlT9wwvdP8L1WeIWTwI1N23CJijeqpOwJrpNBU+P/PEZF+45fWJhGfpLH4rR4Nkc/lY5Da4Tl6Y48tEkqfp36x0Xy9JAz4tZ7VgYSiblhGZvqxHQgd0TiTkm3kPGXR2opbhY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.co.uk; spf=pass smtp.mailfrom=amazon.co.uk; dkim=pass (1024-bit key) header.d=amazon.co.uk header.i=@amazon.co.uk header.b=G+zWQtHX; arc=none smtp.client-ip=99.78.197.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.uk; i=@amazon.co.uk; q=dns/txt; s=amazon201209; t=1717787412; x=1749323412; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cSxRdA7CtZqMH5AHnu0pjbjgm4y83TDi1I22kwsZmWA=; b=G+zWQtHXmfXubDNFTDepYAk6wIz5BaO1db6q8RE4t1Io5Y4OYqMi21ut tRa2inuUCr3LHCG/BQ/KJ6HcRQkEqZ6SXLFqtZ+2NYOqiY03i+UqSCVCK FliK/N1lxR2Qg5LiAKvJ5jFUOW22WasckeaQto6pSmlqTGPMoWwoLOdUu w=; X-IronPort-AV: E=Sophos;i="6.08,221,1712620800"; d="scan'208";a="301930328" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2024 19:10:06 +0000 Received: from EX19MTAEUB001.ant.amazon.com [10.0.17.79:48726] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.2.117:2525] with esmtp (Farcaster) id 6c8e0930-de93-4c38-9937-28cedbcfa495; Fri, 7 Jun 2024 19:10:05 +0000 (UTC) X-Farcaster-Flow-ID: 6c8e0930-de93-4c38-9937-28cedbcfa495 Received: from EX19D007EUA003.ant.amazon.com (10.252.50.8) by EX19MTAEUB001.ant.amazon.com (10.252.51.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Fri, 7 Jun 2024 19:10:05 +0000 Received: from EX19MTAUWC001.ant.amazon.com (10.250.64.145) by EX19D007EUA003.ant.amazon.com (10.252.50.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Fri, 7 Jun 2024 19:10:04 +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.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34 via Frontend Transport; Fri, 7 Jun 2024 19:10:00 +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 v3 0/2] vfio/pci: add msi interrupt affinity support Date: Fri, 7 Jun 2024 19:09:47 +0000 Message-ID: <20240607190955.15376-1-fgriffo@amazon.co.uk> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 | 1 + drivers/vfio/pci/vfio_pci_core.c | 26 +++++++++++++++++---- 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, 81 insertions(+), 9 deletions(-) base-commit: cbb325e77fbe62a06184175aa98c9eb98736c3e8 -- 2.40.1