RE: [PATCH v4 10/27] vfio/cxl: Reject unsupported decoder topologies at bind
From: Manish Honap
Date: Thu Sep 03 2026 - 06:29:00 EST
> -----Original Message-----
> From: Alex Williamson <alex@xxxxxxxxxxx>
> Sent: Friday, August 28, 2026 2:28 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 v4 10/27] vfio/cxl: Reject unsupported decoder topologies
> at bind
>
> External email: Use caution opening links or attachments
>
>
> On Thu, 13 Aug 2026 15:06:14 +0530
> <mhonap@xxxxxxxxxx> wrote:
>
> > From: Manish Honap <mhonap@xxxxxxxxxx>
> >
> > The guest drives a single virtual decoder whose memory maps 1:1, so a
> > device with more than one HDM decoder, or an interleaved one, cannot
> > be represented. Turn that assumption into an explicit refusal at bind
> > rather than a silent misprogramming later.
> >
> > Signed-off-by: Manish Honap <mhonap@xxxxxxxxxx>
> > ---
> > drivers/vfio/pci/cxl/vfio_cxl_core.c | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > b/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > index 125e11354a46..7edc53b25576 100644
> > --- a/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > +++ b/drivers/vfio/pci/cxl/vfio_cxl_core.c
> > @@ -36,10 +36,30 @@ static int vfio_cxl_init_device(struct
> vfio_pci_core_device *vdev)
> > if (!pdev->hdm)
> > return -EPROBE_DEFER;
> >
> > + /* The guest drives one virtual decoder; multiple are unsupported. */
> > + if (pdev->hdm->decoder_count != 1)
> > + return -EOPNOTSUPP;
> > +
> > hdm_size = range_len(&pdev->hdm->settings[0].hpa_range);
> > if (!hdm_size)
> > return -ENXIO;
> >
> > + /* Interleaved decoders are unsupported. */
> > + if (pdev->hdm->settings[0].interleave_ways != 1)
> > + return -EOPNOTSUPP;
> > +
> > + /*
> > + * The guest drives resets through the CXL Device DVSEC and polls the
> > + * shadow for completion. If the host cannot service a function-scoped
> > + * CXL reset (no reset DVSEC, a multifunction device, or no HDM reset
> > + * support), that guest request could never complete, so refuse the
> > + * device rather than advertise a reset the guest would poll on forever.
> > + */
> > + if (!cxl_reset_capable(pdev)) {
> > + pci_err(pdev, "vfio-cxl: Unsupported device: host cannot service a
> CXL reset request\n");
> > + return -EOPNOTSUPP;
> > + }
>
> Why does this particular error deserve such a high priority log while we silently
> fail the other two cases added here?
>
> These don't seem particularly noteworthy to split into a separate patch versus
> rolling them into the previous. I'd probably also group the easily testable
> EOPNOTSUPP errors before we actually start evaluating things like the
> hdm_size. Thanks,
>
Okay, I will fold this into the previous patch and make the log levels consistent.
I will also re-order the EOPNOTSUPP checks before evaluating hdm_size as suggested.
Manish
> Alex
>
> > +
> > dvsec = pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_CXL,
> > PCI_DVSEC_CXL_DEVICE);
> > serial = pci_get_dsn(pdev);