Linux Documentation
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Gary Guo" <gary@garyguo.net>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Johan Hovold" <johan@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Nipun Gupta" <nipun.gupta@amd.com>,
	"Nikhil Agarwal" <nikhil.agarwal@amd.com>,
	"Ioana Ciornei" <ioana.ciornei@nxp.com>,
	"Longfang Liu" <liulongfang@huawei.com>,
	"Julian Ruess" <julianr@linux.ibm.com>,
	"Ankit Agrawal" <ankita@nvidia.com>,
	"Brett Creeley" <brett.creeley@amd.com>,
	"Giovanni Cabiddu" <giovanni.cabiddu@intel.com>,
	"Michał Winiarski" <michal.winiarski@intel.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Tony Krowiak" <akrowiak@linux.ibm.com>,
	"Jason Herne" <jjherne@linux.ibm.com>,
	"Harald Freudenberger" <freude@linux.ibm.com>,
	"Holger Dengler" <dengler@linux.ibm.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Abel Vesa" <abelvesa@kernel.org>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Mathieu Poirier" <mathieu.poirier@linaro.org>,
	"Srinivas Kandagatla" <srini@kernel.org>,
	"Sylwester Nawrocki" <s.nawrocki@samsung.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Jaroslav Kysela" <perex@perex.cz>
Cc: "Jonathan Corbet" <corbet@lwn.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Bradley Morgan" <bradley.morgan@linux.dev>,
	"Armin Wolf" <W_Armin@gmx.de>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	<linux-doc@vger.kernel.org>, <driver-core@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>,
	<linux-trace-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>,
	"Alex Williamson" <alex@shazbot.org>,
	"Mostafa Saleh" <smostafa@google.com>, <kvm@vger.kernel.org>,
	<qat-linux@intel.com>, <virtualization@lists.linux.dev>,
	<intel-xe@lists.freedesktop.org>,
	"Vineeth Vijayan" <vneethv@linux.ibm.com>,
	"Peter Oberparleiter" <oberpar@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	<linux-s390@vger.kernel.org>, <linux-hyperv@vger.kernel.org>,
	<linux-spi@vger.kernel.org>, "Frank Li" <Frank.Li@nxp.com>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	<linux-clk@vger.kernel.org>, <imx@lists.linux.dev>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-remoteproc@vger.kernel.org>,
	<linux-arm-msm@vger.kernel.org>, <linux-sound@vger.kernel.org>,
	"Takashi Iwai" <tiwai@suse.com>
Subject: Re: [PATCH v2 00/10] driver core: Disable driver overriding by default
Date: Thu, 26 Nov 2026 02:13:27 +0000	[thread overview]
Message-ID: <DN4S2C127FMU.1GA3O72TFAC0Q@garyguo.net> (raw)
In-Reply-To: <DN4RPY231N71.1XDIB9HKGBU0O@garyguo.net>

On Thu Nov 26, 2026 at 1:57 AM GMT, Gary Guo wrote:
> On Fri Nov 20, 2026 at 11:11 AM GMT, Uwe Kleine-König wrote:
>> Hello,
>>
>> here comes v2 which addresses the review feedback I got for (implicit)
>> v1. See https://lore.kernel.org/linux-kernel/20261116110853.3418077-2-u.kleine-koenig@baylibre.com
>> for the discussion about that previous submission.
>>  
>> The objective is to deny force binding a device to a driver that isn't
>> prepared for that. There are many drivers that run in a null pointer
>> exception when this happens and only very few drivers are supposed to be
>> used like that. So the first patch implements an explicit opt-in for
>> drivers and denies other matches; the remaining patches implement the
>> opt-in for drivers that rely on it. This makes it unnecessary to fix
>> individual drivers to explicitly refuse such bindings. See commit
>> 1e50a0349012 ("iio: adc: mcp3564: reject devices without match data")
>> for an example of such a driver-specific fix.
>
> For PCI, there is actually already a mechanism for it -- override_only. VFIO
> devices already have that annotation. I think it's a better mechanism. In
> addition to providing a useful id_info, you can also say what IDs you want the
> override match to become possible.
>
> We can do something like this?
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 2398f03a77c1..2cf4659b36a4 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -218,8 +218,8 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
>  	if (found_id)
>  		return found_id;
>  
> -	/* driver_override will always match, send a dummy id */
> -	if (ret > 0)
> +	/* For a forced driver override, send a dummy id */
> +	if (ret > 0 && device_forced_driver_override(dev))
>  		return &pci_device_id_any;
>  	return NULL;
>  }
>
> Where device_forced_driver_override your added logic about parameter and
> tainting/warning logic.
>
> I suppose the issue is that only CDX and PCI have this mechanism via ID table.
> That said, other buses can gain a bus-specific allow_override field and you just
> do
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 720a72ecd174..7539b43961e6 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -563,7 +563,8 @@ static int spi_match_device(struct device *dev, const struct device_driver *drv)
>  
>  	/* Check override first, and if set, only use the named driver */
>  	ret = device_match_driver_override(dev, drv);
> -	if (ret >= 0)
> +	if (ret >= 0 && (sdrv->support_driver_override ||
> +			 device_force_driver_override(dev, drv)))
>  		return ret;

To add on this, from
https://lore.kernel.org/all/7008c5ea-58fd-4452-a70a-2162cc3d562b@linux.ibm.com/
tt looks like that for some buses, the "driver_override" is a mere preference
mechanism and not forced override, as ID/filter must still match.

I took another look at this direction, and it seems that s390/css, s390/ap, cdx
and vdpa all have this property where forced override wouldn't occur, which is
probably a hint that this direction is worth exploring.

Best,
Gary

      reply	other threads:[~2026-11-26  2:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 11:11 [PATCH v2 00/10] driver core: Disable driver overriding by default Uwe Kleine-König
2026-11-20 11:11 ` [PATCH v2 01/10] " Uwe Kleine-König
2026-11-20 18:59   ` Jason Gunthorpe
2026-11-20 20:07   ` Michael Kelley
2026-11-21  1:16 ` [PATCH v2 00/10] " Danilo Krummrich
2026-11-26  1:57 ` Gary Guo
2026-11-26  2:13   ` Gary Guo [this message]

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=DN4S2C127FMU.1GA3O72TFAC0Q@garyguo.net \
    --to=gary@garyguo.net \
    --cc=Frank.Li@nxp.com \
    --cc=W_Armin@gmx.de \
    --cc=abelvesa@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=alex@shazbot.org \
    --cc=andersson@kernel.org \
    --cc=ankita@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=bmasney+clk@redhat.com \
    --cc=bradley.morgan@linux.dev \
    --cc=brett.creeley@amd.com \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dakr@kernel.org \
    --cc=decui@microsoft.com \
    --cc=dengler@linux.ibm.com \
    --cc=driver-core@lists.linux.dev \
    --cc=eric.auger@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=gor@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haiyangz@microsoft.com \
    --cc=hca@linux.ibm.com \
    --cc=imx@lists.linux.dev \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=ioana.ciornei@nxp.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=jjherne@linux.ibm.com \
    --cc=johan@kernel.org \
    --cc=julianr@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=liulongfang@huawei.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mhiramat@kernel.org \
    --cc=michal.winiarski@intel.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=nikhil.agarwal@amd.com \
    --cc=nipun.gupta@amd.com \
    --cc=oberpar@linux.ibm.com \
    --cc=perex@perex.cz \
    --cc=qat-linux@intel.com \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=smostafa@google.com \
    --cc=srini@kernel.org \
    --cc=tiwai@suse.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=virtualization@lists.linux.dev \
    --cc=vneethv@linux.ibm.com \
    --cc=wei.liu@kernel.org \
    /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