aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/include
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:27:33 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:09 -0400
commit54ae36f24b103e521dd683f66fe72b0584ccb7e2 (patch)
tree1504968363c0935479ebd28e710562d8046dd884 /arch/um/include
parent605c1e57690fddbd11347ec6788ff77c527994dd (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/include')
-rw-r--r--arch/um/include/as-layout.h24
-rw-r--r--arch/um/include/sysdep-i386/stub.h11
-rw-r--r--arch/um/include/sysdep-x86_64/stub.h13
3 files changed, 37 insertions, 11 deletions
diff --git a/arch/um/include/as-layout.h b/arch/um/include/as-layout.h
index 2f16a1c7d616..a5cdf953e04a 100644
--- a/arch/um/include/as-layout.h
+++ b/arch/um/include/as-layout.h
@@ -6,6 +6,28 @@
6#ifndef __START_H__ 6#ifndef __START_H__
7#define __START_H__ 7#define __START_H__
8 8
9#include "uml-config.h"
10#include "kern_constants.h"
11
12/*
13 * Assembly doesn't want any casting, but C does, so define these
14 * without casts here, and define new symbols with casts inside the C
15 * section.
16 */
17#define ASM_STUB_CODE (UML_CONFIG_TOP_ADDR - 2 * UM_KERN_PAGE_SIZE)
18#define ASM_STUB_DATA (UML_CONFIG_TOP_ADDR - UM_KERN_PAGE_SIZE)
19#define ASM_STUB_START ASM_STUB_CODE
20
21/*
22 * This file is included by the assembly stubs, which just want the
23 * definitions above.
24 */
25#ifndef __ASSEMBLY__
26
27#define STUB_CODE ((unsigned long) ASM_STUB_CODE)
28#define STUB_DATA ((unsigned long) ASM_STUB_DATA)
29#define STUB_START ((unsigned long) ASM_STUB_START)
30
9#include "sysdep/ptrace.h" 31#include "sysdep/ptrace.h"
10 32
11struct cpu_task { 33struct cpu_task {
@@ -32,3 +54,5 @@ extern int linux_main(int argc, char **argv);
32extern void (*sig_info[])(int, struct uml_pt_regs *); 54extern void (*sig_info[])(int, struct uml_pt_regs *);
33 55
34#endif 56#endif
57
58#endif
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h
index 19c85f330fc1..8c097b87fca7 100644
--- a/arch/um/include/sysdep-i386/stub.h
+++ b/arch/um/include/sysdep-i386/stub.h
@@ -9,6 +9,7 @@
9#include <sys/mman.h> 9#include <sys/mman.h>
10#include <asm/ptrace.h> 10#include <asm/ptrace.h>
11#include <asm/unistd.h> 11#include <asm/unistd.h>
12#include "as-layout.h"
12#include "stub-data.h" 13#include "stub-data.h"
13#include "kern_constants.h" 14#include "kern_constants.h"
14#include "uml-config.h" 15#include "uml-config.h"
@@ -89,12 +90,12 @@ static inline void remap_stack(int fd, unsigned long offset)
89{ 90{
90 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;" 91 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
91 "movl %7, %%ebx ; movl %%eax, (%%ebx)" 92 "movl %7, %%ebx ; movl %%eax, (%%ebx)"
92 : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA), 93 : : "g" (STUB_MMAP_NR), "b" (STUB_DATA),
93 "c" (UM_KERN_PAGE_SIZE), 94 "c" (UM_KERN_PAGE_SIZE),
94 "d" (PROT_READ | PROT_WRITE), 95 "d" (PROT_READ | PROT_WRITE),
95 "S" (MAP_FIXED | MAP_SHARED), "D" (fd), 96 "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
96 "a" (offset), 97 "a" (offset),
97 "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err) 98 "i" (&((struct stub_data *) STUB_DATA)->err)
98 : "memory"); 99 : "memory");
99} 100}
100 101
diff --git a/arch/um/include/sysdep-x86_64/stub.h b/arch/um/include/sysdep-x86_64/stub.h
index 92e989f81761..655f9c2de3ac 100644
--- a/arch/um/include/sysdep-x86_64/stub.h
+++ b/arch/um/include/sysdep-x86_64/stub.h
@@ -9,6 +9,7 @@
9#include <sys/mman.h> 9#include <sys/mman.h>
10#include <asm/unistd.h> 10#include <asm/unistd.h>
11#include <sysdep/ptrace_user.h> 11#include <sysdep/ptrace_user.h>
12#include "as-layout.h"
12#include "stub-data.h" 13#include "stub-data.h"
13#include "kern_constants.h" 14#include "kern_constants.h"
14#include "uml-config.h" 15#include "uml-config.h"
@@ -94,13 +95,13 @@ static inline void remap_stack(long fd, unsigned long offset)
94{ 95{
95 __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; " 96 __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
96 "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; " 97 "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
97 "movq %%rax, (%%rbx)": 98 "movq %%rax, (%%rbx)":
98 : "a" (STUB_MMAP_NR), "D" (UML_CONFIG_STUB_DATA), 99 : "a" (STUB_MMAP_NR), "D" (STUB_DATA),
99 "S" (UM_KERN_PAGE_SIZE), 100 "S" (UM_KERN_PAGE_SIZE),
100 "d" (PROT_READ | PROT_WRITE), 101 "d" (PROT_READ | PROT_WRITE),
101 "g" (MAP_FIXED | MAP_SHARED), "g" (fd), 102 "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
102 "g" (offset), 103 "g" (offset),
103 "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err) 104 "i" (&((struct stub_data *) STUB_DATA)->err)
104 : __syscall_clobber, "r10", "r8", "r9" ); 105 : __syscall_clobber, "r10", "r8", "r9" );
105} 106}
106 107