pte_t *src_pte, *dst_pte;
src_pte = getpte(src_task);
dst_pte = getpte(dst_task);
free_pte(dst_pte); /*to free the page referenced by this PTE */
*dst_pte = *src_pte; /*copy source PTE to destination PTE */
And here is code added to the kernel:
-------------------------------------------------------------------------------------------------------------
len = PAGE_SIZE;
src_vma=find_vma_intersection(src_proc->p_task->mm,src_addr,src_addr+len);
dst_vma=find_vma_intersection(dst_proc->p_task->mm,dst_addr,dst_addr+len);
src_pgd=pgd_offset(src_proc->p_task->mm, (unsigned long) src_addr);
src_pud=pud_offset(src_pgd,(unsigned long) src_addr);
src_pmd=pmd_offset(src_pud,(unsigned long) src_addr);
src_pte=pte_offset_map_lock(src_proc->p_task->mm, src_pmd,(unsigned long) src_addr, &src_ptl);
dst_pgd=pgd_offset(dst_proc->p_task->mm, (unsigned long) dst_addr);
dst_pud=pud_offset(dst_pgd,(unsigned long) dst_addr);
dst_pmd=pmd_offset(dst_pud,(unsigned long) dst_addr);
dst_pte=pte_offset_map_lock(dst_proc->p_task->mm, dst_pmd,(unsigned long) dst_addr, &dst_ptl);
pte_free(dst_proc->p_task->mm, dst_pte);
copy_pte_range(dst_proc->p_task->mm, src_proc->p_task->mm, dst_pmd, src_pmd,
dst_vma, (unsigned long) dst_addr, ((unsigned long)dst_addr+PAGE_SIZE));
spin_unlock(src_ptl);
spin_unlock(dst_ptl);
-------------------------------------------------------------------------------------------------------------
There are a lots of kernel functions that are not well documented or they have been changed.
Can anybody help me with this issue? Does COW (Copy On Write) will make the copy when the processes will modify their buffers?
I am not suscribed to the mailing list, please CC: the answers to this email account.
Thanks in Advance.
I apologize for my basic English.
Pablo Pessolani
PD: once finishing with that code, some issues about page protection will be considered.