diff options
Diffstat (limited to 'arch/um')
45 files changed, 413 insertions, 577 deletions
diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index b89989de364d..bd41e4286d0d 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug | |||
@@ -2,10 +2,6 @@ menu "Kernel hacking" | |||
2 | 2 | ||
3 | source "lib/Kconfig.debug" | 3 | source "lib/Kconfig.debug" |
4 | 4 | ||
5 | config FRAME_POINTER | ||
6 | bool | ||
7 | default y if DEBUG_INFO | ||
8 | |||
9 | config PT_PROXY | 5 | config PT_PROXY |
10 | bool "Enable ptrace proxy" | 6 | bool "Enable ptrace proxy" |
11 | depends on XTERM_CHAN && DEBUG_INFO && MODE_TT | 7 | depends on XTERM_CHAN && DEBUG_INFO && MODE_TT |
diff --git a/arch/um/Kconfig_char b/arch/um/Kconfig_char index 3e50fdb67626..62d87b71179b 100644 --- a/arch/um/Kconfig_char +++ b/arch/um/Kconfig_char | |||
@@ -204,5 +204,11 @@ config UML_RANDOM | |||
204 | http://sourceforge.net/projects/gkernel/). rngd periodically reads | 204 | http://sourceforge.net/projects/gkernel/). rngd periodically reads |
205 | /dev/hwrng and injects the entropy into /dev/random. | 205 | /dev/hwrng and injects the entropy into /dev/random. |
206 | 206 | ||
207 | config MMAPPER | ||
208 | tristate "iomem emulation driver" | ||
209 | help | ||
210 | This driver allows a host file to be used as emulated IO memory inside | ||
211 | UML. | ||
212 | |||
207 | endmenu | 213 | endmenu |
208 | 214 | ||
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index 323f72c64cd2..b2de9916c32c 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile | |||
@@ -22,8 +22,8 @@ obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o | |||
22 | obj-$(CONFIG_SSL) += ssl.o | 22 | obj-$(CONFIG_SSL) += ssl.o |
23 | obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o | 23 | obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o |
24 | 24 | ||
25 | obj-$(CONFIG_UML_NET_SLIP) += slip.o | 25 | obj-$(CONFIG_UML_NET_SLIP) += slip.o slip_common.o |
26 | obj-$(CONFIG_UML_NET_SLIRP) += slirp.o | 26 | obj-$(CONFIG_UML_NET_SLIRP) += slirp.o slip_common.o |
27 | obj-$(CONFIG_UML_NET_DAEMON) += daemon.o | 27 | obj-$(CONFIG_UML_NET_DAEMON) += daemon.o |
28 | obj-$(CONFIG_UML_NET_MCAST) += mcast.o | 28 | obj-$(CONFIG_UML_NET_MCAST) += mcast.o |
29 | #obj-$(CONFIG_UML_NET_PCAP) += pcap.o $(PCAP) | 29 | #obj-$(CONFIG_UML_NET_PCAP) += pcap.o $(PCAP) |
@@ -41,6 +41,6 @@ obj-$(CONFIG_UML_WATCHDOG) += harddog.o | |||
41 | obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o | 41 | obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o |
42 | obj-$(CONFIG_UML_RANDOM) += random.o | 42 | obj-$(CONFIG_UML_RANDOM) += random.o |
43 | 43 | ||
44 | USER_OBJS := fd.o null.o pty.o tty.o xterm.o | 44 | USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o |
45 | 45 | ||
46 | include arch/um/scripts/Makefile.rules | 46 | include arch/um/scripts/Makefile.rules |
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 583b8e137c33..5d3768156c92 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -143,22 +143,22 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out) | |||
143 | { | 143 | { |
144 | struct winch_data data; | 144 | struct winch_data data; |
145 | unsigned long stack; | 145 | unsigned long stack; |
146 | int fds[2], pid, n, err; | 146 | int fds[2], n, err; |
147 | char c; | 147 | char c; |
148 | 148 | ||
149 | err = os_pipe(fds, 1, 1); | 149 | err = os_pipe(fds, 1, 1); |
150 | if(err < 0){ | 150 | if(err < 0){ |
151 | printk("winch_tramp : os_pipe failed, err = %d\n", -err); | 151 | printk("winch_tramp : os_pipe failed, err = %d\n", -err); |
152 | return(err); | 152 | goto out; |
153 | } | 153 | } |
154 | 154 | ||
155 | data = ((struct winch_data) { .pty_fd = fd, | 155 | data = ((struct winch_data) { .pty_fd = fd, |
156 | .pipe_fd = fds[1], | 156 | .pipe_fd = fds[1], |
157 | .close_me = fds[0] } ); | 157 | .close_me = fds[0] } ); |
158 | pid = run_helper_thread(winch_thread, &data, 0, &stack, 0); | 158 | err = run_helper_thread(winch_thread, &data, 0, &stack, 0); |
159 | if(pid < 0){ | 159 | if(err < 0){ |
160 | printk("fork of winch_thread failed - errno = %d\n", errno); | 160 | printk("fork of winch_thread failed - errno = %d\n", errno); |
161 | return(pid); | 161 | goto out_close; |
162 | } | 162 | } |
163 | 163 | ||
164 | os_close_file(fds[1]); | 164 | os_close_file(fds[1]); |
@@ -168,14 +168,22 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out) | |||
168 | printk("winch_tramp : failed to read synchronization byte\n"); | 168 | printk("winch_tramp : failed to read synchronization byte\n"); |
169 | printk("read failed, err = %d\n", -n); | 169 | printk("read failed, err = %d\n", -n); |
170 | printk("fd %d will not support SIGWINCH\n", fd); | 170 | printk("fd %d will not support SIGWINCH\n", fd); |
171 | *fd_out = -1; | 171 | err = -EINVAL; |
172 | goto out_close1; | ||
172 | } | 173 | } |
173 | return(pid); | 174 | return err ; |
175 | |||
176 | out_close: | ||
177 | os_close_file(fds[1]); | ||
178 | out_close1: | ||
179 | os_close_file(fds[0]); | ||
180 | out: | ||
181 | return err; | ||
174 | } | 182 | } |
175 | 183 | ||
176 | void register_winch(int fd, struct tty_struct *tty) | 184 | void register_winch(int fd, struct tty_struct *tty) |
177 | { | 185 | { |
178 | int pid, thread, thread_fd; | 186 | int pid, thread, thread_fd = -1; |
179 | int count; | 187 | int count; |
180 | char c = 1; | 188 | char c = 1; |
181 | 189 | ||
@@ -186,7 +194,7 @@ void register_winch(int fd, struct tty_struct *tty) | |||
186 | if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, | 194 | if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, |
187 | tty) && (pid == -1)){ | 195 | tty) && (pid == -1)){ |
188 | thread = winch_tramp(fd, tty, &thread_fd); | 196 | thread = winch_tramp(fd, tty, &thread_fd); |
189 | if(fd != -1){ | 197 | if(thread > 0){ |
190 | register_winch_irq(thread_fd, fd, thread, tty); | 198 | register_winch_irq(thread_fd, fd, thread, tty); |
191 | 199 | ||
192 | count = os_write_file(thread_fd, &c, sizeof(c)); | 200 | count = os_write_file(thread_fd, &c, sizeof(c)); |
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c index a63231dffe05..a37a5ac13c22 100644 --- a/arch/um/drivers/mmapper_kern.c +++ b/arch/um/drivers/mmapper_kern.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/smp_lock.h> | 20 | #include <linux/smp_lock.h> |
21 | #include <linux/miscdevice.h> | ||
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
22 | #include <asm/irq.h> | 23 | #include <asm/irq.h> |
23 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
@@ -117,24 +118,39 @@ static struct file_operations mmapper_fops = { | |||
117 | .release = mmapper_release, | 118 | .release = mmapper_release, |
118 | }; | 119 | }; |
119 | 120 | ||
121 | static struct miscdevice mmapper_dev = { | ||
122 | .minor = MISC_DYNAMIC_MINOR, | ||
123 | .name = "mmapper", | ||
124 | .fops = &mmapper_fops | ||
125 | }; | ||
126 | |||
120 | static int __init mmapper_init(void) | 127 | static int __init mmapper_init(void) |
121 | { | 128 | { |
129 | int err; | ||
130 | |||
122 | printk(KERN_INFO "Mapper v0.1\n"); | 131 | printk(KERN_INFO "Mapper v0.1\n"); |
123 | 132 | ||
124 | v_buf = (char *) find_iomem("mmapper", &mmapper_size); | 133 | v_buf = (char *) find_iomem("mmapper", &mmapper_size); |
125 | if(mmapper_size == 0){ | 134 | if(mmapper_size == 0){ |
126 | printk(KERN_ERR "mmapper_init - find_iomem failed\n"); | 135 | printk(KERN_ERR "mmapper_init - find_iomem failed\n"); |
127 | return(0); | 136 | goto out; |
128 | } | 137 | } |
129 | 138 | ||
130 | p_buf = __pa(v_buf); | 139 | err = misc_register(&mmapper_dev); |
140 | if(err){ | ||
141 | printk(KERN_ERR "mmapper - misc_register failed, err = %d\n", | ||
142 | err); | ||
143 | goto out; | ||
144 | } | ||
131 | 145 | ||
132 | devfs_mk_cdev(MKDEV(30, 0), S_IFCHR|S_IRUGO|S_IWUGO, "mmapper"); | 146 | p_buf = __pa(v_buf); |
133 | return(0); | 147 | out: |
148 | return 0; | ||
134 | } | 149 | } |
135 | 150 | ||
136 | static void mmapper_exit(void) | 151 | static void mmapper_exit(void) |
137 | { | 152 | { |
153 | misc_deregister(&mmapper_dev); | ||
138 | } | 154 | } |
139 | 155 | ||
140 | module_init(mmapper_init); | 156 | module_init(mmapper_init); |
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c index 47229fe4a813..3730d4f12713 100644 --- a/arch/um/drivers/net_user.c +++ b/arch/um/drivers/net_user.c | |||
@@ -32,7 +32,7 @@ int tap_open_common(void *dev, char *gate_addr) | |||
32 | return(0); | 32 | return(0); |
33 | } | 33 | } |
34 | 34 | ||
35 | void tap_check_ips(char *gate_addr, char *eth_addr) | 35 | void tap_check_ips(char *gate_addr, unsigned char *eth_addr) |
36 | { | 36 | { |
37 | int tap_addr[4]; | 37 | int tap_addr[4]; |
38 | 38 | ||
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c index d43e9fab05a7..f9e22198e011 100644 --- a/arch/um/drivers/random.c +++ b/arch/um/drivers/random.c | |||
@@ -1,5 +1,10 @@ | |||
1 | /* Much of this ripped from hw_random.c */ | 1 | /* Copyright (C) 2005 Jeff Dike <jdike@addtoit.com> */ |
2 | 2 | /* Much of this ripped from drivers/char/hw_random.c, see there for other | |
3 | * copyright. | ||
4 | * | ||
5 | * This software may be used and distributed according to the terms | ||
6 | * of the GNU General Public License, incorporated herein by reference. | ||
7 | */ | ||
3 | #include <linux/module.h> | 8 | #include <linux/module.h> |
4 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
5 | #include <linux/miscdevice.h> | 10 | #include <linux/miscdevice.h> |
@@ -12,8 +17,6 @@ | |||
12 | */ | 17 | */ |
13 | #define RNG_VERSION "1.0.0" | 18 | #define RNG_VERSION "1.0.0" |
14 | #define RNG_MODULE_NAME "random" | 19 | #define RNG_MODULE_NAME "random" |
15 | #define RNG_DRIVER_NAME RNG_MODULE_NAME " virtual driver " RNG_VERSION | ||
16 | #define PFX RNG_MODULE_NAME ": " | ||
17 | 20 | ||
18 | #define RNG_MISCDEV_MINOR 183 /* official */ | 21 | #define RNG_MISCDEV_MINOR 183 /* official */ |
19 | 22 | ||
@@ -98,7 +101,7 @@ static int __init rng_init (void) | |||
98 | 101 | ||
99 | err = misc_register (&rng_miscdev); | 102 | err = misc_register (&rng_miscdev); |
100 | if (err) { | 103 | if (err) { |
101 | printk (KERN_ERR PFX "misc device register failed\n"); | 104 | printk (KERN_ERR RNG_MODULE_NAME ": misc device register failed\n"); |
102 | goto err_out_cleanup_hw; | 105 | goto err_out_cleanup_hw; |
103 | } | 106 | } |
104 | 107 | ||
@@ -120,3 +123,6 @@ static void __exit rng_cleanup (void) | |||
120 | 123 | ||
121 | module_init (rng_init); | 124 | module_init (rng_init); |
122 | module_exit (rng_cleanup); | 125 | module_exit (rng_cleanup); |
126 | |||
127 | MODULE_DESCRIPTION("UML Host Random Number Generator (RNG) driver"); | ||
128 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/um/drivers/slip.h b/arch/um/drivers/slip.h index 495f2f1b1420..bb0dab41c2e4 100644 --- a/arch/um/drivers/slip.h +++ b/arch/um/drivers/slip.h | |||
@@ -1,10 +1,7 @@ | |||
1 | #ifndef __UM_SLIP_H | 1 | #ifndef __UM_SLIP_H |
2 | #define __UM_SLIP_H | 2 | #define __UM_SLIP_H |
3 | 3 | ||
4 | #define BUF_SIZE 1500 | 4 | #include "slip_common.h" |
5 | /* two bytes each for a (pathological) max packet of escaped chars + * | ||
6 | * terminating END char + initial END char */ | ||
7 | #define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
8 | 5 | ||
9 | struct slip_data { | 6 | struct slip_data { |
10 | void *dev; | 7 | void *dev; |
@@ -12,28 +9,12 @@ struct slip_data { | |||
12 | char *addr; | 9 | char *addr; |
13 | char *gate_addr; | 10 | char *gate_addr; |
14 | int slave; | 11 | int slave; |
15 | char ibuf[ENC_BUF_SIZE]; | 12 | struct slip_proto slip; |
16 | char obuf[ENC_BUF_SIZE]; | ||
17 | int more; /* more data: do not read fd until ibuf has been drained */ | ||
18 | int pos; | ||
19 | int esc; | ||
20 | }; | 13 | }; |
21 | 14 | ||
22 | extern struct net_user_info slip_user_info; | 15 | extern struct net_user_info slip_user_info; |
23 | 16 | ||
24 | extern int set_umn_addr(int fd, char *addr, char *ptp_addr); | ||
25 | extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); | 17 | extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); |
26 | extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri); | 18 | extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri); |
27 | 19 | ||
28 | #endif | 20 | #endif |
29 | |||
30 | /* | ||
31 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
32 | * Emacs will notice this stuff at the end of the file and automatically | ||
33 | * adjust the settings for this buffer only. This must remain at the end | ||
34 | * of the file. | ||
35 | * --------------------------------------------------------------------------- | ||
36 | * Local variables: | ||
37 | * c-file-style: "linux" | ||
38 | * End: | ||
39 | */ | ||
diff --git a/arch/um/drivers/slip_common.c b/arch/um/drivers/slip_common.c new file mode 100644 index 000000000000..e89cfc68fc3e --- /dev/null +++ b/arch/um/drivers/slip_common.c | |||
@@ -0,0 +1,54 @@ | |||
1 | #include <string.h> | ||
2 | #include "slip_common.h" | ||
3 | #include "net_user.h" | ||
4 | |||
5 | int slip_proto_read(int fd, void *buf, int len, struct slip_proto *slip) | ||
6 | { | ||
7 | int i, n, size, start; | ||
8 | |||
9 | if(slip->more > 0){ | ||
10 | i = 0; | ||
11 | while(i < slip->more){ | ||
12 | size = slip_unesc(slip->ibuf[i++], slip->ibuf, | ||
13 | &slip->pos, &slip->esc); | ||
14 | if(size){ | ||
15 | memcpy(buf, slip->ibuf, size); | ||
16 | memmove(slip->ibuf, &slip->ibuf[i], | ||
17 | slip->more - i); | ||
18 | slip->more = slip->more - i; | ||
19 | return size; | ||
20 | } | ||
21 | } | ||
22 | slip->more = 0; | ||
23 | } | ||
24 | |||
25 | n = net_read(fd, &slip->ibuf[slip->pos], | ||
26 | sizeof(slip->ibuf) - slip->pos); | ||
27 | if(n <= 0) | ||
28 | return n; | ||
29 | |||
30 | start = slip->pos; | ||
31 | for(i = 0; i < n; i++){ | ||
32 | size = slip_unesc(slip->ibuf[start + i], slip->ibuf,&slip->pos, | ||
33 | &slip->esc); | ||
34 | if(size){ | ||
35 | memcpy(buf, slip->ibuf, size); | ||
36 | memmove(slip->ibuf, &slip->ibuf[start+i+1], | ||
37 | n - (i + 1)); | ||
38 | slip->more = n - (i + 1); | ||
39 | return size; | ||
40 | } | ||
41 | } | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | int slip_proto_write(int fd, void *buf, int len, struct slip_proto *slip) | ||
46 | { | ||
47 | int actual, n; | ||
48 | |||
49 | actual = slip_esc(buf, slip->obuf, len); | ||
50 | n = net_write(fd, slip->obuf, actual); | ||
51 | if(n < 0) | ||
52 | return n; | ||
53 | else return len; | ||
54 | } | ||
diff --git a/arch/um/drivers/slip_proto.h b/arch/um/drivers/slip_common.h index 7206361ace45..2ae76d8f1be1 100644 --- a/arch/um/drivers/slip_proto.h +++ b/arch/um/drivers/slip_common.h | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | #ifndef __UM_SLIP_COMMON_H |
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | #define __UM_SLIP_COMMON_H |
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | 3 | ||
6 | #ifndef __UM_SLIP_PROTO_H__ | 4 | #define BUF_SIZE 1500 |
7 | #define __UM_SLIP_PROTO_H__ | 5 | /* two bytes each for a (pathological) max packet of escaped chars + * |
6 | * terminating END char + initial END char */ | ||
7 | #define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
8 | 8 | ||
9 | /* SLIP protocol characters. */ | 9 | /* SLIP protocol characters. */ |
10 | #define SLIP_END 0300 /* indicates end of frame */ | 10 | #define SLIP_END 0300 /* indicates end of frame */ |
@@ -12,7 +12,8 @@ | |||
12 | #define SLIP_ESC_END 0334 /* ESC ESC_END means END 'data' */ | 12 | #define SLIP_ESC_END 0334 /* ESC ESC_END means END 'data' */ |
13 | #define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */ | 13 | #define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */ |
14 | 14 | ||
15 | static inline int slip_unesc(unsigned char c,char *buf,int *pos, int *esc) | 15 | static inline int slip_unesc(unsigned char c, unsigned char *buf, int *pos, |
16 | int *esc) | ||
16 | { | 17 | { |
17 | int ret; | 18 | int ret; |
18 | 19 | ||
@@ -79,15 +80,25 @@ static inline int slip_esc(unsigned char *s, unsigned char *d, int len) | |||
79 | return (ptr - d); | 80 | return (ptr - d); |
80 | } | 81 | } |
81 | 82 | ||
82 | #endif | 83 | struct slip_proto { |
84 | unsigned char ibuf[ENC_BUF_SIZE]; | ||
85 | unsigned char obuf[ENC_BUF_SIZE]; | ||
86 | int more; /* more data: do not read fd until ibuf has been drained */ | ||
87 | int pos; | ||
88 | int esc; | ||
89 | }; | ||
90 | |||
91 | #define SLIP_PROTO_INIT { \ | ||
92 | .ibuf = { '\0' }, \ | ||
93 | .obuf = { '\0' }, \ | ||
94 | .more = 0, \ | ||
95 | .pos = 0, \ | ||
96 | .esc = 0 \ | ||
97 | } | ||
83 | 98 | ||
84 | /* | 99 | extern int slip_proto_read(int fd, void *buf, int len, |
85 | * Overrides for Emacs so that we follow Linus's tabbing style. | 100 | struct slip_proto *slip); |
86 | * Emacs will notice this stuff at the end of the file and automatically | 101 | extern int slip_proto_write(int fd, void *buf, int len, |
87 | * adjust the settings for this buffer only. This must remain at the end | 102 | struct slip_proto *slip); |
88 | * of the file. | 103 | |
89 | * --------------------------------------------------------------------------- | 104 | #endif |
90 | * Local variables: | ||
91 | * c-file-style: "linux" | ||
92 | * End: | ||
93 | */ | ||
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c index 0886eedba213..9a6f5c85f902 100644 --- a/arch/um/drivers/slip_kern.c +++ b/arch/um/drivers/slip_kern.c | |||
@@ -26,16 +26,16 @@ void slip_init(struct net_device *dev, void *data) | |||
26 | .addr = NULL, | 26 | .addr = NULL, |
27 | .gate_addr = init->gate_addr, | 27 | .gate_addr = init->gate_addr, |
28 | .slave = -1, | 28 | .slave = -1, |
29 | .ibuf = { '\0' }, | 29 | .slip = SLIP_PROTO_INIT, |
30 | .obuf = { '\0' }, | ||
31 | .pos = 0, | ||
32 | .esc = 0, | ||
33 | .dev = dev }); | 30 | .dev = dev }); |
34 | 31 | ||
35 | dev->init = NULL; | 32 | dev->init = NULL; |
33 | dev->header_cache_update = NULL; | ||
34 | dev->hard_header_cache = NULL; | ||
35 | dev->hard_header = NULL; | ||
36 | dev->hard_header_len = 0; | 36 | dev->hard_header_len = 0; |
37 | dev->addr_len = 4; | 37 | dev->addr_len = 0; |
38 | dev->type = ARPHRD_ETHER; | 38 | dev->type = ARPHRD_SLIP; |
39 | dev->tx_queue_len = 256; | 39 | dev->tx_queue_len = 256; |
40 | dev->flags = IFF_NOARP; | 40 | dev->flags = IFF_NOARP; |
41 | printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr); | 41 | printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr); |
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c index d94846b1b4cf..71af444e591f 100644 --- a/arch/um/drivers/slip_user.c +++ b/arch/um/drivers/slip_user.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "user.h" | 13 | #include "user.h" |
14 | #include "net_user.h" | 14 | #include "net_user.h" |
15 | #include "slip.h" | 15 | #include "slip.h" |
16 | #include "slip_proto.h" | 16 | #include "slip_common.h" |
17 | #include "helper.h" | 17 | #include "helper.h" |
18 | #include "os.h" | 18 | #include "os.h" |
19 | 19 | ||
@@ -77,41 +77,51 @@ static int slip_tramp(char **argv, int fd) | |||
77 | err = os_pipe(fds, 1, 0); | 77 | err = os_pipe(fds, 1, 0); |
78 | if(err < 0){ | 78 | if(err < 0){ |
79 | printk("slip_tramp : pipe failed, err = %d\n", -err); | 79 | printk("slip_tramp : pipe failed, err = %d\n", -err); |
80 | return(err); | 80 | goto out; |
81 | } | 81 | } |
82 | 82 | ||
83 | err = 0; | 83 | err = 0; |
84 | pe_data.stdin = fd; | 84 | pe_data.stdin = fd; |
85 | pe_data.stdout = fds[1]; | 85 | pe_data.stdout = fds[1]; |
86 | pe_data.close_me = fds[0]; | 86 | pe_data.close_me = fds[0]; |
87 | pid = run_helper(slip_pre_exec, &pe_data, argv, NULL); | 87 | err = run_helper(slip_pre_exec, &pe_data, argv, NULL); |
88 | if(err < 0) | ||
89 | goto out_close; | ||
90 | pid = err; | ||
91 | |||
92 | output_len = page_size(); | ||
93 | output = um_kmalloc(output_len); | ||
94 | if(output == NULL){ | ||
95 | printk("slip_tramp : failed to allocate output buffer\n"); | ||
96 | os_kill_process(pid, 1); | ||
97 | err = -ENOMEM; | ||
98 | goto out_free; | ||
99 | } | ||
88 | 100 | ||
89 | if(pid < 0) err = pid; | 101 | os_close_file(fds[1]); |
90 | else { | 102 | read_output(fds[0], output, output_len); |
91 | output_len = page_size(); | 103 | printk("%s", output); |
92 | output = um_kmalloc(output_len); | 104 | |
93 | if(output == NULL) | 105 | CATCH_EINTR(err = waitpid(pid, &status, 0)); |
94 | printk("slip_tramp : failed to allocate output " | 106 | if(err < 0) |
95 | "buffer\n"); | 107 | err = errno; |
96 | 108 | else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){ | |
97 | os_close_file(fds[1]); | 109 | printk("'%s' didn't exit with status 0\n", argv[0]); |
98 | read_output(fds[0], output, output_len); | 110 | err = -EINVAL; |
99 | if(output != NULL){ | ||
100 | printk("%s", output); | ||
101 | kfree(output); | ||
102 | } | ||
103 | CATCH_EINTR(err = waitpid(pid, &status, 0)); | ||
104 | if(err < 0) | ||
105 | err = errno; | ||
106 | else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){ | ||
107 | printk("'%s' didn't exit with status 0\n", argv[0]); | ||
108 | err = -EINVAL; | ||
109 | } | ||
110 | } | 111 | } |
112 | else err = 0; | ||
111 | 113 | ||
112 | os_close_file(fds[0]); | 114 | os_close_file(fds[0]); |
113 | 115 | ||
114 | return(err); | 116 | out_free: |
117 | kfree(output); | ||
118 | return err; | ||
119 | |||
120 | out_close: | ||
121 | os_close_file(fds[0]); | ||
122 | os_close_file(fds[1]); | ||
123 | out: | ||
124 | return err; | ||
115 | } | 125 | } |
116 | 126 | ||
117 | static int slip_open(void *data) | 127 | static int slip_open(void *data) |
@@ -123,21 +133,26 @@ static int slip_open(void *data) | |||
123 | NULL }; | 133 | NULL }; |
124 | int sfd, mfd, err; | 134 | int sfd, mfd, err; |
125 | 135 | ||
126 | mfd = get_pty(); | 136 | err = get_pty(); |
127 | if(mfd < 0){ | 137 | if(err < 0){ |
128 | printk("umn : Failed to open pty, err = %d\n", -mfd); | 138 | printk("slip-open : Failed to open pty, err = %d\n", -err); |
129 | return(mfd); | 139 | goto out; |
130 | } | 140 | } |
131 | sfd = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0); | 141 | mfd = err; |
132 | if(sfd < 0){ | 142 | |
133 | printk("Couldn't open tty for slip line, err = %d\n", -sfd); | 143 | err = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0); |
134 | os_close_file(mfd); | 144 | if(err < 0){ |
135 | return(sfd); | 145 | printk("Couldn't open tty for slip line, err = %d\n", -err); |
146 | goto out_close; | ||
136 | } | 147 | } |
137 | if(set_up_tty(sfd)) return(-1); | 148 | sfd = err; |
149 | |||
150 | if(set_up_tty(sfd)) | ||
151 | goto out_close2; | ||
152 | |||
138 | pri->slave = sfd; | 153 | pri->slave = sfd; |
139 | pri->pos = 0; | 154 | pri->slip.pos = 0; |
140 | pri->esc = 0; | 155 | pri->slip.esc = 0; |
141 | if(pri->gate_addr != NULL){ | 156 | if(pri->gate_addr != NULL){ |
142 | sprintf(version_buf, "%d", UML_NET_VERSION); | 157 | sprintf(version_buf, "%d", UML_NET_VERSION); |
143 | strcpy(gate_buf, pri->gate_addr); | 158 | strcpy(gate_buf, pri->gate_addr); |
@@ -146,12 +161,12 @@ static int slip_open(void *data) | |||
146 | 161 | ||
147 | if(err < 0){ | 162 | if(err < 0){ |
148 | printk("slip_tramp failed - err = %d\n", -err); | 163 | printk("slip_tramp failed - err = %d\n", -err); |
149 | return(err); | 164 | goto out_close2; |
150 | } | 165 | } |
151 | err = os_get_ifname(pri->slave, pri->name); | 166 | err = os_get_ifname(pri->slave, pri->name); |
152 | if(err < 0){ | 167 | if(err < 0){ |
153 | printk("get_ifname failed, err = %d\n", -err); | 168 | printk("get_ifname failed, err = %d\n", -err); |
154 | return(err); | 169 | goto out_close2; |
155 | } | 170 | } |
156 | iter_addresses(pri->dev, open_addr, pri->name); | 171 | iter_addresses(pri->dev, open_addr, pri->name); |
157 | } | 172 | } |
@@ -160,10 +175,16 @@ static int slip_open(void *data) | |||
160 | if(err < 0){ | 175 | if(err < 0){ |
161 | printk("Failed to set slip discipline encapsulation - " | 176 | printk("Failed to set slip discipline encapsulation - " |
162 | "err = %d\n", -err); | 177 | "err = %d\n", -err); |
163 | return(err); | 178 | goto out_close2; |
164 | } | 179 | } |
165 | } | 180 | } |
166 | return(mfd); | 181 | return(mfd); |
182 | out_close2: | ||
183 | os_close_file(sfd); | ||
184 | out_close: | ||
185 | os_close_file(mfd); | ||
186 | out: | ||
187 | return err; | ||
167 | } | 188 | } |
168 | 189 | ||
169 | static void slip_close(int fd, void *data) | 190 | static void slip_close(int fd, void *data) |
@@ -190,48 +211,12 @@ static void slip_close(int fd, void *data) | |||
190 | 211 | ||
191 | int slip_user_read(int fd, void *buf, int len, struct slip_data *pri) | 212 | int slip_user_read(int fd, void *buf, int len, struct slip_data *pri) |
192 | { | 213 | { |
193 | int i, n, size, start; | 214 | return slip_proto_read(fd, buf, len, &pri->slip); |
194 | |||
195 | if(pri->more>0) { | ||
196 | i = 0; | ||
197 | while(i < pri->more) { | ||
198 | size = slip_unesc(pri->ibuf[i++], | ||
199 | pri->ibuf, &pri->pos, &pri->esc); | ||
200 | if(size){ | ||
201 | memcpy(buf, pri->ibuf, size); | ||
202 | memmove(pri->ibuf, &pri->ibuf[i], pri->more-i); | ||
203 | pri->more=pri->more-i; | ||
204 | return(size); | ||
205 | } | ||
206 | } | ||
207 | pri->more=0; | ||
208 | } | ||
209 | |||
210 | n = net_read(fd, &pri->ibuf[pri->pos], sizeof(pri->ibuf) - pri->pos); | ||
211 | if(n <= 0) return(n); | ||
212 | |||
213 | start = pri->pos; | ||
214 | for(i = 0; i < n; i++){ | ||
215 | size = slip_unesc(pri->ibuf[start + i], | ||
216 | pri->ibuf, &pri->pos, &pri->esc); | ||
217 | if(size){ | ||
218 | memcpy(buf, pri->ibuf, size); | ||
219 | memmove(pri->ibuf, &pri->ibuf[start+i+1], n-(i+1)); | ||
220 | pri->more=n-(i+1); | ||
221 | return(size); | ||
222 | } | ||
223 | } | ||
224 | return(0); | ||
225 | } | 215 | } |
226 | 216 | ||
227 | int slip_user_write(int fd, void *buf, int len, struct slip_data *pri) | 217 | int slip_user_write(int fd, void *buf, int len, struct slip_data *pri) |
228 | { | 218 | { |
229 | int actual, n; | 219 | return slip_proto_write(fd, buf, len, &pri->slip); |
230 | |||
231 | actual = slip_esc(buf, pri->obuf, len); | ||
232 | n = net_write(fd, pri->obuf, actual); | ||
233 | if(n < 0) return(n); | ||
234 | else return(len); | ||
235 | } | 220 | } |
236 | 221 | ||
237 | static int slip_set_mtu(int mtu, void *data) | 222 | static int slip_set_mtu(int mtu, void *data) |
@@ -267,14 +252,3 @@ struct net_user_info slip_user_info = { | |||
267 | .delete_address = slip_del_addr, | 252 | .delete_address = slip_del_addr, |
268 | .max_packet = BUF_SIZE | 253 | .max_packet = BUF_SIZE |
269 | }; | 254 | }; |
270 | |||
271 | /* | ||
272 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
273 | * Emacs will notice this stuff at the end of the file and automatically | ||
274 | * adjust the settings for this buffer only. This must remain at the end | ||
275 | * of the file. | ||
276 | * --------------------------------------------------------------------------- | ||
277 | * Local variables: | ||
278 | * c-file-style: "linux" | ||
279 | * End: | ||
280 | */ | ||
diff --git a/arch/um/drivers/slirp.h b/arch/um/drivers/slirp.h index 04e407d1e44a..6cf88ab580c9 100644 --- a/arch/um/drivers/slirp.h +++ b/arch/um/drivers/slirp.h | |||
@@ -1,10 +1,7 @@ | |||
1 | #ifndef __UM_SLIRP_H | 1 | #ifndef __UM_SLIRP_H |
2 | #define __UM_SLIRP_H | 2 | #define __UM_SLIRP_H |
3 | 3 | ||
4 | #define BUF_SIZE 1500 | 4 | #include "slip_common.h" |
5 | /* two bytes each for a (pathological) max packet of escaped chars + * | ||
6 | * terminating END char + initial END char */ | ||
7 | #define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
8 | 5 | ||
9 | #define SLIRP_MAX_ARGS 100 | 6 | #define SLIRP_MAX_ARGS 100 |
10 | /* | 7 | /* |
@@ -24,28 +21,13 @@ struct slirp_data { | |||
24 | struct arg_list_dummy_wrapper argw; | 21 | struct arg_list_dummy_wrapper argw; |
25 | int pid; | 22 | int pid; |
26 | int slave; | 23 | int slave; |
27 | char ibuf[ENC_BUF_SIZE]; | 24 | struct slip_proto slip; |
28 | char obuf[ENC_BUF_SIZE]; | ||
29 | int more; /* more data: do not read fd until ibuf has been drained */ | ||
30 | int pos; | ||
31 | int esc; | ||
32 | }; | 25 | }; |
33 | 26 | ||
34 | extern struct net_user_info slirp_user_info; | 27 | extern struct net_user_info slirp_user_info; |
35 | 28 | ||
36 | extern int set_umn_addr(int fd, char *addr, char *ptp_addr); | ||
37 | extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri); | 29 | extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri); |
38 | extern int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri); | 30 | extern int slirp_user_write(int fd, void *buf, int len, |
31 | struct slirp_data *pri); | ||
39 | 32 | ||
40 | #endif | 33 | #endif |
41 | |||
42 | /* | ||
43 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
44 | * Emacs will notice this stuff at the end of the file and automatically | ||
45 | * adjust the settings for this buffer only. This must remain at the end | ||
46 | * of the file. | ||
47 | * --------------------------------------------------------------------------- | ||
48 | * Local variables: | ||
49 | * c-file-style: "linux" | ||
50 | * End: | ||
51 | */ | ||
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c index c9d6b52a831d..9864d27afdbe 100644 --- a/arch/um/drivers/slirp_kern.c +++ b/arch/um/drivers/slirp_kern.c | |||
@@ -25,10 +25,7 @@ void slirp_init(struct net_device *dev, void *data) | |||
25 | { .argw = init->argw, | 25 | { .argw = init->argw, |
26 | .pid = -1, | 26 | .pid = -1, |
27 | .slave = -1, | 27 | .slave = -1, |
28 | .ibuf = { '\0' }, | 28 | .slip = SLIP_PROTO_INIT, |
29 | .obuf = { '\0' }, | ||
30 | .pos = 0, | ||
31 | .esc = 0, | ||
32 | .dev = dev }); | 29 | .dev = dev }); |
33 | 30 | ||
34 | dev->init = NULL; | 31 | dev->init = NULL; |
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c index c322515c71cc..8d91f663d82c 100644 --- a/arch/um/drivers/slirp_user.c +++ b/arch/um/drivers/slirp_user.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "user.h" | 12 | #include "user.h" |
13 | #include "net_user.h" | 13 | #include "net_user.h" |
14 | #include "slirp.h" | 14 | #include "slirp.h" |
15 | #include "slip_proto.h" | 15 | #include "slip_common.h" |
16 | #include "helper.h" | 16 | #include "helper.h" |
17 | #include "os.h" | 17 | #include "os.h" |
18 | 18 | ||
@@ -48,47 +48,32 @@ static int slirp_tramp(char **argv, int fd) | |||
48 | return(pid); | 48 | return(pid); |
49 | } | 49 | } |
50 | 50 | ||
51 | /* XXX This is just a trivial wrapper around os_pipe */ | ||
52 | static int slirp_datachan(int *mfd, int *sfd) | ||
53 | { | ||
54 | int fds[2], err; | ||
55 | |||
56 | err = os_pipe(fds, 1, 1); | ||
57 | if(err < 0){ | ||
58 | printk("slirp_datachan: Failed to open pipe, err = %d\n", -err); | ||
59 | return(err); | ||
60 | } | ||
61 | |||
62 | *mfd = fds[0]; | ||
63 | *sfd = fds[1]; | ||
64 | return(0); | ||
65 | } | ||
66 | |||
67 | static int slirp_open(void *data) | 51 | static int slirp_open(void *data) |
68 | { | 52 | { |
69 | struct slirp_data *pri = data; | 53 | struct slirp_data *pri = data; |
70 | int sfd, mfd, pid, err; | 54 | int fds[2], pid, err; |
71 | 55 | ||
72 | err = slirp_datachan(&mfd, &sfd); | 56 | err = os_pipe(fds, 1, 1); |
73 | if(err) | 57 | if(err) |
74 | return(err); | 58 | return(err); |
75 | 59 | ||
76 | pid = slirp_tramp(pri->argw.argv, sfd); | 60 | err = slirp_tramp(pri->argw.argv, fds[1]); |
77 | 61 | if(err < 0){ | |
78 | if(pid < 0){ | 62 | printk("slirp_tramp failed - errno = %d\n", -err); |
79 | printk("slirp_tramp failed - errno = %d\n", -pid); | 63 | goto out; |
80 | os_close_file(sfd); | ||
81 | os_close_file(mfd); | ||
82 | return(pid); | ||
83 | } | 64 | } |
84 | 65 | pid = err; | |
85 | pri->slave = sfd; | 66 | |
86 | pri->pos = 0; | 67 | pri->slave = fds[1]; |
87 | pri->esc = 0; | 68 | pri->slip.pos = 0; |
88 | 69 | pri->slip.esc = 0; | |
89 | pri->pid = pid; | 70 | pri->pid = err; |
90 | 71 | ||
91 | return(mfd); | 72 | return(fds[0]); |
73 | out: | ||
74 | os_close_file(fds[0]); | ||
75 | os_close_file(fds[1]); | ||
76 | return err; | ||
92 | } | 77 | } |
93 | 78 | ||
94 | static void slirp_close(int fd, void *data) | 79 | static void slirp_close(int fd, void *data) |
@@ -129,48 +114,12 @@ static void slirp_close(int fd, void *data) | |||
129 | 114 | ||
130 | int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri) | 115 | int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri) |
131 | { | 116 | { |
132 | int i, n, size, start; | 117 | return slip_proto_read(fd, buf, len, &pri->slip); |
133 | |||
134 | if(pri->more>0) { | ||
135 | i = 0; | ||
136 | while(i < pri->more) { | ||
137 | size = slip_unesc(pri->ibuf[i++], | ||
138 | pri->ibuf,&pri->pos,&pri->esc); | ||
139 | if(size){ | ||
140 | memcpy(buf, pri->ibuf, size); | ||
141 | memmove(pri->ibuf, &pri->ibuf[i], pri->more-i); | ||
142 | pri->more=pri->more-i; | ||
143 | return(size); | ||
144 | } | ||
145 | } | ||
146 | pri->more=0; | ||
147 | } | ||
148 | |||
149 | n = net_read(fd, &pri->ibuf[pri->pos], sizeof(pri->ibuf) - pri->pos); | ||
150 | if(n <= 0) return(n); | ||
151 | |||
152 | start = pri->pos; | ||
153 | for(i = 0; i < n; i++){ | ||
154 | size = slip_unesc(pri->ibuf[start + i], | ||
155 | pri->ibuf,&pri->pos,&pri->esc); | ||
156 | if(size){ | ||
157 | memcpy(buf, pri->ibuf, size); | ||
158 | memmove(pri->ibuf, &pri->ibuf[start+i+1], n-(i+1)); | ||
159 | pri->more=n-(i+1); | ||
160 | return(size); | ||
161 | } | ||
162 | } | ||
163 | return(0); | ||
164 | } | 118 | } |
165 | 119 | ||
166 | int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri) | 120 | int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri) |
167 | { | 121 | { |
168 | int actual, n; | 122 | return slip_proto_write(fd, buf, len, &pri->slip); |
169 | |||
170 | actual = slip_esc(buf, pri->obuf, len); | ||
171 | n = net_write(fd, pri->obuf, actual); | ||
172 | if(n < 0) return(n); | ||
173 | else return(len); | ||
174 | } | 123 | } |
175 | 124 | ||
176 | static int slirp_set_mtu(int mtu, void *data) | 125 | static int slirp_set_mtu(int mtu, void *data) |
@@ -188,14 +137,3 @@ struct net_user_info slirp_user_info = { | |||
188 | .delete_address = NULL, | 137 | .delete_address = NULL, |
189 | .max_packet = BUF_SIZE | 138 | .max_packet = BUF_SIZE |
190 | }; | 139 | }; |
191 | |||
192 | /* | ||
193 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
194 | * Emacs will notice this stuff at the end of the file and automatically | ||
195 | * adjust the settings for this buffer only. This must remain at the end | ||
196 | * of the file. | ||
197 | * --------------------------------------------------------------------------- | ||
198 | * Local variables: | ||
199 | * c-file-style: "linux" | ||
200 | * End: | ||
201 | */ | ||
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index a2bac429f3d4..b32a77010fbe 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "init.h" | 22 | #include "init.h" |
23 | #include "irq_user.h" | 23 | #include "irq_user.h" |
24 | #include "mconsole_kern.h" | 24 | #include "mconsole_kern.h" |
25 | #include "2_5compat.h" | ||
26 | 25 | ||
27 | static int ssl_version = 1; | 26 | static int ssl_version = 1; |
28 | 27 | ||
diff --git a/arch/um/drivers/stderr_console.c b/arch/um/drivers/stderr_console.c index 98565b53d170..429ae8e6c7e5 100644 --- a/arch/um/drivers/stderr_console.c +++ b/arch/um/drivers/stderr_console.c | |||
@@ -22,9 +22,9 @@ static void stderr_console_write(struct console *console, const char *string, | |||
22 | } | 22 | } |
23 | 23 | ||
24 | static struct console stderr_console = { | 24 | static struct console stderr_console = { |
25 | .name "stderr", | 25 | .name = "stderr", |
26 | .write stderr_console_write, | 26 | .write = stderr_console_write, |
27 | .flags CON_PRINTBUFFER, | 27 | .flags = CON_PRINTBUFFER, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | static int __init stderr_console_init(void) | 30 | static int __init stderr_console_init(void) |
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 361d0be342b3..afbe1e71ed83 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "irq_user.h" | 28 | #include "irq_user.h" |
29 | #include "mconsole_kern.h" | 29 | #include "mconsole_kern.h" |
30 | #include "init.h" | 30 | #include "init.h" |
31 | #include "2_5compat.h" | ||
32 | 31 | ||
33 | #define MAX_TTYS (16) | 32 | #define MAX_TTYS (16) |
34 | 33 | ||
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 88f956c34fed..2a7f6892c55c 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include "irq_user.h" | 49 | #include "irq_user.h" |
50 | #include "irq_kern.h" | 50 | #include "irq_kern.h" |
51 | #include "ubd_user.h" | 51 | #include "ubd_user.h" |
52 | #include "2_5compat.h" | ||
53 | #include "os.h" | 52 | #include "os.h" |
54 | #include "mem.h" | 53 | #include "mem.h" |
55 | #include "mem_kern.h" | 54 | #include "mem_kern.h" |
@@ -440,9 +439,9 @@ static int udb_setup(char *str) | |||
440 | __setup("udb", udb_setup); | 439 | __setup("udb", udb_setup); |
441 | __uml_help(udb_setup, | 440 | __uml_help(udb_setup, |
442 | "udb\n" | 441 | "udb\n" |
443 | " This option is here solely to catch ubd -> udb typos, which can be\n\n" | 442 | " This option is here solely to catch ubd -> udb typos, which can be\n" |
444 | " to impossible to catch visually unless you specifically look for\n\n" | 443 | " to impossible to catch visually unless you specifically look for\n" |
445 | " them. The only result of any option starting with 'udb' is an error\n\n" | 444 | " them. The only result of any option starting with 'udb' is an error\n" |
446 | " in the boot output.\n\n" | 445 | " in the boot output.\n\n" |
447 | ); | 446 | ); |
448 | 447 | ||
diff --git a/arch/um/include/2_5compat.h b/arch/um/include/2_5compat.h deleted file mode 100644 index abdb015a4d71..000000000000 --- a/arch/um/include/2_5compat.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __2_5_COMPAT_H__ | ||
7 | #define __2_5_COMPAT_H__ | ||
8 | |||
9 | #define INIT_HARDSECT(arr, maj, sizes) | ||
10 | |||
11 | #define SET_PRI(task) do ; while(0) | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* | ||
16 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
17 | * Emacs will notice this stuff at the end of the file and automatically | ||
18 | * adjust the settings for this buffer only. This must remain at the end | ||
19 | * of the file. | ||
20 | * --------------------------------------------------------------------------- | ||
21 | * Local variables: | ||
22 | * c-file-style: "linux" | ||
23 | * End: | ||
24 | */ | ||
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h index 9fbe3083fdd8..cfa368e045a5 100644 --- a/arch/um/include/mconsole.h +++ b/arch/um/include/mconsole.h | |||
@@ -56,7 +56,7 @@ struct mc_request | |||
56 | int as_interrupt; | 56 | int as_interrupt; |
57 | 57 | ||
58 | int originating_fd; | 58 | int originating_fd; |
59 | int originlen; | 59 | unsigned int originlen; |
60 | unsigned char origin[128]; /* sockaddr_un */ | 60 | unsigned char origin[128]; /* sockaddr_un */ |
61 | 61 | ||
62 | struct mconsole_request request; | 62 | struct mconsole_request request; |
diff --git a/arch/um/include/net_user.h b/arch/um/include/net_user.h index 36807b796e9f..89885a77a771 100644 --- a/arch/um/include/net_user.h +++ b/arch/um/include/net_user.h | |||
@@ -35,7 +35,7 @@ extern void *get_output_buffer(int *len_out); | |||
35 | extern void free_output_buffer(void *buffer); | 35 | extern void free_output_buffer(void *buffer); |
36 | 36 | ||
37 | extern int tap_open_common(void *dev, char *gate_addr); | 37 | extern int tap_open_common(void *dev, char *gate_addr); |
38 | extern void tap_check_ips(char *gate_addr, char *eth_addr); | 38 | extern void tap_check_ips(char *gate_addr, unsigned char *eth_addr); |
39 | 39 | ||
40 | extern void read_output(int fd, char *output_out, int len); | 40 | extern void read_output(int fd, char *output_out, int len); |
41 | 41 | ||
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index d246d5a24609..881d2988d2d8 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -136,7 +136,7 @@ extern int os_seek_file(int fd, __u64 offset); | |||
136 | extern int os_open_file(char *file, struct openflags flags, int mode); | 136 | extern int os_open_file(char *file, struct openflags flags, int mode); |
137 | extern int os_read_file(int fd, void *buf, int len); | 137 | extern int os_read_file(int fd, void *buf, int len); |
138 | extern int os_write_file(int fd, const void *buf, int count); | 138 | extern int os_write_file(int fd, const void *buf, int count); |
139 | extern int os_file_size(char *file, long long *size_out); | 139 | extern int os_file_size(char *file, unsigned long long *size_out); |
140 | extern int os_file_modtime(char *file, unsigned long *modtime); | 140 | extern int os_file_modtime(char *file, unsigned long *modtime); |
141 | extern int os_pipe(int *fd, int stream, int close_on_exec); | 141 | extern int os_pipe(int *fd, int stream, int close_on_exec); |
142 | extern int os_set_fd_async(int fd, int owner); | 142 | extern int os_set_fd_async(int fd, int owner); |
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h index 6eaeb9919983..c8ee9559f3ab 100644 --- a/arch/um/include/sysdep-i386/ptrace.h +++ b/arch/um/include/sysdep-i386/ptrace.h | |||
@@ -8,6 +8,8 @@ | |||
8 | 8 | ||
9 | #include "uml-config.h" | 9 | #include "uml-config.h" |
10 | #include "user_constants.h" | 10 | #include "user_constants.h" |
11 | #include "sysdep/faultinfo.h" | ||
12 | #include "choose-mode.h" | ||
11 | 13 | ||
12 | #define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long)) | 14 | #define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long)) |
13 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) | 15 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) |
@@ -58,9 +60,6 @@ extern int sysemu_supported; | |||
58 | #define PTRACE_SYSEMU_SINGLESTEP 32 | 60 | #define PTRACE_SYSEMU_SINGLESTEP 32 |
59 | #endif | 61 | #endif |
60 | 62 | ||
61 | #include "sysdep/faultinfo.h" | ||
62 | #include "choose-mode.h" | ||
63 | |||
64 | union uml_pt_regs { | 63 | union uml_pt_regs { |
65 | #ifdef UML_CONFIG_MODE_TT | 64 | #ifdef UML_CONFIG_MODE_TT |
66 | struct tt_regs { | 65 | struct tt_regs { |
diff --git a/arch/um/include/sysrq.h b/arch/um/include/sysrq.h index 2ce9423460b3..c8d332b56b98 100644 --- a/arch/um/include/sysrq.h +++ b/arch/um/include/sysrq.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __UM_SYSRQ_H | 1 | #ifndef __UM_SYSRQ_H |
2 | #define __UM_SYSRQ_H | 2 | #define __UM_SYSRQ_H |
3 | 3 | ||
4 | extern void show_trace(unsigned long *stack); | 4 | struct task_struct; |
5 | extern void show_trace(struct task_struct* task, unsigned long *stack); | ||
5 | 6 | ||
6 | #endif | 7 | #endif |
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h index b8c5b8a95250..7b6a24dfd302 100644 --- a/arch/um/include/user_util.h +++ b/arch/um/include/user_util.h | |||
@@ -41,9 +41,6 @@ extern unsigned long highmem; | |||
41 | extern char host_info[]; | 41 | extern char host_info[]; |
42 | 42 | ||
43 | extern char saved_command_line[]; | 43 | extern char saved_command_line[]; |
44 | extern char command_line[]; | ||
45 | |||
46 | extern char *tempdir; | ||
47 | 44 | ||
48 | extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; | 45 | extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; |
49 | extern unsigned long _unprotected_end; | 46 | extern unsigned long _unprotected_end; |
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c index 49ddabe69be7..efd222ffe20e 100644 --- a/arch/um/kernel/exec_kern.c +++ b/arch/um/kernel/exec_kern.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include "kern.h" | 16 | #include "kern.h" |
17 | #include "irq_user.h" | 17 | #include "irq_user.h" |
18 | #include "tlb.h" | 18 | #include "tlb.h" |
19 | #include "2_5compat.h" | ||
20 | #include "os.h" | 19 | #include "os.h" |
21 | #include "time_user.h" | 20 | #include "time_user.h" |
22 | #include "choose-mode.h" | 21 | #include "choose-mode.h" |
diff --git a/arch/um/kernel/initrd_kern.c b/arch/um/kernel/initrd_kern.c deleted file mode 100644 index fc568af468b9..000000000000 --- a/arch/um/kernel/initrd_kern.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include "linux/init.h" | ||
7 | #include "linux/bootmem.h" | ||
8 | #include "linux/initrd.h" | ||
9 | #include "asm/types.h" | ||
10 | #include "user_util.h" | ||
11 | #include "kern_util.h" | ||
12 | #include "initrd.h" | ||
13 | #include "init.h" | ||
14 | #include "os.h" | ||
15 | |||
16 | /* Changed by uml_initrd_setup, which is a setup */ | ||
17 | static char *initrd __initdata = NULL; | ||
18 | |||
19 | static int __init read_initrd(void) | ||
20 | { | ||
21 | void *area; | ||
22 | long long size; | ||
23 | int err; | ||
24 | |||
25 | if(initrd == NULL) return 0; | ||
26 | err = os_file_size(initrd, &size); | ||
27 | if(err) return 0; | ||
28 | area = alloc_bootmem(size); | ||
29 | if(area == NULL) return 0; | ||
30 | if(load_initrd(initrd, area, size) == -1) return 0; | ||
31 | initrd_start = (unsigned long) area; | ||
32 | initrd_end = initrd_start + size; | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | __uml_postsetup(read_initrd); | ||
37 | |||
38 | static int __init uml_initrd_setup(char *line, int *add) | ||
39 | { | ||
40 | initrd = line; | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | __uml_setup("initrd=", uml_initrd_setup, | ||
45 | "initrd=<initrd image>\n" | ||
46 | " This is used to boot UML from an initrd image. The argument is the\n" | ||
47 | " name of the file containing the image.\n\n" | ||
48 | ); | ||
49 | |||
50 | /* | ||
51 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
52 | * Emacs will notice this stuff at the end of the file and automatically | ||
53 | * adjust the settings for this buffer only. This must remain at the end | ||
54 | * of the file. | ||
55 | * --------------------------------------------------------------------------- | ||
56 | * Local variables: | ||
57 | * c-file-style: "linux" | ||
58 | * End: | ||
59 | */ | ||
diff --git a/arch/um/kernel/initrd_user.c b/arch/um/kernel/initrd_user.c deleted file mode 100644 index cb90681e151c..000000000000 --- a/arch/um/kernel/initrd_user.c +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <unistd.h> | ||
7 | #include <sys/types.h> | ||
8 | #include <sys/stat.h> | ||
9 | #include <errno.h> | ||
10 | |||
11 | #include "user_util.h" | ||
12 | #include "kern_util.h" | ||
13 | #include "user.h" | ||
14 | #include "initrd.h" | ||
15 | #include "os.h" | ||
16 | |||
17 | int load_initrd(char *filename, void *buf, int size) | ||
18 | { | ||
19 | int fd, n; | ||
20 | |||
21 | fd = os_open_file(filename, of_read(OPENFLAGS()), 0); | ||
22 | if(fd < 0){ | ||
23 | printk("Opening '%s' failed - err = %d\n", filename, -fd); | ||
24 | return(-1); | ||
25 | } | ||
26 | n = os_read_file(fd, buf, size); | ||
27 | if(n != size){ | ||
28 | printk("Read of %d bytes from '%s' failed, err = %d\n", size, | ||
29 | filename, -n); | ||
30 | return(-1); | ||
31 | } | ||
32 | |||
33 | os_close_file(fd); | ||
34 | return(0); | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
39 | * Emacs will notice this stuff at the end of the file and automatically | ||
40 | * adjust the settings for this buffer only. This must remain at the end | ||
41 | * of the file. | ||
42 | * --------------------------------------------------------------------------- | ||
43 | * Local variables: | ||
44 | * c-file-style: "linux" | ||
45 | * End: | ||
46 | */ | ||
diff --git a/arch/um/kernel/main.c b/arch/um/kernel/main.c index a17c49703f9b..e59f58152678 100644 --- a/arch/um/kernel/main.c +++ b/arch/um/kernel/main.c | |||
@@ -24,8 +24,6 @@ | |||
24 | #include "mode.h" | 24 | #include "mode.h" |
25 | #include "choose-mode.h" | 25 | #include "choose-mode.h" |
26 | #include "uml-config.h" | 26 | #include "uml-config.h" |
27 | #include "irq_user.h" | ||
28 | #include "time_user.h" | ||
29 | #include "os.h" | 27 | #include "os.h" |
30 | 28 | ||
31 | /* Set in set_stklim, which is called from main and __wrap_malloc. | 29 | /* Set in set_stklim, which is called from main and __wrap_malloc. |
@@ -71,7 +69,7 @@ static __init void do_uml_initcalls(void) | |||
71 | 69 | ||
72 | static void last_ditch_exit(int sig) | 70 | static void last_ditch_exit(int sig) |
73 | { | 71 | { |
74 | CHOOSE_MODE(kmalloc_ok = 0, (void) 0); | 72 | kmalloc_ok = 0; |
75 | signal(SIGINT, SIG_DFL); | 73 | signal(SIGINT, SIG_DFL); |
76 | signal(SIGTERM, SIG_DFL); | 74 | signal(SIGTERM, SIG_DFL); |
77 | signal(SIGHUP, SIG_DFL); | 75 | signal(SIGHUP, SIG_DFL); |
@@ -87,7 +85,7 @@ int main(int argc, char **argv, char **envp) | |||
87 | { | 85 | { |
88 | char **new_argv; | 86 | char **new_argv; |
89 | sigset_t mask; | 87 | sigset_t mask; |
90 | int ret, i; | 88 | int ret, i, err; |
91 | 89 | ||
92 | /* Enable all signals except SIGIO - in some environments, we can | 90 | /* Enable all signals except SIGIO - in some environments, we can |
93 | * enter with some signals blocked | 91 | * enter with some signals blocked |
@@ -160,27 +158,29 @@ int main(int argc, char **argv, char **envp) | |||
160 | */ | 158 | */ |
161 | change_sig(SIGPROF, 0); | 159 | change_sig(SIGPROF, 0); |
162 | 160 | ||
163 | /* Reboot */ | 161 | /* This signal stuff used to be in the reboot case. However, |
164 | if(ret){ | 162 | * sometimes a SIGVTALRM can come in when we're halting (reproducably |
165 | int err; | 163 | * when writing out gcov information, presumably because that takes |
164 | * some time) and cause a segfault. | ||
165 | */ | ||
166 | 166 | ||
167 | printf("\n"); | 167 | /* stop timers and set SIG*ALRM to be ignored */ |
168 | disable_timer(); | ||
168 | 169 | ||
169 | /* stop timers and set SIG*ALRM to be ignored */ | 170 | /* disable SIGIO for the fds and set SIGIO to be ignored */ |
170 | disable_timer(); | 171 | err = deactivate_all_fds(); |
172 | if(err) | ||
173 | printf("deactivate_all_fds failed, errno = %d\n", -err); | ||
171 | 174 | ||
172 | /* disable SIGIO for the fds and set SIGIO to be ignored */ | 175 | /* Let any pending signals fire now. This ensures |
173 | err = deactivate_all_fds(); | 176 | * that they won't be delivered after the exec, when |
174 | if(err) | 177 | * they are definitely not expected. |
175 | printf("deactivate_all_fds failed, errno = %d\n", | 178 | */ |
176 | -err); | 179 | unblock_signals(); |
177 | |||
178 | /* Let any pending signals fire now. This ensures | ||
179 | * that they won't be delivered after the exec, when | ||
180 | * they are definitely not expected. | ||
181 | */ | ||
182 | unblock_signals(); | ||
183 | 180 | ||
181 | /* Reboot */ | ||
182 | if(ret){ | ||
183 | printf("\n"); | ||
184 | execvp(new_argv[0], new_argv); | 184 | execvp(new_argv[0], new_argv); |
185 | perror("Failed to exec kernel"); | 185 | perror("Failed to exec kernel"); |
186 | ret = 1; | 186 | ret = 1; |
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 51f8e5a8ac6a..1b5ef3e96c71 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include "init.h" | 30 | #include "init.h" |
31 | #include "os.h" | 31 | #include "os.h" |
32 | #include "uml-config.h" | 32 | #include "uml-config.h" |
33 | #include "ptrace_user.h" | ||
34 | #include "choose-mode.h" | 33 | #include "choose-mode.h" |
35 | #include "mode.h" | 34 | #include "mode.h" |
36 | #ifdef UML_CONFIG_MODE_SKAS | 35 | #ifdef UML_CONFIG_MODE_SKAS |
@@ -131,7 +130,7 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack, | |||
131 | return(arg.pid); | 130 | return(arg.pid); |
132 | } | 131 | } |
133 | 132 | ||
134 | static int ptrace_child(void *arg) | 133 | static int ptrace_child(void) |
135 | { | 134 | { |
136 | int ret; | 135 | int ret; |
137 | int pid = os_getpid(), ppid = getppid(); | 136 | int pid = os_getpid(), ppid = getppid(); |
@@ -160,20 +159,16 @@ static int ptrace_child(void *arg) | |||
160 | _exit(ret); | 159 | _exit(ret); |
161 | } | 160 | } |
162 | 161 | ||
163 | static int start_ptraced_child(void **stack_out) | 162 | static int start_ptraced_child(void) |
164 | { | 163 | { |
165 | void *stack; | ||
166 | unsigned long sp; | ||
167 | int pid, n, status; | 164 | int pid, n, status; |
168 | 165 | ||
169 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, | 166 | pid = fork(); |
170 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 167 | if(pid == 0) |
171 | if(stack == MAP_FAILED) | 168 | ptrace_child(); |
172 | panic("check_ptrace : mmap failed, errno = %d", errno); | 169 | |
173 | sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *); | ||
174 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); | ||
175 | if(pid < 0) | 170 | if(pid < 0) |
176 | panic("check_ptrace : clone failed, errno = %d", errno); | 171 | panic("check_ptrace : fork failed, errno = %d", errno); |
177 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 172 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
178 | if(n < 0) | 173 | if(n < 0) |
179 | panic("check_ptrace : wait failed, errno = %d", errno); | 174 | panic("check_ptrace : wait failed, errno = %d", errno); |
@@ -181,7 +176,6 @@ static int start_ptraced_child(void **stack_out) | |||
181 | panic("check_ptrace : expected SIGSTOP, got status = %d", | 176 | panic("check_ptrace : expected SIGSTOP, got status = %d", |
182 | status); | 177 | status); |
183 | 178 | ||
184 | *stack_out = stack; | ||
185 | return(pid); | 179 | return(pid); |
186 | } | 180 | } |
187 | 181 | ||
@@ -189,12 +183,12 @@ static int start_ptraced_child(void **stack_out) | |||
189 | * just avoid using sysemu, not panic, but only if SYSEMU features are broken. | 183 | * just avoid using sysemu, not panic, but only if SYSEMU features are broken. |
190 | * So only for SYSEMU features we test mustpanic, while normal host features | 184 | * So only for SYSEMU features we test mustpanic, while normal host features |
191 | * must work anyway!*/ | 185 | * must work anyway!*/ |
192 | static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic) | 186 | static int stop_ptraced_child(int pid, int exitcode, int mustexit) |
193 | { | 187 | { |
194 | int status, n, ret = 0; | 188 | int status, n, ret = 0; |
195 | 189 | ||
196 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) | 190 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) |
197 | panic("check_ptrace : ptrace failed, errno = %d", errno); | 191 | panic("stop_ptraced_child : ptrace failed, errno = %d", errno); |
198 | CATCH_EINTR(n = waitpid(pid, &status, 0)); | 192 | CATCH_EINTR(n = waitpid(pid, &status, 0)); |
199 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { | 193 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { |
200 | int exit_with = WEXITSTATUS(status); | 194 | int exit_with = WEXITSTATUS(status); |
@@ -205,15 +199,13 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic) | |||
205 | printk("check_ptrace : child exited with exitcode %d, while " | 199 | printk("check_ptrace : child exited with exitcode %d, while " |
206 | "expecting %d; status 0x%x", exit_with, | 200 | "expecting %d; status 0x%x", exit_with, |
207 | exitcode, status); | 201 | exitcode, status); |
208 | if (mustpanic) | 202 | if (mustexit) |
209 | panic("\n"); | 203 | panic("\n"); |
210 | else | 204 | else |
211 | printk("\n"); | 205 | printk("\n"); |
212 | ret = -1; | 206 | ret = -1; |
213 | } | 207 | } |
214 | 208 | ||
215 | if(munmap(stack, PAGE_SIZE) < 0) | ||
216 | panic("check_ptrace : munmap failed, errno = %d", errno); | ||
217 | return ret; | 209 | return ret; |
218 | } | 210 | } |
219 | 211 | ||
@@ -235,12 +227,11 @@ __uml_setup("nosysemu", nosysemu_cmd_param, | |||
235 | 227 | ||
236 | static void __init check_sysemu(void) | 228 | static void __init check_sysemu(void) |
237 | { | 229 | { |
238 | void *stack; | ||
239 | int pid, syscall, n, status, count=0; | 230 | int pid, syscall, n, status, count=0; |
240 | 231 | ||
241 | printk("Checking syscall emulation patch for ptrace..."); | 232 | printk("Checking syscall emulation patch for ptrace..."); |
242 | sysemu_supported = 0; | 233 | sysemu_supported = 0; |
243 | pid = start_ptraced_child(&stack); | 234 | pid = start_ptraced_child(); |
244 | 235 | ||
245 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) | 236 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) |
246 | goto fail; | 237 | goto fail; |
@@ -258,7 +249,7 @@ static void __init check_sysemu(void) | |||
258 | panic("check_sysemu : failed to modify system " | 249 | panic("check_sysemu : failed to modify system " |
259 | "call return, errno = %d", errno); | 250 | "call return, errno = %d", errno); |
260 | 251 | ||
261 | if (stop_ptraced_child(pid, stack, 0, 0) < 0) | 252 | if (stop_ptraced_child(pid, 0, 0) < 0) |
262 | goto fail_stopped; | 253 | goto fail_stopped; |
263 | 254 | ||
264 | sysemu_supported = 1; | 255 | sysemu_supported = 1; |
@@ -266,7 +257,7 @@ static void __init check_sysemu(void) | |||
266 | set_using_sysemu(!force_sysemu_disabled); | 257 | set_using_sysemu(!force_sysemu_disabled); |
267 | 258 | ||
268 | printk("Checking advanced syscall emulation patch for ptrace..."); | 259 | printk("Checking advanced syscall emulation patch for ptrace..."); |
269 | pid = start_ptraced_child(&stack); | 260 | pid = start_ptraced_child(); |
270 | while(1){ | 261 | while(1){ |
271 | count++; | 262 | count++; |
272 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) | 263 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) |
@@ -291,7 +282,7 @@ static void __init check_sysemu(void) | |||
291 | break; | 282 | break; |
292 | } | 283 | } |
293 | } | 284 | } |
294 | if (stop_ptraced_child(pid, stack, 0, 0) < 0) | 285 | if (stop_ptraced_child(pid, 0, 0) < 0) |
295 | goto fail_stopped; | 286 | goto fail_stopped; |
296 | 287 | ||
297 | sysemu_supported = 2; | 288 | sysemu_supported = 2; |
@@ -302,18 +293,17 @@ static void __init check_sysemu(void) | |||
302 | return; | 293 | return; |
303 | 294 | ||
304 | fail: | 295 | fail: |
305 | stop_ptraced_child(pid, stack, 1, 0); | 296 | stop_ptraced_child(pid, 1, 0); |
306 | fail_stopped: | 297 | fail_stopped: |
307 | printk("missing\n"); | 298 | printk("missing\n"); |
308 | } | 299 | } |
309 | 300 | ||
310 | void __init check_ptrace(void) | 301 | void __init check_ptrace(void) |
311 | { | 302 | { |
312 | void *stack; | ||
313 | int pid, syscall, n, status; | 303 | int pid, syscall, n, status; |
314 | 304 | ||
315 | printk("Checking that ptrace can change system call numbers..."); | 305 | printk("Checking that ptrace can change system call numbers..."); |
316 | pid = start_ptraced_child(&stack); | 306 | pid = start_ptraced_child(); |
317 | 307 | ||
318 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) | 308 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) |
319 | panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); | 309 | panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); |
@@ -340,7 +330,7 @@ void __init check_ptrace(void) | |||
340 | break; | 330 | break; |
341 | } | 331 | } |
342 | } | 332 | } |
343 | stop_ptraced_child(pid, stack, 0, 1); | 333 | stop_ptraced_child(pid, 0, 1); |
344 | printk("OK\n"); | 334 | printk("OK\n"); |
345 | check_sysemu(); | 335 | check_sysemu(); |
346 | } | 336 | } |
@@ -372,11 +362,10 @@ void forward_pending_sigio(int target) | |||
372 | static inline int check_skas3_ptrace_support(void) | 362 | static inline int check_skas3_ptrace_support(void) |
373 | { | 363 | { |
374 | struct ptrace_faultinfo fi; | 364 | struct ptrace_faultinfo fi; |
375 | void *stack; | ||
376 | int pid, n, ret = 1; | 365 | int pid, n, ret = 1; |
377 | 366 | ||
378 | printf("Checking for the skas3 patch in the host..."); | 367 | printf("Checking for the skas3 patch in the host..."); |
379 | pid = start_ptraced_child(&stack); | 368 | pid = start_ptraced_child(); |
380 | 369 | ||
381 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 370 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
382 | if (n < 0) { | 371 | if (n < 0) { |
@@ -391,7 +380,7 @@ static inline int check_skas3_ptrace_support(void) | |||
391 | } | 380 | } |
392 | 381 | ||
393 | init_registers(pid); | 382 | init_registers(pid); |
394 | stop_ptraced_child(pid, stack, 1, 1); | 383 | stop_ptraced_child(pid, 1, 1); |
395 | 384 | ||
396 | return(ret); | 385 | return(ret); |
397 | } | 386 | } |
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index c1adf7ba3fd1..804c6bbdf67c 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include "tlb.h" | 43 | #include "tlb.h" |
44 | #include "frame_kern.h" | 44 | #include "frame_kern.h" |
45 | #include "sigcontext.h" | 45 | #include "sigcontext.h" |
46 | #include "2_5compat.h" | ||
47 | #include "os.h" | 46 | #include "os.h" |
48 | #include "mode.h" | 47 | #include "mode.h" |
49 | #include "mode_kern.h" | 48 | #include "mode_kern.h" |
@@ -55,18 +54,6 @@ | |||
55 | */ | 54 | */ |
56 | struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } }; | 55 | struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } }; |
57 | 56 | ||
58 | struct task_struct *get_task(int pid, int require) | ||
59 | { | ||
60 | struct task_struct *ret; | ||
61 | |||
62 | read_lock(&tasklist_lock); | ||
63 | ret = find_task_by_pid(pid); | ||
64 | read_unlock(&tasklist_lock); | ||
65 | |||
66 | if(require && (ret == NULL)) panic("get_task couldn't find a task\n"); | ||
67 | return(ret); | ||
68 | } | ||
69 | |||
70 | int external_pid(void *t) | 57 | int external_pid(void *t) |
71 | { | 58 | { |
72 | struct task_struct *task = t ? t : current; | 59 | struct task_struct *task = t ? t : current; |
@@ -189,7 +176,6 @@ void default_idle(void) | |||
189 | 176 | ||
190 | while(1){ | 177 | while(1){ |
191 | /* endless idle loop with no priority at all */ | 178 | /* endless idle loop with no priority at all */ |
192 | SET_PRI(current); | ||
193 | 179 | ||
194 | /* | 180 | /* |
195 | * although we are an idle CPU, we do not want to | 181 | * although we are an idle CPU, we do not want to |
@@ -212,11 +198,6 @@ int page_size(void) | |||
212 | return(PAGE_SIZE); | 198 | return(PAGE_SIZE); |
213 | } | 199 | } |
214 | 200 | ||
215 | unsigned long page_mask(void) | ||
216 | { | ||
217 | return(PAGE_MASK); | ||
218 | } | ||
219 | |||
220 | void *um_virt_to_phys(struct task_struct *task, unsigned long addr, | 201 | void *um_virt_to_phys(struct task_struct *task, unsigned long addr, |
221 | pte_t *pte_out) | 202 | pte_t *pte_out) |
222 | { | 203 | { |
@@ -349,11 +330,6 @@ char *uml_strdup(char *string) | |||
349 | return(new); | 330 | return(new); |
350 | } | 331 | } |
351 | 332 | ||
352 | void *get_init_task(void) | ||
353 | { | ||
354 | return(&init_thread_union.thread_info.task); | ||
355 | } | ||
356 | |||
357 | int copy_to_user_proc(void __user *to, void *from, int size) | 333 | int copy_to_user_proc(void __user *to, void *from, int size) |
358 | { | 334 | { |
359 | return(copy_to_user(to, from, size)); | 335 | return(copy_to_user(to, from, size)); |
@@ -480,15 +456,3 @@ unsigned long arch_align_stack(unsigned long sp) | |||
480 | return sp & ~0xf; | 456 | return sp & ~0xf; |
481 | } | 457 | } |
482 | #endif | 458 | #endif |
483 | |||
484 | |||
485 | /* | ||
486 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
487 | * Emacs will notice this stuff at the end of the file and automatically | ||
488 | * adjust the settings for this buffer only. This must remain at the end | ||
489 | * of the file. | ||
490 | * --------------------------------------------------------------------------- | ||
491 | * Local variables: | ||
492 | * c-file-style: "linux" | ||
493 | * End: | ||
494 | */ | ||
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 2925e15324de..71af4d503899 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c | |||
@@ -322,11 +322,9 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit) | |||
322 | UPT_SYSCALL_ARG2(regs), | 322 | UPT_SYSCALL_ARG2(regs), |
323 | UPT_SYSCALL_ARG3(regs), | 323 | UPT_SYSCALL_ARG3(regs), |
324 | UPT_SYSCALL_ARG4(regs)); | 324 | UPT_SYSCALL_ARG4(regs)); |
325 | else { | 325 | else audit_syscall_exit(current, |
326 | int res = UPT_SYSCALL_RET(regs); | 326 | AUDITSC_RESULT(UPT_SYSCALL_RET(regs)), |
327 | audit_syscall_exit(current, AUDITSC_RESULT(res), | 327 | UPT_SYSCALL_RET(regs)); |
328 | res); | ||
329 | } | ||
330 | } | 328 | } |
331 | 329 | ||
332 | /* Fake a debug trap */ | 330 | /* Fake a debug trap */ |
@@ -356,14 +354,3 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit) | |||
356 | current->exit_code = 0; | 354 | current->exit_code = 0; |
357 | } | 355 | } |
358 | } | 356 | } |
359 | |||
360 | /* | ||
361 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
362 | * Emacs will notice this stuff at the end of the file and automatically | ||
363 | * adjust the settings for this buffer only. This must remain at the end | ||
364 | * of the file. | ||
365 | * --------------------------------------------------------------------------- | ||
366 | * Local variables: | ||
367 | * c-file-style: "linux" | ||
368 | * End: | ||
369 | */ | ||
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index ab5d3271da0b..fc71ef295782 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -68,8 +68,11 @@ void new_thread_handler(int sig) | |||
68 | * 0 if it just exits | 68 | * 0 if it just exits |
69 | */ | 69 | */ |
70 | n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf); | 70 | n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf); |
71 | if(n == 1) | 71 | if(n == 1){ |
72 | /* Handle any immediate reschedules or signals */ | ||
73 | interrupt_end(); | ||
72 | userspace(¤t->thread.regs.regs); | 74 | userspace(¤t->thread.regs.regs); |
75 | } | ||
73 | else do_exit(0); | 76 | else do_exit(0); |
74 | } | 77 | } |
75 | 78 | ||
@@ -96,6 +99,8 @@ void fork_handler(int sig) | |||
96 | schedule_tail(current->thread.prev_sched); | 99 | schedule_tail(current->thread.prev_sched); |
97 | current->thread.prev_sched = NULL; | 100 | current->thread.prev_sched = NULL; |
98 | 101 | ||
102 | /* Handle any immediate reschedules or signals */ | ||
103 | interrupt_end(); | ||
99 | userspace(¤t->thread.regs.regs); | 104 | userspace(¤t->thread.regs.regs); |
100 | } | 105 | } |
101 | 106 | ||
diff --git a/arch/um/kernel/sysrq.c b/arch/um/kernel/sysrq.c index e630438f9e73..f80850091e79 100644 --- a/arch/um/kernel/sysrq.c +++ b/arch/um/kernel/sysrq.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/config.h" | ||
6 | #include "linux/sched.h" | 7 | #include "linux/sched.h" |
7 | #include "linux/kernel.h" | 8 | #include "linux/kernel.h" |
8 | #include "linux/module.h" | 9 | #include "linux/module.h" |
@@ -12,14 +13,14 @@ | |||
12 | #include "sysrq.h" | 13 | #include "sysrq.h" |
13 | #include "user_util.h" | 14 | #include "user_util.h" |
14 | 15 | ||
15 | void show_trace(unsigned long * stack) | 16 | /* Catch non-i386 SUBARCH's. */ |
17 | #if !defined(CONFIG_UML_X86) || defined(CONFIG_64BIT) | ||
18 | void show_trace(struct task_struct *task, unsigned long * stack) | ||
16 | { | 19 | { |
17 | /* XXX: Copy the CONFIG_FRAME_POINTER stack-walking backtrace from | ||
18 | * arch/i386/kernel/traps.c, and then move this to sys-i386/sysrq.c.*/ | ||
19 | unsigned long addr; | 20 | unsigned long addr; |
20 | 21 | ||
21 | if (!stack) { | 22 | if (!stack) { |
22 | stack = (unsigned long*) &stack; | 23 | stack = (unsigned long*) &stack; |
23 | WARN_ON(1); | 24 | WARN_ON(1); |
24 | } | 25 | } |
25 | 26 | ||
@@ -35,6 +36,7 @@ void show_trace(unsigned long * stack) | |||
35 | } | 36 | } |
36 | printk("\n"); | 37 | printk("\n"); |
37 | } | 38 | } |
39 | #endif | ||
38 | 40 | ||
39 | /* | 41 | /* |
40 | * stack dumps generator - this is used by arch-independent code. | 42 | * stack dumps generator - this is used by arch-independent code. |
@@ -44,7 +46,7 @@ void dump_stack(void) | |||
44 | { | 46 | { |
45 | unsigned long stack; | 47 | unsigned long stack; |
46 | 48 | ||
47 | show_trace(&stack); | 49 | show_trace(current, &stack); |
48 | } | 50 | } |
49 | EXPORT_SYMBOL(dump_stack); | 51 | EXPORT_SYMBOL(dump_stack); |
50 | 52 | ||
@@ -59,7 +61,11 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
59 | int i; | 61 | int i; |
60 | 62 | ||
61 | if (esp == NULL) { | 63 | if (esp == NULL) { |
62 | if (task != current) { | 64 | if (task != current && task != NULL) { |
65 | /* XXX: Isn't this bogus? I.e. isn't this the | ||
66 | * *userspace* stack of this task? If not so, use this | ||
67 | * even when task == current (as in i386). | ||
68 | */ | ||
63 | esp = (unsigned long *) KSTK_ESP(task); | 69 | esp = (unsigned long *) KSTK_ESP(task); |
64 | /* Which one? No actual difference - just coding style.*/ | 70 | /* Which one? No actual difference - just coding style.*/ |
65 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); | 71 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); |
@@ -77,5 +83,6 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
77 | printk("%08lx ", *stack++); | 83 | printk("%08lx ", *stack++); |
78 | } | 84 | } |
79 | 85 | ||
80 | show_trace(esp); | 86 | printk("Call Trace: \n"); |
87 | show_trace(current, esp); | ||
81 | } | 88 | } |
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c index 1de22d8a313a..c20aef120598 100644 --- a/arch/um/kernel/trap_kern.c +++ b/arch/um/kernel/trap_kern.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "kern.h" | 23 | #include "kern.h" |
24 | #include "chan_kern.h" | 24 | #include "chan_kern.h" |
25 | #include "mconsole_kern.h" | 25 | #include "mconsole_kern.h" |
26 | #include "2_5compat.h" | ||
27 | #include "mem.h" | 26 | #include "mem.h" |
28 | #include "mem_kern.h" | 27 | #include "mem_kern.h" |
29 | 28 | ||
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c index df810ca8fc12..776310fd5b8b 100644 --- a/arch/um/kernel/tt/process_kern.c +++ b/arch/um/kernel/tt/process_kern.c | |||
@@ -32,10 +32,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
32 | unsigned long flags; | 32 | unsigned long flags; |
33 | int err, vtalrm, alrm, prof, cpu; | 33 | int err, vtalrm, alrm, prof, cpu; |
34 | char c; | 34 | char c; |
35 | /* jailing and SMP are incompatible, so this doesn't need to be | ||
36 | * made per-cpu | ||
37 | */ | ||
38 | static int reading; | ||
39 | 35 | ||
40 | from = prev; | 36 | from = prev; |
41 | to = next; | 37 | to = next; |
@@ -59,13 +55,11 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
59 | c = 0; | 55 | c = 0; |
60 | set_current(to); | 56 | set_current(to); |
61 | 57 | ||
62 | reading = 0; | ||
63 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); | 58 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); |
64 | if(err != sizeof(c)) | 59 | if(err != sizeof(c)) |
65 | panic("write of switch_pipe failed, err = %d", -err); | 60 | panic("write of switch_pipe failed, err = %d", -err); |
66 | 61 | ||
67 | reading = 1; | 62 | if(from->thread.mode.tt.switch_pipe[0] == -1) |
68 | if(from->thread.mode.tt.switch_pipe[0] == -1) | ||
69 | os_kill_process(os_getpid(), 0); | 63 | os_kill_process(os_getpid(), 0); |
70 | 64 | ||
71 | err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c)); | 65 | err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c)); |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 4d10ec372a67..8736d098f0ee 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "asm/setup.h" | 26 | #include "asm/setup.h" |
27 | #include "ubd_user.h" | 27 | #include "ubd_user.h" |
28 | #include "asm/current.h" | 28 | #include "asm/current.h" |
29 | #include "asm/setup.h" | ||
30 | #include "user_util.h" | 29 | #include "user_util.h" |
31 | #include "kern_util.h" | 30 | #include "kern_util.h" |
32 | #include "kern.h" | 31 | #include "kern.h" |
@@ -111,12 +110,6 @@ struct seq_operations cpuinfo_op = { | |||
111 | .show = show_cpuinfo, | 110 | .show = show_cpuinfo, |
112 | }; | 111 | }; |
113 | 112 | ||
114 | pte_t * __bad_pagetable(void) | ||
115 | { | ||
116 | panic("Someone should implement __bad_pagetable"); | ||
117 | return(NULL); | ||
118 | } | ||
119 | |||
120 | /* Set in linux_main */ | 113 | /* Set in linux_main */ |
121 | unsigned long host_task_size; | 114 | unsigned long host_task_size; |
122 | unsigned long task_size; | 115 | unsigned long task_size; |
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index 9aee0b62ebca..f0d6060e3e57 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c | |||
@@ -45,7 +45,11 @@ __init void scan_elf_aux( char **envp) | |||
45 | elf_aux_hwcap = auxv->a_un.a_val; | 45 | elf_aux_hwcap = auxv->a_un.a_val; |
46 | break; | 46 | break; |
47 | case AT_PLATFORM: | 47 | case AT_PLATFORM: |
48 | elf_aux_platform = auxv->a_un.a_ptr; | 48 | /* elf.h removed the pointer elements from |
49 | * a_un, so we have to use a_val, which is | ||
50 | * all that's left. | ||
51 | */ | ||
52 | elf_aux_platform = (char *) auxv->a_un.a_val; | ||
49 | break; | 53 | break; |
50 | case AT_PAGESZ: | 54 | case AT_PAGESZ: |
51 | page_size = auxv->a_un.a_val; | 55 | page_size = auxv->a_un.a_val; |
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 77d4066d1af8..fd45bb260907 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -363,7 +363,7 @@ int os_write_file(int fd, const void *buf, int len) | |||
363 | (int (*)(int, void *, int)) write, copy_to_user_proc)); | 363 | (int (*)(int, void *, int)) write, copy_to_user_proc)); |
364 | } | 364 | } |
365 | 365 | ||
366 | int os_file_size(char *file, long long *size_out) | 366 | int os_file_size(char *file, unsigned long long *size_out) |
367 | { | 367 | { |
368 | struct uml_stat buf; | 368 | struct uml_stat buf; |
369 | int err; | 369 | int err; |
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index 0b2491883d9c..98346c711493 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules | |||
@@ -14,7 +14,7 @@ quiet_cmd_make_link = SYMLINK $@ | |||
14 | cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ | 14 | cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ |
15 | 15 | ||
16 | # this needs to be before the foreach, because targets does not accept | 16 | # this needs to be before the foreach, because targets does not accept |
17 | # complete paths like $(obj)/$(f). To make sure this works, use a := assignment, | 17 | # complete paths like $(obj)/$(f). To make sure this works, use a := assignment |
18 | # or we will get $(obj)/$(f) in the "targets" value. | 18 | # or we will get $(obj)/$(f) in the "targets" value. |
19 | # Also, this forces you to use the := syntax when assigning to targets. | 19 | # Also, this forces you to use the := syntax when assigning to targets. |
20 | # Otherwise the line below will cause an infinite loop (if you don't know why, | 20 | # Otherwise the line below will cause an infinite loop (if you don't know why, |
diff --git a/arch/um/sys-i386/sysrq.c b/arch/um/sys-i386/sysrq.c index 281fc7b8ca00..e3706d15c4f5 100644 --- a/arch/um/sys-i386/sysrq.c +++ b/arch/um/sys-i386/sysrq.c | |||
@@ -3,12 +3,15 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/config.h" | ||
6 | #include "linux/kernel.h" | 7 | #include "linux/kernel.h" |
7 | #include "linux/smp.h" | 8 | #include "linux/smp.h" |
8 | #include "linux/sched.h" | 9 | #include "linux/sched.h" |
10 | #include "linux/kallsyms.h" | ||
9 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
10 | #include "sysrq.h" | 12 | #include "sysrq.h" |
11 | 13 | ||
14 | /* This is declared by <linux/sched.h> */ | ||
12 | void show_regs(struct pt_regs *regs) | 15 | void show_regs(struct pt_regs *regs) |
13 | { | 16 | { |
14 | printk("\n"); | 17 | printk("\n"); |
@@ -31,5 +34,80 @@ void show_regs(struct pt_regs *regs) | |||
31 | 0xffff & PT_REGS_DS(regs), | 34 | 0xffff & PT_REGS_DS(regs), |
32 | 0xffff & PT_REGS_ES(regs)); | 35 | 0xffff & PT_REGS_ES(regs)); |
33 | 36 | ||
34 | show_trace((unsigned long *) ®s); | 37 | show_trace(NULL, (unsigned long *) ®s); |
35 | } | 38 | } |
39 | |||
40 | /* Copied from i386. */ | ||
41 | static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) | ||
42 | { | ||
43 | return p > (void *)tinfo && | ||
44 | p < (void *)tinfo + THREAD_SIZE - 3; | ||
45 | } | ||
46 | |||
47 | /* Adapted from i386 (we also print the address we read from). */ | ||
48 | static inline unsigned long print_context_stack(struct thread_info *tinfo, | ||
49 | unsigned long *stack, unsigned long ebp) | ||
50 | { | ||
51 | unsigned long addr; | ||
52 | |||
53 | #ifdef CONFIG_FRAME_POINTER | ||
54 | while (valid_stack_ptr(tinfo, (void *)ebp)) { | ||
55 | addr = *(unsigned long *)(ebp + 4); | ||
56 | printk("%08lx: [<%08lx>]", ebp + 4, addr); | ||
57 | print_symbol(" %s", addr); | ||
58 | printk("\n"); | ||
59 | ebp = *(unsigned long *)ebp; | ||
60 | } | ||
61 | #else | ||
62 | while (valid_stack_ptr(tinfo, stack)) { | ||
63 | addr = *stack; | ||
64 | if (__kernel_text_address(addr)) { | ||
65 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
66 | print_symbol(" %s", addr); | ||
67 | printk("\n"); | ||
68 | } | ||
69 | stack++; | ||
70 | } | ||
71 | #endif | ||
72 | return ebp; | ||
73 | } | ||
74 | |||
75 | void show_trace(struct task_struct* task, unsigned long * stack) | ||
76 | { | ||
77 | unsigned long ebp; | ||
78 | struct thread_info *context; | ||
79 | |||
80 | /* Turn this into BUG_ON if possible. */ | ||
81 | if (!stack) { | ||
82 | stack = (unsigned long*) &stack; | ||
83 | printk("show_trace: got NULL stack, implicit assumption task == current"); | ||
84 | WARN_ON(1); | ||
85 | } | ||
86 | |||
87 | if (!task) | ||
88 | task = current; | ||
89 | |||
90 | if (task != current) { | ||
91 | //ebp = (unsigned long) KSTK_EBP(task); | ||
92 | /* Which one? No actual difference - just coding style.*/ | ||
93 | ebp = (unsigned long) PT_REGS_EBP(&task->thread.regs); | ||
94 | } else { | ||
95 | asm ("movl %%ebp, %0" : "=r" (ebp) : ); | ||
96 | } | ||
97 | |||
98 | context = (struct thread_info *) | ||
99 | ((unsigned long)stack & (~(THREAD_SIZE - 1))); | ||
100 | print_context_stack(context, stack, ebp); | ||
101 | |||
102 | /*while (((long) stack & (THREAD_SIZE-1)) != 0) { | ||
103 | addr = *stack; | ||
104 | if (__kernel_text_address(addr)) { | ||
105 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
106 | print_symbol(" %s", addr); | ||
107 | printk("\n"); | ||
108 | } | ||
109 | stack++; | ||
110 | }*/ | ||
111 | printk("\n"); | ||
112 | } | ||
113 | |||
diff --git a/arch/um/sys-ppc/sysrq.c b/arch/um/sys-ppc/sysrq.c index 82d6e9335bb6..2f816f1a0ff4 100644 --- a/arch/um/sys-ppc/sysrq.c +++ b/arch/um/sys-ppc/sysrq.c | |||
@@ -27,17 +27,5 @@ void show_regs(struct pt_regs_subarch *regs) | |||
27 | 0xffff & regs->xds, 0xffff & regs->xes); | 27 | 0xffff & regs->xds, 0xffff & regs->xes); |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | show_trace(®s->gpr[1]); | 30 | show_trace(current, ®s->gpr[1]); |
31 | } | 31 | } |
32 | |||
33 | |||
34 | /* | ||
35 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
36 | * Emacs will notice this stuff at the end of the file and automatically | ||
37 | * adjust the settings for this buffer only. This must remain at the end | ||
38 | * of the file. | ||
39 | * --------------------------------------------------------------------------- | ||
40 | * Local variables: | ||
41 | * c-file-style: "linux" | ||
42 | * End: | ||
43 | */ | ||
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c index d4a59657fb99..6f44f40204ed 100644 --- a/arch/um/sys-x86_64/syscalls.c +++ b/arch/um/sys-x86_64/syscalls.c | |||
@@ -133,23 +133,27 @@ static long arch_prctl_tt(int code, unsigned long addr) | |||
133 | 133 | ||
134 | #ifdef CONFIG_MODE_SKAS | 134 | #ifdef CONFIG_MODE_SKAS |
135 | 135 | ||
136 | /* XXX: Must also call arch_prctl in the host, beside saving the segment bases! */ | ||
136 | static long arch_prctl_skas(int code, unsigned long addr) | 137 | static long arch_prctl_skas(int code, unsigned long addr) |
137 | { | 138 | { |
138 | long ret = 0; | 139 | long ret = 0; |
139 | 140 | ||
140 | switch(code){ | 141 | switch(code){ |
141 | case ARCH_SET_GS: | ||
142 | current->thread.regs.regs.skas.regs[GS_BASE / sizeof(unsigned long)] = addr; | ||
143 | break; | ||
144 | case ARCH_SET_FS: | 142 | case ARCH_SET_FS: |
145 | current->thread.regs.regs.skas.regs[FS_BASE / sizeof(unsigned long)] = addr; | 143 | current->thread.regs.regs.skas.regs[FS_BASE / sizeof(unsigned long)] = addr; |
146 | break; | 144 | break; |
145 | case ARCH_SET_GS: | ||
146 | current->thread.regs.regs.skas.regs[GS_BASE / sizeof(unsigned long)] = addr; | ||
147 | break; | ||
147 | case ARCH_GET_FS: | 148 | case ARCH_GET_FS: |
148 | ret = put_user(current->thread.regs.regs.skas.regs[GS / sizeof(unsigned long)], &addr); | 149 | ret = put_user(current->thread.regs.regs.skas. |
150 | regs[FS_BASE / sizeof(unsigned long)], | ||
151 | (unsigned long __user *)addr); | ||
149 | break; | 152 | break; |
150 | case ARCH_GET_GS: | 153 | case ARCH_GET_GS: |
151 | ret = put_user(current->thread.regs.regs.skas.regs[FS / sizeof(unsigned \ | 154 | ret = put_user(current->thread.regs.regs.skas. |
152 | long)], &addr); | 155 | regs[GS_BASE / sizeof(unsigned long)], |
156 | (unsigned long __user *)addr); | ||
153 | break; | 157 | break; |
154 | default: | 158 | default: |
155 | ret = -EINVAL; | 159 | ret = -EINVAL; |
diff --git a/arch/um/sys-x86_64/sysrq.c b/arch/um/sys-x86_64/sysrq.c index ddf74691a610..d0a25af19a5b 100644 --- a/arch/um/sys-x86_64/sysrq.c +++ b/arch/um/sys-x86_64/sysrq.c | |||
@@ -36,14 +36,5 @@ void __show_regs(struct pt_regs * regs) | |||
36 | void show_regs(struct pt_regs *regs) | 36 | void show_regs(struct pt_regs *regs) |
37 | { | 37 | { |
38 | __show_regs(regs); | 38 | __show_regs(regs); |
39 | show_trace((unsigned long *) ®s); | 39 | show_trace(current, (unsigned long *) ®s); |
40 | } | 40 | } |
41 | |||
42 | /* Emacs will notice this stuff at the end of the file and automatically | ||
43 | * adjust the settings for this buffer only. This must remain at the end | ||
44 | * of the file. | ||
45 | * --------------------------------------------------------------------------- | ||
46 | * Local variables: | ||
47 | * c-file-style: "linux" | ||
48 | * End: | ||
49 | */ | ||