diff options
Diffstat (limited to 'arch/um')
33 files changed, 470 insertions, 565 deletions
diff --git a/arch/um/Kconfig.i386 b/arch/um/Kconfig.i386 index 8ad156a00499..5d92cacd56c6 100644 --- a/arch/um/Kconfig.i386 +++ b/arch/um/Kconfig.i386 | |||
| @@ -42,3 +42,7 @@ config ARCH_HAS_SC_SIGNALS | |||
| 42 | config ARCH_REUSE_HOST_VSYSCALL_AREA | 42 | config ARCH_REUSE_HOST_VSYSCALL_AREA |
| 43 | bool | 43 | bool |
| 44 | default y | 44 | default y |
| 45 | |||
| 46 | config X86_CMPXCHG | ||
| 47 | bool | ||
| 48 | default y | ||
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 7a0d115b29d0..5db136e2651c 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | #include <errno.h> | 14 | #include <errno.h> |
| 15 | #include <unistd.h> | 15 | #include <unistd.h> |
| 16 | #include <linux/inet.h> | ||
| 17 | #include <sys/socket.h> | 16 | #include <sys/socket.h> |
| 18 | #include <sys/un.h> | 17 | #include <sys/un.h> |
| 19 | #include <sys/time.h> | 18 | #include <sys/time.h> |
| @@ -55,7 +54,7 @@ static int mcast_open(void *data) | |||
| 55 | struct mcast_data *pri = data; | 54 | struct mcast_data *pri = data; |
| 56 | struct sockaddr_in *sin = pri->mcast_addr; | 55 | struct sockaddr_in *sin = pri->mcast_addr; |
| 57 | struct ip_mreq mreq; | 56 | struct ip_mreq mreq; |
| 58 | int fd = -EINVAL, yes = 1, err = -EINVAL;; | 57 | int fd, yes = 1, err = 0; |
| 59 | 58 | ||
| 60 | 59 | ||
| 61 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) | 60 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) |
| @@ -66,13 +65,14 @@ static int mcast_open(void *data) | |||
| 66 | if (fd < 0){ | 65 | if (fd < 0){ |
| 67 | printk("mcast_open : data socket failed, errno = %d\n", | 66 | printk("mcast_open : data socket failed, errno = %d\n", |
| 68 | errno); | 67 | errno); |
| 69 | fd = -errno; | 68 | err = -errno; |
| 70 | goto out; | 69 | goto out; |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { | 72 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { |
| 74 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", | 73 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", |
| 75 | errno); | 74 | errno); |
| 75 | err = -errno; | ||
| 76 | goto out_close; | 76 | goto out_close; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -81,6 +81,7 @@ static int mcast_open(void *data) | |||
| 81 | sizeof(pri->ttl)) < 0) { | 81 | sizeof(pri->ttl)) < 0) { |
| 82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", | 82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", |
| 83 | errno); | 83 | errno); |
| 84 | err = -errno; | ||
| 84 | goto out_close; | 85 | goto out_close; |
| 85 | } | 86 | } |
| 86 | 87 | ||
| @@ -88,12 +89,14 @@ static int mcast_open(void *data) | |||
| 88 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { | 89 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { |
| 89 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", | 90 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", |
| 90 | errno); | 91 | errno); |
| 92 | err = -errno; | ||
| 91 | goto out_close; | 93 | goto out_close; |
| 92 | } | 94 | } |
| 93 | 95 | ||
| 94 | /* bind socket to mcast address */ | 96 | /* bind socket to mcast address */ |
| 95 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { | 97 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { |
| 96 | printk("mcast_open : data bind failed, errno = %d\n", errno); | 98 | printk("mcast_open : data bind failed, errno = %d\n", errno); |
| 99 | err = -errno; | ||
| 97 | goto out_close; | 100 | goto out_close; |
| 98 | } | 101 | } |
| 99 | 102 | ||
| @@ -108,14 +111,15 @@ static int mcast_open(void *data) | |||
| 108 | "interface on the host.\n"); | 111 | "interface on the host.\n"); |
| 109 | printk("eth0 should be configured in order to use the " | 112 | printk("eth0 should be configured in order to use the " |
| 110 | "multicast transport.\n"); | 113 | "multicast transport.\n"); |
| 114 | err = -errno; | ||
| 111 | goto out_close; | 115 | goto out_close; |
| 112 | } | 116 | } |
| 113 | 117 | ||
| 114 | out: | ||
| 115 | return fd; | 118 | return fd; |
| 116 | 119 | ||
| 117 | out_close: | 120 | out_close: |
| 118 | os_close_file(fd); | 121 | os_close_file(fd); |
| 122 | out: | ||
| 119 | return err; | 123 | return err; |
| 120 | } | 124 | } |
| 121 | 125 | ||
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index c190c2414197..12c95368124a 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include "os.h" | 32 | #include "os.h" |
| 33 | #include "umid.h" | 33 | #include "umid.h" |
| 34 | #include "irq_kern.h" | 34 | #include "irq_kern.h" |
| 35 | #include "choose-mode.h" | ||
| 35 | 36 | ||
| 36 | static int do_unlink_socket(struct notifier_block *notifier, | 37 | static int do_unlink_socket(struct notifier_block *notifier, |
| 37 | unsigned long what, void *data) | 38 | unsigned long what, void *data) |
| @@ -276,6 +277,7 @@ void mconsole_proc(struct mc_request *req) | |||
| 276 | go - continue the UML after a 'stop' \n\ | 277 | go - continue the UML after a 'stop' \n\ |
| 277 | log <string> - make UML enter <string> into the kernel log\n\ | 278 | log <string> - make UML enter <string> into the kernel log\n\ |
| 278 | proc <file> - returns the contents of the UML's /proc/<file>\n\ | 279 | proc <file> - returns the contents of the UML's /proc/<file>\n\ |
| 280 | stack <pid> - returns the stack of the specified pid\n\ | ||
| 279 | " | 281 | " |
| 280 | 282 | ||
| 281 | void mconsole_help(struct mc_request *req) | 283 | void mconsole_help(struct mc_request *req) |
| @@ -479,6 +481,56 @@ void mconsole_sysrq(struct mc_request *req) | |||
| 479 | } | 481 | } |
| 480 | #endif | 482 | #endif |
| 481 | 483 | ||
| 484 | /* Mconsole stack trace | ||
| 485 | * Added by Allan Graves, Jeff Dike | ||
| 486 | * Dumps a stacks registers to the linux console. | ||
| 487 | * Usage stack <pid>. | ||
| 488 | */ | ||
| 489 | void do_stack(struct mc_request *req) | ||
| 490 | { | ||
| 491 | char *ptr = req->request.data; | ||
| 492 | int pid_requested= -1; | ||
| 493 | struct task_struct *from = NULL; | ||
| 494 | struct task_struct *to = NULL; | ||
| 495 | |||
| 496 | /* Would be nice: | ||
| 497 | * 1) Send showregs output to mconsole. | ||
| 498 | * 2) Add a way to stack dump all pids. | ||
| 499 | */ | ||
| 500 | |||
| 501 | ptr += strlen("stack"); | ||
| 502 | while(isspace(*ptr)) ptr++; | ||
| 503 | |||
| 504 | /* Should really check for multiple pids or reject bad args here */ | ||
| 505 | /* What do the arguments in mconsole_reply mean? */ | ||
| 506 | if(sscanf(ptr, "%d", &pid_requested) == 0){ | ||
| 507 | mconsole_reply(req, "Please specify a pid", 1, 0); | ||
| 508 | return; | ||
| 509 | } | ||
| 510 | |||
| 511 | from = current; | ||
| 512 | to = find_task_by_pid(pid_requested); | ||
| 513 | |||
| 514 | if((to == NULL) || (pid_requested == 0)) { | ||
| 515 | mconsole_reply(req, "Couldn't find that pid", 1, 0); | ||
| 516 | return; | ||
| 517 | } | ||
| 518 | to->thread.saved_task = current; | ||
| 519 | |||
| 520 | switch_to(from, to, from); | ||
| 521 | mconsole_reply(req, "Stack Dumped to console and message log", 0, 0); | ||
| 522 | } | ||
| 523 | |||
| 524 | void mconsole_stack(struct mc_request *req) | ||
| 525 | { | ||
| 526 | /* This command doesn't work in TT mode, so let's check and then | ||
| 527 | * get out of here | ||
| 528 | */ | ||
| 529 | CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode", | ||
| 530 | 1, 0), | ||
| 531 | do_stack(req)); | ||
| 532 | } | ||
| 533 | |||
| 482 | /* Changed by mconsole_setup, which is __setup, and called before SMP is | 534 | /* Changed by mconsole_setup, which is __setup, and called before SMP is |
| 483 | * active. | 535 | * active. |
| 484 | */ | 536 | */ |
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index fe5afb13252c..310c1f823f26 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c | |||
| @@ -30,6 +30,7 @@ static struct mconsole_command commands[] = { | |||
| 30 | { "go", mconsole_go, MCONSOLE_INTR }, | 30 | { "go", mconsole_go, MCONSOLE_INTR }, |
| 31 | { "log", mconsole_log, MCONSOLE_INTR }, | 31 | { "log", mconsole_log, MCONSOLE_INTR }, |
| 32 | { "proc", mconsole_proc, MCONSOLE_PROC }, | 32 | { "proc", mconsole_proc, MCONSOLE_PROC }, |
| 33 | { "stack", mconsole_stack, MCONSOLE_INTR }, | ||
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | /* Initialized in mconsole_init, which is an initcall */ | 36 | /* Initialized in mconsole_init, which is an initcall */ |
| @@ -172,9 +173,9 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
| 172 | if(notify_sock < 0){ | 173 | if(notify_sock < 0){ |
| 173 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 174 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
| 174 | if(notify_sock < 0){ | 175 | if(notify_sock < 0){ |
| 175 | printk("mconsole_notify - socket failed, errno = %d\n", | ||
| 176 | errno); | ||
| 177 | err = -errno; | 176 | err = -errno; |
| 177 | printk("mconsole_notify - socket failed, errno = %d\n", | ||
| 178 | err); | ||
| 178 | } | 179 | } |
| 179 | } | 180 | } |
| 180 | unlock_notify(); | 181 | unlock_notify(); |
| @@ -197,8 +198,8 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
| 197 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, | 198 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, |
| 198 | sizeof(target)); | 199 | sizeof(target)); |
| 199 | if(n < 0){ | 200 | if(n < 0){ |
| 200 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | ||
| 201 | err = -errno; | 201 | err = -errno; |
| 202 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | ||
| 202 | } | 203 | } |
| 203 | return(err); | 204 | return(err); |
| 204 | } | 205 | } |
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c index ed84d01df6cc..0306a1b215b7 100644 --- a/arch/um/drivers/pty.c +++ b/arch/um/drivers/pty.c | |||
| @@ -43,8 +43,9 @@ static int pts_open(int input, int output, int primary, void *d, | |||
| 43 | 43 | ||
| 44 | fd = get_pty(); | 44 | fd = get_pty(); |
| 45 | if(fd < 0){ | 45 | if(fd < 0){ |
| 46 | err = -errno; | ||
| 46 | printk("open_pts : Failed to open pts\n"); | 47 | printk("open_pts : Failed to open pts\n"); |
| 47 | return(-errno); | 48 | return err; |
| 48 | } | 49 | } |
| 49 | if(data->raw){ | 50 | if(data->raw){ |
| 50 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); | 51 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); |
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c deleted file mode 100644 index b94d2bc4fe06..000000000000 --- a/arch/um/drivers/ubd_user.c +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
| 3 | * Copyright (C) 2001 Ridgerun,Inc (glonnon@ridgerun.com) | ||
| 4 | * Licensed under the GPL | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <stddef.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | #include <errno.h> | ||
| 10 | #include <sched.h> | ||
| 11 | #include <signal.h> | ||
| 12 | #include <string.h> | ||
| 13 | #include <netinet/in.h> | ||
| 14 | #include <sys/time.h> | ||
| 15 | #include <sys/socket.h> | ||
| 16 | #include <sys/mman.h> | ||
| 17 | #include <sys/param.h> | ||
| 18 | #include "asm/types.h" | ||
| 19 | #include "user_util.h" | ||
| 20 | #include "kern_util.h" | ||
| 21 | #include "user.h" | ||
| 22 | #include "ubd_user.h" | ||
| 23 | #include "os.h" | ||
| 24 | #include "cow.h" | ||
| 25 | |||
| 26 | #include <endian.h> | ||
| 27 | #include <byteswap.h> | ||
| 28 | |||
| 29 | void ignore_sigwinch_sig(void) | ||
| 30 | { | ||
| 31 | signal(SIGWINCH, SIG_IGN); | ||
| 32 | } | ||
| 33 | |||
| 34 | int start_io_thread(unsigned long sp, int *fd_out) | ||
| 35 | { | ||
| 36 | int pid, fds[2], err; | ||
| 37 | |||
| 38 | err = os_pipe(fds, 1, 1); | ||
| 39 | if(err < 0){ | ||
| 40 | printk("start_io_thread - os_pipe failed, err = %d\n", -err); | ||
| 41 | goto out; | ||
| 42 | } | ||
| 43 | |||
| 44 | kernel_fd = fds[0]; | ||
| 45 | *fd_out = fds[1]; | ||
| 46 | |||
| 47 | pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD, | ||
| 48 | NULL); | ||
| 49 | if(pid < 0){ | ||
| 50 | printk("start_io_thread - clone failed : errno = %d\n", errno); | ||
| 51 | err = -errno; | ||
| 52 | goto out_close; | ||
| 53 | } | ||
| 54 | |||
| 55 | return(pid); | ||
| 56 | |||
| 57 | out_close: | ||
| 58 | os_close_file(fds[0]); | ||
| 59 | os_close_file(fds[1]); | ||
| 60 | kernel_fd = -1; | ||
| 61 | *fd_out = -1; | ||
| 62 | out: | ||
| 63 | return(err); | ||
| 64 | } | ||
| 65 | |||
| 66 | /* | ||
| 67 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 68 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 69 | * adjust the settings for this buffer only. This must remain at the end | ||
| 70 | * of the file. | ||
| 71 | * --------------------------------------------------------------------------- | ||
| 72 | * Local variables: | ||
| 73 | * c-file-style: "linux" | ||
| 74 | * End: | ||
| 75 | */ | ||
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 93dc1911363f..90e0e5ff451e 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c | |||
| @@ -110,13 +110,15 @@ int xterm_open(int input, int output, int primary, void *d, | |||
| 110 | 110 | ||
| 111 | fd = mkstemp(file); | 111 | fd = mkstemp(file); |
| 112 | if(fd < 0){ | 112 | if(fd < 0){ |
| 113 | err = -errno; | ||
| 113 | printk("xterm_open : mkstemp failed, errno = %d\n", errno); | 114 | printk("xterm_open : mkstemp failed, errno = %d\n", errno); |
| 114 | return(-errno); | 115 | return err; |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | if(unlink(file)){ | 118 | if(unlink(file)){ |
| 119 | err = -errno; | ||
| 118 | printk("xterm_open : unlink failed, errno = %d\n", errno); | 120 | printk("xterm_open : unlink failed, errno = %d\n", errno); |
| 119 | return(-errno); | 121 | return err; |
| 120 | } | 122 | } |
| 121 | os_close_file(fd); | 123 | os_close_file(fd); |
| 122 | 124 | ||
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h index cfa368e045a5..b1b512f47035 100644 --- a/arch/um/include/mconsole.h +++ b/arch/um/include/mconsole.h | |||
| @@ -81,6 +81,7 @@ extern void mconsole_stop(struct mc_request *req); | |||
| 81 | extern void mconsole_go(struct mc_request *req); | 81 | extern void mconsole_go(struct mc_request *req); |
| 82 | extern void mconsole_log(struct mc_request *req); | 82 | extern void mconsole_log(struct mc_request *req); |
| 83 | extern void mconsole_proc(struct mc_request *req); | 83 | extern void mconsole_proc(struct mc_request *req); |
| 84 | extern void mconsole_stack(struct mc_request *req); | ||
| 84 | 85 | ||
| 85 | extern int mconsole_get_request(int fd, struct mc_request *req); | 86 | extern int mconsole_get_request(int fd, struct mc_request *req); |
| 86 | extern int mconsole_notify(char *sock_name, int type, const void *data, | 87 | extern int mconsole_notify(char *sock_name, int type, const void *data, |
diff --git a/arch/um/include/mem_user.h b/arch/um/include/mem_user.h index d6404bb64662..9fef4123a65a 100644 --- a/arch/um/include/mem_user.h +++ b/arch/um/include/mem_user.h | |||
| @@ -51,7 +51,6 @@ extern unsigned long task_size; | |||
| 51 | 51 | ||
| 52 | extern void check_devanon(void); | 52 | extern void check_devanon(void); |
| 53 | extern int init_mem_user(void); | 53 | extern int init_mem_user(void); |
| 54 | extern int create_mem_file(unsigned long len); | ||
| 55 | extern void setup_memory(void *entry); | 54 | extern void setup_memory(void *entry); |
| 56 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); | 55 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); |
| 57 | extern int init_maps(unsigned long physmem, unsigned long iomem, | 56 | extern int init_maps(unsigned long physmem, unsigned long iomem, |
| @@ -64,20 +63,6 @@ extern unsigned long phys_offset(unsigned long phys); | |||
| 64 | extern void unmap_physmem(void); | 63 | extern void unmap_physmem(void); |
| 65 | extern void map_memory(unsigned long virt, unsigned long phys, | 64 | extern void map_memory(unsigned long virt, unsigned long phys, |
| 66 | unsigned long len, int r, int w, int x); | 65 | unsigned long len, int r, int w, int x); |
| 67 | extern int protect_memory(unsigned long addr, unsigned long len, | ||
| 68 | int r, int w, int x, int must_succeed); | ||
| 69 | extern unsigned long get_kmem_end(void); | 66 | extern unsigned long get_kmem_end(void); |
| 70 | extern void check_tmpexec(void); | ||
| 71 | 67 | ||
| 72 | #endif | 68 | #endif |
| 73 | |||
| 74 | /* | ||
| 75 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 76 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 77 | * adjust the settings for this buffer only. This must remain at the end | ||
| 78 | * of the file. | ||
| 79 | * --------------------------------------------------------------------------- | ||
| 80 | * Local variables: | ||
| 81 | * c-file-style: "linux" | ||
| 82 | * End: | ||
| 83 | */ | ||
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 4c362458052c..583329d0a539 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
| @@ -157,6 +157,9 @@ extern int os_lock_file(int fd, int excl); | |||
| 157 | extern void os_early_checks(void); | 157 | extern void os_early_checks(void); |
| 158 | extern int can_do_skas(void); | 158 | extern int can_do_skas(void); |
| 159 | 159 | ||
| 160 | /* mem.c */ | ||
| 161 | extern int create_mem_file(unsigned long len); | ||
| 162 | |||
| 160 | /* process.c */ | 163 | /* process.c */ |
| 161 | extern unsigned long os_process_pc(int pid); | 164 | extern unsigned long os_process_pc(int pid); |
| 162 | extern int os_process_parent(int pid); | 165 | extern int os_process_parent(int pid); |
| @@ -181,6 +184,8 @@ extern unsigned long long os_usecs(void); | |||
| 181 | /* tt.c | 184 | /* tt.c |
| 182 | * for tt mode only (will be deleted in future...) | 185 | * for tt mode only (will be deleted in future...) |
| 183 | */ | 186 | */ |
| 187 | extern int protect_memory(unsigned long addr, unsigned long len, | ||
| 188 | int r, int w, int x, int must_succeed); | ||
| 184 | extern void forward_pending_sigio(int target); | 189 | extern void forward_pending_sigio(int target); |
| 185 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, | 190 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, |
| 186 | int clone_flags, int (*tramp)(void *)); | 191 | int clone_flags, int (*tramp)(void *)); |
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 614b8ebeb0ed..1a0001b3850c 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # | 1 | # |
| 2 | # Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | # Copyright (C) 2002 Jeff Dike (jdike@karaya.com) |
| 3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
| 4 | # | 4 | # |
| @@ -7,11 +7,11 @@ extra-y := vmlinux.lds | |||
| 7 | clean-files := | 7 | clean-files := |
| 8 | 8 | ||
| 9 | obj-y = config.o exec_kern.o exitcode.o \ | 9 | obj-y = config.o exec_kern.o exitcode.o \ |
| 10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \ | 10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o physmem.o \ |
| 11 | physmem.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
| 12 | sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o \ | 12 | signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ |
| 13 | tempfile.o time.o time_kern.o tlb.o trap_kern.o trap_user.o \ | 13 | time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \ |
| 14 | uaccess_user.o um_arch.o umid.o user_util.o | 14 | umid.o user_util.o |
| 15 | 15 | ||
| 16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o | 16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
| 17 | obj-$(CONFIG_GPROF) += gprof_syms.o | 17 | obj-$(CONFIG_GPROF) += gprof_syms.o |
| @@ -24,8 +24,8 @@ obj-$(CONFIG_MODE_SKAS) += skas/ | |||
| 24 | 24 | ||
| 25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | 25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o |
| 26 | 26 | ||
| 27 | USER_OBJS := $(user-objs-y) config.o helper.o main.o tempfile.o time.o \ | 27 | USER_OBJS := $(user-objs-y) config.o helper.o main.o time.o tty_log.o umid.o \ |
| 28 | tty_log.o umid.o user_util.o | 28 | user_util.o |
| 29 | 29 | ||
| 30 | include arch/um/scripts/Makefile.rules | 30 | include arch/um/scripts/Makefile.rules |
| 31 | 31 | ||
diff --git a/arch/um/kernel/helper.c b/arch/um/kernel/helper.c index f83e1e8e2392..33fb0bd3b11a 100644 --- a/arch/um/kernel/helper.c +++ b/arch/um/kernel/helper.c | |||
| @@ -85,8 +85,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
| 85 | data.fd = fds[1]; | 85 | data.fd = fds[1]; |
| 86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); | 86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); |
| 87 | if(pid < 0){ | 87 | if(pid < 0){ |
| 88 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
| 89 | ret = -errno; | 88 | ret = -errno; |
| 89 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
| 90 | goto out_close; | 90 | goto out_close; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| @@ -122,7 +122,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
| 122 | unsigned long *stack_out, int stack_order) | 122 | unsigned long *stack_out, int stack_order) |
| 123 | { | 123 | { |
| 124 | unsigned long stack, sp; | 124 | unsigned long stack, sp; |
| 125 | int pid, status; | 125 | int pid, status, err; |
| 126 | 126 | ||
| 127 | stack = alloc_stack(stack_order, um_in_interrupt()); | 127 | stack = alloc_stack(stack_order, um_in_interrupt()); |
| 128 | if(stack == 0) return(-ENOMEM); | 128 | if(stack == 0) return(-ENOMEM); |
| @@ -130,16 +130,18 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
| 130 | sp = stack + (page_size() << stack_order) - sizeof(void *); | 130 | sp = stack + (page_size() << stack_order) - sizeof(void *); |
| 131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); | 131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
| 132 | if(pid < 0){ | 132 | if(pid < 0){ |
| 133 | err = -errno; | ||
| 133 | printk("run_helper_thread : clone failed, errno = %d\n", | 134 | printk("run_helper_thread : clone failed, errno = %d\n", |
| 134 | errno); | 135 | errno); |
| 135 | return(-errno); | 136 | return err; |
| 136 | } | 137 | } |
| 137 | if(stack_out == NULL){ | 138 | if(stack_out == NULL){ |
| 138 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); | 139 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); |
| 139 | if(pid < 0){ | 140 | if(pid < 0){ |
| 141 | err = -errno; | ||
| 140 | printk("run_helper_thread - wait failed, errno = %d\n", | 142 | printk("run_helper_thread - wait failed, errno = %d\n", |
| 141 | errno); | 143 | errno); |
| 142 | pid = -errno; | 144 | pid = err; |
| 143 | } | 145 | } |
| 144 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) | 146 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) |
| 145 | printk("run_helper_thread - thread returned status " | 147 | printk("run_helper_thread - thread returned status " |
| @@ -156,8 +158,8 @@ int helper_wait(int pid) | |||
| 156 | 158 | ||
| 157 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); | 159 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); |
| 158 | if(ret < 0){ | 160 | if(ret < 0){ |
| 161 | ret = -errno; | ||
| 159 | printk("helper_wait : waitpid failed, errno = %d\n", errno); | 162 | printk("helper_wait : waitpid failed, errno = %d\n", errno); |
| 160 | return(-errno); | ||
| 161 | } | 163 | } |
| 162 | return(ret); | 164 | return(ret); |
| 163 | } | 165 | } |
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c index cd7c85be0a1b..49ed5ddf0704 100644 --- a/arch/um/kernel/init_task.c +++ b/arch/um/kernel/init_task.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "asm/pgtable.h" | 13 | #include "asm/pgtable.h" |
| 14 | #include "user_util.h" | 14 | #include "user_util.h" |
| 15 | #include "mem_user.h" | 15 | #include "mem_user.h" |
| 16 | #include "os.h" | ||
| 16 | 17 | ||
| 17 | static struct fs_struct init_fs = INIT_FS; | 18 | static struct fs_struct init_fs = INIT_FS; |
| 18 | struct mm_struct init_mm = INIT_MM(init_mm); | 19 | struct mm_struct init_mm = INIT_MM(init_mm); |
| @@ -45,8 +46,8 @@ __attribute__((__section__(".data.init_task"))) = | |||
| 45 | 46 | ||
| 46 | void unprotect_stack(unsigned long stack) | 47 | void unprotect_stack(unsigned long stack) |
| 47 | { | 48 | { |
| 48 | protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, | 49 | os_protect_memory((void *) stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, |
| 49 | 1, 1, 0, 1); | 50 | 1, 1, 0); |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | /* | 53 | /* |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 64fa062cc119..ea008b031a8f 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) | 2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) |
| 3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
| 4 | */ | 4 | */ |
| @@ -19,6 +19,10 @@ | |||
| 19 | #include "mem_user.h" | 19 | #include "mem_user.h" |
| 20 | #include "uml_uaccess.h" | 20 | #include "uml_uaccess.h" |
| 21 | #include "os.h" | 21 | #include "os.h" |
| 22 | #include "linux/types.h" | ||
| 23 | #include "linux/string.h" | ||
| 24 | #include "init.h" | ||
| 25 | #include "kern_constants.h" | ||
| 22 | 26 | ||
| 23 | extern char __binary_start; | 27 | extern char __binary_start; |
| 24 | 28 | ||
| @@ -368,6 +372,16 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) | |||
| 368 | return pte; | 372 | return pte; |
| 369 | } | 373 | } |
| 370 | 374 | ||
| 375 | struct iomem_region *iomem_regions = NULL; | ||
| 376 | int iomem_size = 0; | ||
| 377 | |||
| 378 | extern int parse_iomem(char *str, int *add) __init; | ||
| 379 | |||
| 380 | __uml_setup("iomem=", parse_iomem, | ||
| 381 | "iomem=<name>,<file>\n" | ||
| 382 | " Configure <file> as an IO memory region named <name>.\n\n" | ||
| 383 | ); | ||
| 384 | |||
| 371 | /* | 385 | /* |
| 372 | * Overrides for Emacs so that we follow Linus's tabbing style. | 386 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 373 | * Emacs will notice this stuff at the end of the file and automatically | 387 | * Emacs will notice this stuff at the end of the file and automatically |
diff --git a/arch/um/kernel/mem_user.c b/arch/um/kernel/mem_user.c deleted file mode 100644 index 4a663fd434bb..000000000000 --- a/arch/um/kernel/mem_user.c +++ /dev/null | |||
| @@ -1,273 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * arch/um/kernel/mem_user.c | ||
| 3 | * | ||
| 4 | * BRIEF MODULE DESCRIPTION | ||
| 5 | * user side memory routines for supporting IO memory inside user mode linux | ||
| 6 | * | ||
| 7 | * Copyright (C) 2001 RidgeRun, Inc. | ||
| 8 | * Author: RidgeRun, Inc. | ||
| 9 | * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify it | ||
| 12 | * under the terms of the GNU General Public License as published by the | ||
| 13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 14 | * option) any later version. | ||
| 15 | * | ||
| 16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
| 19 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
| 22 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
| 23 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 26 | * | ||
| 27 | * You should have received a copy of the GNU General Public License along | ||
| 28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 30 | */ | ||
| 31 | |||
| 32 | #include <stdio.h> | ||
| 33 | #include <stdlib.h> | ||
| 34 | #include <stddef.h> | ||
| 35 | #include <stdarg.h> | ||
| 36 | #include <unistd.h> | ||
| 37 | #include <errno.h> | ||
| 38 | #include <string.h> | ||
| 39 | #include <fcntl.h> | ||
| 40 | #include <sys/types.h> | ||
| 41 | #include <sys/mman.h> | ||
| 42 | #include "kern_util.h" | ||
| 43 | #include "user.h" | ||
| 44 | #include "user_util.h" | ||
| 45 | #include "mem_user.h" | ||
| 46 | #include "init.h" | ||
| 47 | #include "os.h" | ||
| 48 | #include "tempfile.h" | ||
| 49 | #include "kern_constants.h" | ||
| 50 | |||
| 51 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | ||
| 52 | |||
| 53 | static int create_tmp_file(unsigned long len) | ||
| 54 | { | ||
| 55 | int fd, err; | ||
| 56 | char zero; | ||
| 57 | |||
| 58 | fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); | ||
| 59 | if(fd < 0) { | ||
| 60 | os_print_error(fd, "make_tempfile"); | ||
| 61 | exit(1); | ||
| 62 | } | ||
| 63 | |||
| 64 | err = os_mode_fd(fd, 0777); | ||
| 65 | if(err < 0){ | ||
| 66 | os_print_error(err, "os_mode_fd"); | ||
| 67 | exit(1); | ||
| 68 | } | ||
| 69 | err = os_seek_file(fd, len); | ||
| 70 | if(err < 0){ | ||
| 71 | os_print_error(err, "os_seek_file"); | ||
| 72 | exit(1); | ||
| 73 | } | ||
| 74 | zero = 0; | ||
| 75 | err = os_write_file(fd, &zero, 1); | ||
| 76 | if(err != 1){ | ||
| 77 | os_print_error(err, "os_write_file"); | ||
| 78 | exit(1); | ||
| 79 | } | ||
| 80 | |||
| 81 | return(fd); | ||
| 82 | } | ||
| 83 | |||
| 84 | void check_tmpexec(void) | ||
| 85 | { | ||
| 86 | void *addr; | ||
| 87 | int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE); | ||
| 88 | |||
| 89 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | ||
| 90 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | ||
| 91 | printf("Checking PROT_EXEC mmap in /tmp..."); | ||
| 92 | fflush(stdout); | ||
| 93 | if(addr == MAP_FAILED){ | ||
| 94 | err = errno; | ||
| 95 | perror("failed"); | ||
| 96 | if(err == EPERM) | ||
| 97 | printf("/tmp must be not mounted noexec\n"); | ||
| 98 | exit(1); | ||
| 99 | } | ||
| 100 | printf("OK\n"); | ||
| 101 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
| 102 | |||
| 103 | os_close_file(fd); | ||
| 104 | } | ||
| 105 | |||
| 106 | static int have_devanon = 0; | ||
| 107 | |||
| 108 | void check_devanon(void) | ||
| 109 | { | ||
| 110 | int fd; | ||
| 111 | |||
| 112 | printk("Checking for /dev/anon on the host..."); | ||
| 113 | fd = open("/dev/anon", O_RDWR); | ||
| 114 | if(fd < 0){ | ||
| 115 | printk("Not available (open failed with errno %d)\n", errno); | ||
| 116 | return; | ||
| 117 | } | ||
| 118 | |||
| 119 | printk("OK\n"); | ||
| 120 | have_devanon = 1; | ||
| 121 | } | ||
| 122 | |||
| 123 | static int create_anon_file(unsigned long len) | ||
| 124 | { | ||
| 125 | void *addr; | ||
| 126 | int fd; | ||
| 127 | |||
| 128 | fd = open("/dev/anon", O_RDWR); | ||
| 129 | if(fd < 0) { | ||
| 130 | os_print_error(fd, "opening /dev/anon"); | ||
| 131 | exit(1); | ||
| 132 | } | ||
| 133 | |||
| 134 | addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); | ||
| 135 | if(addr == MAP_FAILED){ | ||
| 136 | perror("mapping physmem file"); | ||
| 137 | exit(1); | ||
| 138 | } | ||
| 139 | munmap(addr, len); | ||
| 140 | |||
| 141 | return(fd); | ||
| 142 | } | ||
| 143 | |||
| 144 | int create_mem_file(unsigned long len) | ||
| 145 | { | ||
| 146 | int err, fd; | ||
| 147 | |||
| 148 | if(have_devanon) | ||
| 149 | fd = create_anon_file(len); | ||
| 150 | else fd = create_tmp_file(len); | ||
| 151 | |||
| 152 | err = os_set_exec_close(fd, 1); | ||
| 153 | if(err < 0) | ||
| 154 | os_print_error(err, "exec_close"); | ||
| 155 | return(fd); | ||
| 156 | } | ||
| 157 | |||
| 158 | struct iomem_region *iomem_regions = NULL; | ||
| 159 | int iomem_size = 0; | ||
| 160 | |||
| 161 | static int __init parse_iomem(char *str, int *add) | ||
| 162 | { | ||
| 163 | struct iomem_region *new; | ||
| 164 | struct uml_stat buf; | ||
| 165 | char *file, *driver; | ||
| 166 | int fd, err, size; | ||
| 167 | |||
| 168 | driver = str; | ||
| 169 | file = strchr(str,','); | ||
| 170 | if(file == NULL){ | ||
| 171 | printf("parse_iomem : failed to parse iomem\n"); | ||
| 172 | goto out; | ||
| 173 | } | ||
| 174 | *file = '\0'; | ||
| 175 | file++; | ||
| 176 | fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0); | ||
| 177 | if(fd < 0){ | ||
| 178 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | ||
| 179 | goto out; | ||
| 180 | } | ||
| 181 | |||
| 182 | err = os_stat_fd(fd, &buf); | ||
| 183 | if(err < 0){ | ||
| 184 | os_print_error(err, "parse_iomem - cannot stat_fd file"); | ||
| 185 | goto out_close; | ||
| 186 | } | ||
| 187 | |||
| 188 | new = malloc(sizeof(*new)); | ||
| 189 | if(new == NULL){ | ||
| 190 | perror("Couldn't allocate iomem_region struct"); | ||
| 191 | goto out_close; | ||
| 192 | } | ||
| 193 | |||
| 194 | size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1); | ||
| 195 | |||
| 196 | *new = ((struct iomem_region) { .next = iomem_regions, | ||
| 197 | .driver = driver, | ||
| 198 | .fd = fd, | ||
| 199 | .size = size, | ||
| 200 | .phys = 0, | ||
| 201 | .virt = 0 }); | ||
| 202 | iomem_regions = new; | ||
| 203 | iomem_size += new->size + UM_KERN_PAGE_SIZE; | ||
| 204 | |||
| 205 | return(0); | ||
| 206 | out_close: | ||
| 207 | os_close_file(fd); | ||
| 208 | out: | ||
| 209 | return(1); | ||
| 210 | } | ||
| 211 | |||
| 212 | __uml_setup("iomem=", parse_iomem, | ||
| 213 | "iomem=<name>,<file>\n" | ||
| 214 | " Configure <file> as an IO memory region named <name>.\n\n" | ||
| 215 | ); | ||
| 216 | |||
| 217 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, | ||
| 218 | int must_succeed) | ||
| 219 | { | ||
| 220 | int err; | ||
| 221 | |||
| 222 | err = os_protect_memory((void *) addr, len, r, w, x); | ||
| 223 | if(err < 0){ | ||
| 224 | if(must_succeed) | ||
| 225 | panic("protect failed, err = %d", -err); | ||
| 226 | else return(err); | ||
| 227 | } | ||
| 228 | return(0); | ||
| 229 | } | ||
| 230 | |||
| 231 | #if 0 | ||
| 232 | /* Debugging facility for dumping stuff out to the host, avoiding the timing | ||
| 233 | * problems that come with printf and breakpoints. | ||
| 234 | * Enable in case of emergency. | ||
| 235 | */ | ||
| 236 | |||
| 237 | int logging = 1; | ||
| 238 | int logging_fd = -1; | ||
| 239 | |||
| 240 | int logging_line = 0; | ||
| 241 | char logging_buf[512]; | ||
| 242 | |||
| 243 | void log(char *fmt, ...) | ||
| 244 | { | ||
| 245 | va_list ap; | ||
| 246 | struct timeval tv; | ||
| 247 | struct openflags flags; | ||
| 248 | |||
| 249 | if(logging == 0) return; | ||
| 250 | if(logging_fd < 0){ | ||
| 251 | flags = of_create(of_trunc(of_rdwr(OPENFLAGS()))); | ||
| 252 | logging_fd = os_open_file("log", flags, 0644); | ||
| 253 | } | ||
| 254 | gettimeofday(&tv, NULL); | ||
| 255 | sprintf(logging_buf, "%d\t %u.%u ", logging_line++, tv.tv_sec, | ||
| 256 | tv.tv_usec); | ||
| 257 | va_start(ap, fmt); | ||
| 258 | vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap); | ||
| 259 | va_end(ap); | ||
| 260 | write(logging_fd, logging_buf, strlen(logging_buf)); | ||
| 261 | } | ||
| 262 | #endif | ||
| 263 | |||
| 264 | /* | ||
| 265 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 266 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 267 | * adjust the settings for this buffer only. This must remain at the end | ||
| 268 | * of the file. | ||
| 269 | * --------------------------------------------------------------------------- | ||
| 270 | * Local variables: | ||
| 271 | * c-file-style: "linux" | ||
| 272 | * End: | ||
| 273 | */ | ||
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index c23d8a08d0ff..39cf568ccfaf 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
| @@ -113,8 +113,23 @@ void set_current(void *t) | |||
| 113 | 113 | ||
| 114 | void *_switch_to(void *prev, void *next, void *last) | 114 | void *_switch_to(void *prev, void *next, void *last) |
| 115 | { | 115 | { |
| 116 | return(CHOOSE_MODE(switch_to_tt(prev, next), | 116 | struct task_struct *from = prev; |
| 117 | switch_to_skas(prev, next))); | 117 | struct task_struct *to= next; |
| 118 | |||
| 119 | to->thread.prev_sched = from; | ||
| 120 | set_current(to); | ||
| 121 | |||
| 122 | do { | ||
| 123 | current->thread.saved_task = NULL ; | ||
| 124 | CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next); | ||
| 125 | if(current->thread.saved_task) | ||
| 126 | show_regs(&(current->thread.regs)); | ||
| 127 | next= current->thread.saved_task; | ||
| 128 | prev= current; | ||
| 129 | } while(current->thread.saved_task); | ||
| 130 | |||
| 131 | return(current->thread.prev_sched); | ||
| 132 | |||
| 118 | } | 133 | } |
| 119 | 134 | ||
| 120 | void interrupt_end(void) | 135 | void interrupt_end(void) |
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h index e48490028111..c97a80dfe370 100644 --- a/arch/um/kernel/skas/include/mode_kern-skas.h +++ b/arch/um/kernel/skas/include/mode_kern-skas.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
| 12 | 12 | ||
| 13 | extern void flush_thread_skas(void); | 13 | extern void flush_thread_skas(void); |
| 14 | extern void *switch_to_skas(void *prev, void *next); | 14 | extern void switch_to_skas(void *prev, void *next); |
| 15 | extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, | 15 | extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, |
| 16 | unsigned long esp); | 16 | unsigned long esp); |
| 17 | extern int copy_thread_skas(int nr, unsigned long clone_flags, | 17 | extern int copy_thread_skas(int nr, unsigned long clone_flags, |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index 3d1b227226e6..efe92e8aa2a9 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #include "proc_mm.h" | 24 | #include "proc_mm.h" |
| 25 | #include "registers.h" | 25 | #include "registers.h" |
| 26 | 26 | ||
| 27 | void *switch_to_skas(void *prev, void *next) | 27 | void switch_to_skas(void *prev, void *next) |
| 28 | { | 28 | { |
| 29 | struct task_struct *from, *to; | 29 | struct task_struct *from, *to; |
| 30 | 30 | ||
| @@ -35,16 +35,11 @@ void *switch_to_skas(void *prev, void *next) | |||
| 35 | if(current->pid == 0) | 35 | if(current->pid == 0) |
| 36 | switch_timers(0); | 36 | switch_timers(0); |
| 37 | 37 | ||
| 38 | to->thread.prev_sched = from; | ||
| 39 | set_current(to); | ||
| 40 | |||
| 41 | switch_threads(&from->thread.mode.skas.switch_buf, | 38 | switch_threads(&from->thread.mode.skas.switch_buf, |
| 42 | to->thread.mode.skas.switch_buf); | 39 | to->thread.mode.skas.switch_buf); |
| 43 | 40 | ||
| 44 | if(current->pid == 0) | 41 | if(current->pid == 0) |
| 45 | switch_timers(1); | 42 | switch_timers(1); |
| 46 | |||
| 47 | return(current->thread.prev_sched); | ||
| 48 | } | 43 | } |
| 49 | 44 | ||
| 50 | extern void schedule_tail(struct task_struct *prev); | 45 | extern void schedule_tail(struct task_struct *prev); |
diff --git a/arch/um/kernel/tempfile.c b/arch/um/kernel/tempfile.c deleted file mode 100644 index b1674bc1395d..000000000000 --- a/arch/um/kernel/tempfile.c +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <stdio.h> | ||
| 7 | #include <stdlib.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | #include <string.h> | ||
| 10 | #include <errno.h> | ||
| 11 | #include <sys/param.h> | ||
| 12 | #include "init.h" | ||
| 13 | |||
| 14 | /* Modified from create_mem_file and start_debugger */ | ||
| 15 | static char *tempdir = NULL; | ||
| 16 | |||
| 17 | static void __init find_tempdir(void) | ||
| 18 | { | ||
| 19 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | ||
| 20 | int i; | ||
| 21 | char *dir = NULL; | ||
| 22 | |||
| 23 | if(tempdir != NULL) return; /* We've already been called */ | ||
| 24 | for(i = 0; dirs[i]; i++){ | ||
| 25 | dir = getenv(dirs[i]); | ||
| 26 | if((dir != NULL) && (*dir != '\0')) | ||
| 27 | break; | ||
| 28 | } | ||
| 29 | if((dir == NULL) || (*dir == '\0')) | ||
| 30 | dir = "/tmp"; | ||
| 31 | |||
| 32 | tempdir = malloc(strlen(dir) + 2); | ||
| 33 | if(tempdir == NULL){ | ||
| 34 | fprintf(stderr, "Failed to malloc tempdir, " | ||
| 35 | "errno = %d\n", errno); | ||
| 36 | return; | ||
| 37 | } | ||
| 38 | strcpy(tempdir, dir); | ||
| 39 | strcat(tempdir, "/"); | ||
| 40 | } | ||
| 41 | |||
| 42 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | ||
| 43 | { | ||
| 44 | char tempname[MAXPATHLEN]; | ||
| 45 | int fd; | ||
| 46 | |||
| 47 | find_tempdir(); | ||
| 48 | if (*template != '/') | ||
| 49 | strcpy(tempname, tempdir); | ||
| 50 | else | ||
| 51 | *tempname = 0; | ||
| 52 | strcat(tempname, template); | ||
| 53 | fd = mkstemp(tempname); | ||
| 54 | if(fd < 0){ | ||
| 55 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | ||
| 56 | strerror(errno)); | ||
| 57 | return -1; | ||
| 58 | } | ||
| 59 | if(do_unlink && (unlink(tempname) < 0)){ | ||
| 60 | perror("unlink"); | ||
| 61 | return -1; | ||
| 62 | } | ||
| 63 | if(out_tempname){ | ||
| 64 | *out_tempname = strdup(tempname); | ||
| 65 | if(*out_tempname == NULL){ | ||
| 66 | perror("strdup"); | ||
| 67 | return -1; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | return(fd); | ||
| 71 | } | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 75 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 76 | * adjust the settings for this buffer only. This must remain at the end | ||
| 77 | * of the file. | ||
| 78 | * --------------------------------------------------------------------------- | ||
| 79 | * Local variables: | ||
| 80 | * c-file-style: "linux" | ||
| 81 | * End: | ||
| 82 | */ | ||
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index 80ed6188e8a2..0a562c3c0fd8 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c | |||
| @@ -307,7 +307,7 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end) | |||
| 307 | } | 307 | } |
| 308 | else if(pte_newprot(*pte)){ | 308 | else if(pte_newprot(*pte)){ |
| 309 | updated = 1; | 309 | updated = 1; |
| 310 | protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1); | 310 | os_protect_memory((void *) addr, PAGE_SIZE, 1, 1, 1); |
| 311 | } | 311 | } |
| 312 | addr += PAGE_SIZE; | 312 | addr += PAGE_SIZE; |
| 313 | } | 313 | } |
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h index e0ca0e0b2516..2a35b15c5fef 100644 --- a/arch/um/kernel/tt/include/mode_kern-tt.h +++ b/arch/um/kernel/tt/include/mode_kern-tt.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
| 12 | #include "asm/uaccess.h" | 12 | #include "asm/uaccess.h" |
| 13 | 13 | ||
| 14 | extern void *switch_to_tt(void *prev, void *next); | 14 | extern void switch_to_tt(void *prev, void *next); |
| 15 | extern void flush_thread_tt(void); | 15 | extern void flush_thread_tt(void); |
| 16 | extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, | 16 | extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, |
| 17 | unsigned long esp); | 17 | unsigned long esp); |
diff --git a/arch/um/kernel/tt/mem_user.c b/arch/um/kernel/tt/mem_user.c index 3085267459b1..03e589895388 100644 --- a/arch/um/kernel/tt/mem_user.c +++ b/arch/um/kernel/tt/mem_user.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "tt.h" | 12 | #include "tt.h" |
| 13 | #include "mem_user.h" | 13 | #include "mem_user.h" |
| 14 | #include "user_util.h" | 14 | #include "user_util.h" |
| 15 | #include "os.h" | ||
| 15 | 16 | ||
| 16 | void remap_data(void *segment_start, void *segment_end, int w) | 17 | void remap_data(void *segment_start, void *segment_end, int w) |
| 17 | { | 18 | { |
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c index a189a2b92935..0de05a268b22 100644 --- a/arch/um/kernel/tt/process_kern.c +++ b/arch/um/kernel/tt/process_kern.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | #include "init.h" | 26 | #include "init.h" |
| 27 | #include "tt.h" | 27 | #include "tt.h" |
| 28 | 28 | ||
| 29 | void *switch_to_tt(void *prev, void *next, void *last) | 29 | int switch_to_tt(void *prev, void *next, void *last) |
| 30 | { | 30 | { |
| 31 | struct task_struct *from, *to, *prev_sched; | 31 | struct task_struct *from, *to, *prev_sched; |
| 32 | unsigned long flags; | 32 | unsigned long flags; |
| @@ -36,8 +36,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
| 36 | from = prev; | 36 | from = prev; |
| 37 | to = next; | 37 | to = next; |
| 38 | 38 | ||
| 39 | to->thread.prev_sched = from; | ||
| 40 | |||
| 41 | cpu = from->thread_info->cpu; | 39 | cpu = from->thread_info->cpu; |
| 42 | if(cpu == 0) | 40 | if(cpu == 0) |
| 43 | forward_interrupts(to->thread.mode.tt.extern_pid); | 41 | forward_interrupts(to->thread.mode.tt.extern_pid); |
| @@ -53,7 +51,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
| 53 | forward_pending_sigio(to->thread.mode.tt.extern_pid); | 51 | forward_pending_sigio(to->thread.mode.tt.extern_pid); |
| 54 | 52 | ||
| 55 | c = 0; | 53 | c = 0; |
| 56 | set_current(to); | ||
| 57 | 54 | ||
| 58 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); | 55 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); |
| 59 | if(err != sizeof(c)) | 56 | if(err != sizeof(c)) |
| @@ -85,8 +82,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
| 85 | 82 | ||
| 86 | flush_tlb_all(); | 83 | flush_tlb_all(); |
| 87 | local_irq_restore(flags); | 84 | local_irq_restore(flags); |
| 88 | |||
| 89 | return(current->thread.prev_sched); | ||
| 90 | } | 85 | } |
| 91 | 86 | ||
| 92 | void release_thread_tt(struct task_struct *task) | 87 | void release_thread_tt(struct task_struct *task) |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 09f6f7ce4695..f0a275947d34 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
| @@ -361,11 +361,6 @@ int linux_main(int argc, char **argv) | |||
| 361 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, | 361 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, |
| 362 | &host_task_size, &task_size); | 362 | &host_task_size, &task_size); |
| 363 | 363 | ||
| 364 | /* Need to check this early because mmapping happens before the | ||
| 365 | * kernel is running. | ||
| 366 | */ | ||
| 367 | check_tmpexec(); | ||
| 368 | |||
| 369 | brk_start = (unsigned long) sbrk(0); | 364 | brk_start = (unsigned long) sbrk(0); |
| 370 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); | 365 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); |
| 371 | /* Increase physical memory size for exec-shield users | 366 | /* Increase physical memory size for exec-shield users |
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c index 954ff67cc8b3..a25f3ea11fd7 100644 --- a/arch/um/kernel/user_util.c +++ b/arch/um/kernel/user_util.c | |||
| @@ -109,18 +109,14 @@ int raw(int fd) | |||
| 109 | int err; | 109 | int err; |
| 110 | 110 | ||
| 111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); | 111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); |
| 112 | if (err < 0) { | 112 | if(err < 0) |
| 113 | printk("tcgetattr failed, errno = %d\n", errno); | 113 | return -errno; |
| 114 | return(-errno); | ||
| 115 | } | ||
| 116 | 114 | ||
| 117 | cfmakeraw(&tt); | 115 | cfmakeraw(&tt); |
| 118 | 116 | ||
| 119 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); | 117 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); |
| 120 | if (err < 0) { | 118 | if(err < 0) |
| 121 | printk("tcsetattr failed, errno = %d\n", errno); | 119 | return -errno; |
| 122 | return(-errno); | ||
| 123 | } | ||
| 124 | 120 | ||
| 125 | /* XXX tcsetattr could have applied only some changes | 121 | /* XXX tcsetattr could have applied only some changes |
| 126 | * (and cfmakeraw() is a set of changes) */ | 122 | * (and cfmakeraw() is a set of changes) */ |
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 7a1662419c0c..d15ec2af6a22 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile | |||
| @@ -3,11 +3,11 @@ | |||
| 3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | obj-y = aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \ | 6 | obj-y = aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o time.o \ |
| 7 | tty.o user_syms.o drivers/ sys-$(SUBARCH)/ | 7 | tt.o tty.o user_syms.o drivers/ sys-$(SUBARCH)/ |
| 8 | 8 | ||
| 9 | USER_OBJS := aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \ | 9 | USER_OBJS := aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o \ |
| 10 | tty.o | 10 | time.o tt.o tty.o |
| 11 | 11 | ||
| 12 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h | 12 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h |
| 13 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um | 13 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um |
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index b04897cd995d..298d5632128b 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c | |||
| @@ -117,6 +117,8 @@ static int do_aio(aio_context_t ctx, struct aio_context *aio) | |||
| 117 | err = io_submit(ctx, 1, &iocbp); | 117 | err = io_submit(ctx, 1, &iocbp); |
| 118 | if(err > 0) | 118 | if(err > 0) |
| 119 | err = 0; | 119 | err = 0; |
| 120 | else | ||
| 121 | err = -errno; | ||
| 120 | 122 | ||
| 121 | out: | 123 | out: |
| 122 | return err; | 124 | return err; |
| @@ -142,7 +144,7 @@ static int aio_thread(void *arg) | |||
| 142 | "errno = %d\n", errno); | 144 | "errno = %d\n", errno); |
| 143 | } | 145 | } |
| 144 | else { | 146 | else { |
| 145 | aio = (struct aio_context *) event.data; | 147 | aio = (struct aio_context *) (long) event.data; |
| 146 | if(update_aio(aio, event.res)){ | 148 | if(update_aio(aio, event.res)){ |
| 147 | do_aio(ctx, aio); | 149 | do_aio(ctx, aio); |
| 148 | continue; | 150 | continue; |
| @@ -313,15 +315,16 @@ static int init_aio_26(void) | |||
| 313 | int err; | 315 | int err; |
| 314 | 316 | ||
| 315 | if(io_setup(256, &ctx)){ | 317 | if(io_setup(256, &ctx)){ |
| 318 | err = -errno; | ||
| 316 | printk("aio_thread failed to initialize context, err = %d\n", | 319 | printk("aio_thread failed to initialize context, err = %d\n", |
| 317 | errno); | 320 | errno); |
| 318 | return -errno; | 321 | return err; |
| 319 | } | 322 | } |
| 320 | 323 | ||
| 321 | err = run_helper_thread(aio_thread, NULL, | 324 | err = run_helper_thread(aio_thread, NULL, |
| 322 | CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); | 325 | CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); |
| 323 | if(err < 0) | 326 | if(err < 0) |
| 324 | return -errno; | 327 | return err; |
| 325 | 328 | ||
| 326 | aio_pid = err; | 329 | aio_pid = err; |
| 327 | 330 | ||
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 4b83c6c3f48d..4ba9b17adf13 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c | |||
| @@ -75,7 +75,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
| 75 | struct msghdr msg; | 75 | struct msghdr msg; |
| 76 | struct cmsghdr *cmsg; | 76 | struct cmsghdr *cmsg; |
| 77 | struct iovec iov; | 77 | struct iovec iov; |
| 78 | int pid, n; | 78 | int pid, n, err; |
| 79 | 79 | ||
| 80 | sprintf(version_buf, "%d", UML_NET_VERSION); | 80 | sprintf(version_buf, "%d", UML_NET_VERSION); |
| 81 | 81 | ||
| @@ -105,9 +105,10 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
| 105 | n = recvmsg(me, &msg, 0); | 105 | n = recvmsg(me, &msg, 0); |
| 106 | *used_out = n; | 106 | *used_out = n; |
| 107 | if(n < 0){ | 107 | if(n < 0){ |
| 108 | err = -errno; | ||
| 108 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", | 109 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", |
| 109 | errno); | 110 | errno); |
| 110 | return(-errno); | 111 | return err; |
| 111 | } | 112 | } |
| 112 | CATCH_EINTR(waitpid(pid, NULL, 0)); | 113 | CATCH_EINTR(waitpid(pid, NULL, 0)); |
| 113 | 114 | ||
| @@ -147,9 +148,10 @@ static int tuntap_open(void *data) | |||
| 147 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; | 148 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; |
| 148 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); | 149 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); |
| 149 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ | 150 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ |
| 151 | err = -errno; | ||
| 150 | printk("TUNSETIFF failed, errno = %d\n", errno); | 152 | printk("TUNSETIFF failed, errno = %d\n", errno); |
| 151 | os_close_file(pri->fd); | 153 | os_close_file(pri->fd); |
| 152 | return(-errno); | 154 | return err; |
| 153 | } | 155 | } |
| 154 | } | 156 | } |
| 155 | else { | 157 | else { |
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index 1399520a8588..e770cb029578 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c | |||
| @@ -54,7 +54,8 @@ __init void scan_elf_aux( char **envp) | |||
| 54 | * a_un, so we have to use a_val, which is | 54 | * a_un, so we have to use a_val, which is |
| 55 | * all that's left. | 55 | * all that's left. |
| 56 | */ | 56 | */ |
| 57 | elf_aux_platform = (char *) auxv->a_un.a_val; | 57 | elf_aux_platform = |
| 58 | (char *) (long) auxv->a_un.a_val; | ||
| 58 | break; | 59 | break; |
| 59 | case AT_PAGESZ: | 60 | case AT_PAGESZ: |
| 60 | page_size = auxv->a_un.a_val; | 61 | page_size = auxv->a_un.a_val; |
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index fd45bb260907..f55773c819e6 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
| @@ -119,15 +119,11 @@ int os_window_size(int fd, int *rows, int *cols) | |||
| 119 | 119 | ||
| 120 | int os_new_tty_pgrp(int fd, int pid) | 120 | int os_new_tty_pgrp(int fd, int pid) |
| 121 | { | 121 | { |
| 122 | if(ioctl(fd, TIOCSCTTY, 0) < 0){ | 122 | if(ioctl(fd, TIOCSCTTY, 0) < 0) |
| 123 | printk("TIOCSCTTY failed, errno = %d\n", errno); | 123 | return -errno; |
| 124 | return(-errno); | ||
| 125 | } | ||
| 126 | 124 | ||
| 127 | if(tcsetpgrp(fd, pid) < 0){ | 125 | if(tcsetpgrp(fd, pid) < 0) |
| 128 | printk("tcsetpgrp failed, errno = %d\n", errno); | 126 | return -errno; |
| 129 | return(-errno); | ||
| 130 | } | ||
| 131 | 127 | ||
| 132 | return(0); | 128 | return(0); |
| 133 | } | 129 | } |
| @@ -146,18 +142,12 @@ int os_set_slip(int fd) | |||
| 146 | int disc, sencap; | 142 | int disc, sencap; |
| 147 | 143 | ||
| 148 | disc = N_SLIP; | 144 | disc = N_SLIP; |
| 149 | if(ioctl(fd, TIOCSETD, &disc) < 0){ | 145 | if(ioctl(fd, TIOCSETD, &disc) < 0) |
| 150 | printk("Failed to set slip line discipline - " | 146 | return -errno; |
| 151 | "errno = %d\n", errno); | ||
| 152 | return(-errno); | ||
| 153 | } | ||
| 154 | 147 | ||
| 155 | sencap = 0; | 148 | sencap = 0; |
| 156 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0){ | 149 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) |
| 157 | printk("Failed to set slip encapsulation - " | 150 | return -errno; |
| 158 | "errno = %d\n", errno); | ||
| 159 | return(-errno); | ||
| 160 | } | ||
| 161 | 151 | ||
| 162 | return(0); | 152 | return(0); |
| 163 | } | 153 | } |
| @@ -180,22 +170,15 @@ int os_sigio_async(int master, int slave) | |||
| 180 | int flags; | 170 | int flags; |
| 181 | 171 | ||
| 182 | flags = fcntl(master, F_GETFL); | 172 | flags = fcntl(master, F_GETFL); |
| 183 | if(flags < 0) { | 173 | if(flags < 0) |
| 184 | printk("fcntl F_GETFL failed, errno = %d\n", errno); | 174 | return errno; |
| 185 | return(-errno); | ||
| 186 | } | ||
| 187 | 175 | ||
| 188 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || | 176 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || |
| 189 | (fcntl(master, F_SETOWN, os_getpid()) < 0)){ | 177 | (fcntl(master, F_SETOWN, os_getpid()) < 0)) |
| 190 | printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", | 178 | return -errno; |
| 191 | errno); | ||
| 192 | return(-errno); | ||
| 193 | } | ||
| 194 | 179 | ||
| 195 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)){ | 180 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)) |
| 196 | printk("fcntl F_SETFL failed, errno = %d\n", errno); | 181 | return -errno; |
| 197 | return(-errno); | ||
| 198 | } | ||
| 199 | 182 | ||
| 200 | return(0); | 183 | return(0); |
| 201 | } | 184 | } |
| @@ -255,7 +238,7 @@ int os_file_mode(char *file, struct openflags *mode_out) | |||
| 255 | 238 | ||
| 256 | int os_open_file(char *file, struct openflags flags, int mode) | 239 | int os_open_file(char *file, struct openflags flags, int mode) |
| 257 | { | 240 | { |
| 258 | int fd, f = 0; | 241 | int fd, err, f = 0; |
| 259 | 242 | ||
| 260 | if(flags.r && flags.w) f = O_RDWR; | 243 | if(flags.r && flags.w) f = O_RDWR; |
| 261 | else if(flags.r) f = O_RDONLY; | 244 | else if(flags.r) f = O_RDONLY; |
| @@ -272,8 +255,9 @@ int os_open_file(char *file, struct openflags flags, int mode) | |||
| 272 | return(-errno); | 255 | return(-errno); |
| 273 | 256 | ||
| 274 | if(flags.cl && fcntl(fd, F_SETFD, 1)){ | 257 | if(flags.cl && fcntl(fd, F_SETFD, 1)){ |
| 258 | err = -errno; | ||
| 275 | os_close_file(fd); | 259 | os_close_file(fd); |
| 276 | return(-errno); | 260 | return err; |
| 277 | } | 261 | } |
| 278 | 262 | ||
| 279 | return(fd); | 263 | return(fd); |
| @@ -383,9 +367,9 @@ int os_file_size(char *file, unsigned long long *size_out) | |||
| 383 | return(fd); | 367 | return(fd); |
| 384 | } | 368 | } |
| 385 | if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ | 369 | if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ |
| 370 | err = -errno; | ||
| 386 | printk("Couldn't get the block size of \"%s\", " | 371 | printk("Couldn't get the block size of \"%s\", " |
| 387 | "errno = %d\n", file, errno); | 372 | "errno = %d\n", file, errno); |
| 388 | err = -errno; | ||
| 389 | os_close_file(fd); | 373 | os_close_file(fd); |
| 390 | return(err); | 374 | return(err); |
| 391 | } | 375 | } |
| @@ -473,11 +457,14 @@ int os_pipe(int *fds, int stream, int close_on_exec) | |||
| 473 | 457 | ||
| 474 | int os_set_fd_async(int fd, int owner) | 458 | int os_set_fd_async(int fd, int owner) |
| 475 | { | 459 | { |
| 460 | int err; | ||
| 461 | |||
| 476 | /* XXX This should do F_GETFL first */ | 462 | /* XXX This should do F_GETFL first */ |
| 477 | if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ | 463 | if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ |
| 464 | err = -errno; | ||
| 478 | printk("os_set_fd_async : failed to set O_ASYNC and " | 465 | printk("os_set_fd_async : failed to set O_ASYNC and " |
| 479 | "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); | 466 | "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); |
| 480 | return(-errno); | 467 | return err; |
| 481 | } | 468 | } |
| 482 | #ifdef notdef | 469 | #ifdef notdef |
| 483 | if(fcntl(fd, F_SETFD, 1) < 0){ | 470 | if(fcntl(fd, F_SETFD, 1) < 0){ |
| @@ -488,10 +475,11 @@ int os_set_fd_async(int fd, int owner) | |||
| 488 | 475 | ||
| 489 | if((fcntl(fd, F_SETSIG, SIGIO) < 0) || | 476 | if((fcntl(fd, F_SETSIG, SIGIO) < 0) || |
| 490 | (fcntl(fd, F_SETOWN, owner) < 0)){ | 477 | (fcntl(fd, F_SETOWN, owner) < 0)){ |
| 478 | err = -errno; | ||
| 491 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " | 479 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " |
| 492 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, | 480 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, |
| 493 | owner, errno); | 481 | owner, errno); |
| 494 | return(-errno); | 482 | return err; |
| 495 | } | 483 | } |
| 496 | 484 | ||
| 497 | return(0); | 485 | return(0); |
| @@ -516,11 +504,9 @@ int os_set_fd_block(int fd, int blocking) | |||
| 516 | if(blocking) flags &= ~O_NONBLOCK; | 504 | if(blocking) flags &= ~O_NONBLOCK; |
| 517 | else flags |= O_NONBLOCK; | 505 | else flags |= O_NONBLOCK; |
| 518 | 506 | ||
| 519 | if(fcntl(fd, F_SETFL, flags) < 0){ | 507 | if(fcntl(fd, F_SETFL, flags) < 0) |
| 520 | printk("Failed to change blocking on fd # %d, errno = %d\n", | 508 | return -errno; |
| 521 | fd, errno); | 509 | |
| 522 | return(-errno); | ||
| 523 | } | ||
| 524 | return(0); | 510 | return(0); |
| 525 | } | 511 | } |
| 526 | 512 | ||
| @@ -609,11 +595,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
| 609 | int sock, err; | 595 | int sock, err; |
| 610 | 596 | ||
| 611 | sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 597 | sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
| 612 | if (sock < 0){ | 598 | if(sock < 0) |
| 613 | printk("create_unix_socket - socket failed, errno = %d\n", | 599 | return -errno; |
| 614 | errno); | ||
| 615 | return(-errno); | ||
| 616 | } | ||
| 617 | 600 | ||
| 618 | if(close_on_exec) { | 601 | if(close_on_exec) { |
| 619 | err = os_set_exec_close(sock, 1); | 602 | err = os_set_exec_close(sock, 1); |
| @@ -628,11 +611,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
| 628 | snprintf(addr.sun_path, len, "%s", file); | 611 | snprintf(addr.sun_path, len, "%s", file); |
| 629 | 612 | ||
| 630 | err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); | 613 | err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); |
| 631 | if (err < 0){ | 614 | if(err < 0) |
| 632 | printk("create_listening_socket at '%s' - bind failed, " | 615 | return -errno; |
| 633 | "errno = %d\n", file, errno); | ||
| 634 | return(-errno); | ||
| 635 | } | ||
| 636 | 616 | ||
| 637 | return(sock); | 617 | return(sock); |
| 638 | } | 618 | } |
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c new file mode 100644 index 000000000000..8e71edaaf80b --- /dev/null +++ b/arch/um/os-Linux/mem.c | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <stddef.h> | ||
| 4 | #include <stdarg.h> | ||
| 5 | #include <unistd.h> | ||
| 6 | #include <errno.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include <fcntl.h> | ||
| 9 | #include <sys/types.h> | ||
| 10 | #include <sys/mman.h> | ||
| 11 | #include "kern_util.h" | ||
| 12 | #include "user.h" | ||
| 13 | #include "user_util.h" | ||
| 14 | #include "mem_user.h" | ||
| 15 | #include "init.h" | ||
| 16 | #include "os.h" | ||
| 17 | #include "tempfile.h" | ||
| 18 | #include "kern_constants.h" | ||
| 19 | |||
| 20 | #include <sys/param.h> | ||
| 21 | |||
| 22 | static char *tempdir = NULL; | ||
| 23 | |||
| 24 | static void __init find_tempdir(void) | ||
| 25 | { | ||
| 26 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | ||
| 27 | int i; | ||
| 28 | char *dir = NULL; | ||
| 29 | |||
| 30 | if(tempdir != NULL) return; /* We've already been called */ | ||
| 31 | for(i = 0; dirs[i]; i++){ | ||
| 32 | dir = getenv(dirs[i]); | ||
| 33 | if((dir != NULL) && (*dir != '\0')) | ||
| 34 | break; | ||
| 35 | } | ||
| 36 | if((dir == NULL) || (*dir == '\0')) | ||
| 37 | dir = "/tmp"; | ||
| 38 | |||
| 39 | tempdir = malloc(strlen(dir) + 2); | ||
| 40 | if(tempdir == NULL){ | ||
| 41 | fprintf(stderr, "Failed to malloc tempdir, " | ||
| 42 | "errno = %d\n", errno); | ||
| 43 | return; | ||
| 44 | } | ||
| 45 | strcpy(tempdir, dir); | ||
| 46 | strcat(tempdir, "/"); | ||
| 47 | } | ||
| 48 | |||
| 49 | /* | ||
| 50 | * This proc still used in tt-mode | ||
| 51 | * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger). | ||
| 52 | * So it isn't 'static' yet. | ||
| 53 | */ | ||
| 54 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | ||
| 55 | { | ||
| 56 | char tempname[MAXPATHLEN]; | ||
| 57 | int fd; | ||
| 58 | |||
| 59 | find_tempdir(); | ||
| 60 | if (*template != '/') | ||
| 61 | strcpy(tempname, tempdir); | ||
| 62 | else | ||
| 63 | *tempname = 0; | ||
| 64 | strcat(tempname, template); | ||
| 65 | fd = mkstemp(tempname); | ||
| 66 | if(fd < 0){ | ||
| 67 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | ||
| 68 | strerror(errno)); | ||
| 69 | return -1; | ||
| 70 | } | ||
| 71 | if(do_unlink && (unlink(tempname) < 0)){ | ||
| 72 | perror("unlink"); | ||
| 73 | return -1; | ||
| 74 | } | ||
| 75 | if(out_tempname){ | ||
| 76 | *out_tempname = strdup(tempname); | ||
| 77 | if(*out_tempname == NULL){ | ||
| 78 | perror("strdup"); | ||
| 79 | return -1; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | return(fd); | ||
| 83 | } | ||
| 84 | |||
| 85 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | ||
| 86 | |||
| 87 | /* | ||
| 88 | * This proc is used in start_up.c | ||
| 89 | * So it isn't 'static'. | ||
| 90 | */ | ||
| 91 | int create_tmp_file(unsigned long len) | ||
| 92 | { | ||
| 93 | int fd, err; | ||
| 94 | char zero; | ||
| 95 | |||
| 96 | fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); | ||
| 97 | if(fd < 0) { | ||
| 98 | exit(1); | ||
| 99 | } | ||
| 100 | |||
| 101 | err = fchmod(fd, 0777); | ||
| 102 | if(err < 0){ | ||
| 103 | perror("os_mode_fd"); | ||
| 104 | exit(1); | ||
| 105 | } | ||
| 106 | |||
| 107 | if (lseek64(fd, len, SEEK_SET) < 0) { | ||
| 108 | perror("os_seek_file"); | ||
| 109 | exit(1); | ||
| 110 | } | ||
| 111 | |||
| 112 | zero = 0; | ||
| 113 | |||
| 114 | err = os_write_file(fd, &zero, 1); | ||
| 115 | if(err != 1){ | ||
| 116 | errno = -err; | ||
| 117 | perror("os_write_file"); | ||
| 118 | exit(1); | ||
| 119 | } | ||
| 120 | |||
| 121 | return(fd); | ||
| 122 | } | ||
| 123 | |||
| 124 | static int create_anon_file(unsigned long len) | ||
| 125 | { | ||
| 126 | void *addr; | ||
| 127 | int fd; | ||
| 128 | |||
| 129 | fd = open("/dev/anon", O_RDWR); | ||
| 130 | if(fd < 0) { | ||
| 131 | perror("opening /dev/anon"); | ||
| 132 | exit(1); | ||
| 133 | } | ||
| 134 | |||
| 135 | addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); | ||
| 136 | if(addr == MAP_FAILED){ | ||
| 137 | perror("mapping physmem file"); | ||
| 138 | exit(1); | ||
| 139 | } | ||
| 140 | munmap(addr, len); | ||
| 141 | |||
| 142 | return(fd); | ||
| 143 | } | ||
| 144 | |||
| 145 | extern int have_devanon; | ||
| 146 | |||
| 147 | int create_mem_file(unsigned long len) | ||
| 148 | { | ||
| 149 | int err, fd; | ||
| 150 | |||
| 151 | if(have_devanon) | ||
| 152 | fd = create_anon_file(len); | ||
| 153 | else fd = create_tmp_file(len); | ||
| 154 | |||
| 155 | err = os_set_exec_close(fd, 1); | ||
| 156 | if(err < 0){ | ||
| 157 | errno = -err; | ||
| 158 | perror("exec_close"); | ||
| 159 | } | ||
| 160 | return(fd); | ||
| 161 | } | ||
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 040cc1472bc7..6af83171ca4e 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
| @@ -4,18 +4,22 @@ | |||
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include <stdio.h> | 6 | #include <stdio.h> |
| 7 | #include <stddef.h> | ||
| 8 | #include <stdarg.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <string.h> | ||
| 7 | #include <unistd.h> | 11 | #include <unistd.h> |
| 8 | #include <signal.h> | 12 | #include <signal.h> |
| 9 | #include <sched.h> | 13 | #include <sched.h> |
| 14 | #include <fcntl.h> | ||
| 10 | #include <errno.h> | 15 | #include <errno.h> |
| 11 | #include <stdarg.h> | ||
| 12 | #include <stdlib.h> | ||
| 13 | #include <setjmp.h> | 16 | #include <setjmp.h> |
| 14 | #include <sys/time.h> | 17 | #include <sys/time.h> |
| 15 | #include <sys/wait.h> | 18 | #include <sys/wait.h> |
| 16 | #include <sys/mman.h> | 19 | #include <sys/mman.h> |
| 17 | #include <asm/unistd.h> | 20 | #include <asm/unistd.h> |
| 18 | #include <asm/page.h> | 21 | #include <asm/page.h> |
| 22 | #include <sys/types.h> | ||
| 19 | #include "user_util.h" | 23 | #include "user_util.h" |
| 20 | #include "kern_util.h" | 24 | #include "kern_util.h" |
| 21 | #include "user.h" | 25 | #include "user.h" |
| @@ -25,6 +29,7 @@ | |||
| 25 | #include "sysdep/sigcontext.h" | 29 | #include "sysdep/sigcontext.h" |
| 26 | #include "irq_user.h" | 30 | #include "irq_user.h" |
| 27 | #include "ptrace_user.h" | 31 | #include "ptrace_user.h" |
| 32 | #include "mem_user.h" | ||
| 28 | #include "time_user.h" | 33 | #include "time_user.h" |
| 29 | #include "init.h" | 34 | #include "init.h" |
| 30 | #include "os.h" | 35 | #include "os.h" |
| @@ -32,6 +37,8 @@ | |||
| 32 | #include "choose-mode.h" | 37 | #include "choose-mode.h" |
| 33 | #include "mode.h" | 38 | #include "mode.h" |
| 34 | #include "tempfile.h" | 39 | #include "tempfile.h" |
| 40 | #include "kern_constants.h" | ||
| 41 | |||
| 35 | #ifdef UML_CONFIG_MODE_SKAS | 42 | #ifdef UML_CONFIG_MODE_SKAS |
| 36 | #include "skas.h" | 43 | #include "skas.h" |
| 37 | #include "skas_ptrace.h" | 44 | #include "skas_ptrace.h" |
| @@ -276,9 +283,38 @@ static void __init check_ptrace(void) | |||
| 276 | check_sysemu(); | 283 | check_sysemu(); |
| 277 | } | 284 | } |
| 278 | 285 | ||
| 286 | extern int create_tmp_file(unsigned long len); | ||
| 287 | |||
| 288 | static void check_tmpexec(void) | ||
| 289 | { | ||
| 290 | void *addr; | ||
| 291 | int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE); | ||
| 292 | |||
| 293 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | ||
| 294 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | ||
| 295 | printf("Checking PROT_EXEC mmap in /tmp..."); | ||
| 296 | fflush(stdout); | ||
| 297 | if(addr == MAP_FAILED){ | ||
| 298 | err = errno; | ||
| 299 | perror("failed"); | ||
| 300 | if(err == EPERM) | ||
| 301 | printf("/tmp must be not mounted noexec\n"); | ||
| 302 | exit(1); | ||
| 303 | } | ||
| 304 | printf("OK\n"); | ||
| 305 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
| 306 | |||
| 307 | close(fd); | ||
| 308 | } | ||
| 309 | |||
| 279 | void os_early_checks(void) | 310 | void os_early_checks(void) |
| 280 | { | 311 | { |
| 281 | check_ptrace(); | 312 | check_ptrace(); |
| 313 | |||
| 314 | /* Need to check this early because mmapping happens before the | ||
| 315 | * kernel is running. | ||
| 316 | */ | ||
| 317 | check_tmpexec(); | ||
| 282 | } | 318 | } |
| 283 | 319 | ||
| 284 | static int __init noprocmm_cmd_param(char *str, int* add) | 320 | static int __init noprocmm_cmd_param(char *str, int* add) |
| @@ -357,3 +393,72 @@ int can_do_skas(void) | |||
| 357 | return(0); | 393 | return(0); |
| 358 | } | 394 | } |
| 359 | #endif | 395 | #endif |
| 396 | |||
| 397 | int have_devanon = 0; | ||
| 398 | |||
| 399 | void check_devanon(void) | ||
| 400 | { | ||
| 401 | int fd; | ||
| 402 | |||
| 403 | printk("Checking for /dev/anon on the host..."); | ||
| 404 | fd = open("/dev/anon", O_RDWR); | ||
| 405 | if(fd < 0){ | ||
| 406 | printk("Not available (open failed with errno %d)\n", errno); | ||
| 407 | return; | ||
| 408 | } | ||
| 409 | |||
| 410 | printk("OK\n"); | ||
| 411 | have_devanon = 1; | ||
| 412 | } | ||
| 413 | |||
| 414 | int __init parse_iomem(char *str, int *add) | ||
| 415 | { | ||
| 416 | struct iomem_region *new; | ||
| 417 | struct uml_stat buf; | ||
| 418 | char *file, *driver; | ||
| 419 | int fd, err, size; | ||
| 420 | |||
| 421 | driver = str; | ||
| 422 | file = strchr(str,','); | ||
| 423 | if(file == NULL){ | ||
| 424 | printf("parse_iomem : failed to parse iomem\n"); | ||
| 425 | goto out; | ||
| 426 | } | ||
| 427 | *file = '\0'; | ||
| 428 | file++; | ||
| 429 | fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0); | ||
| 430 | if(fd < 0){ | ||
| 431 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | ||
| 432 | goto out; | ||
| 433 | } | ||
| 434 | |||
| 435 | err = os_stat_fd(fd, &buf); | ||
| 436 | if(err < 0){ | ||
| 437 | os_print_error(err, "parse_iomem - cannot stat_fd file"); | ||
| 438 | goto out_close; | ||
| 439 | } | ||
| 440 | |||
| 441 | new = malloc(sizeof(*new)); | ||
| 442 | if(new == NULL){ | ||
| 443 | perror("Couldn't allocate iomem_region struct"); | ||
| 444 | goto out_close; | ||
| 445 | } | ||
| 446 | |||
| 447 | size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1); | ||
| 448 | |||
| 449 | *new = ((struct iomem_region) { .next = iomem_regions, | ||
| 450 | .driver = driver, | ||
| 451 | .fd = fd, | ||
| 452 | .size = size, | ||
| 453 | .phys = 0, | ||
| 454 | .virt = 0 }); | ||
| 455 | iomem_regions = new; | ||
| 456 | iomem_size += new->size + UM_KERN_PAGE_SIZE; | ||
| 457 | |||
| 458 | return(0); | ||
| 459 | out_close: | ||
| 460 | os_close_file(fd); | ||
| 461 | out: | ||
| 462 | return(1); | ||
| 463 | } | ||
| 464 | |||
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c index 5b047ab8416a..a6db8877931a 100644 --- a/arch/um/os-Linux/tt.c +++ b/arch/um/os-Linux/tt.c | |||
| @@ -36,6 +36,20 @@ | |||
| 36 | #include "mode.h" | 36 | #include "mode.h" |
| 37 | #include "tempfile.h" | 37 | #include "tempfile.h" |
| 38 | 38 | ||
| 39 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, | ||
| 40 | int must_succeed) | ||
| 41 | { | ||
| 42 | int err; | ||
| 43 | |||
| 44 | err = os_protect_memory((void *) addr, len, r, w, x); | ||
| 45 | if(err < 0){ | ||
| 46 | if(must_succeed) | ||
| 47 | panic("protect failed, err = %d", -err); | ||
| 48 | else return(err); | ||
| 49 | } | ||
| 50 | return(0); | ||
| 51 | } | ||
| 52 | |||
| 39 | /* | 53 | /* |
| 40 | *------------------------- | 54 | *------------------------- |
| 41 | * only for tt mode (will be deleted in future...) | 55 | * only for tt mode (will be deleted in future...) |
