From patchwork Thu Oct 2 10:02:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38286 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B88B420549 for ; Thu, 2 Oct 2014 10:06:38 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d17sf963915eek.6 for ; Thu, 02 Oct 2014 03:06:37 -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=Q5B/CHQTz5A1YNDLu+Tfj/WgPx1Us35KSZAfS88u+xw=; b=WeznircYM7MqhSi2QFDqwHQzPReGa16cHqxSXBrRBBuL2mxqvGflziIAOaFgGsjo0u Yu/j02/3+RcRfO81nlE3zkS/V/Cd8JjEFbXnzIC01Afa3vtvkOT01m2gkwkzenbA1OQ+ avKqNoacEJWXlrX+dsRvR1R0lhSI3CoxihzOkOmfhL2sbsSJjjAw3vAVFvtI5412SsjH tpUvWtQxzY44Cw34xrvU/bghkH7RGfbcwb4IsWXq8lrJvdhEhfeuneAxUZzSVLb2PmGz b2WK+0mNC5x7I2UzPsGovFgHHfBS7/dwL5Ktf1Wlnyb70YT02HcGUGSrovaWJhl4lSXR m0zg== X-Gm-Message-State: ALoCoQkJ1To4e7koqp4PR2zAk1Am3YGL1L9lzJLdq7BMG1c0gVahm4rilNpKkQK6vuBf9RgV/2Jc X-Received: by 10.112.157.193 with SMTP id wo1mr311725lbb.19.1412244397932; Thu, 02 Oct 2014 03:06:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.169 with SMTP id s9ls226415laa.47.gmail; Thu, 02 Oct 2014 03:06:37 -0700 (PDT) X-Received: by 10.112.26.103 with SMTP id k7mr24972098lbg.86.1412244397789; Thu, 02 Oct 2014 03:06:37 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx.google.com with ESMTPS id kf3si5795327lbc.68.2014.10.02.03.06.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so2042457lam.36 for ; Thu, 02 Oct 2014 03:06:37 -0700 (PDT) X-Received: by 10.112.167.137 with SMTP id zo9mr29490310lbb.0.1412244397438; Thu, 02 Oct 2014 03:06:37 -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.130.169 with SMTP id of9csp25666lbb; Thu, 2 Oct 2014 03:06:36 -0700 (PDT) X-Received: by 10.140.91.42 with SMTP id y39mr1583530qgd.58.1412244395569; Thu, 02 Oct 2014 03:06:35 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t10si6450936qat.113.2014.10.02.03.06.35 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:06:35 -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 1XZdFo-0001A7-LG; Thu, 02 Oct 2014 10:04:56 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZdFn-00019Z-Dq for xen-devel@lists.xensource.com; Thu, 02 Oct 2014 10:04:55 +0000 Received: from [193.109.254.147:3337] by server-4.bemta-14.messagelabs.com id 17/97-01677-6432D245; Thu, 02 Oct 2014 10:04:54 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1412244292!8300535!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.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 636 invoked from network); 2 Oct 2014 10:04:54 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 2 Oct 2014 10:04:54 -0000 X-IronPort-AV: E=Sophos;i="5.04,638,1406592000"; d="scan'208";a="178470624" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Thu, 2 Oct 2014 06:04:52 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XZdFe-0001pd-Na; Thu, 02 Oct 2014 11:04:46 +0100 From: Stefano Stabellini To: Date: Thu, 2 Oct 2014 11:02:38 +0100 Message-ID: <1412244158-12124-4-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: MIA2 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH 4/4] 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.215.49 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: Just keep the definition of XENFEAT_grant_map_identity. Signed-off-by: Stefano Stabellini --- 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 ++- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index e1dc330..47a3495 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -770,23 +770,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 ) { @@ -983,19 +973,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 47147ce..eac8a70 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_nr_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__ */ /*