From patchwork Fri Mar 17 11:27:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9630419 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 297E760249 for ; Fri, 17 Mar 2017 11:37:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 137E0284E9 for ; Fri, 17 Mar 2017 11:37:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 085582862B; Fri, 17 Mar 2017 11:37:27 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 6F0F0284E9 for ; Fri, 17 Mar 2017 11:37: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 1coqAV-000488-A1; Fri, 17 Mar 2017 11:35:39 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coqAU-00044V-76 for xen-devel@lists.xen.org; Fri, 17 Mar 2017 11:35:38 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id E2/5D-05091-90ACBC85; Fri, 17 Mar 2017 11:35:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgkeJIrShJLcpLzFFi42I5YG4Soct56nS EQetyRoslHxezODB6HN39mymAMYo1My8pvyKBNePF7/WMBVvlK37u2MbSwLhMsouRi4NF4BaT xJlza1hAHCGB6YwSd879Ze9i5OSQEOCVOLJsBiuE7S8xc24jK0RRP6PE6h9LwBJsAuoSJxZPZ ASxRQSkJa59vswIUsQs0Mgo0bC3kQ0kISzgJfH82E+wBhYBVYn7Lw4zgdi8Aq4SS+98AbI5gD YoSMyZZAMS5gQK3217AHaEkICLxL2uKywTGPkWMDKsYtQoTi0qSy3SNTTUSyrKTM8oyU3MzNE 1NDDWy00tLk5MT81JTCrWS87P3cQIDBUGINjBuPq30yFGSQ4mJVHe6+dORAjxJeWnVGYkFmfE F5XmpBYfYpTh4FCS4LV6DpQTLEpNT61Iy8wBBi1MWoKDR0mE1wgkzVtckJhbnJkOkTrFqMux6 N/uN0xCLHn5ealS4ryfngEVCYAUZZTmwY2ARdAlRlkpYV5GoKOEeApSi3IzS1DlXzGKczAqCf O6gqziycwrgdv0CugIJqAjEn8eATmiJBEhJdXAWFyg0Po/+52ESI12X72O0FqpR0XBkz4lnOD 2/eP4+P3Z7Ahz5luCawqr9pw8175HW+XGwjOHUyR/OSRc/isnuKGjPzf2TV3S+z+HjoYdrdub u0BG0NFxi2CW3oZLR6OPTjl1ewLjhc87/nmHXjIXOM3jUVb+4xqLiFGN+rnX8+pj9t+sSq8pV WIpzkg01GIuKk4EAGJmjrObAgAA X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1489750534!90139755!1 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6478 invoked from network); 17 Mar 2017 11:35:36 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-13.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Mar 2017 11:35:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489750536; x=1521286536; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1LWGcflEkSGuBomx2tclLHdQhAB0wPNytt4lMfPYprY=; b=ZcTzwbdW22Ap01ruPjG5umU+GXliZiUrdJAdt39IQ9kiqOtlxPIJIX89 k5f5wiPKt1UO4bOKYACfENM9odPhMw==; Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Mar 2017 04:35:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,176,1486454400"; d="scan'208";a="237460477" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.159.159]) by fmsmga004.fm.intel.com with ESMTP; 17 Mar 2017 04:35:32 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Fri, 17 Mar 2017 19:27:15 +0800 Message-Id: <1489750043-17260-16-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1489750043-17260-1-git-send-email-tianyu.lan@intel.com> References: <1489750043-17260-1-git-send-email-tianyu.lan@intel.com> Cc: Lan Tianyu , andrew.cooper3@citrix.com, kevin.tian@intel.com, jbeulich@suse.com, chao.gao@intel.com Subject: [Xen-devel] [RFC PATCH 15/23] 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 enabled, IOAPIC Redirection Entry maybe is in remapping format. If that, generate a irq_remapping_request and send it to domain. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- xen/arch/x86/Makefile | 1 + xen/arch/x86/hvm/vioapic.c | 10 ++++++++++ xen/arch/x86/viommu.c | 30 ++++++++++++++++++++++++++++++ xen/include/asm-x86/viommu.h | 3 +++ xen/include/public/arch-x86/hvm/save.h | 1 + 5 files changed, 45 insertions(+) create mode 100644 xen/arch/x86/viommu.c diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index f75eca0..d49f8c8 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -66,6 +66,7 @@ obj-y += usercopy.o obj-y += x86_emulate.o obj-$(CONFIG_TBOOT) += tboot.o obj-y += hpet.o +obj-y += viommu.o obj-y += vm_event.o obj-y += xstate.o diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index fdbb21f..6a00644 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 @@ -285,9 +286,18 @@ static void vioapic_deliver(struct hvm_hw_vioapic *vioapic, int irq) struct domain *d = vioapic_domain(vioapic); struct vlapic *target; struct vcpu *v; + struct irq_remapping_request request; ASSERT(spin_is_locked(&d->arch.hvm_domain.irq_lock)); + if ( vioapic->redirtbl[irq].ir.format ) + { + irq_request_ioapic_fill(&request, vioapic->id, + vioapic->redirtbl[irq].bits); + 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/arch/x86/viommu.c b/xen/arch/x86/viommu.c new file mode 100644 index 0000000..ef78d3b --- /dev/null +++ b/xen/arch/x86/viommu.c @@ -0,0 +1,30 @@ +/* + * viommu.c + * + * virtualize IOMMU. + * + * Copyright (C) 2017 Chao Gao, Intel Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + */ + +#include + +void irq_request_ioapic_fill(struct 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; +} diff --git a/xen/include/asm-x86/viommu.h b/xen/include/asm-x86/viommu.h index 0b25f34..fcf3c24 100644 --- a/xen/include/asm-x86/viommu.h +++ b/xen/include/asm-x86/viommu.h @@ -49,6 +49,9 @@ struct irq_remapping_request } msg; }; +void irq_request_ioapic_fill(struct irq_remapping_request *req, + uint32_t ioapic_id, uint64_t rte); + static inline const struct viommu_ops *viommu_get_ops(void) { /* diff --git a/xen/include/public/arch-x86/hvm/save.h b/xen/include/public/arch-x86/hvm/save.h index 6127f89..06be4a5 100644 --- a/xen/include/public/arch-x86/hvm/save.h +++ b/xen/include/public/arch-x86/hvm/save.h @@ -401,6 +401,7 @@ struct hvm_hw_vioapic { uint8_t reserved[4]; uint8_t dest_id; } fields; + struct ir_ioapic_rte ir; } redirtbl[VIOAPIC_NUM_PINS]; };