[PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU

Ariadne Conill posted 1 patch 6 days, 2 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260224231235.6277-1-ariadne@ariadne.space
xen/drivers/vpci/header.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
[PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU
Posted by Ariadne Conill 6 days, 2 hours ago
From: Steven Noonan <steven@edera.dev>

This function should only be used for the hardware domain, because it
compares addresses against the host e820 map.

Signed-off-by: Steven Noonan <steven@edera.dev>
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
---
 xen/drivers/vpci/header.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 852dfd8ae3..1f930b2a1f 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -394,13 +394,15 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             }
         }
 
-        rc = pci_sanitize_bar_memory(bar->mem);
-        if ( rc )
-        {
-            gprintk(XENLOG_WARNING,
-                    "%pp: failed to sanitize BAR#%u memory: %d\n",
-                    &pdev->sbdf, i, rc);
-            return rc;
+        if (is_hardware_domain(pdev->domain)) {
+            rc = pci_sanitize_bar_memory(mem);
+            if ( rc )
+            {
+                gprintk(XENLOG_WARNING,
+                        "%pp: failed to sanitize BAR#%u memory: %d\n",
+                        &pdev->sbdf, i, rc);
+                return rc;
+            }
         }
     }
 
-- 
2.53.0
Re: [PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU
Posted by Jan Beulich 5 days, 9 hours ago
On 25.02.2026 00:12, Ariadne Conill wrote:
> From: Steven Noonan <steven@edera.dev>
> 
> This function should only be used for the hardware domain, because it
> compares addresses against the host e820 map.

The same is true for its sibling function, pci_check_bar(). For both the
question is whether skipping is the right thing, or whether for DomU-s
checking against their memory map is what is needed instead.

> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -394,13 +394,15 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
>              }
>          }
>  
> -        rc = pci_sanitize_bar_memory(bar->mem);
> -        if ( rc )
> -        {
> -            gprintk(XENLOG_WARNING,
> -                    "%pp: failed to sanitize BAR#%u memory: %d\n",
> -                    &pdev->sbdf, i, rc);
> -            return rc;
> +        if (is_hardware_domain(pdev->domain)) {

Nit: Style (see surrounding code you alter).

> +            rc = pci_sanitize_bar_memory(mem);
> +            if ( rc )
> +            {
> +                gprintk(XENLOG_WARNING,
> +                        "%pp: failed to sanitize BAR#%u memory: %d\n",
> +                        &pdev->sbdf, i, rc);
> +                return rc;
> +            }

To avoid the need for re-indentation here (reducing churn) you may want
to leverage that rc is 0 ahead of the call to pci_sanitize_bar_memory().
I.e. you could make just the call conditional, without touching anything
else.

Jan