From patchwork Wed Aug 9 20:34:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9892621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3225160236 for ; Thu, 10 Aug 2017 02:43:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1840428A03 for ; Thu, 10 Aug 2017 02:43:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D29628A08; Thu, 10 Aug 2017 02:43:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 93ECC28A1F for ; Thu, 10 Aug 2017 02:43:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfdQA-0001o1-FY; Thu, 10 Aug 2017 02:42:02 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfdQ8-0001kc-MC for xen-devel@lists.xen.org; Thu, 10 Aug 2017 02:42:00 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 66/09-03044-8F7CB895; Thu, 10 Aug 2017 02:42:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsVywNykQvf78e5 Ig9a7UhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8blxlNsBZN0K96ems3YwHhSoYuRi0NIYDqj xIO+NexdjJwcEgK8EkeWzWCFsP0lpv99wghR1MEoMfNmMwtIgk1AXeLE4omMILaIgLTEtc+Xw YqYBa4ySpzeNp8ZJCEsEC2xpHkX0CQODhYBVYmmLj+QMK+Aq8TnbT1sEAsUJKY8fA9WzgkUn7 plKxOILSTgIrFu+TTGCYy8CxgZVjFqFKcWlaUW6RpZ6CUVZaZnlOQmZuboGhqY6eWmFhcnpqf mJCYV6yXn525iBAYEAxDsYDy/NvAQoyQHk5Iob0dDd6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4l CV4WYIAJCRalpqdWpGXmAEMTJi3BwaMkwvv+GFCat7ggMbc4Mx0idYpRl+PVhP/fmIRY8vLzU qXEeZeAFAmAFGWU5sGNgMXJJUZZKWFeRqCjhHgKUotyM0tQ5V8xinMwKgnzVoBM4cnMK4Hb9A roCCagIyJ8O0GOKElESEk1MG5/yhsQ9KdipbpYVvW0feeYL03SOsT6LHzOq8WVhrffRT/0WNP OspHxtyNb3Ca20oCFGyXWpMg8tG8SXnvs+ZYC23xuf7UTqx4wHr2d6rLk3qqJRmWRtz5eSM5+ YZzg7Hlle8bCRTtWX92omamleyD0zL0mt7wTeXWdm+zePa01c2Y4mSUk+UiJpTgj0VCLuag4E QBv+xzBjgIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1502332917!70579653!1 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13428 invoked from network); 10 Aug 2017 02:41:59 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-14.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Aug 2017 02:41:59 -0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2017 19:41:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,349,1498546800"; d="scan'208";a="137767015" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.141]) by fmsmga005.fm.intel.com with ESMTP; 09 Aug 2017 19:41:55 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Wed, 9 Aug 2017 16:34:21 -0400 Message-Id: <1502310866-10450-21-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502310866-10450-1-git-send-email-tianyu.lan@intel.com> References: <1502310866-10450-1-git-send-email-tianyu.lan@intel.com> Cc: Lan Tianyu , kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, jbeulich@suse.com, Chao Gao Subject: [Xen-devel] [PATCH V2 20/25] passthrough: move some fields of hvm_gmsi_info to a sub-structure X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Chao Gao No functional change. It is a preparation for introducing new fields in hvm_gmsi_info to manage remapping format msi bound to a physical msi. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- xen/arch/x86/hvm/vmsi.c | 4 ++-- xen/drivers/passthrough/io.c | 32 ++++++++++++++++---------------- xen/include/xen/hvm/irq.h | 8 ++++++-- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c index a36692c..c4ec0ad 100644 --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -101,8 +101,8 @@ int vmsi_deliver( void vmsi_deliver_pirq(struct domain *d, const struct hvm_pirq_dpci *pirq_dpci) { - uint32_t flags = pirq_dpci->gmsi.gflags; - int vector = pirq_dpci->gmsi.gvec; + uint32_t flags = pirq_dpci->gmsi.legacy.gflags; + int vector = pirq_dpci->gmsi.legacy.gvec; uint8_t dest = (uint8_t)flags; uint8_t dest_mode = !!(flags & VMSI_DM_MASK); uint8_t delivery_mode = (flags & VMSI_DELIV_MASK) diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index ffeaf70..4d457f6 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -348,8 +348,8 @@ int pt_irq_create_bind( { pirq_dpci->flags = HVM_IRQ_DPCI_MAPPED | HVM_IRQ_DPCI_MACH_MSI | HVM_IRQ_DPCI_GUEST_MSI; - pirq_dpci->gmsi.gvec = pt_irq_bind->u.msi.gvec; - pirq_dpci->gmsi.gflags = pt_irq_bind->u.msi.gflags; + pirq_dpci->gmsi.legacy.gvec = pt_irq_bind->u.msi.gvec; + pirq_dpci->gmsi.legacy.gflags = pt_irq_bind->u.msi.gflags; /* * 'pt_irq_create_bind' can be called after 'pt_irq_destroy_bind'. * The 'pirq_cleanup_check' which would free the structure is only @@ -381,8 +381,8 @@ int pt_irq_create_bind( } if ( unlikely(rc) ) { - pirq_dpci->gmsi.gflags = 0; - pirq_dpci->gmsi.gvec = 0; + pirq_dpci->gmsi.legacy.gflags = 0; + pirq_dpci->gmsi.legacy.gvec = 0; pirq_dpci->dom = NULL; pirq_dpci->flags = 0; pirq_cleanup_check(info, d); @@ -401,20 +401,20 @@ int pt_irq_create_bind( } /* If pirq is already mapped as vmsi, update guest data/addr. */ - if ( pirq_dpci->gmsi.gvec != pt_irq_bind->u.msi.gvec || - pirq_dpci->gmsi.gflags != pt_irq_bind->u.msi.gflags ) + if ( pirq_dpci->gmsi.legacy.gvec != pt_irq_bind->u.msi.gvec || + pirq_dpci->gmsi.legacy.gflags != pt_irq_bind->u.msi.gflags ) { /* Directly clear pending EOIs before enabling new MSI info. */ pirq_guest_eoi(info); - pirq_dpci->gmsi.gvec = pt_irq_bind->u.msi.gvec; - pirq_dpci->gmsi.gflags = pt_irq_bind->u.msi.gflags; + pirq_dpci->gmsi.legacy.gvec = pt_irq_bind->u.msi.gvec; + pirq_dpci->gmsi.legacy.gflags = pt_irq_bind->u.msi.gflags; } } /* Calculate dest_vcpu_id for MSI-type pirq migration. */ - dest = pirq_dpci->gmsi.gflags & VMSI_DEST_ID_MASK; - dest_mode = !!(pirq_dpci->gmsi.gflags & VMSI_DM_MASK); - delivery_mode = (pirq_dpci->gmsi.gflags & VMSI_DELIV_MASK) >> + dest = pirq_dpci->gmsi.legacy.gflags & VMSI_DEST_ID_MASK; + dest_mode = !!(pirq_dpci->gmsi.legacy.gflags & VMSI_DM_MASK); + delivery_mode = (pirq_dpci->gmsi.legacy.gflags & VMSI_DELIV_MASK) >> GFLAGS_SHIFT_DELIV_MODE; dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); @@ -427,7 +427,7 @@ int pt_irq_create_bind( { if ( delivery_mode == dest_LowestPrio ) vcpu = vector_hashing_dest(d, dest, dest_mode, - pirq_dpci->gmsi.gvec); + pirq_dpci->gmsi.legacy.gvec); if ( vcpu ) pirq_dpci->gmsi.posted = true; } @@ -437,7 +437,7 @@ int pt_irq_create_bind( /* Use interrupt posting if it is supported. */ if ( iommu_intpost ) pi_update_irte(vcpu ? &vcpu->arch.hvm_vmx.pi_desc : NULL, - info, pirq_dpci->gmsi.gvec); + info, pirq_dpci->gmsi.legacy.gvec); break; } @@ -817,10 +817,10 @@ static int _hvm_dpci_msi_eoi(struct domain *d, int vector = (long)arg; if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && - (pirq_dpci->gmsi.gvec == vector) ) + (pirq_dpci->gmsi.legacy.gvec == vector) ) { - int dest = pirq_dpci->gmsi.gflags & VMSI_DEST_ID_MASK; - int dest_mode = !!(pirq_dpci->gmsi.gflags & VMSI_DM_MASK); + int dest = pirq_dpci->gmsi.legacy.gflags & VMSI_DEST_ID_MASK; + int dest_mode = !!(pirq_dpci->gmsi.legacy.gflags & VMSI_DM_MASK); if ( vlapic_match_dest(vcpu_vlapic(current), NULL, 0, dest, dest_mode) ) diff --git a/xen/include/xen/hvm/irq.h b/xen/include/xen/hvm/irq.h index 0d2c72c..5e736f8 100644 --- a/xen/include/xen/hvm/irq.h +++ b/xen/include/xen/hvm/irq.h @@ -62,8 +62,12 @@ struct dev_intx_gsi_link { #define GFLAGS_SHIFT_TRG_MODE 15 struct hvm_gmsi_info { - uint32_t gvec; - uint32_t gflags; + union { + struct { + uint32_t gvec; + uint32_t gflags; + } legacy; + }; int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */ bool posted; /* directly deliver to guest via VT-d PI? */ };