From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.196.33 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796204026; b=450BxKFhW7fobyBjQWZDdcgfnoTNwAadWFqB6XComDeKpUdy/osBGOex6NN154nh/8mK +eSXQ3DEylTurikRUjY/l/bDf7/EO8dCQxI1l3mBuq7Kc+Wcn9w5tcQFTw4xyMOR/igmn a0nC6Jb7WghcOjHkObYGaauRnFNia3EHvresEgO3dRzU3N2h+VLfe+TUmCzYcScS0GJID 1x5qffmD4gKQyD6AQYXu6rbSTyuRqDP/lagSBowTqNflr6OCTLP8WuVH8mvx+/MlwKMUP z6HhHXiOA3gM+GACAdiTlN5JA+bMAV42W9PLDoHPLpm/kwlqI9EE7L5I/Jz+a56fIPw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204026; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=XHjXBcyvSFk33CxVwq/yqmLzndN+Rn+1/boc5hqN67o=; b=QNCr115ZIeAQeDgqHxZkuaE9dqWTGhBwV0k/Y4FjkUn58ttrXGvnkO3TW1aV7f8wCV1r IiNRdqFMZ31n/zLF39HgCrJAmWhriO1VWuldLzLvhC0H3RIzV4lUYUuFBziZyYjKMU7XB XuQUxvHJe4tR0IDn7v6MVuPc51YEmQ/hdHA+YSIDZA8XJ7HJDYrs3g8Gizeg3PgWxz6cR 1u53lFbd2/IRq88iI1GxKbnLn0t1gHXh2L1KDq5XPfg5ndiMDioDNHDduZcRWwM+BwG4d dUucBHmVlt+oTDoMTZAYhY5Wl0Fyiw2vuQSsCtSzKeX1NKumBGpJHcmLfVpdprn7URw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=jE5+0plT; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.196.33 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013033.outbound.protection.outlook.com [40.93.196.33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8001E606A31A; Wed, 2 Dec 2026 09:33:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8001E606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=jE5+0plT ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sSiraelNkiwNPT1alVCO4T070kLFWAWtnVwXVfgFdubMsjocc/8BMGxrtyJx/fJbyZmFeTqpTky8HLszyJQ9XQvRr5D3Ik6sJne0zVshP3dZPDrQfe6lEEKquMmXbKywVjoTGlAT3yTu2zLe0e5K8+Bbi57QYID43ZNe4vh/UCXzjE4j0mHmJII6UAA+07hXgXD19dr6UB88e9ULyiZBcERxnfG9ftWjRkhjhNQ1eFOqosaDwTaCL6It2vU4qLbzkdzXpmNsxfsHw/nYG7+AldVuMRoama7bucBkrIkWzcp7+eVgBB1Xil7mug3QiPU3GkBqX/al040sk05gjqTt0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XHjXBcyvSFk33CxVwq/yqmLzndN+Rn+1/boc5hqN67o=; b=vLuUl6SYgSctYjoZisYZfSsGWoN+NW22lPc2Li+mlkOoTES54ngovpLj373Sdy/H96Zr4umysi5GFguBVk/tKsyLBrRxLW7eBTJapqFsUx/dRh+dF2OgpkJbhYQMmidn7V0B5OJmdDFvIriXLvCpixOUSrP0p7KGcYm3POub9wWzFEradrGz+7zP9Bv1Mv6AuzrXvHykC7VF+/Ztu1v4iHUyuWcgE4dgn1mL5WFKJy666NmgJ/JbOBIL0BULzZmk7kM3f3MVsRodY27y1WGKGu31i5ZOASQ3BN81gEBKx+7SBhxbDiCH0nRPVdoUBzmcGVooEAntGkCbJNzRYi2neA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=ziepe.ca smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XHjXBcyvSFk33CxVwq/yqmLzndN+Rn+1/boc5hqN67o=; b=jE5+0plTfJne4xwMvPo8DnZFRUSoLBkpeJ4TnPXR/BcMNTIE5/17se4w2VO18/v48XFK2gV2Yiemb6+zGBM4Y+UUf/b5Awz6YlwHfIpp0YfEznQw+Vsp1+QC5vHOAeSRTLrkFM+DSPg3q+92Pp3JhXz3CmhHhDv79AWIDjV3cgzIKpTEJJ8No6Z+nxab3K+N/bWv4CBRjroltJdZI30+BK3AF1BsYcCf9G3CsQnFy0zl+BMSHVXPJ610dKOzqizkWLa6mhqoHPJxc9zBYwu/7dezCb/sGYeuM/MhzDApMByztTiqeTVLrfjJHP/0y3M5KQHShL1prRFbN4AfzXckCA== Received: from MW4PR04CA0198.namprd04.prod.outlook.com (2603:10b6:303:86::23) by DS7PR12MB5717.namprd12.prod.outlook.com (2603:10b6:8:70::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Wed, 2 Dec 2026 09:33:40 +0000 Received: from MW1PEPF0001888D.namprd03.prod.outlook.com (2603:10b6:303:86:cafe::9a) by MW4PR04CA0198.outlook.office365.com (2603:10b6:303:86::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Wed, 2 Dec 2026 09:33:39 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MW1PEPF0001888D.mail.protection.outlook.com (10.167.249.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 09:33:39 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 01:33:18 -0800 Received: from nvidia-4028GR-scsim.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 01:33:15 -0800 From: To: , , CC: , , , , , , Subject: [PATCH 0/5] vfio/pci: Per-BAR excluded ranges Date: Wed, 2 Dec 2026 15:02:45 +0530 Message-ID: <20261202093250.1683744-1-mhonap@nvidia.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW1PEPF0001888D:EE_|DS7PR12MB5717:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b817ee1-ac2f-413b-52f0-08df505758c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|1800799024|82310400026|376014|261102123227099003|261028144727099003|10067099003|56012099006|261026140227099003|261026121527099003|261022075727099003|261022105027099003|261022115727099003|261021123027099003|261021121427099003|261102130727099003|18002099003|5023799004|11063799006|6133799003|13003099007|261009223027099003; X-Microsoft-Antispam-Message-Info: KLPHcS//ZXP8l87fsjdrFTmCxkvf6rbX3VYnt6YcuJuWivvDm54tpptWSc9pajFyb2SVel4PRXd4sQQWvGkIF516qIoVG5pbbjR6Hw72FS6qjLGCZYYa/4IHYztv7fAxKRdlnT4cT8BS/ODRavfgnebeukJ128T6n4yLwVXNSrG60Z1ERM8FeYlp7QjTx258Je9msz5nZ7ty2xFVxuO6q8Su6JIfWq5BeewkipvNU+XgJhiwJKm26tUov2zrVGDzk3CY7XCFnsHBJWznjAFn7iZFKNRArYFHfA2v5DMTcErRxelBDPJ6zky1JF+CHGa0NwTDVDmOluFOlbNY5HfrQgIikX2Zt28zmWr2G0eCwiPPLSRRh3lnCbvNTwDsCK0M2dVAEb164N4WdDOxEDa9a4AgTG3iliqG/Tq20gniWYQLGlTqS0WUPDY8f7tq14+eJTqCBlZpihr/dkhgT6DPn57KIYFiwnon0LW3Goh5Dvql7+fTmmAZR+opV8gkz73CXT6KM/HF3HbXfXAhRwVxkEaFqlzoyaDac8g+B64QPoG5SwU9G7hm3OkKgWXqmCBkjIS/SWh+EPtRkpWy64E7QizGXAFvCyFiuOVnTKo8dxEpPInB5QKyT36KyXf81am7PBc8A8A/nJEbtxFyby8iPso/NxbnESTum+07soj4DuEnTEDDSbDqRbTDchiHx3eMwR6QXoy15zeF7ITfjnlTdQ== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(1800799024)(82310400026)(376014)(261102123227099003)(261028144727099003)(10067099003)(56012099006)(261026140227099003)(261026121527099003)(261022075727099003)(261022105027099003)(261022115727099003)(261021123027099003)(261021121427099003)(261102130727099003)(18002099003)(5023799004)(11063799006)(6133799003)(13003099007)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F/JjZ5hAkuJf15X+aEbCNZZOOMKTNwJ00nP5EQTLbmsVVSdudAVr3Wbz2Wszlz5VC9rt8Fxpbs6NhhzJgkHH7R97XcZCjy7wlBZZDeEukOPZhWeOwbsyJPsfft11UELFuRh38hEhVOsJe3paEwSzsJlmXB0PEsd9gcvZCGXWW0TP0D+Z3LCWelo1K/svXEjggcqzCR/VzHSUu7d1A421IDZEBT+BahJF6FA9SO/jEXY4XUIj44GIWHGBIo2Z7BQX6WoO+3X9KjDAiS8rgE3tCaTWcP/RPy4dUzd0+ImOYeJXK4rc/l6E1O8hIjstBQshRL0D/Aun0LAnlVBAYA5zK9Gj78IQYR5GSd1bGdTTVma1MQVP9zscZE+V5nqfu3xZgf4vGnhAFm5LQPxPamBHnMeA+IqmJD7jL8tsCSFVbZiQXaDjaOQhkluFdi6LAtni X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 09:33:39.0474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b817ee1-ac2f-413b-52f0-08df505758c3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MW1PEPF0001888D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5717 From: Manish Honap vfio-pci keeps the user away from one range of a BAR, the MSI-X table: reads through the device file return 0xff and writes are dropped. The vfio-cxl series needs the same for the HDM decoder registers of a CXL device, and Piotr's xe RFC [3] needs it for ranges of an xe BAR. Alex pointed both at one generic interface [4]. This series adds it, with the MSI-X table as its in-tree user. Patch 1 moves the MSI-X and ROM windows out of the exported vfio_pci_core_do_io_rw() into vfio_pci_bar_rw(). The VGA and nvgrace-gpu callers lose two arguments. No functional change. Patch 2 fixes an error path in virtio-vfio that skips vfio_pci_core_release_dev(). Patch 3 allocates in vfio_pci_core_init_dev() and would leak there. Patch 3 adds a list of excluded ranges for each standard BAR, sorted by start. Each range has flags for mmap, read and write. The lists are built in .init and freed in .release, so readers take no lock. The MSI-X table is the first range, excluded from read and write. If its BIR or offset is outside a standard BAR, nothing is added and one warning is printed. Patch 4 refuses an mmap that overlaps a range excluded from mmap, and reports the other areas of the BAR with a sparse mmap capability. The MSI-X table is not excluded from mmap, so the MSI-X BAR stays mappable as it has been since commit a32295c612c5 ("vfio-pci: Allow mapping MSIX BAR"). Patch 5 refuses an ioeventfd over a range excluded from write, and a dma-buf export over a range excluded from mmap. The generic test replaces the open-coded MSI-X ioeventfd test. After this series no in-tree range is excluded from mmap, so patch 4 and the dma-buf check in patch 5 have no in-tree trigger yet. The vfio-cxl v7 series adds the first such range, the HDM decoder registers, and exports vfio_pci_core_add_excluded_range() with it. Piotr's xe ranges are the second. If you prefer, patch 4 can move into the vfio-cxl series, in front of its first user. Changes from vfio-cxl v6 08 to 10/31 [1]: - Patches 1 and 2 are new. - Patch 3 (v6 08): lists built in vfio_pci_core_init_dev() and freed in vfio_pci_core_release_dev() (Alex, 08/31 [2]). Entries use struct range. The ROM BAR keeps its range past the ROM image outside the list. The MSI-X table is added by its own helper. - Patch 4 (v6 09): count the sparse areas, allocate and fill them once (Alex, 09/31 [6]). VFIO_REGION_INFO_CAP_MSIX_MAPPABLE is not reported when a range excluded from mmap covers the MSI-X table pages (Sashiko on Piotr's RFC 2/4 [5]). - Patch 5 (v6 10): the dma-buf check is in validate_dmabuf_input() (Alex, 10/31 [7]). The open-coded MSI-X ioeventfd test is removed. - The export of vfio_pci_core_add_excluded_range() moves to the vfio-cxl series, with its first caller. Testing: - Series applies cleanly to v7.4-rc4 (b6a9fa34ce41) - Tested with a passthrough guest on VR-NVL72 system with running CUDA/UVM workloads in guest. - No vfio selftests, kmemleak or sparse were run. [1] https://lore.kernel.org/all/20261016161839.2765592-1-mhonap@nvidia.com/ [2] https://lore.kernel.org/all/20261106085939.764b6dde@shazbot.org/ [3] https://lore.kernel.org/all/20261105153738.1938345-1-piotr.piorkowski@intel.com/ [4] https://lore.kernel.org/all/20261105085032.679881ff@shazbot.org/ [5] https://lore.kernel.org/all/sashiko-outbox-199483@kernel.org/ [6] https://lore.kernel.org/all/20261106133920.144f0665@shazbot.org/ [7] https://lore.kernel.org/all/20261106135245.2870aebb@shazbot.org/ base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f Manish Honap (5): vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw() vfio/virtio: Release vfio-pci-core state when legacy I/O setup fails vfio/pci: Add per-BAR excluded ranges and put the MSI-X table on them vfio/pci: Advertise the mmap areas around excluded ranges vfio/pci: Refuse ioeventfds and dma-buf exports over excluded ranges drivers/vfio/pci/nvgrace-gpu/main.c | 4 +- drivers/vfio/pci/vfio_pci_core.c | 178 +++++++++++++++++++++++++++- drivers/vfio/pci/vfio_pci_dmabuf.c | 10 +- drivers/vfio/pci/vfio_pci_priv.h | 14 +++ drivers/vfio/pci/vfio_pci_rdwr.c | 152 ++++++++++++++++-------- drivers/vfio/pci/virtio/main.c | 5 +- include/linux/vfio_pci_core.h | 5 +- 7 files changed, 312 insertions(+), 56 deletions(-) -- 2.53.0