Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Szymon Durawa" <szymon.durawa@linux.intel.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v8 8/8] PCI: vmd: Workaround for hardwired BUS1 bus number
Date: Mon, 21 Sep 2026 14:34:02 +0000	[thread overview]
Message-ID: <20260921143403.055851F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921164316.3860312-9-szymon.durawa@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci: vmd: fake root bus number 0x80 causes resource conflict and breaks hotplug
--

commit 96fa114ac906af61b74b8a37fc6def3f417dbf5b
Author: Szymon Durawa <szymon.durawa@linux.intel.com>

    PCI: vmd: Workaround for hardwired BUS1 bus number

This commit implements a workaround for the VMD BUS1 root bus number being
fixed to 0x80 in hardware. It overrides the root bus number in vmd_create_bus()
and attempts to handle the translation during config accesses and ACPI matching.

> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index 51b8c2d9b7f0b..91c5b02bf91d1 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -467,10 +467,23 @@ static unsigned int vmd_bus_to_ecam(struct vmd_dev *vmd, unsigned int busnr)
>  static void __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
>  				  unsigned int devfn, int reg, int len)
>  {
[ ... ]
> +	if (vmd->bus1_rootbus && bus->number == VMD_PRIMARY_BUS1)
> +		bus_number = vmd->busn_start[VMD_BUS_1];
> +	else
> +		bus_number = bus->number;

[Severity: High]
Does this break configuration space accesses for dynamically assigned downstream
bus numbers?

During dynamic bus assignment like hotplug or SR-IOV on root ports behind
VMD BUS1, the PCI core sees 0x80 as the parent bus number and assigns child
buses starting from 0x81 instead of the physical downstream window (e.g., 0xE1).

When accessing these dynamically assigned buses, this code falls through to the
untranslated bus->number (e.g., 0x81). It then subtracts the physical ECAM
start (e.g., 0xE0) from 0x81, leading to a massive unsigned underflow
(0xFFFFFFA1).

This out-of-bounds offset will cause vmd_cfg_addr() to return NULL, silently
breaking all configuration accesses.

[ ... ]
> @@ -1188,6 +1223,7 @@ static int vmd_create_bus(struct vmd_dev *vmd, enum vmd_rootbus bus_number,
>  			  struct pci_sysdata *sd, resource_size_t *offset,
>  			  bool vmd_in_guest, u8 primary)
>  {
[ ... ]
> +	/*
> +	 * Workaround: set VMD_BUS_1's bus number to VMD_PRIMARY_BUS1 so it
> +	 * matches vmd->bus[VMD_BUS_1]->primary and bypasses bus number
> +	 * reconfiguration.
> +	 */
> +	if (bus_number == VMD_BUS_1 && vmd->bus1_rootbus)
> +		root_busnr = VMD_PRIMARY_BUS1;

[Severity: High]
Does overriding the root bus number to 0x80 here initiate a resource conflict
that breaks the dynamic allocator's base range?

By overriding the BUS1 root bus number to 0x80 instead of its physical ECAM
base (e.g., 0xE1), pci_register_host_bridge() requests the bus resource range
[0x80-0xFF]. This overlaps with BUS0's physical range (e.g., [0xE0-0xF0]).

pci_bus_insert_busn_res() detects this conflict and fails to attach the bus
resource of BUS1 to the domain, breaking hotplug and SR-IOV completely on
VMD BUS1.

> +	else
> +		root_busnr = vmd->busn_start[bus_number];
> +
> +	vmd_bus = pci_create_root_bus(&vmd->dev->dev, root_busnr, &vmd_ops, sd,
>  				      &resources);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921164316.3860312-1-szymon.durawa@linux.intel.com?part=8

  reply	other threads:[~2026-09-21 14:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 16:43 [PATCH v8 0/8] VMD add second root bus support Szymon Durawa
2026-09-21 16:43 ` [PATCH v8 1/8] PCI: vmd: Add vmd_bus_enumeration() helper function Szymon Durawa
2026-09-21 14:25   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 2/8] PCI: vmd: Add vmd_configure_cfgbar() " Szymon Durawa
2026-09-21 14:21   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 3/8] PCI: vmd: Add vmd_configure_membar() and vmd_configure_membar1_membar2() Szymon Durawa
2026-09-21 14:25   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 4/8] PCI: vmd: Add vmd_create_bus() Szymon Durawa
2026-09-21 14:27   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 5/8] PCI: vmd: Replace hardcoded values with enum and defines Szymon Durawa
2026-09-21 14:26   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 6/8] PCI: vmd: Convert bus and busn_start to an array Szymon Durawa
2026-09-21 14:26   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 7/8] PCI: vmd: Add support for second rootbus under VMD Szymon Durawa
2026-09-21 14:32   ` sashiko-bot
2026-09-21 16:43 ` [PATCH v8 8/8] PCI: vmd: Workaround for hardwired BUS1 bus number Szymon Durawa
2026-09-21 14:34   ` sashiko-bot [this message]
2026-09-22 15:49 ` [PATCH v8 0/8] VMD add second root bus support Manivannan Sadhasivam

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=20260921143403.055851F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=szymon.durawa@linux.intel.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