modification for no_cache: extend_process_region(...,flag)
This commit is contained in:
committed by
Masamichi Takagi m-takagi@ab.jp.nec.com
parent
b902a245e4
commit
b79d20d7bf
@ -101,13 +101,7 @@ void init_process_stack(struct process *process, struct program_load_desc *pn,
|
||||
int envc, char **env);
|
||||
unsigned long extend_process_region(struct process *proc,
|
||||
unsigned long start, unsigned long end,
|
||||
unsigned long address);
|
||||
|
||||
#ifdef USE_NOCACHE_MMAP
|
||||
unsigned long extend_process_nocache_region(struct process *proc,
|
||||
unsigned long start, unsigned long end,
|
||||
unsigned long address);
|
||||
#endif
|
||||
unsigned long address, unsigned long flag);
|
||||
|
||||
void schedule(void);
|
||||
void runq_add_proc(struct process *proc, int cpu_id);
|
||||
|
||||
@ -280,7 +280,7 @@ void init_process_stack(struct process *process, struct program_load_desc *pn,
|
||||
|
||||
unsigned long extend_process_region(struct process *proc,
|
||||
unsigned long start, unsigned long end,
|
||||
unsigned long address)
|
||||
unsigned long address, unsigned long flag)
|
||||
{
|
||||
unsigned long aligned_end, aligned_new_end;
|
||||
void *p;
|
||||
@ -330,7 +330,7 @@ unsigned long extend_process_region(struct process *proc,
|
||||
}
|
||||
|
||||
add_process_memory_range(proc, aligned_end, aligned_new_end,
|
||||
virt_to_phys((void *)p_aligned), 0);
|
||||
virt_to_phys((void *)p_aligned), flag);
|
||||
|
||||
dkprintf("largePTE area: 0x%lX - 0x%lX (s: %lu) -> 0x%lX - \n",
|
||||
aligned_end, aligned_new_end,
|
||||
@ -348,95 +348,11 @@ unsigned long extend_process_region(struct process *proc,
|
||||
}
|
||||
|
||||
add_process_memory_range(proc, aligned_end, aligned_new_end,
|
||||
virt_to_phys(p), 0);
|
||||
virt_to_phys(p), flag);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
#ifdef USE_NOCACHE_MMAP
|
||||
unsigned long extend_process_nocache_region(struct process *proc,
|
||||
unsigned long start, unsigned long end,
|
||||
unsigned long address)
|
||||
{
|
||||
unsigned long aligned_end, aligned_new_end;
|
||||
void *p;
|
||||
|
||||
if (!address || address < start || address >= USER_END) {
|
||||
return end;
|
||||
}
|
||||
|
||||
aligned_end = ((end + PAGE_SIZE - 1) & PAGE_MASK);
|
||||
|
||||
if (aligned_end >= address) {
|
||||
return address;
|
||||
}
|
||||
|
||||
aligned_new_end = (address + PAGE_SIZE - 1) & PAGE_MASK;
|
||||
|
||||
#ifdef USE_LARGE_PAGES
|
||||
if (aligned_new_end - aligned_end >= LARGE_PAGE_SIZE) {
|
||||
unsigned long p_aligned;
|
||||
unsigned long old_aligned_end = aligned_end;
|
||||
|
||||
if ((aligned_end & (LARGE_PAGE_SIZE - 1)) != 0) {
|
||||
|
||||
aligned_end = (aligned_end + (LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
/* Fill in the gap between old_aligned_end and aligned_end
|
||||
* with regular pages */
|
||||
p = allocate_pages((aligned_end - old_aligned_end) >> PAGE_SHIFT, 0);
|
||||
add_process_memory_range(proc, old_aligned_end, aligned_end,
|
||||
virt_to_phys(p), 0);
|
||||
|
||||
dkprintf("filled in gap for LARGE_PAGE_SIZE aligned start: 0x%lX -> 0x%lX\n",
|
||||
old_aligned_end, aligned_end);
|
||||
}
|
||||
|
||||
/* Add large region for the actual mapping */
|
||||
aligned_new_end = (aligned_new_end + (aligned_end - old_aligned_end) +
|
||||
(LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
address = aligned_new_end;
|
||||
|
||||
p = allocate_pages((aligned_new_end - aligned_end + LARGE_PAGE_SIZE)
|
||||
>> PAGE_SHIFT, 0);
|
||||
|
||||
p_aligned = ((unsigned long)p + (LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
|
||||
if (p_aligned > (unsigned long)p) {
|
||||
free_pages(p, (p_aligned - (unsigned long)p) >> PAGE_SHIFT);
|
||||
}
|
||||
|
||||
add_process_memory_range(proc, aligned_end, aligned_new_end,
|
||||
virt_to_phys((void *)p_aligned), VR_IO_NOCACHE);
|
||||
|
||||
dkprintf("largePTE area(no cache): 0x%lX - 0x%lX (s: %lu) -> 0x%lX - \n",
|
||||
aligned_end, aligned_new_end,
|
||||
(aligned_new_end - aligned_end),
|
||||
virt_to_phys((void *)p_aligned));
|
||||
|
||||
return address;
|
||||
}
|
||||
#endif
|
||||
|
||||
p = allocate_pages((aligned_new_end - aligned_end) >> PAGE_SHIFT, 0);
|
||||
|
||||
// kprintf("process.c,p=%lx\n", p);
|
||||
if (!p) {
|
||||
// kprintf("process.c,p==0\n");
|
||||
return end;
|
||||
}
|
||||
|
||||
add_process_memory_range(proc, aligned_end, aligned_new_end,
|
||||
virt_to_phys(p), VR_IO_NOCACHE);
|
||||
dkprintf("extend area(no cache): 0x%lX - 0x%lX (s: %lu) -> 0x%lX - \n",
|
||||
aligned_end, aligned_new_end,
|
||||
(aligned_new_end - aligned_end),
|
||||
virt_to_phys(p));
|
||||
|
||||
|
||||
return address;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Original version retained because dcfa (src/mccmd/client/ibmic/main.c) calls this
|
||||
int remove_process_region(struct process *proc,
|
||||
unsigned long start, unsigned long end)
|
||||
|
||||
@ -121,7 +121,7 @@ long sys_brk(int n, aal_mc_user_context_t *ctx)
|
||||
region->brk_end =
|
||||
extend_process_region(cpu_local_var(current),
|
||||
region->brk_start, region->brk_end,
|
||||
address);
|
||||
address, 0);
|
||||
aal_mc_spinlock_unlock(&cpu_local_var(current)->vm->memory_range_lock, flags);
|
||||
dkprintf("SC(%d)[sys_brk] brk_end set to %lx\n", aal_mc_get_processor_id(), region->brk_end);
|
||||
|
||||
@ -464,9 +464,9 @@ SYSCALL_DECLARE(mmap)
|
||||
#ifdef USE_NOCACHE_MMAP
|
||||
if ((aal_mc_syscall_arg3(ctx) & 0x40) == 0x40) {
|
||||
dkprintf("SC(%d),syscall.c,mmap,nocache,len=%lx\n", cpuid, len);
|
||||
region->map_end = extend_process_nocache_region(
|
||||
region->map_end = extend_process_region(
|
||||
cpu_local_var(current), region->map_start, map_end_aligned,
|
||||
s + len);
|
||||
s + len, VR_IO_NOCACHE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -475,7 +475,7 @@ SYSCALL_DECLARE(mmap)
|
||||
extend_process_region(cpu_local_var(current),
|
||||
region->map_start,
|
||||
map_end_aligned,
|
||||
s + len);
|
||||
s + len, 0);
|
||||
}
|
||||
|
||||
aal_mc_spinlock_unlock(&cpu_local_var(current)->vm->memory_range_lock, flags);
|
||||
@ -506,7 +506,7 @@ SYSCALL_DECLARE(mmap)
|
||||
extend_process_region(cpu_local_var(current),
|
||||
region->map_start,
|
||||
s,
|
||||
s + len);
|
||||
s + len, 0);
|
||||
#else
|
||||
unsigned long s = (region->map_end + PAGE_SIZE - 1) & PAGE_MASK;
|
||||
unsigned long len = (aal_mc_syscall_arg1(ctx) + PAGE_SIZE - 1) & PAGE_MASK;
|
||||
@ -514,7 +514,7 @@ SYSCALL_DECLARE(mmap)
|
||||
extend_process_region(cpu_local_var(current),
|
||||
region->map_start,
|
||||
region->map_end,
|
||||
s + len);
|
||||
s + len, 0);
|
||||
#endif
|
||||
aal_mc_spinlock_unlock(&cpu_local_var(current)->vm->memory_range_lock, flags);
|
||||
if (region->map_end < s + len) { return -EINVAL; }
|
||||
|
||||
Reference in New Issue
Block a user