RE: [PATCH v5 17/27] vfio/cxl: Own the whole component register BAR

From: Manish Honap

Date: Fri Oct 09 2026 - 02:21:14 EST



> -----Original Message-----
> From: Alex Williamson <alex@xxxxxxxxxxx>
> Sent: Tuesday, September 22, 2026 7:44 AM
> To: Manish Honap <mhonap@xxxxxxxxxx>
> Cc: jgg@xxxxxxxx; Ankit Agrawal <ankita@xxxxxxxxxx>; jic23@xxxxxxxxxx;
> dave.jiang@xxxxxxxxx; alejandro.lucero-palau@xxxxxxx; Srirangan
> Madhavan <smadhavan@xxxxxxxxxx>; corbet@xxxxxxx;
> skhan@xxxxxxxxxxxxxxxxxxx; dave@xxxxxxxxxxxx; alison.schofield@xxxxxxxxx;
> vishal.l.verma@xxxxxxxxx; iweiny@xxxxxxxxxx; ming.li@xxxxxxxxxxxx; Yishai
> Hadas <yishaih@xxxxxxxxxx>; Shameer Kolothum Thodi
> <skolothumtho@xxxxxxxxxx>; kevin.tian@xxxxxxxxx; bhelgaas@xxxxxxxxxx;
> dmatlack@xxxxxxxxxx; kees@xxxxxxxxxx; gustavoars@xxxxxxxxxx; Neo Jia
> <cjia@xxxxxxxxxx>; Krishnakant Jaju <kjaju@xxxxxxxxxx>; Vikram Sethi
> <vsethi@xxxxxxxxxx>; Zhi Wang <zhiw@xxxxxxxxxx>; linux-
> doc@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; kvm@xxxxxxxxxxxxxxx;
> linux-cxl@xxxxxxxxxxxxxxx; linux-pci@xxxxxxxxxxxxxxx; linux-
> kselftest@xxxxxxxxxxxxxxx; linux-hardening@xxxxxxxxxxxxxxx; alex@xxxxxxxxxxx
> Subject: Re: [PATCH v5 17/27] vfio/cxl: Own the whole component register
> BAR
>
> External email: Use caution opening links or attachments
>
>
> On Thu, 17 Sep 2026 00:05:30 +0530
> <mhonap@xxxxxxxxxx> wrote:
>
> > From: Manish Honap <mhonap@xxxxxxxxxx>
> >
> > devm_cxl_probe_mem() maps the component registers through the CXL
> > core, which by default claims each HDM and RAS sub-block. That
> > collides with the full-BAR request vfio-pci-core makes when the guest opens
> the device.
> >
> > After the component registers are discovered, declare the containing
> > BAR owned with cxl_reg_map_add_owned_resource(). The core then
> > ioremaps the sub-blocks without requesting them, so vfio-pci-core owns
> > the whole BAR and the requests do not collide.
> >
> > Assisted-by: LLM
> > Signed-off-by: Manish Honap <mhonap@xxxxxxxxxx>
> > ---
> > drivers/vfio/pci/cxl/vfio_cxl_core.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > b/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > index 0d92e6a409c1..5c8a63833a43 100644
> > --- a/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > +++ b/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > @@ -89,6 +89,15 @@ static int vfio_cxl_init_device(struct
> vfio_pci_core_device *vdev)
> > goto err;
> > }
> >
> > + /*
> > + * vfio-pci-core requests the whole component-register BAR when the
> > + * guest opens the device. Declare that BAR owned so the CXL core
> > + * ioremaps the HDM and RAS sub-blocks without claiming them, and the
> > + * full-BAR request does not collide.
> > + */
> > + cxl_reg_map_add_owned_resource(&cxl->cxlds.reg_map,
> > + pci_resource_n(pdev,
> > + pdev->hdm->hdm_bar));
> > +
>
> The result of this operation is setting a singleton "owned" pointer to this
> resource, whereas the name suggests it's adding the resource to some set of
> owned resources. Is "set" really the more idiomatic verb for this than "add"?
> Thanks,
>

Yes. I will rename it to cxl_reg_map_set_owned_resource() in v6.

> Alex
>
> > if (!cxl->cxlds.reg_map.component_map.hdm_decoder.valid) {
> > pci_err(pdev, "vfio-cxl: HDM decoder registers not found\n");
> > ret = -ENODEV;