From patchwork Wed Oct 22 16:40:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39326 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 44948202DB for ; Wed, 22 Oct 2014 16:45:13 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id m15sf2239211wgh.11 for ; Wed, 22 Oct 2014 09:45:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=ZRwEffq97BGlpDRw72MxZdR+el21x3jtuVRGWGLCyIs=; b=MKcoFYP8znN+ivRevo8CIFgiipRSbI6fgITl0VpKMikRfxldWAkNHGEgC+QFVR2Qn9 sQAEhYyrwoLDEc7cEmOl6eiJtFDw7XSlOmqTPbUlWSffaZTkhdnu1Y2gprCk90snwEOh 9BM5aHyNlmNZV+13xy3QhyGjmhXtwVJAVqKFQ3YMquwLS9NHkgHFyuI8iUC9CMYEDHDF Eb8Gbiilb5WIkgVP7aBbY1at0lejoDOMOlv9wX8nwpUMrJO8gUjrAHA9ZcPFaGmDRb0P 0lSkhWWUuVad6TMZLJZbbpznGqJOitQZlfuK5U++HWw51BrfqVB3xmrRG9d61Hgjo/kD cQKA== X-Gm-Message-State: ALoCoQnJmwXSgQIDkew/CCx4wBTJesWPRzxny6mO6mdPUJ5iR1+82NgxRadCJVOnMd3YgXy9lH6P X-Received: by 10.112.26.82 with SMTP id j18mr387093lbg.16.1413996312300; Wed, 22 Oct 2014 09:45:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.167 with SMTP id kr7ls209031lac.94.gmail; Wed, 22 Oct 2014 09:45:12 -0700 (PDT) X-Received: by 10.152.27.134 with SMTP id t6mr42564423lag.17.1413996312114; Wed, 22 Oct 2014 09:45:12 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id n7si24031919laj.61.2014.10.22.09.45.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 09:45:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so3190793lbv.10 for ; Wed, 22 Oct 2014 09:45:12 -0700 (PDT) X-Received: by 10.152.120.199 with SMTP id le7mr8875779lab.67.1413996312013; Wed, 22 Oct 2014 09:45:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp110840lbz; Wed, 22 Oct 2014 09:45:08 -0700 (PDT) X-Received: by 10.224.1.200 with SMTP id 8mr55683370qag.54.1413996305467; Wed, 22 Oct 2014 09:45:05 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id j15si23248323qae.81.2014.10.22.09.45.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Oct 2014 09:45:05 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xgz0M-00049Z-Dy; Wed, 22 Oct 2014 16:43:22 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xgz0K-00048T-2E for xen-devel@lists.xensource.com; Wed, 22 Oct 2014 16:43:20 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 86/56-02952-7AED7445; Wed, 22 Oct 2014 16:43:19 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1413996193!12015823!5 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28684 invoked from network); 22 Oct 2014 16:43:18 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-10.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Oct 2014 16:43:18 -0000 X-IronPort-AV: E=Sophos;i="5.04,769,1406592000"; d="scan'208";a="185164555" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Wed, 22 Oct 2014 12:43:10 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xgz05-0001kp-EX; Wed, 22 Oct 2014 17:43:05 +0100 From: Stefano Stabellini To: Date: Wed, 22 Oct 2014 17:40:36 +0100 Message-ID: <1413996037-2747-7-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, JBeulich@suse.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v11 7/8] Revert "xen/arm: introduce XENFEAT_grant_map_identity" X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Revert commit id 8d09ef6906ca0a9957e21334ad2c3eed626abe63. Just keep the definition of XENFEAT_grant_map_identity. XENFEAT_grant_map_identity is superseeded by GNTTABOP_cache_flush. As XENFEAT_grant_map_identity causes additional tlb flushes, it is best to remove the feature entirely now. Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall Acked-by: Ian Campbell --- Changes in v2: - comment out the definition of XENFEAT_grant_map_identity. --- xen/common/grant_table.c | 30 +++++------------------------- xen/common/kernel.c | 2 -- xen/drivers/passthrough/arm/smmu.c | 33 +++++++++++++++++++++++++++++++++ xen/include/asm-arm/grant_table.h | 3 ++- xen/include/public/features.h | 4 +++- 5 files changed, 43 insertions(+), 29 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 9b1c338..6b3c1cd 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -786,23 +786,13 @@ __gnttab_map_grant_ref( !(old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) ) { if ( wrc == 0 ) - { - if ( is_domain_direct_mapped(ld) ) - err = arch_grant_map_page_identity(ld, frame, 1); - else - err = iommu_map_page(ld, frame, frame, - IOMMUF_readable|IOMMUF_writable); - } + err = iommu_map_page(ld, frame, frame, + IOMMUF_readable|IOMMUF_writable); } else if ( act_pin && !old_pin ) { if ( (wrc + rdc) == 0 ) - { - if ( is_domain_direct_mapped(ld) ) - err = arch_grant_map_page_identity(ld, frame, 0); - else - err = iommu_map_page(ld, frame, frame, IOMMUF_readable); - } + err = iommu_map_page(ld, frame, frame, IOMMUF_readable); } if ( err ) { @@ -999,19 +989,9 @@ __gnttab_unmap_common( int err = 0; mapcount(lgt, rd, op->frame, &wrc, &rdc); if ( (wrc + rdc) == 0 ) - { - if ( is_domain_direct_mapped(ld) ) - err = arch_grant_unmap_page_identity(ld, op->frame); - else - err = iommu_unmap_page(ld, op->frame); - } + err = iommu_unmap_page(ld, op->frame); else if ( wrc == 0 ) - { - if ( is_domain_direct_mapped(ld) ) - err = arch_grant_map_page_identity(ld, op->frame, 0); - else - err = iommu_map_page(ld, op->frame, op->frame, IOMMUF_readable); - } + err = iommu_map_page(ld, op->frame, op->frame, IOMMUF_readable); if ( err ) { rc = GNTST_general_error; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index ce65486..d23c422 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -332,8 +332,6 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) break; } #endif - if ( is_domain_direct_mapped(d) ) - fi.submap |= 1U << XENFEAT_grant_map_identity; break; default: return -EINVAL; diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 3cbd206..9a95ac9 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -1536,6 +1536,37 @@ static void arm_smmu_iommu_domain_teardown(struct domain *d) xfree(smmu_domain); } +static int arm_smmu_map_page(struct domain *d, unsigned long gfn, + unsigned long mfn, unsigned int flags) +{ + /* Grant mappings can be used for DMA requests. The dev_bus_addr returned by + * the hypercall is the MFN (not the IPA). For device protected by + * an IOMMU, Xen needs to add a 1:1 mapping in the domain p2m to + * allow DMA request to work. + * This is only valid when the domain is directed mapped. Hence this + * function should only be used by gnttab code with gfn == mfn. + */ + BUG_ON(!is_domain_direct_mapped(d)); + BUG_ON(mfn != gfn); + + /* We only support readable and writable flags */ + if ( !(flags & (IOMMUF_readable | IOMMUF_writable)) ) + return -EINVAL; + + return arch_grant_map_page_identity(d, mfn, flags & IOMMUF_writable); +} + +static int arm_smmu_unmap_page(struct domain *d, unsigned long gfn) +{ + /* This function should only be used by gnttab code when the domain + * is direct mapped + */ + if ( !is_domain_direct_mapped(d) ) + return -EINVAL; + + return arch_grant_unmap_page_identity(d, gfn); +} + static const struct iommu_ops arm_smmu_iommu_ops = { .init = arm_smmu_iommu_domain_init, .hwdom_init = arm_smmu_iommu_hwdom_init, @@ -1544,6 +1575,8 @@ static const struct iommu_ops arm_smmu_iommu_ops = { .iotlb_flush_all = arm_smmu_iotlb_flush_all, .assign_dt_device = arm_smmu_attach_dev, .reassign_dt_device = arm_smmu_reassign_dt_dev, + .map_page = arm_smmu_map_page, + .unmap_page = arm_smmu_unmap_page, }; static int __init smmu_init(struct dt_device_node *dev, diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h index e798880..0edad67 100644 --- a/xen/include/asm-arm/grant_table.h +++ b/xen/include/asm-arm/grant_table.h @@ -33,7 +33,8 @@ static inline int replace_grant_supported(void) ( ((i >= nr_grant_frames(d->grant_table)) && \ (i < max_grant_frames)) ? 0 : (d->arch.grant_table_gpfn[i])) -#define gnttab_need_iommu_mapping(d) (is_domain_direct_mapped(d)) +#define gnttab_need_iommu_mapping(d) \ + (is_domain_direct_mapped(d) && need_iommu(d)) #endif /* __ASM_GRANT_TABLE_H__ */ /* diff --git a/xen/include/public/features.h b/xen/include/public/features.h index b7bf83f..16d92aa 100644 --- a/xen/include/public/features.h +++ b/xen/include/public/features.h @@ -94,8 +94,10 @@ /* operation as Dom0 is supported */ #define XENFEAT_dom0 11 -/* Xen also maps grant references at pfn = mfn */ +/* Xen also maps grant references at pfn = mfn. + * This feature flag is deprecated and should not be used. #define XENFEAT_grant_map_identity 12 + */ #define XENFEAT_NR_SUBMAPS 1