From patchwork Thu May 18 05:34:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9733881 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 647D7601BC for ; Thu, 18 May 2017 11:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53F1020952 for ; Thu, 18 May 2017 11:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48CF82621D; Thu, 18 May 2017 11:42:46 +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 D061E20952 for ; Thu, 18 May 2017 11:42:45 +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 1dBJnd-0004yo-94; Thu, 18 May 2017 11:40:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBJnc-0004wZ-7S for xen-devel@lists.xen.org; Thu, 18 May 2017 11:40:56 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 3F/76-19466-7488D195; Thu, 18 May 2017 11:40:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsVywNykWNetQzb SYM0ZPYslHxezODB6HN39mymAMYo1My8pvyKBNaN91zrGgkm6FacOPWNpYDyp0MXIySEkMI1R 4vgVVRBbQoBX4siyGawQtr/Eyyt7mLoYuYBqOhglLv+5xA6SYBNQlzixeCIjiC0iIC1x7fNlM JtZYB+jxJvnYIOEBeIlTi3sAatnEVCVOHWxCaiGg4NXwFXiy786iPkKElMevmcGsTmBwtu23m KBuMdFonFhL+sERt4FjAyrGDWKU4vKUot0DQ31kooy0zNKchMzc3QNDUz1clOLixPTU3MSk4r 1kvNzNzECg4EBCHYwrmx3PsQoycGkJMp7uEA2UogvKT+lMiOxOCO+qDQntfgQowwHh5IEL187 UE6wKDU9tSItMwcYljBpCQ4eJRFeHZA0b3FBYm5xZjpE6hSjopQ478Y2oIQASCKjNA+uDRYLl xhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMywoyniczrwRu+iugxUxAi5sfSIMsLklESEk1MG 51uvmz8NwJ050t73jMRP4aT/BtvnK9+Ph9TekUBn6xqG337tYfVHfLP7ly8Q7FOQKBmzc5Pbb /OdHY3Lj7j+jHcrand0SyN8Ta5nAfz2z/Fb3FKOn3c9mfO6PCP+9cnb+QqYg5/ZPm6m9V21nc dvy90SG1irPQ/4703IeHjp1nlFL758iXcliJpTgj0VCLuag4EQD8RsbNgAIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1495107647!84949287!2 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10648 invoked from network); 18 May 2017 11:40:54 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-15.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 May 2017 11:40:54 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 May 2017 04:40:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,358,1491289200"; d="scan'208";a="970138933" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.124]) by orsmga003.jf.intel.com with ESMTP; 18 May 2017 04:40:51 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 18 May 2017 01:34:50 -0400 Message-Id: <1495085696-10819-21-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1495085696-10819-1-git-send-email-tianyu.lan@intel.com> References: <1495085696-10819-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, jbeulich@suse.com, Chao Gao Subject: [Xen-devel] [RFC PATCH V2 20/26] 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 e5a43e5..2158a11 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -325,8 +325,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 @@ -358,8 +358,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); @@ -378,20 +378,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); @@ -404,7 +404,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; } @@ -414,7 +414,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; } @@ -729,10 +729,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 671a6f2..5f8e2f4 100644 --- a/xen/include/xen/hvm/irq.h +++ b/xen/include/xen/hvm/irq.h @@ -60,8 +60,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? */ };