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

From: mhonap

Date: Wed Sep 16 2026 - 15:25:15 EST


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));
+
if (!cxl->cxlds.reg_map.component_map.hdm_decoder.valid) {
pci_err(pdev, "vfio-cxl: HDM decoder registers not found\n");
ret = -ENODEV;
--
2.25.1