Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: mhonap@nvidia.com
Cc: kvm@vger.kernel.org, linux-cxl@vger.kernel.org
Subject: Re: [PATCH 2/2] vfio/pci: Make the CXL DVSEC read-only
Date: Wed, 02 Dec 2026 09:22:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-245290@kernel.org> (raw)
In-Reply-To: <20261202091105.1674275-3-mhonap@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] vfio/pci: vfio_pci_cxl_dvsec() leaves single-capability CXL
  DVSECs writable
--

commit 19e2a95ba8c72061f8495872d7deca8225c841c5
Author: Manish Honap <mhonap@nvidia.com>

vfio/pci: Make the CXL DVSEC read-only

This commit locates the PCIe DVSEC for CXL Devices capability during
config space initialization and switches its permissions to read-only.

> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
> index dd0b899fbdfdf..2bc0c7cbc4b7b 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -1746,6 +1746,23 @@ static int vfio_ecap_init(struct vfio_pci_core_device *vdev)
>  	return 0;
>  }
>  
> +static u16 vfio_pci_cxl_dvsec(struct pci_dev *pdev)
> +{
> +	u16 dvsec, cap;
> +
> +	dvsec = pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_CXL,
> +					  PCI_DVSEC_CXL_DEVICE);
> +	if (!dvsec ||
> +	    pci_read_config_word(pdev, dvsec + PCI_DVSEC_CXL_CAP, &cap))
> +		return 0;
> +
> +	if (!(cap & PCI_DVSEC_CXL_CACHE_CAPABLE) ||
> +	    !(cap & PCI_DVSEC_CXL_MEM_CAPABLE))
> +		return 0;

[Severity: High]
Does vfio_pci_cxl_dvsec() leave PCI_DVSEC_CXL_DEVICE writable on CXL
functions that advertise only CXL.mem or only CXL.cache?

Using || requires both capability bits to be set, so Type 3 (CXL.mem-only)
and Type 1 (CXL.cache-only) functions return 0 and keep
vfio_raw_config_write(), allowing userspace to modify Mem_Enable or
Cache_Enable, trigger an uncoordinated CXL reset, or set Config Lock.
Should this check !(cap & (PCI_DVSEC_CXL_CACHE_CAPABLE |
PCI_DVSEC_CXL_MEM_CAPABLE)) instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202091105.1674275-1-mhonap@nvidia.com?part=2

      reply	other threads:[~2026-12-02  9:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:11 [PATCH 0/2] vfio/pci: CXL DVSEC config space fixes mhonap
2026-12-02  9:11 ` [PATCH 1/2] vfio/pci: Find the start of an abutting extended capability mhonap
2026-12-02  9:21   ` sashiko-bot
2026-12-02  9:11 ` [PATCH 2/2] vfio/pci: Make the CXL DVSEC read-only mhonap
2026-12-02  9:22   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-245290@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=mhonap@nvidia.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox