From patchwork Thu Jun 29 05:50:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9816541 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 3B230603D7 for ; Thu, 29 Jun 2017 12:00:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 082372841C for ; Thu, 29 Jun 2017 12:00:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F120328717; Thu, 29 Jun 2017 12:00:11 +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 9718D2841C for ; Thu, 29 Jun 2017 12:00:11 +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 1dQY5k-0006s8-5e; Thu, 29 Jun 2017 11:58:36 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQY5i-0006op-K1 for xen-devel@lists.xen.org; Thu, 29 Jun 2017 11:58:34 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 28/A2-02176-96BE4595; Thu, 29 Jun 2017 11:58:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsXS1tYhr5v+OiT S4P9bZoslHxezODB6HN39mymAMYo1My8pvyKBNWP53jVsBRskKv7/v8vewHhOuIuRg0NIoEKi fY9rFyMnh4QAr8SRZTNYIWx/iY7rU5m6GLmAStoZJTZPe8sOkmATUJc4sXgiI4gtIiAtce3zZ TCbWWAfo8Sb56ogtjBQ85fnf9hA5rMIqEr8PqAIEuYVcJXYub2fHWK+gsSUh++ZQWxOoHjDzS 1sILaQgIvEp56dzBMYeRcwMqxi1ChOLSpLLdI1NNBLKspMzyjJTczMAfKM9XJTi4sT01NzEpO K9ZLzczcxAkOhnoGBcQfjti7nQ4ySHExKoryGz0MihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw Or8CygkWpaanVqRl5gCDEiYtwcGjJMLbB9LKW1yQmFucmQ6ROsWoKCXOywXSJwCSyCjNg2uDR cIlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK88iBTeDLzSuCmvwJazAS0WHgG2OKSRISUVA Mj34pftx5+i1ALM6z3+tV/eu3cwjie91EKzREL0zwsjacfnDVnrvEjA/bAjMZuPauJc/yezbr pte6vd5pHeCH3LUuXF49uTj+zNDfep2f9sr5TBWu0U9NY3qpp8FzwEhZyXxzAYDXFvnpR46Jd pwIj3lxd/WvZLoPnLlZpz6af1mQwYjv3LIdRiaU4I9FQi7moOBEA3b6WiH8CAAA= X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1498737508!86360169!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.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6678 invoked from network); 29 Jun 2017 11:58:30 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-12.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Jun 2017 11:58:30 -0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 29 Jun 2017 04:58:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,280,1496127600"; d="scan'208";a="118874789" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.74]) by orsmga005.jf.intel.com with ESMTP; 29 Jun 2017 04:58:26 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 29 Jun 2017 01:50:51 -0400 Message-Id: <1498715457-16565-20-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498715457-16565-1-git-send-email-tianyu.lan@intel.com> References: <1498715457-16565-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] [PATCH 19/25] x86/vioapic: introduce a function to get vector from pin 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 When IOAPIC RTE is in remapping format, it doesn't contain the vector of interrupt. This patch adds vioapic_pin_vector() to get vector from pin for both remapping format and legacy format and uses this function other than accessing IOAPIC RTE directly. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- xen/arch/x86/hvm/vioapic.c | 21 +++++++++++++++++++++ xen/arch/x86/hvm/vpt.c | 11 ++++++++++- xen/include/asm-x86/hvm/vioapic.h | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 40f529c..f560c0b 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -319,6 +319,27 @@ static inline int pit_channel0_enabled(void) return pt_active(¤t->domain->arch.vpit.pt0); } +int vioapic_pin_vector(struct hvm_vioapic *vioapic, unsigned int pin) +{ + struct IO_APIC_route_remap_entry rte = { { vioapic->redirtbl[pin].bits } }; + + if ( rte.format ) + { + int err; + struct irq_remapping_request request; + struct irq_remapping_info info; + + irq_request_ioapic_fill(&request, vioapic->id, rte.val); + /* Currently, only viommu 0 is supported */ + err = viommu_get_irq_info(vioapic->domain, 0, &request, &info); + return !err ? info.vector : -1; + } + else + { + return vioapic->redirtbl[pin].fields.vector; + } +} + static void vioapic_deliver(struct hvm_vioapic *vioapic, unsigned int pin) { uint16_t dest = vioapic->redirtbl[pin].fields.dest_id; diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index e3f2039..d69c3c0 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -80,6 +80,7 @@ static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) struct vcpu *v = pt->vcpu; struct hvm_vioapic *vioapic; unsigned int gsi, isa_irq, pin; + int vector; if ( pt->source == PTSRC_lapic ) return pt->irq; @@ -101,7 +102,15 @@ static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) return -1; } - return vioapic->redirtbl[pin].fields.vector; + vector = vioapic_pin_vector(vioapic, pin); + if ( vector < 0 ) + { + gdprintk(XENLOG_ERR, "Can't get interrupt vector from GSI (%u)\n", + gsi); + domain_crash(v->domain); + return -1; + } + return vector; } static int pt_irq_masked(struct periodic_time *pt) diff --git a/xen/include/asm-x86/hvm/vioapic.h b/xen/include/asm-x86/hvm/vioapic.h index 2ceb60e..bc2725b 100644 --- a/xen/include/asm-x86/hvm/vioapic.h +++ b/xen/include/asm-x86/hvm/vioapic.h @@ -64,6 +64,7 @@ struct hvm_vioapic { struct hvm_vioapic *gsi_vioapic(const struct domain *d, unsigned int gsi, unsigned int *pin); +int vioapic_pin_vector(struct hvm_vioapic *vioapic, unsigned int pin); int vioapic_init(struct domain *d); void vioapic_deinit(struct domain *d); void vioapic_reset(struct domain *d);