Hi all,To get the corresponding pysical adress (of a virtual adress), you can use the function follow_page(). This function takes a virtual adress and walk trhough the GPD,PMD and PT. So you can get the physical page. Here is the nearly code of follow_page() (but have a look at the source code ):
I am developing my thesys' project and I need to know the physical pages a process occupies. I have just tried to read these informations from the proc directory; in particular, I've read some memory ranges from the file /proc/$pid/maps, but I have later understood that these ranges indicate intervals of linear addresses (or better, indicate the memory region occupied by the process). In other word, I've not found the physical addresses I need.
Later, I've also read, from the book "Understanding Linux Kernel", how to obtain memory regions informations from the process descriptor; but I haven't understood where I can find physical addresses or how can I translate linear addresses representing memory region into physical ones or finally if exists a C function that return these values.
Can Someone help me, please?
pgd_t *pgd; pmd_t *pmd; pte_t *ptep, pte;
pgd = pgd_offset(mm, address); if (pgd_none(*pgd) || pgd_bad(*pgd)) goto out;
pmd = pmd_offset(pgd, address); if (pmd_none(*pmd) || pmd_bad(*pmd)) goto out;
ptep = pte_offset(pmd, address); if (!ptep) goto out;
pte = *ptep;
You have to use this code with the good PGD,PMD and PTE, corresponding to the process you deal with.
I hope i've grought you some help
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/