Message ID | 20250122192241.32172-1-naravamudan@nvidia.com (mailing list archive) |
---|---|
State | New |
Headers | show
Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) (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 F09F121519C; Wed, 22 Jan 2025 19:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737573769; cv=fail; b=D3uP0AkRHsQblpt3aaOgsULMC6Vkf/MtfTmZ24MuIW5LtUIs4UMLn017rODOBvFJkdNj+X+/jwRzr1k8K2kHEfeTHpcJCwLT1IhvC9THHZkZV7ROfOnsF8Sonp66T7VEuxsxeFNZDqK+hKChpHsbHlCmBPWiXwvIH+XH+syzG1M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737573769; c=relaxed/simple; bh=bgvXRF4EDZ73nVEaPOZEejuiyuOXbVMWEceolpTwIa4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cp9mxhRd28gv/uz/MrfJ+67lt/YVeX0X2CTXNumjkOUH5WuLhquNPE13pzCUGbA5t2qU8sFdKWaIjbMvYI+B4RXLK1QhkT6bNnILch+M7hwcY499sRjEvJnAFGmvqcrcPhOZmmrgzNsWC5EQc2H2FFjvy8ovMJcPCF5vTuE/BQY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=K/wG/NMu; arc=fail smtp.client-ip=40.107.244.50 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) header.d=Nvidia.com header.i=@Nvidia.com header.b="K/wG/NMu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RU6/Dxtk7+9CTcH8fzXHaX6/+uFB7UHse/KBSK+2XSiALS3IIe2WZmi2ylCBk3pqOZ1EO9ewqPKTbYnD4w3HFSzSmzgvtjaiUG7hkfJLr8+T0g6tWShi1Nv/+ZDvGd6II4uHbA02l53mVRWFYOrfufx1+OTVNyCteX6OBmHHN5f9YPe8eWdPgz67M9uPrQ+jObEX/VHlumQHoczl2+c0+kDhhE1lETK1uIbEQvjeF5riwHopyLDLRHeFwe5ciCHTYjl7/D+ESDdVgkPTeFuJb1gXc6+/F+El/m1K3mwb9+SmMsPKM1lN3Bp2pLnnnyEhTnhJw/HUMatvYw8kPyA06w== 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=tbAbOLe4RssSU4/wqtFL41gdLFIh/i4/uk5HCzZEFPQ=; b=e4p3dPiIED4mQRao+BpvMuBv3Jyrr4S2H7YRP2Hv6FkyhR9E/vyLF4Kn9RGnOFqz3OKagCsxyhp3khWJD9d1snbgNeRLp+up4oVvOb71+D6JcI023qf5ZyZrTV7hHVHpanCrSrpcZ9GM/5JUsrppZR+F1E0QvqIvLyI+v8cjwngyK1z6R/3LngasxwAYBsJ52DbTsMFimwMOQ8kxkUzQPwqMbZ0TOtTb0ofNvVuC0/3LH1T1di7041+51GAl4VEp440EQKBFgY1WThuNr7rUXN/Mw0g0iNI/Y/zNIZLH6qhA8F9fy+3A5OyoTwR79xWW/DUitnkkgQqoJKd+MvUquA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none 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=tbAbOLe4RssSU4/wqtFL41gdLFIh/i4/uk5HCzZEFPQ=; b=K/wG/NMu0bgxfvulNkTf5JWXyeiYmJ0/fYcDJjGduZKLZm/Yu7SI70gScgLrZCyfRZk7ac8p4B6Iu+8gxRrwU2MhG09KFyetQyWYS53t07ZT6lIUv8P9UiXdUKMhFImM6x0yxTyDvG3FeQmfGSeaeH/aUyrhNGGLtsjlcCgWup06I+kEBZgZeGRu9L0lNN7TsxGdmpi2B7LzF5ZuUgWIV7vtX0TW5NU/+sZVKMH/v2cjkcGPYC3HcjqOdIwqB7aYO22O7EKUWjE3MPBFhHEDZIp56WaEuy18Q4aMoXW5guYt13GFO60DHAFZghfBiHaF/LHgXB9NXofMS6tbkBfqNA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MW3PR12MB4524.namprd12.prod.outlook.com (2603:10b6:303:2d::12) by DM4PR12MB7648.namprd12.prod.outlook.com (2603:10b6:8:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 19:22:43 +0000 Received: from MW3PR12MB4524.namprd12.prod.outlook.com ([fe80::b134:a3d5:5871:979e]) by MW3PR12MB4524.namprd12.prod.outlook.com ([fe80::b134:a3d5:5871:979e%4]) with mapi id 15.20.8377.009; Wed, 22 Jan 2025 19:22:43 +0000 From: Nishanth Aravamudan <naravamudan@nvidia.com> To: Cc: Bjorn Helgaas <bhelgaas@google.com>, Alex Williamson <alex.williamson@redhat.com>, Raphael Norwitz <raphael.norwitz@nutanix.com>, Amey Narkhede <ameynarkhede03@gmail.com>, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Gunthorpe <jgg@nvidia.com>, Yishai Hadas <yishaih@nvidia.com>, Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>, Kevin Tian <kevin.tian@intel.com>, kvm@vger.kernel.org Subject: [PATCH v2] PCI: account for sysfs-disabled reset in pci_{slot,bus}_resettable() Date: Wed, 22 Jan 2025 13:22:41 -0600 Message-Id: <20250122192241.32172-1-naravamudan@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250106215231.2104123-1-naravamudan@nvidia.com> References: <20250106215231.2104123-1-naravamudan@nvidia.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR05CA0058.namprd05.prod.outlook.com (2603:10b6:a03:33f::33) To MW3PR12MB4524.namprd12.prod.outlook.com (2603:10b6:303:2d::12) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: <kvm.vger.kernel.org> List-Subscribe: <mailto:kvm+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:kvm+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR12MB4524:EE_|DM4PR12MB7648:EE_ X-MS-Office365-Filtering-Correlation-Id: 46bbe2db-eddb-4f40-2efd-08dd3b1a24d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7053199007; X-Microsoft-Antispam-Message-Info: Qhl2eSKIWbgbEbxM1ncO95OlsTPNfU+NyLpXn3k8disFsq4RWPcxf2sHFK/mLy5wwguyiN/bbpVKGihKpJjF02Mam3P1M6pDcsRBjKWEDDG6T/7NF5Rz9U8gHL6YVGNW1hZuuryIoJ0jihnpsbn54vswVFb4Prj2wfva+Qi7m6MXhcMt6Knv1HXbtcW5W+1m5DBzg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+WjnY1lkWpN3qORyvXk/ZsdkPtdBJ2T/y59L2aIOW9ItQMP+3etgzbf5zLVOoSttOhBzLNg9h7p6e9Yf1orpYuiAEJMqphzvMGEAxjaldNCgLaZPBVR1hmhsfam7q5tUIIPNpim3uoY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR12MB4524.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LEuziOOt8mrgJUyJNkOC/MlndZYJvIXC7zDlK79vnIFwqORlBKQpRlLmEMe6cJaqBg02scxtU0QsxVV4WJW4vlAXRwOsT74IK9rZ3B+3OukLaqLepB8l+YpEu28Yr77pTyC0e6FCphafXKR0jum9XKH80vksM5mFoBzXXgIx6vdEur31L5Bc89aTto9Hdq+vH/X0DdSzujHkROu8AVA3rl5UXaOKuDV6wuF6MjmP7ES0S36lpvQ9vWO/St7Px2qHMjAqpNBrit5PePHoZIR5nD6eaQJxGLm9HfqnGaRUekCslnOiSUVazzodt7hRfhevuMJhtq8LmI5JB2VL1YUU+Fble75ohePJbNznObhgnyK32R+hdAWZza6HmINjB8zbOeRTNwb36Hr2MaMrWo8N7m4i4dUtOSAKg+W5ubUzvAYZ6EWYnRbu+ZWJmAKSCVs5GyvZgzWme9LuH0/7L4UA5FIkEH09qn4vIfpDupKQU11tvpuXfV2kAqsaUg/74Cp+VT3isL7740/3B96vrwH3Qb+fpaZpPqVZO7wdMYsQjcrJhdBqfVycnMdeCiKc9aA2ikYqCsYD38sYM6FqgmZK1nmyS7bcu2d47FtPRzQ+WVSuyxD1xDVNaOnLhupRh6fPdhaoOxeO4Dv4O/JP/+unQwabj1mXA+n/4KmLbpWt+AaeFI5S8dtE1CZWXmq9aomRTL5EO2E12CNjEdQMukvB1elEz9juXYLVS8OSQW3icBKUOmPuh6X7YGMI8KFdfAWC52HOOykWBnBedlIBLXY8JavZFoLKt37NHVQlWRqN+Z98FA3FkB8lpSQetP6mkxJ0a+ZXoAwcyDPFAAwVejcZNuGmdp99US7aLllwj3KY9RyFI+/f1ceyQyOv20YlMCKGszagH7PialY2DGSg6YAw4IZJ7mR7QD7sy/7M5AMwE4MFuPw1JCE0rvSHT/dMJqHLLBifiiocIJ+7er92zSU0kEqX4vvsC7iJ73wE6jdgfdMNl6dFSB/wPosDjq26RX5/PKJl87QqYzem2q1iDaNIsZj2a7m47hxzjuWu+glL7oB0YEH/JnEFMsPvJ3b6msSXD+kDEhq/tnKFCCQ3Zp29u+710vij2+pdD/sLf3wy32+pjkFhYKvQO96ofS1pWlNIfxayuCQ6fhvnzntS0CcuXvpM9OifATzvqNRQQSpJ/Lsm/ad4RgsqQx3swPJ9nHjCso4BfJjYVFKn8B66K1udc+jgCYQZd1Pvpctf6YV34dUFY3nj9hkF4A+opcwH5d9l4oxrssqoDtlgodna4YxxaSGZjARiEF+jS3C2/eKSyJb9yc2gKj4jgGsRZUJdASaY2YFKbkwbXhJH3OPndccdcvMYDKMUOd6i9LnrG11q0YPrcrxlI7dBo72FO27vQKwoXGl8gGAINXPTkm9WNyZxAL+k2yRcGAdS3dk+RTkH1vnOVbslONPayrPiI8ulP5r/btwMrqlxRiKxRcd7ZcYv+8TVEWj55uEvLnkAJh/DcAyDy1R8MXcUUaDoxgilBd2n1IwhWrhDRLQ0EinEQ7ZQi+v1QPAZYnBFBi3cglAnxtjWl1KIYNykQGovyp3nOJgOTGkWl+65sV/eUpooMZNBtA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46bbe2db-eddb-4f40-2efd-08dd3b1a24d3 X-MS-Exchange-CrossTenant-AuthSource: MW3PR12MB4524.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 19:22:43.1016 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: anmu3lADzJT9IJzoc6w22Q8XnUpON6h0TsY5uO1wIAbqYY/4t3kJddyS5ZFxLshgyGgDlq5mBwKlayMmUdyOFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7648 |
Series |
[v2] PCI: account for sysfs-disabled reset in pci_{slot,bus}_resettable()
|
expand
|
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 661f98c6c63a..809936e1c3b7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5536,6 +5536,8 @@ static bool pci_bus_resettable(struct pci_bus *bus) return false; list_for_each_entry(dev, &bus->devices, bus_list) { + if (!pci_reset_supported(dev)) + return false; if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resettable(dev->subordinate))) return false; @@ -5612,6 +5614,8 @@ static bool pci_slot_resettable(struct pci_slot *slot) list_for_each_entry(dev, &slot->bus->devices, bus_list) { if (!dev->slot || dev->slot != slot) continue; + if (!pci_reset_supported(dev)) + return false; if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resettable(dev->subordinate))) return false;
Both vfio_pci_ioctl_get_pci_hot_reset_info() and vfio_pci_ioctl_pci_hot_reset() check if either the vdev's slot or bus is not resettable by calling pci_probe_reset_{slot,bus}(). Those functions in turn call pci_{slot,bus}_resettable() to see if the PCI device supports reset. However, commit d88f521da3ef ("PCI: Allow userspace to query and set device reset mechanism") added support for userspace to disable reset of specific PCI devices (by echo'ing "" into reset_method) and pci_{slot,bus}_resettable() methods do not check pci_reset_supported() to see if userspace has disabled reset. Therefore, if an administrator disables PCI reset of a specific device, but then uses vfio-pci with that device (e.g. with qemu), vfio-pci will happily end up issuing a reset to that device. Add an explicit check of pci_reset_supported() in both pci_slot_resettable() and pci_bus_resettable() to ensure both the hot reset status and hot reset execution are both bypassed if an administrator disables it for a vfio-pci managed device. Fixes: d88f521da3ef ("PCI: Allow userspace to query and set device reset mechanism") Signed-off-by: Nishanth Aravamudan <naravamudan@nvidia.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Alex Williamson <alex.williamson@redhat.com> Cc: Raphael Norwitz <raphael.norwitz@nutanix.com> Cc: Amey Narkhede <ameynarkhede03@gmail.com> Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Yishai Hadas <yishaih@nvidia.com> Cc: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Cc: Kevin Tian <kevin.tian@intel.com> Cc: kvm@vger.kernel.org --- Changes since v1: - fix capitalization and ()s - clarify same checks are done in reset path --- drivers/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+)