On 8/27/05, Vincenzo Mallozzi <vinjunior@xxxxxxxx> wrote: > I'm really sorry, but just when all seems to work well, the problem > re-occurred. > > LIST_HEAD(vm_write_protected); > > static struct mtpmc_wrprotected_pages *mk_page(unsigned long > addr) > { > struct mtpmc_wrprotected_pages *wr_page; > > wr_page = (...) kmalloc(.......); > ideally you should also initialize your list element in page structure here only. Well this is not the place of OOPS rite, but its a probable source of error. Do add the following in this function INIT_LIST_HEAD(&wr_page->list); // If you dont do this, it will still work, but its preferable to initilize all the elements. > wr_page->address = addr; > return wr_page; > } > > struct mtpmc_vm_wrprotected *mk_vm(struct vm_area_struct > *vm) > { > struct mtpmc_vm_wrprotected *wr_vma; > > wr_vma = (...) kmalloc(...........); > INIT_LIST_HEAD(&wr_vma->pages_list); > along with this, also initialize the other list element of this structure here only, the same thing which I mentioned for page structure above. Also set the vm_start and vm_end elements here only, rather than doing then later in function as your are doing. So add the following lines to this function INIT_LIST_HEAD(&wr_vma->list); // If you dont do this, it will still work, but its preferable to initilize all the elements. vma->vm_start = vm->vm_start; vma->vm_end = vm->vm_end; start and end should be set here, earlier you wee seting them after adding the structure to the list and i think out side the control of spinlocks, so an OOPS ..... ;-) this is the right place to do it before adding the structure to list. > return wr_vma; > } > > void mtpmc_set_mm_not_writable(struct mm_struct *mm) > { > struct mtpmc_vm_wrprotected *vma; > struct mtpmc_wrprotected_pages *page; > struct vm_area_struct *vm; > unsigned long addr; > pte_t *pte; > > down_write(&mm->mmap_sem); > > for(vm = mm->mmap; vm != NULL; vm = vm->vm_next){ > vma = mk_vm(vm); > for (addr = vm->vm_start; addr<vm->vm_end; addr+=PAGE_SIZE){ > page = mk_page(addr); > list_add_tail(&page->list, &vma->pages_list); > } > > list_add_tail(&vma->list, &vm_write_protected); > vma->vm_start = vm->vm_start; > vma->vm_end = vma->vm_end; /* THE PROLEM IS HERE - I'LL DESCRIBE IT Dont set start and end here ..... you should set them in above function as mentioned earlier. Well I can not see the use of spinlocks here, but I hope you are using them at right places. As mentioned earlier also, do all the modification or reading of lisits under the control of spinlocks. I think the error you are doing is that you do add the vma and page structure in there corresponding lists under the control of spinlock but then you start modifing the elements of these structure directly without using the spinlocks, you should not do that as the structures are on lists when you manupulate them, so do hold the spinlock before doing any thing on list, not only addition or deletion of structures from list, but rather manupulation of elements of these structures as well which are on list. If still the problem exist, I would advice you to send the whole code without any modifications, just pate the whole code and someone on the list might rectify that. > BELOW */ > } > > up_write(&mm->mmap_sem); > > return; > } > > See the line indicated above where I execute "vma->vm_end = vma->vm_end;". > In this line there's an error. It should be "vma->vm_end = vm->vm_end;". > So I've changed vma in vm. The result is that the system crashes with the NULL > exception I've described in previous emails. > I'm sorry if I'm posting many times this problem but when all seems go well > some problem occurs. > Now, I've posted all interesting code, by simplifying it. > I initialize all values of pages and vma before inserting them into the > appropriate lists. > I'm using spin_lock_irqsave/spin_unlock_irqrestore while I'm creating the > lists and spinlock/spin_unlock when I scan the lists from within the page > fault handler. > I hope you've the patience to reply to this mail. Dont worry about this, this list is to help each other and that is what we all are doing on this. -Gaurav > Thanks. > Vincenzo Mallozzi. > > > > > > ___________________________________ > Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB > http://mail.yahoo.it > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/