diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-06 17:51:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:13:02 -0400 |
commit | 1ffb9164f51094b7105ce9f81600b222ddf5b82c (patch) | |
tree | b2efe2af99a2827692a7541058eaef9e938f1da6 /arch/um/os-Linux | |
parent | 6e21aec3fcf6c8862b755d45c0af45acdefff976 (diff) |
uml: remove page_size()
userspace code used to have to call the kernelspace function page_size() in
order to determine the value of the kernel's PAGE_SIZE. Since this is now
available directly from kern_constants.h as UM_KERN_PAGE_SIZE, page_size() can
be deleted and calls changed to use the constant.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
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/drivers/ethertap_user.c | 7 | ||||
-rw-r--r-- | arch/um/os-Linux/helper.c | 5 | ||||
-rw-r--r-- | arch/um/os-Linux/process.c | 2 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 9 | ||||
-rw-r--r-- | arch/um/os-Linux/tt.c | 3 | ||||
-rw-r--r-- | arch/um/os-Linux/util.c | 11 |
6 files changed, 21 insertions, 16 deletions
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c index 4e38ccf35129..96e12ea8172c 100644 --- a/arch/um/os-Linux/drivers/ethertap_user.c +++ b/arch/um/os-Linux/drivers/ethertap_user.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "etap.h" | 20 | #include "etap.h" |
21 | #include "os.h" | 21 | #include "os.h" |
22 | #include "um_malloc.h" | 22 | #include "um_malloc.h" |
23 | #include "kern_constants.h" | ||
23 | 24 | ||
24 | #define MAX_PACKET ETH_MAX_PACKET | 25 | #define MAX_PACKET ETH_MAX_PACKET |
25 | 26 | ||
@@ -50,10 +51,10 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask, | |||
50 | n = os_write_file(fd, &change, sizeof(change)); | 51 | n = os_write_file(fd, &change, sizeof(change)); |
51 | if(n != sizeof(change)) | 52 | if(n != sizeof(change)) |
52 | printk("etap_change - request failed, err = %d\n", -n); | 53 | printk("etap_change - request failed, err = %d\n", -n); |
53 | output = um_kmalloc(page_size()); | 54 | output = um_kmalloc(UM_KERN_PAGE_SIZE); |
54 | if(output == NULL) | 55 | if(output == NULL) |
55 | printk("etap_change : Failed to allocate output buffer\n"); | 56 | printk("etap_change : Failed to allocate output buffer\n"); |
56 | read_output(fd, output, page_size()); | 57 | read_output(fd, output, UM_KERN_PAGE_SIZE); |
57 | if(output != NULL){ | 58 | if(output != NULL){ |
58 | printk("%s", output); | 59 | printk("%s", output); |
59 | kfree(output); | 60 | kfree(output); |
@@ -159,7 +160,7 @@ static int etap_open(void *data) | |||
159 | 160 | ||
160 | err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], | 161 | err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], |
161 | control_fds[1], data_fds[0], data_fds[1]); | 162 | control_fds[1], data_fds[0], data_fds[1]); |
162 | output_len = page_size(); | 163 | output_len = UM_KERN_PAGE_SIZE; |
163 | output = um_kmalloc(output_len); | 164 | output = um_kmalloc(output_len); |
164 | read_output(control_fds[0], output, output_len); | 165 | read_output(control_fds[0], output, output_len); |
165 | 166 | ||
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index f35220c72042..2184ddb9cb31 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "os.h" | 16 | #include "os.h" |
17 | #include "um_malloc.h" | 17 | #include "um_malloc.h" |
18 | #include "kern_constants.h" | ||
18 | 19 | ||
19 | struct helper_data { | 20 | struct helper_data { |
20 | void (*pre_exec)(void*); | 21 | void (*pre_exec)(void*); |
@@ -69,7 +70,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
69 | goto out_close; | 70 | goto out_close; |
70 | } | 71 | } |
71 | 72 | ||
72 | sp = stack + page_size() - sizeof(void *); | 73 | sp = stack + UM_KERN_PAGE_SIZE - sizeof(void *); |
73 | data.pre_exec = pre_exec; | 74 | data.pre_exec = pre_exec; |
74 | data.pre_data = pre_data; | 75 | data.pre_data = pre_data; |
75 | data.argv = argv; | 76 | data.argv = argv; |
@@ -123,7 +124,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
123 | if (stack == 0) | 124 | if (stack == 0) |
124 | return -ENOMEM; | 125 | return -ENOMEM; |
125 | 126 | ||
126 | sp = stack + (page_size() << stack_order) - sizeof(void *); | 127 | sp = stack + (UM_KERN_PAGE_SIZE << stack_order) - sizeof(void *); |
127 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); | 128 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
128 | if (pid < 0) { | 129 | if (pid < 0) { |
129 | err = -errno; | 130 | err = -errno; |
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 2babea30345e..37933d3f92b8 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -244,7 +244,7 @@ void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) | |||
244 | 244 | ||
245 | if(sig_stack != NULL){ | 245 | if(sig_stack != NULL){ |
246 | pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER); | 246 | pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER); |
247 | set_sigstack(sig_stack, pages * page_size()); | 247 | set_sigstack(sig_stack, pages * UM_KERN_PAGE_SIZE); |
248 | flags = SA_ONSTACK; | 248 | flags = SA_ONSTACK; |
249 | } | 249 | } |
250 | if(usr1_handler){ | 250 | if(usr1_handler){ |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 6554ff530128..29fd079c30b1 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "uml-config.h" | 33 | #include "uml-config.h" |
34 | #include "process.h" | 34 | #include "process.h" |
35 | #include "longjmp.h" | 35 | #include "longjmp.h" |
36 | #include "kern_constants.h" | ||
36 | 37 | ||
37 | int is_skas_winch(int pid, int fd, void *data) | 38 | int is_skas_winch(int pid, int fd, void *data) |
38 | { | 39 | { |
@@ -171,7 +172,7 @@ static int userspace_tramp(void *stack) | |||
171 | int fd; | 172 | int fd; |
172 | __u64 offset; | 173 | __u64 offset; |
173 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); | 174 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); |
174 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, page_size(), | 175 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, UM_KERN_PAGE_SIZE, |
175 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); | 176 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); |
176 | if(addr == MAP_FAILED){ | 177 | if(addr == MAP_FAILED){ |
177 | printk("mapping mmap stub failed, errno = %d\n", | 178 | printk("mapping mmap stub failed, errno = %d\n", |
@@ -181,8 +182,8 @@ static int userspace_tramp(void *stack) | |||
181 | 182 | ||
182 | if(stack != NULL){ | 183 | if(stack != NULL){ |
183 | fd = phys_mapping(to_phys(stack), &offset); | 184 | fd = phys_mapping(to_phys(stack), &offset); |
184 | addr = mmap((void *) UML_CONFIG_STUB_DATA, page_size(), | 185 | addr = mmap((void *) UML_CONFIG_STUB_DATA, |
185 | PROT_READ | PROT_WRITE, | 186 | UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
186 | MAP_FIXED | MAP_SHARED, fd, offset); | 187 | MAP_FIXED | MAP_SHARED, fd, offset); |
187 | if(addr == MAP_FAILED){ | 188 | if(addr == MAP_FAILED){ |
188 | printk("mapping segfault stack failed, " | 189 | printk("mapping segfault stack failed, " |
@@ -198,7 +199,7 @@ static int userspace_tramp(void *stack) | |||
198 | (unsigned long) stub_segv_handler - | 199 | (unsigned long) stub_segv_handler - |
199 | (unsigned long) &__syscall_stub_start; | 200 | (unsigned long) &__syscall_stub_start; |
200 | 201 | ||
201 | set_sigstack((void *) UML_CONFIG_STUB_DATA, page_size()); | 202 | set_sigstack((void *) UML_CONFIG_STUB_DATA, UM_KERN_PAGE_SIZE); |
202 | sigemptyset(&sa.sa_mask); | 203 | sigemptyset(&sa.sa_mask); |
203 | sigaddset(&sa.sa_mask, SIGIO); | 204 | sigaddset(&sa.sa_mask, SIGIO); |
204 | sigaddset(&sa.sa_mask, SIGWINCH); | 205 | sigaddset(&sa.sa_mask, SIGWINCH); |
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c index 00e14f446f16..bcf9359c4e9f 100644 --- a/arch/um/os-Linux/tt.c +++ b/arch/um/os-Linux/tt.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "choose-mode.h" | 31 | #include "choose-mode.h" |
32 | #include "mode.h" | 32 | #include "mode.h" |
33 | #include "tempfile.h" | 33 | #include "tempfile.h" |
34 | #include "kern_constants.h" | ||
34 | 35 | ||
35 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, | 36 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, |
36 | int must_succeed) | 37 | int must_succeed) |
@@ -142,7 +143,7 @@ int outer_tramp(void *arg) | |||
142 | int sig = sigkill; | 143 | int sig = sigkill; |
143 | 144 | ||
144 | t = arg; | 145 | t = arg; |
145 | t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2, | 146 | t->pid = clone(t->tramp, (void *) t->temp_stack + UM_KERN_PAGE_SIZE/2, |
146 | t->flags, t->tramp_data); | 147 | t->flags, t->tramp_data); |
147 | if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL); | 148 | if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL); |
148 | kill(os_getpid(), sig); | 149 | kill(os_getpid(), sig); |
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c index 0e771bb04dd2..48bc4927b996 100644 --- a/arch/um/os-Linux/util.c +++ b/arch/um/os-Linux/util.c | |||
@@ -29,28 +29,29 @@ | |||
29 | #include "uml-config.h" | 29 | #include "uml-config.h" |
30 | #include "os.h" | 30 | #include "os.h" |
31 | #include "longjmp.h" | 31 | #include "longjmp.h" |
32 | #include "kern_constants.h" | ||
32 | 33 | ||
33 | void stack_protections(unsigned long address) | 34 | void stack_protections(unsigned long address) |
34 | { | 35 | { |
35 | int prot = PROT_READ | PROT_WRITE | PROT_EXEC; | 36 | int prot = PROT_READ | PROT_WRITE | PROT_EXEC; |
36 | 37 | ||
37 | if(mprotect((void *) address, page_size(), prot) < 0) | 38 | if(mprotect((void *) address, UM_KERN_PAGE_SIZE, prot) < 0) |
38 | panic("protecting stack failed, errno = %d", errno); | 39 | panic("protecting stack failed, errno = %d", errno); |
39 | } | 40 | } |
40 | 41 | ||
41 | void task_protections(unsigned long address) | 42 | void task_protections(unsigned long address) |
42 | { | 43 | { |
43 | unsigned long guard = address + page_size(); | 44 | unsigned long guard = address + UM_KERN_PAGE_SIZE; |
44 | unsigned long stack = guard + page_size(); | 45 | unsigned long stack = guard + UM_KERN_PAGE_SIZE; |
45 | int prot = 0, pages; | 46 | int prot = 0, pages; |
46 | 47 | ||
47 | #ifdef notdef | 48 | #ifdef notdef |
48 | if(mprotect((void *) stack, page_size(), prot) < 0) | 49 | if(mprotect((void *) stack, UM_KERN_PAGE_SIZE, prot) < 0) |
49 | panic("protecting guard page failed, errno = %d", errno); | 50 | panic("protecting guard page failed, errno = %d", errno); |
50 | #endif | 51 | #endif |
51 | pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2; | 52 | pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2; |
52 | prot = PROT_READ | PROT_WRITE | PROT_EXEC; | 53 | prot = PROT_READ | PROT_WRITE | PROT_EXEC; |
53 | if(mprotect((void *) stack, pages * page_size(), prot) < 0) | 54 | if(mprotect((void *) stack, pages * UM_KERN_PAGE_SIZE, prot) < 0) |
54 | panic("protecting stack failed, errno = %d", errno); | 55 | panic("protecting stack failed, errno = %d", errno); |
55 | } | 56 | } |
56 | 57 | ||