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

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

 



On Mon, 2003-07-21 at 14:06, Ravi Krishnamurthy wrote:
> --- 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.

Yep, I am only doing that via a syscall.

> > 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?

I added some code the to kernel module to scribble
a pattern over the old buffer when I switch to the new one.
I was filling each byte with the value 0x62.

The user-space test program had something like...

	if (data->len > 2000)
		printf("length (0x%x) is too big\n", data->len);

and it prints out 0x62626262 for the length (old buffer contents).
But if I use gdb to print out data->len, at that point, I
get a reasonable/expected value.







--
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