From: sashiko-bot@kernel.org
To: "Nikola Prica" <nikprica@amd.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v3] PCI: Accept AtomicOps already enabled by the hypervisor
Date: Fri, 18 Sep 2026 09:28:05 +0000 [thread overview]
Message-ID: <20260918092805.DF2361F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918092857.648810-1-nikprica@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci: atomic capabilities check bypass in headless topologies
--
commit 7a2c6321c34255d72f250ecd35fa5e1846785e21
Author: Nikola Prica <nikola.prica@amd.com>
PCI: Accept AtomicOps already enabled by the hypervisor
In passthrough guests without a visible Root Port, this commit allows
pci_enable_atomic_ops_to_root() to return success if AtomicOps are already
enabled by the hypervisor.
> 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 this bypass the cap_mask size verification in headless topologies?
pci_enable_atomic_ops_to_root() requires a cap_mask parameter (e.g.,
PCI_EXP_DEVCAP2_ATOMIC_COMP64) to verify that the physical Completer supports
the specific atomic sizes required by the driver.
In the newly added headless topology path (!root), the function checks if the
PCI_EXP_DEVCTL2_ATOMIC_REQ bit is already set on the endpoint. If the bit is
set, it returns 0 (success), completely discarding the caller's cap_mask size
requirements.
The ATOMIC_REQ flag is merely a boolean enable bit for initiating atomics; it
does not guarantee that the physical Completer supports the specific sizes
requested in cap_mask.
If a hypervisor or host enables Atomics for 32-bit sizes, setting ATOMIC_REQ,
but the guest driver requires 64-bit or 128-bit Atomics, this function will
falsely return success. The guest driver will then issue unsupported 64/128-bit
Atomics, which the physical hardware will reject with an Unsupported Request
(UR) fault, potentially triggering an AER and crashing the system.
> +
> return -EINVAL;
> + }
>
> pcie_capability_read_dword(root, PCI_EXP_DEVCAP2, &cap);
> if ((cap & cap_mask) != cap_mask)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260918092857.648810-1-nikprica@amd.com?part=1
next prev parent reply other threads:[~2026-09-18 9:28 UTC|newest]
Thread overview: 23+ 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
2026-09-07 18:23 ` Prica, Nikola
2026-09-08 8:47 ` Christian König
2026-09-11 14:09 ` Prica, Nikola
2026-09-14 13:41 ` Gerd Bayer
2026-09-14 13:54 ` Christian König
2026-09-18 9:07 ` Prica, Nikola
2026-09-18 9:28 ` [PATCH v3] " Nikola Prica
2026-09-18 9:28 ` sashiko-bot [this message]
2026-09-18 12:07 ` Christian König
2026-09-18 17:07 ` Bjorn Helgaas
2026-09-21 11:04 ` Prica, Nikola
2026-09-21 11:05 ` Prica, Nikola
2026-09-21 11:19 ` [PATCH v4] " Nikola Prica
2026-09-21 11:13 ` sashiko-bot
2026-10-01 16:23 ` Bjorn Helgaas
2026-09-21 11:58 ` [PATCH v3] " Christian König
2026-09-21 12:12 ` Thorsten Leemhuis
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=20260918092805.DF2361F000FF@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