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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86jzdl27my.wl-maz@kernel.org>
Date: Sat, 02 Nov 2024 11:32:37 +0000
From: Marc Zyngier <maz@...nel.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
Cc: Frank Li <Frank.Li@....com>,	Bjorn Helgaas <bhelgaas@...gle.com>,
	Richard Zhu <hongxing.zhu@....com>,	Lucas Stach <l.stach@...gutronix.de>,
	Lorenzo Pieralisi <lpieralisi@...nel.org>,	Krzysztof WilczyƄski <kw@...ux.com>,	Rob Herring <robh@...nel.org>,	Shawn
 Guo <shawnguo@...nel.org>,	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,	Fabio Estevam
 <festevam@...il.com>,	linux-pci@...r.kernel.org,
	linux-kernel@...r.kernel.org,	linux-arm-kernel@...ts.infradead.org,
	imx@...ts.linux.dev,	alyssa@...enzweig.io,	bpf@...r.kernel.org,
	broonie@...nel.org,	jgg@...pe.ca,	joro@...tes.org,	lgirdwood@...il.com,
	p.zabel@...gutronix.de,	robin.murphy@....com,	will@...nel.org
Subject: Re: [PATCH v3 1/2] PCI: Add enable_device() and disable_device() callbacks for bridges

On Sat, 02 Nov 2024 11:10:12 +0000,
Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org> wrote:
> 
> On Thu, Oct 24, 2024 at 06:34:44PM -0400, Frank Li wrote:
> > Some PCIe host bridges require special handling when enabling or disabling
> > PCIe Endpoints. For example, the i.MX95 platform has a lookup table to map
> > Requester IDs to StreamIDs, which are used by the SMMU and MSI controller
> > to identify the source of DMA accesses.
> > 
> > Without this mapping, DMA accesses may target unintended memory, which
> > would corrupt memory or read the wrong data.
> > 
> > Add a host bridge .enable_device() hook the imx6 driver can use to
> > configure the Requester ID to StreamID mapping. The hardware table isn't
> > big enough to map all possible Requester IDs, so this hook may fail if no
> > table space is available. In that case, return failure from
> > pci_enable_device().
> > 
> > It might make more sense to make pci_set_master() decline to enable bus
> > mastering and return failure, but it currently doesn't have a way to return
> > failure.
> > 
> > Signed-off-by: Frank Li <Frank.Li@....com>
> > ---
> > Change from v2 to v3
> > - use Bjorn suggest's commit message.
> > - call disable_device() when error happen.
> > 
> > Change from v1 to v2
> > - move enable(disable)device ops to pci_host_bridge
> > ---
> >  drivers/pci/pci.c   | 23 ++++++++++++++++++++++-
> >  include/linux/pci.h |  2 ++
> >  2 files changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index 7d85c04fbba2a..5e0cb9b6f4d4f 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -2056,6 +2056,7 @@ int __weak pcibios_enable_device(struct pci_dev *dev, int bars)
> >  static int do_pci_enable_device(struct pci_dev *dev, int bars)
> >  {
> >  	int err;
> > +	struct pci_host_bridge *host_bridge;
> >  	struct pci_dev *bridge;
> >  	u16 cmd;
> >  	u8 pin;
> > @@ -2068,9 +2069,16 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
> >  	if (bridge)
> >  		pcie_aspm_powersave_config_link(bridge);
> >  
> > +	host_bridge = pci_find_host_bridge(dev->bus);
> > +	if (host_bridge && host_bridge->enable_device) {
> > +		err = host_bridge->enable_device(host_bridge, dev);
> > +		if (err)
> > +			return err;
> > +	}
> 
> How about wrapping the enable/disable part in a helper?
> 
> 	int pci_host_bridge_enable_device(dev);
> 	void pci_host_bridge_disable_device(dev);
> 
> The definition could be placed in drivers/pci/pci.h as an inline
> function.

What does it bring? I would see the point if there was another user.
But this is very much core infrastructure which doesn't lend itself to
duplication.

Unless you have something in mind?

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ