[PATCH v2] xen/pci: prevent infinite loop for faulty SR-IOV cards

Frediano Ziglio posted 1 patch 3 days, 23 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/CAHt6W4e1XOoqO-W0O1mEU4UCr._5Fik=J9bRGQQPeNL3YLQSyV7._5Fw@mail.gmail.com
xen/drivers/passthrough/pci.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2] xen/pci: prevent infinite loop for faulty SR-IOV cards
Posted by Frediano Ziglio 3 days, 23 hours ago
If a SR-IOV card presents an I/O space inside a BAR the
code will continue to loop on the same card.
This is due to the missing increment of the cycle variable.

Fixes: a1a6d59862f4 ("pci: split code to size BARs from pci_add_device")
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
Changes since v1:
- add Fixes comment
---
 xen/drivers/passthrough/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 3edcfa8a04..52c22fa50c 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -746,6 +746,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
                     printk(XENLOG_WARNING
                            "SR-IOV device %pp with vf BAR%u in IO space\n",
                            &pdev->sbdf, i);
+                    ++i;
                     continue;
                 }
                 ret = pci_size_mem_bar(pdev->sbdf, idx, NULL,
-- 
2.43.0
Re: [PATCH v2 for-4.21?] xen/pci: prevent infinite loop for faulty SR-IOV cards
Posted by Jan Beulich 2 days, 10 hours ago
On 25.10.2025 22:09, Frediano Ziglio wrote:
> If a SR-IOV card presents an I/O space inside a BAR the
> code will continue to loop on the same card.
> This is due to the missing increment of the cycle variable.
> 
> Fixes: a1a6d59862f4 ("pci: split code to size BARs from pci_add_device")
> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

I have to admit though that "faulty" to me suggests more like active misbehavior
than the presenting of a bogus BAR. But maybe that's just me ...

Oleksii, thoughts towards 4.21?

Jan
Re: [PATCH v2 for-4.21?] xen/pci: prevent infinite loop for faulty SR-IOV cards
Posted by Oleksii Kurochko 2 days, 5 hours ago
On 10/27/25 10:07 AM, Jan Beulich wrote:
> On 25.10.2025 22:09, Frediano Ziglio wrote:
>> If a SR-IOV card presents an I/O space inside a BAR the
>> code will continue to loop on the same card.
>> This is due to the missing increment of the cycle variable.
>>
>> Fixes: a1a6d59862f4 ("pci: split code to size BARs from pci_add_device")
>> Signed-off-by: Frediano Ziglio<frediano.ziglio@cloud.com>
> Reviewed-by: Jan Beulich<jbeulich@suse.com>
>
> I have to admit though that "faulty" to me suggests more like active misbehavior
> than the presenting of a bogus BAR. But maybe that's just me ...
>
> Oleksii, thoughts towards 4.21?

Lets take it to 4.21:
  Release-Acked-By: Oleksii Kurochko<oleksii.kurochko@gmail.com>

Thanks.

~ Oleksii