From patchwork Thu May 18 05:34:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9733853 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 E499B601BC for ; Thu, 18 May 2017 11:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D365820952 for ; Thu, 18 May 2017 11:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C83DA25404; Thu, 18 May 2017 11:42:29 +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 7594E20952 for ; Thu, 18 May 2017 11:42:29 +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-0004yI-1D; Thu, 18 May 2017 11:40:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBJnb-0004ug-1I for xen-devel@lists.xen.org; Thu, 18 May 2017 11:40:55 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id CE/5C-03696-6488D195; Thu, 18 May 2017 11:40:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsXS1tYhoevaIRt pcGS2ocWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvH1dBdbwWzRilOHNrE0MHYLdjFycQgJTGeU uPvgJ2sXIyeHhACvxJFlM6Bsf4nfkz8zQRR1MErsb/vPApJgE1CXOLF4IiOILSIgLXHt82Uwm 1lgH6PEm+eqILawQLjEjIZmsEEsAqoSl09sBOvlFXCVmDlhA9QCBYkpD98zg9icQPFtW2+B1Q gJuEg0LuxlncDIu4CRYRWjenFqUVlqka6RXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ +7iZGYDgwAMEOxmV/nQ4xSnIwKYnyHi6QjRTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwcvXDpQT LEpNT61Iy8wBBiZMWoKDR0mEVwckzVtckJhbnJkOkTrFqCglzruxDSghAJLIKM2Da4NFwyVGW SlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ89qBjOfJzCuBm/4KaDET0OLmB9Igi0sSEVJSDYz5TO Z7PzDcTbtU+SP4YP4ckT19LJKpfP3774pMX5Kzkj/a1MGn99n7Jyt0+fROmVprLZROumDYe1p ZU9VQNfndZCcuK8ubU9asLlv26N6Jq02/ZzKsyuW1vFNVfbffbNPlm1s5lKKeHr5ZLpU7bydb tecyh48n4+dWJn3Lsc58ICH+mUuOl1mJpTgj0VCLuag4EQBJWjyrgQIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1495107651!103212674!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51166 invoked from network); 18 May 2017 11:40:53 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 May 2017 11:40:53 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 May 2017 04:40:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,358,1491289200"; d="scan'208";a="263417874" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.124]) by fmsmga004.fm.intel.com with ESMTP; 18 May 2017 04:40:49 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 18 May 2017 01:34:49 -0400 Message-Id: <1495085696-10819-20-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 19/26] x86/vpt: Get interrupt vector through a vioapic interface 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_gsi_vector() to translate pin to vector. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- xen/arch/x86/hvm/vioapic.c | 27 +++++++++++++++++++++++++++ xen/arch/x86/hvm/vpt.c | 2 +- xen/include/asm-x86/hvm/vioapic.h | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 40f529c..e7d1de7 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -319,6 +319,33 @@ 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); + if ( err < 0 ) + { + gdprintk(XENLOG_ERR, "Bad gsi or bad interrupt remapping table " + "entry.\n"); + domain_crash(vioapic->domain); + } + return info.vector; + } + 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..b95d3a1 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -101,7 +101,7 @@ static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) return -1; } - return vioapic->redirtbl[pin].fields.vector; + return vioapic_pin_vector(vioapic, pin); } 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);