diff options
Diffstat (limited to 'arch/um')
50 files changed, 855 insertions, 455 deletions
diff --git a/arch/um/Kconfig b/arch/um/Kconfig index cd06ed7d842d..3b5f47c46907 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig | |||
@@ -65,6 +65,30 @@ config STATIC_LINK | |||
65 | chroot, and you disable CONFIG_MODE_TT, you probably want to say Y | 65 | chroot, and you disable CONFIG_MODE_TT, you probably want to say Y |
66 | here. | 66 | here. |
67 | 67 | ||
68 | config HOST_2G_2G | ||
69 | bool "2G/2G host address space split" | ||
70 | default n | ||
71 | depends on MODE_TT | ||
72 | help | ||
73 | This is needed when the host on which you run has a 2G/2G memory | ||
74 | split, instead of the customary 3G/1G. | ||
75 | |||
76 | Note that to enable such a host | ||
77 | configuration, which makes sense only in some cases, you need special | ||
78 | host patches. | ||
79 | |||
80 | So, if you do not know what to do here, say 'N'. | ||
81 | |||
82 | config KERNEL_HALF_GIGS | ||
83 | int "Kernel address space size (in .5G units)" | ||
84 | default "1" | ||
85 | depends on MODE_TT | ||
86 | help | ||
87 | This determines the amount of address space that UML will allocate for | ||
88 | its own, measured in half Gigabyte units. The default is 1. | ||
89 | Change this only if you need to boot UML with an unusually large amount | ||
90 | of physical memory. | ||
91 | |||
68 | config MODE_SKAS | 92 | config MODE_SKAS |
69 | bool "Separate Kernel Address Space support" | 93 | bool "Separate Kernel Address Space support" |
70 | default y | 94 | default y |
@@ -182,19 +206,6 @@ config MAGIC_SYSRQ | |||
182 | The keys are documented in <file:Documentation/sysrq.txt>. Don't say Y | 206 | The keys are documented in <file:Documentation/sysrq.txt>. Don't say Y |
183 | unless you really know what this hack does. | 207 | unless you really know what this hack does. |
184 | 208 | ||
185 | config HOST_2G_2G | ||
186 | bool "2G/2G host address space split" | ||
187 | default n | ||
188 | help | ||
189 | This is needed when the host on which you run has a 2G/2G memory | ||
190 | split, instead of the customary 3G/1G. | ||
191 | |||
192 | Note that to enable such a host | ||
193 | configuration, which makes sense only in some cases, you need special | ||
194 | host patches. | ||
195 | |||
196 | So, if you do not know what to do here, say 'N'. | ||
197 | |||
198 | config SMP | 209 | config SMP |
199 | bool "Symmetric multi-processing support (EXPERIMENTAL)" | 210 | bool "Symmetric multi-processing support (EXPERIMENTAL)" |
200 | default n | 211 | default n |
@@ -241,15 +252,6 @@ config NEST_LEVEL | |||
241 | set to the host's CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS. | 252 | set to the host's CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS. |
242 | Only change this if you are running nested UMLs. | 253 | Only change this if you are running nested UMLs. |
243 | 254 | ||
244 | config KERNEL_HALF_GIGS | ||
245 | int "Kernel address space size (in .5G units)" | ||
246 | default "1" | ||
247 | help | ||
248 | This determines the amount of address space that UML will allocate for | ||
249 | its own, measured in half Gigabyte units. The default is 1. | ||
250 | Change this only if you need to boot UML with an unusually large amount | ||
251 | of physical memory. | ||
252 | |||
253 | config HIGHMEM | 255 | config HIGHMEM |
254 | bool "Highmem support" | 256 | bool "Highmem support" |
255 | depends on !64BIT | 257 | depends on !64BIT |
diff --git a/arch/um/Makefile b/arch/um/Makefile index e1ffad224605..e55d32e903bc 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -60,7 +60,7 @@ AFLAGS += $(ARCH_INCLUDE) | |||
60 | 60 | ||
61 | USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) | 61 | USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) |
62 | USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \ | 62 | USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \ |
63 | $(MODE_INCLUDE) | 63 | $(MODE_INCLUDE) -D_FILE_OFFSET_BITS=64 |
64 | 64 | ||
65 | # -Derrno=kernel_errno - This turns all kernel references to errno into | 65 | # -Derrno=kernel_errno - This turns all kernel references to errno into |
66 | # kernel_errno to separate them from the libc errno. This allows -fno-common | 66 | # kernel_errno to separate them from the libc errno. This allows -fno-common |
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386 index aef7c50f8e13..1f7dcb064aee 100644 --- a/arch/um/Makefile-i386 +++ b/arch/um/Makefile-i386 | |||
@@ -17,8 +17,6 @@ ifeq ("$(origin SUBARCH)", "command line") | |||
17 | ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") | 17 | ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") |
18 | CFLAGS += $(call cc-option,-m32) | 18 | CFLAGS += $(call cc-option,-m32) |
19 | USER_CFLAGS += $(call cc-option,-m32) | 19 | USER_CFLAGS += $(call cc-option,-m32) |
20 | HOSTCFLAGS += $(call cc-option,-m32) | ||
21 | HOSTLDFLAGS += $(call cc-option,-m32) | ||
22 | AFLAGS += $(call cc-option,-m32) | 20 | AFLAGS += $(call cc-option,-m32) |
23 | LINK-y += $(call cc-option,-m32) | 21 | LINK-y += $(call cc-option,-m32) |
24 | UML_OBJCOPYFLAGS += -F $(ELF_FORMAT) | 22 | UML_OBJCOPYFLAGS += -F $(ELF_FORMAT) |
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index de3bce71aeb3..1c55d5802489 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include "user_util.h" | 16 | #include "user_util.h" |
17 | #include "chan_user.h" | 17 | #include "chan_user.h" |
18 | #include "user.h" | 18 | #include "user.h" |
19 | #include "helper.h" | ||
20 | #include "os.h" | 19 | #include "os.h" |
21 | #include "choose-mode.h" | 20 | #include "choose-mode.h" |
22 | #include "mode.h" | 21 | #include "mode.h" |
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c index 147ec19f6bb9..49acb2badf32 100644 --- a/arch/um/drivers/harddog_kern.c +++ b/arch/um/drivers/harddog_kern.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include <linux/smp_lock.h> | 46 | #include <linux/smp_lock.h> |
47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
48 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
49 | #include "helper.h" | ||
50 | #include "mconsole.h" | 49 | #include "mconsole.h" |
51 | 50 | ||
52 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
diff --git a/arch/um/drivers/harddog_user.c b/arch/um/drivers/harddog_user.c index d934181b8d4c..def013b5a3c7 100644 --- a/arch/um/drivers/harddog_user.c +++ b/arch/um/drivers/harddog_user.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include "user_util.h" | 9 | #include "user_util.h" |
10 | #include "user.h" | 10 | #include "user.h" |
11 | #include "helper.h" | ||
12 | #include "mconsole.h" | 11 | #include "mconsole.h" |
13 | #include "os.h" | 12 | #include "os.h" |
14 | #include "choose-mode.h" | 13 | #include "choose-mode.h" |
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 721e2601a75d..fe865d9a3721 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
@@ -96,7 +96,6 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
96 | static int uml_net_open(struct net_device *dev) | 96 | static int uml_net_open(struct net_device *dev) |
97 | { | 97 | { |
98 | struct uml_net_private *lp = dev->priv; | 98 | struct uml_net_private *lp = dev->priv; |
99 | char addr[sizeof("255.255.255.255\0")]; | ||
100 | int err; | 99 | int err; |
101 | 100 | ||
102 | spin_lock(&lp->lock); | 101 | spin_lock(&lp->lock); |
@@ -107,7 +106,7 @@ static int uml_net_open(struct net_device *dev) | |||
107 | } | 106 | } |
108 | 107 | ||
109 | if(!lp->have_mac){ | 108 | if(!lp->have_mac){ |
110 | dev_ip_addr(dev, addr, &lp->mac[2]); | 109 | dev_ip_addr(dev, &lp->mac[2]); |
111 | set_ether_mac(dev, lp->mac); | 110 | set_ether_mac(dev, lp->mac); |
112 | } | 111 | } |
113 | 112 | ||
@@ -664,8 +663,6 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, | |||
664 | void *ptr) | 663 | void *ptr) |
665 | { | 664 | { |
666 | struct in_ifaddr *ifa = ptr; | 665 | struct in_ifaddr *ifa = ptr; |
667 | u32 addr = ifa->ifa_address; | ||
668 | u32 netmask = ifa->ifa_mask; | ||
669 | struct net_device *dev = ifa->ifa_dev->dev; | 666 | struct net_device *dev = ifa->ifa_dev->dev; |
670 | struct uml_net_private *lp; | 667 | struct uml_net_private *lp; |
671 | void (*proc)(unsigned char *, unsigned char *, void *); | 668 | void (*proc)(unsigned char *, unsigned char *, void *); |
@@ -685,14 +682,8 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, | |||
685 | break; | 682 | break; |
686 | } | 683 | } |
687 | if(proc != NULL){ | 684 | if(proc != NULL){ |
688 | addr_buf[0] = addr & 0xff; | 685 | memcpy(addr_buf, &ifa->ifa_address, sizeof(addr_buf)); |
689 | addr_buf[1] = (addr >> 8) & 0xff; | 686 | memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf)); |
690 | addr_buf[2] = (addr >> 16) & 0xff; | ||
691 | addr_buf[3] = addr >> 24; | ||
692 | netmask_buf[0] = netmask & 0xff; | ||
693 | netmask_buf[1] = (netmask >> 8) & 0xff; | ||
694 | netmask_buf[2] = (netmask >> 16) & 0xff; | ||
695 | netmask_buf[3] = netmask >> 24; | ||
696 | (*proc)(addr_buf, netmask_buf, &lp->user); | 687 | (*proc)(addr_buf, netmask_buf, &lp->user); |
697 | } | 688 | } |
698 | return(NOTIFY_DONE); | 689 | return(NOTIFY_DONE); |
@@ -774,27 +765,18 @@ int setup_etheraddr(char *str, unsigned char *addr) | |||
774 | return(1); | 765 | return(1); |
775 | } | 766 | } |
776 | 767 | ||
777 | void dev_ip_addr(void *d, char *buf, char *bin_buf) | 768 | void dev_ip_addr(void *d, unsigned char *bin_buf) |
778 | { | 769 | { |
779 | struct net_device *dev = d; | 770 | struct net_device *dev = d; |
780 | struct in_device *ip = dev->ip_ptr; | 771 | struct in_device *ip = dev->ip_ptr; |
781 | struct in_ifaddr *in; | 772 | struct in_ifaddr *in; |
782 | u32 addr; | ||
783 | 773 | ||
784 | if((ip == NULL) || ((in = ip->ifa_list) == NULL)){ | 774 | if((ip == NULL) || ((in = ip->ifa_list) == NULL)){ |
785 | printk(KERN_WARNING "dev_ip_addr - device not assigned an " | 775 | printk(KERN_WARNING "dev_ip_addr - device not assigned an " |
786 | "IP address\n"); | 776 | "IP address\n"); |
787 | return; | 777 | return; |
788 | } | 778 | } |
789 | addr = in->ifa_address; | 779 | memcpy(bin_buf, &in->ifa_address, sizeof(in->ifa_address)); |
790 | sprintf(buf, "%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff, | ||
791 | (addr >> 16) & 0xff, addr >> 24); | ||
792 | if(bin_buf){ | ||
793 | bin_buf[0] = addr & 0xff; | ||
794 | bin_buf[1] = (addr >> 8) & 0xff; | ||
795 | bin_buf[2] = (addr >> 16) & 0xff; | ||
796 | bin_buf[3] = addr >> 24; | ||
797 | } | ||
798 | } | 780 | } |
799 | 781 | ||
800 | void set_ether_mac(void *d, unsigned char *addr) | 782 | void set_ether_mac(void *d, unsigned char *addr) |
@@ -829,14 +811,8 @@ void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *, | |||
829 | if(ip == NULL) return; | 811 | if(ip == NULL) return; |
830 | in = ip->ifa_list; | 812 | in = ip->ifa_list; |
831 | while(in != NULL){ | 813 | while(in != NULL){ |
832 | address[0] = in->ifa_address & 0xff; | 814 | memcpy(address, &in->ifa_address, sizeof(address)); |
833 | address[1] = (in->ifa_address >> 8) & 0xff; | 815 | memcpy(netmask, &in->ifa_mask, sizeof(netmask)); |
834 | address[2] = (in->ifa_address >> 16) & 0xff; | ||
835 | address[3] = in->ifa_address >> 24; | ||
836 | netmask[0] = in->ifa_mask & 0xff; | ||
837 | netmask[1] = (in->ifa_mask >> 8) & 0xff; | ||
838 | netmask[2] = (in->ifa_mask >> 16) & 0xff; | ||
839 | netmask[3] = in->ifa_mask >> 24; | ||
840 | (*cb)(address, netmask, arg); | 816 | (*cb)(address, netmask, arg); |
841 | in = in->ifa_next; | 817 | in = in->ifa_next; |
842 | } | 818 | } |
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c index 3730d4f12713..098fa65981ab 100644 --- a/arch/um/drivers/net_user.c +++ b/arch/um/drivers/net_user.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include "user_util.h" | 16 | #include "user_util.h" |
17 | #include "kern_util.h" | 17 | #include "kern_util.h" |
18 | #include "net_user.h" | 18 | #include "net_user.h" |
19 | #include "helper.h" | ||
20 | #include "os.h" | 19 | #include "os.h" |
21 | 20 | ||
22 | int tap_open_common(void *dev, char *gate_addr) | 21 | int tap_open_common(void *dev, char *gate_addr) |
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c index 14dd2002d2da..ed4a1a6c5d83 100644 --- a/arch/um/drivers/port_user.c +++ b/arch/um/drivers/port_user.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include "user.h" | 18 | #include "user.h" |
19 | #include "chan_user.h" | 19 | #include "chan_user.h" |
20 | #include "port.h" | 20 | #include "port.h" |
21 | #include "helper.h" | ||
22 | #include "os.h" | 21 | #include "os.h" |
23 | 22 | ||
24 | struct port_chan { | 23 | struct port_chan { |
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c index f9e22198e011..ba471f5864a6 100644 --- a/arch/um/drivers/random.c +++ b/arch/um/drivers/random.c | |||
@@ -58,10 +58,8 @@ static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, | |||
58 | if (filp->f_flags & O_NONBLOCK) | 58 | if (filp->f_flags & O_NONBLOCK) |
59 | return ret ? : -EAGAIN; | 59 | return ret ? : -EAGAIN; |
60 | 60 | ||
61 | if(need_resched()){ | 61 | if(need_resched()) |
62 | current->state = TASK_INTERRUPTIBLE; | 62 | schedule_timeout_interruptible(1); |
63 | schedule_timeout(1); | ||
64 | } | ||
65 | } | 63 | } |
66 | else return n; | 64 | else return n; |
67 | if (signal_pending (current)) | 65 | if (signal_pending (current)) |
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c index 71af444e591f..89fbec185cc1 100644 --- a/arch/um/drivers/slip_user.c +++ b/arch/um/drivers/slip_user.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include "net_user.h" | 14 | #include "net_user.h" |
15 | #include "slip.h" | 15 | #include "slip.h" |
16 | #include "slip_common.h" | 16 | #include "slip_common.h" |
17 | #include "helper.h" | ||
18 | #include "os.h" | 17 | #include "os.h" |
19 | 18 | ||
20 | void slip_user_init(void *data, void *dev) | 19 | void slip_user_init(void *data, void *dev) |
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c index 8d91f663d82c..b94c66114bc8 100644 --- a/arch/um/drivers/slirp_user.c +++ b/arch/um/drivers/slirp_user.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include "net_user.h" | 13 | #include "net_user.h" |
14 | #include "slirp.h" | 14 | #include "slirp.h" |
15 | #include "slip_common.h" | 15 | #include "slip_common.h" |
16 | #include "helper.h" | ||
17 | #include "os.h" | 16 | #include "os.h" |
18 | 17 | ||
19 | void slirp_user_init(void *data, void *dev) | 18 | void slirp_user_init(void *data, void *dev) |
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 90e0e5ff451e..b530f1a6540d 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <sys/socket.h> | 14 | #include <sys/socket.h> |
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "chan_user.h" | 16 | #include "chan_user.h" |
17 | #include "helper.h" | ||
18 | #include "user_util.h" | 17 | #include "user_util.h" |
19 | #include "user.h" | 18 | #include "user.h" |
20 | #include "os.h" | 19 | #include "os.h" |
diff --git a/arch/um/include/helper.h b/arch/um/include/helper.h deleted file mode 100644 index 162ac31192fd..000000000000 --- a/arch/um/include/helper.h +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __HELPER_H__ | ||
7 | #define __HELPER_H__ | ||
8 | |||
9 | extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | ||
10 | unsigned long *stack_out); | ||
11 | extern int run_helper_thread(int (*proc)(void *), void *arg, | ||
12 | unsigned int flags, unsigned long *stack_out, | ||
13 | int stack_order); | ||
14 | extern int helper_wait(int pid); | ||
15 | |||
16 | #endif | ||
17 | |||
18 | /* | ||
19 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
20 | * Emacs will notice this stuff at the end of the file and automatically | ||
21 | * adjust the settings for this buffer only. This must remain at the end | ||
22 | * of the file. | ||
23 | * --------------------------------------------------------------------------- | ||
24 | * Local variables: | ||
25 | * c-file-style: "linux" | ||
26 | * End: | ||
27 | */ | ||
diff --git a/arch/um/include/mem_user.h b/arch/um/include/mem_user.h index 9fef4123a65a..a1064c5823bf 100644 --- a/arch/um/include/mem_user.h +++ b/arch/um/include/mem_user.h | |||
@@ -57,7 +57,7 @@ extern int init_maps(unsigned long physmem, unsigned long iomem, | |||
57 | unsigned long highmem); | 57 | unsigned long highmem); |
58 | extern unsigned long get_vm(unsigned long len); | 58 | extern unsigned long get_vm(unsigned long len); |
59 | extern void setup_physmem(unsigned long start, unsigned long usable, | 59 | extern void setup_physmem(unsigned long start, unsigned long usable, |
60 | unsigned long len, unsigned long highmem); | 60 | unsigned long len, unsigned long long highmem); |
61 | extern void add_iomem(char *name, int fd, unsigned long size); | 61 | extern void add_iomem(char *name, int fd, unsigned long size); |
62 | extern unsigned long phys_offset(unsigned long phys); | 62 | extern unsigned long phys_offset(unsigned long phys); |
63 | extern void unmap_physmem(void); | 63 | extern void unmap_physmem(void); |
diff --git a/arch/um/include/net_user.h b/arch/um/include/net_user.h index 89885a77a771..800c403920bc 100644 --- a/arch/um/include/net_user.h +++ b/arch/um/include/net_user.h | |||
@@ -25,7 +25,7 @@ struct net_user_info { | |||
25 | }; | 25 | }; |
26 | 26 | ||
27 | extern void ether_user_init(void *data, void *dev); | 27 | extern void ether_user_init(void *data, void *dev); |
28 | extern void dev_ip_addr(void *d, char *buf, char *bin_buf); | 28 | extern void dev_ip_addr(void *d, unsigned char *bin_buf); |
29 | extern void set_ether_mac(void *d, unsigned char *addr); | 29 | extern void set_ether_mac(void *d, unsigned char *addr); |
30 | extern void iter_addresses(void *d, void (*cb)(unsigned char *, | 30 | extern void iter_addresses(void *d, void (*cb)(unsigned char *, |
31 | unsigned char *, void *), | 31 | unsigned char *, void *), |
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 2e58e304b8be..2cccfa5b8ab5 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -167,7 +167,7 @@ extern int can_do_skas(void); | |||
167 | #endif | 167 | #endif |
168 | 168 | ||
169 | /* mem.c */ | 169 | /* mem.c */ |
170 | extern int create_mem_file(unsigned long len); | 170 | extern int create_mem_file(unsigned long long len); |
171 | 171 | ||
172 | /* process.c */ | 172 | /* process.c */ |
173 | extern unsigned long os_process_pc(int pid); | 173 | extern unsigned long os_process_pc(int pid); |
@@ -199,6 +199,20 @@ extern void forward_pending_sigio(int target); | |||
199 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, | 199 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, |
200 | int clone_flags, int (*tramp)(void *)); | 200 | int clone_flags, int (*tramp)(void *)); |
201 | 201 | ||
202 | /* uaccess.c */ | ||
203 | extern unsigned long __do_user_copy(void *to, const void *from, int n, | ||
204 | void **fault_addr, void **fault_catcher, | ||
205 | void (*op)(void *to, const void *from, | ||
206 | int n), int *faulted_out); | ||
207 | |||
208 | /* helper.c */ | ||
209 | extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | ||
210 | unsigned long *stack_out); | ||
211 | extern int run_helper_thread(int (*proc)(void *), void *arg, | ||
212 | unsigned int flags, unsigned long *stack_out, | ||
213 | int stack_order); | ||
214 | extern int helper_wait(int pid); | ||
215 | |||
202 | #endif | 216 | #endif |
203 | 217 | ||
204 | /* | 218 | /* |
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h index d3699fe1c613..a49ceb199ee5 100644 --- a/arch/um/include/sysdep-i386/stub.h +++ b/arch/um/include/sysdep-i386/stub.h | |||
@@ -16,45 +16,69 @@ extern void stub_clone_handler(void); | |||
16 | #define STUB_MMAP_NR __NR_mmap2 | 16 | #define STUB_MMAP_NR __NR_mmap2 |
17 | #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT) | 17 | #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT) |
18 | 18 | ||
19 | static inline long stub_syscall1(long syscall, long arg1) | ||
20 | { | ||
21 | long ret; | ||
22 | |||
23 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1)); | ||
24 | |||
25 | return ret; | ||
26 | } | ||
27 | |||
19 | static inline long stub_syscall2(long syscall, long arg1, long arg2) | 28 | static inline long stub_syscall2(long syscall, long arg1, long arg2) |
20 | { | 29 | { |
21 | long ret; | 30 | long ret; |
22 | 31 | ||
23 | __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); | 32 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), |
24 | __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); | 33 | "c" (arg2)); |
25 | __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); | 34 | |
26 | __asm__("int $0x80;" : : : "%eax"); | 35 | return ret; |
27 | __asm__ __volatile__("movl %%eax, %0; " : "=g" (ret) :); | ||
28 | return(ret); | ||
29 | } | 36 | } |
30 | 37 | ||
31 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) | 38 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) |
32 | { | 39 | { |
33 | __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); | 40 | long ret; |
34 | return(stub_syscall2(syscall, arg1, arg2)); | 41 | |
42 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
43 | "c" (arg2), "d" (arg3)); | ||
44 | |||
45 | return ret; | ||
35 | } | 46 | } |
36 | 47 | ||
37 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, | 48 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, |
38 | long arg4) | 49 | long arg4) |
39 | { | 50 | { |
40 | __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); | 51 | long ret; |
41 | return(stub_syscall3(syscall, arg1, arg2, arg3)); | 52 | |
53 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
54 | "c" (arg2), "d" (arg3), "S" (arg4)); | ||
55 | |||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, | ||
60 | long arg4, long arg5) | ||
61 | { | ||
62 | long ret; | ||
63 | |||
64 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
65 | "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)); | ||
66 | |||
67 | return ret; | ||
42 | } | 68 | } |
43 | 69 | ||
44 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, | 70 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, |
45 | long arg4, long arg5, long arg6) | 71 | long arg4, long arg5, long arg6) |
46 | { | 72 | { |
47 | long ret; | 73 | long ret; |
48 | __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); | 74 | |
49 | __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); | 75 | __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; " |
50 | __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); | 76 | "int $0x80 ; pop %%ebp" |
51 | __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); | 77 | : "=a" (ret) |
52 | __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); | 78 | : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3), |
53 | __asm__("movl %0, %%edi; " : : "g" (arg5) : "%edi"); | 79 | "S" (arg4), "D" (arg5), "0" (arg6)); |
54 | __asm__ __volatile__("pushl %%ebp ; movl %1, %%ebp; " | 80 | |
55 | "int $0x80; popl %%ebp ; " | 81 | return ret; |
56 | "movl %%eax, %0; " : "=g" (ret) : "g" (arg6) : "%eax"); | ||
57 | return(ret); | ||
58 | } | 82 | } |
59 | 83 | ||
60 | static inline void trap_myself(void) | 84 | static inline void trap_myself(void) |
diff --git a/arch/um/include/sysdep-x86_64/stub.h b/arch/um/include/sysdep-x86_64/stub.h index f599058d8263..2bd6e7a97286 100644 --- a/arch/um/include/sysdep-x86_64/stub.h +++ b/arch/um/include/sysdep-x86_64/stub.h | |||
@@ -17,37 +17,72 @@ extern void stub_clone_handler(void); | |||
17 | #define STUB_MMAP_NR __NR_mmap | 17 | #define STUB_MMAP_NR __NR_mmap |
18 | #define MMAP_OFFSET(o) (o) | 18 | #define MMAP_OFFSET(o) (o) |
19 | 19 | ||
20 | #define __syscall_clobber "r11","rcx","memory" | ||
21 | #define __syscall "syscall" | ||
22 | |||
20 | static inline long stub_syscall2(long syscall, long arg1, long arg2) | 23 | static inline long stub_syscall2(long syscall, long arg1, long arg2) |
21 | { | 24 | { |
22 | long ret; | 25 | long ret; |
23 | 26 | ||
24 | __asm__("movq %0, %%rsi; " : : "g" (arg2) : "%rsi"); | 27 | __asm__ volatile (__syscall |
25 | __asm__("movq %0, %%rdi; " : : "g" (arg1) : "%rdi"); | 28 | : "=a" (ret) |
26 | __asm__("movq %0, %%rax; " : : "g" (syscall) : "%rax"); | 29 | : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber ); |
27 | __asm__("syscall;" : : : "%rax", "%r11", "%rcx"); | 30 | |
28 | __asm__ __volatile__("movq %%rax, %0; " : "=g" (ret) :); | 31 | return ret; |
29 | return(ret); | ||
30 | } | 32 | } |
31 | 33 | ||
32 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) | 34 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) |
33 | { | 35 | { |
34 | __asm__("movq %0, %%rdx; " : : "g" (arg3) : "%rdx"); | 36 | long ret; |
35 | return(stub_syscall2(syscall, arg1, arg2)); | 37 | |
38 | __asm__ volatile (__syscall | ||
39 | : "=a" (ret) | ||
40 | : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3) | ||
41 | : __syscall_clobber ); | ||
42 | |||
43 | return ret; | ||
36 | } | 44 | } |
37 | 45 | ||
38 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, | 46 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, |
39 | long arg4) | 47 | long arg4) |
40 | { | 48 | { |
41 | __asm__("movq %0, %%r10; " : : "g" (arg4) : "%r10"); | 49 | long ret; |
42 | return(stub_syscall3(syscall, arg1, arg2, arg3)); | 50 | |
51 | __asm__ volatile ("movq %5,%%r10 ; " __syscall | ||
52 | : "=a" (ret) | ||
53 | : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), | ||
54 | "g" (arg4) | ||
55 | : __syscall_clobber, "r10" ); | ||
56 | |||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, | ||
61 | long arg4, long arg5) | ||
62 | { | ||
63 | long ret; | ||
64 | |||
65 | __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall | ||
66 | : "=a" (ret) | ||
67 | : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), | ||
68 | "g" (arg4), "g" (arg5) | ||
69 | : __syscall_clobber, "r10", "r8" ); | ||
70 | |||
71 | return ret; | ||
43 | } | 72 | } |
44 | 73 | ||
45 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, | 74 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, |
46 | long arg4, long arg5, long arg6) | 75 | long arg4, long arg5, long arg6) |
47 | { | 76 | { |
48 | __asm__("movq %0, %%r9; " : : "g" (arg6) : "%r9"); | 77 | long ret; |
49 | __asm__("movq %0, %%r8; " : : "g" (arg5) : "%r8"); | 78 | |
50 | return(stub_syscall4(syscall, arg1, arg2, arg3, arg4)); | 79 | __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " |
80 | "movq %7, %%r9; " __syscall : "=a" (ret) | ||
81 | : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), | ||
82 | "g" (arg4), "g" (arg5), "g" (arg6) | ||
83 | : __syscall_clobber, "r10", "r8", "r9" ); | ||
84 | |||
85 | return ret; | ||
51 | } | 86 | } |
52 | 87 | ||
53 | static inline void trap_myself(void) | 88 | static inline void trap_myself(void) |
diff --git a/arch/um/include/uml_uaccess.h b/arch/um/include/uml_uaccess.h index f77eb6428453..c0df11d06f5e 100644 --- a/arch/um/include/uml_uaccess.h +++ b/arch/um/include/uml_uaccess.h | |||
@@ -8,10 +8,6 @@ | |||
8 | 8 | ||
9 | extern int __do_copy_to_user(void *to, const void *from, int n, | 9 | extern int __do_copy_to_user(void *to, const void *from, int n, |
10 | void **fault_addr, void **fault_catcher); | 10 | void **fault_addr, void **fault_catcher); |
11 | extern unsigned long __do_user_copy(void *to, const void *from, int n, | ||
12 | void **fault_addr, void **fault_catcher, | ||
13 | void (*op)(void *to, const void *from, | ||
14 | int n), int *faulted_out); | ||
15 | void __do_copy(void *to, const void *from, int n); | 11 | void __do_copy(void *to, const void *from, int n); |
16 | 12 | ||
17 | #endif | 13 | #endif |
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 1a0001b3850c..3de9d21e36bf 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -7,10 +7,10 @@ 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 physmem.o \ | 10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ |
11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
12 | signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ | 12 | signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ |
13 | time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \ | 13 | time_kern.o tlb.o trap_kern.o trap_user.o uaccess.o um_arch.o \ |
14 | 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 |
@@ -24,8 +24,7 @@ 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 time.o tty_log.o umid.o \ | 27 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o umid.o user_util.o |
28 | user_util.o | ||
29 | 28 | ||
30 | include arch/um/scripts/Makefile.rules | 29 | include arch/um/scripts/Makefile.rules |
31 | 30 | ||
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c index a97a72e516aa..7713e7a6f476 100644 --- a/arch/um/kernel/ksyms.c +++ b/arch/um/kernel/ksyms.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include "user_util.h" | 20 | #include "user_util.h" |
21 | #include "mem_user.h" | 21 | #include "mem_user.h" |
22 | #include "os.h" | 22 | #include "os.h" |
23 | #include "helper.h" | ||
24 | 23 | ||
25 | EXPORT_SYMBOL(stop); | 24 | EXPORT_SYMBOL(stop); |
26 | EXPORT_SYMBOL(uml_physmem); | 25 | EXPORT_SYMBOL(uml_physmem); |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 462cc9d65386..fa4f915be5c5 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -234,8 +234,8 @@ void paging_init(void) | |||
234 | empty_bad_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE); | 234 | empty_bad_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE); |
235 | for(i=0;i<sizeof(zones_size)/sizeof(zones_size[0]);i++) | 235 | for(i=0;i<sizeof(zones_size)/sizeof(zones_size[0]);i++) |
236 | zones_size[i] = 0; | 236 | zones_size[i] = 0; |
237 | zones_size[0] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT); | 237 | zones_size[ZONE_DMA] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT); |
238 | zones_size[2] = highmem >> PAGE_SHIFT; | 238 | zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT; |
239 | free_area_init(zones_size); | 239 | free_area_init(zones_size); |
240 | 240 | ||
241 | /* | 241 | /* |
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index ea670fcc8af5..f3b583a878a6 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c | |||
@@ -246,7 +246,7 @@ int is_remapped(void *virt) | |||
246 | /* Changed during early boot */ | 246 | /* Changed during early boot */ |
247 | unsigned long high_physmem; | 247 | unsigned long high_physmem; |
248 | 248 | ||
249 | extern unsigned long physmem_size; | 249 | extern unsigned long long physmem_size; |
250 | 250 | ||
251 | int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem) | 251 | int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem) |
252 | { | 252 | { |
@@ -321,7 +321,7 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len, | |||
321 | extern int __syscall_stub_start, __binary_start; | 321 | extern int __syscall_stub_start, __binary_start; |
322 | 322 | ||
323 | void setup_physmem(unsigned long start, unsigned long reserve_end, | 323 | void setup_physmem(unsigned long start, unsigned long reserve_end, |
324 | unsigned long len, unsigned long highmem) | 324 | unsigned long len, unsigned long long highmem) |
325 | { | 325 | { |
326 | unsigned long reserve = reserve_end - start; | 326 | unsigned long reserve = reserve_end - start; |
327 | int pfn = PFN_UP(__pa(reserve_end)); | 327 | int pfn = PFN_UP(__pa(reserve_end)); |
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 71af4d503899..98e09395c093 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c | |||
@@ -43,53 +43,10 @@ void ptrace_disable(struct task_struct *child) | |||
43 | extern int peek_user(struct task_struct * child, long addr, long data); | 43 | extern int peek_user(struct task_struct * child, long addr, long data); |
44 | extern int poke_user(struct task_struct * child, long addr, long data); | 44 | extern int poke_user(struct task_struct * child, long addr, long data); |
45 | 45 | ||
46 | long sys_ptrace(long request, long pid, long addr, long data) | 46 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
47 | { | 47 | { |
48 | struct task_struct *child; | ||
49 | int i, ret; | 48 | int i, ret; |
50 | 49 | ||
51 | lock_kernel(); | ||
52 | ret = -EPERM; | ||
53 | if (request == PTRACE_TRACEME) { | ||
54 | /* are we already being traced? */ | ||
55 | if (current->ptrace & PT_PTRACED) | ||
56 | goto out; | ||
57 | |||
58 | ret = security_ptrace(current->parent, current); | ||
59 | if (ret) | ||
60 | goto out; | ||
61 | |||
62 | /* set the ptrace bit in the process flags. */ | ||
63 | current->ptrace |= PT_PTRACED; | ||
64 | ret = 0; | ||
65 | goto out; | ||
66 | } | ||
67 | ret = -ESRCH; | ||
68 | read_lock(&tasklist_lock); | ||
69 | child = find_task_by_pid(pid); | ||
70 | if (child) | ||
71 | get_task_struct(child); | ||
72 | read_unlock(&tasklist_lock); | ||
73 | if (!child) | ||
74 | goto out; | ||
75 | |||
76 | ret = -EPERM; | ||
77 | if (pid == 1) /* you may not mess with init */ | ||
78 | goto out_tsk; | ||
79 | |||
80 | if (request == PTRACE_ATTACH) { | ||
81 | ret = ptrace_attach(child); | ||
82 | goto out_tsk; | ||
83 | } | ||
84 | |||
85 | #ifdef SUBACH_PTRACE_SPECIAL | ||
86 | SUBARCH_PTRACE_SPECIAL(child,request,addr,data); | ||
87 | #endif | ||
88 | |||
89 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
90 | if (ret < 0) | ||
91 | goto out_tsk; | ||
92 | |||
93 | switch (request) { | 50 | switch (request) { |
94 | /* when I and D space are separate, these will need to be fixed. */ | 51 | /* when I and D space are separate, these will need to be fixed. */ |
95 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 52 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -282,10 +239,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
282 | ret = ptrace_request(child, request, addr, data); | 239 | ret = ptrace_request(child, request, addr, data); |
283 | break; | 240 | break; |
284 | } | 241 | } |
285 | out_tsk: | 242 | |
286 | put_task_struct(child); | ||
287 | out: | ||
288 | unlock_kernel(); | ||
289 | return ret; | 243 | return ret; |
290 | } | 244 | } |
291 | 245 | ||
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c index a52751108aa1..48b1f644b9a6 100644 --- a/arch/um/kernel/sigio_user.c +++ b/arch/um/kernel/sigio_user.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include "kern_util.h" | 18 | #include "kern_util.h" |
19 | #include "user_util.h" | 19 | #include "user_util.h" |
20 | #include "sigio.h" | 20 | #include "sigio.h" |
21 | #include "helper.h" | ||
22 | #include "os.h" | 21 | #include "os.h" |
23 | 22 | ||
24 | /* Changed during early boot */ | 23 | /* Changed during early boot */ |
@@ -225,7 +224,7 @@ static int need_poll(int n) | |||
225 | next_poll.used = n; | 224 | next_poll.used = n; |
226 | return(0); | 225 | return(0); |
227 | } | 226 | } |
228 | if(next_poll.poll != NULL) kfree(next_poll.poll); | 227 | kfree(next_poll.poll); |
229 | next_poll.poll = um_kmalloc_atomic(n * sizeof(struct pollfd)); | 228 | next_poll.poll = um_kmalloc_atomic(n * sizeof(struct pollfd)); |
230 | if(next_poll.poll == NULL){ | 229 | if(next_poll.poll == NULL){ |
231 | printk("need_poll : failed to allocate new pollfds\n"); | 230 | printk("need_poll : failed to allocate new pollfds\n"); |
diff --git a/arch/um/kernel/skas/include/mmu-skas.h b/arch/um/kernel/skas/include/mmu-skas.h index 09536f81ee42..44110c521e49 100644 --- a/arch/um/kernel/skas/include/mmu-skas.h +++ b/arch/um/kernel/skas/include/mmu-skas.h | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include "linux/config.h" | 9 | #include "linux/config.h" |
10 | #include "mm_id.h" | 10 | #include "mm_id.h" |
11 | #include "asm/ldt.h" | ||
11 | 12 | ||
12 | struct mmu_context_skas { | 13 | struct mmu_context_skas { |
13 | struct mm_id id; | 14 | struct mm_id id; |
@@ -15,6 +16,7 @@ struct mmu_context_skas { | |||
15 | #ifdef CONFIG_3_LEVEL_PGTABLES | 16 | #ifdef CONFIG_3_LEVEL_PGTABLES |
16 | unsigned long last_pmd; | 17 | unsigned long last_pmd; |
17 | #endif | 18 | #endif |
19 | uml_ldt_t ldt; | ||
18 | }; | 20 | }; |
19 | 21 | ||
20 | extern void switch_mm_skas(struct mm_id * mm_idp); | 22 | extern void switch_mm_skas(struct mm_id * mm_idp); |
diff --git a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h index 060934740f9f..daa2f85b684c 100644 --- a/arch/um/kernel/skas/include/skas.h +++ b/arch/um/kernel/skas/include/skas.h | |||
@@ -10,7 +10,8 @@ | |||
10 | #include "sysdep/ptrace.h" | 10 | #include "sysdep/ptrace.h" |
11 | 11 | ||
12 | extern int userspace_pid[]; | 12 | extern int userspace_pid[]; |
13 | extern int proc_mm, ptrace_faultinfo; | 13 | extern int proc_mm, ptrace_faultinfo, ptrace_ldt; |
14 | extern int skas_needs_stub; | ||
14 | 15 | ||
15 | extern void switch_threads(void *me, void *next); | 16 | extern void switch_threads(void *me, void *next); |
16 | extern void thread_wait(void *sw, void *fb); | 17 | extern void thread_wait(void *sw, void *fb); |
diff --git a/arch/um/kernel/skas/mem.c b/arch/um/kernel/skas/mem.c index 147466d7ff4f..88ab96c609ce 100644 --- a/arch/um/kernel/skas/mem.c +++ b/arch/um/kernel/skas/mem.c | |||
@@ -20,7 +20,7 @@ unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out, | |||
20 | *task_size_out = CONFIG_HOST_TASK_SIZE; | 20 | *task_size_out = CONFIG_HOST_TASK_SIZE; |
21 | #else | 21 | #else |
22 | *host_size_out = top; | 22 | *host_size_out = top; |
23 | if (proc_mm && ptrace_faultinfo) | 23 | if (!skas_needs_stub) |
24 | *task_size_out = top; | 24 | *task_size_out = top; |
25 | else *task_size_out = CONFIG_STUB_START & PGDIR_MASK; | 25 | else *task_size_out = CONFIG_STUB_START & PGDIR_MASK; |
26 | #endif | 26 | #endif |
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c index 9e5e39cea821..677871f1b37c 100644 --- a/arch/um/kernel/skas/mmu.c +++ b/arch/um/kernel/skas/mmu.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "asm/mmu.h" | 15 | #include "asm/mmu.h" |
16 | #include "asm/pgalloc.h" | 16 | #include "asm/pgalloc.h" |
17 | #include "asm/pgtable.h" | 17 | #include "asm/pgtable.h" |
18 | #include "asm/ldt.h" | ||
18 | #include "os.h" | 19 | #include "os.h" |
19 | #include "skas.h" | 20 | #include "skas.h" |
20 | 21 | ||
@@ -74,13 +75,12 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc, | |||
74 | 75 | ||
75 | int init_new_context_skas(struct task_struct *task, struct mm_struct *mm) | 76 | int init_new_context_skas(struct task_struct *task, struct mm_struct *mm) |
76 | { | 77 | { |
77 | struct mm_struct *cur_mm = current->mm; | 78 | struct mmu_context_skas *from_mm = NULL; |
78 | struct mm_id *cur_mm_id = &cur_mm->context.skas.id; | 79 | struct mmu_context_skas *to_mm = &mm->context.skas; |
79 | struct mm_id *mm_id = &mm->context.skas.id; | ||
80 | unsigned long stack = 0; | 80 | unsigned long stack = 0; |
81 | int from, ret = -ENOMEM; | 81 | int from_fd, ret = -ENOMEM; |
82 | 82 | ||
83 | if(!proc_mm || !ptrace_faultinfo){ | 83 | if(skas_needs_stub){ |
84 | stack = get_zeroed_page(GFP_KERNEL); | 84 | stack = get_zeroed_page(GFP_KERNEL); |
85 | if(stack == 0) | 85 | if(stack == 0) |
86 | goto out; | 86 | goto out; |
@@ -102,33 +102,43 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm) | |||
102 | 102 | ||
103 | mm->nr_ptes--; | 103 | mm->nr_ptes--; |
104 | } | 104 | } |
105 | mm_id->stack = stack; | 105 | |
106 | to_mm->id.stack = stack; | ||
107 | if(current->mm != NULL && current->mm != &init_mm) | ||
108 | from_mm = ¤t->mm->context.skas; | ||
106 | 109 | ||
107 | if(proc_mm){ | 110 | if(proc_mm){ |
108 | if((cur_mm != NULL) && (cur_mm != &init_mm)) | 111 | if(from_mm) |
109 | from = cur_mm_id->u.mm_fd; | 112 | from_fd = from_mm->id.u.mm_fd; |
110 | else from = -1; | 113 | else from_fd = -1; |
111 | 114 | ||
112 | ret = new_mm(from, stack); | 115 | ret = new_mm(from_fd, stack); |
113 | if(ret < 0){ | 116 | if(ret < 0){ |
114 | printk("init_new_context_skas - new_mm failed, " | 117 | printk("init_new_context_skas - new_mm failed, " |
115 | "errno = %d\n", ret); | 118 | "errno = %d\n", ret); |
116 | goto out_free; | 119 | goto out_free; |
117 | } | 120 | } |
118 | mm_id->u.mm_fd = ret; | 121 | to_mm->id.u.mm_fd = ret; |
119 | } | 122 | } |
120 | else { | 123 | else { |
121 | if((cur_mm != NULL) && (cur_mm != &init_mm)) | 124 | if(from_mm) |
122 | mm_id->u.pid = copy_context_skas0(stack, | 125 | to_mm->id.u.pid = copy_context_skas0(stack, |
123 | cur_mm_id->u.pid); | 126 | from_mm->id.u.pid); |
124 | else mm_id->u.pid = start_userspace(stack); | 127 | else to_mm->id.u.pid = start_userspace(stack); |
128 | } | ||
129 | |||
130 | ret = init_new_ldt(to_mm, from_mm); | ||
131 | if(ret < 0){ | ||
132 | printk("init_new_context_skas - init_ldt" | ||
133 | " failed, errno = %d\n", ret); | ||
134 | goto out_free; | ||
125 | } | 135 | } |
126 | 136 | ||
127 | return 0; | 137 | return 0; |
128 | 138 | ||
129 | out_free: | 139 | out_free: |
130 | if(mm_id->stack != 0) | 140 | if(to_mm->id.stack != 0) |
131 | free_page(mm_id->stack); | 141 | free_page(to_mm->id.stack); |
132 | out: | 142 | out: |
133 | return ret; | 143 | return ret; |
134 | } | 144 | } |
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c index 5cd0e9929789..599d679bd4fc 100644 --- a/arch/um/kernel/skas/process.c +++ b/arch/um/kernel/skas/process.c | |||
@@ -69,6 +69,17 @@ void wait_stub_done(int pid, int sig, char * fname) | |||
69 | 69 | ||
70 | if((n < 0) || !WIFSTOPPED(status) || | 70 | if((n < 0) || !WIFSTOPPED(status) || |
71 | (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ | 71 | (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ |
72 | unsigned long regs[FRAME_SIZE]; | ||
73 | if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) | ||
74 | printk("Failed to get registers from stub, " | ||
75 | "errno = %d\n", errno); | ||
76 | else { | ||
77 | int i; | ||
78 | |||
79 | printk("Stub registers -\n"); | ||
80 | for(i = 0; i < FRAME_SIZE; i++) | ||
81 | printk("\t%d - %lx\n", i, regs[i]); | ||
82 | } | ||
72 | panic("%s : failed to wait for SIGUSR1/SIGTRAP, " | 83 | panic("%s : failed to wait for SIGUSR1/SIGTRAP, " |
73 | "pid = %d, n = %d, errno = %d, status = 0x%x\n", | 84 | "pid = %d, n = %d, errno = %d, status = 0x%x\n", |
74 | fname, pid, n, errno, status); | 85 | fname, pid, n, errno, status); |
@@ -370,9 +381,9 @@ int copy_context_skas0(unsigned long new_stack, int pid) | |||
370 | } | 381 | } |
371 | 382 | ||
372 | /* | 383 | /* |
373 | * This is used only, if proc_mm is available, while PTRACE_FAULTINFO | 384 | * This is used only, if stub pages are needed, while proc_mm is |
374 | * isn't. Opening /proc/mm creates a new mm_context, which lacks the stub-pages | 385 | * availabl. Opening /proc/mm creates a new mm_context, which lacks |
375 | * Thus, we map them using /proc/mm-fd | 386 | * the stub-pages. Thus, we map them using /proc/mm-fd |
376 | */ | 387 | */ |
377 | void map_stub_pages(int fd, unsigned long code, | 388 | void map_stub_pages(int fd, unsigned long code, |
378 | unsigned long data, unsigned long stack) | 389 | unsigned long data, unsigned long stack) |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index efe92e8aa2a9..9c990253966c 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -145,7 +145,7 @@ int new_mm(int from, unsigned long stack) | |||
145 | "err = %d\n", -n); | 145 | "err = %d\n", -n); |
146 | } | 146 | } |
147 | 147 | ||
148 | if(!ptrace_faultinfo) | 148 | if(skas_needs_stub) |
149 | map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack); | 149 | map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack); |
150 | 150 | ||
151 | return(fd); | 151 | return(fd); |
diff --git a/arch/um/kernel/tt/uaccess_user.c b/arch/um/kernel/tt/uaccess_user.c index 8c220f054b61..6c92bbccb49c 100644 --- a/arch/um/kernel/tt/uaccess_user.c +++ b/arch/um/kernel/tt/uaccess_user.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "uml_uaccess.h" | 10 | #include "uml_uaccess.h" |
11 | #include "task.h" | 11 | #include "task.h" |
12 | #include "kern_util.h" | 12 | #include "kern_util.h" |
13 | #include "os.h" | ||
13 | 14 | ||
14 | int __do_copy_from_user(void *to, const void *from, int n, | 15 | int __do_copy_from_user(void *to, const void *from, int n, |
15 | void **fault_addr, void **fault_catcher) | 16 | void **fault_addr, void **fault_catcher) |
diff --git a/arch/um/kernel/uaccess.c b/arch/um/kernel/uaccess.c new file mode 100644 index 000000000000..054e3de0784e --- /dev/null +++ b/arch/um/kernel/uaccess.c | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) | ||
3 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | /* These are here rather than tt/uaccess.c because skas mode needs them in | ||
8 | * order to do SIGBUS recovery when a tmpfs mount runs out of room. | ||
9 | */ | ||
10 | |||
11 | #include <linux/string.h> | ||
12 | #include "os.h" | ||
13 | |||
14 | void __do_copy(void *to, const void *from, int n) | ||
15 | { | ||
16 | memcpy(to, from, n); | ||
17 | } | ||
18 | |||
19 | |||
20 | int __do_copy_to_user(void *to, const void *from, int n, | ||
21 | void **fault_addr, void **fault_catcher) | ||
22 | { | ||
23 | unsigned long fault; | ||
24 | int faulted; | ||
25 | |||
26 | fault = __do_user_copy(to, from, n, fault_addr, fault_catcher, | ||
27 | __do_copy, &faulted); | ||
28 | if(!faulted) return(0); | ||
29 | else return(n - (fault - (unsigned long) to)); | ||
30 | } | ||
diff --git a/arch/um/kernel/uaccess_user.c b/arch/um/kernel/uaccess_user.c deleted file mode 100644 index d035257ed0af..000000000000 --- a/arch/um/kernel/uaccess_user.c +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) | ||
3 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <setjmp.h> | ||
8 | #include <string.h> | ||
9 | |||
10 | /* These are here rather than tt/uaccess.c because skas mode needs them in | ||
11 | * order to do SIGBUS recovery when a tmpfs mount runs out of room. | ||
12 | */ | ||
13 | |||
14 | unsigned long __do_user_copy(void *to, const void *from, int n, | ||
15 | void **fault_addr, void **fault_catcher, | ||
16 | void (*op)(void *to, const void *from, | ||
17 | int n), int *faulted_out) | ||
18 | { | ||
19 | unsigned long *faddrp = (unsigned long *) fault_addr, ret; | ||
20 | |||
21 | sigjmp_buf jbuf; | ||
22 | *fault_catcher = &jbuf; | ||
23 | if(sigsetjmp(jbuf, 1) == 0){ | ||
24 | (*op)(to, from, n); | ||
25 | ret = 0; | ||
26 | *faulted_out = 0; | ||
27 | } | ||
28 | else { | ||
29 | ret = *faddrp; | ||
30 | *faulted_out = 1; | ||
31 | } | ||
32 | *fault_addr = NULL; | ||
33 | *fault_catcher = NULL; | ||
34 | return ret; | ||
35 | } | ||
36 | |||
37 | void __do_copy(void *to, const void *from, int n) | ||
38 | { | ||
39 | memcpy(to, from, n); | ||
40 | } | ||
41 | |||
42 | |||
43 | int __do_copy_to_user(void *to, const void *from, int n, | ||
44 | void **fault_addr, void **fault_catcher) | ||
45 | { | ||
46 | unsigned long fault; | ||
47 | int faulted; | ||
48 | |||
49 | fault = __do_user_copy(to, from, n, fault_addr, fault_catcher, | ||
50 | __do_copy, &faulted); | ||
51 | if(!faulted) return(0); | ||
52 | else return(n - (fault - (unsigned long) to)); | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
57 | * Emacs will notice this stuff at the end of the file and automatically | ||
58 | * adjust the settings for this buffer only. This must remain at the end | ||
59 | * of the file. | ||
60 | * --------------------------------------------------------------------------- | ||
61 | * Local variables: | ||
62 | * c-file-style: "linux" | ||
63 | * End: | ||
64 | */ | ||
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 93dc782dc1cc..142a9493912b 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -137,7 +137,7 @@ static char *argv1_end = NULL; | |||
137 | 137 | ||
138 | /* Set in early boot */ | 138 | /* Set in early boot */ |
139 | static int have_root __initdata = 0; | 139 | static int have_root __initdata = 0; |
140 | long physmem_size = 32 * 1024 * 1024; | 140 | long long physmem_size = 32 * 1024 * 1024; |
141 | 141 | ||
142 | void set_cmdline(char *cmd) | 142 | void set_cmdline(char *cmd) |
143 | { | 143 | { |
@@ -402,7 +402,7 @@ int linux_main(int argc, char **argv) | |||
402 | #ifndef CONFIG_HIGHMEM | 402 | #ifndef CONFIG_HIGHMEM |
403 | highmem = 0; | 403 | highmem = 0; |
404 | printf("CONFIG_HIGHMEM not enabled - physical memory shrunk " | 404 | printf("CONFIG_HIGHMEM not enabled - physical memory shrunk " |
405 | "to %ld bytes\n", physmem_size); | 405 | "to %lu bytes\n", physmem_size); |
406 | #endif | 406 | #endif |
407 | } | 407 | } |
408 | 408 | ||
@@ -414,8 +414,8 @@ int linux_main(int argc, char **argv) | |||
414 | 414 | ||
415 | setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); | 415 | setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); |
416 | if(init_maps(physmem_size, iomem_size, highmem)){ | 416 | if(init_maps(physmem_size, iomem_size, highmem)){ |
417 | printf("Failed to allocate mem_map for %ld bytes of physical " | 417 | printf("Failed to allocate mem_map for %lu bytes of physical " |
418 | "memory and %ld bytes of highmem\n", physmem_size, | 418 | "memory and %lu bytes of highmem\n", physmem_size, |
419 | highmem); | 419 | highmem); |
420 | exit(1); | 420 | exit(1); |
421 | } | 421 | } |
@@ -426,7 +426,7 @@ int linux_main(int argc, char **argv) | |||
426 | end_vm = start_vm + virtmem_size; | 426 | end_vm = start_vm + virtmem_size; |
427 | 427 | ||
428 | if(virtmem_size < physmem_size) | 428 | if(virtmem_size < physmem_size) |
429 | printf("Kernel virtual memory size shrunk to %ld bytes\n", | 429 | printf("Kernel virtual memory size shrunk to %lu bytes\n", |
430 | virtmem_size); | 430 | virtmem_size); |
431 | 431 | ||
432 | uml_postsetup(); | 432 | uml_postsetup(); |
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c index 41d17c71511c..4c231161f257 100644 --- a/arch/um/kernel/user_util.c +++ b/arch/um/kernel/user_util.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "user.h" | 27 | #include "user.h" |
28 | #include "mem_user.h" | 28 | #include "mem_user.h" |
29 | #include "init.h" | 29 | #include "init.h" |
30 | #include "helper.h" | ||
31 | #include "ptrace_user.h" | 30 | #include "ptrace_user.h" |
32 | #include "uml-config.h" | 31 | #include "uml-config.h" |
33 | 32 | ||
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index d15ec2af6a22..b83ac8e21c35 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile | |||
@@ -3,11 +3,12 @@ | |||
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y = aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o time.o \ | 6 | obj-y = aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ |
7 | tt.o tty.o user_syms.o drivers/ sys-$(SUBARCH)/ | 7 | start_up.o time.o tt.o tty.o uaccess.o user_syms.o drivers/ \ |
8 | sys-$(SUBARCH)/ | ||
8 | 9 | ||
9 | USER_OBJS := aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o \ | 10 | USER_OBJS := aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ |
10 | time.o tt.o tty.o | 11 | start_up.o time.o tt.o tty.o uaccess.o |
11 | 12 | ||
12 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h | 13 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h |
13 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um | 14 | 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 41cfb0944201..ffa759addd3c 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <sched.h> | 10 | #include <sched.h> |
11 | #include <sys/syscall.h> | 11 | #include <sys/syscall.h> |
12 | #include "os.h" | 12 | #include "os.h" |
13 | #include "helper.h" | ||
14 | #include "aio.h" | 13 | #include "aio.h" |
15 | #include "init.h" | 14 | #include "init.h" |
16 | #include "user.h" | 15 | #include "user.h" |
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c index cd4d6544da71..901b85e8a1c6 100644 --- a/arch/um/os-Linux/drivers/ethertap_user.c +++ b/arch/um/os-Linux/drivers/ethertap_user.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include "user_util.h" | 19 | #include "user_util.h" |
20 | #include "net_user.h" | 20 | #include "net_user.h" |
21 | #include "etap.h" | 21 | #include "etap.h" |
22 | #include "helper.h" | ||
23 | #include "os.h" | 22 | #include "os.h" |
24 | 23 | ||
25 | #define MAX_PACKET ETH_MAX_PACKET | 24 | #define MAX_PACKET ETH_MAX_PACKET |
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 4ba9b17adf13..52945338b64d 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include "kern_util.h" | 20 | #include "kern_util.h" |
21 | #include "user_util.h" | 21 | #include "user_util.h" |
22 | #include "user.h" | 22 | #include "user.h" |
23 | #include "helper.h" | ||
24 | #include "os.h" | 23 | #include "os.h" |
25 | 24 | ||
26 | #define MAX_PACKET ETH_MAX_PACKET | 25 | #define MAX_PACKET ETH_MAX_PACKET |
diff --git a/arch/um/kernel/helper.c b/arch/um/os-Linux/helper.c index 33fb0bd3b11a..36cc8475bcda 100644 --- a/arch/um/kernel/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -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 | */ |
@@ -13,7 +13,6 @@ | |||
13 | #include "user.h" | 13 | #include "user.h" |
14 | #include "kern_util.h" | 14 | #include "kern_util.h" |
15 | #include "user_util.h" | 15 | #include "user_util.h" |
16 | #include "helper.h" | ||
17 | #include "os.h" | 16 | #include "os.h" |
18 | 17 | ||
19 | struct helper_data { | 18 | struct helper_data { |
@@ -46,7 +45,7 @@ static int helper_child(void *arg) | |||
46 | errval = errno; | 45 | errval = errno; |
47 | printk("execvp of '%s' failed - errno = %d\n", argv[0], errno); | 46 | printk("execvp of '%s' failed - errno = %d\n", argv[0], errno); |
48 | os_write_file(data->fd, &errval, sizeof(errval)); | 47 | os_write_file(data->fd, &errval, sizeof(errval)); |
49 | os_kill_process(os_getpid(), 0); | 48 | kill(os_getpid(), SIGKILL); |
50 | return(0); | 49 | return(0); |
51 | } | 50 | } |
52 | 51 | ||
@@ -90,7 +89,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
90 | goto out_close; | 89 | goto out_close; |
91 | } | 90 | } |
92 | 91 | ||
93 | os_close_file(fds[1]); | 92 | close(fds[1]); |
94 | fds[1] = -1; | 93 | fds[1] = -1; |
95 | 94 | ||
96 | /*Read the errno value from the child.*/ | 95 | /*Read the errno value from the child.*/ |
@@ -98,7 +97,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
98 | if(n < 0){ | 97 | if(n < 0){ |
99 | printk("run_helper : read on pipe failed, ret = %d\n", -n); | 98 | printk("run_helper : read on pipe failed, ret = %d\n", -n); |
100 | ret = n; | 99 | ret = n; |
101 | os_kill_process(pid, 1); | 100 | kill(pid, SIGKILL); |
101 | CATCH_EINTR(waitpid(pid, NULL, 0)); | ||
102 | } | 102 | } |
103 | else if(n != 0){ | 103 | else if(n != 0){ |
104 | CATCH_EINTR(n = waitpid(pid, NULL, 0)); | 104 | CATCH_EINTR(n = waitpid(pid, NULL, 0)); |
@@ -109,8 +109,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
109 | 109 | ||
110 | out_close: | 110 | out_close: |
111 | if (fds[1] != -1) | 111 | if (fds[1] != -1) |
112 | os_close_file(fds[1]); | 112 | close(fds[1]); |
113 | os_close_file(fds[0]); | 113 | close(fds[0]); |
114 | out_free: | 114 | out_free: |
115 | if(stack_out == NULL) | 115 | if(stack_out == NULL) |
116 | free_stack(stack, 0); | 116 | free_stack(stack, 0); |
@@ -118,7 +118,7 @@ out_free: | |||
118 | return(ret); | 118 | return(ret); |
119 | } | 119 | } |
120 | 120 | ||
121 | int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | 121 | 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; |
@@ -131,7 +131,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
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 | err = -errno; |
134 | printk("run_helper_thread : clone failed, errno = %d\n", | 134 | printk("run_helper_thread : clone failed, errno = %d\n", |
135 | errno); | 135 | errno); |
136 | return err; | 136 | return err; |
137 | } | 137 | } |
diff --git a/arch/um/kernel/main.c b/arch/um/os-Linux/main.c index d31027f0fe39..23da27d22569 100644 --- a/arch/um/kernel/main.c +++ b/arch/um/os-Linux/main.c | |||
@@ -157,25 +157,25 @@ int main(int argc, char **argv, char **envp) | |||
157 | */ | 157 | */ |
158 | change_sig(SIGPROF, 0); | 158 | change_sig(SIGPROF, 0); |
159 | 159 | ||
160 | /* This signal stuff used to be in the reboot case. However, | 160 | /* This signal stuff used to be in the reboot case. However, |
161 | * sometimes a SIGVTALRM can come in when we're halting (reproducably | 161 | * sometimes a SIGVTALRM can come in when we're halting (reproducably |
162 | * when writing out gcov information, presumably because that takes | 162 | * when writing out gcov information, presumably because that takes |
163 | * some time) and cause a segfault. | 163 | * some time) and cause a segfault. |
164 | */ | 164 | */ |
165 | 165 | ||
166 | /* stop timers and set SIG*ALRM to be ignored */ | 166 | /* stop timers and set SIG*ALRM to be ignored */ |
167 | disable_timer(); | 167 | disable_timer(); |
168 | 168 | ||
169 | /* disable SIGIO for the fds and set SIGIO to be ignored */ | 169 | /* disable SIGIO for the fds and set SIGIO to be ignored */ |
170 | err = deactivate_all_fds(); | 170 | err = deactivate_all_fds(); |
171 | if(err) | 171 | if(err) |
172 | printf("deactivate_all_fds failed, errno = %d\n", -err); | 172 | printf("deactivate_all_fds failed, errno = %d\n", -err); |
173 | 173 | ||
174 | /* Let any pending signals fire now. This ensures | 174 | /* Let any pending signals fire now. This ensures |
175 | * that they won't be delivered after the exec, when | 175 | * that they won't be delivered after the exec, when |
176 | * they are definitely not expected. | 176 | * they are definitely not expected. |
177 | */ | 177 | */ |
178 | unblock_signals(); | 178 | unblock_signals(); |
179 | 179 | ||
180 | /* Reboot */ | 180 | /* Reboot */ |
181 | if(ret){ | 181 | if(ret){ |
@@ -257,14 +257,3 @@ void __wrap_free(void *ptr) | |||
257 | } | 257 | } |
258 | else __real_free(ptr); | 258 | else __real_free(ptr); |
259 | } | 259 | } |
260 | |||
261 | /* | ||
262 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
263 | * Emacs will notice this stuff at the end of the file and automatically | ||
264 | * adjust the settings for this buffer only. This must remain at the end | ||
265 | * of the file. | ||
266 | * --------------------------------------------------------------------------- | ||
267 | * Local variables: | ||
268 | * c-file-style: "linux" | ||
269 | * End: | ||
270 | */ | ||
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 8e71edaaf80b..9d7d69a523bb 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c | |||
@@ -88,7 +88,7 @@ int make_tempfile(const char *template, char **out_tempname, int do_unlink) | |||
88 | * This proc is used in start_up.c | 88 | * This proc is used in start_up.c |
89 | * So it isn't 'static'. | 89 | * So it isn't 'static'. |
90 | */ | 90 | */ |
91 | int create_tmp_file(unsigned long len) | 91 | int create_tmp_file(unsigned long long len) |
92 | { | 92 | { |
93 | int fd, err; | 93 | int fd, err; |
94 | char zero; | 94 | char zero; |
@@ -121,7 +121,7 @@ int create_tmp_file(unsigned long len) | |||
121 | return(fd); | 121 | return(fd); |
122 | } | 122 | } |
123 | 123 | ||
124 | static int create_anon_file(unsigned long len) | 124 | static int create_anon_file(unsigned long long len) |
125 | { | 125 | { |
126 | void *addr; | 126 | void *addr; |
127 | int fd; | 127 | int fd; |
@@ -144,7 +144,7 @@ static int create_anon_file(unsigned long len) | |||
144 | 144 | ||
145 | extern int have_devanon; | 145 | extern int have_devanon; |
146 | 146 | ||
147 | int create_mem_file(unsigned long len) | 147 | int create_mem_file(unsigned long long len) |
148 | { | 148 | { |
149 | int err, fd; | 149 | int err, fd; |
150 | 150 | ||
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index b99ab414542f..37517d49c4ae 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -135,7 +135,9 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, | |||
135 | } | 135 | } |
136 | 136 | ||
137 | int ptrace_faultinfo = 1; | 137 | int ptrace_faultinfo = 1; |
138 | int ptrace_ldt = 1; | ||
138 | int proc_mm = 1; | 139 | int proc_mm = 1; |
140 | int skas_needs_stub = 0; | ||
139 | 141 | ||
140 | static int __init skas0_cmd_param(char *str, int* add) | 142 | static int __init skas0_cmd_param(char *str, int* add) |
141 | { | 143 | { |
@@ -294,7 +296,7 @@ static void __init check_ptrace(void) | |||
294 | check_sysemu(); | 296 | check_sysemu(); |
295 | } | 297 | } |
296 | 298 | ||
297 | extern int create_tmp_file(unsigned long len); | 299 | extern int create_tmp_file(unsigned long long len); |
298 | 300 | ||
299 | static void check_tmpexec(void) | 301 | static void check_tmpexec(void) |
300 | { | 302 | { |
@@ -352,14 +354,26 @@ __uml_setup("noptracefaultinfo", noptracefaultinfo_cmd_param, | |||
352 | " it. To support PTRACE_FAULTINFO, the host needs to be patched\n" | 354 | " it. To support PTRACE_FAULTINFO, the host needs to be patched\n" |
353 | " using the current skas3 patch.\n\n"); | 355 | " using the current skas3 patch.\n\n"); |
354 | 356 | ||
357 | static int __init noptraceldt_cmd_param(char *str, int* add) | ||
358 | { | ||
359 | ptrace_ldt = 0; | ||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | __uml_setup("noptraceldt", noptraceldt_cmd_param, | ||
364 | "noptraceldt\n" | ||
365 | " Turns off usage of PTRACE_LDT, even if host supports it.\n" | ||
366 | " To support PTRACE_LDT, the host needs to be patched using\n" | ||
367 | " the current skas3 patch.\n\n"); | ||
368 | |||
355 | #ifdef UML_CONFIG_MODE_SKAS | 369 | #ifdef UML_CONFIG_MODE_SKAS |
356 | static inline void check_skas3_ptrace_support(void) | 370 | static inline void check_skas3_ptrace_faultinfo(void) |
357 | { | 371 | { |
358 | struct ptrace_faultinfo fi; | 372 | struct ptrace_faultinfo fi; |
359 | void *stack; | 373 | void *stack; |
360 | int pid, n; | 374 | int pid, n; |
361 | 375 | ||
362 | printf("Checking for the skas3 patch in the host..."); | 376 | printf(" - PTRACE_FAULTINFO..."); |
363 | pid = start_ptraced_child(&stack); | 377 | pid = start_ptraced_child(&stack); |
364 | 378 | ||
365 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 379 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
@@ -381,9 +395,49 @@ static inline void check_skas3_ptrace_support(void) | |||
381 | stop_ptraced_child(pid, stack, 1, 1); | 395 | stop_ptraced_child(pid, stack, 1, 1); |
382 | } | 396 | } |
383 | 397 | ||
384 | int can_do_skas(void) | 398 | static inline void check_skas3_ptrace_ldt(void) |
399 | { | ||
400 | #ifdef PTRACE_LDT | ||
401 | void *stack; | ||
402 | int pid, n; | ||
403 | unsigned char ldtbuf[40]; | ||
404 | struct ptrace_ldt ldt_op = (struct ptrace_ldt) { | ||
405 | .func = 2, /* read default ldt */ | ||
406 | .ptr = ldtbuf, | ||
407 | .bytecount = sizeof(ldtbuf)}; | ||
408 | |||
409 | printf(" - PTRACE_LDT..."); | ||
410 | pid = start_ptraced_child(&stack); | ||
411 | |||
412 | n = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op); | ||
413 | if (n < 0) { | ||
414 | if(errno == EIO) | ||
415 | printf("not found\n"); | ||
416 | else { | ||
417 | perror("not found"); | ||
418 | } | ||
419 | ptrace_ldt = 0; | ||
420 | } | ||
421 | else { | ||
422 | if(ptrace_ldt) | ||
423 | printf("found\n"); | ||
424 | else | ||
425 | printf("found, but use is disabled\n"); | ||
426 | } | ||
427 | |||
428 | stop_ptraced_child(pid, stack, 1, 1); | ||
429 | #else | ||
430 | /* PTRACE_LDT might be disabled via cmdline option. | ||
431 | * We want to override this, else we might use the stub | ||
432 | * without real need | ||
433 | */ | ||
434 | ptrace_ldt = 1; | ||
435 | #endif | ||
436 | } | ||
437 | |||
438 | static inline void check_skas3_proc_mm(void) | ||
385 | { | 439 | { |
386 | printf("Checking for /proc/mm..."); | 440 | printf(" - /proc/mm..."); |
387 | if (os_access("/proc/mm", OS_ACC_W_OK) < 0) { | 441 | if (os_access("/proc/mm", OS_ACC_W_OK) < 0) { |
388 | proc_mm = 0; | 442 | proc_mm = 0; |
389 | printf("not found\n"); | 443 | printf("not found\n"); |
@@ -394,8 +448,19 @@ int can_do_skas(void) | |||
394 | else | 448 | else |
395 | printf("found\n"); | 449 | printf("found\n"); |
396 | } | 450 | } |
451 | } | ||
452 | |||
453 | int can_do_skas(void) | ||
454 | { | ||
455 | printf("Checking for the skas3 patch in the host:\n"); | ||
456 | |||
457 | check_skas3_proc_mm(); | ||
458 | check_skas3_ptrace_faultinfo(); | ||
459 | check_skas3_ptrace_ldt(); | ||
460 | |||
461 | if(!proc_mm || !ptrace_faultinfo || !ptrace_ldt) | ||
462 | skas_needs_stub = 1; | ||
397 | 463 | ||
398 | check_skas3_ptrace_support(); | ||
399 | return 1; | 464 | return 1; |
400 | } | 465 | } |
401 | #else | 466 | #else |
diff --git a/arch/um/os-Linux/uaccess.c b/arch/um/os-Linux/uaccess.c new file mode 100644 index 000000000000..38d710158c3d --- /dev/null +++ b/arch/um/os-Linux/uaccess.c | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) | ||
3 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <setjmp.h> | ||
8 | #include <string.h> | ||
9 | |||
10 | unsigned long __do_user_copy(void *to, const void *from, int n, | ||
11 | void **fault_addr, void **fault_catcher, | ||
12 | void (*op)(void *to, const void *from, | ||
13 | int n), int *faulted_out) | ||
14 | { | ||
15 | unsigned long *faddrp = (unsigned long *) fault_addr, ret; | ||
16 | |||
17 | sigjmp_buf jbuf; | ||
18 | *fault_catcher = &jbuf; | ||
19 | if(sigsetjmp(jbuf, 1) == 0){ | ||
20 | (*op)(to, from, n); | ||
21 | ret = 0; | ||
22 | *faulted_out = 0; | ||
23 | } | ||
24 | else { | ||
25 | ret = *faddrp; | ||
26 | *faulted_out = 1; | ||
27 | } | ||
28 | *fault_addr = NULL; | ||
29 | *fault_catcher = NULL; | ||
30 | return ret; | ||
31 | } | ||
32 | |||
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index 651d9d88b656..b3fbf125709b 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules | |||
@@ -26,8 +26,13 @@ define unprofile | |||
26 | $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1))) | 26 | $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1))) |
27 | endef | 27 | endef |
28 | 28 | ||
29 | # cmd_make_link checks to see if the $(foo-dir) variable starts with a /. If | ||
30 | # so, it's considered to be a path relative to $(srcdir) rather than | ||
31 | # $(srcdir)/arch/$(SUBARCH). This is because x86_64 wants to get ldt.c from | ||
32 | # arch/um/sys-i386 rather than arch/i386 like the other borrowed files. So, | ||
33 | # it sets $(ldt.c-dir) to /arch/um/sys-i386. | ||
29 | quiet_cmd_make_link = SYMLINK $@ | 34 | quiet_cmd_make_link = SYMLINK $@ |
30 | cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ | 35 | cmd_make_link = rm -f $@; ln -sf $(srctree)$(if $(filter-out /%,$($(notdir $@)-dir)),/arch/$(SUBARCH))/$($(notdir $@)-dir)/$(notdir $@) $@ |
31 | 36 | ||
32 | # this needs to be before the foreach, because targets does not accept | 37 | # this needs to be before the foreach, because targets does not accept |
33 | # complete paths like $(obj)/$(f). To make sure this works, use a := assignment | 38 | # complete paths like $(obj)/$(f). To make sure this works, use a := assignment |
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c index 36b5c2c13289..6360f1c958d0 100644 --- a/arch/um/sys-i386/ldt.c +++ b/arch/um/sys-i386/ldt.c | |||
@@ -3,53 +3,26 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/stddef.h" | ||
6 | #include "linux/config.h" | 7 | #include "linux/config.h" |
7 | #include "linux/sched.h" | 8 | #include "linux/sched.h" |
8 | #include "linux/slab.h" | 9 | #include "linux/slab.h" |
9 | #include "linux/types.h" | 10 | #include "linux/types.h" |
11 | #include "linux/errno.h" | ||
10 | #include "asm/uaccess.h" | 12 | #include "asm/uaccess.h" |
11 | #include "asm/ptrace.h" | ||
12 | #include "asm/smp.h" | 13 | #include "asm/smp.h" |
13 | #include "asm/ldt.h" | 14 | #include "asm/ldt.h" |
15 | #include "asm/unistd.h" | ||
14 | #include "choose-mode.h" | 16 | #include "choose-mode.h" |
15 | #include "kern.h" | 17 | #include "kern.h" |
16 | #include "mode_kern.h" | 18 | #include "mode_kern.h" |
17 | 19 | ||
18 | #ifdef CONFIG_MODE_TT | ||
19 | |||
20 | extern int modify_ldt(int func, void *ptr, unsigned long bytecount); | 20 | extern int modify_ldt(int func, void *ptr, unsigned long bytecount); |
21 | 21 | ||
22 | static int do_modify_ldt_tt(int func, void *ptr, unsigned long bytecount) | 22 | #ifdef CONFIG_MODE_TT |
23 | { | ||
24 | return modify_ldt(func, ptr, bytecount); | ||
25 | } | ||
26 | |||
27 | #endif | ||
28 | |||
29 | #ifdef CONFIG_MODE_SKAS | ||
30 | |||
31 | #include "skas.h" | ||
32 | #include "skas_ptrace.h" | ||
33 | |||
34 | static int do_modify_ldt_skas(int func, void *ptr, unsigned long bytecount) | ||
35 | { | ||
36 | struct ptrace_ldt ldt; | ||
37 | u32 cpu; | ||
38 | int res; | ||
39 | |||
40 | ldt = ((struct ptrace_ldt) { .func = func, | ||
41 | .ptr = ptr, | ||
42 | .bytecount = bytecount }); | ||
43 | |||
44 | cpu = get_cpu(); | ||
45 | res = ptrace(PTRACE_LDT, userspace_pid[cpu], 0, (unsigned long) &ldt); | ||
46 | put_cpu(); | ||
47 | |||
48 | return res; | ||
49 | } | ||
50 | #endif | ||
51 | 23 | ||
52 | int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) | 24 | static long do_modify_ldt_tt(int func, void __user *ptr, |
25 | unsigned long bytecount) | ||
53 | { | 26 | { |
54 | struct user_desc info; | 27 | struct user_desc info; |
55 | int res = 0; | 28 | int res = 0; |
@@ -89,8 +62,7 @@ int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) | |||
89 | goto out; | 62 | goto out; |
90 | } | 63 | } |
91 | 64 | ||
92 | res = CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func, | 65 | res = modify_ldt(func, p, bytecount); |
93 | p, bytecount); | ||
94 | if(res < 0) | 66 | if(res < 0) |
95 | goto out; | 67 | goto out; |
96 | 68 | ||
@@ -108,3 +80,467 @@ out: | |||
108 | kfree(buf); | 80 | kfree(buf); |
109 | return res; | 81 | return res; |
110 | } | 82 | } |
83 | |||
84 | #endif | ||
85 | |||
86 | #ifdef CONFIG_MODE_SKAS | ||
87 | |||
88 | #include "skas.h" | ||
89 | #include "skas_ptrace.h" | ||
90 | #include "asm/mmu_context.h" | ||
91 | |||
92 | long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc, | ||
93 | void **addr, int done) | ||
94 | { | ||
95 | long res; | ||
96 | |||
97 | if(proc_mm){ | ||
98 | /* This is a special handling for the case, that the mm to | ||
99 | * modify isn't current->active_mm. | ||
100 | * If this is called directly by modify_ldt, | ||
101 | * (current->active_mm->context.skas.u == mm_idp) | ||
102 | * will be true. So no call to switch_mm_skas(mm_idp) is done. | ||
103 | * If this is called in case of init_new_ldt or PTRACE_LDT, | ||
104 | * mm_idp won't belong to current->active_mm, but child->mm. | ||
105 | * So we need to switch child's mm into our userspace, then | ||
106 | * later switch back. | ||
107 | * | ||
108 | * Note: I'm unshure: should interrupts be disabled here? | ||
109 | */ | ||
110 | if(!current->active_mm || current->active_mm == &init_mm || | ||
111 | mm_idp != ¤t->active_mm->context.skas.id) | ||
112 | switch_mm_skas(mm_idp); | ||
113 | } | ||
114 | |||
115 | if(ptrace_ldt) { | ||
116 | struct ptrace_ldt ldt_op = (struct ptrace_ldt) { | ||
117 | .func = func, | ||
118 | .ptr = desc, | ||
119 | .bytecount = sizeof(*desc)}; | ||
120 | u32 cpu; | ||
121 | int pid; | ||
122 | |||
123 | if(!proc_mm) | ||
124 | pid = mm_idp->u.pid; | ||
125 | else { | ||
126 | cpu = get_cpu(); | ||
127 | pid = userspace_pid[cpu]; | ||
128 | } | ||
129 | |||
130 | res = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op); | ||
131 | if(res) | ||
132 | res = errno; | ||
133 | |||
134 | if(proc_mm) | ||
135 | put_cpu(); | ||
136 | } | ||
137 | else { | ||
138 | void *stub_addr; | ||
139 | res = syscall_stub_data(mm_idp, (unsigned long *)desc, | ||
140 | (sizeof(*desc) + sizeof(long) - 1) & | ||
141 | ~(sizeof(long) - 1), | ||
142 | addr, &stub_addr); | ||
143 | if(!res){ | ||
144 | unsigned long args[] = { func, | ||
145 | (unsigned long)stub_addr, | ||
146 | sizeof(*desc), | ||
147 | 0, 0, 0 }; | ||
148 | res = run_syscall_stub(mm_idp, __NR_modify_ldt, args, | ||
149 | 0, addr, done); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | if(proc_mm){ | ||
154 | /* This is the second part of special handling, that makes | ||
155 | * PTRACE_LDT possible to implement. | ||
156 | */ | ||
157 | if(current->active_mm && current->active_mm != &init_mm && | ||
158 | mm_idp != ¤t->active_mm->context.skas.id) | ||
159 | switch_mm_skas(¤t->active_mm->context.skas.id); | ||
160 | } | ||
161 | |||
162 | return res; | ||
163 | } | ||
164 | |||
165 | static long read_ldt_from_host(void __user * ptr, unsigned long bytecount) | ||
166 | { | ||
167 | int res, n; | ||
168 | struct ptrace_ldt ptrace_ldt = (struct ptrace_ldt) { | ||
169 | .func = 0, | ||
170 | .bytecount = bytecount, | ||
171 | .ptr = (void *)kmalloc(bytecount, GFP_KERNEL)}; | ||
172 | u32 cpu; | ||
173 | |||
174 | if(ptrace_ldt.ptr == NULL) | ||
175 | return -ENOMEM; | ||
176 | |||
177 | /* This is called from sys_modify_ldt only, so userspace_pid gives | ||
178 | * us the right number | ||
179 | */ | ||
180 | |||
181 | cpu = get_cpu(); | ||
182 | res = ptrace(PTRACE_LDT, userspace_pid[cpu], 0, | ||
183 | (unsigned long) &ptrace_ldt); | ||
184 | put_cpu(); | ||
185 | if(res < 0) | ||
186 | goto out; | ||
187 | |||
188 | n = copy_to_user(ptr, ptrace_ldt.ptr, res); | ||
189 | if(n != 0) | ||
190 | res = -EFAULT; | ||
191 | |||
192 | out: | ||
193 | kfree(ptrace_ldt.ptr); | ||
194 | |||
195 | return res; | ||
196 | } | ||
197 | |||
198 | /* | ||
199 | * In skas mode, we hold our own ldt data in UML. | ||
200 | * Thus, the code implementing sys_modify_ldt_skas | ||
201 | * is very similar to (and mostly stolen from) sys_modify_ldt | ||
202 | * for arch/i386/kernel/ldt.c | ||
203 | * The routines copied and modified in part are: | ||
204 | * - read_ldt | ||
205 | * - read_default_ldt | ||
206 | * - write_ldt | ||
207 | * - sys_modify_ldt_skas | ||
208 | */ | ||
209 | |||
210 | static int read_ldt(void __user * ptr, unsigned long bytecount) | ||
211 | { | ||
212 | int i, err = 0; | ||
213 | unsigned long size; | ||
214 | uml_ldt_t * ldt = ¤t->mm->context.skas.ldt; | ||
215 | |||
216 | if(!ldt->entry_count) | ||
217 | goto out; | ||
218 | if(bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES) | ||
219 | bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES; | ||
220 | err = bytecount; | ||
221 | |||
222 | if(ptrace_ldt){ | ||
223 | return read_ldt_from_host(ptr, bytecount); | ||
224 | } | ||
225 | |||
226 | down(&ldt->semaphore); | ||
227 | if(ldt->entry_count <= LDT_DIRECT_ENTRIES){ | ||
228 | size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES; | ||
229 | if(size > bytecount) | ||
230 | size = bytecount; | ||
231 | if(copy_to_user(ptr, ldt->entries, size)) | ||
232 | err = -EFAULT; | ||
233 | bytecount -= size; | ||
234 | ptr += size; | ||
235 | } | ||
236 | else { | ||
237 | for(i=0; i<ldt->entry_count/LDT_ENTRIES_PER_PAGE && bytecount; | ||
238 | i++){ | ||
239 | size = PAGE_SIZE; | ||
240 | if(size > bytecount) | ||
241 | size = bytecount; | ||
242 | if(copy_to_user(ptr, ldt->pages[i], size)){ | ||
243 | err = -EFAULT; | ||
244 | break; | ||
245 | } | ||
246 | bytecount -= size; | ||
247 | ptr += size; | ||
248 | } | ||
249 | } | ||
250 | up(&ldt->semaphore); | ||
251 | |||
252 | if(bytecount == 0 || err == -EFAULT) | ||
253 | goto out; | ||
254 | |||
255 | if(clear_user(ptr, bytecount)) | ||
256 | err = -EFAULT; | ||
257 | |||
258 | out: | ||
259 | return err; | ||
260 | } | ||
261 | |||
262 | static int read_default_ldt(void __user * ptr, unsigned long bytecount) | ||
263 | { | ||
264 | int err; | ||
265 | |||
266 | if(bytecount > 5*LDT_ENTRY_SIZE) | ||
267 | bytecount = 5*LDT_ENTRY_SIZE; | ||
268 | |||
269 | err = bytecount; | ||
270 | /* UML doesn't support lcall7 and lcall27. | ||
271 | * So, we don't really have a default ldt, but emulate | ||
272 | * an empty ldt of common host default ldt size. | ||
273 | */ | ||
274 | if(clear_user(ptr, bytecount)) | ||
275 | err = -EFAULT; | ||
276 | |||
277 | return err; | ||
278 | } | ||
279 | |||
280 | static int write_ldt(void __user * ptr, unsigned long bytecount, int func) | ||
281 | { | ||
282 | uml_ldt_t * ldt = ¤t->mm->context.skas.ldt; | ||
283 | struct mm_id * mm_idp = ¤t->mm->context.skas.id; | ||
284 | int i, err; | ||
285 | struct user_desc ldt_info; | ||
286 | struct ldt_entry entry0, *ldt_p; | ||
287 | void *addr = NULL; | ||
288 | |||
289 | err = -EINVAL; | ||
290 | if(bytecount != sizeof(ldt_info)) | ||
291 | goto out; | ||
292 | err = -EFAULT; | ||
293 | if(copy_from_user(&ldt_info, ptr, sizeof(ldt_info))) | ||
294 | goto out; | ||
295 | |||
296 | err = -EINVAL; | ||
297 | if(ldt_info.entry_number >= LDT_ENTRIES) | ||
298 | goto out; | ||
299 | if(ldt_info.contents == 3){ | ||
300 | if (func == 1) | ||
301 | goto out; | ||
302 | if (ldt_info.seg_not_present == 0) | ||
303 | goto out; | ||
304 | } | ||
305 | |||
306 | if(!ptrace_ldt) | ||
307 | down(&ldt->semaphore); | ||
308 | |||
309 | err = write_ldt_entry(mm_idp, func, &ldt_info, &addr, 1); | ||
310 | if(err) | ||
311 | goto out_unlock; | ||
312 | else if(ptrace_ldt) { | ||
313 | /* With PTRACE_LDT available, this is used as a flag only */ | ||
314 | ldt->entry_count = 1; | ||
315 | goto out; | ||
316 | } | ||
317 | |||
318 | if(ldt_info.entry_number >= ldt->entry_count && | ||
319 | ldt_info.entry_number >= LDT_DIRECT_ENTRIES){ | ||
320 | for(i=ldt->entry_count/LDT_ENTRIES_PER_PAGE; | ||
321 | i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number; | ||
322 | i++){ | ||
323 | if(i == 0) | ||
324 | memcpy(&entry0, ldt->entries, sizeof(entry0)); | ||
325 | ldt->pages[i] = (struct ldt_entry *) | ||
326 | __get_free_page(GFP_KERNEL|__GFP_ZERO); | ||
327 | if(!ldt->pages[i]){ | ||
328 | err = -ENOMEM; | ||
329 | /* Undo the change in host */ | ||
330 | memset(&ldt_info, 0, sizeof(ldt_info)); | ||
331 | write_ldt_entry(mm_idp, 1, &ldt_info, &addr, 1); | ||
332 | goto out_unlock; | ||
333 | } | ||
334 | if(i == 0) { | ||
335 | memcpy(ldt->pages[0], &entry0, sizeof(entry0)); | ||
336 | memcpy(ldt->pages[0]+1, ldt->entries+1, | ||
337 | sizeof(entry0)*(LDT_DIRECT_ENTRIES-1)); | ||
338 | } | ||
339 | ldt->entry_count = (i + 1) * LDT_ENTRIES_PER_PAGE; | ||
340 | } | ||
341 | } | ||
342 | if(ldt->entry_count <= ldt_info.entry_number) | ||
343 | ldt->entry_count = ldt_info.entry_number + 1; | ||
344 | |||
345 | if(ldt->entry_count <= LDT_DIRECT_ENTRIES) | ||
346 | ldt_p = ldt->entries + ldt_info.entry_number; | ||
347 | else | ||
348 | ldt_p = ldt->pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] + | ||
349 | ldt_info.entry_number%LDT_ENTRIES_PER_PAGE; | ||
350 | |||
351 | if(ldt_info.base_addr == 0 && ldt_info.limit == 0 && | ||
352 | (func == 1 || LDT_empty(&ldt_info))){ | ||
353 | ldt_p->a = 0; | ||
354 | ldt_p->b = 0; | ||
355 | } | ||
356 | else{ | ||
357 | if (func == 1) | ||
358 | ldt_info.useable = 0; | ||
359 | ldt_p->a = LDT_entry_a(&ldt_info); | ||
360 | ldt_p->b = LDT_entry_b(&ldt_info); | ||
361 | } | ||
362 | err = 0; | ||
363 | |||
364 | out_unlock: | ||
365 | up(&ldt->semaphore); | ||
366 | out: | ||
367 | return err; | ||
368 | } | ||
369 | |||
370 | static long do_modify_ldt_skas(int func, void __user *ptr, | ||
371 | unsigned long bytecount) | ||
372 | { | ||
373 | int ret = -ENOSYS; | ||
374 | |||
375 | switch (func) { | ||
376 | case 0: | ||
377 | ret = read_ldt(ptr, bytecount); | ||
378 | break; | ||
379 | case 1: | ||
380 | case 0x11: | ||
381 | ret = write_ldt(ptr, bytecount, func); | ||
382 | break; | ||
383 | case 2: | ||
384 | ret = read_default_ldt(ptr, bytecount); | ||
385 | break; | ||
386 | } | ||
387 | return ret; | ||
388 | } | ||
389 | |||
390 | short dummy_list[9] = {0, -1}; | ||
391 | short * host_ldt_entries = NULL; | ||
392 | |||
393 | void ldt_get_host_info(void) | ||
394 | { | ||
395 | long ret; | ||
396 | struct ldt_entry * ldt; | ||
397 | int i, size, k, order; | ||
398 | |||
399 | host_ldt_entries = dummy_list+1; | ||
400 | |||
401 | for(i = LDT_PAGES_MAX-1, order=0; i; i>>=1, order++); | ||
402 | |||
403 | ldt = (struct ldt_entry *) | ||
404 | __get_free_pages(GFP_KERNEL|__GFP_ZERO, order); | ||
405 | if(ldt == NULL) { | ||
406 | printk("ldt_get_host_info: couldn't allocate buffer for host ldt\n"); | ||
407 | return; | ||
408 | } | ||
409 | |||
410 | ret = modify_ldt(0, ldt, (1<<order)*PAGE_SIZE); | ||
411 | if(ret < 0) { | ||
412 | printk("ldt_get_host_info: couldn't read host ldt\n"); | ||
413 | goto out_free; | ||
414 | } | ||
415 | if(ret == 0) { | ||
416 | /* default_ldt is active, simply write an empty entry 0 */ | ||
417 | host_ldt_entries = dummy_list; | ||
418 | goto out_free; | ||
419 | } | ||
420 | |||
421 | for(i=0, size=0; i<ret/LDT_ENTRY_SIZE; i++){ | ||
422 | if(ldt[i].a != 0 || ldt[i].b != 0) | ||
423 | size++; | ||
424 | } | ||
425 | |||
426 | if(size < sizeof(dummy_list)/sizeof(dummy_list[0])) { | ||
427 | host_ldt_entries = dummy_list; | ||
428 | } | ||
429 | else { | ||
430 | size = (size + 1) * sizeof(dummy_list[0]); | ||
431 | host_ldt_entries = (short *)kmalloc(size, GFP_KERNEL); | ||
432 | if(host_ldt_entries == NULL) { | ||
433 | printk("ldt_get_host_info: couldn't allocate host ldt list\n"); | ||
434 | goto out_free; | ||
435 | } | ||
436 | } | ||
437 | |||
438 | for(i=0, k=0; i<ret/LDT_ENTRY_SIZE; i++){ | ||
439 | if(ldt[i].a != 0 || ldt[i].b != 0) { | ||
440 | host_ldt_entries[k++] = i; | ||
441 | } | ||
442 | } | ||
443 | host_ldt_entries[k] = -1; | ||
444 | |||
445 | out_free: | ||
446 | free_pages((unsigned long)ldt, order); | ||
447 | } | ||
448 | |||
449 | long init_new_ldt(struct mmu_context_skas * new_mm, | ||
450 | struct mmu_context_skas * from_mm) | ||
451 | { | ||
452 | struct user_desc desc; | ||
453 | short * num_p; | ||
454 | int i; | ||
455 | long page, err=0; | ||
456 | void *addr = NULL; | ||
457 | |||
458 | memset(&desc, 0, sizeof(desc)); | ||
459 | |||
460 | if(!ptrace_ldt) | ||
461 | init_MUTEX(&new_mm->ldt.semaphore); | ||
462 | |||
463 | if(!from_mm){ | ||
464 | /* | ||
465 | * We have to initialize a clean ldt. | ||
466 | */ | ||
467 | if(proc_mm) { | ||
468 | /* | ||
469 | * If the new mm was created using proc_mm, host's | ||
470 | * default-ldt currently is assigned, which normally | ||
471 | * contains the call-gates for lcall7 and lcall27. | ||
472 | * To remove these gates, we simply write an empty | ||
473 | * entry as number 0 to the host. | ||
474 | */ | ||
475 | err = write_ldt_entry(&new_mm->id, 1, &desc, | ||
476 | &addr, 1); | ||
477 | } | ||
478 | else{ | ||
479 | /* | ||
480 | * Now we try to retrieve info about the ldt, we | ||
481 | * inherited from the host. All ldt-entries found | ||
482 | * will be reset in the following loop | ||
483 | */ | ||
484 | if(host_ldt_entries == NULL) | ||
485 | ldt_get_host_info(); | ||
486 | for(num_p=host_ldt_entries; *num_p != -1; num_p++){ | ||
487 | desc.entry_number = *num_p; | ||
488 | err = write_ldt_entry(&new_mm->id, 1, &desc, | ||
489 | &addr, *(num_p + 1) == -1); | ||
490 | if(err) | ||
491 | break; | ||
492 | } | ||
493 | } | ||
494 | new_mm->ldt.entry_count = 0; | ||
495 | } | ||
496 | else if (!ptrace_ldt) { | ||
497 | /* Our local LDT is used to supply the data for | ||
498 | * modify_ldt(READLDT), if PTRACE_LDT isn't available, | ||
499 | * i.e., we have to use the stub for modify_ldt, which | ||
500 | * can't handle the big read buffer of up to 64kB. | ||
501 | */ | ||
502 | down(&from_mm->ldt.semaphore); | ||
503 | if(from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES){ | ||
504 | memcpy(new_mm->ldt.entries, from_mm->ldt.entries, | ||
505 | sizeof(new_mm->ldt.entries)); | ||
506 | } | ||
507 | else{ | ||
508 | i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; | ||
509 | while(i-->0){ | ||
510 | page = __get_free_page(GFP_KERNEL|__GFP_ZERO); | ||
511 | if (!page){ | ||
512 | err = -ENOMEM; | ||
513 | break; | ||
514 | } | ||
515 | new_mm->ldt.pages[i] = (struct ldt_entry*)page; | ||
516 | memcpy(new_mm->ldt.pages[i], | ||
517 | from_mm->ldt.pages[i], PAGE_SIZE); | ||
518 | } | ||
519 | } | ||
520 | new_mm->ldt.entry_count = from_mm->ldt.entry_count; | ||
521 | up(&from_mm->ldt.semaphore); | ||
522 | } | ||
523 | |||
524 | return err; | ||
525 | } | ||
526 | |||
527 | |||
528 | void free_ldt(struct mmu_context_skas * mm) | ||
529 | { | ||
530 | int i; | ||
531 | |||
532 | if(!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES){ | ||
533 | i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; | ||
534 | while(i-- > 0){ | ||
535 | free_page((long )mm->ldt.pages[i]); | ||
536 | } | ||
537 | } | ||
538 | mm->ldt.entry_count = 0; | ||
539 | } | ||
540 | #endif | ||
541 | |||
542 | int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) | ||
543 | { | ||
544 | return(CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func, | ||
545 | ptr, bytecount)); | ||
546 | } | ||
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index 06c3633457a2..ea977df395a1 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | #XXX: why into lib-y? | 7 | #XXX: why into lib-y? |
8 | lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o mem.o memcpy.o \ | 8 | lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o ldt.o mem.o memcpy.o \ |
9 | ptrace.o ptrace_user.o sigcontext.o signal.o stub.o \ | 9 | ptrace.o ptrace_user.o sigcontext.o signal.o stub.o \ |
10 | stub_segv.o syscalls.o syscall_table.o sysrq.o thunk.o | 10 | stub_segv.o syscalls.o syscall_table.o sysrq.o thunk.o |
11 | 11 | ||
@@ -14,7 +14,7 @@ obj-$(CONFIG_MODULES) += module.o um_module.o | |||
14 | 14 | ||
15 | USER_OBJS := ptrace_user.o sigcontext.o | 15 | USER_OBJS := ptrace_user.o sigcontext.o |
16 | 16 | ||
17 | SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \ | 17 | SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c ldt.c memcpy.S \ |
18 | thunk.S module.c | 18 | thunk.S module.c |
19 | 19 | ||
20 | include arch/um/scripts/Makefile.rules | 20 | include arch/um/scripts/Makefile.rules |
@@ -23,6 +23,7 @@ bitops.c-dir = lib | |||
23 | csum-copy.S-dir = lib | 23 | csum-copy.S-dir = lib |
24 | csum-partial.c-dir = lib | 24 | csum-partial.c-dir = lib |
25 | csum-wrappers.c-dir = lib | 25 | csum-wrappers.c-dir = lib |
26 | ldt.c-dir = /arch/um/sys-i386 | ||
26 | memcpy.S-dir = lib | 27 | memcpy.S-dir = lib |
27 | thunk.S-dir = lib | 28 | thunk.S-dir = lib |
28 | module.c-dir = kernel | 29 | module.c-dir = kernel |
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c index 3259a4db4534..6acee5c4ada6 100644 --- a/arch/um/sys-x86_64/syscalls.c +++ b/arch/um/sys-x86_64/syscalls.c | |||
@@ -29,81 +29,6 @@ asmlinkage long sys_uname64(struct new_utsname __user * name) | |||
29 | } | 29 | } |
30 | 30 | ||
31 | #ifdef CONFIG_MODE_TT | 31 | #ifdef CONFIG_MODE_TT |
32 | extern int modify_ldt(int func, void *ptr, unsigned long bytecount); | ||
33 | |||
34 | long sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount) | ||
35 | { | ||
36 | /* XXX This should check VERIFY_WRITE depending on func, check this | ||
37 | * in i386 as well. | ||
38 | */ | ||
39 | if (!access_ok(VERIFY_READ, ptr, bytecount)) | ||
40 | return -EFAULT; | ||
41 | return(modify_ldt(func, ptr, bytecount)); | ||
42 | } | ||
43 | #endif | ||
44 | |||
45 | #ifdef CONFIG_MODE_SKAS | ||
46 | extern int userspace_pid[]; | ||
47 | |||
48 | #include "skas_ptrace.h" | ||
49 | |||
50 | long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount) | ||
51 | { | ||
52 | struct ptrace_ldt ldt; | ||
53 | void *buf; | ||
54 | int res, n; | ||
55 | |||
56 | buf = kmalloc(bytecount, GFP_KERNEL); | ||
57 | if(buf == NULL) | ||
58 | return(-ENOMEM); | ||
59 | |||
60 | res = 0; | ||
61 | |||
62 | switch(func){ | ||
63 | case 1: | ||
64 | case 0x11: | ||
65 | res = copy_from_user(buf, ptr, bytecount); | ||
66 | break; | ||
67 | } | ||
68 | |||
69 | if(res != 0){ | ||
70 | res = -EFAULT; | ||
71 | goto out; | ||
72 | } | ||
73 | |||
74 | ldt = ((struct ptrace_ldt) { .func = func, | ||
75 | .ptr = buf, | ||
76 | .bytecount = bytecount }); | ||
77 | #warning Need to look up userspace_pid by cpu | ||
78 | res = ptrace(PTRACE_LDT, userspace_pid[0], 0, (unsigned long) &ldt); | ||
79 | if(res < 0) | ||
80 | goto out; | ||
81 | |||
82 | switch(func){ | ||
83 | case 0: | ||
84 | case 2: | ||
85 | n = res; | ||
86 | res = copy_to_user(ptr, buf, n); | ||
87 | if(res != 0) | ||
88 | res = -EFAULT; | ||
89 | else | ||
90 | res = n; | ||
91 | break; | ||
92 | } | ||
93 | |||
94 | out: | ||
95 | kfree(buf); | ||
96 | return(res); | ||
97 | } | ||
98 | #endif | ||
99 | |||
100 | long sys_modify_ldt(int func, void *ptr, unsigned long bytecount) | ||
101 | { | ||
102 | return(CHOOSE_MODE_PROC(sys_modify_ldt_tt, sys_modify_ldt_skas, func, | ||
103 | ptr, bytecount)); | ||
104 | } | ||
105 | |||
106 | #ifdef CONFIG_MODE_TT | ||
107 | extern long arch_prctl(int code, unsigned long addr); | 32 | extern long arch_prctl(int code, unsigned long addr); |
108 | 33 | ||
109 | static long arch_prctl_tt(int code, unsigned long addr) | 34 | static long arch_prctl_tt(int code, unsigned long addr) |