aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/um/include/tlb.h22
-rw-r--r--arch/um/kernel/skas/include/skas.h13
-rw-r--r--arch/um/kernel/skas/mem_user.c112
-rw-r--r--arch/um/kernel/skas/tlb.c23
-rw-r--r--arch/um/kernel/tlb.c226
-rw-r--r--arch/um/kernel/tt/tlb.c5
-rw-r--r--arch/um/sys-i386/stub.S17
-rw-r--r--arch/um/sys-x86_64/stub.S21
8 files changed, 273 insertions, 166 deletions
diff --git a/arch/um/include/tlb.h b/arch/um/include/tlb.h
index c6f9628f39bf..2deefb99c63c 100644
--- a/arch/um/include/tlb.h
+++ b/arch/um/include/tlb.h
@@ -9,7 +9,7 @@
9#include "um_mmu.h" 9#include "um_mmu.h"
10 10
11struct host_vm_op { 11struct host_vm_op {
12 enum { MMAP, MUNMAP, MPROTECT } type; 12 enum { NONE, MMAP, MUNMAP, MPROTECT } type;
13 union { 13 union {
14 struct { 14 struct {
15 unsigned long addr; 15 unsigned long addr;
@@ -38,24 +38,10 @@ extern void mprotect_kernel_vm(int w);
38extern void force_flush_all(void); 38extern void force_flush_all(void);
39extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr, 39extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
40 unsigned long end_addr, int force, 40 unsigned long end_addr, int force,
41 void (*do_ops)(union mm_context *, 41 void *(*do_ops)(union mm_context *,
42 struct host_vm_op *, int)); 42 struct host_vm_op *, int, int,
43 void *));
43extern int flush_tlb_kernel_range_common(unsigned long start, 44extern int flush_tlb_kernel_range_common(unsigned long start,
44 unsigned long end); 45 unsigned long end);
45 46
46extern int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
47 int r, int w, int x, struct host_vm_op *ops, int index,
48 int last_filled, union mm_context *mmu,
49 void (*do_ops)(union mm_context *, struct host_vm_op *,
50 int));
51extern int add_munmap(unsigned long addr, unsigned long len,
52 struct host_vm_op *ops, int index, int last_filled,
53 union mm_context *mmu,
54 void (*do_ops)(union mm_context *, struct host_vm_op *,
55 int));
56extern int add_mprotect(unsigned long addr, unsigned long len, int r, int w,
57 int x, struct host_vm_op *ops, int index,
58 int last_filled, union mm_context *mmu,
59 void (*do_ops)(union mm_context *, struct host_vm_op *,
60 int));
61#endif 47#endif
diff --git a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h
index d983ea842547..e91064b7e5a0 100644
--- a/arch/um/kernel/skas/include/skas.h
+++ b/arch/um/kernel/skas/include/skas.h
@@ -24,11 +24,14 @@ extern void new_thread_proc(void *stack, void (*handler)(int sig));
24extern void remove_sigstack(void); 24extern void remove_sigstack(void);
25extern void new_thread_handler(int sig); 25extern void new_thread_handler(int sig);
26extern void handle_syscall(union uml_pt_regs *regs); 26extern void handle_syscall(union uml_pt_regs *regs);
27extern int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len, 27extern void *map(struct mm_id * mm_idp, unsigned long virt,
28 int r, int w, int x, int phys_fd, unsigned long long offset); 28 unsigned long len, int r, int w, int x, int phys_fd,
29extern int unmap(struct mm_id * mm_idp, void *addr, unsigned long len); 29 unsigned long long offset, int done, void *data);
30extern int protect(struct mm_id * mm_idp, unsigned long addr, 30extern void *unmap(struct mm_id * mm_idp, void *addr,
31 unsigned long len, int r, int w, int x); 31 unsigned long len, int done, void *data);
32extern void *protect(struct mm_id * mm_idp, unsigned long addr,
33 unsigned long len, int r, int w, int x, int done,
34 void *data);
32extern void user_signal(int sig, union uml_pt_regs *regs, int pid); 35extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
33extern int new_mm(int from); 36extern int new_mm(int from);
34extern int start_userspace(unsigned long stub_stack); 37extern int start_userspace(unsigned long stub_stack);
diff --git a/arch/um/kernel/skas/mem_user.c b/arch/um/kernel/skas/mem_user.c
index b0980ff3bd95..c976320ebe84 100644
--- a/arch/um/kernel/skas/mem_user.c
+++ b/arch/um/kernel/skas/mem_user.c
@@ -25,12 +25,14 @@
25#include "sysdep/stub.h" 25#include "sysdep/stub.h"
26#include "skas.h" 26#include "skas.h"
27 27
28extern unsigned long syscall_stub, __syscall_stub_start; 28extern unsigned long syscall_stub, batch_syscall_stub, __syscall_stub_start;
29 29
30extern void wait_stub_done(int pid, int sig, char * fname); 30extern void wait_stub_done(int pid, int sig, char * fname);
31 31
32static long run_syscall_stub(struct mm_id * mm_idp, int syscall, 32int single_count = 0;
33 unsigned long *args) 33
34static long one_syscall_stub(struct mm_id * mm_idp, int syscall,
35 unsigned long *args)
34{ 36{
35 int n, pid = mm_idp->u.pid; 37 int n, pid = mm_idp->u.pid;
36 unsigned long regs[MAX_REG_NR]; 38 unsigned long regs[MAX_REG_NR];
@@ -49,18 +51,80 @@ static long run_syscall_stub(struct mm_id * mm_idp, int syscall,
49 regs[REGS_SYSCALL_ARG6] = args[5]; 51 regs[REGS_SYSCALL_ARG6] = args[5];
50 n = ptrace_setregs(pid, regs); 52 n = ptrace_setregs(pid, regs);
51 if(n < 0){ 53 if(n < 0){
52 printk("run_syscall_stub : PTRACE_SETREGS failed, " 54 printk("one_syscall_stub : PTRACE_SETREGS failed, "
55 "errno = %d\n", n);
56 return(n);
57 }
58
59 wait_stub_done(pid, 0, "one_syscall_stub");
60
61 return(*((unsigned long *) mm_idp->stack));
62}
63
64int multi_count = 0;
65int multi_op_count = 0;
66
67static long many_syscall_stub(struct mm_id * mm_idp, int syscall,
68 unsigned long *args, int done, void **addr_out)
69{
70 unsigned long regs[MAX_REG_NR], *stack;
71 int n, pid = mm_idp->u.pid;
72
73 stack = *addr_out;
74 if(stack == NULL)
75 stack = (unsigned long *) current_stub_stack();
76 *stack++ = syscall;
77 *stack++ = args[0];
78 *stack++ = args[1];
79 *stack++ = args[2];
80 *stack++ = args[3];
81 *stack++ = args[4];
82 *stack++ = args[5];
83 *stack = 0;
84 multi_op_count++;
85
86 if(!done && ((((unsigned long) stack) & ~PAGE_MASK) <
87 PAGE_SIZE - 8 * sizeof(long))){
88 *addr_out = stack;
89 return 0;
90 }
91
92 multi_count++;
93 get_safe_registers(regs);
94 regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE +
95 ((unsigned long) &batch_syscall_stub -
96 (unsigned long) &__syscall_stub_start);
97 regs[REGS_SP_INDEX] = UML_CONFIG_STUB_DATA;
98
99 n = ptrace_setregs(pid, regs);
100 if(n < 0){
101 printk("many_syscall_stub : PTRACE_SETREGS failed, "
53 "errno = %d\n", n); 102 "errno = %d\n", n);
54 return(n); 103 return(n);
55 } 104 }
56 105
57 wait_stub_done(pid, 0, "run_syscall_stub"); 106 wait_stub_done(pid, 0, "many_syscall_stub");
107 stack = (unsigned long *) mm_idp->stack;
58 108
59 return(*((unsigned long *) mm_idp->stack)); 109 *addr_out = stack;
110 return(*stack);
60} 111}
61 112
62int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, 113static long run_syscall_stub(struct mm_id * mm_idp, int syscall,
63 int r, int w, int x, int phys_fd, unsigned long long offset) 114 unsigned long *args, void **addr, int done)
115{
116 long res;
117
118 if((*addr == NULL) && done)
119 res = one_syscall_stub(mm_idp, syscall, args);
120 else res = many_syscall_stub(mm_idp, syscall, args, done, addr);
121
122 return res;
123}
124
125void *map(struct mm_id * mm_idp, unsigned long virt, unsigned long len,
126 int r, int w, int x, int phys_fd, unsigned long long offset,
127 int done, void *data)
64{ 128{
65 int prot, n; 129 int prot, n;
66 130
@@ -70,6 +134,7 @@ int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len,
70 if(proc_mm){ 134 if(proc_mm){
71 struct proc_mm_op map; 135 struct proc_mm_op map;
72 int fd = mm_idp->u.mm_fd; 136 int fd = mm_idp->u.mm_fd;
137
73 map = ((struct proc_mm_op) { .op = MM_MMAP, 138 map = ((struct proc_mm_op) { .op = MM_MMAP,
74 .u = 139 .u =
75 { .mmap = 140 { .mmap =
@@ -91,21 +156,24 @@ int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len,
91 MAP_SHARED | MAP_FIXED, phys_fd, 156 MAP_SHARED | MAP_FIXED, phys_fd,
92 MMAP_OFFSET(offset) }; 157 MMAP_OFFSET(offset) };
93 158
94 res = run_syscall_stub(mm_idp, STUB_MMAP_NR, args); 159 res = run_syscall_stub(mm_idp, STUB_MMAP_NR, args,
160 &data, done);
95 if((void *) res == MAP_FAILED) 161 if((void *) res == MAP_FAILED)
96 printk("mmap stub failed, errno = %d\n", res); 162 printk("mmap stub failed, errno = %d\n", res);
97 } 163 }
98 164
99 return 0; 165 return data;
100} 166}
101 167
102int unmap(struct mm_id *mm_idp, void *addr, unsigned long len) 168void *unmap(struct mm_id * mm_idp, void *addr, unsigned long len, int done,
169 void *data)
103{ 170{
104 int n; 171 int n;
105 172
106 if(proc_mm){ 173 if(proc_mm){
107 struct proc_mm_op unmap; 174 struct proc_mm_op unmap;
108 int fd = mm_idp->u.mm_fd; 175 int fd = mm_idp->u.mm_fd;
176
109 unmap = ((struct proc_mm_op) { .op = MM_MUNMAP, 177 unmap = ((struct proc_mm_op) { .op = MM_MUNMAP,
110 .u = 178 .u =
111 { .munmap = 179 { .munmap =
@@ -113,28 +181,25 @@ int unmap(struct mm_id *mm_idp, void *addr, unsigned long len)
113 (unsigned long) addr, 181 (unsigned long) addr,
114 .len = len } } } ); 182 .len = len } } } );
115 n = os_write_file(fd, &unmap, sizeof(unmap)); 183 n = os_write_file(fd, &unmap, sizeof(unmap));
116 if(n != sizeof(unmap)) { 184 if(n != sizeof(unmap))
117 if(n < 0) 185 printk("unmap - proc_mm write returned %d\n", n);
118 return(n);
119 else if(n > 0)
120 return(-EIO);
121 }
122 } 186 }
123 else { 187 else {
124 int res; 188 int res;
125 unsigned long args[] = { (unsigned long) addr, len, 0, 0, 0, 189 unsigned long args[] = { (unsigned long) addr, len, 0, 0, 0,
126 0 }; 190 0 };
127 191
128 res = run_syscall_stub(mm_idp, __NR_munmap, args); 192 res = run_syscall_stub(mm_idp, __NR_munmap, args,
193 &data, done);
129 if(res < 0) 194 if(res < 0)
130 printk("munmap stub failed, errno = %d\n", res); 195 printk("munmap stub failed, errno = %d\n", res);
131 } 196 }
132 197
133 return(0); 198 return data;
134} 199}
135 200
136int protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len, 201void *protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
137 int r, int w, int x) 202 int r, int w, int x, int done, void *data)
138{ 203{
139 struct proc_mm_op protect; 204 struct proc_mm_op protect;
140 int prot, n; 205 int prot, n;
@@ -160,12 +225,13 @@ int protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len,
160 int res; 225 int res;
161 unsigned long args[] = { addr, len, prot, 0, 0, 0 }; 226 unsigned long args[] = { addr, len, prot, 0, 0, 0 };
162 227
163 res = run_syscall_stub(mm_idp, __NR_mprotect, args); 228 res = run_syscall_stub(mm_idp, __NR_mprotect, args,
229 &data, done);
164 if(res < 0) 230 if(res < 0)
165 panic("mprotect stub failed, errno = %d\n", res); 231 panic("mprotect stub failed, errno = %d\n", res);
166 } 232 }
167 233
168 return(0); 234 return data;
169} 235}
170 236
171void before_mem_skas(unsigned long unused) 237void before_mem_skas(unsigned long unused)
diff --git a/arch/um/kernel/skas/tlb.c b/arch/um/kernel/skas/tlb.c
index 6230999c672c..4b5fd2049547 100644
--- a/arch/um/kernel/skas/tlb.c
+++ b/arch/um/kernel/skas/tlb.c
@@ -18,7 +18,8 @@
18#include "os.h" 18#include "os.h"
19#include "tlb.h" 19#include "tlb.h"
20 20
21static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last) 21static void *do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
22 int finished, void *flush)
22{ 23{
23 struct host_vm_op *op; 24 struct host_vm_op *op;
24 int i; 25 int i;
@@ -27,24 +28,28 @@ static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last)
27 op = &ops[i]; 28 op = &ops[i];
28 switch(op->type){ 29 switch(op->type){
29 case MMAP: 30 case MMAP:
30 map(&mmu->skas.id, op->u.mmap.addr, op->u.mmap.len, 31 flush = map(&mmu->skas.id, op->u.mmap.addr,
31 op->u.mmap.r, op->u.mmap.w, op->u.mmap.x, 32 op->u.mmap.len, op->u.mmap.r, op->u.mmap.w,
32 op->u.mmap.fd, op->u.mmap.offset); 33 op->u.mmap.x, op->u.mmap.fd,
34 op->u.mmap.offset, finished, flush);
33 break; 35 break;
34 case MUNMAP: 36 case MUNMAP:
35 unmap(&mmu->skas.id, (void *) op->u.munmap.addr, 37 flush = unmap(&mmu->skas.id, (void *) op->u.munmap.addr,
36 op->u.munmap.len); 38 op->u.munmap.len, finished, flush);
37 break; 39 break;
38 case MPROTECT: 40 case MPROTECT:
39 protect(&mmu->skas.id, op->u.mprotect.addr, 41 flush = protect(&mmu->skas.id, op->u.mprotect.addr,
40 op->u.mprotect.len, op->u.mprotect.r, 42 op->u.mprotect.len, op->u.mprotect.r,
41 op->u.mprotect.w, op->u.mprotect.x); 43 op->u.mprotect.w, op->u.mprotect.x,
44 finished, flush);
42 break; 45 break;
43 default: 46 default:
44 printk("Unknown op type %d in do_ops\n", op->type); 47 printk("Unknown op type %d in do_ops\n", op->type);
45 break; 48 break;
46 } 49 }
47 } 50 }
51
52 return flush;
48} 53}
49 54
50extern int proc_mm; 55extern int proc_mm;
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
index 83ec8d4747fd..7d914bb6b002 100644
--- a/arch/um/kernel/tlb.c
+++ b/arch/um/kernel/tlb.c
@@ -15,12 +15,116 @@
15#include "mem_user.h" 15#include "mem_user.h"
16#include "os.h" 16#include "os.h"
17 17
18static int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
19 int r, int w, int x, struct host_vm_op *ops, int index,
20 int last_filled, union mm_context *mmu, void **flush,
21 void *(*do_ops)(union mm_context *, struct host_vm_op *,
22 int, int, void *))
23{
24 __u64 offset;
25 struct host_vm_op *last;
26 int fd;
27
28 fd = phys_mapping(phys, &offset);
29 if(index != -1){
30 last = &ops[index];
31 if((last->type == MMAP) &&
32 (last->u.mmap.addr + last->u.mmap.len == virt) &&
33 (last->u.mmap.r == r) && (last->u.mmap.w == w) &&
34 (last->u.mmap.x == x) && (last->u.mmap.fd == fd) &&
35 (last->u.mmap.offset + last->u.mmap.len == offset)){
36 last->u.mmap.len += len;
37 return index;
38 }
39 }
40
41 if(index == last_filled){
42 *flush = (*do_ops)(mmu, ops, last_filled, 0, *flush);
43 index = -1;
44 }
45
46 ops[++index] = ((struct host_vm_op) { .type = MMAP,
47 .u = { .mmap = {
48 .addr = virt,
49 .len = len,
50 .r = r,
51 .w = w,
52 .x = x,
53 .fd = fd,
54 .offset = offset }
55 } });
56 return index;
57}
58
59static int add_munmap(unsigned long addr, unsigned long len,
60 struct host_vm_op *ops, int index, int last_filled,
61 union mm_context *mmu, void **flush,
62 void *(*do_ops)(union mm_context *, struct host_vm_op *,
63 int, int, void *))
64{
65 struct host_vm_op *last;
66
67 if(index != -1){
68 last = &ops[index];
69 if((last->type == MUNMAP) &&
70 (last->u.munmap.addr + last->u.mmap.len == addr)){
71 last->u.munmap.len += len;
72 return index;
73 }
74 }
75
76 if(index == last_filled){
77 *flush = (*do_ops)(mmu, ops, last_filled, 0, *flush);
78 index = -1;
79 }
80
81 ops[++index] = ((struct host_vm_op) { .type = MUNMAP,
82 .u = { .munmap = {
83 .addr = addr,
84 .len = len } } });
85 return index;
86}
87
88static int add_mprotect(unsigned long addr, unsigned long len, int r, int w,
89 int x, struct host_vm_op *ops, int index,
90 int last_filled, union mm_context *mmu, void **flush,
91 void *(*do_ops)(union mm_context *,
92 struct host_vm_op *, int, int, void *))
93{
94 struct host_vm_op *last;
95
96 if(index != -1){
97 last = &ops[index];
98 if((last->type == MPROTECT) &&
99 (last->u.mprotect.addr + last->u.mprotect.len == addr) &&
100 (last->u.mprotect.r == r) && (last->u.mprotect.w == w) &&
101 (last->u.mprotect.x == x)){
102 last->u.mprotect.len += len;
103 return index;
104 }
105 }
106
107 if(index == last_filled){
108 *flush = (*do_ops)(mmu, ops, last_filled, 0, *flush);
109 index = -1;
110 }
111
112 ops[++index] = ((struct host_vm_op) { .type = MPROTECT,
113 .u = { .mprotect = {
114 .addr = addr,
115 .len = len,
116 .r = r,
117 .w = w,
118 .x = x } } });
119 return index;
120}
121
18#define ADD_ROUND(n, inc) (((n) + (inc)) & ~((inc) - 1)) 122#define ADD_ROUND(n, inc) (((n) + (inc)) & ~((inc) - 1))
19 123
20void fix_range_common(struct mm_struct *mm, unsigned long start_addr, 124void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
21 unsigned long end_addr, int force, 125 unsigned long end_addr, int force,
22 void (*do_ops)(union mm_context *, struct host_vm_op *, 126 void *(*do_ops)(union mm_context *, struct host_vm_op *,
23 int)) 127 int, int, void *))
24{ 128{
25 pgd_t *npgd; 129 pgd_t *npgd;
26 pud_t *npud; 130 pud_t *npud;
@@ -29,11 +133,13 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
29 union mm_context *mmu = &mm->context; 133 union mm_context *mmu = &mm->context;
30 unsigned long addr, end; 134 unsigned long addr, end;
31 int r, w, x; 135 int r, w, x;
32 struct host_vm_op ops[16]; 136 struct host_vm_op ops[1];
137 void *flush = NULL;
33 int op_index = -1, last_op = sizeof(ops) / sizeof(ops[0]) - 1; 138 int op_index = -1, last_op = sizeof(ops) / sizeof(ops[0]) - 1;
34 139
35 if(mm == NULL) return; 140 if(mm == NULL) return;
36 141
142 ops[0].type = NONE;
37 for(addr = start_addr; addr < end_addr;){ 143 for(addr = start_addr; addr < end_addr;){
38 npgd = pgd_offset(mm, addr); 144 npgd = pgd_offset(mm, addr);
39 if(!pgd_present(*npgd)){ 145 if(!pgd_present(*npgd)){
@@ -43,7 +149,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
43 if(force || pgd_newpage(*npgd)){ 149 if(force || pgd_newpage(*npgd)){
44 op_index = add_munmap(addr, end - addr, ops, 150 op_index = add_munmap(addr, end - addr, ops,
45 op_index, last_op, mmu, 151 op_index, last_op, mmu,
46 do_ops); 152 &flush, do_ops);
47 pgd_mkuptodate(*npgd); 153 pgd_mkuptodate(*npgd);
48 } 154 }
49 addr = end; 155 addr = end;
@@ -58,7 +164,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
58 if(force || pud_newpage(*npud)){ 164 if(force || pud_newpage(*npud)){
59 op_index = add_munmap(addr, end - addr, ops, 165 op_index = add_munmap(addr, end - addr, ops,
60 op_index, last_op, mmu, 166 op_index, last_op, mmu,
61 do_ops); 167 &flush, do_ops);
62 pud_mkuptodate(*npud); 168 pud_mkuptodate(*npud);
63 } 169 }
64 addr = end; 170 addr = end;
@@ -73,7 +179,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
73 if(force || pmd_newpage(*npmd)){ 179 if(force || pmd_newpage(*npmd)){
74 op_index = add_munmap(addr, end - addr, ops, 180 op_index = add_munmap(addr, end - addr, ops,
75 op_index, last_op, mmu, 181 op_index, last_op, mmu,
76 do_ops); 182 &flush, do_ops);
77 pmd_mkuptodate(*npmd); 183 pmd_mkuptodate(*npmd);
78 } 184 }
79 addr = end; 185 addr = end;
@@ -96,20 +202,20 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
96 pte_val(*npte) & PAGE_MASK, 202 pte_val(*npte) & PAGE_MASK,
97 PAGE_SIZE, r, w, x, ops, 203 PAGE_SIZE, r, w, x, ops,
98 op_index, last_op, mmu, 204 op_index, last_op, mmu,
99 do_ops); 205 &flush, do_ops);
100 else op_index = add_munmap(addr, PAGE_SIZE, ops, 206 else op_index = add_munmap(addr, PAGE_SIZE, ops,
101 op_index, last_op, mmu, 207 op_index, last_op, mmu,
102 do_ops); 208 &flush, do_ops);
103 } 209 }
104 else if(pte_newprot(*npte)) 210 else if(pte_newprot(*npte))
105 op_index = add_mprotect(addr, PAGE_SIZE, r, w, x, ops, 211 op_index = add_mprotect(addr, PAGE_SIZE, r, w, x, ops,
106 op_index, last_op, mmu, 212 op_index, last_op, mmu,
107 do_ops); 213 &flush, do_ops);
108 214
109 *npte = pte_mkuptodate(*npte); 215 *npte = pte_mkuptodate(*npte);
110 addr += PAGE_SIZE; 216 addr += PAGE_SIZE;
111 } 217 }
112 (*do_ops)(mmu, ops, op_index); 218 flush = (*do_ops)(mmu, ops, op_index, 1, flush);
113} 219}
114 220
115int flush_tlb_kernel_range_common(unsigned long start, unsigned long end) 221int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
@@ -226,106 +332,6 @@ pte_t *addr_pte(struct task_struct *task, unsigned long addr)
226 return(pte_offset_map(pmd, addr)); 332 return(pte_offset_map(pmd, addr));
227} 333}
228 334
229int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
230 int r, int w, int x, struct host_vm_op *ops, int index,
231 int last_filled, union mm_context *mmu,
232 void (*do_ops)(union mm_context *, struct host_vm_op *, int))
233{
234 __u64 offset;
235 struct host_vm_op *last;
236 int fd;
237
238 fd = phys_mapping(phys, &offset);
239 if(index != -1){
240 last = &ops[index];
241 if((last->type == MMAP) &&
242 (last->u.mmap.addr + last->u.mmap.len == virt) &&
243 (last->u.mmap.r == r) && (last->u.mmap.w == w) &&
244 (last->u.mmap.x == x) && (last->u.mmap.fd == fd) &&
245 (last->u.mmap.offset + last->u.mmap.len == offset)){
246 last->u.mmap.len += len;
247 return(index);
248 }
249 }
250
251 if(index == last_filled){
252 (*do_ops)(mmu, ops, last_filled);
253 index = -1;
254 }
255
256 ops[++index] = ((struct host_vm_op) { .type = MMAP,
257 .u = { .mmap = {
258 .addr = virt,
259 .len = len,
260 .r = r,
261 .w = w,
262 .x = x,
263 .fd = fd,
264 .offset = offset }
265 } });
266 return(index);
267}
268
269int add_munmap(unsigned long addr, unsigned long len, struct host_vm_op *ops,
270 int index, int last_filled, union mm_context *mmu,
271 void (*do_ops)(union mm_context *, struct host_vm_op *, int))
272{
273 struct host_vm_op *last;
274
275 if(index != -1){
276 last = &ops[index];
277 if((last->type == MUNMAP) &&
278 (last->u.munmap.addr + last->u.mmap.len == addr)){
279 last->u.munmap.len += len;
280 return(index);
281 }
282 }
283
284 if(index == last_filled){
285 (*do_ops)(mmu, ops, last_filled);
286 index = -1;
287 }
288
289 ops[++index] = ((struct host_vm_op) { .type = MUNMAP,
290 .u = { .munmap = {
291 .addr = addr,
292 .len = len } } });
293 return(index);
294}
295
296int add_mprotect(unsigned long addr, unsigned long len, int r, int w, int x,
297 struct host_vm_op *ops, int index, int last_filled,
298 union mm_context *mmu,
299 void (*do_ops)(union mm_context *, struct host_vm_op *, int))
300{
301 struct host_vm_op *last;
302
303 if(index != -1){
304 last = &ops[index];
305 if((last->type == MPROTECT) &&
306 (last->u.mprotect.addr + last->u.mprotect.len == addr) &&
307 (last->u.mprotect.r == r) && (last->u.mprotect.w == w) &&
308 (last->u.mprotect.x == x)){
309 last->u.mprotect.len += len;
310 return(index);
311 }
312 }
313
314 if(index == last_filled){
315 (*do_ops)(mmu, ops, last_filled);
316 index = -1;
317 }
318
319 ops[++index] = ((struct host_vm_op) { .type = MPROTECT,
320 .u = { .mprotect = {
321 .addr = addr,
322 .len = len,
323 .r = r,
324 .w = w,
325 .x = x } } });
326 return(index);
327}
328
329void flush_tlb_page(struct vm_area_struct *vma, unsigned long address) 335void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
330{ 336{
331 address &= PAGE_MASK; 337 address &= PAGE_MASK;
diff --git a/arch/um/kernel/tt/tlb.c b/arch/um/kernel/tt/tlb.c
index 2eefb43bc9c2..16fc6a28882d 100644
--- a/arch/um/kernel/tt/tlb.c
+++ b/arch/um/kernel/tt/tlb.c
@@ -17,7 +17,8 @@
17#include "os.h" 17#include "os.h"
18#include "tlb.h" 18#include "tlb.h"
19 19
20static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last) 20static void *do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
21 int finished, void *flush)
21{ 22{
22 struct host_vm_op *op; 23 struct host_vm_op *op;
23 int i; 24 int i;
@@ -45,6 +46,8 @@ static void do_ops(union mm_context *mmu, struct host_vm_op *ops, int last)
45 break; 46 break;
46 } 47 }
47 } 48 }
49
50 return NULL;
48} 51}
49 52
50static void fix_range(struct mm_struct *mm, unsigned long start_addr, 53static void fix_range(struct mm_struct *mm, unsigned long start_addr,
diff --git a/arch/um/sys-i386/stub.S b/arch/um/sys-i386/stub.S
index 2f2c70a8f043..a0f9506312d1 100644
--- a/arch/um/sys-i386/stub.S
+++ b/arch/um/sys-i386/stub.S
@@ -6,3 +6,20 @@ syscall_stub:
6 int $0x80 6 int $0x80
7 mov %eax, UML_CONFIG_STUB_DATA 7 mov %eax, UML_CONFIG_STUB_DATA
8 int3 8 int3
9
10 .globl batch_syscall_stub
11batch_syscall_stub:
12 mov $UML_CONFIG_STUB_DATA, %esp
13again: pop %eax
14 cmpl $0, %eax
15 jz done
16 pop %ebx
17 pop %ecx
18 pop %edx
19 pop %esi
20 pop %edi
21 pop %ebp
22 int $0x80
23 mov %eax, UML_CONFIG_STUB_DATA
24 jmp again
25done: int3
diff --git a/arch/um/sys-x86_64/stub.S b/arch/um/sys-x86_64/stub.S
index 31c14925716b..957f2eff32ca 100644
--- a/arch/um/sys-x86_64/stub.S
+++ b/arch/um/sys-x86_64/stub.S
@@ -13,3 +13,24 @@ syscall_stub:
13 or %rcx, %rbx 13 or %rcx, %rbx
14 movq %rax, (%rbx) 14 movq %rax, (%rbx)
15 int3 15 int3
16
17 .globl batch_syscall_stub
18batch_syscall_stub:
19 movq $(UML_CONFIG_STUB_DATA >> 32), %rbx
20 salq $32, %rbx
21 movq $(UML_CONFIG_STUB_DATA & 0xffffffff), %rcx
22 or %rcx, %rbx
23 movq %rbx, %rsp
24again: pop %rax
25 cmpq $0, %rax
26jz done
27 pop %rdi
28 pop %rsi
29 pop %rdx
30 pop %r10
31 pop %r8
32 pop %r9
33 syscall
34 mov %rax, (%rbx)
35 jmp again
36done: int3