Linux USB
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Alex Williamson" <alex@shazbot.org>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Armin Wolf" <W_Armin@gmx.de>,
	"David Lechner" <dlechner@baylibre.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Petr Pavlu" <petr.pavlu@suse.com>,
	"Daniel Gomez" <da.gomez@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Aaron Tomlin" <atomlin@atomlin.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Bradley Morgan" <brads@mainlining.org>,
	"Aleksandr Nogikh" <nogikh@google.com>,
	linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-usb@vger.kernel.org,
	driver-core@lists.linux.dev, linux-trace-kernel@vger.kernel.org,
	"Johan Hovold" <johan@kernel.org>,
	"Richard Weinberger" <richard@nod.at>,
	"Thierry Reding" <thierry.reding@kernel.org>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Bjorn Helgaas" <helgaas@kernel.org>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 0/3] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers
Date: Tue, 27 Oct 2026 11:01:57 +0200	[thread overview]
Message-ID: <20261027090157.GB28851@unreal> (raw)
In-Reply-To: <2026102654-enlighten-perkiness-193c@gregkh>

On Mon, Oct 26, 2026 at 09:27:25PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Oct 26, 2026 at 02:22:43PM +0200, Leon Romanovsky wrote:
> > On Fri, Oct 23, 2026 at 06:13:26PM -0600, Alex Williamson wrote:
> > > On Wed, 23 Sep 2026 12:29:56 +0200
> > > Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> > > 
> > > > On Wed, Sep 23, 2026 at 11:54:50AM +0200, Uwe Kleine-König wrote:
> > > > > > No, drivers should NOT have to do that in their .probe() function,
> > > > > > that's what we moved away from decades ago!  The match function should
> > > > > > handle all of that for you, otherwise it's contant duplication
> > > > > > everywhere that is unneeded.  
> > > > > 
> > > > > Well then you have to accept that root can provoke a null pointer
> > > > > exception (e.g. by forcing the pwm-tegra driver on a device) because at
> > > > > least with today's platform bus match function such a match is ok.  
> > > > 
> > > > Agreed, yes, root can cause a crash and can do tons of horrible things
> > > > much worse than this, that's not the issue.
> > > > 
> > > > That's why this taint is there, to make it obvious that this is not a
> > > > "real" bug at all.
> > > > 
> > > > > > Please, learn from our history, don't make the same mistakes.
> > > > > > 
> > > > > > Now I might be convinced that driver_override is the way to go here, but
> > > > > > it still feels really odd as again, bind/unbind was created as a driver
> > > > > > debugging option only, it should NOT be a normal operation that any user
> > > > > > should rely on.  The driver should "just work" properly instead, without
> > > > > > requiring manual bind work, as that's not a good model at all.  
> > > > > 
> > > > > I agree in principle, but (in my case wifi) drivers are buggy sometimes
> > > > > (due to missing documentation and/or engineering effort) and being able
> > > > > to rebind the driver instead of rebooting to get a working device again
> > > > > is very useful.  
> > > > 
> > > > Fine, use it!  Just don't expect that to be "normal".
> > > > 
> > > > > So yes, theoretically bind/unbind isn't needed, but theory and practise
> > > > > differ in practise.  
> > > > 
> > > > Agreed, but again, don't rely on this as a "real" solution fo ranything.
> > > 
> > > Sorry, late to the party, but this isn't a few user scripts that rely
> > > on this behavior.  Effectively every use case of vfio relies on this
> > > behavior.  We rely on unbinding the default driver from the device
> > > before using driver_override and drivers_probe.  That means every
> > > hypervisor with device assignment and every userspace driver use case
> > > now experiences a tainted kernel. That seems like a significant
> > > regression.
> > 
> > Sorry, I was on vacation and missed this change earlier. This change will
> > affect SR-IOV deployments around the world, which *rely* on being able to
> > bind a driver manually *after* virtual functions are created but before
> > they are used.
> 
> Why can't a real driver bind to those virtual functions?  Like is
> happening in the rust apis?

The actual driver is also bound, but at a later stage. I'm not sure what you
mean by “Rust APIs.”

> 
> > This is needed for two reasons: to save hardware and software resources
> > when creating a large number of VFs, and to allow the PCI config space to
> > be configured *before* the driver starts using it.
> 
> How is hardware and software resources an issue here at all?  And you
> can write to PCI config space from userspace today, no driver needed
> anywhere at all, that's always been allowed.

According to the PCI spec—or, at least, the common interpretation of it—
newly created VFs should have equivalent hardware-resource partitions.
For most hardware resources, this is not an issue. One resource, however,
is critical to partition correctly: the number of MSI-X vectors per VF.
These vectors are backed by physical resources and directly affect
performance and utilization.

In a correctly configured system, the number of MSI-X vectors should
match the number of CPUs assigned to the VM. More vectors can leave
hardware underutilized; fewer can degrade performance.

The workflow for cloud operators is therefore:

1. Create a large number of VFs, but do not assign them yet.
2. Lease a VM to a user and determine how many CPUs they requested.
3. Repartition the internal MSI-X table allocation.
4. Assign the VF to the user.
5. Check how many MSI-X vectors remain available, then return to step 2.

The MSI-X table size is read near the beginning of driver initialization
and cannot be changed afterward.

So, no—you cannot change those PCI values without breaking the driver
and OS that are already running.

> 
> > There is no in-kernel alternative.
> 
> Then just don't have a in-kernel driver for the device and all is good?

In addition to Jason's comments, the PF and VF share the same driver because
they are nearly identical, apart from a few differences in PCI
configuration space.

Please revert the series ASAP, you are clearly breaking existing deployments.

Thanks

> 
> thanks,
> 
> greg k-h
> 

  parent reply	other threads:[~2026-10-27  9:02 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 14:30 [PATCH v4 0/3] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-09-14 14:30 ` [PATCH v4 1/3] module: pull out add_taint_module() to be public Greg Kroah-Hartman
2026-09-14 14:30 ` [PATCH v4 2/3] module: fix up documentation for add_taint() and add_taint_module() Greg Kroah-Hartman
2026-09-14 14:42   ` Bradley Morgan
2026-09-18 15:44   ` Aaron Tomlin
2026-09-14 14:30 ` [PATCH v4 3/3] driver core: add TAINT_FORCED_BIND for when userspace manually messes with devices and drivers Greg Kroah-Hartman
2026-09-18 16:39 ` [PATCH v4 0/3] " Danilo Krummrich
2026-09-18 17:25   ` Greg Kroah-Hartman
2026-09-18 17:29     ` Bradley Morgan
2026-09-22  7:39   ` Uwe Kleine-König
2026-09-22 13:40     ` David Lechner
2026-09-22 21:04       ` Armin Wolf
2026-09-23  6:29         ` Uwe Kleine-König
2026-09-23  9:27         ` Greg Kroah-Hartman
2026-09-23  9:54           ` Uwe Kleine-König
2026-09-23 10:29             ` Greg Kroah-Hartman
2026-10-24  0:13               ` Alex Williamson
2026-10-24  4:56                 ` Greg Kroah-Hartman
2026-10-24  7:32                   ` Uwe Kleine-König
2026-10-24  8:03                     ` Danilo Krummrich
2026-10-24 16:35                   ` Alex Williamson
2026-10-26 20:34                     ` Greg Kroah-Hartman
2026-10-27  6:03                       ` Michal Pecio
2026-10-27  8:05                         ` Greg Kroah-Hartman
2026-10-25 12:48                   ` Uwe Kleine-König
2026-10-26 22:59                     ` Jason Gunthorpe
2026-10-26 12:22                 ` Leon Romanovsky
2026-10-26 18:43                   ` Jason Gunthorpe
2026-10-26 20:05                     ` Greg Kroah-Hartman
2026-10-26 22:46                       ` Jason Gunthorpe
2026-10-26 20:27                   ` Greg Kroah-Hartman
2026-10-26 22:55                     ` Jason Gunthorpe
2026-10-27  9:01                     ` Leon Romanovsky [this message]
2026-09-23 20:52           ` Armin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027090157.GB28851@unreal \
    --to=leon@kernel.org \
    --cc=W_Armin@gmx.de \
    --cc=alex@shazbot.org \
    --cc=atomlin@atomlin.com \
    --cc=brads@mainlining.org \
    --cc=corbet@lwn.net \
    --cc=da.gomez@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=helgaas@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=johan@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mcgrof@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=nogikh@google.com \
    --cc=petr.pavlu@suse.com \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=richard@nod.at \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=skhan@linuxfoundation.org \
    --cc=thierry.reding@kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox