File 5d80ea13-vpci-honor-read-only-devices.patch of Package xen.13549
# Commit 79f9ba78380fb3f4bf509e5c726c6cdd76e00c4f
# Date 2019-09-17 16:13:39 +0200
# Author Roger Pau Monné <roger.pau@citrix.com>
# Committer Jan Beulich <jbeulich@suse.com>
vpci: honor read-only devices
Don't allow the hardware domain write access the PCI config space of
devices marked as read-only.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
--- a/tools/tests/vpci/emul.h
+++ b/tools/tests/vpci/emul.h
@@ -92,6 +92,9 @@ typedef union {
#define xfree(p) free(p)
#define pci_get_pdev_by_domain(...) &test_pdev
+#define pci_get_ro_map(...) NULL
+
+#define test_bit(...) false
/* Dummy native helpers. Writes are ignored, reads return 1's. */
#define pci_conf_read8(...) 0xff
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -421,6 +421,7 @@ void vpci_write(pci_sbdf_t sbdf, unsigne
const struct pci_dev *pdev;
const struct vpci_register *r;
unsigned int data_offset = 0;
+ const unsigned long *ro_map = pci_get_ro_map(sbdf.seg);
if ( !size )
{
@@ -428,6 +429,10 @@ void vpci_write(pci_sbdf_t sbdf, unsigne
return;
}
+ if ( ro_map && test_bit(sbdf.bdf, ro_map) )
+ /* Ignore writes to read-only devices. */
+ return;
+
/*
* Find the PCI dev matching the address.
* Passthrough everything that's not trapped.