lock when changing process memory region (in syscall.c) and page-table (in process.c)

This commit is contained in:
Masamichi Takagi m-takagi@ab.jp.nec.com
2012-10-09 11:40:49 +09:00
parent 9a8449df2b
commit dd596a2a78
3 changed files with 17 additions and 2 deletions

View File

@ -89,6 +89,7 @@ void update_process_page_table(struct process *process, struct vm_range *range,
{
unsigned long p, pa = range->phys;
unsigned long flags = aal_mc_spinlock_lock(&process->vm->page_table_lock);
p = range->start;
while (p < range->end) {
aal_mc_pt_set_page(process->vm->page_table, (void *)p,
@ -98,6 +99,7 @@ void update_process_page_table(struct process *process, struct vm_range *range,
p += PAGE_SIZE;
}
aal_mc_spinlock_unlock(&process->vm->page_table_lock, flags);
}
int add_process_large_range(struct process *process,
@ -282,15 +284,18 @@ unsigned long extend_process_region(struct process *proc,
int remove_process_region(struct process *proc,
unsigned long start, unsigned long end)
{
unsigned long flags;
if ((start & (PAGE_SIZE - 1)) || (end & (PAGE_SIZE - 1))) {
return -EINVAL;
}
flags = aal_mc_spinlock_lock(&proc->vm->page_table_lock);
/* We defer freeing to the time of exit */
while (start < end) {
aal_mc_pt_clear_page(proc->vm->page_table, (void *)start);
start += PAGE_SIZE;
}
aal_mc_spinlock_unlock(&proc->vm->page_table_lock, flags);
return 0;
}