aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-06 17:51:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:13:02 -0400
commit1ffb9164f51094b7105ce9f81600b222ddf5b82c (patch)
treeb2efe2af99a2827692a7541058eaef9e938f1da6 /arch
parent6e21aec3fcf6c8862b755d45c0af45acdefff976 (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')
-rw-r--r--arch/um/drivers/net_user.c3
-rw-r--r--arch/um/drivers/slip_user.c3
-rw-r--r--arch/um/include/kern_util.h1
-rw-r--r--arch/um/kernel/process.c5
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c7
-rw-r--r--arch/um/os-Linux/helper.c5
-rw-r--r--arch/um/os-Linux/process.c2
-rw-r--r--arch/um/os-Linux/skas/process.c9
-rw-r--r--arch/um/os-Linux/tt.c3
-rw-r--r--arch/um/os-Linux/util.c11
10 files changed, 25 insertions, 24 deletions
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index b63a86046374..3503cff867c3 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -18,6 +18,7 @@
18#include "net_user.h" 18#include "net_user.h"
19#include "os.h" 19#include "os.h"
20#include "um_malloc.h" 20#include "um_malloc.h"
21#include "kern_constants.h"
21 22
22int tap_open_common(void *dev, char *gate_addr) 23int tap_open_common(void *dev, char *gate_addr)
23{ 24{
@@ -215,7 +216,7 @@ static void change(char *dev, char *what, unsigned char *addr,
215 sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1], 216 sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1],
216 netmask[2], netmask[3]); 217 netmask[2], netmask[3]);
217 218
218 output_len = page_size(); 219 output_len = UM_KERN_PAGE_SIZE;
219 output = um_kmalloc(output_len); 220 output = um_kmalloc(output_len);
220 if(output == NULL) 221 if(output == NULL)
221 printk("change : failed to allocate output buffer\n"); 222 printk("change : failed to allocate output buffer\n");
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
index 9f41cece0916..78f0e515da8f 100644
--- a/arch/um/drivers/slip_user.c
+++ b/arch/um/drivers/slip_user.c
@@ -15,6 +15,7 @@
15#include "slip_common.h" 15#include "slip_common.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
19static int slip_user_init(void *data, void *dev) 20static int slip_user_init(void *data, void *dev)
20{ 21{
@@ -89,7 +90,7 @@ static int slip_tramp(char **argv, int fd)
89 goto out_close; 90 goto out_close;
90 pid = err; 91 pid = err;
91 92
92 output_len = page_size(); 93 output_len = UM_KERN_PAGE_SIZE;
93 output = um_kmalloc(output_len); 94 output = um_kmalloc(output_len);
94 if(output == NULL){ 95 if(output == NULL){
95 printk("slip_tramp : failed to allocate output buffer\n"); 96 printk("slip_tramp : failed to allocate output buffer\n");
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 09810bc48e5b..ae434a9b400d 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -52,7 +52,6 @@ extern void set_tracing(void *t, int tracing);
52extern int is_tracing(void *task); 52extern int is_tracing(void *task);
53extern int segv_syscall(void); 53extern int segv_syscall(void);
54extern void kern_finish_exec(void *task, int new_pid, unsigned long stack); 54extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
55extern int page_size(void);
56extern unsigned long page_mask(void); 55extern unsigned long page_mask(void);
57extern int need_finish_fork(void); 56extern int need_finish_fork(void);
58extern void free_stack(unsigned long stack, int order); 57extern void free_stack(unsigned long stack, int order);
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index d6d3319b3670..9ac9944aa2c7 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -217,11 +217,6 @@ void cpu_idle(void)
217 CHOOSE_MODE(init_idle_tt(), init_idle_skas()); 217 CHOOSE_MODE(init_idle_tt(), init_idle_skas());
218} 218}
219 219
220int page_size(void)
221{
222 return PAGE_SIZE;
223}
224
225void *um_virt_to_phys(struct task_struct *task, unsigned long addr, 220void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
226 pte_t *pte_out) 221 pte_t *pte_out)
227{ 222{
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
19struct helper_data { 20struct 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
37int is_skas_winch(int pid, int fd, void *data) 38int 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
35int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, 36int 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
33void stack_protections(unsigned long address) 34void 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
41void task_protections(unsigned long address) 42void 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