From nobody Tue Dec 2 02:29:04 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 69E4B28688C for ; Wed, 19 Nov 2025 22:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763590762; cv=none; b=obh0Jg3mQQu/BJHIU49l8xJi0SNQ/LxbA2REBCczRIEsjaYtk23uLyLSVQWAG1ts+D6FKuNAoqWewu6RTHqrZOIdF4tZ2InrpMsR31LC16Jsrlz8y0XuE9gm3BYZhkXboqNELUuzL5WPCIhsFdu4CE3ExHPXwffjUIssPiziMEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763590762; c=relaxed/simple; bh=MeAH/L9J30qCwqNdMB87QZq7p2/nxJ5qIpUSuF+RrHo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b/YJafojST5s8uQdGu7/6vSUA8Yu02pt6nBoVUr6k2Gl1ItC/KgcpGQfpq5TjxogcznAkvEJoEO8LouQkfCG+meOWqcgZVZLPEVvySze5EZeojhgDaiaH+xTFXVR0e/tQ6f219J9sPyz/TEesq48u/4v+twaLggFa3bvvRsenVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ejYWQbOb; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=t+67ORCo; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ejYWQbOb"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="t+67ORCo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763590759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X0Vb/20jTWy28ubGj9MV+Ibuanb4TZxQpwWcQXJ663I=; b=ejYWQbOb4MWpprm+N03+x/SZSuyp4cZfF9v7+DUhgZ0B7Kg0HO6P6EYNQLMgGp7eKb+aD3 i33sRcpNvic8HBiCobDnLARW4rtomcv4YMRpsM/HDAbQf0PqfJP45wwshq7rAih+HIqxFx aqCdskQDZYWp8GI9wo5InG5UvEc9jEk= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-R-Ld88WnPXSQANoFtbMcyg-1; Wed, 19 Nov 2025 17:19:18 -0500 X-MC-Unique: R-Ld88WnPXSQANoFtbMcyg-1 X-Mimecast-MFC-AGG-ID: R-Ld88WnPXSQANoFtbMcyg_1763590757 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-88233d526baso8302066d6.1 for ; Wed, 19 Nov 2025 14:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763590757; x=1764195557; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=X0Vb/20jTWy28ubGj9MV+Ibuanb4TZxQpwWcQXJ663I=; b=t+67ORCoQvloq0ZpCZzCXRZ1dG6L1e2Fagkc2ClXYCH6LqFrSiXeyddwaUJiXEkrSN QBBMuI6QIAEbKWRh8tDYo97qjCziBr19H4qSS3/goFj8o0NTrXE4gNyq4FGULp2ohXAH dpqFz4sgmhIlW83WAeR0/9KU8ByZG7hp7kKBBLt7Jfc9mIz1C70Z0+7QU8xGATGUUR7O LE1WLkhB6Wd5zXUMeQHlpvqZFmH15QWvT3OpVR0kzobeOz+RAJx21wNeXylo2PBHD2tE sDZE6rNidMH3c2UhSsWzIoH+Vm2Uv971b+IcHMa+2HSLhemeKiG4VeQjllUR1Hj+2LjE MYUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763590757; x=1764195557; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=X0Vb/20jTWy28ubGj9MV+Ibuanb4TZxQpwWcQXJ663I=; b=f40GoguJ9nAQa5Myo/9GUTTge4TwHGS8mKCXQEL5babpgN4riqGw5uSq1S+yvl74aK /vn6SqjUWSwe34ZfUFKPYj2ANyOK4FXPSKOhbYeNt2n5jqcfCUQmL4tfO99P/UymOXWO JNr3Qgqo9D8sOjuk885lYEZPzR8DXOQ127YNt31eFCFuf3Nwkv8nYuj39ERBEIKDVTy1 2+Tsb/JepwSf0ue+Bmd5XYmgJmMrLooKmeuj1nX2o5OR5l/de6OuiKns+N4BDy4pFABc bI5wxeIMt3lBHeTXTW/8aWcYvVJVktPhUkTOOc0hA0q9hYkCTIOsoktF1yRK6z+pk+je 48qg== X-Forwarded-Encrypted: i=1; AJvYcCVWtAlG9BOBSb7fcd/5ljxaj442J1eAYiI8y0UrdG35GYBSjIeHIt89FGvQ/E9zirqIO421VrC72gV9HvM=@vger.kernel.org X-Gm-Message-State: AOJu0YwumawZf6R5kTAxJnaH5x7VT1AP7yIQQ10NKdzbEE/1p/LPGPY9 2X29qKLoUXwC48LsqWCg8L5V2YtlQME5RgCb+OuibiA3oQe3sdaO4sNlXFpBudjDi37C1LJmI6g TrLshZQK+5urWbXNPHsZzGuj6MBNlsd2MU+KFdSEUNE7b8o3vOpcmnMS2jzfI/QXFrg== X-Gm-Gg: ASbGncsHNb0XxuiDxCxLJlUiCj7tgO6xh4FXMqeTHmSBXPt/n4T030rTJmiTG4pkIZV W27jMqgWt1K2ccVL/4AfZhvI+G1/we1s8SgZ+YQ39tdush+UP2VFKBRb/plOIGZ9hlkxB573LEI hbNdkkjbwDjd/hJgFyt2NmfEdMXvJdy4tzJPevAqFEzbyWGfsg2+bkQmmAb9E3s5xhrQratRqZf CG5At6BQ5keCYdwyOIuAoo2oyb0N2ipKNvHnUiAQZWT8Zjx66R8dJpy6tP4I4jGwLCXq6o453XV fzaE5edYJ6yIR1qHe+kDLT94DPUjkqDRSin2KhyV8ea36W/d91c6IKl1JimVd3i8Ue/EKCiF3eN JZxUpWFkI6rd14A== X-Received: by 2002:a05:6214:768:b0:78e:6354:b258 with SMTP id 6a1803df08f44-8846e055f2bmr12533366d6.15.1763590757418; Wed, 19 Nov 2025 14:19:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFT94Xj7OzL6w7dHQO8Ye/Fmage53na9GJygM3mxuQHkkniYgbaAhhdRnQnnHNNrHgeJgJp7Q== X-Received: by 2002:a05:6214:768:b0:78e:6354:b258 with SMTP id 6a1803df08f44-8846e055f2bmr12532836d6.15.1763590756867; Wed, 19 Nov 2025 14:19:16 -0800 (PST) Received: from [172.16.1.8] ([2607:f2c0:b141:ac00:ca1:dc8c:d6d0:7e87]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8846e447304sm4426866d6.4.2025.11.19.14.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 14:19:16 -0800 (PST) From: Peter Colberg Date: Wed, 19 Nov 2025 17:19:05 -0500 Subject: [PATCH 1/8] rust: pci: add is_virtfn(), to check for VFs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-rust-pci-sriov-v1-1-883a94599a97@redhat.com> References: <20251119-rust-pci-sriov-v1-0-883a94599a97@redhat.com> In-Reply-To: <20251119-rust-pci-sriov-v1-0-883a94599a97@redhat.com> To: Danilo Krummrich , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky Cc: linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot , Alistair Popple , Joel Fernandes , John Hubbard , Zhi Wang , Peter Colberg , Jason Gunthorpe X-Mailer: b4 0.14.2 From: John Hubbard Add a method to check if a PCI device is a Virtual Function (VF) created through Single Root I/O Virtualization (SR-IOV). Signed-off-by: John Hubbard Reviewed-by: Alistair Popple Signed-off-by: Peter Colberg --- This patch was originally part of the series "rust: pci: expose is_virtfn() and reject VFs in nova-core" and modified as follows: - Replace true -> `true` in doc comment. - Shorten description and omit justification specific to nova-core. Link: https://lore.kernel.org/rust-for-linux/20250930220759.288528-2-jhubba= rd@nvidia.com/ --- rust/kernel/pci.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 82e128431f080fde78a06dc5c284ab12739e747e..c20b8daeb7aadbef9f6ecfc48c9= 72436efac9a08 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -409,6 +409,12 @@ pub fn resource_start(&self, bar: u32) -> Result { Ok(unsafe { bindings::pci_resource_start(self.as_raw(), bar.try_in= to()?) }) } =20 + /// Returns `true` if this device is a Virtual Function (VF). + pub fn is_virtfn(&self) -> bool { + // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`. + unsafe { (*self.as_raw()).is_virtfn() !=3D 0 } + } + /// Returns the size of the given PCI BAR resource. pub fn resource_len(&self, bar: u32) -> Result { if !Bar::index_is_valid(bar) { --=20 2.51.1