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: <ZzYq2GIUoD2kkUyK@wunner.de>
Date: Thu, 14 Nov 2024 17:52:40 +0100
From: Lukas Wunner <lukas@...ner.de>
To: "Bowman, Terry" <terry.bowman@....com>
Cc: linux-cxl@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-pci@...r.kernel.org, nifan.cxl@...il.com, ming4.li@...el.com,
	dave@...olabs.net, jonathan.cameron@...wei.com,
	dave.jiang@...el.com, alison.schofield@...el.com,
	vishal.l.verma@...el.com, dan.j.williams@...el.com,
	bhelgaas@...gle.com, mahesh@...ux.ibm.com, ira.weiny@...el.com,
	oohall@...il.com, Benjamin.Cheatham@....com, rrichter@....com,
	nathan.fontenot@....com, Smita.KoralahalliChannabasappa@....com
Subject: Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions
 pcie_is_cxl() and pcie_is_cxl_port()

On Thu, Nov 14, 2024 at 10:45:39AM -0600, Bowman, Terry wrote:
> On 11/14/2024 9:45 AM, Lukas Wunner wrote:
> > On Wed, Nov 13, 2024 at 03:54:17PM -0600, Terry Bowman wrote:
> > > --- a/drivers/pci/pci.c
> > > +++ b/drivers/pci/pci.c
> > > @@ -5038,6 +5038,20 @@ static u16 cxl_port_dvsec(struct pci_dev *dev)
> > >  					 PCI_DVSEC_CXL_PORT);
> > >  }
> > >  
> > > +bool pcie_is_cxl_port(struct pci_dev *dev)
> > > +{
> > > +	if (!pcie_is_cxl(dev))
> > > +		return false;
> > > +
> > > +	if ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
> > > +	    (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
> > > +	    (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM))
> > > +		return false;
> > > +
> > > +	return cxl_port_dvsec(dev);
> > > +}
> > > +EXPORT_SYMBOL_GPL(pcie_is_cxl_port);
> > 
> > The "!pcie_is_cxl(dev)" check at the top of the function is identical
> > to the return value "cxl_port_dvsec(dev)".  This looks redundant.
> > However one cannot call pci_pcie_type() without first checking
> > pci_is_pcie().  So I'm wondering if the "!pcie_is_cxl(dev)" check
> > is actually erroneous and supposed to be "!pci_is_pcie(dev)"?
> > That would make more sense to me.
> 
> I see pcie_is_cxl(dev) is different than cxl_port_dvsec(dev).
> They check different DVSECs.

Ah, sorry, I missed that.

> CXL flexbus DVSEC presence is cached in pci_dev::is_cxl and returned by
> pcie_is_cxl(). This is used for indicating CXL device.
> 
> cxl_port_dvsec(dev) returns boolean based on presence of CXL port DVSEC to 
> indicate a CXL port device.
> 
> I don't believe they are redundant if you consider you can have a CXL
> device that 
> is not a CXL port device.

Can you have a CXL port that is not a CXL device?

If not, it would seem to me that checking for Flexbus DVSEC presence
*is* redundant.  Or do you anticipate broken devices which lack the
Flexbus DVSEC and that you explicitly want to exclude?

Thanks,

Lukas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ