Sébastien Frémal
2013-Jul-25 13:36 UTC
How to get the PFN of a vmalloc''ed address in a domU ?
Hello, I''ve mapped granted pages in a module inserted in a domU and I''m trying to get the PFN or the struct page * of these pages to map them in the user space : Mapping granted pages (that''s xensocket''s code) : if (!(x->buffer_area = alloc_vm_area(buffer_num_pages * PAGE_SIZE, NULL))) { DPRINTK("error: cannot allocate %d buffer pages\n", buffer_num_pages); goto err_unmap; } x->buffer_addr = (unsigned long)x->buffer_area->addr; grefp = &d->buffer_first_gref; for (i = 0; i < buffer_num_pages; i++) { printk(KERN_INFO "Mounting GREF %d\n", *grefp); memset(&op, 0, sizeof(op)); op.host_addr = x->buffer_addr + i * PAGE_SIZE; op.flags = GNTMAP_host_map; op.ref = *grefp; op.dom = x->otherend_id; rc = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1); if (rc == -ENOSYS) { goto err_unmap; } if (op.status) { DPRINTK("error: grant table mapping failed\n"); goto err_unmap; } x->buffer_handles[i] = op.handle; grefp = (int *)(x->buffer_addr + i * PAGE_SIZE); } The mapping is successful. I then try to get a reference to these pages : if(is_vmalloc_addr((void *)(x->buffer_addr+recv_offset*PAGE_SIZE))) printk(KERN_INFO "Is vmalloc addr\n"); // As this text is displayed, I verified it''s a vmalloc''ed page if(virt_addr_valid((void *)(x->buffer_addr+recv_offset*PAGE_SIZE))) printk(KERN_INFO "Is virt addr\n"); unsigned long pfn = vmalloc_to_pfn((void *)(x->buffer_addr+recv_offset*PAGE_SIZE)); printk(KERN_INFO "PFN 1 : %lu\n", pfn); // The returned PFN is "0", it''s therefore useless if(pfn_valid(pfn)){ printk(KERN_INFO "PFN 1 est valide\n"); } struct page * shPage = vmalloc_to_page((void *)(x->buffer_addr+recv_offset*PAGE_SIZE)); if(!page_count(shPage)){ printk(KERN_INFO "Error in page_count\n"); // I get a page, but the function page_count fails } I also tried to apply the operation >> PAGE_SHIFT to "manually" get the PFN but the PFN I get is not a valid PFN. Does someone please know how to get the PFN or the struct page * from a vmalloc''ed address in a domU ? Thank you, Best regards, Sebastien Fremal _______________________________________________ Xen-users mailing list Xen-users@lists.xen.org http://lists.xen.org/xen-users
Apparently Analagous Threads
- [PATCH][HVM] vmx domain save/restore support
- [PATCH 6/8] HVM save restore: guest memory handling
- [RFC PATCH] drm/virtio: Export resource handles via DMA-buf API
- [RFC PATCH] drm/virtio: Export resource handles via DMA-buf API
- [RFC PATCH] drm/virtio: Export resource handles via DMA-buf API