Commit 1ffb9164f51094b7105ce9f81600b222ddf5b82c
Committed by
Linus Torvalds
1 parent
6e21aec3fc
Exists in
master
and in
20 other branches
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>
Showing 10 changed files with 25 additions and 24 deletions Side-by-side Diff
arch/um/drivers/net_user.c
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | #include "net_user.h" |
19 | 19 | #include "os.h" |
20 | 20 | #include "um_malloc.h" |
21 | +#include "kern_constants.h" | |
21 | 22 | |
22 | 23 | int tap_open_common(void *dev, char *gate_addr) |
23 | 24 | { |
... | ... | @@ -215,7 +216,7 @@ |
215 | 216 | sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1], |
216 | 217 | netmask[2], netmask[3]); |
217 | 218 | |
218 | - output_len = page_size(); | |
219 | + output_len = UM_KERN_PAGE_SIZE; | |
219 | 220 | output = um_kmalloc(output_len); |
220 | 221 | if(output == NULL) |
221 | 222 | printk("change : failed to allocate output buffer\n"); |
arch/um/drivers/slip_user.c
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | #include "slip_common.h" |
16 | 16 | #include "os.h" |
17 | 17 | #include "um_malloc.h" |
18 | +#include "kern_constants.h" | |
18 | 19 | |
19 | 20 | static int slip_user_init(void *data, void *dev) |
20 | 21 | { |
... | ... | @@ -89,7 +90,7 @@ |
89 | 90 | goto out_close; |
90 | 91 | pid = err; |
91 | 92 | |
92 | - output_len = page_size(); | |
93 | + output_len = UM_KERN_PAGE_SIZE; | |
93 | 94 | output = um_kmalloc(output_len); |
94 | 95 | if(output == NULL){ |
95 | 96 | printk("slip_tramp : failed to allocate output buffer\n"); |
arch/um/include/kern_util.h
... | ... | @@ -52,7 +52,6 @@ |
52 | 52 | extern int is_tracing(void *task); |
53 | 53 | extern int segv_syscall(void); |
54 | 54 | extern void kern_finish_exec(void *task, int new_pid, unsigned long stack); |
55 | -extern int page_size(void); | |
56 | 55 | extern unsigned long page_mask(void); |
57 | 56 | extern int need_finish_fork(void); |
58 | 57 | extern void free_stack(unsigned long stack, int order); |
arch/um/kernel/process.c
arch/um/os-Linux/drivers/ethertap_user.c
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | #include "etap.h" |
21 | 21 | #include "os.h" |
22 | 22 | #include "um_malloc.h" |
23 | +#include "kern_constants.h" | |
23 | 24 | |
24 | 25 | #define MAX_PACKET ETH_MAX_PACKET |
25 | 26 | |
26 | 27 | |
... | ... | @@ -50,10 +51,10 @@ |
50 | 51 | n = os_write_file(fd, &change, sizeof(change)); |
51 | 52 | if(n != sizeof(change)) |
52 | 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 | 55 | if(output == NULL) |
55 | 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 | 58 | if(output != NULL){ |
58 | 59 | printk("%s", output); |
59 | 60 | kfree(output); |
... | ... | @@ -159,7 +160,7 @@ |
159 | 160 | |
160 | 161 | err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], |
161 | 162 | control_fds[1], data_fds[0], data_fds[1]); |
162 | - output_len = page_size(); | |
163 | + output_len = UM_KERN_PAGE_SIZE; | |
163 | 164 | output = um_kmalloc(output_len); |
164 | 165 | read_output(control_fds[0], output, output_len); |
165 | 166 |
arch/um/os-Linux/helper.c
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | #include "kern_util.h" |
16 | 16 | #include "os.h" |
17 | 17 | #include "um_malloc.h" |
18 | +#include "kern_constants.h" | |
18 | 19 | |
19 | 20 | struct helper_data { |
20 | 21 | void (*pre_exec)(void*); |
... | ... | @@ -69,7 +70,7 @@ |
69 | 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 | 74 | data.pre_exec = pre_exec; |
74 | 75 | data.pre_data = pre_data; |
75 | 76 | data.argv = argv; |
... | ... | @@ -123,7 +124,7 @@ |
123 | 124 | if (stack == 0) |
124 | 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 | 128 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
128 | 129 | if (pid < 0) { |
129 | 130 | err = -errno; |
arch/um/os-Linux/process.c
arch/um/os-Linux/skas/process.c
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | #include "uml-config.h" |
34 | 34 | #include "process.h" |
35 | 35 | #include "longjmp.h" |
36 | +#include "kern_constants.h" | |
36 | 37 | |
37 | 38 | int is_skas_winch(int pid, int fd, void *data) |
38 | 39 | { |
... | ... | @@ -171,7 +172,7 @@ |
171 | 172 | int fd; |
172 | 173 | __u64 offset; |
173 | 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 | 176 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); |
176 | 177 | if(addr == MAP_FAILED){ |
177 | 178 | printk("mapping mmap stub failed, errno = %d\n", |
... | ... | @@ -181,8 +182,8 @@ |
181 | 182 | |
182 | 183 | if(stack != NULL){ |
183 | 184 | fd = phys_mapping(to_phys(stack), &offset); |
184 | - addr = mmap((void *) UML_CONFIG_STUB_DATA, page_size(), | |
185 | - PROT_READ | PROT_WRITE, | |
185 | + addr = mmap((void *) UML_CONFIG_STUB_DATA, | |
186 | + UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, | |
186 | 187 | MAP_FIXED | MAP_SHARED, fd, offset); |
187 | 188 | if(addr == MAP_FAILED){ |
188 | 189 | printk("mapping segfault stack failed, " |
... | ... | @@ -198,7 +199,7 @@ |
198 | 199 | (unsigned long) stub_segv_handler - |
199 | 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 | 203 | sigemptyset(&sa.sa_mask); |
203 | 204 | sigaddset(&sa.sa_mask, SIGIO); |
204 | 205 | sigaddset(&sa.sa_mask, SIGWINCH); |
arch/um/os-Linux/tt.c
... | ... | @@ -31,6 +31,7 @@ |
31 | 31 | #include "choose-mode.h" |
32 | 32 | #include "mode.h" |
33 | 33 | #include "tempfile.h" |
34 | +#include "kern_constants.h" | |
34 | 35 | |
35 | 36 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, |
36 | 37 | int must_succeed) |
... | ... | @@ -142,7 +143,7 @@ |
142 | 143 | int sig = sigkill; |
143 | 144 | |
144 | 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 | 147 | t->flags, t->tramp_data); |
147 | 148 | if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL); |
148 | 149 | kill(os_getpid(), sig); |
arch/um/os-Linux/util.c
... | ... | @@ -29,28 +29,29 @@ |
29 | 29 | #include "uml-config.h" |
30 | 30 | #include "os.h" |
31 | 31 | #include "longjmp.h" |
32 | +#include "kern_constants.h" | |
32 | 33 | |
33 | 34 | void stack_protections(unsigned long address) |
34 | 35 | { |
35 | 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 | 39 | panic("protecting stack failed, errno = %d", errno); |
39 | 40 | } |
40 | 41 | |
41 | 42 | void task_protections(unsigned long address) |
42 | 43 | { |
43 | - unsigned long guard = address + page_size(); | |
44 | - unsigned long stack = guard + page_size(); | |
44 | + unsigned long guard = address + UM_KERN_PAGE_SIZE; | |
45 | + unsigned long stack = guard + UM_KERN_PAGE_SIZE; | |
45 | 46 | int prot = 0, pages; |
46 | 47 | |
47 | 48 | #ifdef notdef |
48 | - if(mprotect((void *) stack, page_size(), prot) < 0) | |
49 | + if(mprotect((void *) stack, UM_KERN_PAGE_SIZE, prot) < 0) | |
49 | 50 | panic("protecting guard page failed, errno = %d", errno); |
50 | 51 | #endif |
51 | 52 | pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2; |
52 | 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 | 55 | panic("protecting stack failed, errno = %d", errno); |
55 | 56 | } |
56 | 57 |