From patchwork Thu Jun 29 05:50:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9816533 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 25F286020A for ; Thu, 29 Jun 2017 12:00:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DE312521E for ; Thu, 29 Jun 2017 12:00:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 927DB2853A; Thu, 29 Jun 2017 12:00:05 +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.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM 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 27979286E1 for ; Thu, 29 Jun 2017 12:00:05 +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 1dQY5a-0006br-0d; Thu, 29 Jun 2017 11:58:26 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQY5Y-0006Z8-Ex for xen-devel@lists.xen.org; Thu, 29 Jun 2017 11:58:24 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id A6/84-02176-F5BE4595; Thu, 29 Jun 2017 11:58:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsXS1tYhohv/OiT SYH2HiMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmjFxzwL2grV8FTcaLrM3MD7n7mLk5BASmM4o 0fKMFcSWEOCVOLJsBpTtL7F46xGmLkYuoJp2RonjhycwgyTYBNQlTiyeyAhiiwhIS1z7fBnMZ hbYxyjx5rkqiC0s4CbRNOkvUDMHB4uAqsTGiW4gYV4BV4nde68wQsxXkJjy8D3YSE6geMPNLW wQ97hIfOrZyTyBkXcBI8MqRo3i1KKy1CJdQ1O9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK 95PzcTYzAYGAAgh2MDds9DzFKcjApifIaPg+JFOJLyk+pzEgszogvKs1JLT7EKMPBoSTB6/wK KCdYlJqeWpGWmQMMS5i0BAePkghvH0grb3FBYm5xZjpE6hSjopQ4LxdInwBIIqM0D64NFguXG GWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMw7C2QKT2ZeCdz0V0CLmYAWC88AW1ySiJCSamBc+O bozVLtNypmGcV3k9a/Uoq2Cn/UcZWHuXZFueXNVXpfa+ds4F+9kjc1mH1CRIz2P7nM8PmRkcU H+lbobF7qfD7+6oTb0v7tNVO5d2e2Xz32c+6ynxVxy0QDitZelf2tILTgarffseMeTLZXpHsl 9m1qfXgq53lOi7vgoycZy/fftql5xCGhxFKckWioxVxUnAgASpURRoACAAA= X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1498737500!100604376!1 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34978 invoked from network); 29 Jun 2017 11:58:23 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-4.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Jun 2017 11:58:23 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2017 04:58:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,280,1496127600"; d="scan'208";a="280113716" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.74]) by fmsmga004.fm.intel.com with ESMTP; 29 Jun 2017 04:58:18 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 29 Jun 2017 01:50:48 -0400 Message-Id: <1498715457-16565-17-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 16/25] x86/vioapic: Hook interrupt delivery of vIOAPIC 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 irq remapping is enabled, IOAPIC Redirection Entry may be in remapping format. If that, generate an irq_remapping_request and call the common VIOMMU abstraction's callback to handle this interrupt request. Device model is responsible for checking the request's validity. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- xen/arch/x86/hvm/vioapic.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index abcc473..40f529c 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,8 @@ #include #include +#include "../../../drivers/passthrough/vtd/vtd.h" + /* HACK: Route IRQ0 only to VCPU0 to prevent time jumps. */ #define IRQ0_SPECIAL_ROUTING 1 @@ -327,9 +330,20 @@ static void vioapic_deliver(struct hvm_vioapic *vioapic, unsigned int pin) struct vlapic *target; struct vcpu *v; unsigned int irq = vioapic->base_gsi + pin; + struct IO_APIC_route_remap_entry rte = { { vioapic->redirtbl[pin].bits } }; ASSERT(spin_is_locked(&d->arch.hvm_domain.irq_lock)); + if ( rte.format ) + { + struct irq_remapping_request request; + + irq_request_ioapic_fill(&request, vioapic->id, rte.val); + /* Currently, only viommu 0 is supported */ + viommu_handle_irq_request(d, 0, &request); + return; + } + HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "dest=%x dest_mode=%x delivery_mode=%x " "vector=%x trig_mode=%x",