[linux-sh:03343] Re: Howto convert from process virtual (linear address) to physical address?
Paul Mundt <[email protected]> Fri, 8 Oct 2004 20:34:22 +0300
| Newsgroups | gmane.linux.ports.sh.general,gmane.linux.ports.sh.devel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Oct 08, 2004 at 05:40:32PM +0100, Alex Bennee wrote:
> Now I'm probably just lost because I haven't got my head fully wrapped
> around the multi-level page tables but this is what I've got:
>
> do {
> pgd_t *pgd;
> pmd_t *pmd;
> pte_t *ptep, pte;
> struct page *the_page;
> unsigned long phys_addr;
>
> get_user(addr, start_addr);
> start_addr++;
>
> pgd = pgd_offset(tsk->mm, addr);
> if (pgd_none(*pgd) || pgd_bad(*pgd))
> goto out;
>
> pmd = pmd_offset(pgd, addr);
> if (pmd_none(*pmd) || pmd_bad(*pmd))
> goto out;
>
> ptep = pte_offset(pmd, addr);
> if (!ptep)
> goto out;
>
> pte = *ptep;
>
> the_page = pte_page(pte);
> phys_addr = page_to_phys(the_page)+(addr&PAGE_MASK);
This looks problematic.
What about:
phys_addr = pte_val(*ptep) & PTE_PHYS_MASK;
> Any idea where I'm going wrong? A pointer to code that actually needs to
> convert from user-space linear address to actual physical address would
> be cool if anyone can point me to one.
>
The closest you will probably get is copy/clear_user_page(), but that
probably won't help you much.
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBZs+d1K+teJFxZ9wRAtruAJ9iK5yDBJpFL9WJZLbLyZUPx8AwMACfdVzE oTUwIGfWuPyjBfxWOLFDL2Q= =0Qyk -----END PGP SIGNATURE-----