Skip to contentSkip to conversation

x86: correct MSI_ADDR_DEST_ID_MASK

PATCH New Jan Beulich 1 participant 1 message May 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: correct MSI_ADDR_DEST_ID_MASK

This should only cover bits 12-19, in line with MSI_ADDR_DEST_ID_SHIFT.

Also replace a couple of open-coded uses of this shift and mask.

xen/arch/x86/hvm/irq.c +2 -1
@@ -283,7 +283,8 @@ int hvm_inject_msi(struct domain *d, uin
 
     if ( !vector )
     {
-        int pirq = ((addr >> 32) & 0xffffff00) | ((addr >> 12) & 0xff);
+        int pirq = ((addr >> 32) & 0xffffff00) | dest;
+
         if ( pirq > 0 )
         {
             struct pirq *info = pirq_info(d, pirq);
xen/drivers/passthrough/vtd/intremap.c +1 -1
@@ -535,7 +535,7 @@ static int remap_entry_to_msi_msg(
         msg->dest32 = iremap_entry->lo.dst;
     else
         msg->dest32 = (iremap_entry->lo.dst >> 8) & 0xff;
-    msg->address_lo |= (msg->dest32 & 0xff) << MSI_ADDR_DEST_ID_SHIFT;
+    msg->address_lo |= MSI_ADDR_DEST_ID(msg->dest32);
 
     msg->data =
         MSI_DATA_TRIGGER_EDGE |
xen/drivers/passthrough/vtd/iommu.c +1 -1
@@ -1044,7 +1044,7 @@ static void dma_msi_set_affinity(struct 
     if (x2apic_enabled)
         msg.address_hi = dest & 0xFFFFFF00;
     msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
-    msg.address_lo |= MSI_ADDR_DEST_ID(dest & 0xff);
+    msg.address_lo |= MSI_ADDR_DEST_ID(dest);
     iommu->msi.msg = msg;
 
     spin_lock_irqsave(&iommu->register_lock, flags);
xen/include/asm-x86/msi.h +1 -1
@@ -49,7 +49,7 @@
 #define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT)
 
 #define MSI_ADDR_DEST_ID_SHIFT		12
-#define	 MSI_ADDR_DEST_ID_MASK		0x00ffff0
+#define	 MSI_ADDR_DEST_ID_MASK		0x00ff000
 #define  MSI_ADDR_DEST_ID(dest)		(((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK)
 
 /* MAX fixed pages reserved for mapping MSIX tables. */

x86: correct MSI_ADDR_DEST_ID_MASK

This should only cover bits 12-19, in line with MSI_ADDR_DEST_ID_SHIFT.

Also replace a couple of open-coded uses of this shift and mask.

xen/arch/x86/hvm/irq.c +2 -1
@@ -283,7 +283,8 @@ int hvm_inject_msi(struct domain *d, uin
 
     if ( !vector )
     {
-        int pirq = ((addr >> 32) & 0xffffff00) | ((addr >> 12) & 0xff);
+        int pirq = ((addr >> 32) & 0xffffff00) | dest;
+
         if ( pirq > 0 )
         {
             struct pirq *info = pirq_info(d, pirq);
xen/drivers/passthrough/vtd/intremap.c +1 -1
@@ -535,7 +535,7 @@ static int remap_entry_to_msi_msg(
         msg->dest32 = iremap_entry->lo.dst;
     else
         msg->dest32 = (iremap_entry->lo.dst >> 8) & 0xff;
-    msg->address_lo |= (msg->dest32 & 0xff) << MSI_ADDR_DEST_ID_SHIFT;
+    msg->address_lo |= MSI_ADDR_DEST_ID(msg->dest32);
 
     msg->data =
         MSI_DATA_TRIGGER_EDGE |
xen/drivers/passthrough/vtd/iommu.c +1 -1
@@ -1044,7 +1044,7 @@ static void dma_msi_set_affinity(struct 
     if (x2apic_enabled)
         msg.address_hi = dest & 0xFFFFFF00;
     msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
-    msg.address_lo |= MSI_ADDR_DEST_ID(dest & 0xff);
+    msg.address_lo |= MSI_ADDR_DEST_ID(dest);
     iommu->msi.msg = msg;
 
     spin_lock_irqsave(&iommu->register_lock, flags);
xen/include/asm-x86/msi.h +1 -1
@@ -49,7 +49,7 @@
 #define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT)
 
 #define MSI_ADDR_DEST_ID_SHIFT		12
-#define	 MSI_ADDR_DEST_ID_MASK		0x00ffff0
+#define	 MSI_ADDR_DEST_ID_MASK		0x00ff000
 #define  MSI_ADDR_DEST_ID(dest)		(((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK)
 
 /* MAX fixed pages reserved for mapping MSIX tables. */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel