From patchwork Wed Mar 15 05:11:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9625485 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 7024060424 for ; Wed, 15 Mar 2017 12:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63D442838E for ; Wed, 15 Mar 2017 12:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5507028346; Wed, 15 Mar 2017 12:17:17 +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 BC91A28346 for ; Wed, 15 Mar 2017 12:17:16 +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 1co7pe-0004WJ-PX; Wed, 15 Mar 2017 12:15:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1co7pd-0004VV-Rn for xen-devel@lists.xen.org; Wed, 15 Mar 2017 12:15:09 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 91/C8-13192-D4039C85; Wed, 15 Mar 2017 12:15:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsXS1tYhr+tjcDL CYHmnicWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvF0bjNbwVypioebDzE1MJ4T7mLk5BASqJDo X7OIDcSWEOCVOLJsBiuEHSDxau8nNoiacon9z/awgNhsAsoSF7/2gsVFBKQlrn2+zNjFyMHBL JAv8bSHESQsLJAg0dCxlwnEZhFQlWi5PBMszivgKNG8eiMTxHgFiSkP3zODtHIKOElseFsHsc lRYtfeGawTGHkXMDKsYtQoTi0qSy3SNTbQSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87 P3cQIDAQGINjB+Hdt4CFGSQ4mJVHez3MPRgjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4OU7DZQT LEpNT61Iy8wBhiRMWoKDR0mEd+cpoDRvcUFibnFmOkTqFKOilDjvHZCEAEgiozQPrg0WB5cYZ aWEeRmBDhHiKUgtys0sQZV/xSjOwagkzPsdZApPZl4J3PRXQIuZgBZP4wNbXJKIkJJqYGSf7f h75oTPa6ccnyzY+6wm+88epW0rntXw1ly7bsG5sc5fbX1A/OOJ9Rr5Zs6x0mfWBqyaF5KYufn E8UmLtm+MXuNuebawPOH/OZGo5xtc484sPSsi9rIlOzz+EqPwFuur5iIdLpvfblWJMtgdN5V9 7cu6W/duOl36l/T3iZ606sukWM1DPX1KLMUZiYZazEXFiQAgCNMdfgIAAA== X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1489580106!56634074!1 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12032 invoked from network); 15 Mar 2017 12:15:08 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-14.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Mar 2017 12:15:08 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 15 Mar 2017 05:15:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.36,168,1486454400"; d="scan'208"; a="1108707439" Received: from skl-2s3.sh.intel.com ([10.239.48.35]) by orsmga001.jf.intel.com with ESMTP; 15 Mar 2017 05:15:04 -0700 From: Chao Gao To: xen-devel@lists.xen.org Date: Wed, 15 Mar 2017 13:11:21 +0800 Message-Id: <1489554682-6126-6-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1489554682-6126-1-git-send-email-chao.gao@intel.com> References: <1489554682-6126-1-git-send-email-chao.gao@intel.com> Cc: Andrew Cooper , Jan Beulich , Chao Gao Subject: [Xen-devel] [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI 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 When a vCPU migrated to another pCPU, pt irqs binded to this vCPU also needed migration. When VT-d PI is enabled, interrupt vector will be recorded to a main memory resident data-structure and a notification whose destination is decided by NDST is generated. NDST is properly adjusted during vCPU migration so pirq directly injected to guest needn't be migrated. This patch adds a indicator, @via_pi, to show whether the pt irq is delivered through VT-d PI. Signed-off-by: Chao Gao --- v10: - Newly added. xen/arch/x86/hvm/hvm.c | 3 +++ xen/drivers/passthrough/io.c | 15 +++++++++++---- xen/include/xen/hvm/irq.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index ccfae4f..abbdab9 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -445,6 +445,9 @@ static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci, struct vcpu *v = arg; if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && + (pirq_dpci->flags & HVM_IRQ_DPCI_GUEST_MSI) && + /* Needn't migrate pirq if this pirq is delivered to guest directly.*/ + (pirq_dpci->gmsi.via_pi != 1) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) { struct irq_desc *desc = diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index 080183e..37d9af6 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -365,6 +365,7 @@ int pt_irq_create_bind( { uint8_t dest, dest_mode, delivery_mode; int dest_vcpu_id; + const struct vcpu *vcpu = NULL; if ( !(pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) ) { @@ -441,6 +442,15 @@ int pt_irq_create_bind( dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id; + + pirq_dpci->gmsi.via_pi = 0; + if ( iommu_intpost ) + { + vcpu = pi_find_dest_vcpu(d, dest, dest_mode, delivery_mode, + pirq_dpci->gmsi.gvec); + if ( vcpu ) + pirq_dpci->gmsi.via_pi = 1; + } spin_unlock(&d->event_lock); if ( dest_vcpu_id >= 0 ) hvm_migrate_pirqs(d->vcpu[dest_vcpu_id]); @@ -448,11 +458,8 @@ int pt_irq_create_bind( /* Use interrupt posting if it is supported. */ if ( iommu_intpost ) { - const struct vcpu *vcpu = pi_find_dest_vcpu(d, dest, dest_mode, - delivery_mode, pirq_dpci->gmsi.gvec); - if ( vcpu ) - pi_update_irte( vcpu, info, pirq_dpci->gmsi.gvec ); + pi_update_irte(vcpu, info, pirq_dpci->gmsi.gvec); else dprintk(XENLOG_G_INFO, "%pv: deliver interrupt in remapping mode,gvec:%02x\n", diff --git a/xen/include/xen/hvm/irq.h b/xen/include/xen/hvm/irq.h index d3f8623..ba74a31 100644 --- a/xen/include/xen/hvm/irq.h +++ b/xen/include/xen/hvm/irq.h @@ -63,6 +63,7 @@ struct hvm_gmsi_info { uint32_t gvec; uint32_t gflags; int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */ + bool via_pi; /* directly deliver to guest via VT-d PI? */ }; struct hvm_girq_dpci_mapping {