lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251207062819.GA212851@joelbox2>
Date: Sun, 7 Dec 2025 01:28:19 -0500
From: Joel Fernandes <joelagnelf@...dia.com>
To: Peter Colberg <pcolberg@...hat.com>
Cc: Danilo Krummrich <dakr@...nel.org>, Bjorn Helgaas <bhelgaas@...gle.com>,
	Krzysztof Wilczyński <kwilczynski@...nel.org>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <lossin@...nel.org>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	Abdiel Janulgue <abdiel.janulgue@...il.com>,
	Daniel Almeida <daniel.almeida@...labora.com>,
	Robin Murphy <robin.murphy@....com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Dave Ertman <david.m.ertman@...el.com>,
	Ira Weiny <ira.weiny@...el.com>, Leon Romanovsky <leon@...nel.org>,
	linux-pci@...r.kernel.org, rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Alexandre Courbot <acourbot@...dia.com>,
	Alistair Popple <apopple@...dia.com>,
	John Hubbard <jhubbard@...dia.com>, Zhi Wang <zhiw@...dia.com>,
	Jason Gunthorpe <jgg@...pe.ca>
Subject: Re: [PATCH 1/8] rust: pci: add is_virtfn(), to check for VFs

On Wed, Nov 19, 2025 at 05:19:05PM -0500, Peter Colberg wrote:
> From: John Hubbard <jhubbard@...dia.com>
> 
> 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 <jhubbard@...dia.com>
> Reviewed-by: Alistair Popple <apopple@...dia.com>
> Signed-off-by: Peter Colberg <pcolberg@...hat.com>
> ---
> 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-jhubbard@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..c20b8daeb7aadbef9f6ecfc48c972436efac9a08 100644
> --- a/rust/kernel/pci.rs
> +++ b/rust/kernel/pci.rs
> @@ -409,6 +409,12 @@ pub fn resource_start(&self, bar: u32) -> Result<bindings::resource_size_t> {
>          Ok(unsafe { bindings::pci_resource_start(self.as_raw(), bar.try_into()?) })
>      }
>  
> +    /// Returns `true` if this device is a Virtual Function (VF).
> +    pub fn is_virtfn(&self) -> bool {

Add #[inline] here and to `is_physfn()` similar to other methods in this struct?

With that,

Reviewed-by: Joel Fernandes <joelagnelf@...dia.com>

thanks,

 - Joel


> +        // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
> +        unsafe { (*self.as_raw()).is_virtfn() != 0 }
> +    }
> +
>      /// Returns the size of the given PCI BAR resource.
>      pub fn resource_len(&self, bar: u32) -> Result<bindings::resource_size_t> {
>          if !Bar::index_is_valid(bar) {
> 
> -- 
> 2.51.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ