aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /arch/um/kernel
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'arch/um/kernel')
-rw-r--r--arch/um/kernel/exec.c1
-rw-r--r--arch/um/kernel/exitcode.c43
-rw-r--r--arch/um/kernel/irq.c5
-rw-r--r--arch/um/kernel/mem.c2
-rw-r--r--arch/um/kernel/process.c33
-rw-r--r--arch/um/kernel/ptrace.c70
-rw-r--r--arch/um/kernel/reboot.c1
-rw-r--r--arch/um/kernel/skas/mmu.c1
-rw-r--r--arch/um/kernel/syscall.c73
9 files changed, 70 insertions, 159 deletions
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index fda30d21fb90..97974c1bdd12 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -8,6 +8,7 @@
8#include "linux/smp_lock.h" 8#include "linux/smp_lock.h"
9#include "linux/ptrace.h" 9#include "linux/ptrace.h"
10#include "linux/sched.h" 10#include "linux/sched.h"
11#include "linux/slab.h"
11#include "asm/current.h" 12#include "asm/current.h"
12#include "asm/processor.h" 13#include "asm/processor.h"
13#include "asm/uaccess.h" 14#include "asm/uaccess.h"
diff --git a/arch/um/kernel/exitcode.c b/arch/um/kernel/exitcode.c
index 6540d2c9fbb7..829df49dee99 100644
--- a/arch/um/kernel/exitcode.c
+++ b/arch/um/kernel/exitcode.c
@@ -6,7 +6,9 @@
6#include <linux/ctype.h> 6#include <linux/ctype.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/module.h>
9#include <linux/proc_fs.h> 10#include <linux/proc_fs.h>
11#include <linux/seq_file.h>
10#include <linux/types.h> 12#include <linux/types.h>
11#include <asm/uaccess.h> 13#include <asm/uaccess.h>
12 14
@@ -16,30 +18,26 @@
16 */ 18 */
17int uml_exitcode = 0; 19int uml_exitcode = 0;
18 20
19static int read_proc_exitcode(char *page, char **start, off_t off, 21static int exitcode_proc_show(struct seq_file *m, void *v)
20 int count, int *eof, void *data)
21{ 22{
22 int len, val; 23 int val;
23 24
24 /* 25 /*
25 * Save uml_exitcode in a local so that we don't need to guarantee 26 * Save uml_exitcode in a local so that we don't need to guarantee
26 * that sprintf accesses it atomically. 27 * that sprintf accesses it atomically.
27 */ 28 */
28 val = uml_exitcode; 29 val = uml_exitcode;
29 len = sprintf(page, "%d\n", val); 30 seq_printf(m, "%d\n", val);
30 len -= off; 31 return 0;
31 if (len <= off+count) 32}
32 *eof = 1; 33
33 *start = page + off; 34static int exitcode_proc_open(struct inode *inode, struct file *file)
34 if (len > count) 35{
35 len = count; 36 return single_open(file, exitcode_proc_show, NULL);
36 if (len < 0)
37 len = 0;
38 return len;
39} 37}
40 38
41static int write_proc_exitcode(struct file *file, const char __user *buffer, 39static ssize_t exitcode_proc_write(struct file *file,
42 unsigned long count, void *data) 40 const char __user *buffer, size_t count, loff_t *pos)
43{ 41{
44 char *end, buf[sizeof("nnnnn\0")]; 42 char *end, buf[sizeof("nnnnn\0")];
45 int tmp; 43 int tmp;
@@ -55,20 +53,25 @@ static int write_proc_exitcode(struct file *file, const char __user *buffer,
55 return count; 53 return count;
56} 54}
57 55
56static const struct file_operations exitcode_proc_fops = {
57 .owner = THIS_MODULE,
58 .open = exitcode_proc_open,
59 .read = seq_read,
60 .llseek = seq_lseek,
61 .release = single_release,
62 .write = exitcode_proc_write,
63};
64
58static int make_proc_exitcode(void) 65static int make_proc_exitcode(void)
59{ 66{
60 struct proc_dir_entry *ent; 67 struct proc_dir_entry *ent;
61 68
62 ent = create_proc_entry("exitcode", 0600, NULL); 69 ent = proc_create("exitcode", 0600, NULL, &exitcode_proc_fops);
63 if (ent == NULL) { 70 if (ent == NULL) {
64 printk(KERN_WARNING "make_proc_exitcode : Failed to register " 71 printk(KERN_WARNING "make_proc_exitcode : Failed to register "
65 "/proc/exitcode\n"); 72 "/proc/exitcode\n");
66 return 0; 73 return 0;
67 } 74 }
68
69 ent->read_proc = read_proc_exitcode;
70 ent->write_proc = write_proc_exitcode;
71
72 return 0; 75 return 0;
73} 76}
74 77
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 039270b9b73b..a3f0b04d7101 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -12,6 +12,7 @@
12#include "linux/module.h" 12#include "linux/module.h"
13#include "linux/sched.h" 13#include "linux/sched.h"
14#include "linux/seq_file.h" 14#include "linux/seq_file.h"
15#include "linux/slab.h"
15#include "as-layout.h" 16#include "as-layout.h"
16#include "kern_util.h" 17#include "kern_util.h"
17#include "os.h" 18#include "os.h"
@@ -34,7 +35,7 @@ int show_interrupts(struct seq_file *p, void *v)
34 } 35 }
35 36
36 if (i < NR_IRQS) { 37 if (i < NR_IRQS) {
37 spin_lock_irqsave(&irq_desc[i].lock, flags); 38 raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
38 action = irq_desc[i].action; 39 action = irq_desc[i].action;
39 if (!action) 40 if (!action)
40 goto skip; 41 goto skip;
@@ -53,7 +54,7 @@ int show_interrupts(struct seq_file *p, void *v)
53 54
54 seq_putc(p, '\n'); 55 seq_putc(p, '\n');
55skip: 56skip:
56 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 57 raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
57 } else if (i == NR_IRQS) 58 } else if (i == NR_IRQS)
58 seq_putc(p, '\n'); 59 seq_putc(p, '\n');
59 60
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index a5d5e70cf6f5..8137ccc9635b 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -5,10 +5,10 @@
5 5
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7#include <linux/bootmem.h> 7#include <linux/bootmem.h>
8#include <linux/gfp.h>
9#include <linux/highmem.h> 8#include <linux/highmem.h>
10#include <linux/mm.h> 9#include <linux/mm.h>
11#include <linux/swap.h> 10#include <linux/swap.h>
11#include <linux/slab.h>
12#include <asm/fixmap.h> 12#include <asm/fixmap.h>
13#include <asm/page.h> 13#include <asm/page.h>
14#include "as-layout.h" 14#include "as-layout.h"
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 4a28a1568d85..fab4371184f6 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -7,13 +7,15 @@
7#include <linux/stddef.h> 7#include <linux/stddef.h>
8#include <linux/err.h> 8#include <linux/err.h>
9#include <linux/hardirq.h> 9#include <linux/hardirq.h>
10#include <linux/gfp.h>
11#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/module.h>
12#include <linux/personality.h> 12#include <linux/personality.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/ptrace.h> 14#include <linux/ptrace.h>
15#include <linux/random.h> 15#include <linux/random.h>
16#include <linux/slab.h>
16#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/seq_file.h>
17#include <linux/tick.h> 19#include <linux/tick.h>
18#include <linux/threads.h> 20#include <linux/threads.h>
19#include <asm/current.h> 21#include <asm/current.h>
@@ -336,16 +338,19 @@ int get_using_sysemu(void)
336 return atomic_read(&using_sysemu); 338 return atomic_read(&using_sysemu);
337} 339}
338 340
339static int proc_read_sysemu(char *buf, char **start, off_t offset, int size,int *eof, void *data) 341static int sysemu_proc_show(struct seq_file *m, void *v)
340{ 342{
341 if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size) 343 seq_printf(m, "%d\n", get_using_sysemu());
342 /* No overflow */ 344 return 0;
343 *eof = 1; 345}
344 346
345 return strlen(buf); 347static int sysemu_proc_open(struct inode *inode, struct file *file)
348{
349 return single_open(file, sysemu_proc_show, NULL);
346} 350}
347 351
348static int proc_write_sysemu(struct file *file,const char __user *buf, unsigned long count,void *data) 352static ssize_t sysemu_proc_write(struct file *file, const char __user *buf,
353 size_t count, loff_t *pos)
349{ 354{
350 char tmp[2]; 355 char tmp[2];
351 356
@@ -358,13 +363,22 @@ static int proc_write_sysemu(struct file *file,const char __user *buf, unsigned
358 return count; 363 return count;
359} 364}
360 365
366static const struct file_operations sysemu_proc_fops = {
367 .owner = THIS_MODULE,
368 .open = sysemu_proc_open,
369 .read = seq_read,
370 .llseek = seq_lseek,
371 .release = single_release,
372 .write = sysemu_proc_write,
373};
374
361int __init make_proc_sysemu(void) 375int __init make_proc_sysemu(void)
362{ 376{
363 struct proc_dir_entry *ent; 377 struct proc_dir_entry *ent;
364 if (!sysemu_supported) 378 if (!sysemu_supported)
365 return 0; 379 return 0;
366 380
367 ent = create_proc_entry("sysemu", 0600, NULL); 381 ent = proc_create("sysemu", 0600, NULL, &sysemu_proc_fops);
368 382
369 if (ent == NULL) 383 if (ent == NULL)
370 { 384 {
@@ -372,9 +386,6 @@ int __init make_proc_sysemu(void)
372 return 0; 386 return 0;
373 } 387 }
374 388
375 ent->read_proc = proc_read_sysemu;
376 ent->write_proc = proc_write_sysemu;
377
378 return 0; 389 return 0;
379} 390}
380 391
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 8e3d69e4fcb5..484509948ee9 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -12,16 +12,25 @@
12#endif 12#endif
13#include "skas_ptrace.h" 13#include "skas_ptrace.h"
14 14
15static inline void set_singlestepping(struct task_struct *child, int on) 15
16
17void user_enable_single_step(struct task_struct *child)
16{ 18{
17 if (on) 19 child->ptrace |= PT_DTRACE;
18 child->ptrace |= PT_DTRACE;
19 else
20 child->ptrace &= ~PT_DTRACE;
21 child->thread.singlestep_syscall = 0; 20 child->thread.singlestep_syscall = 0;
22 21
23#ifdef SUBARCH_SET_SINGLESTEPPING 22#ifdef SUBARCH_SET_SINGLESTEPPING
24 SUBARCH_SET_SINGLESTEPPING(child, on); 23 SUBARCH_SET_SINGLESTEPPING(child, 1);
24#endif
25}
26
27void user_disable_single_step(struct task_struct *child)
28{
29 child->ptrace &= ~PT_DTRACE;
30 child->thread.singlestep_syscall = 0;
31
32#ifdef SUBARCH_SET_SINGLESTEPPING
33 SUBARCH_SET_SINGLESTEPPING(child, 0);
25#endif 34#endif
26} 35}
27 36
@@ -30,7 +39,7 @@ static inline void set_singlestepping(struct task_struct *child, int on)
30 */ 39 */
31void ptrace_disable(struct task_struct *child) 40void ptrace_disable(struct task_struct *child)
32{ 41{
33 set_singlestepping(child,0); 42 user_disable_single_step(child);
34} 43}
35 44
36extern int peek_user(struct task_struct * child, long addr, long data); 45extern int peek_user(struct task_struct * child, long addr, long data);
@@ -69,53 +78,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
69 ret = -EIO; 78 ret = -EIO;
70 break; 79 break;
71 80
72 /* continue and stop at next (return from) syscall */
73 case PTRACE_SYSCALL:
74 /* restart after signal. */
75 case PTRACE_CONT: {
76 ret = -EIO;
77 if (!valid_signal(data))
78 break;
79
80 set_singlestepping(child, 0);
81 if (request == PTRACE_SYSCALL)
82 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
83 else clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
84 child->exit_code = data;
85 wake_up_process(child);
86 ret = 0;
87 break;
88 }
89
90/*
91 * make the child exit. Best I can do is send it a sigkill.
92 * perhaps it should be put in the status that it wants to
93 * exit.
94 */
95 case PTRACE_KILL: {
96 ret = 0;
97 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
98 break;
99
100 set_singlestepping(child, 0);
101 child->exit_code = SIGKILL;
102 wake_up_process(child);
103 break;
104 }
105
106 case PTRACE_SINGLESTEP: { /* set the trap flag. */
107 ret = -EIO;
108 if (!valid_signal(data))
109 break;
110 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
111 set_singlestepping(child, 1);
112 child->exit_code = data;
113 /* give it a chance to run. */
114 wake_up_process(child);
115 ret = 0;
116 break;
117 }
118
119#ifdef PTRACE_GETREGS 81#ifdef PTRACE_GETREGS
120 case PTRACE_GETREGS: { /* Get all gp regs from the child. */ 82 case PTRACE_GETREGS: { /* Get all gp regs from the child. */
121 if (!access_ok(VERIFY_WRITE, p, MAX_REG_OFFSET)) { 83 if (!access_ok(VERIFY_WRITE, p, MAX_REG_OFFSET)) {
diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c
index 00197d3d21ec..869bec9f2516 100644
--- a/arch/um/kernel/reboot.c
+++ b/arch/um/kernel/reboot.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include "linux/sched.h" 6#include "linux/sched.h"
7#include "linux/slab.h"
7#include "kern_util.h" 8#include "kern_util.h"
8#include "os.h" 9#include "os.h"
9#include "skas.h" 10#include "skas.h"
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 8bfd1e905812..3d099f974785 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -5,6 +5,7 @@
5 5
6#include "linux/mm.h" 6#include "linux/mm.h"
7#include "linux/sched.h" 7#include "linux/sched.h"
8#include "linux/slab.h"
8#include "asm/pgalloc.h" 9#include "asm/pgalloc.h"
9#include "asm/pgtable.h" 10#include "asm/pgtable.h"
10#include "as-layout.h" 11#include "as-layout.h"
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index a4625c7b2bf9..4393173923f5 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -8,6 +8,7 @@
8#include "linux/mm.h" 8#include "linux/mm.h"
9#include "linux/sched.h" 9#include "linux/sched.h"
10#include "linux/utsname.h" 10#include "linux/utsname.h"
11#include "linux/syscalls.h"
11#include "asm/current.h" 12#include "asm/current.h"
12#include "asm/mman.h" 13#include "asm/mman.h"
13#include "asm/uaccess.h" 14#include "asm/uaccess.h"
@@ -37,31 +38,6 @@ long sys_vfork(void)
37 return ret; 38 return ret;
38} 39}
39 40
40/* common code for old and new mmaps */
41long sys_mmap2(unsigned long addr, unsigned long len,
42 unsigned long prot, unsigned long flags,
43 unsigned long fd, unsigned long pgoff)
44{
45 long error = -EBADF;
46 struct file * file = NULL;
47
48 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
49 if (!(flags & MAP_ANONYMOUS)) {
50 file = fget(fd);
51 if (!file)
52 goto out;
53 }
54
55 down_write(&current->mm->mmap_sem);
56 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
57 up_write(&current->mm->mmap_sem);
58
59 if (file)
60 fput(file);
61 out:
62 return error;
63}
64
65long old_mmap(unsigned long addr, unsigned long len, 41long old_mmap(unsigned long addr, unsigned long len,
66 unsigned long prot, unsigned long flags, 42 unsigned long prot, unsigned long flags,
67 unsigned long fd, unsigned long offset) 43 unsigned long fd, unsigned long offset)
@@ -70,56 +46,11 @@ long old_mmap(unsigned long addr, unsigned long len,
70 if (offset & ~PAGE_MASK) 46 if (offset & ~PAGE_MASK)
71 goto out; 47 goto out;
72 48
73 err = sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); 49 err = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
74 out: 50 out:
75 return err; 51 return err;
76} 52}
77 53
78long sys_uname(struct old_utsname __user * name)
79{
80 long err;
81 if (!name)
82 return -EFAULT;
83 down_read(&uts_sem);
84 err = copy_to_user(name, utsname(), sizeof (*name));
85 up_read(&uts_sem);
86 return err?-EFAULT:0;
87}
88
89long sys_olduname(struct oldold_utsname __user * name)
90{
91 long error;
92
93 if (!name)
94 return -EFAULT;
95 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
96 return -EFAULT;
97
98 down_read(&uts_sem);
99
100 error = __copy_to_user(&name->sysname, &utsname()->sysname,
101 __OLD_UTS_LEN);
102 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
103 error |= __copy_to_user(&name->nodename, &utsname()->nodename,
104 __OLD_UTS_LEN);
105 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
106 error |= __copy_to_user(&name->release, &utsname()->release,
107 __OLD_UTS_LEN);
108 error |= __put_user(0, name->release + __OLD_UTS_LEN);
109 error |= __copy_to_user(&name->version, &utsname()->version,
110 __OLD_UTS_LEN);
111 error |= __put_user(0, name->version + __OLD_UTS_LEN);
112 error |= __copy_to_user(&name->machine, &utsname()->machine,
113 __OLD_UTS_LEN);
114 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
115
116 up_read(&uts_sem);
117
118 error = error ? -EFAULT : 0;
119
120 return error;
121}
122
123int kernel_execve(const char *filename, char *const argv[], char *const envp[]) 54int kernel_execve(const char *filename, char *const argv[], char *const envp[])
124{ 55{
125 mm_segment_t fs; 56 mm_segment_t fs;