From patchwork Wed Jul 23 13:31:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 34156 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B8652061E for ; Wed, 23 Jul 2014 13:34:43 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id m1sf7605720oag.7 for ; Wed, 23 Jul 2014 06:34:42 -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:date:from:to:in-reply-to:message-id :references:user-agent: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=T+SrYCqJvmbEmWhQO4ZhOH5DV1NGQWLB+eT2JlXt2Tw=; b=BZyYvejycCtpJnOcPU4l+sha14+JM6o+Hv4k65uQqgace7kYtIjBpSiycxNDfOM5FF LPUZfm7eh4QZIdgqzBKn4VVMnSzNUULmpMufOAXIwzc6FF9zaOPpZYAaagiomvifyCmH 2wZ9V85Udo/Ngz1+pPUftKVfhltHZ0KjZLiP1ap6u+NUgSwFt2XiAgmBvMO3vuCqzJOX SEJ9KV7hN6/wmuCN3rKetMqjuxo6tI/54VLv3BNJD8AtdUAnaJx5L/OowAtmcs8uHetN cC6RCIqJpa/UbkSC7nwiE2vy411kqNaZbfhI/x8HKYKkHE1lZo30b4lVUmRwDAMAAvwh L+Tg== X-Gm-Message-State: ALoCoQmobZRIvWOSH3gfmGCUdavk1GFz68cWvyPommvinwFXQuiWOtVGTK9nU3Qs3chMFPozNXkU X-Received: by 10.43.149.193 with SMTP id kl1mr870825icc.5.1406122482740; Wed, 23 Jul 2014 06:34:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.21 with SMTP id 21ls348641qgs.58.gmail; Wed, 23 Jul 2014 06:34:42 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr2376943vcy.8.1406122482601; Wed, 23 Jul 2014 06:34:42 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id ey8si2003172vdc.18.2014.07.23.06.34.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 06:34:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so2115815vcb.39 for ; Wed, 23 Jul 2014 06:34:41 -0700 (PDT) X-Received: by 10.52.37.81 with SMTP id w17mr1590908vdj.95.1406122481738; Wed, 23 Jul 2014 06:34:41 -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 tc5csp280037vcb; Wed, 23 Jul 2014 06:34:41 -0700 (PDT) X-Received: by 10.50.56.38 with SMTP id x6mr3826754igp.30.1406122480588; Wed, 23 Jul 2014 06:34:40 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id yx8si6150670icb.42.2014.07.23.06.34.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Jul 2014 06:34:40 -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 1X9wf6-0002WP-9Y; Wed, 23 Jul 2014 13:32:52 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9wf4-0002WC-N9 for xen-devel@lists.xenproject.org; Wed, 23 Jul 2014 13:32:50 +0000 Received: from [85.158.139.211:61267] by server-14.bemta-5.messagelabs.com id 04/5A-12422-289BFC35; Wed, 23 Jul 2014 13:32:50 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1406122367!17137962!1 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.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28124 invoked from network); 23 Jul 2014 13:32:49 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jul 2014 13:32:49 -0000 X-IronPort-AV: E=Sophos;i="5.01,717,1400025600"; d="scan'208";a="154910419" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 23 Jul 2014 13:32:47 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.3.181.6; Wed, 23 Jul 2014 09:32: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 1X9wf0-0003wu-NT; Wed, 23 Jul 2014 14:32:46 +0100 Date: Wed, 23 Jul 2014 14:31:48 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Jan Beulich In-Reply-To: <53CFB5FC02000078000250C0@mail.emea.novell.com> Message-ID: References: <1404834794-16055-2-git-send-email-stefano.stabellini@eu.citrix.com> <53CFB5FC02000078000250C0@mail.emea.novell.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@citrix.com, xen-devel , Ian.Campbell@citrix.com, Stefano Stabellini Subject: Re: [Xen-devel] [RFC PATCH 2/2] xen/arm: introduce XENFEAT_grant_map_11 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.180 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: On Wed, 23 Jul 2014, Jan Beulich wrote: > >>> On 08.07.14 at 17:53, wrote: > > --- a/xen/common/kernel.c > > +++ b/xen/common/kernel.c > > @@ -325,6 +325,10 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) > > break; > > } > > #endif > > +#ifdef CONFIG_ARM > > + if ( is_domain_direct_mapped(d) ) > > The #ifdef and if() seem kind of redundant - can't x86 simply get a > stub always returning false? Yes, you are right > > --- a/xen/include/asm-arm/grant_table.h > > +++ b/xen/include/asm-arm/grant_table.h > > @@ -33,8 +33,7 @@ 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) && need_iommu(d)) > > +#define gnttab_need_iommu_mapping(d) (is_domain_direct_mapped(d)) > > How is this change related to the subject of the patch? This change is the one that actually enables the second mapping on ARM. gnttab_need_iommu_mapping needs to return true for dom0, so that arch_iommu_grant_map_page gets called by __gnttab_map_grant_ref. I understand that actually XENFEAT_grant_map_11 doesn't have much to do with IOMMUs or SMMUs, however it would still be nice to share the code under: if ( gnttab_need_iommu_mapping(ld) ) { in __gnttab_map_grant_ref. An alternative to this change that would also get rid of patch #1 of this series could be something like: do you think this would be better? > > --- 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_11 12 > > As already said by others, this needs a better name. I'll rename it to XENFEAT_grant_map_identity diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 464007e..e4e945a 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(ld, frame, IOMMUF_readable|IOMMUF_writable); + } } 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(ld, frame, IOMMUF_readable); + } } if ( err ) {