diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-06-16 13:16:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-06-16 16:16:16 -0400 |
commit | c539ab73070b381f0452dae791f891ec2515098e (patch) | |
tree | 68e4e706fe31b88b26bd4b29eadb32440148eb3e /arch/um | |
parent | f5a9c77df45b113d21b64cbc2bf6c72a0da48998 (diff) |
uml: remove PAGE_SIZE from libc code
Distros seem to be removing PAGE_SIZE from asm/page.h. So, the libc side of
UML should stop using it.
I replace it with UM_KERN_PAGE_SIZE, which is defined to be the same as
PAGE_SIZE on the kernel side of the house. I could also use getpagesize(),
but it's more important that UML have the same value of PAGE_SIZE everywhere.
It's conceivable that it could be built with a larger PAGE_SIZE, and use of
getpagesize() would break that badly.
PAGE_MASK got the same treatment, as it is closely tied to PAGE_SIZE.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/include/common-offsets.h | 1 | ||||
-rw-r--r-- | arch/um/os-Linux/main.c | 4 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/mem.c | 13 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 13 | ||||
-rw-r--r-- | arch/um/os-Linux/start_up.c | 7 |
5 files changed, 22 insertions, 16 deletions
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h index 541f4a8ca512..7376ee44e330 100644 --- a/arch/um/include/common-offsets.h +++ b/arch/um/include/common-offsets.h | |||
@@ -9,6 +9,7 @@ OFFSET(HOST_TASK_REGS, task_struct, thread.regs); | |||
9 | OFFSET(HOST_TASK_PID, task_struct, pid); | 9 | OFFSET(HOST_TASK_PID, task_struct, pid); |
10 | 10 | ||
11 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); | 11 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); |
12 | DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK); | ||
12 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | 13 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); |
13 | 14 | ||
14 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); | 15 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); |
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index ea9a23696f36..fb510d40480c 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "uml-config.h" | 24 | #include "uml-config.h" |
25 | #include "os.h" | 25 | #include "os.h" |
26 | #include "um_malloc.h" | 26 | #include "um_malloc.h" |
27 | #include "kern_constants.h" | ||
27 | 28 | ||
28 | /* Set in main, unchanged thereafter */ | 29 | /* Set in main, unchanged thereafter */ |
29 | char *linux_prog; | 30 | char *linux_prog; |
@@ -232,7 +233,8 @@ void *__wrap_malloc(int size) | |||
232 | 233 | ||
233 | if(!CAN_KMALLOC()) | 234 | if(!CAN_KMALLOC()) |
234 | return __real_malloc(size); | 235 | return __real_malloc(size); |
235 | else if(size <= PAGE_SIZE) /* finding contiguos pages can be hard*/ | 236 | else if(size <= UM_KERN_PAGE_SIZE) |
237 | /* finding contiguous pages can be hard*/ | ||
236 | ret = um_kmalloc(size); | 238 | ret = um_kmalloc(size); |
237 | else ret = um_vmalloc(size); | 239 | else ret = um_vmalloc(size); |
238 | 240 | ||
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c index 5c8946320799..0f7df4eb903f 100644 --- a/arch/um/os-Linux/skas/mem.c +++ b/arch/um/os-Linux/skas/mem.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "sysdep/ptrace.h" | 25 | #include "sysdep/ptrace.h" |
26 | #include "sysdep/stub.h" | 26 | #include "sysdep/stub.h" |
27 | #include "init.h" | 27 | #include "init.h" |
28 | #include "kern_constants.h" | ||
28 | 29 | ||
29 | extern unsigned long batch_syscall_stub, __syscall_stub_start; | 30 | extern unsigned long batch_syscall_stub, __syscall_stub_start; |
30 | 31 | ||
@@ -149,8 +150,8 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall, | |||
149 | *stack = 0; | 150 | *stack = 0; |
150 | multi_op_count++; | 151 | multi_op_count++; |
151 | 152 | ||
152 | if(!done && ((((unsigned long) stack) & ~PAGE_MASK) < | 153 | if(!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) < |
153 | PAGE_SIZE - 10 * sizeof(long))){ | 154 | UM_KERN_PAGE_SIZE - 10 * sizeof(long))){ |
154 | *addr = stack; | 155 | *addr = stack; |
155 | return 0; | 156 | return 0; |
156 | } | 157 | } |
@@ -168,8 +169,8 @@ long syscall_stub_data(struct mm_id * mm_idp, | |||
168 | /* If *addr still is uninitialized, it *must* contain NULL. | 169 | /* If *addr still is uninitialized, it *must* contain NULL. |
169 | * Thus in this case do_syscall_stub correctly won't be called. | 170 | * Thus in this case do_syscall_stub correctly won't be called. |
170 | */ | 171 | */ |
171 | if((((unsigned long) *addr) & ~PAGE_MASK) >= | 172 | if((((unsigned long) *addr) & ~UM_KERN_PAGE_MASK) >= |
172 | PAGE_SIZE - (10 + data_count) * sizeof(long)) { | 173 | UM_KERN_PAGE_SIZE - (10 + data_count) * sizeof(long)) { |
173 | ret = do_syscall_stub(mm_idp, addr); | 174 | ret = do_syscall_stub(mm_idp, addr); |
174 | /* in case of error, don't overwrite data on stack */ | 175 | /* in case of error, don't overwrite data on stack */ |
175 | if(ret) | 176 | if(ret) |
@@ -183,8 +184,8 @@ long syscall_stub_data(struct mm_id * mm_idp, | |||
183 | 184 | ||
184 | memcpy(stack + 1, data, data_count * sizeof(long)); | 185 | memcpy(stack + 1, data, data_count * sizeof(long)); |
185 | 186 | ||
186 | *stub_addr = (void *)(((unsigned long)(stack + 1) & ~PAGE_MASK) + | 187 | *stub_addr = (void *)(((unsigned long)(stack + 1) & |
187 | UML_CONFIG_STUB_DATA); | 188 | ~UM_KERN_PAGE_MASK) + UML_CONFIG_STUB_DATA); |
188 | 189 | ||
189 | return 0; | 190 | return 0; |
190 | } | 191 | } |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index f9d2f8545afe..46c00cc429bc 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -252,11 +252,12 @@ int start_userspace(unsigned long stub_stack) | |||
252 | unsigned long sp; | 252 | unsigned long sp; |
253 | int pid, status, n, flags; | 253 | int pid, status, n, flags; |
254 | 254 | ||
255 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, | 255 | stack = mmap(NULL, UM_KERN_PAGE_SIZE, |
256 | PROT_READ | PROT_WRITE | PROT_EXEC, | ||
256 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 257 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
257 | if(stack == MAP_FAILED) | 258 | if(stack == MAP_FAILED) |
258 | panic("start_userspace : mmap failed, errno = %d", errno); | 259 | panic("start_userspace : mmap failed, errno = %d", errno); |
259 | sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *); | 260 | sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); |
260 | 261 | ||
261 | flags = CLONE_FILES | SIGCHLD; | 262 | flags = CLONE_FILES | SIGCHLD; |
262 | if(proc_mm) flags |= CLONE_VM; | 263 | if(proc_mm) flags |= CLONE_VM; |
@@ -279,7 +280,7 @@ int start_userspace(unsigned long stub_stack) | |||
279 | panic("start_userspace : PTRACE_OLDSETOPTIONS failed, errno=%d\n", | 280 | panic("start_userspace : PTRACE_OLDSETOPTIONS failed, errno=%d\n", |
280 | errno); | 281 | errno); |
281 | 282 | ||
282 | if(munmap(stack, PAGE_SIZE) < 0) | 283 | if(munmap(stack, UM_KERN_PAGE_SIZE) < 0) |
283 | panic("start_userspace : munmap failed, errno = %d\n", errno); | 284 | panic("start_userspace : munmap failed, errno = %d\n", errno); |
284 | 285 | ||
285 | return(pid); | 286 | return(pid); |
@@ -365,7 +366,7 @@ static int __init init_thread_regs(void) | |||
365 | thread_regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE + | 366 | thread_regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE + |
366 | (unsigned long) stub_clone_handler - | 367 | (unsigned long) stub_clone_handler - |
367 | (unsigned long) &__syscall_stub_start; | 368 | (unsigned long) &__syscall_stub_start; |
368 | thread_regs[REGS_SP_INDEX] = UML_CONFIG_STUB_DATA + PAGE_SIZE - | 369 | thread_regs[REGS_SP_INDEX] = UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE - |
369 | sizeof(void *); | 370 | sizeof(void *); |
370 | #ifdef __SIGNAL_FRAMESIZE | 371 | #ifdef __SIGNAL_FRAMESIZE |
371 | thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE; | 372 | thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE; |
@@ -453,7 +454,7 @@ void map_stub_pages(int fd, unsigned long code, | |||
453 | .u = | 454 | .u = |
454 | { .mmap = | 455 | { .mmap = |
455 | { .addr = code, | 456 | { .addr = code, |
456 | .len = PAGE_SIZE, | 457 | .len = UM_KERN_PAGE_SIZE, |
457 | .prot = PROT_EXEC, | 458 | .prot = PROT_EXEC, |
458 | .flags = MAP_FIXED | MAP_PRIVATE, | 459 | .flags = MAP_FIXED | MAP_PRIVATE, |
459 | .fd = code_fd, | 460 | .fd = code_fd, |
@@ -476,7 +477,7 @@ void map_stub_pages(int fd, unsigned long code, | |||
476 | .u = | 477 | .u = |
477 | { .mmap = | 478 | { .mmap = |
478 | { .addr = data, | 479 | { .addr = data, |
479 | .len = PAGE_SIZE, | 480 | .len = UM_KERN_PAGE_SIZE, |
480 | .prot = PROT_READ | PROT_WRITE, | 481 | .prot = PROT_READ | PROT_WRITE, |
481 | .flags = MAP_FIXED | MAP_SHARED, | 482 | .flags = MAP_FIXED | MAP_SHARED, |
482 | .fd = map_fd, | 483 | .fd = map_fd, |
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 3fc13fa8729d..46f613975c19 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -107,11 +107,12 @@ static int start_ptraced_child(void **stack_out) | |||
107 | unsigned long sp; | 107 | unsigned long sp; |
108 | int pid, n, status; | 108 | int pid, n, status; |
109 | 109 | ||
110 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, | 110 | stack = mmap(NULL, UM_KERN_PAGE_SIZE, |
111 | PROT_READ | PROT_WRITE | PROT_EXEC, | ||
111 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 112 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
112 | if(stack == MAP_FAILED) | 113 | if(stack == MAP_FAILED) |
113 | fatal_perror("check_ptrace : mmap failed"); | 114 | fatal_perror("check_ptrace : mmap failed"); |
114 | sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *); | 115 | sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); |
115 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); | 116 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); |
116 | if(pid < 0) | 117 | if(pid < 0) |
117 | fatal_perror("start_ptraced_child : clone failed"); | 118 | fatal_perror("start_ptraced_child : clone failed"); |
@@ -153,7 +154,7 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, | |||
153 | ret = -1; | 154 | ret = -1; |
154 | } | 155 | } |
155 | 156 | ||
156 | if(munmap(stack, PAGE_SIZE) < 0) | 157 | if(munmap(stack, UM_KERN_PAGE_SIZE) < 0) |
157 | fatal_perror("check_ptrace : munmap failed"); | 158 | fatal_perror("check_ptrace : munmap failed"); |
158 | return ret; | 159 | return ret; |
159 | } | 160 | } |