From: Jon Smirl <jonsmirl@gmail.com>
To: Andi Kleen <ak@muc.de>
Cc: linux-kernel@vger.kernel.org,
DRI Devel <dri-devel@lists.sourceforge.net>
Subject: Re: chasing the four level page table
Date: Thu, 6 Jan 2005 13:36:46 -0500 [thread overview]
Message-ID: <9e47339105010610362fd7fffe@mail.gmail.com> (raw)
In-Reply-To: <m1vfaav340.fsf@muc.de>
On Thu, 06 Jan 2005 19:12:15 +0100, Andi Kleen <ak@muc.de> wrote:
> Yes, you should use get_user_pages() instead if you access real memory.
> If you try to find hardware mappings using that there is no ready
> function for you right now, although I guess it could be added.
drm_follow_page is used like this:
offset = drm_follow_page(pt) | ((unsigned long) pt & ~PAGE_MASK);
map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP) {
vunmap(pt);
return;
}
I think pt is a user space address. In DRM AGP memory is mapped into
kernel and user space so the user space address is being converted
into a kernel space one. The kernel space one is used to verify that
the address is a valid mapping to AGP space, if so the page is
unmapped. I didn't write this code so I'm not 100% sure of what is
going on.
On Thu, 06 Jan 2005 19:12:15 +0100, Andi Kleen <ak@muc.de> wrote:
> Jon Smirl <jonsmirl@gmail.com> writes:
>
> > The DRM driver contains this routine:
> >
> > drivers/char/drm/drm_memory.h
> >
> > static inline unsigned long
> > drm_follow_page (void *vaddr)
> > {
> > pgd_t *pgd = pgd_offset_k((unsigned long) vaddr);
> > pud_t *pud = pud_offset(pgd, (unsigned long) vaddr);
> > pmd_t *pmd = pmd_offset(pud, (unsigned long) vaddr);
> > pte_t *ptep = pte_offset_kernel(pmd, (unsigned long) vaddr);
> > return pte_pfn(*ptep) << PAGE_SHIFT;
> > }
> >
> > No other driver needs to chase the page table like this so there is
> > probably some other way to achieve this. Can someone who knows more
> > about the VM system tell me if there is a way to eliminate this code?
>
> Yes, you should use get_user_pages() instead if you access real memory.
> If you try to find hardware mappings using that there is no ready
> function for you right now, although I guess it could be added.
>
> The function is also not quite correct, it should already least take
> the page_table_lock (depending on where you call it from) and check
> p*_none() on each level.
>
> -Andi
>
--
Jon Smirl
jonsmirl@gmail.com
next prev parent reply other threads:[~2005-01-06 18:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-06 17:17 chasing the four level page table Jon Smirl
2005-01-06 18:12 ` Andi Kleen
2005-01-06 18:36 ` Jon Smirl [this message]
2005-01-06 19:38 ` Andi Kleen
2005-01-06 20:05 ` Jon Smirl
2005-01-06 21:41 ` Dave Jones
2005-01-08 5:22 ` Jon Smirl
2005-01-15 2:54 ` H. Peter Anvin
2005-01-15 3:37 ` Roland Dreier
2005-01-15 4:24 ` Andi Kleen
2005-01-15 5:59 ` Jon Smirl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e47339105010610362fd7fffe@mail.gmail.com \
--to=jonsmirl@gmail.com \
--cc=ak@muc.de \
--cc=dri-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.