mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Invalidating page of a user level process from a device driver
@ 2006-03-16 16:03 osuv osuv
  2006-03-16 23:29 ` Alan Cox
  0 siblings, 1 reply; 2+ messages in thread
From: osuv osuv @ 2006-03-16 16:03 UTC (permalink / raw)
  To: linux-kernel

HI ALL,

   I need to invalidate a user process page . To
invalidate the page , i need to get into kernel space
, so i am using
   the ioctl func of a char device driver. I am not
getting the right functions or the right way to
invalidate a page.
   
   
   This is my code .
   
                                 User level process 
				 
#include <stdio.h>
#include <fcntl.h>

#define MAX 3000



int main()
{
	int fd,ch,val,i;
	int *buff;
	

	fd=open("filepte", O_RDWR);
	if (!fd)
       {
		perror("OPEN");
		exit(1);
  	} 
   
	printf("\nThe pid of the process is %d",getpid());
	

        buff=(void *)malloc(sizeof(int)*MAX);         
                          // Declaring the buffer
	
        printf("\n The address of buff[0]is
%x,\n",&buff[0]);

	for (i=0;i<MAX;i++)
	   buff[i]=20;                                       
                   // Accessing the buffer (pages) 
	   
	ioctl(fd,1,&buff[0]);                                
                   // Calling ioctl of the device
driver

	for(i=0;i<MAX;i++)
	   buff[i]=i+1;                                      
                   // Accessing the buffer again
(pages)
	   
	printf("The first element of the buffer is
%d",buff[0]);
			
	close(fd);
	return(0);
}

                                    Kernel code
(Device driver)

				    
		IOCTL FUNCTION
		
   
		
   static int motspk_ioctl(struct inode *inode, struct
file *file,unsigned int cmd, unsigned long arg)
  {
   
              /* The virtual address comes in the
parameter "arg" . I want to invalidate the page
corresponding	 
	                     to the virtual address */
     
      struct vm_area_struct *vma1=NULL;
      pte_t *page_table,pg_pte,res;
      struct page *pgptr=NULL;
    
    
      struct mm_struct* mm;
    
       
      
      mm=current->mm;
      
        
    
      
      printk(KERN_ALERT "The pid of the driver is
%d",current->pid);
      
      printk(KERN_ALERT "Entered IOCTL and the addr is
%x\n",arg);
      
    
      
     
      vma1=find_vma(current->mm,arg);                 
                          // Find the vma          
          
      pg_pte=pfn_pte(page_to_pfn(pgptr),PAGE_SHARED); 
                          // Getting the pte for the
page
          
      pte_clear(current->mm,arg,&pg_pte);             
                          // Clearing pte
        
      flush_tlb_page(vma1,arg);                       
                          // Flushing tlb page
     
     
      return 0;     
    }  
    				    


    Thank u in advance.
    
    
    


		
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Invalidating page of a user level process from a device driver
  2006-03-16 16:03 Invalidating page of a user level process from a device driver osuv osuv
@ 2006-03-16 23:29 ` Alan Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2006-03-16 23:29 UTC (permalink / raw)
  To: osuv osuv; +Cc: linux-kernel

On Iau, 2006-03-16 at 16:03 +0000, osuv osuv wrote:
>    I need to invalidate a user process page . To
> invalidate the page , i need to get into kernel space
> , so i am using
>    the ioctl func of a char device driver. I am not
> getting the right functions or the right way to
> invalidate a page.


What is wrong with using munmap() ?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-16 23:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-16 16:03 Invalidating page of a user level process from a device driver osuv osuv
2006-03-16 23:29 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®