From patchwork Fri Oct 17 15:31:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38892 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 362E52054E for ; Fri, 17 Oct 2014 15:36:21 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf713657wiw.7 for ; Fri, 17 Oct 2014 08:36:20 -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=1uxQkcGz34zMVa24D/8ByfDRv1rgW1sn+BedM2sNAnc=; b=cwVV/qmwdV4Mr3NQWpySM/UANJo+xwjrfegyftd24BQQkk20vrAXX/hd6yuSiQAjIj qskxfe+Qi1FTOB50szVRi0LeAQ50OiCFyAyrKiNstBxS0yKMVpcHc/CV488MBM/gny5S eHfYrx/B0fQA2ADUCHmHBjydzJO4enH5DnisEIA+SHg/cWuy1l6d7p8lAJmXUKmkkMKG tqELIwLvS8EYbiJy2bfzopvh/tW0zzivqoeWENFSu773z/sF2NfdwlmW52+rifWCWhMj NfVesEQytU2iGwf4Dci714vnKPMUNiURAs/5T90HAA0/56FWYwj1NgaQXnLc3eXijbuD AwTg== X-Gm-Message-State: ALoCoQlgPcW5RjEMWEDzPnwpasatYq3JbiX0J4D3VxJFreF3pFkVEOg4khYIUJoEc9Sh7Z5mUo6y X-Received: by 10.112.40.161 with SMTP id y1mr116690lbk.13.1413560180357; Fri, 17 Oct 2014 08:36:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.133 with SMTP id b5ls249502lah.26.gmail; Fri, 17 Oct 2014 08:36:20 -0700 (PDT) X-Received: by 10.112.157.194 with SMTP id wo2mr493955lbb.55.1413560180173; Fri, 17 Oct 2014 08:36:20 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id yg7si2520854lbb.133.2014.10.17.08.36.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 08:36:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so918461lab.2 for ; Fri, 17 Oct 2014 08:36:19 -0700 (PDT) X-Received: by 10.112.77.74 with SMTP id q10mr1363584lbw.66.1413560179793; Fri, 17 Oct 2014 08:36:19 -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 c5csp250497lbz; Fri, 17 Oct 2014 08:36:19 -0700 (PDT) X-Received: by 10.220.202.72 with SMTP id fd8mr1281554vcb.59.1413560178288; Fri, 17 Oct 2014 08:36:18 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id a2si2819203qcn.40.2014.10.17.08.36.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 17 Oct 2014 08:36:18 -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 1Xf9Y6-0000S1-Ai; Fri, 17 Oct 2014 15:34:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xf9Y4-0000R0-1g for xen-devel@lists.xensource.com; Fri, 17 Oct 2014 15:34:36 +0000 Received: from [85.158.139.211:25330] by server-5.bemta-5.messagelabs.com id 86/AE-11546-B0731445; Fri, 17 Oct 2014 15:34:35 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-14.tower-206.messagelabs.com!1413560069!6467790!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 21079 invoked from network); 17 Oct 2014 15:34:34 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 Oct 2014 15:34:34 -0000 X-IronPort-AV: E=Sophos;i="5.04,739,1406592000"; d="scan'208";a="183586912" 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; Fri, 17 Oct 2014 11:33:55 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xf9XJ-0008GX-GO; Fri, 17 Oct 2014 16:33:49 +0100 From: Stefano Stabellini To: Date: Fri, 17 Oct 2014 16:31:25 +0100 Message-ID: <1413559886-11516-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, Stefano Stabellini Subject: [Xen-devel] [PATCH v7 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.215.43 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 9d05e89..5a27ee7 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -780,23 +780,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 ) { @@ -993,19 +983,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