xen/vpci: do not use pci_sanitize_bar_memory for domU
PATCH 1/1 xen/vpci: do not use pci_sanitize_bar_memory for domU
From: Steven Noonan <[email protected]>
This function should only be used for the hardware domain, because it compares addresses against the host e820 map.
--- xen/drivers/vpci/header.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
xen/drivers/vpci/header.c +9 -7
@@ -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; + } } }
Signature · 1 line
2.53.0
Quoted 4 lines · Ariadne Conill
From: Steven Noonan <[email protected]>
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.
Quoted 4 lines
xen/drivers/vpci/header.c +0
-0@@ -394,13 +394,15 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only) }
xen/drivers/vpci/header.c static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only) · line 397
Quoted 10 lines
xen/drivers/vpci/header.c +1
-7} - 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).
xen/drivers/vpci/header.c static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only) · line 405
Quoted 8 lines
xen/drivers/vpci/header.c +8
-0+ 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
Quoted 9 lines · Jan Beulich
Quoted 4 lines · Ariadne Conill
From: Steven Noonan <[email protected]>
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.
Quoted 26 lines
Quoted 4 lines
xen/drivers/vpci/header.c +0
-0@@ -394,13 +394,15 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only) }xen/drivers/vpci/header.c static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only) · line 397
Quoted 10 lines
xen/drivers/vpci/header.c +1
-7} - 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).
xen/drivers/vpci/header.c static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only) · line 405
Quoted 8 lines
xen/drivers/vpci/header.c +8
-0+ 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; + }
Quoted 4 lines
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.