Re: [Fwd: Re: using remap_page_range()]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Jim Bauer <jfbauer@nfr.com> wrote:

> > I couldn't find an example in any 2.5.x driver. But
> > here is what is needed:
> > 
> > {
> > struct mm_struct *mm;
> > pgd_t *pgd;
> > pmd_t *pmd;
> > pte_t *ptep, pte;
> > struct page *old_page;
> > struct page *new_page = ...; /* new page to be mapped
> in */
> > pgprot_t prot = ...;  /* PTE flags. _PAGE_RW,
> PAGE_SHARED, etc.
> >                        * Set appropriately. */
> > 
> > mm = current->mm; 
> > spin_lock(&mm->page_table_lock);
> > pgd = pgd_offset(mm, address);
> > pmd = pmd_offset(pgd, address);
> > ptep = pte_offset_map(pmd, address);
> > pte = ptep_get_and_clear(ptep);
> > set_pte(ptep, mk_pte(new_page, prot));
> > spin_unlock(&mm->page_table_lock);
> > old_page = pte_page(pte);
> > ...
> > }
> > 
> > Not many error checks are needed in this case since we
> > know that the required address definitely has a mapping
> > in the process page table.
> > 
> 
> 
> I tried this, but the user-space program's mapping was
> still refering to the old pages.  

Are you sure current->mm is what you want always? If the
remapping is triggered from an interrupt context, then
current->mm will refer to the mm structure of some other
process.

> However, if I ran it 
> through gdb and single stepped it then it saw the new 
> buffer.  It I used gdb, but did not single step, then 
> the prog being debugged saw the old pages, but gdb saw 
> the new ones?
 
I am not sure I understand that. What do you mean by
'gdb saw new ones'? How exactly did you check that in
gdb?

-Ravi.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux