Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752852AbdCHMep (ORCPT ); Wed, 8 Mar 2017 07:34:45 -0500 Received: from foss.arm.com ([217.140.101.70]:58814 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752157AbdCHMen (ORCPT ); Wed, 8 Mar 2017 07:34:43 -0500 Subject: Re: [Xen-devel] [PATCH 4/7] xen/9pfs: connect to the backend To: Stefano Stabellini References: <1488830488-18506-1-git-send-email-sstabellini@kernel.org> <1488830488-18506-4-git-send-email-sstabellini@kernel.org> Cc: xen-devel@lists.xenproject.org, jgross@suse.com, Latchesar Ionkov , Eric Van Hensbergen , linux-kernel@vger.kernel.org, Stefano Stabellini , v9fs-developer@lists.sourceforge.net, Ron Minnich , boris.ostrovsky@oracle.com From: Julien Grall Message-ID: <28e5fcdb-8943-d059-ae9b-d1a73e40297f@arm.com> Date: Wed, 8 Mar 2017 12:25:37 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1298 Lines: 41 Hi Stefano, On 08/03/17 00:49, Stefano Stabellini wrote: > On Tue, 7 Mar 2017, Julien Grall wrote: >> On 03/06/2017 08:01 PM, Stefano Stabellini wrote: >>> + if (ring->bytes == NULL) >>> + goto error; >>> + for (i = 0; i < (1 << XEN_9PFS_RING_ORDER); i++) >>> + ring->intf->ref[i] = >>> gnttab_grant_foreign_access(dev->otherend_id, >>> pfn_to_gfn(virt_to_pfn((void*)ring->bytes) + i), 0);. >> >> Please use virt_to_gfn rather than pfn_to_gfn(virt_to_pfn). > > OK > > >> Also, this is not going to work on 64K kernel because you will grant access to >> noncontiguous memory (e.g 0-4K, 64K-68K,...). > > By using virt_to_gfn like you suggested, the loop will correctly iterate > on a 4K by 4K basis, even on a 64K kernel: > > ring->bytes = (void*)__get_free_pages(GFP_KERNEL | __GFP_ZERO, > XEN_9PFS_RING_ORDER - (PAGE_SHIFT - XEN_PAGE_SHIFT)); > for (i = 0; i < (1 << XEN_9PFS_RING_ORDER); i++) > ring->intf->ref[i] = gnttab_grant_foreign_access(dev->otherend_id, virt_to_gfn((void*)ring->bytes) + i, 0); BTW, the cast (void *) is not necessary. > > where XEN_9PFS_RING_ORDER specifies the order at 4K granularity. Am I > missing something? I think it is fine. You could move virt_to_gfn(...) outside and avoid to do the translation everytime. Cheers, -- Julien Grall