> -----Original Message----- > From: Alex Williamson <[email protected]> > Sent: Tuesday, September 22, 2026 7:45 AM > To: Manish Honap <[email protected]> > Cc: [email protected]; Ankit Agrawal <[email protected]>; [email protected]; > [email protected]; [email protected]; Srirangan > Madhavan <[email protected]>; [email protected]; > [email protected]; [email protected]; [email protected]; > [email protected]; [email protected]; [email protected]; Yishai > Hadas <[email protected]>; Shameer Kolothum Thodi > <[email protected]>; [email protected]; [email protected]; > [email protected]; [email protected]; [email protected]; Neo Jia > <[email protected]>; Krishnakant Jaju <[email protected]>; Vikram Sethi > <[email protected]>; Zhi Wang <[email protected]>; linux- > [email protected]; [email protected]; [email protected]; > [email protected]; [email protected]; linux- > [email protected]; [email protected]; [email protected] > Subject: Re: [PATCH v5 11/27] vfio/pci: Virtualize the CXL DVSEC in > vfio_pci_config.c > > External email: Use caution opening links or attachments > > > On Thu, 17 Sep 2026 00:05:24 +0530 > <[email protected]> wrote: > > +/* Virtualize the CXL DVSEC so a guest cannot reprogram the device > > +through it. */ static int vfio_cxl_dvsec_init(struct > > +vfio_pci_core_device *vdev) { > > + struct pci_dev *pdev = vdev->pdev; > > + u32 dword; > > + u16 dvsec; > > + int len, ret; > > + > > + dvsec = pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_CXL, > > + PCI_DVSEC_CXL_DEVICE); > > + if (!dvsec) > > + return 0; > > + > > + ret = pci_read_config_dword(pdev, dvsec + PCI_DVSEC_HEADER1, > &dword); > > + if (ret) > > + return pcibios_err_to_errno(ret); > > + len = PCI_DVSEC_HEADER1_LEN(dword); > > + > > + /* > > + * The virtualization writes fixed DVSEC offsets up to Status2 (the > > reset > > + * doorbell stamps it). A device that reports a shorter DVSEC is not a > > + * usable Type-2 function; leave it as plain vfio-pci rather than > > index the > > + * device-length-sized perm allocation past its end. > > + */ > > + if (len < PCI_DVSEC_CXL_STATUS2 + 2) > > + return 0; > > + > > + vdev->cxl_perm = kmalloc_obj(struct perm_bits, > GFP_KERNEL_ACCOUNT); > > + if (!vdev->cxl_perm) > > + return -ENOMEM; > > + > > + ret = init_cxl_dvsec_perm(vdev->cxl_perm, len); > > + if (ret) { > > + kfree(vdev->cxl_perm); > > + vdev->cxl_perm = NULL; > > + return ret; > > + } > > + > > + vdev->cxl_dvsec = dvsec; > > + vdev->cxl_dvsec_len = len; > > cxl_dvsec_len is never used here or elsewhere in the series. Thanks,
Yes, I will remove this in v6. > > Alex > > > + > > + return 0; > > +} > > +

