tag:blogger.com,1999:blog-7633821106051275217.post4253445023042724534..comments2023-10-26T05:19:08.981-04:00Comments on Five Lines of Code: How to translate virtual to physical addresses through /proc/pid/pagemapD-manhttp://www.blogger.com/profile/00977517200271707010noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-7633821106051275217.post-21502221427950345852022-08-28T12:16:51.988-04:002022-08-28T12:16:51.988-04:00Naaptol prize departmentwill appear here after cli...<b><a href="https://www.naaptolwinnerprizes.in/" rel="nofollow">Naaptol prize department</a></b>will appear here after clicking.<b><a href="https://www.naaptolwinnerprizes.in/" rel="nofollow">Naaptol Lucky Draw 2022</a></b> is already here. you can contact Naaptol lucky customer just now.Shopclues Winner Listhttps://www.blogger.com/profile/17197231984461371153noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-81237657688763039282022-05-15T12:20:29.374-04:002022-05-15T12:20:29.374-04:00Aswindow is one of the largest Aluminium and upvc...<b> <a rel="nofollow">Aswindow</a></b> is one of the largest Aluminium and <b> <a rel="nofollow">upvc doors and windows manufacturers Delhi</a></b> India. It provides quality Aluminium and upvc doors and windows manufacturers delhi.Aswindowhttps://www.blogger.com/profile/08903000648599310247noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-26165650913479413332022-01-31T04:33:58.575-05:002022-01-31T04:33:58.575-05:00Dear Customer Registration Ya Koi Aur Charges Pay ...Dear Customer Registration Ya Koi Aur Charges Pay Karne Se Pehle Hamain Whatsapp Ya Call Karen Hamara Whatsapp Number 7430074723 Hai. Aur Helpline Number 7430074723 Hai. Naaptol,Naaptol winners, Naaptol lottery winners, Naaptol lucky winners, Naaptol lucky draw, <a href="https://winnernaaptol.co.in/" rel="nofollow">Naaptol winner list 2022</a>, Naaptol tata safari winners, Naaptol tata safari winners 2022Anonymoushttps://www.blogger.com/profile/06391109786432424742noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-42729457533007179482021-12-11T04:52:11.517-05:002021-12-11T04:52:11.517-05:00physical or virtual office<a href="https:/...<a href="https://www.euify.eu/" rel="nofollow">physical or virtual office</a><a href="https://www.euify.eu/:/https://www.euify.eu/</agajendrahttps://www.blogger.com/profile/13735752493584250999noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-24802282641283588752021-10-25T12:02:11.504-04:002021-10-25T12:02:11.504-04:00Get to know the lucky winner list and prize-relate...Get to know the lucky winner list and prize-related information directly from our <b><a href="https://www.naaptolwinnerprizes.in" rel="nofollow">Naaptol prize department </a></b> helpline number .<br /><b><a href="https://www.naaptolwinnerprizes.in" rel="nofollow">Naaptol winner list 2021</a></b><br /><b><a href="https://sites.google.com/view/naaptolprizelist/" rel="nofollow">Naaptol lucky winner 2021</a></b>naaptol-winner-list-2020https://www.blogger.com/profile/08404501302237542294noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-66707406035966378512021-09-03T19:30:51.081-04:002021-09-03T19:30:51.081-04:00I thought not, but this code still works in 2021 !...I thought not, but this code still works in 2021 !!!. << On the condition that the program is run as root >>. Neverthelessit is absurd to do cat / proc / self / maps and then pagemap PID virtaddress, because then cat is no longer in memory (cat is self). Obviously many things have changed since 2014 when this code was published.Alexander Villalbahttps://www.blogger.com/profile/15515602186987875248noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-46101567340730281822021-09-03T18:54:37.986-04:002021-09-03T18:54:37.986-04:00This comment has been removed by the author.Alexander Villalbahttps://www.blogger.com/profile/15515602186987875248noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-32946210179207976942021-09-03T18:53:57.164-04:002021-09-03T18:53:57.164-04:00This comment has been removed by the author.Alexander Villalbahttps://www.blogger.com/profile/15515602186987875248noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-40471875710159383582021-09-03T18:43:30.689-04:002021-09-03T18:43:30.689-04:00This comment has been removed by the author.Alexander Villalbahttps://www.blogger.com/profile/15515602186987875248noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-8679276927636328612021-09-03T08:14:38.915-04:002021-09-03T08:14:38.915-04:00This comment has been removed by the author.Alexander Villalbahttps://www.blogger.com/profile/15515602186987875248noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-61094342285105241972021-04-15T04:44:34.568-04:002021-04-15T04:44:34.568-04:00ubu-eng-016:~$ ./a.out self 0x5555555540000
Big e...ubu-eng-016:~$ ./a.out self 0x5555555540000<br /><br />Big endian? 0<br /><br />Vaddr: 0x5555555540000, Page_size: 4096, Entry_size: 8 Reading /proc/self/pagemap at 0x2aaaaaaaa00<br /><br />Reached end of the file@ngiehttps://www.blogger.com/profile/06686990536299040308noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-76090556655615958892021-04-15T04:43:41.886-04:002021-04-15T04:43:41.886-04:00Not able to get result:.. line. Not able to get result:.. line. @ngiehttps://www.blogger.com/profile/06686990536299040308noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-17196170378410224432019-04-17T07:07:14.153-04:002019-04-17T07:07:14.153-04:00Thanks a lot. Your program helped me finding bug i...Thanks a lot. Your program helped me finding bug in my program.Manoj Malviyahttps://www.blogger.com/profile/04004200831321167287noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-50806455728662383712018-05-03T10:21:39.624-04:002018-05-03T10:21:39.624-04:00Great job for publishing such a beneficial web sit...Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing<br /><a href="http://aztranslator.com/" rel="nofollow">Translation services near me</a><br />Naveed Mughalhttps://www.blogger.com/profile/10692198202169963899noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-60276206626658942282018-03-21T15:48:10.817-04:002018-03-21T15:48:10.817-04:00My aim is to find the current process task structMy aim is to find the current process task structZibrihttps://www.blogger.com/profile/06742760452319979615noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-49438019174167229722018-03-19T06:43:40.866-04:002018-03-19T06:43:40.866-04:00I don't get it... how to get the physical memo...I don't get it... how to get the physical memory address from the page address??Zibrihttps://www.blogger.com/profile/06742760452319979615noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-33539468253163170072017-10-17T17:48:38.335-04:002017-10-17T17:48:38.335-04:00It worked for me on aarch64, except that you were ...It worked for me on aarch64, except that you were missing to include the string.h header for memcpy. Thanks!<br /><br />rack# ./a.out 719 0x2bdfc000<br />Big endian? 0<br />Vaddr: 0x2bdfc000, Page_size: 16384, Entry_size: 8<br />Reading /proc/719/pagemap at 0x57bf8<br />[0]0x73 [1]0x25 [2]0x20 [3]0x0 [4]0x0 [5]0x0 [6]0x0 [7]0x81 <br />Result: 0x7400000000202873<br />PFN: 0x202873 Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-14272976461219584132017-10-04T13:29:31.368-04:002017-10-04T13:29:31.368-04:00I'm also running this on an arm processor and ...I'm also running this on an arm processor and get the same results.Anonymoushttps://www.blogger.com/profile/05234000667755604785noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-89509860350269056002017-07-13T07:06:25.959-04:002017-07-13T07:06:25.959-04:00Thanks!
I used your code to write it in python and...Thanks!<br />I used your code to write it in python and study for my OS test (=<br /><br />goes something like:<br /><br />import resource<br />f = open("proc/TheProcessId/pagemap", 'rb')<br />virtual_addr = int(TheVirtualAddressInHexAsString, 16)<br />file_offset = virtual_addr / resource.getpagesize() * 8<br />f.seek(file_offset)<br />for i in range (0,8):<br />byte = f.read(1)<br />print repr(byte)<br /><br />not sure if this gives the real answer needed but I did get some value that looked<br />sensible + helped me understand the virtual address calculations (=Anonymoushttps://www.blogger.com/profile/09438945497392885410noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-44110864235594805242017-07-13T07:03:27.431-04:002017-07-13T07:03:27.431-04:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/09438945497392885410noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-68438997444533926232016-11-22T05:10:58.279-05:002016-11-22T05:10:58.279-05:00Excellent, code is working for allocated memory.
D...Excellent, code is working for allocated memory.<br />Does anyone know how to get physical address of mmaped memory?<br /><br />I have linux driver which is allocating specific kind of memory (for DMA, uncached).<br />It is simply file where mmap fn. is implemented like this:<br />int uma_mmap(struct file *filp, struct vm_area_struct *vma) {<br /> phys_addr_t physAddr;<br /> size_t size = vma->vm_end - vma->vm_start;<br /> void * virtAddr;<br /><br /> // we are not using NULL instead of device, because device has hot specified<br /> // memory range<br /> virtAddr = dma_alloc_coherent(NULL, size, &physAddr, GFP_KERNEL);<br /><br /> if (!virtAddr) {<br /> pr_info(<br /> KERN_ERR"[uncached_mem_allocator] %s: can not allocate memory of size %zu, device:%p\n",<br /> __func__, size, mmap_dev_device.this_device);<br /> return -ENOMEM;<br /> }<br /> vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);<br /><br /> if (remap_pfn_range(vma, vma->vm_start, physAddr >> PAGE_SHIFT, size,<br /> vma->vm_page_prot) < 0) {<br /> printk(KERN_ERR"[uncached_mem_allocator] %s: Error remap failed\n",<br /> __func__);<br /> vma->vm_ops =NULL;<br /> dma_free_coherent(NULL, size, virtAddr, physAddr);<br /> return -EAGAIN;<br /> }<br /><br /> return 0;<br />}<br /><br />If I try your code I will get "Page not present".Anonymoushttps://www.blogger.com/profile/04433994637648340240noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-73883773985952740652016-11-22T04:38:21.265-05:002016-11-22T04:38:21.265-05:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/04433994637648340240noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-11639902528274206202016-07-31T22:33:23.449-04:002016-07-31T22:33:23.449-04:00Thanks for share the code.But it not work well on ...Thanks for share the code.But it not work well on Android(arm linux).<br />root@sp9832iea_4m_volte:/data/local/tmp # cat /proc/3507/maps<br />b6400000-b6c00000 rw-p 00000000 00:00 0 [anon:libc_malloc]<br />b6e54000-b6e5c000 rw-s 60b00000 00:0c 6804 /dev/sprd_jpg<br />b6e5c000-b6e5d000 r-xp 00000000 b3:11 1285 /system/lib/libnetd_client.so<br />b6e5d000-b6e5e000 ---p 00000000 00:00 0<br />b6e5e000-b6e5f000 r--p 00001000 b3:11 1285 /system/lib/libnetd_client.so<br />b6e5f000-b6e60000 rw-p 00002000 b3:11 1285 /system/lib/libnetd_client.so<br />b6e60000-b6e61000 r--p 00000000 00:00 0<br />b6e61000-b6e81000 r--s 00000000 00:0c 7924 /dev/__properties__<br />b6e81000-b6ee7000 r-xp 00000000 b3:11 1176 /system/lib/libc.so<br />b6ee7000-b6ee8000 ---p 00000000 00:00 0<br />b6ee8000-b6eeb000 r--p 00066000 b3:11 1176 /system/lib/libc.so<br />b6eeb000-b6eee000 rw-p 00069000 b3:11 1176 /system/lib/libc.so<br />b6eee000-b6ef7000 rw-p 00000000 00:00 0<br />b6ef7000-b6f0d000 r-xp 00000000 b3:11 1265 /system/lib/libm.so<br />b6f0d000-b6f0e000 ---p 00000000 00:00 0<br />b6f0e000-b6f0f000 r--p 00016000 b3:11 1265 /system/lib/libm.so<br />b6f0f000-b6f10000 rw-p 00017000 b3:11 1265 /system/lib/libm.so<br />b6f10000-b6f12000 r-xp 00000000 b3:11 1388 /system/lib/libstdc++.so<br />b6f12000-b6f13000 r--p 00001000 b3:11 1388 /system/lib/libstdc++.so<br />b6f13000-b6f14000 rw-p 00002000 b3:11 1388 /system/lib/libstdc++.so<br />b6f14000-b6f18000 r-xp 00000000 b3:11 1261 /system/lib/liblog.so<br />b6f18000-b6f19000 r--p 00003000 b3:11 1261 /system/lib/liblog.so<br />b6f19000-b6f1a000 rw-p 00004000 b3:11 1261 /system/lib/liblog.so<br />b6f1a000-b6f1b000 r--p 00000000 00:00 0 [anon:linker_alloc]<br />b6f1b000-b6f1c000 rw-p 00000000 00:00 0 [anon:linker_alloc]<br />b6f1c000-b6f1d000 r--p 00000000 00:00 0 [anon:linker_alloc]<br />b6f1d000-b6f1e000 r--p 00000000 00:00 0<br />b6f1e000-b6f20000 rw-p 00000000 00:00 0<br />b6f20000-b6f21000 r-xp 00000000 00:00 0 [sigpage]<br />b6f21000-b6f2f000 r-xp 00000000 b3:11 610 /system/bin/linker<br />b6f2f000-b6f30000 r--p 0000d000 b3:11 610 /system/bin/linker<br />b6f30000-b6f31000 rw-p 0000e000 b3:11 610 /system/bin/linker<br />b6f31000-b6f32000 rw-p 00000000 00:00 0<br />b6f32000-b6f34000 r-xp 00000000 b3:17 222055 /data/local/tmp/get_phy_addr<br />b6f34000-b6f35000 r--p 00001000 b3:17 222055 /data/local/tmp/get_phy_addr<br />b6f35000-b6f36000 rw-p 00000000 00:00 0<br />be8fe000-be91f000 rw-p 00000000 00:00 0 [stack]<br />ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]<br /><br /><br /><br /><br />root@sp9832iea_4m_volte:/data/local/tmp # ./tool 3507 b6e54000<br />pid:3529<br />Big endian? 0<br />Vaddr: 0x7fffffff, Page_size: 4096, Entry_size: 8<br />Reading /proc/3507/pagemap at 0x3ffff8<br />[0]0x0 [1]0x0 [2]0x0 [3]0x0 [4]0x0 [5]0x0 [6]0x0 [7]0x6<br />Result: 0x600000000000000<br />Page not present<br />root@sp9832iea_4m_volte:/data/local/tmp # ./tool 3507 b6e5c000<br />pid:3531<br />Big endian? 0<br />Vaddr: 0x7fffffff, Page_size: 4096, Entry_size: 8<br />Reading /proc/3507/pagemap at 0x3ffff8<br />[0]0x0 [1]0x0 [2]0x0 [3]0x0 [4]0x0 [5]0x0 [6]0x0 [7]0x6<br />Result: 0x600000000000000<br />Page not present<br /><br /><br />my email : Cheng_Cheng_C_C@outlook.com .Looking forward to your reply.evil01https://www.blogger.com/profile/05574875931334522713noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-19005989348097725052016-02-20T04:28:31.427-05:002016-02-20T04:28:31.427-05:00It is probably just because the stack page is not ...It is probably just because the stack page is not resident in RAM at the moment. Try comparing it to the pmap output to see if RSS shows that regioneshahttps://www.blogger.com/profile/10589138741105012661noreply@blogger.comtag:blogger.com,1999:blog-7633821106051275217.post-30241214280440196622015-12-21T03:38:03.268-05:002015-12-21T03:38:03.268-05:00Try to run it with sudo. Physical frame numbers is...Try to run it with sudo. Physical frame numbers is potentially dangerous information, the kernel does not want let user processes to mess with it.D-manhttps://www.blogger.com/profile/00977517200271707010noreply@blogger.com