From patchwork Fri Nov 17 06:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10062319 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 06E4A604D4 for ; Fri, 17 Nov 2017 06:27:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE1A72A539 for ; Fri, 17 Nov 2017 06:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2CFE2A825; Fri, 17 Nov 2017 06:27:14 +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=-4.2 required=2.0 tests=BAYES_00, 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 942382A990 for ; Fri, 17 Nov 2017 06:27:14 +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 1eFa5m-0001HZ-Eg; Fri, 17 Nov 2017 06:25:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFa5l-0001Er-EZ for xen-devel@lists.xen.org; Fri, 17 Nov 2017 06:25:33 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id BE/8A-20902-CD08E0A5; Fri, 17 Nov 2017 06:25:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsXS1tYhoXungS/ K4N8yPoslHxezODB6HN39mymAMYo1My8pvyKBNePjX7uC1wIVz1rXsDQw9vB1MXJxCAlMZ5Q4 2/mXqYuRk0NCgFfiyLIZrBB2gMTnw9tYQGwhgSqJX50HGEFsNgFliYtfe9lAbBEBaYlrny+Dx ZkFnjNLzGvUArGFBTwlvr9dBFbDIqAqMeXzLrAaXgFniSe9+1gg5itITHn4nhnE5gSK739zkA lil5PEwXXTmCYw8i5gZFjFqFGcWlSWWqRraKqXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKy XnJ+7iREYDAxAsIOxYbvnIUZJDiYlUV4ec74oIb6k/JTKjMTijPii0pzU4kOMMhwcShK8x+qB coJFqempFWmZOcCwhElLcPAoifAmAkNTiLe4IDG3ODMdInWK0Zjj2czXDcwc0662NjELseTl5 6VKifPeB5kkAFKaUZoHNwgWL5cYZaWEeRmBThPiKUgtys0sQZV/xSjOwagkzFsJMoUnM68Ebt 8roFOYgE6xucENckpJIkJKqoEx/PKjXcxz3arYrleobp32/0D6PMPnxr+/eqdcZ3kfLLx3avM sDqWjrVdME3xsgloZF05Vmyegff+ax92tovylMbOZJfrYdpzurzsyWebLuQTxMzZbyrfN3ZFe KJFfy1gkf+BX7I6nNvpOOmmBUTxLeOefs8xrXhDFWKHmbGd1pKRJ5Zx3la0SS3FGoqEWc1FxI gBRhk3FkgIAAA== X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1510899922!87798367!4 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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52456 invoked from network); 17 Nov 2017 06:25:31 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-11.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Nov 2017 06:25:31 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 22:25:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.44,407,1505804400"; d="scan'208"; a="1245165279" Received: from skl-4s-chao.sh.intel.com ([10.239.48.9]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2017 22:25:29 -0800 From: Chao Gao To: xen-devel@lists.xen.org Date: Fri, 17 Nov 2017 14:22:25 +0800 Message-Id: <1510899755-40237-19-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510899755-40237-1-git-send-email-chao.gao@intel.com> References: <1510899755-40237-1-git-send-email-chao.gao@intel.com> Cc: Lan Tianyu , Kevin Tian , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Ian Jackson , Tim Deegan , Jan Beulich , Andrew Cooper , Chao Gao , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v4 18/28] 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 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 --- v3: - use the new interface to check remapping format. --- xen/arch/x86/hvm/vioapic.c | 9 +++++++++ xen/include/asm-x86/viommu.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 97b419f..0f20e3f 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 @@ -387,9 +388,17 @@ 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 arch_irq_remapping_request request; ASSERT(spin_is_locked(&d->arch.hvm_domain.irq_lock)); + irq_request_ioapic_fill(&request, vioapic->id, vioapic->redirtbl[pin].bits); + if ( viommu_check_irq_remapping(d, &request) ) + { + viommu_handle_irq_request(d, &request); + return; + } + HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "dest=%x dest_mode=%x delivery_mode=%x " "vector=%x trig_mode=%x", diff --git a/xen/include/asm-x86/viommu.h b/xen/include/asm-x86/viommu.h index 3d995ba..e526e38 100644 --- a/xen/include/asm-x86/viommu.h +++ b/xen/include/asm-x86/viommu.h @@ -49,6 +49,15 @@ struct arch_irq_remapping_request enum viommu_irq_request_type type; }; +static inline void irq_request_ioapic_fill( + struct arch_irq_remapping_request *req, uint32_t ioapic_id, uint64_t rte) +{ + ASSERT(req); + req->type = VIOMMU_REQUEST_IRQ_APIC; + req->source_id = ioapic_id; + req->msg.rte = rte; +} + #endif /* __ARCH_X86_VIOMMU_H__ */ /*