diff options
Diffstat (limited to 'arch/um/os-Linux/process.c')
-rw-r--r-- | arch/um/os-Linux/process.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 8176b0b52047..233be2f4f8cb 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -190,7 +190,7 @@ int os_unmap_memory(void *addr, int len) | |||
190 | } | 190 | } |
191 | 191 | ||
192 | #ifndef MADV_REMOVE | 192 | #ifndef MADV_REMOVE |
193 | #define MADV_REMOVE 0x5 /* remove these pages & resources */ | 193 | #define MADV_REMOVE KERNEL_MADV_REMOVE |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | int os_drop_memory(void *addr, int length) | 196 | int os_drop_memory(void *addr, int length) |
@@ -206,29 +206,36 @@ int os_drop_memory(void *addr, int length) | |||
206 | int can_drop_memory(void) | 206 | int can_drop_memory(void) |
207 | { | 207 | { |
208 | void *addr; | 208 | void *addr; |
209 | int fd; | 209 | int fd, ok = 0; |
210 | 210 | ||
211 | printk("Checking host MADV_REMOVE support..."); | 211 | printk("Checking host MADV_REMOVE support..."); |
212 | fd = create_mem_file(UM_KERN_PAGE_SIZE); | 212 | fd = create_mem_file(UM_KERN_PAGE_SIZE); |
213 | if(fd < 0){ | 213 | if(fd < 0){ |
214 | printk("Creating test memory file failed, err = %d\n", -fd); | 214 | printk("Creating test memory file failed, err = %d\n", -fd); |
215 | return 0; | 215 | goto out; |
216 | } | 216 | } |
217 | 217 | ||
218 | addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, | 218 | addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
219 | MAP_PRIVATE, fd, 0); | 219 | MAP_SHARED, fd, 0); |
220 | if(addr == MAP_FAILED){ | 220 | if(addr == MAP_FAILED){ |
221 | printk("Mapping test memory file failed, err = %d\n", -errno); | 221 | printk("Mapping test memory file failed, err = %d\n", -errno); |
222 | return 0; | 222 | goto out_close; |
223 | } | 223 | } |
224 | 224 | ||
225 | if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){ | 225 | if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){ |
226 | printk("MADV_REMOVE failed, err = %d\n", -errno); | 226 | printk("MADV_REMOVE failed, err = %d\n", -errno); |
227 | return 0; | 227 | goto out_unmap; |
228 | } | 228 | } |
229 | 229 | ||
230 | printk("OK\n"); | 230 | printk("OK\n"); |
231 | return 1; | 231 | ok = 1; |
232 | |||
233 | out_unmap: | ||
234 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
235 | out_close: | ||
236 | close(fd); | ||
237 | out: | ||
238 | return ok; | ||
232 | } | 239 | } |
233 | 240 | ||
234 | void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) | 241 | void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) |
@@ -266,11 +273,11 @@ void init_new_thread_signals(int altstack) | |||
266 | 273 | ||
267 | int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) | 274 | int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) |
268 | { | 275 | { |
269 | sigjmp_buf buf; | 276 | jmp_buf buf; |
270 | int n, enable; | 277 | int n, enable; |
271 | 278 | ||
272 | *jmp_ptr = &buf; | 279 | *jmp_ptr = &buf; |
273 | n = UML_SIGSETJMP(&buf, enable); | 280 | n = UML_SETJMP(&buf, enable); |
274 | if(n != 0) | 281 | if(n != 0) |
275 | return(n); | 282 | return(n); |
276 | (*fn)(arg); | 283 | (*fn)(arg); |