From patchwork Wed Jul 23 17:19:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 34174 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E71CA2061E for ; Wed, 23 Jul 2014 17:22:40 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id b6sf5304234yha.9 for ; Wed, 23 Jul 2014 10:22:40 -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=EnVktubo77ahYgenYIOXmjIvl6WdfKtOuaQ0nn6ht8g=; b=DAd/Vxxw6hCNn/8dcr0dr5+XiCDvOsQ0p0G2l5X3JObq34yrAhxCUhQ1koAtGOYtri uC6w/0xUFh+JqGf30NAA6eICATLHvlhK5AizRN+PaIgaFPAgTUzKTwoHfSeuSWt3ocer YA6gdeWOpTRlnvPhPvrbGlR/JrGcLOkcNUVIcT7tagZ6mKIeR+zZZBymkei4PsrJlK4V vVfGfRTxSzhO4fjjVq9LqwOCOBMjfOWERmHt9mw7XvKa5lR10IXrB6x3dih2tM7tAMRi 3P2b2OGkWUTd1jsqUgrPsCUhwYnslr1LOn1BNJeDi2FQa/fcCsrGHR4PoMvimDuZHbPW tD8Q== X-Gm-Message-State: ALoCoQnyyLywzQPk/urGPGklxiQep7lZIoHjIbtb+hY+uEwIzHbFJ1kOkfunE7Y5uUaKIgBqANFy X-Received: by 10.236.69.138 with SMTP id n10mr112320yhd.49.1406136160715; Wed, 23 Jul 2014 10:22:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls385768qgf.66.gmail; Wed, 23 Jul 2014 10:22:40 -0700 (PDT) X-Received: by 10.52.154.106 with SMTP id vn10mr3479566vdb.36.1406136160584; Wed, 23 Jul 2014 10:22:40 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id w6si2831516vco.104.2014.07.23.10.22.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 10:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so2820808vcb.19 for ; Wed, 23 Jul 2014 10:22:40 -0700 (PDT) X-Received: by 10.52.248.146 with SMTP id ym18mr3756701vdc.8.1406136160278; Wed, 23 Jul 2014 10:22:40 -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.221.37.5 with SMTP id tc5csp298055vcb; Wed, 23 Jul 2014 10:22:39 -0700 (PDT) X-Received: by 10.42.107.75 with SMTP id c11mr5021555icp.60.1406136158543; Wed, 23 Jul 2014 10:22:38 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id dp4si7779303icc.59.2014.07.23.10.22.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Jul 2014 10:22:38 -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 1XA0Dm-0005UD-Ks; Wed, 23 Jul 2014 17:20:54 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XA0Dk-0005Tk-EZ for xen-devel@lists.xensource.com; Wed, 23 Jul 2014 17:20:52 +0000 Received: from [193.109.254.147:56930] by server-12.bemta-14.messagelabs.com id 39/33-23840-3FEEFC35; Wed, 23 Jul 2014 17:20:51 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1406136047!15840566!2 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.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4386 invoked from network); 23 Jul 2014 17:20:49 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jul 2014 17:20:49 -0000 X-IronPort-AV: E=Sophos;i="5.01,718,1400025600"; d="scan'208";a="155506959" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 23 Jul 2014 17:20:47 +0000 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, 23 Jul 2014 13:20:46 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XA0DZ-0008HI-H6; Wed, 23 Jul 2014 18:20:41 +0100 From: Stefano Stabellini To: Date: Wed, 23 Jul 2014 18:19:42 +0100 Message-ID: <1406135982-15487-2-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 v2 2/2] 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.220.174 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: The flag specifies that the hypervisor maps a grant page to guest physical address == machine address of the page in addition to the normal grant mapping address. Frontends are allowed to map the same page multiple times using multiple grant references. On the backend side it can be difficult to find out the physical address corresponding to a particular machine address, especially at the completation of a dma operation. To simplify address translations, we introduce a second mapping of the grant at physical address == machine address so that dom0 can issue cache maintenance operations without having to find the pfn. Call arch_grant_map_page_identity and arch_grant_unmap_page_identity from __gnttab_map_grant_ref and __gnttab_unmap_common to introduce the second mapping if the domain is directly mapped. Signed-off-by: Stefano Stabellini --- Changes in v2: - rename XENFEAT_grant_map_11 to XENFEAT_grant_map_identity; - remove superfluous ifdef CONFIG_ARM in xen/common/kernel.c; - don't modify gnttab_need_iommu_mapping; - call arch_grant_map_page_identity and arch_grant_unmap_page_identity from grant_table functions. --- xen/common/grant_table.c | 35 +++++++++++++++++++++++++++-------- xen/common/kernel.c | 2 ++ xen/include/public/features.h | 3 +++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 464007e..06cc88f 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -727,7 +727,7 @@ __gnttab_map_grant_ref( double_gt_lock(lgt, rgt); - if ( gnttab_need_iommu_mapping(ld) ) + if ( gnttab_need_iommu_mapping(ld) || is_domain_direct_mapped(ld) ) { unsigned int wrc, rdc; int err = 0; @@ -738,13 +738,23 @@ __gnttab_map_grant_ref( !(old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) ) { if ( wrc == 0 ) - err = iommu_map_page(ld, frame, frame, - IOMMUF_readable|IOMMUF_writable); + { + if ( gnttab_need_iommu_mapping(ld) ) + err = iommu_map_page(ld, frame, frame, + IOMMUF_readable|IOMMUF_writable); + else + err = arch_grant_map_page_identity(ld, frame, true); + } } else if ( act_pin && !old_pin ) { if ( (wrc + rdc) == 0 ) - err = iommu_map_page(ld, frame, frame, IOMMUF_readable); + { + if ( gnttab_need_iommu_mapping(ld) ) + err = iommu_map_page(ld, frame, frame, IOMMUF_readable); + else + err = arch_grant_map_page_identity(ld, frame, false); + } } if ( err ) { @@ -935,15 +945,24 @@ __gnttab_unmap_common( act->pin -= GNTPIN_hstw_inc; } - if ( gnttab_need_iommu_mapping(ld) ) + if ( gnttab_need_iommu_mapping(ld) || is_domain_direct_mapped(ld) ) { unsigned int wrc, rdc; int err = 0; mapcount(lgt, rd, op->frame, &wrc, &rdc); if ( (wrc + rdc) == 0 ) - err = iommu_unmap_page(ld, op->frame); - else if ( wrc == 0 ) - err = iommu_map_page(ld, op->frame, op->frame, IOMMUF_readable); + { + if ( gnttab_need_iommu_mapping(ld) ) + err = iommu_unmap_page(ld, op->frame); + else + err = arch_grant_unmap_page_identity(ld, op->frame); + } else if ( wrc == 0 ) + { + if ( gnttab_need_iommu_mapping(ld) ) + err = iommu_map_page(ld, op->frame, op->frame, IOMMUF_readable); + else + err = arch_grant_map_page_identity(ld, op->frame, false); + } if ( err ) { rc = GNTST_general_error; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 7e83353..fa40a36 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -325,6 +325,8 @@ 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/include/public/features.h b/xen/include/public/features.h index a149aa6..ba753a0 100644 --- a/xen/include/public/features.h +++ b/xen/include/public/features.h @@ -94,6 +94,9 @@ /* operation as Dom0 is supported */ #define XENFEAT_dom0 11 +/* Xen also maps grant references at pfn = mfn */ +#define XENFEAT_grant_map_identity 12 + #define XENFEAT_NR_SUBMAPS 1 #endif /* __XEN_PUBLIC_FEATURES_H__ */