diff options
Diffstat (limited to 'arch/um/kernel/skas/tlb.c')
-rw-r--r-- | arch/um/kernel/skas/tlb.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/um/kernel/skas/tlb.c b/arch/um/kernel/skas/tlb.c new file mode 100644 index 000000000000..b8c5e71763d1 --- /dev/null +++ b/arch/um/kernel/skas/tlb.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Copyright 2003 PathScale, Inc. | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include "linux/stddef.h" | ||
8 | #include "linux/sched.h" | ||
9 | #include "linux/mm.h" | ||
10 | #include "asm/page.h" | ||
11 | #include "asm/pgtable.h" | ||
12 | #include "asm/mmu.h" | ||
13 | #include "user_util.h" | ||
14 | #include "mem_user.h" | ||
15 | #include "mem.h" | ||
16 | #include "skas.h" | ||
17 | #include "os.h" | ||
18 | #include "tlb.h" | ||
19 | |||
20 | static void do_ops(int fd, struct host_vm_op *ops, int last) | ||
21 | { | ||
22 | struct host_vm_op *op; | ||
23 | int i; | ||
24 | |||
25 | for(i = 0; i <= last; i++){ | ||
26 | op = &ops[i]; | ||
27 | switch(op->type){ | ||
28 | case MMAP: | ||
29 | map(fd, op->u.mmap.addr, op->u.mmap.len, | ||
30 | op->u.mmap.r, op->u.mmap.w, op->u.mmap.x, | ||
31 | op->u.mmap.fd, op->u.mmap.offset); | ||
32 | break; | ||
33 | case MUNMAP: | ||
34 | unmap(fd, (void *) op->u.munmap.addr, | ||
35 | op->u.munmap.len); | ||
36 | break; | ||
37 | case MPROTECT: | ||
38 | protect(fd, op->u.mprotect.addr, op->u.mprotect.len, | ||
39 | op->u.mprotect.r, op->u.mprotect.w, | ||
40 | op->u.mprotect.x); | ||
41 | break; | ||
42 | default: | ||
43 | printk("Unknown op type %d in do_ops\n", op->type); | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | |||
49 | static void fix_range(struct mm_struct *mm, unsigned long start_addr, | ||
50 | unsigned long end_addr, int force) | ||
51 | { | ||
52 | int fd = mm->context.skas.mm_fd; | ||
53 | |||
54 | fix_range_common(mm, start_addr, end_addr, force, fd, do_ops); | ||
55 | } | ||
56 | |||
57 | void __flush_tlb_one_skas(unsigned long addr) | ||
58 | { | ||
59 | flush_tlb_kernel_range_common(addr, addr + PAGE_SIZE); | ||
60 | } | ||
61 | |||
62 | void flush_tlb_range_skas(struct vm_area_struct *vma, unsigned long start, | ||
63 | unsigned long end) | ||
64 | { | ||
65 | if(vma->vm_mm == NULL) | ||
66 | flush_tlb_kernel_range_common(start, end); | ||
67 | else fix_range(vma->vm_mm, start, end, 0); | ||
68 | } | ||
69 | |||
70 | void flush_tlb_mm_skas(struct mm_struct *mm) | ||
71 | { | ||
72 | /* Don't bother flushing if this address space is about to be | ||
73 | * destroyed. | ||
74 | */ | ||
75 | if(atomic_read(&mm->mm_users) == 0) | ||
76 | return; | ||
77 | |||
78 | fix_range(mm, 0, host_task_size, 0); | ||
79 | flush_tlb_kernel_range_common(start_vm, end_vm); | ||
80 | } | ||
81 | |||
82 | void force_flush_all_skas(void) | ||
83 | { | ||
84 | fix_range(current->mm, 0, host_task_size, 1); | ||
85 | } | ||