Re: Calculating kernel logical address ..

Daniel Phillips
2002-09-07T01:37:42Z

On Friday 06 September 2002 05:34, Imran Badr wrote:
> 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?
>
> I will really appreciate any guidance.

It looks good to me. Note that somebody has added some new voodoo in 2.5
so that page table pages can be in highmem, with the result that the above
code won't work in 2.5, whether or not highmem is configured.

--
Daniel