* [PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU
@ 2026-02-24 23:12 Ariadne Conill
2026-02-25 15:44 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: Ariadne Conill @ 2026-02-24 23:12 UTC (permalink / raw)
To: xen-devel
Cc: Ariadne Conill, Roger Pau Monné, Stewart Hildebrand,
Steven Noonan
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>
---
| 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU
2026-02-24 23:12 [PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU Ariadne Conill
@ 2026-02-25 15:44 ` Jan Beulich
2026-03-04 15:32 ` Roger Pau Monné
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2026-02-25 15:44 UTC (permalink / raw)
To: Ariadne Conill
Cc: Roger Pau Monné, Stewart Hildebrand, Steven Noonan,
xen-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU
2026-02-25 15:44 ` Jan Beulich
@ 2026-03-04 15:32 ` Roger Pau Monné
0 siblings, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2026-03-04 15:32 UTC (permalink / raw)
To: Jan Beulich; +Cc: Ariadne Conill, Stewart Hildebrand, Steven Noonan, xen-devel
On Wed, Feb 25, 2026 at 04:44:09PM +0100, Jan Beulich wrote:
> 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.
Well, the usage of pci_check_bar() from modify_bars() is slightly
different: it does get called with the BAR host addresses (not the
guest ones). So the check will work as expected, albeit given a domU
cannot change the BAR host addresses the check is likely redundant,
but not strictly wrong.
Checking against the memory map for domUs would be complicated, as the
guest can play many games with that memory map.
> > --- 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.
You could also introduce an early continue, and leave the check(s)
below applicable to the hardware domain only.
Thanks, Roger.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-04 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 23:12 [PATCH] xen/vpci: do not use pci_sanitize_bar_memory for domU Ariadne Conill
2026-02-25 15:44 ` Jan Beulich
2026-03-04 15:32 ` Roger Pau Monné
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.