Re: [PATCH v13 01/25] CXL/PCI: Move CXL DVSEC definitions into uapi/linux/pci_regs.h
From: dan.j.williams
Date: Fri Dec 05 2025 - 23:57:02 EST
Bjorn Helgaas wrote:
> On Fri, Dec 05, 2025 at 04:41:40PM -0800, dan.j.williams@xxxxxxxxx wrote:
> > Bjorn Helgaas wrote:
> > > On Mon, Nov 03, 2025 at 06:09:37PM -0600, Terry Bowman wrote:
> > > > The CXL DVSECs are currently defined in cxl/core/cxlpci.h. These are not
> > > > accessible to other subsystems. Move these to uapi/linux/pci_regs.h.
>
> > > > +#define PCI_DVSEC_HEADER1_LENGTH_MASK __GENMASK(31, 20)
> > >
> > > Looks like a functional duplicate of PCI_DVSEC_HEADER1_LEN().
> > >
> > > Why __GENMASK() instead of GENMASK()? I don't know the purpose of
> > > __GENMASK(), but I see other include/uapi/ files using GENMASK().
> > > Maybe they're wrong?
> > >
> > > Same questions for _BITUL() below.
> >
> > See this commit:
> >
> > 3c7a8e190bc5 uapi: introduce uapi-friendly macros for GENMASK
> >
> > GENMASK() for a long time was not available to uapi headers since uapi
> > headers can only include other include/uapi/ headers, not
> > include/linux/. That commit made some common kernel bitfield helpers
> > finally available to the uapi side of the house.
>
> So are the uses I see here wrong?
>
> git grep "\<GENMASK\|\<BIT\>" include/uapi/
Yes, but the build failure for userspace can be mitigated if it provides
a replacement defintion. For example, the project for CXL
user tooling locally defines:
util/bitmap.h:34:#define BIT(nr) (1UL << (nr))
util/bitmap.h:31:#define GENMASK(h, l) \
...to supplement the missing kernel definitions, but those predated
2023. Paolo solved the problem globally with 3c7a8e190bc5.
Otherwise, userspace projects that do not already locally define
GENMASK() but include uapi/pci_regs.h would start seeing new build
failures when they update kernel headers.