From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Wei Wang <wei.w.wang@hotmail.com>
Cc: bhelgaas@google.com, jgg@nvidia.com, jic23@kernel.org,
error27@gmail.com, kwilczynski@kernel.org,
rdunlap@infradead.org, akpm@linux-foundation.org, bp@alien8.de,
alex@shazbot.org, kevin.tian@intel.com,
manivannan.sadhasivam@oss.qualcomm.com,
LKML <linux-kernel@vger.kernel.org>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH v9 1/6] PCI: Validate ACS control bits against device-specific ACS capabilities
Date: Thu, 3 Sep 2026 14:07:43 +0300 (EEST) [thread overview]
Message-ID: <7cab6f02-d557-abcf-63a8-28db43504acd@linux.intel.com> (raw)
In-Reply-To: <SI2PR01MB43931558B27C956BDBDCE0C6DCB62@SI2PR01MB4393.apcprd01.prod.exchangelabs.com>
On Thu, 3 Sep 2026, Wei Wang wrote:
> The ACS control validation used the kernel's full set of ACS control bits,
> which allowed users to request ACS features that the device does not
> support. Because hardware silently ignores these unsupported bits, users
> have no indication that their config_acs= request was partially
> ineffective.
>
> Validate the requested ACS control bits against dev->acs_capabilities so
> that only device-supported ACS controls are accepted. Mask the capability
> with GENMASK_U16(6, 0) to select only the currently defined ACS control
> bits (0-6). Higher bits in the capability structure (e.g. the egress
> control vector size in bits 8-15) do not correspond to control bits in
> the ACS control register. Add a debug message to report which unsupported
> bits were ignored.
>
> __pci_config_acs() is also called from disable_acs_redir_param(), which
> passes a hardcoded acs_mask (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC) that
> does not need validation. Gate the new check on !acs_mask so it only
> fires for the config_acs_param path, which always invokes
> __pci_config_acs() with acs_mask == 0 and builds the actual mask from
> user input.
>
> Also move the check after the device is matched, since the ctrl bits apply
> only to the matched device.
>
> Signed-off-by: Wei Wang <wei.w.wang@hotmail.com>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/pci/pci.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index b2879a6be5f8..2af679111a9b 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -910,6 +910,7 @@ struct pci_acs {
> static void __pci_config_acs(struct pci_dev *dev, struct pci_acs *caps,
> const char *p, const u16 acs_mask, const u16 acs_flags)
> {
> + u16 valid_ctrl = dev->acs_capabilities & GENMASK_U16(6, 0);
This looks a step backwards.
These bits are surely named so this mask should be a composite of those
define names, either done here or through another define (likely the
latter is better).
> u16 flags = acs_flags;
> u16 mask = acs_mask;
> char *delimit;
> @@ -955,12 +956,6 @@ static void __pci_config_acs(struct pci_dev *dev, struct pci_acs *caps,
> }
> }
>
> - if (mask & ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | PCI_ACS_CR |
> - PCI_ACS_UF | PCI_ACS_EC | PCI_ACS_DT)) {
> - pci_err(dev, "Invalid ACS flags specified\n");
> - return;
> - }
> -
> ret = pci_dev_str_match(dev, p, &p);
> if (ret < 0) {
> pr_warn_once("PCI: Can't parse ACS command line parameter\n");
> @@ -983,6 +978,13 @@ static void __pci_config_acs(struct pci_dev *dev, struct pci_acs *caps,
> if (!pci_dev_specific_disable_acs_redir(dev))
> return;
>
> + if (!acs_mask && (mask & ~valid_ctrl)) {
> + pci_dbg(dev, "Ignoring unsupported ACS bits: %#06x\n",
> + mask & ~valid_ctrl);
> + mask &= valid_ctrl;
> + flags &= valid_ctrl;
> + }
> +
> pci_dbg(dev, "ACS mask = %#06x\n", mask);
> pci_dbg(dev, "ACS flags = %#06x\n", flags);
> pci_dbg(dev, "ACS control = %#06x\n", caps->ctrl);
>
--
i.
next prev parent reply other threads:[~2026-09-03 11:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 3:46 [PATCH v9 0/6] PCI: Add support for ACS Enhanced Capability Wei Wang
2026-09-03 3:46 ` [PATCH v9 1/6] PCI: Validate ACS control bits against device-specific ACS capabilities Wei Wang
2026-09-03 4:01 ` sashiko-bot
2026-09-03 11:07 ` Ilpo Järvinen [this message]
2026-09-03 12:51 ` Wei Wang
2026-09-03 3:46 ` [PATCH v9 2/6] Documentation/kernel-parameters: Add multi-device config_acs example Wei Wang
2026-09-03 4:06 ` sashiko-bot
2026-09-03 3:46 ` [PATCH v9 3/6] PCI: Consolidate delimiter handling into pci_dev_str_match() Wei Wang
2026-09-03 4:15 ` sashiko-bot
2026-09-03 3:46 ` [PATCH v9 4/6] PCI: Refactor disable_acs_redir and config_acs param handling Wei Wang
2026-09-03 4:26 ` sashiko-bot
2026-09-03 12:23 ` Wei Wang
2026-09-03 3:46 ` [PATCH v9 5/6] PCI: Enable the enhanced ACS controls introduced by PCI_ACS_ECAP Wei Wang
2026-09-03 4:39 ` sashiko-bot
2026-09-03 3:46 ` [PATCH v9 6/6] PCI: Add the enhanced ACS controls check to pci_acs_flags_enabled() Wei Wang
2026-09-03 4:44 ` sashiko-bot
2026-09-03 11:09 ` Ilpo Järvinen
2026-09-03 12:46 ` Wei Wang
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=7cab6f02-d557-abcf-63a8-28db43504acd@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=error27@gmail.com \
--cc=jgg@nvidia.com \
--cc=jic23@kernel.org \
--cc=kevin.tian@intel.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
--cc=rdunlap@infradead.org \
--cc=wei.w.wang@hotmail.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