From patchwork Thu May 18 05:34:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9733847 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 09271601BC for ; Thu, 18 May 2017 11:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA1EA20952 for ; Thu, 18 May 2017 11:42:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBA5A25404; Thu, 18 May 2017 11:42:26 +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 6BFD020952 for ; Thu, 18 May 2017 11:42:26 +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 1dBJnV-0004lw-66; Thu, 18 May 2017 11:40:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBJnU-0004jl-8h for xen-devel@lists.xen.org; Thu, 18 May 2017 11:40:48 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 54/14-03371-F388D195; Thu, 18 May 2017 11:40:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsXS1tbhqGvfIRt pMPUYr8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmjFxzwL2grV8FTcaLrM3MD7n7mLk4hASmM4o MeP9C9YuRk4OCQFeiSPLZkDZ/hKnp29nhSjqYJSYuOYNC0iCTUBd4sTiiYwgtoiAtMS1z5fBb GaBfYwSb56rgtjCAr4SF+9+YAaxWQRUJZ5cWgxm8wq4SnyZ/IEFYoGCxJSH78HinEDxbVtvgc WFBFwkGhf2sk5g5F3AyLCKUb04tagstUjXWC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC8 5P3cTIzAcGIBgB2PHP6dDjJIcTEqivIcLZCOF+JLyUyozEosz4otKc1KLDzHKcHAoSfDytQPl BItS01Mr0jJzgIEJk5bg4FES4U0BSfMWFyTmFmemQ6ROMSpKifN6gSQEQBIZpXlwbbBouMQoK yXMywh0iBBPQWpRbmYJqvwrRnEORiVh3iqQKTyZeSVw018BLWYCWtz8QBpkcUkiQkqqgTFUK9 yhsuyPJs/F4FcqRrOsVj/eODfpCHeXV+XV0FXLAzUjNmf46ZwvkH7+JkmkWHtOyLFjfw0+T7f XF9npe7H8tPqyPdMM7br5nLWkiyOdVrzSk3q2749m68sI6ZtdVUlJ+h7cx+69b+gpldvAPP9M buvkXG6b6Xw/NwnppbVPt3ymUHvhghJLcUaioRZzUXEiAKmxUJ6BAgAA X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1495107644!63462880!1 X-Originating-IP: [134.134.136.65] 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 28161 invoked from network); 18 May 2017 11:40:46 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 May 2017 11:40:46 -0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 May 2017 04:40:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,358,1491289200"; d="scan'208";a="103909118" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.124]) by fmsmga006.fm.intel.com with ESMTP; 18 May 2017 04:40:42 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 18 May 2017 01:34:46 -0400 Message-Id: <1495085696-10819-17-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 16/26] 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",