Index: linux-2.6.git/arch/um/include/skas/mmu-skas.h =================================================================== --- linux-2.6.git.orig/arch/um/include/skas/mmu-skas.h +++ linux-2.6.git/arch/um/include/skas/mmu-skas.h @@ -16,6 +16,7 @@ struct mmu_context_skas { unsigned long last_pmd; #endif uml_ldt_t ldt; + int first_flush; }; extern void switch_mm_skas(struct mm_id * mm_idp); Index: linux-2.6.git/arch/um/kernel/skas/mmu.c =================================================================== --- linux-2.6.git.orig/arch/um/kernel/skas/mmu.c +++ linux-2.6.git/arch/um/kernel/skas/mmu.c @@ -77,6 +77,7 @@ int init_new_context_skas(struct task_st struct mmu_context_skas *to_mm = &mm->context.skas; unsigned long stack = 0; int ret = -ENOMEM; + void *unused = NULL; if(skas_needs_stub){ stack = get_zeroed_page(GFP_KERNEL); @@ -121,6 +122,14 @@ int init_new_context_skas(struct task_st else to_mm->id.u.pid = start_userspace(stack); } + mm->context.skas.first_flush = 1; + ret = unmap(&mm->context.skas.id, 0, TASK_SIZE, 1, &unused); + if (ret < 0) { + printk("init_new_context_skas - unmap failed, " + "errno = %d; continuing\n", ret); + mm->context.skas.first_flush = 0; + } + ret = init_new_ldt(to_mm, from_mm); if(ret < 0){ printk("init_new_context_skas - init_ldt" Index: linux-2.6.git/arch/um/kernel/tlb.c =================================================================== --- linux-2.6.git.orig/arch/um/kernel/tlb.c +++ linux-2.6.git/arch/um/kernel/tlb.c @@ -139,10 +139,17 @@ void fix_range_common(struct mm_struct * void *flush = NULL; int op_index = -1, last_op = ARRAY_SIZE(ops) - 1; int ret = 0; + int first_flush; if(mm == NULL) return; + /* Nothing is mapped in this address space, so no call to add_munmap() + * must be done */ + first_flush = mm->context.skas.first_flush; + + mm->context.skas.first_flush = 0; + ops[0].type = NONE; for(addr = start_addr; addr < end_addr && !ret;){ npgd = pgd_offset(mm, addr); @@ -151,9 +158,10 @@ void fix_range_common(struct mm_struct * if(end > end_addr) end = end_addr; if(force || pgd_newpage(*npgd)){ - ret = add_munmap(addr, end - addr, ops, - &op_index, last_op, mmu, - &flush, do_ops); + if (!first_flush) + ret = add_munmap(addr, end - addr, ops, + &op_index, last_op, mmu, + &flush, do_ops); pgd_mkuptodate(*npgd); } addr = end; @@ -166,9 +174,10 @@ void fix_range_common(struct mm_struct * if(end > end_addr) end = end_addr; if(force || pud_newpage(*npud)){ - ret = add_munmap(addr, end - addr, ops, - &op_index, last_op, mmu, - &flush, do_ops); + if (!first_flush) + ret = add_munmap(addr, end - addr, ops, + &op_index, last_op, mmu, + &flush, do_ops); pud_mkuptodate(*npud); } addr = end; @@ -181,9 +190,10 @@ void fix_range_common(struct mm_struct * if(end > end_addr) end = end_addr; if(force || pmd_newpage(*npmd)){ - ret = add_munmap(addr, end - addr, ops, - &op_index, last_op, mmu, - &flush, do_ops); + if (!first_flush) + ret = add_munmap(addr, end - addr, ops, + &op_index, last_op, mmu, + &flush, do_ops); pmd_mkuptodate(*npmd); } addr = end; @@ -207,7 +217,8 @@ void fix_range_common(struct mm_struct * PAGE_SIZE, r, w, x, ops, &op_index, last_op, mmu, &flush, do_ops); - else ret = add_munmap(addr, PAGE_SIZE, ops, + else if (!first_flush) + ret = add_munmap(addr, PAGE_SIZE, ops, &op_index, last_op, mmu, &flush, do_ops); } @@ -219,7 +230,7 @@ void fix_range_common(struct mm_struct * *npte = pte_mkuptodate(*npte); addr += PAGE_SIZE; } - if(!ret) + if (!ret && op_index > -1) ret = (*do_ops)(mmu, ops, op_index, 1, &flush); /* This is not an else because ret is modified above */