[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tracking adresses of write and read
> That's what i'm trying to see: Where does the kernel physically write
> when my program write in the mmaped area. I don't want the user space program
> to handle physical adresses. It just care about it for debugging
> purposes, I just want the physical adres as information.
In your program u are not write() ing but storing some value in
those mapped addresses, isn't it? So kernel does not come into picture
there unless u fault (i.e., page fault, then kernel sees that address and
tries to recover etc. etc..).
You can only get the physical address of the pages if u r inside
kernel. U may perhaps try implementing a syscall that does that and
returns the physical address. In that syscall u have to do a page table
lookup to get the address(the user address u supply should be page
address). In 2.4 one such function is given, I think, the following one is
similar to that :
/* returns the page address of a page with u_addr = user v_addr
*/
inline unsigned long get_page_addr(unsigned long u_addr)
{
pgd_t *u_pgd;
pmd_t *u_pmd;
pte_t *u_pte;
u_pgd = pgd_offset(current->mm, u_addr);
u_pmd = pmd_offset(u_pgd, u_addr);
if (u_pmd) {
u_pte = pte_offset(u_pmd, u_addr);
if (u_pte && pte_present(*u_pte))
return pte_page(*u_pte);
}
return 0;
}
The address returns is page address and then u call virt_to_phys on it
to get the physical address. You can't call virt_to_phys() on a user
address.
HTH
sourav
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/