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);
where XEN_9PFS_RING_ORDER specifies the order at 4K granularity. Am I
missing something?