Thread: Read data of a page frame (linux) make freeze the system

  1. #1
    Registered User
    Join Date
    Sep 2009

    Read data of a page frame (linux) make freeze the system


    I'm writing a linux driver that reading the data of a page frame of an process. But when I use it, it make immediately freeze the system. Can you help me? Thank for reading my question!

    system: Ubuntu 9.04, kernel, Intel Duo

    static int read_addr(int pid, unsigned long linear_addr, unsigned int n_bytes, char* buff){
    	pid: id of process
    	linear_addr: linear address of memory region to be read
    	n_bytes: nombre bytes to be read
    	buff: the buffer containing the result
    	struct task_struct *task;
       	struct mm_struct *mm = NULL;
        pgd_t *pgd;
        pmd_t *pmd;
        pte_t *pte;
        unsigned long pteval;
    	int ret = 0;    
    	for_each_process(task) {
    		if ( task->pid == pid) {
    		    mm = task->mm;
    	if(mm == NULL)
    		return 1;
        pgd = pgd_offset(mm, linear_addr);
        if (pgd_none(*pgd)) { ret = 2; goto out; }
        pmd = pmd_offset(pgd, linear_addr);
        if (pmd_none(*pmd)) { ret = 3; goto out; }
        pte = pte_offset_map(pmd, linear_addr);
        if (pte_present(*pte)){
    		unsigned long pteid = pte_index(linear_addr);
    		pteval = pte_val(*pte);
    		memcpy(buff, pteval + pteid, n_bytes);     
        } else {
    		ret = 4;
    		goto out;
        return 0;
     	printk("error: %d\n", ret);
    	return ret;		

  2. #2
    Registered User
    Join Date
    Oct 2008
    Narrow down the snippet of code where it is hanging and go from there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program terminates abruptly
    By roaan in forum C Programming
    Replies: 3
    Last Post: 08-28-2009, 03:53 PM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. C Programming Question
    By TK in forum A Brief History of
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM
  4. data read problem
    By Supra in forum C Programming
    Replies: 0
    Last Post: 02-03-2002, 07:02 PM
  5. read data
    By in_need in forum C Programming
    Replies: 2
    Last Post: 10-30-2001, 08:10 AM

Tags for this Thread