From patchwork Mon Oct 20 09:48:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39026 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 02166203C5 for ; Mon, 20 Oct 2014 09:51:27 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf2267030lab.6 for ; Mon, 20 Oct 2014 02:51:26 -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=WRjxXjkYLnTy612nGZoR4m2bAmeGRvHJ3mJAiwtPXa0=; b=KcK+eRQUEcD8/Jf9oYkPJB0b/OGnNiGj6DbM6T1aijdwAkf0vS00LKeIi+M5VglZ1w /zlCDNUz/yva9c+GdFfKHlahUA4zzgAS1g8THUMJ8k9EYg92CEfOsJiY3J9Yv0QmVDt8 VfUV+VvW9XPH/iwWQiRAfNBpa1YOB2+NT2b3fhTY41FvEs5P5gJbQ9zVcYaEOaZDx9SI eX6YISIvYt2oHPTDFRkwcEis7QaiT01+mcjzYWFXGMkSr7zWxn00Hq+8JA6uexNozg4Y jTZwyWPAFacZvsQtKzIdsTB7tR0L9EAB4tOjN6CPXVILinWTDcVVGWY51anigMpg9W14 5xSA== X-Gm-Message-State: ALoCoQm5R15P9HxAirGuIviW6KlN7+wW5DwW87aujVD2rZCJc/1hesEmLjCGnZf4frj5TwIN1Of3 X-Received: by 10.112.55.10 with SMTP id n10mr218678lbp.14.1413798686463; Mon, 20 Oct 2014 02:51:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.133 with SMTP id o5ls427407lal.35.gmail; Mon, 20 Oct 2014 02:51:26 -0700 (PDT) X-Received: by 10.153.11.133 with SMTP id ei5mr26235405lad.75.1413798686238; Mon, 20 Oct 2014 02:51:26 -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 xm7si13491157lbb.97.2014.10.20.02.51.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 02:51:26 -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 l4so3545799lbv.38 for ; Mon, 20 Oct 2014 02:51:26 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr26192928lad.29.1413798686098; Mon, 20 Oct 2014 02:51:26 -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 c5csp271948lbz; Mon, 20 Oct 2014 02:51:25 -0700 (PDT) X-Received: by 10.52.252.172 with SMTP id zt12mr654216vdc.7.1413798684213; Mon, 20 Oct 2014 02:51:24 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id yk10si4511383vdb.49.2014.10.20.02.51.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 20 Oct 2014 02:51:24 -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 1Xg9cC-00042Y-HK; Mon, 20 Oct 2014 09:51:00 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xg9c9-0003xW-5V for xen-devel@lists.xensource.com; Mon, 20 Oct 2014 09:50:57 +0000 Received: from [85.158.137.68:64327] by server-5.bemta-3.messagelabs.com id 9A/04-30889-00BD4445; Mon, 20 Oct 2014 09:50:56 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1413798654!10829271!1 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 28977 invoked from network); 20 Oct 2014 09:50:55 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-8.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 20 Oct 2014 09:50:55 -0000 X-IronPort-AV: E=Sophos;i="5.04,755,1406592000"; d="scan'208";a="184078603" 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; Mon, 20 Oct 2014 05:50:50 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xg9bw-0002Y1-JR; Mon, 20 Oct 2014 10:50:44 +0100 From: Stefano Stabellini To: Date: Mon, 20 Oct 2014 10:48:18 +0100 Message-ID: <1413798499-28314-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 v8 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. 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 c56ad5e..d53f627 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -779,23 +779,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 ) { @@ -992,19 +982,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