diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:09 -0400 |
commit | 54ae36f24b103e521dd683f66fe72b0584ccb7e2 (patch) | |
tree | 1504968363c0935479ebd28e710562d8046dd884 /arch/um/os-Linux | |
parent | 605c1e57690fddbd11347ec6788ff77c527994dd (diff) |
uml: fix stub address calculations
The calculation of CONFIG_STUB_CODE and CONFIG_STUB_DATA didn't take into
account anything but 3G/1G and 2G/2G, leaving the other vmsplits out in the
cold.
I'd rather not duplicate the four known host vmsplit cases for each of these
symbols. I'd also like to calculate them based on the highest userspace
address.
The Kconfig language seems not to allow calculation of hex constants, so I
moved this to as-layout.h. CONFIG_STUB_CODE, CONFIG_STUB_DATA, and
CONFIG_STUB_START are now gone. In their place are STUB_CODE, STUB_DATA, and
STUB_START in as-layout.h.
i386 and x86_64 seem to differ as to whether an unadorned constant is an int
or a long, so I cast them to unsigned long so they can be printed
consistently. However, they are also used in stub.S, where C types don't work
so well. So, there are ASM_ versions of these constants for use in stub.S. I
also ifdef-ed the non-asm-friendly portion of as-layout.h.
With this in place, most of the rest of this patch is changing CONFIG_STUB_*
to STUB_*, except in stub.S, where they are changed to ASM_STUB_*.
defconfig has the old symbols deleted.
I also print these addresses out in case there is any problem mapping them on
the host.
The two stub.S files had some trailing whitespace, so that is cleaned up here.
[akpm@linux-foundation.org: coding-style fixes]
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/os-Linux')
-rw-r--r-- | arch/um/os-Linux/skas/mem.c | 8 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 21 |
2 files changed, 15 insertions, 14 deletions
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c index d58d11179bb7..484e68f9f7ae 100644 --- a/arch/um/os-Linux/skas/mem.c +++ b/arch/um/os-Linux/skas/mem.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <sys/mman.h> | 10 | #include <sys/mman.h> |
11 | #include "init.h" | 11 | #include "init.h" |
12 | #include "kern_constants.h" | 12 | #include "kern_constants.h" |
13 | #include "as-layout.h" | ||
13 | #include "mm_id.h" | 14 | #include "mm_id.h" |
14 | #include "os.h" | 15 | #include "os.h" |
15 | #include "proc_mm.h" | 16 | #include "proc_mm.h" |
@@ -40,7 +41,7 @@ static unsigned long syscall_regs[MAX_REG_NR]; | |||
40 | static int __init init_syscall_regs(void) | 41 | static int __init init_syscall_regs(void) |
41 | { | 42 | { |
42 | get_safe_registers(syscall_regs); | 43 | get_safe_registers(syscall_regs); |
43 | syscall_regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE + | 44 | syscall_regs[REGS_IP_INDEX] = STUB_CODE + |
44 | ((unsigned long) &batch_syscall_stub - | 45 | ((unsigned long) &batch_syscall_stub - |
45 | (unsigned long) &__syscall_stub_start); | 46 | (unsigned long) &__syscall_stub_start); |
46 | return 0; | 47 | return 0; |
@@ -93,8 +94,7 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr) | |||
93 | ret = *((unsigned long *) mm_idp->stack); | 94 | ret = *((unsigned long *) mm_idp->stack); |
94 | offset = *((unsigned long *) mm_idp->stack + 1); | 95 | offset = *((unsigned long *) mm_idp->stack + 1); |
95 | if (offset) { | 96 | if (offset) { |
96 | data = (unsigned long *)(mm_idp->stack + | 97 | data = (unsigned long *)(mm_idp->stack + offset - STUB_DATA); |
97 | offset - UML_CONFIG_STUB_DATA); | ||
98 | printk(UM_KERN_ERR "do_syscall_stub : ret = %ld, offset = %ld, " | 98 | printk(UM_KERN_ERR "do_syscall_stub : ret = %ld, offset = %ld, " |
99 | "data = %p\n", ret, offset, data); | 99 | "data = %p\n", ret, offset, data); |
100 | syscall = (unsigned long *)((unsigned long)data + data[0]); | 100 | syscall = (unsigned long *)((unsigned long)data + data[0]); |
@@ -182,7 +182,7 @@ long syscall_stub_data(struct mm_id * mm_idp, | |||
182 | memcpy(stack + 1, data, data_count * sizeof(long)); | 182 | memcpy(stack + 1, data, data_count * sizeof(long)); |
183 | 183 | ||
184 | *stub_addr = (void *)(((unsigned long)(stack + 1) & | 184 | *stub_addr = (void *)(((unsigned long)(stack + 1) & |
185 | ~UM_KERN_PAGE_MASK) + UML_CONFIG_STUB_DATA); | 185 | ~UM_KERN_PAGE_MASK) + STUB_DATA); |
186 | 186 | ||
187 | return 0; | 187 | return 0; |
188 | } | 188 | } |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 8548f126d628..e60d6e6c5a58 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -191,22 +191,23 @@ static int userspace_tramp(void *stack) | |||
191 | int fd; | 191 | int fd; |
192 | unsigned long long offset; | 192 | unsigned long long offset; |
193 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); | 193 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); |
194 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, UM_KERN_PAGE_SIZE, | 194 | addr = mmap64((void *) STUB_CODE, UM_KERN_PAGE_SIZE, |
195 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); | 195 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); |
196 | if (addr == MAP_FAILED) { | 196 | if (addr == MAP_FAILED) { |
197 | printk(UM_KERN_ERR "mapping mmap stub failed, " | 197 | printk(UM_KERN_ERR "mapping mmap stub at 0x%lx failed, " |
198 | "errno = %d\n", errno); | 198 | "errno = %d\n", STUB_CODE, errno); |
199 | exit(1); | 199 | exit(1); |
200 | } | 200 | } |
201 | 201 | ||
202 | if (stack != NULL) { | 202 | if (stack != NULL) { |
203 | fd = phys_mapping(to_phys(stack), &offset); | 203 | fd = phys_mapping(to_phys(stack), &offset); |
204 | addr = mmap((void *) UML_CONFIG_STUB_DATA, | 204 | addr = mmap((void *) STUB_DATA, |
205 | UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, | 205 | UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
206 | MAP_FIXED | MAP_SHARED, fd, offset); | 206 | MAP_FIXED | MAP_SHARED, fd, offset); |
207 | if (addr == MAP_FAILED) { | 207 | if (addr == MAP_FAILED) { |
208 | printk(UM_KERN_ERR "mapping segfault stack " | 208 | printk(UM_KERN_ERR "mapping segfault stack " |
209 | "failed, errno = %d\n", errno); | 209 | "at 0x%lx failed, errno = %d\n", |
210 | STUB_DATA, errno); | ||
210 | exit(1); | 211 | exit(1); |
211 | } | 212 | } |
212 | } | 213 | } |
@@ -214,11 +215,11 @@ static int userspace_tramp(void *stack) | |||
214 | if (!ptrace_faultinfo && (stack != NULL)) { | 215 | if (!ptrace_faultinfo && (stack != NULL)) { |
215 | struct sigaction sa; | 216 | struct sigaction sa; |
216 | 217 | ||
217 | unsigned long v = UML_CONFIG_STUB_CODE + | 218 | unsigned long v = STUB_CODE + |
218 | (unsigned long) stub_segv_handler - | 219 | (unsigned long) stub_segv_handler - |
219 | (unsigned long) &__syscall_stub_start; | 220 | (unsigned long) &__syscall_stub_start; |
220 | 221 | ||
221 | set_sigstack((void *) UML_CONFIG_STUB_DATA, UM_KERN_PAGE_SIZE); | 222 | set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE); |
222 | sigemptyset(&sa.sa_mask); | 223 | sigemptyset(&sa.sa_mask); |
223 | sigaddset(&sa.sa_mask, SIGIO); | 224 | sigaddset(&sa.sa_mask, SIGIO); |
224 | sigaddset(&sa.sa_mask, SIGWINCH); | 225 | sigaddset(&sa.sa_mask, SIGWINCH); |
@@ -382,10 +383,10 @@ static int __init init_thread_regs(void) | |||
382 | { | 383 | { |
383 | get_safe_registers(thread_regs); | 384 | get_safe_registers(thread_regs); |
384 | /* Set parent's instruction pointer to start of clone-stub */ | 385 | /* Set parent's instruction pointer to start of clone-stub */ |
385 | thread_regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE + | 386 | thread_regs[REGS_IP_INDEX] = STUB_CODE + |
386 | (unsigned long) stub_clone_handler - | 387 | (unsigned long) stub_clone_handler - |
387 | (unsigned long) &__syscall_stub_start; | 388 | (unsigned long) &__syscall_stub_start; |
388 | thread_regs[REGS_SP_INDEX] = UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE - | 389 | thread_regs[REGS_SP_INDEX] = STUB_DATA + UM_KERN_PAGE_SIZE - |
389 | sizeof(void *); | 390 | sizeof(void *); |
390 | #ifdef __SIGNAL_FRAMESIZE | 391 | #ifdef __SIGNAL_FRAMESIZE |
391 | thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE; | 392 | thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE; |
@@ -443,7 +444,7 @@ int copy_context_skas0(unsigned long new_stack, int pid) | |||
443 | * child's stack and check it. | 444 | * child's stack and check it. |
444 | */ | 445 | */ |
445 | wait_stub_done(pid); | 446 | wait_stub_done(pid); |
446 | if (child_data->err != UML_CONFIG_STUB_DATA) | 447 | if (child_data->err != STUB_DATA) |
447 | panic("copy_context_skas0 - stub-child reports error %ld\n", | 448 | panic("copy_context_skas0 - stub-child reports error %ld\n", |
448 | child_data->err); | 449 | child_data->err); |
449 | 450 | ||