From: sashiko-bot@kernel.org
To: "Srirangan Madhavan" <smadhavan@nvidia.com>
Cc: linux-pci@vger.kernel.org, linux-cxl@vger.kernel.org
Subject: Re: [PATCH v12 12/12] PCI/CXL: Restore CXL state after CXL bus reset
Date: Thu, 10 Sep 2026 07:37:42 +0000 [thread overview]
Message-ID: <20260910073742.907EF1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910070808.1444264-13-smadhavan@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] cxl_reset_bus_function bypasses memory range safety checks and CPU cache invalidation before initiating a bus reset, risking MCEs and system crashes.
- [High] Priority inversion in pci_reset_fn_methods[] bypasses cxl_reset_bus_function, causing CXL state restoration to fail if SBR is already unmasked.
--
commit a0905bda4417fb243d6c3399ed1032ddb3d39e35
Author: Srirangan Madhavan <smadhavan@nvidia.com>
Subject: PCI/CXL: Restore CXL state after CXL bus reset
This commit updates the CXL bus reset path to restore CXL HDM decoder
programming and CXL Device DVSEC protocol enables after a successful CXL
bus reset. It introduces a state restoration function that restores PCI
config state first, ensuring BARs are valid before restoring the cached
CXL state. It also rejects CXL bus reset for multifunction devices and PFs
with enabled VFs.
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 157f06c576e93..a3ba4c28c62bc 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
[ ... ]
> @@ -5054,6 +5057,9 @@ static int cxl_reset_bus_function(struct pci_dev *dev, bool probe)
> pci_write_config_word(bridge, dvsec + PCI_DVSEC_CXL_PORT_CTL,
> reg);
>
> + if (!rc)
> + rc = cxl_restore_state_after_pci_reset(dev);
> +
[Severity: Critical]
This is a pre-existing issue, but does cxl_reset_bus_function() bypass
memory range safety checks and CPU cache invalidation before initiating a
bus reset?
The hardware bus reset is executed in this function (just prior to this
hunk via rc = pci_reset_bus_function()) without any preceding memory range
safety checks or cache invalidation. This bypasses the safety mechanisms
present in the traditional CXL reset path.
While cxl_reset_function() properly invokes cxl_hdm_ranges_prepare() to
verify no memory regions are busy and flush caches,
cxl_reset_bus_function() entirely skips these safety checks before issuing
the reset.
A hardware PCI bus reset instantly clears CXL HDM decoders. If the CXL
backing memory is in active use by the host (e.g., DAX or system RAM),
pulling the memory away can cause Machine Check Exceptions (MCE).
Could this allow a VFIO-assigned VM to crash the host via the sysfs reset
attribute?
[Severity: High]
This isn't a bug introduced by this patch, but does the priority inversion
in pci_reset_fn_methods[] bypass cxl_reset_bus_function() entirely?
The pci_reset_fn_methods[] array defines the fallback priority of reset
mechanisms. The cxl_bus entry is placed after bus:
drivers/pci/pci.c:pci_reset_fn_methods[] = {
...
{ pci_reset_bus_function, .name = "bus" },
{ cxl_reset_bus_function, .name = "cxl_bus" },
};
Placing cxl_bus after bus ensures that if the standard bus reset is
physically possible and unmasked, the CXL-specific wrapper with the state
restoration logic will never run.
If a CXL device's Secondary Bus Reset (SBR) is already unmasked,
pci_reset_bus_function() will successfully probe and execute the reset.
Because it returns 0 on success, the PCI reset core stops iterating and
completely bypasses cxl_reset_bus_function().
As a result, the newly added cxl_restore_state_after_pci_reset() is never
called, leaving the device with unprogrammed CXL HDM decoders.
> pci_dev_reset_iommu_done(dev);
> return rc;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260910070808.1444264-1-smadhavan@nvidia.com?part=12
next prev parent reply other threads:[~2026-09-10 7:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 7:07 [PATCH v12 00/12] PCI/CXL: Add CXL reset support for Type 2 devices Srirangan Madhavan
2026-09-10 7:07 ` [PATCH v12 01/12] cxl: Move HDM decoder programming helpers Srirangan Madhavan
2026-09-10 7:20 ` sashiko-bot
2026-09-11 23:30 ` Jonathan Cameron
2026-09-10 7:07 ` [PATCH v12 02/12] cxl: Make HDM commit helpers available to reset code Srirangan Madhavan
2026-09-10 7:25 ` sashiko-bot
2026-09-10 7:07 ` [PATCH v12 03/12] cxl: Share HDM decoder decode logic Srirangan Madhavan
2026-09-10 7:18 ` sashiko-bot
2026-09-12 0:07 ` Jonathan Cameron
2026-09-10 7:08 ` [PATCH v12 04/12] cxl: Cache decoder settings on PCI devices Srirangan Madhavan
2026-09-10 7:22 ` sashiko-bot
2026-09-12 0:22 ` Jonathan Cameron
2026-09-10 7:08 ` [PATCH v12 05/12] cxl: Cache endpoint decoder settings during PCI enumeration Srirangan Madhavan
2026-09-10 7:25 ` sashiko-bot
2026-09-12 1:03 ` Jonathan Cameron
2026-09-10 7:08 ` [PATCH v12 06/12] cxl: Add CXL Device Reset helper Srirangan Madhavan
2026-09-10 7:20 ` sashiko-bot
2026-09-12 1:26 ` Jonathan Cameron
2026-09-10 7:08 ` [PATCH v12 07/12] cxl: Validate HDM ranges before CXL reset Srirangan Madhavan
2026-09-10 7:22 ` sashiko-bot
2026-09-12 1:33 ` Jonathan Cameron
2026-09-10 7:08 ` [PATCH v12 08/12] PCI/CXL: Reject CXL Reset on multifunction devices Srirangan Madhavan
2026-09-10 7:20 ` sashiko-bot
2026-09-10 7:08 ` [PATCH v12 09/12] cxl: Restore CXL state after PCI reset Srirangan Madhavan
2026-09-10 7:25 ` sashiko-bot
2026-09-12 1:43 ` Jonathan Cameron
2026-09-10 7:08 ` [PATCH v12 10/12] PCI/CXL: Expose CXL Reset as a PCI reset method Srirangan Madhavan
2026-09-10 7:29 ` sashiko-bot
2026-09-10 7:08 ` [PATCH v12 11/12] Documentation/ABI: Document CXL Reset " Srirangan Madhavan
2026-09-10 7:20 ` sashiko-bot
2026-09-10 7:08 ` [PATCH v12 12/12] PCI/CXL: Restore CXL state after CXL bus reset Srirangan Madhavan
2026-09-10 7:37 ` sashiko-bot [this message]
2026-09-10 7:31 ` [PATCH v12 00/12] PCI/CXL: Add CXL reset support for Type 2 devices Srirangan Madhavan
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=20260910073742.907EF1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=smadhavan@nvidia.com \
/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