[lkml]   [2002]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: Calculating kernel logical address ..

-----Original Message-----
From: Manfred Spraul []
Sent: Friday, September 06, 2002 8:44 AM
To: Imran Badr
Subject: Re: Calculating kernel logical address ..

> adr = user_address;
> pgd_offset(current->mm, adr);
> if (!pgd_none(*pgd)) {
> pmd = pmd_offset(pgd, adr);
> if (!pmd_none(*pmd)) {
> ptep = pte_offset(pmd, adr);
> pte = *ptep;
> if(pte_present(pte)) {
> kaddr = (unsigned long) page_address(pte_page(pte));
> kaddr |= (adr & (PAGE_SIZE - 1));
> }
> }
> }
> Will this code always give me correct kernel logical address?
What about


A driver should avoid accessing the page tables.


I was wondering if the code which I am using, will always give me addresses
no matter whether HIGHMEM is defined in kernel configuration or not. I
belive that it should not be problem because I am mmap'ing kmalloc'ed memory
which always returns mapped memory. But whats happeing in my lab is
different. If I define HIGHMEM in kernel configuration and install 2GB of
memory in my server then I see a crash in the kernel where I try to access
kaddr calculated bu above code. Any idea?

The problem with your suggestion is that at the point where user gives me an
address for DMA, I do not know what kmalloc_buffer and vma->vm_start values
are. Also, if there are more than one processes accessing the driver, then
how am I going to keep track of all mmap'ed memory.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:28    [W:0.028 / U:2.896 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site