lkml.org 
[lkml]   [2011]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectNeed help about how linux to handle translation fault
From
Dear all:

I am a newer,I hope someone can help me about how linux to handle
translation fault(ARM architecture)

I define a string arrary in user space code:
unsignd char str[20] = "abcdefg";

And I send the address of str to kernel space using IOCTL interface.
ioctl(fd, VM_TEST_GET_VADDR, str);

When I try to use pgd to find the physical address, I don't find it
.But after calling copy_from_user,I can find physical address through
pgd.I don' know why?
/* user space address convert to physical address , if pte is NULL ,
it will return zero */
static unsigned long uva_to_pa(struct mm_struct *mm, unsigned long addr)
{
unsigned long ret = 0UL;
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *pte;

pgd = pgd_offset(mm, addr);
if (!pgd_none(*pgd)) {
pud = pud_offset(pgd, addr);
if (!pud_none(*pud)) {
pmd = pmd_offset(pud, addr);
if (!pmd_none(*pmd)) {
pte = pte_offset_map(pmd, addr);
if (!pte_none(*pte) && pte_present(*pte)) {
/* Use hard PTE */
pte = (pte_t *)((u32)pte - 2048);
if(pte)
ret = (*pte & 0xfffff000) | (addr & 0xfff);
} else {
printk("pet is not present:0x%08x\n", (*pte & 0xfffff000) | (addr
& 0xfff));
}
}
}
}
return ret;
}

So I think string array is located in data cache not in physical
memory, after I call copy_from_user, kernel will allocate page for it,
then we can access it, is it right?


Thanks
Best regards.

Pecker Hu


\
 
 \ /
  Last update: 2011-08-12 09:39    [W:0.028 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site