From: sashiko-bot@kernel.org
To: "Nikola Prica" <nikprica@amd.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2] PCI: Accept AtomicOps already enabled by the hypervisor
Date: Mon, 07 Sep 2026 16:15:45 +0000 [thread overview]
Message-ID: <20260907161546.5F3471F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907161701.454364-1-nikprica@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Bypassing the cap_mask capability check blindly assumes all requested PCIe AtomicOp sizes are supported, risking Unsupported Request (UR) errors.
--
commit 23f7770048aa6bf9d34e0cd8e0687398f5697661
Author: Nikola Prica <nikola.prica@amd.com>
PCI: Accept AtomicOps already enabled by the hypervisor
This patch modifies pci_enable_atomic_ops_to_root() to support passthrough
guests in headless topologies where no root port is visible. If the hypervisor
has already set PCI_EXP_DEVCTL2_ATOMIC_REQ on the device, it treats AtomicOps
as enabled and returns success instead of failing the topology walk.
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index b2879a6be5f80..62729ade496fc 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3769,8 +3769,18 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)
> }
>
> root = pcie_find_root_port(dev);
> - if (!root)
> + if (!root) {
> + /*
> + * A hypervisor may expose a headless topology with no
> + * visible root port. If it has already set AtomicOp
> + * Requester Enable, there is nothing more to do.
> + */
> + pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl2);
> + if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ)
> + return 0;
[Severity: High]
Does unconditionally returning success here bypass the capability mask
validation?
Guest drivers (e.g., bnxt_re, amdgpu, or vfio) call
pci_enable_atomic_ops_to_root() passing a specific cap_mask to probe whether
certain atomic sizes (e.g., 64-bit or 128-bit) are supported by the routing
topology. By returning early, we skip the cap_mask validation against the
root port's DEVCAP2 register that typically happens right after this check.
If the physical root port only supports 32-bit atomics but the driver
believes 64-bit sizes are supported due to this return, could this result in
PCIe Unsupported Request (UR) errors and potentially trigger fatal Advanced
Error Reporting (AER) events that crash the device or VM?
> +
> return -EINVAL;
> + }
>
> pcie_capability_read_dword(root, PCI_EXP_DEVCAP2, &cap);
> if ((cap & cap_mask) != cap_mask)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907161701.454364-1-nikprica@amd.com?part=1
next prev parent reply other threads:[~2026-09-07 16:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 12:12 [PATCH] PCI: Accept AtomicOps already enabled by the hypervisor Nikola Prica
2026-09-03 12:09 ` Christian König
2026-09-03 12:12 ` sashiko-bot
2026-09-07 15:59 ` Prica, Nikola
2026-09-07 16:17 ` [PATCH v2] " Nikola Prica
2026-09-07 16:15 ` sashiko-bot [this message]
2026-09-07 18:23 ` Prica, Nikola
2026-09-08 8:47 ` Christian König
2026-09-11 14:09 ` Prica, Nikola
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=20260907161546.5F3471F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=nikprica@amd.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