From nobody Mon Feb 9 08:11:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489750691750868.7607295818872; Fri, 17 Mar 2017 04:38:11 -0700 (PDT) Received: from localhost ([::1]:48375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coqCw-0003rg-Av for importer@patchew.org; Fri, 17 Mar 2017 07:38:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coqBt-0003oT-KO for qemu-devel@nongnu.org; Fri, 17 Mar 2017 07:37:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coqBs-0007Dy-Lq for qemu-devel@nongnu.org; Fri, 17 Mar 2017 07:37:05 -0400 Received: from mga04.intel.com ([192.55.52.120]:37369) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1coqBs-0007DC-9m for qemu-devel@nongnu.org; Fri, 17 Mar 2017 07:37:04 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Mar 2017 04:37:03 -0700 Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.159.159]) by fmsmga005.fm.intel.com with ESMTP; 17 Mar 2017 04:36:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489750624; x=1521286624; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=jqV/ruj5d6LzkA6SfRc3tg9uH9kQ3eeC6CX6Orkw+eM=; b=KfmN0GUPFXWV7wDIzgGW/0k3bYVnnbAqWIkSyU7f3tG7LPaUYUO+xOWL VHMwodgZ0gobioMU/7wxcYhyr6FISA==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,176,1486454400"; d="scan'208";a="77573860" From: Lan Tianyu To: xen-devel@lists.xensource.com, qemu-devel@nongnu.org Date: Fri, 17 Mar 2017 19:29:16 +0800 Message-Id: <1489750157-17401-4-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1489750157-17401-1-git-send-email-tianyu.lan@intel.com> References: <1489750157-17401-1-git-send-email-tianyu.lan@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.120 Subject: [Qemu-devel] [RFC PATCH 3/4] xen-pt: bind/unbind interrupt remapping format MSI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lan Tianyu , kevin.tian@intel.com, sstabellini@kernel.org, mst@redhat.com, anthony.perard@citrix.com, chao.gao@intel.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Chao Gao If a vIOMMU is exposed to guest, guest will configure the msi to remapping format. The original code isn't suitable to the new format. A new pair bind/unbind interfaces are added for this usage. This patch recognizes this case and use new interfaces to bind/unbind msi. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- hw/xen/xen_pt_msi.c | 36 ++++++++++++++++++++++++++++-------- include/hw/i386/apic-msidef.h | 1 + 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c index 62add06..8b0d7fc 100644 --- a/hw/xen/xen_pt_msi.c +++ b/hw/xen/xen_pt_msi.c @@ -161,6 +161,7 @@ static int msi_msix_update(XenPCIPassthroughState *s, uint8_t gvec =3D msi_vector(data); uint32_t gflags =3D msi_gflags(data, addr); int rc =3D 0; + bool ir =3D !!(addr & MSI_ADDR_IM_MASK); uint64_t table_addr =3D 0; =20 XEN_PT_LOG(d, "Updating MSI%s with pirq %d gvec %#x gflags %#x" @@ -171,8 +172,14 @@ static int msi_msix_update(XenPCIPassthroughState *s, table_addr =3D s->msix->mmio_base_addr; } =20 - rc =3D xc_domain_update_msi_irq(xen_xc, xen_domid, gvec, + if (ir) { + rc =3D xc_domain_update_msi_irq_remapping(xen_xc, xen_domid, pirq, + d->devfn, data, addr, table_addr); + } + else { + rc =3D xc_domain_update_msi_irq(xen_xc, xen_domid, gvec, pirq, gflags, table_addr); + } =20 if (rc) { XEN_PT_ERR(d, "Updating of MSI%s failed. (err: %d)\n", @@ -204,13 +211,26 @@ static int msi_msix_disable(XenPCIPassthroughState *s, } =20 if (is_binded) { - XEN_PT_LOG(d, "Unbind MSI%s with pirq %d, gvec %#x\n", - is_msix ? "-X" : "", pirq, gvec); - rc =3D xc_domain_unbind_msi_irq(xen_xc, xen_domid, gvec, pirq, gfl= ags); - if (rc) { - XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: %d, = gvec: %#x)\n", - is_msix ? "-X" : "", errno, pirq, gvec); - return rc; + if ( addr & MSI_ADDR_IM_MASK ) { + XEN_PT_LOG(d, "Unbinding of MSI%s . ( pirq: %d, data: %x, addr= : %lx)\n", + is_msix ? "-X" : "", pirq, data, addr); + rc =3D xc_domain_unbind_msi_irq_remapping(xen_xc, xen_domid, p= irq, + d->devfn, data, addr); + if (rc) { + XEN_PT_ERR(d, "Unbinding of MSI%s . (error: %d, pirq: %d, = data: %x, addr: %lx)\n", + is_msix ? "-X" : "", rc, pirq, data, addr); + return rc; + } + + } else { + XEN_PT_LOG(d, "Unbind MSI%s with pirq %d, gvec %#x\n", + is_msix ? "-X" : "", pirq, gvec); + rc =3D xc_domain_unbind_msi_irq(xen_xc, xen_domid, gvec, pirq,= gflags); + if (rc) { + XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: = %d, gvec: %#x)\n", + is_msix ? "-X" : "", errno, pirq, gvec); + return rc; + } } } =20 diff --git a/include/hw/i386/apic-msidef.h b/include/hw/i386/apic-msidef.h index 8b4d4cc..08b584f 100644 --- a/include/hw/i386/apic-msidef.h +++ b/include/hw/i386/apic-msidef.h @@ -27,5 +27,6 @@ #define MSI_ADDR_DEST_ID_SHIFT 12 #define MSI_ADDR_DEST_IDX_SHIFT 4 #define MSI_ADDR_DEST_ID_MASK 0x00ffff0 +#define MSI_ADDR_IM_MASK 0x00000010 =20 #endif /* HW_APIC_MSIDEF_H */ --=20 1.8.3.1