From patchwork Fri Feb 28 12:26:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11412167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46CC114B4 for ; Fri, 28 Feb 2020 12:27:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D201246AC for ; Fri, 28 Feb 2020 12:27:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D201246AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j7ej0-0000Pb-W4; Fri, 28 Feb 2020 12:26:38 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j7eiz-0000PL-M9 for xen-devel@lists.xenproject.org; Fri, 28 Feb 2020 12:26:37 +0000 X-Inumbo-ID: 8fc238be-5a25-11ea-991c-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8fc238be-5a25-11ea-991c-12813bfff9fa; Fri, 28 Feb 2020 12:26:36 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4ACDDB00D; Fri, 28 Feb 2020 12:26:35 +0000 (UTC) From: Jan Beulich To: "xen-devel@lists.xenproject.org" References: Message-ID: <96db3325-fdc0-366a-5b14-e38d61dc0e9c@suse.com> Date: Fri, 28 Feb 2020 13:26:45 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: [Xen-devel] [PATCH 2/5] IOMMU: iommu_intpost is x86/HVM-only X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Wilk , George Dunlap , Andrew Cooper , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Provide a #define for all other cases. Signed-off-by: Jan Beulich --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1309,6 +1309,9 @@ boolean (e.g. `iommu=no`) can override t This option depends on `intremap`, and is disabled by default due to some corner cases in the implementation which have yet to be resolved. + This option is not valid on Arm, or on x86 builds of Xen without HVM + support. + * The `crash-disable` boolean controls disabling IOMMU functionality (DMAR/IR/QI) before switching to a crash kernel. This option is inactive by default and is for compatibility with older kdump kernels only. Modern kernels copy --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -43,14 +43,6 @@ bool __read_mostly iommu_hwdom_passthrou bool __hwdom_initdata iommu_hwdom_inclusive; int8_t __hwdom_initdata iommu_hwdom_reserved = -1; -/* - * In the current implementation of VT-d posted interrupts, in some extreme - * cases, the per cpu list which saves the blocked vCPU will be very long, - * and this will affect the interrupt latency, so let this feature off by - * default until we find a good solution to resolve it. - */ -bool_t __read_mostly iommu_intpost; - #ifndef iommu_hap_pt_share bool __read_mostly iommu_hap_pt_share = true; #endif @@ -93,8 +85,10 @@ static int __init parse_iommu_param(cons else if ( (val = parse_boolean("intremap", s, ss)) >= 0 ) iommu_intremap = val ? iommu_intremap_full : iommu_intremap_off; #endif +#ifndef iommu_intpost else if ( (val = parse_boolean("intpost", s, ss)) >= 0 ) iommu_intpost = val; +#endif #ifdef CONFIG_KEXEC else if ( (val = parse_boolean("crash-disable", s, ss)) >= 0 ) iommu_crash_disable = val; @@ -486,8 +480,10 @@ int __init iommu_setup(void) panic("Couldn't enable %s and iommu=required/force\n", !iommu_enabled ? "IOMMU" : "Interrupt Remapping"); +#ifndef iommu_intpost if ( !iommu_intremap ) iommu_intpost = 0; +#endif printk("I/O virtualisation %sabled\n", iommu_enabled ? "en" : "dis"); if ( !iommu_enabled ) @@ -563,10 +559,13 @@ void iommu_crash_shutdown(void) if ( iommu_enabled ) iommu_get_ops()->crash_shutdown(); - iommu_enabled = iommu_intpost = 0; + iommu_enabled = false; #ifndef iommu_intremap iommu_intremap = iommu_intremap_off; #endif +#ifndef iommu_intpost + iommu_intpost = false; +#endif } int iommu_get_reserved_device_memory(iommu_grdm_t *func, void *ctxt) --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2297,13 +2297,15 @@ static int __init vtd_setup(void) if ( iommu_intremap && !ecap_intr_remap(iommu->ecap) ) iommu_intremap = iommu_intremap_off; +#ifndef iommu_intpost /* * We cannot use posted interrupt if X86_FEATURE_CX16 is * not supported, since we count on this feature to * atomically update 16-byte IRTE in posted format. */ if ( !cap_intr_post(iommu->cap) || !iommu_intremap || !cpu_has_cx16 ) - iommu_intpost = 0; + iommu_intpost = false; +#endif if ( !vtd_ept_page_compatible(iommu) ) clear_iommu_hap_pt_share(); @@ -2330,7 +2332,9 @@ static int __init vtd_setup(void) P(iommu_hwdom_passthrough, "Dom0 DMA Passthrough"); P(iommu_qinval, "Queued Invalidation"); P(iommu_intremap, "Interrupt Remapping"); +#ifndef iommu_intpost P(iommu_intpost, "Posted Interrupt"); +#endif P(iommu_hap_pt_share, "Shared EPT tables"); #undef P @@ -2348,7 +2352,9 @@ static int __init vtd_setup(void) iommu_hwdom_passthrough = false; iommu_qinval = 0; iommu_intremap = iommu_intremap_off; - iommu_intpost = 0; +#ifndef iommu_intpost + iommu_intpost = false; +#endif return ret; } --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -29,6 +29,16 @@ struct iommu_ops __read_mostly iommu_ops enum iommu_intremap __read_mostly iommu_intremap = iommu_intremap_full; +#ifndef iommu_intpost +/* + * In the current implementation of VT-d posted interrupts, in some extreme + * cases, the per cpu list which saves the blocked vCPU will be very long, + * and this will affect the interrupt latency, so let this feature off by + * default until we find a good solution to resolve it. + */ +bool __read_mostly iommu_intpost; +#endif + int __init iommu_hardware_setup(void) { struct IO_APIC_route_entry **ioapic_entries = NULL; --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -54,7 +54,7 @@ static inline bool_t dfn_eq(dfn_t x, dfn extern bool_t iommu_enable, iommu_enabled; extern bool force_iommu, iommu_quarantine, iommu_verbose, iommu_igfx; -extern bool_t iommu_snoop, iommu_qinval, iommu_intpost; +extern bool_t iommu_snoop, iommu_qinval; #ifdef CONFIG_X86 extern enum __packed iommu_intremap { @@ -70,6 +70,12 @@ extern enum __packed iommu_intremap { # define iommu_intremap false #endif +#if defined(CONFIG_X86) && defined(CONFIG_HVM) +extern bool iommu_intpost; +#else +# define iommu_intpost false +#endif + #if defined(CONFIG_IOMMU_FORCE_PT_SHARE) #define iommu_hap_pt_share true #elif defined(CONFIG_HVM)