From patchwork Mon Oct 13 14:58:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38673 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1BC402039B for ; Mon, 13 Oct 2014 15:03:16 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id b6sf4292746lbj.7 for ; Mon, 13 Oct 2014 08:03:15 -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=ayZ0hlMqMwuqDxRqOfgDx32W4dLsjPPYgY696te33Rs=; b=TeP0O6xw+FYreAUFRGzezzqBp1KBtcsxgZdGtuPeIbrfM5dxbrwb8lROUetuprPVB/ g3MpC/JJzwgAvyMS/AR/56sOxqOQmzDKcfmYgSOjGAtFW5T38GdnOC17KF5+JXQVYQ7Z la9XsxVSAsGMbGZxFTCbHNrF94JxmynnoDoWJW7BnPxKttGAwB+0qZmqR5yr1f7f++gW yMXzjTPy8aiIgXPBBuC6fghEYShHdFyyrGIcG8HHz1LagcfaBM5YSMmrwmx3/2Z6cpI9 d/vVJvQDi/GYNr5TSxD0d1rG1gGUYwmr+4QCObPBiNAhFuutlhKTIKJFb7su2siy27+8 ERNw== X-Gm-Message-State: ALoCoQman6wCdZS1hkCniDvO8OpwIc3PVtTmrasNZ2iEQd8AkHVRUXpUvtP60o+Rx8SRZExrbbWO X-Received: by 10.112.34.52 with SMTP id w20mr2709527lbi.5.1413212595817; Mon, 13 Oct 2014 08:03:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.6.7 with SMTP id cq7ls39464lad.8.gmail; Mon, 13 Oct 2014 08:03:15 -0700 (PDT) X-Received: by 10.152.203.204 with SMTP id ks12mr25183806lac.65.1413212595644; Mon, 13 Oct 2014 08:03:15 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx.google.com with ESMTPS id be18si18952536lab.113.2014.10.13.08.03.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Oct 2014 08:03:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so6459911lbd.20 for ; Mon, 13 Oct 2014 08:03:15 -0700 (PDT) X-Received: by 10.112.190.69 with SMTP id go5mr24400307lbc.32.1413212595327; Mon, 13 Oct 2014 08:03:15 -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 c5csp230864lbz; Mon, 13 Oct 2014 08:03:14 -0700 (PDT) X-Received: by 10.140.108.244 with SMTP id j107mr35099613qgf.31.1413212593413; Mon, 13 Oct 2014 08:03:13 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l9si25137743qae.53.2014.10.13.08.03.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 13 Oct 2014 08:03:13 -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 1Xdh7o-0004KH-Sm; Mon, 13 Oct 2014 15:01:28 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xdh7m-0004Gu-FP for xen-devel@lists.xensource.com; Mon, 13 Oct 2014 15:01:26 +0000 Received: from [85.158.143.35:38198] by server-3.bemta-4.messagelabs.com id 70/90-06192-549EB345; Mon, 13 Oct 2014 15:01:25 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1413212482!12583756!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19830 invoked from network); 13 Oct 2014 15:01:25 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Oct 2014 15:01:25 -0000 X-IronPort-AV: E=Sophos;i="5.04,711,1406592000"; d="scan'208";a="180809053" 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, 13 Oct 2014 11:01:09 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xdh7P-0008Ho-U4; Mon, 13 Oct 2014 16:01:03 +0100 From: Stefano Stabellini To: Date: Mon, 13 Oct 2014 15:58:43 +0100 Message-ID: <1413212324-664-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: MIA2 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v5 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.175 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 --- 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 1371e6d..9cdd422 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -778,23 +778,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 ) { @@ -991,19 +981,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