From: "Jan Beulich" Subject: [PATCH] x86: correct MSI_ADDR_DEST_ID_MASK Date: Mon, 12 May 2014 14:52:48 +0100 Message-ID: <5370EE50020000780001172D@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB98B9720.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wjqf3-0000Bi-T5 for xen-devel@lists.xenproject.org; Mon, 12 May 2014 13:52:58 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser , xiantao.zhang@intel.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB98B9720.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/irq.c +++ b/xen/arch/x86/hvm/irq.c @@ -283,7 +283,8 @@ int hvm_inject_msi(struct domain *d, uin =20 if ( !vector ) { - int pirq =3D ((addr >> 32) & 0xffffff00) | ((addr >> 12) & 0xff); + int pirq =3D ((addr >> 32) & 0xffffff00) | dest; + if ( pirq > 0 ) { struct pirq *info =3D pirq_info(d, pirq); --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -535,7 +535,7 @@ static int remap_entry_to_msi_msg( msg->dest32 =3D iremap_entry->lo.dst; else msg->dest32 =3D (iremap_entry->lo.dst >> 8) & 0xff; - msg->address_lo |=3D (msg->dest32 & 0xff) << MSI_ADDR_DEST_ID_SHIFT; + msg->address_lo |=3D MSI_ADDR_DEST_ID(msg->dest32); =20 msg->data =3D MSI_DATA_TRIGGER_EDGE | --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1044,7 +1044,7 @@ static void dma_msi_set_affinity(struct=20 if (x2apic_enabled) msg.address_hi =3D dest & 0xFFFFFF00; msg.address_lo &=3D ~MSI_ADDR_DEST_ID_MASK; - msg.address_lo |=3D MSI_ADDR_DEST_ID(dest & 0xff); + msg.address_lo |=3D MSI_ADDR_DEST_ID(dest); iommu->msi.msg =3D msg; =20 spin_lock_irqsave(&iommu->register_lock, flags); --- a/xen/include/asm-x86/msi.h +++ b/xen/include/asm-x86/msi.h @@ -49,7 +49,7 @@ #define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT) =20 #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_I= D_SHIFT) & MSI_ADDR_DEST_ID_MASK) =20 /* MAX fixed pages reserved for mapping MSIX tables. */ --=__PartB98B9720.1__= Content-Type: text/plain; name="x86-MSI-addr-dest-ID-mask.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-MSI-addr-dest-ID-mask.patch" x86: correct MSI_ADDR_DEST_ID_MASK=0A=0AThis should only cover bits 12-19, = in line with MSI_ADDR_DEST_ID_SHIFT.=0A=0AAlso replace a couple of = open-coded uses of this shift and mask.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/hvm/irq.c=0A+++ b/xen/arch/x86/= hvm/irq.c=0A@@ -283,7 +283,8 @@ int hvm_inject_msi(struct domain *d, = uin=0A =0A if ( !vector )=0A {=0A- int pirq =3D ((addr >> = 32) & 0xffffff00) | ((addr >> 12) & 0xff);=0A+ int pirq =3D ((addr = >> 32) & 0xffffff00) | dest;=0A+=0A if ( pirq > 0 )=0A = {=0A struct pirq *info =3D pirq_info(d, pirq);=0A--- a/xen/driv= ers/passthrough/vtd/intremap.c=0A+++ b/xen/drivers/passthrough/vtd/intremap= .c=0A@@ -535,7 +535,7 @@ static int remap_entry_to_msi_msg(=0A = msg->dest32 =3D iremap_entry->lo.dst;=0A else=0A msg->dest32 = =3D (iremap_entry->lo.dst >> 8) & 0xff;=0A- msg->address_lo |=3D = (msg->dest32 & 0xff) << MSI_ADDR_DEST_ID_SHIFT;=0A+ msg->address_lo = |=3D MSI_ADDR_DEST_ID(msg->dest32);=0A =0A msg->data =3D=0A = MSI_DATA_TRIGGER_EDGE |=0A--- a/xen/drivers/passthrough/vtd/iommu.c=0A+++ = b/xen/drivers/passthrough/vtd/iommu.c=0A@@ -1044,7 +1044,7 @@ static void = dma_msi_set_affinity(struct =0A if (x2apic_enabled)=0A = msg.address_hi =3D dest & 0xFFFFFF00;=0A msg.address_lo &=3D ~MSI_ADDR_= DEST_ID_MASK;=0A- msg.address_lo |=3D MSI_ADDR_DEST_ID(dest & 0xff);=0A+= msg.address_lo |=3D MSI_ADDR_DEST_ID(dest);=0A iommu->msi.msg =3D = msg;=0A =0A spin_lock_irqsave(&iommu->register_lock, flags);=0A--- = a/xen/include/asm-x86/msi.h=0A+++ b/xen/include/asm-x86/msi.h=0A@@ -49,7 = +49,7 @@=0A #define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_= SHIFT)=0A =0A #define MSI_ADDR_DEST_ID_SHIFT 12=0A-#define = MSI_ADDR_DEST_ID_MASK 0x00ffff0=0A+#define MSI_ADDR_DEST_ID_M= ASK 0x00ff000=0A #define MSI_ADDR_DEST_ID(dest) = (((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK)=0A =0A /* MAX = fixed pages reserved for mapping MSIX tables. */=0A --=__PartB98B9720.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB98B9720.1__=--