From patchwork Tue Sep 27 15:56:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9352173 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 C170B60757 for ; Tue, 27 Sep 2016 16:00:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21E62913C for ; Tue, 27 Sep 2016 16:00:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A68052927A; Tue, 27 Sep 2016 16:00:36 +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 C31ED2913C for ; Tue, 27 Sep 2016 16:00:34 +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 1boulg-0007Lo-2j; Tue, 27 Sep 2016 15:58:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boulf-0007LM-0c for xen-devel@lists.xenproject.org; Tue, 27 Sep 2016 15:58:03 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 20/04-01767-A079AE75; Tue, 27 Sep 2016 15:58:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXitHRDpC7n9Ff hBg0X9Sy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxbnzazF0xUq7h31L+BsVGmi5GTQ0LAX6L/ /Rc2EJtNQEfi4tydQDYHh4iAisTtvQZdjFwczAIbGCWmP77NChIXFvCR+H1XH8RkEVCVmPEgH qSTV8BF4svzA0wQE3UlHp77zQpicwq4SvS2LQCLCwHV3J35kRWiXlDi5MwnLCA2s4CmROv23+ wQtrxE89bZzBD1ihL98x6AXSMhwC3xt9t+AiP/LCTds5B0z0LSvYCReRWjRnFqUVlqka6RsV5 SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmDwMQDBDsY/8wMPMUpyMCmJ8mq0vwoX 4kvKT6nMSCzOiC8qzUktPsQow8GhJMHrMRUoJ1iUmp5akZaZA4wDmLQEB4+SCC8nSJq3uCAxt zgzHSJ1ilFRSpy3ASQhAJLIKM2Da4PF3iVGWSlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ84qATO HJzCuBm/4KaDET0OKlJ16ALC5JREhJNTBWGT7d21TpcemlpMguT8fnkoKieR1995lml+05abF 6vuv5o5FXokrDVqSr6GtbHn/S4b7taXCu4LfnOVcL7vZFyh1MPaf73DtTfu+Z702VU7deCvZa H3Hqj+b09T8ZZKxsuKaxS/FJTA3mmtFU8EjT2M/L96Lnx+XfXr95GNbc6Ln8X0z56iNKLMUZi YZazEXFiQALX2yKuAIAAA== X-Env-Sender: prvs=071b8e69e=roger.pau@citrix.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1474991877!29175510!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14095 invoked from network); 27 Sep 2016 15:58:01 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-4.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 27 Sep 2016 15:58:01 -0000 X-IronPort-AV: E=Sophos;i="5.30,405,1470700800"; d="scan'208";a="380934200" From: Roger Pau Monne To: Date: Tue, 27 Sep 2016 17:56:57 +0200 Message-ID: <1474991845-27962-3-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> References: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , boris.ostrovsky@oracle.com, Roger Pau Monne , Jan Beulich Subject: [Xen-devel] [PATCH v2 02/30] xen/x86: remove XENFEAT_hvm_pirqs for PVHv2 guests 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On PVHv2 guests we explicitly want to use native methods for routing interrupts. Introduce a new XEN_X86_EMU_USE_PIRQ to notify Xen whether a HVM guest can route physical interrupts (even from emulated devices) over event channels. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/hvm.c | 23 +++++++++++++++-------- xen/arch/x86/physdev.c | 5 +++-- xen/common/kernel.c | 3 ++- xen/include/public/arch-x86/xen.h | 4 +++- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7bad845..a291f82 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4117,6 +4117,8 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { + struct domain *d = current->domain; + switch ( cmd ) { default: @@ -4128,7 +4130,9 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case PHYSDEVOP_eoi: case PHYSDEVOP_irq_status_query: case PHYSDEVOP_get_free_pirq: - return do_physdev_op(cmd, arg); + return ((d->arch.emulation_flags & XEN_X86_EMU_USE_PIRQ) || + is_pvh_vcpu(current)) ? + do_physdev_op(cmd, arg) : -ENOSYS; } } @@ -4161,17 +4165,20 @@ static long hvm_memory_op_compat32(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) static long hvm_physdev_op_compat32( int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { + struct domain *d = current->domain; + switch ( cmd ) { - case PHYSDEVOP_map_pirq: - case PHYSDEVOP_unmap_pirq: - case PHYSDEVOP_eoi: - case PHYSDEVOP_irq_status_query: - case PHYSDEVOP_get_free_pirq: - return compat_physdev_op(cmd, arg); + case PHYSDEVOP_map_pirq: + case PHYSDEVOP_unmap_pirq: + case PHYSDEVOP_eoi: + case PHYSDEVOP_irq_status_query: + case PHYSDEVOP_get_free_pirq: + return (d->arch.emulation_flags & XEN_X86_EMU_USE_PIRQ) ? + compat_physdev_op(cmd, arg) : -ENOSYS; break; default: - return -ENOSYS; + return -ENOSYS; break; } } diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index 5a49796..0bea6e1 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -94,7 +94,8 @@ int physdev_map_pirq(domid_t domid, int type, int *index, int *pirq_p, int pirq, irq, ret = 0; void *map_data = NULL; - if ( domid == DOMID_SELF && is_hvm_domain(d) ) + if ( domid == DOMID_SELF && is_hvm_domain(d) && + (d->arch.emulation_flags & XEN_X86_EMU_USE_PIRQ) ) { /* * Only makes sense for vector-based callback, else HVM-IRQ logic @@ -265,7 +266,7 @@ int physdev_unmap_pirq(domid_t domid, int pirq) if ( ret ) goto free_domain; - if ( is_hvm_domain(d) ) + if ( is_hvm_domain(d) && (d->arch.emulation_flags & XEN_X86_EMU_USE_PIRQ) ) { spin_lock(&d->event_lock); if ( domain_pirq_to_emuirq(d, pirq) != IRQ_UNBOUND ) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index d0edb13..a82f55f 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -332,7 +332,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case guest_type_hvm: fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) | (1U << XENFEAT_hvm_callback_vector) | - (1U << XENFEAT_hvm_pirqs); + ((d->arch.emulation_flags & XEN_X86_EMU_USE_PIRQ) ? + (1U << XENFEAT_hvm_pirqs) : 0); break; } #endif diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index cdd93c1..da6f4f2 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -283,12 +283,14 @@ struct xen_arch_domainconfig { #define XEN_X86_EMU_IOMMU (1U<<_XEN_X86_EMU_IOMMU) #define _XEN_X86_EMU_PIT 8 #define XEN_X86_EMU_PIT (1U<<_XEN_X86_EMU_PIT) +#define _XEN_X86_EMU_USE_PIRQ 9 +#define XEN_X86_EMU_USE_PIRQ (1U<<_XEN_X86_EMU_USE_PIRQ) #define XEN_X86_EMU_ALL (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPET | \ XEN_X86_EMU_PM | XEN_X86_EMU_RTC | \ XEN_X86_EMU_IOAPIC | XEN_X86_EMU_PIC | \ XEN_X86_EMU_VGA | XEN_X86_EMU_IOMMU | \ - XEN_X86_EMU_PIT) + XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIRQ) uint32_t emulation_flags; }; #endif