X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=lib%2Flibrte_eal%2Flinuxapp%2Feal%2Feal_memory.c;fp=lib%2Flibrte_eal%2Flinuxapp%2Feal%2Feal_memory.c;h=41e0a9288765c95c4cfec3b4b6c8ced066a093f1;hb=7b53c036e6bf56623b8273018ff1c8cc62847857;hp=42a29fafd8d41b23df7ec544ba32f381c1fa85ce;hpb=5d4e5dcd8a186778b3d78e27c81550d07a288fd2;p=deb_dpdk.git diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 42a29faf..41e0a928 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -99,6 +99,8 @@ #include "eal_filesystem.h" #include "eal_hugepages.h" +#define PFN_MASK_SIZE 8 + #ifdef RTE_LIBRTE_XEN_DOM0 int rte_xen_dom0_supported(void) { @@ -158,7 +160,7 @@ rte_mem_lock_page(const void *virt) phys_addr_t rte_mem_virt2phy(const void *virtaddr) { - int fd; + int fd, retval; uint64_t page, physaddr; unsigned long virt_pfn; int page_size; @@ -209,10 +211,17 @@ rte_mem_virt2phy(const void *virtaddr) close(fd); return RTE_BAD_PHYS_ADDR; } - if (read(fd, &page, sizeof(uint64_t)) < 0) { + + retval = read(fd, &page, PFN_MASK_SIZE); + close(fd); + if (retval < 0) { RTE_LOG(ERR, EAL, "%s(): cannot read /proc/self/pagemap: %s\n", __func__, strerror(errno)); - close(fd); + return RTE_BAD_PHYS_ADDR; + } else if (retval != PFN_MASK_SIZE) { + RTE_LOG(ERR, EAL, "%s(): read %d bytes from /proc/self/pagemap " + "but expected %d:\n", + __func__, retval, PFN_MASK_SIZE); return RTE_BAD_PHYS_ADDR; } @@ -222,7 +231,7 @@ rte_mem_virt2phy(const void *virtaddr) */ physaddr = ((page & 0x7fffffffffffffULL) * page_size) + ((unsigned long)virtaddr % page_size); - close(fd); + return physaddr; }