Re: Few queries
- From: "kushneeraj@xxxxxxxxx" <kushneeraj@xxxxxxxxx>
- Date: 29 Oct 2006 17:18:15 -0800
I tried with kmalloc() but the pmd_bad(*pmd) is returning 1, so I am
not able to compare with the physical address returned by __pa()
Neeraj
comp.os.linux.dev.system wrote:
It looks reasonalbe, have you verify it with __pa?
kushneeraj@xxxxxxxxx wrote:
can we follow the page table to get the physical address for kernel
virtual address like this
unsigned long get_pte(unsigned long va)
{
pgd_t *pgd;
pmd_t *pmd;
pte_t *ptep, pte;
unsigned long page_base, pa ;
pgd = pgd_offset(current->mm, va);
if(pgd_none(*pgd) || pgd_bad(*pgd))
goto out;
pmd = pmd_offset(pgd, va);
if(pmd_none(*pmd) || pmd_bad(*pmd))
goto out;
ptep = pte_offset_map(pmd, va);
if(!ptep)
goto out;
pte = *ptep;
pte_unmap(ptep);
if(!pte_present(pte))
goto out;
page_base = pte_val(pte);
pa = (va & ~PAGE_MASK) | (page_base & PAGE_MASK);
return pa;
out:
return -1;
}
Kaz Kylheku wrote:
Josef Moellers wrote:
I still don't see a difference between a "logical" and a "virtual" address.
Apparently the distinction is that "logical addresses" have a simple,
fixed mapping to physical addresses (e.g. a constant offset) while
virtual addresses have an arbitrary mapping
(http://linux.derkeiler.com/Newsgroups/comp.os.linux.development.system/2006-01/msg00245.html)
IMHO, this is just trying to name things differently.
On some better-designed architectures, there can be sections of memory
which are not subject to paging, but instead to a simple translation.
E.g. the kernel segments or "ksegs" on MIPS.
It would not be quite accurate to call these addresses virtual, since
they don't go through virtual address translation.
It's an advantage to have this feature, because accesses to these
segments do not map through the TLB, which is precious cache space.
It's stupid to use virtual address translation to implement a simple
displacement over a large memory range, and the more physical RAM you
make visible that way, the stupider it gets due to the greater demand
on the TLB.
So, ideally, every platform would have a way to do kernel segments, and
so the MMU hardware would never be used for these logical pages at all.
Only for highmem pages, and for truly virtual allocations (user space
mmap, vmalloc).
So it does make sense to distinguish logical and virtual addresses. On
platforms like i386 can think of logical addresses as being a kernel
segment inefficiently emulated using the paging hardware.
.
- References:
- Few queries
- From: kushneeraj@xxxxxxxxx
- Re: Few queries
- From: Josef Moellers
- Re: Few queries
- From: kushneeraj@xxxxxxxxx
- Re: Few queries
- From: Josef Moellers
- Re: Few queries
- From: Kaz Kylheku
- Re: Few queries
- From: kushneeraj@xxxxxxxxx
- Re: Few queries
- From: comp.os.linux.dev.system
- Few queries
- Prev by Date: Re: System calls parameter restrictions
- Next by Date: Looking for a profiler
- Previous by thread: Re: Few queries
- Next by thread: few queries about user/kernel vitual addresses
- Index(es):
Relevant Pages
|