File 57220bd5-x86-vMSI-X-also-snoop-qword-writes.patch of Package xen.4507

# Commit d5016eaee6d668cadd93a3600203466e099e5b3f
# Date 2016-04-28 15:10:45 +0200
# Author Jan Beulich <jbeulich@suse.com>
# Committer Jan Beulich <jbeulich@suse.com>
x86/vMSI-X: also snoop qword writes

... the high half of which may be a write to the Vector Control field.
This gets things in sync again with msixtbl_write().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

--- a/xen/arch/x86/hvm/vmsi.c
+++ b/xen/arch/x86/hvm/vmsi.c
@@ -369,6 +369,7 @@ static int msixtbl_range(struct vcpu *v,
 {
     struct msixtbl_entry *entry;
     void *virt;
+    const struct hvm_vcpu_io *vio;
 
     rcu_read_lock(&msixtbl_rcu_lock);
 
@@ -380,17 +381,28 @@ static int msixtbl_range(struct vcpu *v,
     if ( virt )
         return 1;
 
-    if ( (addr & (PCI_MSIX_ENTRY_SIZE - 1)) ==
-         PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET )
+    vio = &v->arch.hvm_vcpu.hvm_io;
+    if ( vio->io_state != HVMIO_dispatched || vio->io_addr != addr )
+        return 0;
+    if ( vio->io_dir == IOREQ_WRITE )
     {
-        const struct hvm_vcpu_io *vio = &v->arch.hvm_vcpu.hvm_io;
-
-        if ( vio->io_state != HVMIO_dispatched || vio->io_addr != addr )
-            return 0;
-        if ( vio->io_dir == IOREQ_WRITE && vio->io_size == 4 &&
-             !vio->io_data_is_ptr &&
-             !(vio->io_data & PCI_MSIX_VECTOR_BITMASK) )
-            v->arch.hvm_vcpu.hvm_io.msix_snoop_address = addr;
+        if ( !vio->io_data_is_ptr )
+        {
+            unsigned int size = vio->io_size;
+            unsigned long data = vio->io_data;
+
+            if ( size == 8 )
+            {
+                BUILD_BUG_ON(!(PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET & 4));
+                data >>= 32;
+                addr += size = 4;
+            }
+            if ( size == 4 &&
+                 ((addr & (PCI_MSIX_ENTRY_SIZE - 1)) ==
+                  PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET) &&
+                 !(data & PCI_MSIX_VECTOR_BITMASK) )
+                v->arch.hvm_vcpu.hvm_io.msix_snoop_address = addr;
+        }
     }
 
     return 0;
openSUSE Build Service is sponsored by