mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: osuv osuv <osuvthebest@yahoo.co.in>
To: linux-kernel@vger.kernel.org
Subject: Invalidating page of a user level process from a device driver
Date: Thu, 16 Mar 2006 16:03:37 +0000 (GMT)	[thread overview]
Message-ID: <20060316160337.12684.qmail@web8406.mail.in.yahoo.com> (raw)

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

             reply	other threads:[~2006-03-16 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-16 16:03 osuv osuv [this message]
2006-03-16 23:29 ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060316160337.12684.qmail@web8406.mail.in.yahoo.com \
    --to=osuvthebest@yahoo.co.in \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®