From patchwork Sat Oct 29 08:59:47 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: 9403501 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 911656070E for ; Sat, 29 Oct 2016 09:03:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F8F12A4BF for ; Sat, 29 Oct 2016 09:03:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 742882A507; Sat, 29 Oct 2016 09:03:34 +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 581902A4F3 for ; Sat, 29 Oct 2016 09:03:33 +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 1c0PUw-0001rK-J5; Sat, 29 Oct 2016 09:00:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0PUv-0001r0-NL for xen-devel@lists.xenproject.org; Sat, 29 Oct 2016 09:00:17 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id F9/08-01148-12564185; Sat, 29 Oct 2016 09:00:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXitHSDva5Cqki Ewd8zShbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8adFf3sBdO0KubOnsXawDhZvouRk0NCwF/i xJvTbCA2m4COxMW5O8FsEYFYiXWNV5m6GDk4mAXKJWbciAcJCwv4SSy+3cEKYrMIqEr8b57CD GLzCrhIrFm1mx1ipK7Ew3O/WUFaOQVcJfoWqYKEhYBKGr8/YIUoF5Q4OfMJC4jNLKAp0br9Nz uELS/RvHU2M0S9okT/vAdsECO5JW6fnso8gZF/FpL2WUjaZyFpX8DIvIpRozi1qCy1SNfQWC+ pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzAAGYBgB+OXZQGHGCU5mJREeb99EY4Q 4kvKT6nMSCzOiC8qzUktPsQow8GhJME7NVkkQkiwKDU9tSItMwcYCzBpCQ4eJRHePpA0b3FBY m5xZjpE6hSjopQ4bw5IQgAkkVGaB9cGi79LjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuY9Bz KFJzOvBG76K6DFTECLp6cLgCwuSURISTUwsiz9K33q/uIct2VW7r1LbvL7rph3W7va8pTIZI7 FHsHPZj9k+mVyyHWS+vyCLyxs6wvKV4tU7ligKcbo4y52tPjPhYy1i3IvHHrvYJ5k7ep85M/m RVYr7YrObueeHtAn6/Emf4ldWfgqy2+tajt0XZVW5iyJvzQxLe5W5Ip7W0SK2A049oRoKLEUZ yQaajEXFScCADF1kLC6AgAA X-Env-Sender: prvs=103fc987f=roger.pau@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1477731615!32644329!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51731 invoked from network); 29 Oct 2016 09:00:16 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 29 Oct 2016 09:00:16 -0000 X-IronPort-AV: E=Sophos;i="5.31,414,1473120000"; d="scan'208";a="395329324" From: Roger Pau Monne To: , , Date: Sat, 29 Oct 2016 10:59:47 +0200 Message-ID: <1477731601-10926-2-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1477731601-10926-1-git-send-email-roger.pau@citrix.com> References: <1477731601-10926-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v3.1 01/15] 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 PVHv2 guests, unlike HVM guests, won't have the option to route interrupts from physical or emulated devices over event channels using PIRQs. This applies to both DomU and Dom0 PVHv2 guests. 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, and is thus allowed to use some of the PHYSDEV ops. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- Changes since v2: - Change local variable name to currd instead of d. - Use currd where it makes sense. --- xen/arch/x86/hvm/hvm.c | 25 ++++++++++++++++--------- xen/arch/x86/physdev.c | 5 +++-- xen/common/kernel.c | 3 ++- xen/include/public/arch-x86/xen.h | 4 +++- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 11e2b82..e516b20 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4164,10 +4164,12 @@ 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 *currd = current->domain; + switch ( cmd ) { default: - if ( !is_pvh_vcpu(current) || !is_hardware_domain(current->domain) ) + if ( !is_pvh_domain(currd) || !is_hardware_domain(currd) ) return -ENOSYS; /* fall through */ case PHYSDEVOP_map_pirq: @@ -4175,7 +4177,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 ((currd->arch.emulation_flags & XEN_X86_EMU_USE_PIRQ) || + is_pvh_domain(currd)) ? + do_physdev_op(cmd, arg) : -ENOSYS; } } @@ -4208,17 +4212,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