diff options
author | Tony Luck <tony.luck@intel.com> | 2005-06-15 17:06:48 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2005-06-15 17:06:48 -0400 |
commit | f2cbb4f01936a3e4225692e03b084b78c56d386d (patch) | |
tree | f89f3d8baa250589a38a4dd2df56f84cddae3c76 /arch/um | |
parent | 325a479c4c110db278ef3361460a48c4093252cc (diff) | |
parent | 1016888fb69662936b32ab767c7419a3be9a69d3 (diff) |
Auto merge with /home/aegl/GIT/linus
Diffstat (limited to 'arch/um')
137 files changed, 1771 insertions, 1700 deletions
diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index b89989de364d..bd41e4286d0d 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug | |||
@@ -2,10 +2,6 @@ menu "Kernel hacking" | |||
2 | 2 | ||
3 | source "lib/Kconfig.debug" | 3 | source "lib/Kconfig.debug" |
4 | 4 | ||
5 | config FRAME_POINTER | ||
6 | bool | ||
7 | default y if DEBUG_INFO | ||
8 | |||
9 | config PT_PROXY | 5 | config PT_PROXY |
10 | bool "Enable ptrace proxy" | 6 | bool "Enable ptrace proxy" |
11 | depends on XTERM_CHAN && DEBUG_INFO && MODE_TT | 7 | depends on XTERM_CHAN && DEBUG_INFO && MODE_TT |
diff --git a/arch/um/Kconfig_char b/arch/um/Kconfig_char index 3e50fdb67626..62d87b71179b 100644 --- a/arch/um/Kconfig_char +++ b/arch/um/Kconfig_char | |||
@@ -204,5 +204,11 @@ config UML_RANDOM | |||
204 | http://sourceforge.net/projects/gkernel/). rngd periodically reads | 204 | http://sourceforge.net/projects/gkernel/). rngd periodically reads |
205 | /dev/hwrng and injects the entropy into /dev/random. | 205 | /dev/hwrng and injects the entropy into /dev/random. |
206 | 206 | ||
207 | config MMAPPER | ||
208 | tristate "iomem emulation driver" | ||
209 | help | ||
210 | This driver allows a host file to be used as emulated IO memory inside | ||
211 | UML. | ||
212 | |||
207 | endmenu | 213 | endmenu |
208 | 214 | ||
diff --git a/arch/um/Kconfig_x86_64 b/arch/um/Kconfig_x86_64 index fd8d7e8982b1..f162f50f0b17 100644 --- a/arch/um/Kconfig_x86_64 +++ b/arch/um/Kconfig_x86_64 | |||
@@ -6,6 +6,10 @@ config 64BIT | |||
6 | bool | 6 | bool |
7 | default y | 7 | default y |
8 | 8 | ||
9 | config TOP_ADDR | ||
10 | hex | ||
11 | default 0x80000000 | ||
12 | |||
9 | config 3_LEVEL_PGTABLES | 13 | config 3_LEVEL_PGTABLES |
10 | bool | 14 | bool |
11 | default y | 15 | default y |
diff --git a/arch/um/Makefile b/arch/um/Makefile index 97bca6b5ca95..f2a0c40a9204 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -17,7 +17,7 @@ core-y += $(ARCH_DIR)/kernel/ \ | |||
17 | 17 | ||
18 | # Have to precede the include because the included Makefiles reference them. | 18 | # Have to precede the include because the included Makefiles reference them. |
19 | SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ | 19 | SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ |
20 | arch-signal.h module.h vm-flags.h | 20 | module.h vm-flags.h elf.h |
21 | SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) | 21 | SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) |
22 | 22 | ||
23 | # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes | 23 | # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes |
@@ -44,6 +44,11 @@ ifneq ($(MAKEFILES-INCL),) | |||
44 | endif | 44 | endif |
45 | 45 | ||
46 | ARCH_INCLUDE := -I$(ARCH_DIR)/include | 46 | ARCH_INCLUDE := -I$(ARCH_DIR)/include |
47 | ifneq ($(KBUILD_SRC),) | ||
48 | ARCH_INCLUDE += -I$(ARCH_DIR)/include2 | ||
49 | ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include | ||
50 | MRPROPER_DIRS += $(ARCH_DIR)/include2 | ||
51 | endif | ||
47 | SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) | 52 | SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) |
48 | 53 | ||
49 | include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) | 54 | include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) |
@@ -94,17 +99,18 @@ define archhelp | |||
94 | echo ' find in the kernel root.' | 99 | echo ' find in the kernel root.' |
95 | endef | 100 | endef |
96 | 101 | ||
102 | ifneq ($(KBUILD_SRC),) | ||
103 | $(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig_$(SUBARCH) $(ARCH_DIR)/Kconfig_arch) | ||
104 | CLEAN_FILES += $(ARCH_DIR)/Kconfig_arch | ||
105 | else | ||
97 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig_$(SUBARCH) Kconfig_arch) | 106 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig_$(SUBARCH) Kconfig_arch) |
107 | endif | ||
98 | 108 | ||
99 | prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) \ | 109 | prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) |
100 | $(ARCH_DIR)/kernel/vmlinux.lds.S | ||
101 | 110 | ||
102 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static | 111 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static |
103 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib | 112 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib |
104 | 113 | ||
105 | LD_SCRIPT-$(CONFIG_LD_SCRIPT_STATIC) := uml.lds.S | ||
106 | LD_SCRIPT-$(CONFIG_LD_SCRIPT_DYN) := dyn.lds.S | ||
107 | |||
108 | CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT | 114 | CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT |
109 | CONFIG_KERNEL_STACK_ORDER ?= 2 | 115 | CONFIG_KERNEL_STACK_ORDER ?= 2 |
110 | STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) | 116 | STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) |
@@ -126,7 +132,7 @@ define cmd_vmlinux__ | |||
126 | $(CC) $(CFLAGS_vmlinux) -o $@ \ | 132 | $(CC) $(CFLAGS_vmlinux) -o $@ \ |
127 | -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ | 133 | -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ |
128 | -Wl,--start-group $(vmlinux-main) -Wl,--end-group \ | 134 | -Wl,--start-group $(vmlinux-main) -Wl,--end-group \ |
129 | -L/usr/lib -lutil \ | 135 | -lutil \ |
130 | $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \ | 136 | $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \ |
131 | FORCE ,$^) ; rm -f linux | 137 | FORCE ,$^) ; rm -f linux |
132 | endef | 138 | endef |
@@ -145,31 +151,42 @@ archclean: | |||
145 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ | 151 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ |
146 | -o -name '*.gcov' \) -type f -print | xargs rm -f | 152 | -o -name '*.gcov' \) -type f -print | xargs rm -f |
147 | 153 | ||
148 | #We need to re-preprocess this when the symlink dest changes. | ||
149 | #So we touch it when needed. | ||
150 | $(ARCH_DIR)/kernel/vmlinux.lds.S: FORCE | ||
151 | $(Q)if [ "$(shell readlink $@)" != "$(LD_SCRIPT-y)" ]; then \ | ||
152 | echo ' SYMLINK $@'; \ | ||
153 | ln -sf $(LD_SCRIPT-y) $@; \ | ||
154 | touch $@; \ | ||
155 | fi; | ||
156 | |||
157 | $(SYMLINK_HEADERS): | 154 | $(SYMLINK_HEADERS): |
158 | @echo ' SYMLINK $@' | 155 | @echo ' SYMLINK $@' |
156 | ifneq ($(KBUILD_SRC),) | ||
157 | ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ | ||
158 | else | ||
159 | $(Q)cd $(TOPDIR)/$(dir $@) ; \ | 159 | $(Q)cd $(TOPDIR)/$(dir $@) ; \ |
160 | ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) | 160 | ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) |
161 | endif | ||
161 | 162 | ||
162 | include/asm-um/arch: | 163 | include/asm-um/arch: |
163 | @echo ' SYMLINK $@' | 164 | @echo ' SYMLINK $@' |
165 | ifneq ($(KBUILD_SRC),) | ||
166 | $(Q)mkdir -p include/asm-um | ||
167 | $(Q)ln -fsn $(srctree)/include/asm-$(SUBARCH) include/asm-um/arch | ||
168 | else | ||
164 | $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch | 169 | $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch |
170 | endif | ||
165 | 171 | ||
166 | $(ARCH_DIR)/include/sysdep: | 172 | $(ARCH_DIR)/include/sysdep: |
167 | @echo ' SYMLINK $@' | 173 | @echo ' SYMLINK $@' |
174 | ifneq ($(KBUILD_SRC),) | ||
175 | $(Q)mkdir -p $(ARCH_DIR)/include | ||
176 | $(Q)mkdir -p $(ARCH_DIR)/include2 | ||
177 | $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep | ||
178 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep | ||
179 | else | ||
168 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep | 180 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep |
181 | endif | ||
169 | 182 | ||
170 | $(ARCH_DIR)/os: | 183 | $(ARCH_DIR)/os: |
171 | @echo ' SYMLINK $@' | 184 | @echo ' SYMLINK $@' |
185 | ifneq ($(KBUILD_SRC),) | ||
186 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $(ARCH_DIR)/os | ||
187 | else | ||
172 | $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os | 188 | $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os |
189 | endif | ||
173 | 190 | ||
174 | # Generated files | 191 | # Generated files |
175 | define filechk_umlconfig | 192 | define filechk_umlconfig |
@@ -179,10 +196,31 @@ endef | |||
179 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | 196 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h |
180 | $(call filechk,umlconfig) | 197 | $(call filechk,umlconfig) |
181 | 198 | ||
199 | $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c | ||
200 | $(CC) $(USER_CFLAGS) -S -o $@ $< | ||
201 | |||
202 | $(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s | ||
203 | $(call filechk,gen-asm-offsets) | ||
204 | |||
205 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h | ||
206 | |||
207 | $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ | ||
208 | $(ARCH_SYMLINKS) \ | ||
209 | $(SYS_DIR)/sc.h \ | ||
210 | include/asm include/linux/version.h \ | ||
211 | include/config/MARKER \ | ||
212 | $(ARCH_DIR)/include/user_constants.h | ||
213 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< | ||
214 | |||
215 | $(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s | ||
216 | $(call filechk,gen-asm-offsets) | ||
217 | |||
218 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h | ||
219 | |||
182 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task | 220 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task |
183 | $(call filechk,gen_header) | 221 | $(call filechk,gen_header) |
184 | 222 | ||
185 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os/util/mk_user_constants | 223 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants |
186 | $(call filechk,gen_header) | 224 | $(call filechk,gen_header) |
187 | 225 | ||
188 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants | 226 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants |
@@ -191,20 +229,20 @@ $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants | |||
191 | $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs | 229 | $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs |
192 | $(call filechk,gen_header) | 230 | $(call filechk,gen_header) |
193 | 231 | ||
194 | $(ARCH_DIR)/os/util/mk_user_constants: $(ARCH_DIR)/os/util FORCE ; | 232 | $(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ; |
195 | 233 | ||
196 | $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ | 234 | $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ |
197 | FORCE ; | 235 | FORCE ; |
198 | 236 | ||
199 | $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; | 237 | $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; |
200 | 238 | ||
201 | $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h FORCE | 239 | $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE |
202 | $(Q)$(MAKE) $(build)=$@ | 240 | $(Q)$(MAKE) $(build)=$@ |
203 | 241 | ||
204 | $(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE | 242 | $(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE |
205 | $(Q)$(MAKE) $(build)=$@ | 243 | $(Q)$(MAKE) $(build)=$@ |
206 | 244 | ||
207 | $(ARCH_DIR)/os/util: scripts_basic FORCE | 245 | $(ARCH_DIR)/os-$(OS)/util: scripts_basic FORCE |
208 | $(Q)$(MAKE) $(build)=$@ | 246 | $(Q)$(MAKE) $(build)=$@ |
209 | 247 | ||
210 | export SUBARCH USER_CFLAGS OS | 248 | export SUBARCH USER_CFLAGS OS |
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386 index f9e3c0f06541..29e182d5a83a 100644 --- a/arch/um/Makefile-i386 +++ b/arch/um/Makefile-i386 | |||
@@ -32,10 +32,10 @@ $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc | |||
32 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread | 32 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread |
33 | $(call filechk,gen_header) | 33 | $(call filechk,gen_header) |
34 | 34 | ||
35 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic FORCE | 35 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE |
36 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | 36 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ |
37 | 37 | ||
38 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_SYMLINKS) $(GEN_HEADERS) FORCE | 38 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE |
39 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | 39 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ |
40 | 40 | ||
41 | $(SYS_UTIL_DIR): scripts_basic include/asm FORCE | 41 | $(SYS_UTIL_DIR): scripts_basic include/asm FORCE |
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64 index a77971133e91..32144562c279 100644 --- a/arch/um/Makefile-x86_64 +++ b/arch/um/Makefile-x86_64 | |||
@@ -23,10 +23,10 @@ $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc | |||
23 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread | 23 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread |
24 | $(call filechk,gen_header) | 24 | $(call filechk,gen_header) |
25 | 25 | ||
26 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic FORCE | 26 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE |
27 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | 27 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ |
28 | 28 | ||
29 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_SYMLINKS) $(GEN_HEADERS) FORCE | 29 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE |
30 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | 30 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ |
31 | 31 | ||
32 | CLEAN_FILES += $(SYS_HEADERS) | 32 | CLEAN_FILES += $(SYS_HEADERS) |
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index 323f72c64cd2..b2de9916c32c 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile | |||
@@ -22,8 +22,8 @@ obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o | |||
22 | obj-$(CONFIG_SSL) += ssl.o | 22 | obj-$(CONFIG_SSL) += ssl.o |
23 | obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o | 23 | obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o |
24 | 24 | ||
25 | obj-$(CONFIG_UML_NET_SLIP) += slip.o | 25 | obj-$(CONFIG_UML_NET_SLIP) += slip.o slip_common.o |
26 | obj-$(CONFIG_UML_NET_SLIRP) += slirp.o | 26 | obj-$(CONFIG_UML_NET_SLIRP) += slirp.o slip_common.o |
27 | obj-$(CONFIG_UML_NET_DAEMON) += daemon.o | 27 | obj-$(CONFIG_UML_NET_DAEMON) += daemon.o |
28 | obj-$(CONFIG_UML_NET_MCAST) += mcast.o | 28 | obj-$(CONFIG_UML_NET_MCAST) += mcast.o |
29 | #obj-$(CONFIG_UML_NET_PCAP) += pcap.o $(PCAP) | 29 | #obj-$(CONFIG_UML_NET_PCAP) += pcap.o $(PCAP) |
@@ -41,6 +41,6 @@ obj-$(CONFIG_UML_WATCHDOG) += harddog.o | |||
41 | obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o | 41 | obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o |
42 | obj-$(CONFIG_UML_RANDOM) += random.o | 42 | obj-$(CONFIG_UML_RANDOM) += random.o |
43 | 43 | ||
44 | USER_OBJS := fd.o null.o pty.o tty.o xterm.o | 44 | USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o |
45 | 45 | ||
46 | include arch/um/scripts/Makefile.rules | 46 | include arch/um/scripts/Makefile.rules |
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 0150038af795..14a12d6b3df6 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c | |||
@@ -20,9 +20,17 @@ | |||
20 | #include "os.h" | 20 | #include "os.h" |
21 | 21 | ||
22 | #ifdef CONFIG_NOCONFIG_CHAN | 22 | #ifdef CONFIG_NOCONFIG_CHAN |
23 | |||
24 | /* The printk's here are wrong because we are complaining that there is no | ||
25 | * output device, but printk is printing to that output device. The user will | ||
26 | * never see the error. printf would be better, except it can't run on a | ||
27 | * kernel stack because it will overflow it. | ||
28 | * Use printk for now since that will avoid crashing. | ||
29 | */ | ||
30 | |||
23 | static void *not_configged_init(char *str, int device, struct chan_opts *opts) | 31 | static void *not_configged_init(char *str, int device, struct chan_opts *opts) |
24 | { | 32 | { |
25 | printf(KERN_ERR "Using a channel type which is configured out of " | 33 | printk(KERN_ERR "Using a channel type which is configured out of " |
26 | "UML\n"); | 34 | "UML\n"); |
27 | return(NULL); | 35 | return(NULL); |
28 | } | 36 | } |
@@ -30,27 +38,27 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts) | |||
30 | static int not_configged_open(int input, int output, int primary, void *data, | 38 | static int not_configged_open(int input, int output, int primary, void *data, |
31 | char **dev_out) | 39 | char **dev_out) |
32 | { | 40 | { |
33 | printf(KERN_ERR "Using a channel type which is configured out of " | 41 | printk(KERN_ERR "Using a channel type which is configured out of " |
34 | "UML\n"); | 42 | "UML\n"); |
35 | return(-ENODEV); | 43 | return(-ENODEV); |
36 | } | 44 | } |
37 | 45 | ||
38 | static void not_configged_close(int fd, void *data) | 46 | static void not_configged_close(int fd, void *data) |
39 | { | 47 | { |
40 | printf(KERN_ERR "Using a channel type which is configured out of " | 48 | printk(KERN_ERR "Using a channel type which is configured out of " |
41 | "UML\n"); | 49 | "UML\n"); |
42 | } | 50 | } |
43 | 51 | ||
44 | static int not_configged_read(int fd, char *c_out, void *data) | 52 | static int not_configged_read(int fd, char *c_out, void *data) |
45 | { | 53 | { |
46 | printf(KERN_ERR "Using a channel type which is configured out of " | 54 | printk(KERN_ERR "Using a channel type which is configured out of " |
47 | "UML\n"); | 55 | "UML\n"); |
48 | return(-EIO); | 56 | return(-EIO); |
49 | } | 57 | } |
50 | 58 | ||
51 | static int not_configged_write(int fd, const char *buf, int len, void *data) | 59 | static int not_configged_write(int fd, const char *buf, int len, void *data) |
52 | { | 60 | { |
53 | printf(KERN_ERR "Using a channel type which is configured out of " | 61 | printk(KERN_ERR "Using a channel type which is configured out of " |
54 | "UML\n"); | 62 | "UML\n"); |
55 | return(-EIO); | 63 | return(-EIO); |
56 | } | 64 | } |
@@ -58,7 +66,7 @@ static int not_configged_write(int fd, const char *buf, int len, void *data) | |||
58 | static int not_configged_console_write(int fd, const char *buf, int len, | 66 | static int not_configged_console_write(int fd, const char *buf, int len, |
59 | void *data) | 67 | void *data) |
60 | { | 68 | { |
61 | printf(KERN_ERR "Using a channel type which is configured out of " | 69 | printk(KERN_ERR "Using a channel type which is configured out of " |
62 | "UML\n"); | 70 | "UML\n"); |
63 | return(-EIO); | 71 | return(-EIO); |
64 | } | 72 | } |
@@ -66,7 +74,7 @@ static int not_configged_console_write(int fd, const char *buf, int len, | |||
66 | static int not_configged_window_size(int fd, void *data, unsigned short *rows, | 74 | static int not_configged_window_size(int fd, void *data, unsigned short *rows, |
67 | unsigned short *cols) | 75 | unsigned short *cols) |
68 | { | 76 | { |
69 | printf(KERN_ERR "Using a channel type which is configured out of " | 77 | printk(KERN_ERR "Using a channel type which is configured out of " |
70 | "UML\n"); | 78 | "UML\n"); |
71 | return(-ENODEV); | 79 | return(-ENODEV); |
72 | } | 80 | } |
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 583b8e137c33..5d3768156c92 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -143,22 +143,22 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out) | |||
143 | { | 143 | { |
144 | struct winch_data data; | 144 | struct winch_data data; |
145 | unsigned long stack; | 145 | unsigned long stack; |
146 | int fds[2], pid, n, err; | 146 | int fds[2], n, err; |
147 | char c; | 147 | char c; |
148 | 148 | ||
149 | err = os_pipe(fds, 1, 1); | 149 | err = os_pipe(fds, 1, 1); |
150 | if(err < 0){ | 150 | if(err < 0){ |
151 | printk("winch_tramp : os_pipe failed, err = %d\n", -err); | 151 | printk("winch_tramp : os_pipe failed, err = %d\n", -err); |
152 | return(err); | 152 | goto out; |
153 | } | 153 | } |
154 | 154 | ||
155 | data = ((struct winch_data) { .pty_fd = fd, | 155 | data = ((struct winch_data) { .pty_fd = fd, |
156 | .pipe_fd = fds[1], | 156 | .pipe_fd = fds[1], |
157 | .close_me = fds[0] } ); | 157 | .close_me = fds[0] } ); |
158 | pid = run_helper_thread(winch_thread, &data, 0, &stack, 0); | 158 | err = run_helper_thread(winch_thread, &data, 0, &stack, 0); |
159 | if(pid < 0){ | 159 | if(err < 0){ |
160 | printk("fork of winch_thread failed - errno = %d\n", errno); | 160 | printk("fork of winch_thread failed - errno = %d\n", errno); |
161 | return(pid); | 161 | goto out_close; |
162 | } | 162 | } |
163 | 163 | ||
164 | os_close_file(fds[1]); | 164 | os_close_file(fds[1]); |
@@ -168,14 +168,22 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out) | |||
168 | printk("winch_tramp : failed to read synchronization byte\n"); | 168 | printk("winch_tramp : failed to read synchronization byte\n"); |
169 | printk("read failed, err = %d\n", -n); | 169 | printk("read failed, err = %d\n", -n); |
170 | printk("fd %d will not support SIGWINCH\n", fd); | 170 | printk("fd %d will not support SIGWINCH\n", fd); |
171 | *fd_out = -1; | 171 | err = -EINVAL; |
172 | goto out_close1; | ||
172 | } | 173 | } |
173 | return(pid); | 174 | return err ; |
175 | |||
176 | out_close: | ||
177 | os_close_file(fds[1]); | ||
178 | out_close1: | ||
179 | os_close_file(fds[0]); | ||
180 | out: | ||
181 | return err; | ||
174 | } | 182 | } |
175 | 183 | ||
176 | void register_winch(int fd, struct tty_struct *tty) | 184 | void register_winch(int fd, struct tty_struct *tty) |
177 | { | 185 | { |
178 | int pid, thread, thread_fd; | 186 | int pid, thread, thread_fd = -1; |
179 | int count; | 187 | int count; |
180 | char c = 1; | 188 | char c = 1; |
181 | 189 | ||
@@ -186,7 +194,7 @@ void register_winch(int fd, struct tty_struct *tty) | |||
186 | if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, | 194 | if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, |
187 | tty) && (pid == -1)){ | 195 | tty) && (pid == -1)){ |
188 | thread = winch_tramp(fd, tty, &thread_fd); | 196 | thread = winch_tramp(fd, tty, &thread_fd); |
189 | if(fd != -1){ | 197 | if(thread > 0){ |
190 | register_winch_irq(thread_fd, fd, thread, tty); | 198 | register_winch_irq(thread_fd, fd, thread, tty); |
191 | 199 | ||
192 | count = os_write_file(thread_fd, &c, sizeof(c)); | 200 | count = os_write_file(thread_fd, &c, sizeof(c)); |
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index d0f97127adf6..025d3be8aca4 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c | |||
@@ -462,12 +462,15 @@ out: | |||
462 | return err; | 462 | return err; |
463 | } | 463 | } |
464 | 464 | ||
465 | static void unregister_winch(struct tty_struct *tty); | ||
466 | |||
465 | void line_close(struct tty_struct *tty, struct file * filp) | 467 | void line_close(struct tty_struct *tty, struct file * filp) |
466 | { | 468 | { |
467 | struct line *line = tty->driver_data; | 469 | struct line *line = tty->driver_data; |
468 | 470 | ||
469 | /* XXX: I assume this should be called in process context, not with interrupt | 471 | /* XXX: I assume this should be called in process context, not with |
470 | * disabled!*/ | 472 | * interrupts disabled! |
473 | */ | ||
471 | spin_lock_irq(&line->lock); | 474 | spin_lock_irq(&line->lock); |
472 | 475 | ||
473 | /* We ignore the error anyway! */ | 476 | /* We ignore the error anyway! */ |
@@ -478,6 +481,12 @@ void line_close(struct tty_struct *tty, struct file * filp) | |||
478 | line_disable(tty, -1); | 481 | line_disable(tty, -1); |
479 | tty->driver_data = NULL; | 482 | tty->driver_data = NULL; |
480 | } | 483 | } |
484 | |||
485 | if((line->count == 0) && line->sigio){ | ||
486 | unregister_winch(tty); | ||
487 | line->sigio = 0; | ||
488 | } | ||
489 | |||
481 | spin_unlock_irq(&line->lock); | 490 | spin_unlock_irq(&line->lock); |
482 | } | 491 | } |
483 | 492 | ||
@@ -729,6 +738,34 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty) | |||
729 | up(&winch_handler_sem); | 738 | up(&winch_handler_sem); |
730 | } | 739 | } |
731 | 740 | ||
741 | static void unregister_winch(struct tty_struct *tty) | ||
742 | { | ||
743 | struct list_head *ele; | ||
744 | struct winch *winch, *found = NULL; | ||
745 | |||
746 | down(&winch_handler_sem); | ||
747 | list_for_each(ele, &winch_handlers){ | ||
748 | winch = list_entry(ele, struct winch, list); | ||
749 | if(winch->tty == tty){ | ||
750 | found = winch; | ||
751 | break; | ||
752 | } | ||
753 | } | ||
754 | |||
755 | if(found == NULL) | ||
756 | goto out; | ||
757 | |||
758 | if(winch->pid != -1) | ||
759 | os_kill_process(winch->pid, 1); | ||
760 | |||
761 | free_irq_by_irq_and_dev(WINCH_IRQ, winch); | ||
762 | free_irq(WINCH_IRQ, winch); | ||
763 | list_del(&winch->list); | ||
764 | kfree(winch); | ||
765 | out: | ||
766 | up(&winch_handler_sem); | ||
767 | } | ||
768 | |||
732 | static void winch_cleanup(void) | 769 | static void winch_cleanup(void) |
733 | { | 770 | { |
734 | struct list_head *ele; | 771 | struct list_head *ele; |
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c index faf714e87b5b..217438cdef33 100644 --- a/arch/um/drivers/mcast_kern.c +++ b/arch/um/drivers/mcast_kern.c | |||
@@ -73,7 +73,6 @@ int mcast_setup(char *str, char **mac_out, void *data) | |||
73 | struct mcast_init *init = data; | 73 | struct mcast_init *init = data; |
74 | char *port_str = NULL, *ttl_str = NULL, *remain; | 74 | char *port_str = NULL, *ttl_str = NULL, *remain; |
75 | char *last; | 75 | char *last; |
76 | int n; | ||
77 | 76 | ||
78 | *init = ((struct mcast_init) | 77 | *init = ((struct mcast_init) |
79 | { .addr = "239.192.168.1", | 78 | { .addr = "239.192.168.1", |
@@ -89,13 +88,12 @@ int mcast_setup(char *str, char **mac_out, void *data) | |||
89 | } | 88 | } |
90 | 89 | ||
91 | if(port_str != NULL){ | 90 | if(port_str != NULL){ |
92 | n = simple_strtoul(port_str, &last, 10); | 91 | init->port = simple_strtoul(port_str, &last, 10); |
93 | if((*last != '\0') || (last == port_str)){ | 92 | if((*last != '\0') || (last == port_str)){ |
94 | printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", | 93 | printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", |
95 | port_str); | 94 | port_str); |
96 | return(0); | 95 | return(0); |
97 | } | 96 | } |
98 | init->port = htons(n); | ||
99 | } | 97 | } |
100 | 98 | ||
101 | if(ttl_str != NULL){ | 99 | if(ttl_str != NULL){ |
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 0fe1d9fa9139..7a0d115b29d0 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
@@ -38,7 +38,7 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port) | |||
38 | } | 38 | } |
39 | sin->sin_family = AF_INET; | 39 | sin->sin_family = AF_INET; |
40 | sin->sin_addr.s_addr = in_aton(addr); | 40 | sin->sin_addr.s_addr = in_aton(addr); |
41 | sin->sin_port = port; | 41 | sin->sin_port = htons(port); |
42 | return(sin); | 42 | return(sin); |
43 | } | 43 | } |
44 | 44 | ||
@@ -55,28 +55,25 @@ static int mcast_open(void *data) | |||
55 | struct mcast_data *pri = data; | 55 | struct mcast_data *pri = data; |
56 | struct sockaddr_in *sin = pri->mcast_addr; | 56 | struct sockaddr_in *sin = pri->mcast_addr; |
57 | struct ip_mreq mreq; | 57 | struct ip_mreq mreq; |
58 | int fd, yes = 1; | 58 | int fd = -EINVAL, yes = 1, err = -EINVAL;; |
59 | 59 | ||
60 | 60 | ||
61 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) { | 61 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) |
62 | fd = -EINVAL; | ||
63 | goto out; | 62 | goto out; |
64 | } | ||
65 | 63 | ||
66 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 64 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
65 | |||
67 | if (fd < 0){ | 66 | if (fd < 0){ |
68 | printk("mcast_open : data socket failed, errno = %d\n", | 67 | printk("mcast_open : data socket failed, errno = %d\n", |
69 | errno); | 68 | errno); |
70 | fd = -ENOMEM; | 69 | fd = -errno; |
71 | goto out; | 70 | goto out; |
72 | } | 71 | } |
73 | 72 | ||
74 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { | 73 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { |
75 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", | 74 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", |
76 | errno); | 75 | errno); |
77 | os_close_file(fd); | 76 | goto out_close; |
78 | fd = -EINVAL; | ||
79 | goto out; | ||
80 | } | 77 | } |
81 | 78 | ||
82 | /* set ttl according to config */ | 79 | /* set ttl according to config */ |
@@ -84,26 +81,20 @@ static int mcast_open(void *data) | |||
84 | sizeof(pri->ttl)) < 0) { | 81 | sizeof(pri->ttl)) < 0) { |
85 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", | 82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", |
86 | errno); | 83 | errno); |
87 | os_close_file(fd); | 84 | goto out_close; |
88 | fd = -EINVAL; | ||
89 | goto out; | ||
90 | } | 85 | } |
91 | 86 | ||
92 | /* set LOOP, so data does get fed back to local sockets */ | 87 | /* set LOOP, so data does get fed back to local sockets */ |
93 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { | 88 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { |
94 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", | 89 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", |
95 | errno); | 90 | errno); |
96 | os_close_file(fd); | 91 | goto out_close; |
97 | fd = -EINVAL; | ||
98 | goto out; | ||
99 | } | 92 | } |
100 | 93 | ||
101 | /* bind socket to mcast address */ | 94 | /* bind socket to mcast address */ |
102 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { | 95 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { |
103 | printk("mcast_open : data bind failed, errno = %d\n", errno); | 96 | printk("mcast_open : data bind failed, errno = %d\n", errno); |
104 | os_close_file(fd); | 97 | goto out_close; |
105 | fd = -EINVAL; | ||
106 | goto out; | ||
107 | } | 98 | } |
108 | 99 | ||
109 | /* subscribe to the multicast group */ | 100 | /* subscribe to the multicast group */ |
@@ -117,12 +108,15 @@ static int mcast_open(void *data) | |||
117 | "interface on the host.\n"); | 108 | "interface on the host.\n"); |
118 | printk("eth0 should be configured in order to use the " | 109 | printk("eth0 should be configured in order to use the " |
119 | "multicast transport.\n"); | 110 | "multicast transport.\n"); |
120 | os_close_file(fd); | 111 | goto out_close; |
121 | fd = -EINVAL; | ||
122 | } | 112 | } |
123 | 113 | ||
124 | out: | 114 | out: |
125 | return(fd); | 115 | return fd; |
116 | |||
117 | out_close: | ||
118 | os_close_file(fd); | ||
119 | return err; | ||
126 | } | 120 | } |
127 | 121 | ||
128 | static void mcast_close(int fd, void *data) | 122 | static void mcast_close(int fd, void *data) |
@@ -164,14 +158,3 @@ struct net_user_info mcast_user_info = { | |||
164 | .delete_address = NULL, | 158 | .delete_address = NULL, |
165 | .max_packet = MAX_PACKET - ETH_HEADER_OTHER | 159 | .max_packet = MAX_PACKET - ETH_HEADER_OTHER |
166 | }; | 160 | }; |
167 | |||
168 | /* | ||
169 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
170 | * Emacs will notice this stuff at the end of the file and automatically | ||
171 | * adjust the settings for this buffer only. This must remain at the end | ||
172 | * of the file. | ||
173 | * --------------------------------------------------------------------------- | ||
174 | * Local variables: | ||
175 | * c-file-style: "linux" | ||
176 | * End: | ||
177 | */ | ||
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c index a63231dffe05..a37a5ac13c22 100644 --- a/arch/um/drivers/mmapper_kern.c +++ b/arch/um/drivers/mmapper_kern.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/smp_lock.h> | 20 | #include <linux/smp_lock.h> |
21 | #include <linux/miscdevice.h> | ||
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
22 | #include <asm/irq.h> | 23 | #include <asm/irq.h> |
23 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
@@ -117,24 +118,39 @@ static struct file_operations mmapper_fops = { | |||
117 | .release = mmapper_release, | 118 | .release = mmapper_release, |
118 | }; | 119 | }; |
119 | 120 | ||
121 | static struct miscdevice mmapper_dev = { | ||
122 | .minor = MISC_DYNAMIC_MINOR, | ||
123 | .name = "mmapper", | ||
124 | .fops = &mmapper_fops | ||
125 | }; | ||
126 | |||
120 | static int __init mmapper_init(void) | 127 | static int __init mmapper_init(void) |
121 | { | 128 | { |
129 | int err; | ||
130 | |||
122 | printk(KERN_INFO "Mapper v0.1\n"); | 131 | printk(KERN_INFO "Mapper v0.1\n"); |
123 | 132 | ||
124 | v_buf = (char *) find_iomem("mmapper", &mmapper_size); | 133 | v_buf = (char *) find_iomem("mmapper", &mmapper_size); |
125 | if(mmapper_size == 0){ | 134 | if(mmapper_size == 0){ |
126 | printk(KERN_ERR "mmapper_init - find_iomem failed\n"); | 135 | printk(KERN_ERR "mmapper_init - find_iomem failed\n"); |
127 | return(0); | 136 | goto out; |
128 | } | 137 | } |
129 | 138 | ||
130 | p_buf = __pa(v_buf); | 139 | err = misc_register(&mmapper_dev); |
140 | if(err){ | ||
141 | printk(KERN_ERR "mmapper - misc_register failed, err = %d\n", | ||
142 | err); | ||
143 | goto out; | ||
144 | } | ||
131 | 145 | ||
132 | devfs_mk_cdev(MKDEV(30, 0), S_IFCHR|S_IRUGO|S_IWUGO, "mmapper"); | 146 | p_buf = __pa(v_buf); |
133 | return(0); | 147 | out: |
148 | return 0; | ||
134 | } | 149 | } |
135 | 150 | ||
136 | static void mmapper_exit(void) | 151 | static void mmapper_exit(void) |
137 | { | 152 | { |
153 | misc_deregister(&mmapper_dev); | ||
138 | } | 154 | } |
139 | 155 | ||
140 | module_init(mmapper_init); | 156 | module_init(mmapper_init); |
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c index 47229fe4a813..3730d4f12713 100644 --- a/arch/um/drivers/net_user.c +++ b/arch/um/drivers/net_user.c | |||
@@ -32,7 +32,7 @@ int tap_open_common(void *dev, char *gate_addr) | |||
32 | return(0); | 32 | return(0); |
33 | } | 33 | } |
34 | 34 | ||
35 | void tap_check_ips(char *gate_addr, char *eth_addr) | 35 | void tap_check_ips(char *gate_addr, unsigned char *eth_addr) |
36 | { | 36 | { |
37 | int tap_addr[4]; | 37 | int tap_addr[4]; |
38 | 38 | ||
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c index d43e9fab05a7..f9e22198e011 100644 --- a/arch/um/drivers/random.c +++ b/arch/um/drivers/random.c | |||
@@ -1,5 +1,10 @@ | |||
1 | /* Much of this ripped from hw_random.c */ | 1 | /* Copyright (C) 2005 Jeff Dike <jdike@addtoit.com> */ |
2 | 2 | /* Much of this ripped from drivers/char/hw_random.c, see there for other | |
3 | * copyright. | ||
4 | * | ||
5 | * This software may be used and distributed according to the terms | ||
6 | * of the GNU General Public License, incorporated herein by reference. | ||
7 | */ | ||
3 | #include <linux/module.h> | 8 | #include <linux/module.h> |
4 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
5 | #include <linux/miscdevice.h> | 10 | #include <linux/miscdevice.h> |
@@ -12,8 +17,6 @@ | |||
12 | */ | 17 | */ |
13 | #define RNG_VERSION "1.0.0" | 18 | #define RNG_VERSION "1.0.0" |
14 | #define RNG_MODULE_NAME "random" | 19 | #define RNG_MODULE_NAME "random" |
15 | #define RNG_DRIVER_NAME RNG_MODULE_NAME " virtual driver " RNG_VERSION | ||
16 | #define PFX RNG_MODULE_NAME ": " | ||
17 | 20 | ||
18 | #define RNG_MISCDEV_MINOR 183 /* official */ | 21 | #define RNG_MISCDEV_MINOR 183 /* official */ |
19 | 22 | ||
@@ -98,7 +101,7 @@ static int __init rng_init (void) | |||
98 | 101 | ||
99 | err = misc_register (&rng_miscdev); | 102 | err = misc_register (&rng_miscdev); |
100 | if (err) { | 103 | if (err) { |
101 | printk (KERN_ERR PFX "misc device register failed\n"); | 104 | printk (KERN_ERR RNG_MODULE_NAME ": misc device register failed\n"); |
102 | goto err_out_cleanup_hw; | 105 | goto err_out_cleanup_hw; |
103 | } | 106 | } |
104 | 107 | ||
@@ -120,3 +123,6 @@ static void __exit rng_cleanup (void) | |||
120 | 123 | ||
121 | module_init (rng_init); | 124 | module_init (rng_init); |
122 | module_exit (rng_cleanup); | 125 | module_exit (rng_cleanup); |
126 | |||
127 | MODULE_DESCRIPTION("UML Host Random Number Generator (RNG) driver"); | ||
128 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/um/drivers/slip.h b/arch/um/drivers/slip.h index 495f2f1b1420..bb0dab41c2e4 100644 --- a/arch/um/drivers/slip.h +++ b/arch/um/drivers/slip.h | |||
@@ -1,10 +1,7 @@ | |||
1 | #ifndef __UM_SLIP_H | 1 | #ifndef __UM_SLIP_H |
2 | #define __UM_SLIP_H | 2 | #define __UM_SLIP_H |
3 | 3 | ||
4 | #define BUF_SIZE 1500 | 4 | #include "slip_common.h" |
5 | /* two bytes each for a (pathological) max packet of escaped chars + * | ||
6 | * terminating END char + initial END char */ | ||
7 | #define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
8 | 5 | ||
9 | struct slip_data { | 6 | struct slip_data { |
10 | void *dev; | 7 | void *dev; |
@@ -12,28 +9,12 @@ struct slip_data { | |||
12 | char *addr; | 9 | char *addr; |
13 | char *gate_addr; | 10 | char *gate_addr; |
14 | int slave; | 11 | int slave; |
15 | char ibuf[ENC_BUF_SIZE]; | 12 | struct slip_proto slip; |
16 | char obuf[ENC_BUF_SIZE]; | ||
17 | int more; /* more data: do not read fd until ibuf has been drained */ | ||
18 | int pos; | ||
19 | int esc; | ||
20 | }; | 13 | }; |
21 | 14 | ||
22 | extern struct net_user_info slip_user_info; | 15 | extern struct net_user_info slip_user_info; |
23 | 16 | ||
24 | extern int set_umn_addr(int fd, char *addr, char *ptp_addr); | ||
25 | extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); | 17 | extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); |
26 | extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri); | 18 | extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri); |
27 | 19 | ||
28 | #endif | 20 | #endif |
29 | |||
30 | /* | ||
31 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
32 | * Emacs will notice this stuff at the end of the file and automatically | ||
33 | * adjust the settings for this buffer only. This must remain at the end | ||
34 | * of the file. | ||
35 | * --------------------------------------------------------------------------- | ||
36 | * Local variables: | ||
37 | * c-file-style: "linux" | ||
38 | * End: | ||
39 | */ | ||
diff --git a/arch/um/drivers/slip_common.c b/arch/um/drivers/slip_common.c new file mode 100644 index 000000000000..e89cfc68fc3e --- /dev/null +++ b/arch/um/drivers/slip_common.c | |||
@@ -0,0 +1,54 @@ | |||
1 | #include <string.h> | ||
2 | #include "slip_common.h" | ||
3 | #include "net_user.h" | ||
4 | |||
5 | int slip_proto_read(int fd, void *buf, int len, struct slip_proto *slip) | ||
6 | { | ||
7 | int i, n, size, start; | ||
8 | |||
9 | if(slip->more > 0){ | ||
10 | i = 0; | ||
11 | while(i < slip->more){ | ||
12 | size = slip_unesc(slip->ibuf[i++], slip->ibuf, | ||
13 | &slip->pos, &slip->esc); | ||
14 | if(size){ | ||
15 | memcpy(buf, slip->ibuf, size); | ||
16 | memmove(slip->ibuf, &slip->ibuf[i], | ||
17 | slip->more - i); | ||
18 | slip->more = slip->more - i; | ||
19 | return size; | ||
20 | } | ||
21 | } | ||
22 | slip->more = 0; | ||
23 | } | ||
24 | |||
25 | n = net_read(fd, &slip->ibuf[slip->pos], | ||
26 | sizeof(slip->ibuf) - slip->pos); | ||
27 | if(n <= 0) | ||
28 | return n; | ||
29 | |||
30 | start = slip->pos; | ||
31 | for(i = 0; i < n; i++){ | ||
32 | size = slip_unesc(slip->ibuf[start + i], slip->ibuf,&slip->pos, | ||
33 | &slip->esc); | ||
34 | if(size){ | ||
35 | memcpy(buf, slip->ibuf, size); | ||
36 | memmove(slip->ibuf, &slip->ibuf[start+i+1], | ||
37 | n - (i + 1)); | ||
38 | slip->more = n - (i + 1); | ||
39 | return size; | ||
40 | } | ||
41 | } | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | int slip_proto_write(int fd, void *buf, int len, struct slip_proto *slip) | ||
46 | { | ||
47 | int actual, n; | ||
48 | |||
49 | actual = slip_esc(buf, slip->obuf, len); | ||
50 | n = net_write(fd, slip->obuf, actual); | ||
51 | if(n < 0) | ||
52 | return n; | ||
53 | else return len; | ||
54 | } | ||
diff --git a/arch/um/drivers/slip_proto.h b/arch/um/drivers/slip_common.h index 7206361ace45..2ae76d8f1be1 100644 --- a/arch/um/drivers/slip_proto.h +++ b/arch/um/drivers/slip_common.h | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | #ifndef __UM_SLIP_COMMON_H |
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | #define __UM_SLIP_COMMON_H |
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | 3 | ||
6 | #ifndef __UM_SLIP_PROTO_H__ | 4 | #define BUF_SIZE 1500 |
7 | #define __UM_SLIP_PROTO_H__ | 5 | /* two bytes each for a (pathological) max packet of escaped chars + * |
6 | * terminating END char + initial END char */ | ||
7 | #define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
8 | 8 | ||
9 | /* SLIP protocol characters. */ | 9 | /* SLIP protocol characters. */ |
10 | #define SLIP_END 0300 /* indicates end of frame */ | 10 | #define SLIP_END 0300 /* indicates end of frame */ |
@@ -12,7 +12,8 @@ | |||
12 | #define SLIP_ESC_END 0334 /* ESC ESC_END means END 'data' */ | 12 | #define SLIP_ESC_END 0334 /* ESC ESC_END means END 'data' */ |
13 | #define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */ | 13 | #define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */ |
14 | 14 | ||
15 | static inline int slip_unesc(unsigned char c,char *buf,int *pos, int *esc) | 15 | static inline int slip_unesc(unsigned char c, unsigned char *buf, int *pos, |
16 | int *esc) | ||
16 | { | 17 | { |
17 | int ret; | 18 | int ret; |
18 | 19 | ||
@@ -79,15 +80,25 @@ static inline int slip_esc(unsigned char *s, unsigned char *d, int len) | |||
79 | return (ptr - d); | 80 | return (ptr - d); |
80 | } | 81 | } |
81 | 82 | ||
82 | #endif | 83 | struct slip_proto { |
84 | unsigned char ibuf[ENC_BUF_SIZE]; | ||
85 | unsigned char obuf[ENC_BUF_SIZE]; | ||
86 | int more; /* more data: do not read fd until ibuf has been drained */ | ||
87 | int pos; | ||
88 | int esc; | ||
89 | }; | ||
90 | |||
91 | #define SLIP_PROTO_INIT { \ | ||
92 | .ibuf = { '\0' }, \ | ||
93 | .obuf = { '\0' }, \ | ||
94 | .more = 0, \ | ||
95 | .pos = 0, \ | ||
96 | .esc = 0 \ | ||
97 | } | ||
83 | 98 | ||
84 | /* | 99 | extern int slip_proto_read(int fd, void *buf, int len, |
85 | * Overrides for Emacs so that we follow Linus's tabbing style. | 100 | struct slip_proto *slip); |
86 | * Emacs will notice this stuff at the end of the file and automatically | 101 | extern int slip_proto_write(int fd, void *buf, int len, |
87 | * adjust the settings for this buffer only. This must remain at the end | 102 | struct slip_proto *slip); |
88 | * of the file. | 103 | |
89 | * --------------------------------------------------------------------------- | 104 | #endif |
90 | * Local variables: | ||
91 | * c-file-style: "linux" | ||
92 | * End: | ||
93 | */ | ||
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c index 0886eedba213..9a6f5c85f902 100644 --- a/arch/um/drivers/slip_kern.c +++ b/arch/um/drivers/slip_kern.c | |||
@@ -26,16 +26,16 @@ void slip_init(struct net_device *dev, void *data) | |||
26 | .addr = NULL, | 26 | .addr = NULL, |
27 | .gate_addr = init->gate_addr, | 27 | .gate_addr = init->gate_addr, |
28 | .slave = -1, | 28 | .slave = -1, |
29 | .ibuf = { '\0' }, | 29 | .slip = SLIP_PROTO_INIT, |
30 | .obuf = { '\0' }, | ||
31 | .pos = 0, | ||
32 | .esc = 0, | ||
33 | .dev = dev }); | 30 | .dev = dev }); |
34 | 31 | ||
35 | dev->init = NULL; | 32 | dev->init = NULL; |
33 | dev->header_cache_update = NULL; | ||
34 | dev->hard_header_cache = NULL; | ||
35 | dev->hard_header = NULL; | ||
36 | dev->hard_header_len = 0; | 36 | dev->hard_header_len = 0; |
37 | dev->addr_len = 4; | 37 | dev->addr_len = 0; |
38 | dev->type = ARPHRD_ETHER; | 38 | dev->type = ARPHRD_SLIP; |
39 | dev->tx_queue_len = 256; | 39 | dev->tx_queue_len = 256; |
40 | dev->flags = IFF_NOARP; | 40 | dev->flags = IFF_NOARP; |
41 | printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr); | 41 | printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr); |
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c index d94846b1b4cf..71af444e591f 100644 --- a/arch/um/drivers/slip_user.c +++ b/arch/um/drivers/slip_user.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "user.h" | 13 | #include "user.h" |
14 | #include "net_user.h" | 14 | #include "net_user.h" |
15 | #include "slip.h" | 15 | #include "slip.h" |
16 | #include "slip_proto.h" | 16 | #include "slip_common.h" |
17 | #include "helper.h" | 17 | #include "helper.h" |
18 | #include "os.h" | 18 | #include "os.h" |
19 | 19 | ||
@@ -77,41 +77,51 @@ static int slip_tramp(char **argv, int fd) | |||
77 | err = os_pipe(fds, 1, 0); | 77 | err = os_pipe(fds, 1, 0); |
78 | if(err < 0){ | 78 | if(err < 0){ |
79 | printk("slip_tramp : pipe failed, err = %d\n", -err); | 79 | printk("slip_tramp : pipe failed, err = %d\n", -err); |
80 | return(err); | 80 | goto out; |
81 | } | 81 | } |
82 | 82 | ||
83 | err = 0; | 83 | err = 0; |
84 | pe_data.stdin = fd; | 84 | pe_data.stdin = fd; |
85 | pe_data.stdout = fds[1]; | 85 | pe_data.stdout = fds[1]; |
86 | pe_data.close_me = fds[0]; | 86 | pe_data.close_me = fds[0]; |
87 | pid = run_helper(slip_pre_exec, &pe_data, argv, NULL); | 87 | err = run_helper(slip_pre_exec, &pe_data, argv, NULL); |
88 | if(err < 0) | ||
89 | goto out_close; | ||
90 | pid = err; | ||
91 | |||
92 | output_len = page_size(); | ||
93 | output = um_kmalloc(output_len); | ||
94 | if(output == NULL){ | ||
95 | printk("slip_tramp : failed to allocate output buffer\n"); | ||
96 | os_kill_process(pid, 1); | ||
97 | err = -ENOMEM; | ||
98 | goto out_free; | ||
99 | } | ||
88 | 100 | ||
89 | if(pid < 0) err = pid; | 101 | os_close_file(fds[1]); |
90 | else { | 102 | read_output(fds[0], output, output_len); |
91 | output_len = page_size(); | 103 | printk("%s", output); |
92 | output = um_kmalloc(output_len); | 104 | |
93 | if(output == NULL) | 105 | CATCH_EINTR(err = waitpid(pid, &status, 0)); |
94 | printk("slip_tramp : failed to allocate output " | 106 | if(err < 0) |
95 | "buffer\n"); | 107 | err = errno; |
96 | 108 | else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){ | |
97 | os_close_file(fds[1]); | 109 | printk("'%s' didn't exit with status 0\n", argv[0]); |
98 | read_output(fds[0], output, output_len); | 110 | err = -EINVAL; |
99 | if(output != NULL){ | ||
100 | printk("%s", output); | ||
101 | kfree(output); | ||
102 | } | ||
103 | CATCH_EINTR(err = waitpid(pid, &status, 0)); | ||
104 | if(err < 0) | ||
105 | err = errno; | ||
106 | else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){ | ||
107 | printk("'%s' didn't exit with status 0\n", argv[0]); | ||
108 | err = -EINVAL; | ||
109 | } | ||
110 | } | 111 | } |
112 | else err = 0; | ||
111 | 113 | ||
112 | os_close_file(fds[0]); | 114 | os_close_file(fds[0]); |
113 | 115 | ||
114 | return(err); | 116 | out_free: |
117 | kfree(output); | ||
118 | return err; | ||
119 | |||
120 | out_close: | ||
121 | os_close_file(fds[0]); | ||
122 | os_close_file(fds[1]); | ||
123 | out: | ||
124 | return err; | ||
115 | } | 125 | } |
116 | 126 | ||
117 | static int slip_open(void *data) | 127 | static int slip_open(void *data) |
@@ -123,21 +133,26 @@ static int slip_open(void *data) | |||
123 | NULL }; | 133 | NULL }; |
124 | int sfd, mfd, err; | 134 | int sfd, mfd, err; |
125 | 135 | ||
126 | mfd = get_pty(); | 136 | err = get_pty(); |
127 | if(mfd < 0){ | 137 | if(err < 0){ |
128 | printk("umn : Failed to open pty, err = %d\n", -mfd); | 138 | printk("slip-open : Failed to open pty, err = %d\n", -err); |
129 | return(mfd); | 139 | goto out; |
130 | } | 140 | } |
131 | sfd = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0); | 141 | mfd = err; |
132 | if(sfd < 0){ | 142 | |
133 | printk("Couldn't open tty for slip line, err = %d\n", -sfd); | 143 | err = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0); |
134 | os_close_file(mfd); | 144 | if(err < 0){ |
135 | return(sfd); | 145 | printk("Couldn't open tty for slip line, err = %d\n", -err); |
146 | goto out_close; | ||
136 | } | 147 | } |
137 | if(set_up_tty(sfd)) return(-1); | 148 | sfd = err; |
149 | |||
150 | if(set_up_tty(sfd)) | ||
151 | goto out_close2; | ||
152 | |||
138 | pri->slave = sfd; | 153 | pri->slave = sfd; |
139 | pri->pos = 0; | 154 | pri->slip.pos = 0; |
140 | pri->esc = 0; | 155 | pri->slip.esc = 0; |
141 | if(pri->gate_addr != NULL){ | 156 | if(pri->gate_addr != NULL){ |
142 | sprintf(version_buf, "%d", UML_NET_VERSION); | 157 | sprintf(version_buf, "%d", UML_NET_VERSION); |
143 | strcpy(gate_buf, pri->gate_addr); | 158 | strcpy(gate_buf, pri->gate_addr); |
@@ -146,12 +161,12 @@ static int slip_open(void *data) | |||
146 | 161 | ||
147 | if(err < 0){ | 162 | if(err < 0){ |
148 | printk("slip_tramp failed - err = %d\n", -err); | 163 | printk("slip_tramp failed - err = %d\n", -err); |
149 | return(err); | 164 | goto out_close2; |
150 | } | 165 | } |
151 | err = os_get_ifname(pri->slave, pri->name); | 166 | err = os_get_ifname(pri->slave, pri->name); |
152 | if(err < 0){ | 167 | if(err < 0){ |
153 | printk("get_ifname failed, err = %d\n", -err); | 168 | printk("get_ifname failed, err = %d\n", -err); |
154 | return(err); | 169 | goto out_close2; |
155 | } | 170 | } |
156 | iter_addresses(pri->dev, open_addr, pri->name); | 171 | iter_addresses(pri->dev, open_addr, pri->name); |
157 | } | 172 | } |
@@ -160,10 +175,16 @@ static int slip_open(void *data) | |||
160 | if(err < 0){ | 175 | if(err < 0){ |
161 | printk("Failed to set slip discipline encapsulation - " | 176 | printk("Failed to set slip discipline encapsulation - " |
162 | "err = %d\n", -err); | 177 | "err = %d\n", -err); |
163 | return(err); | 178 | goto out_close2; |
164 | } | 179 | } |
165 | } | 180 | } |
166 | return(mfd); | 181 | return(mfd); |
182 | out_close2: | ||
183 | os_close_file(sfd); | ||
184 | out_close: | ||
185 | os_close_file(mfd); | ||
186 | out: | ||
187 | return err; | ||
167 | } | 188 | } |
168 | 189 | ||
169 | static void slip_close(int fd, void *data) | 190 | static void slip_close(int fd, void *data) |
@@ -190,48 +211,12 @@ static void slip_close(int fd, void *data) | |||
190 | 211 | ||
191 | int slip_user_read(int fd, void *buf, int len, struct slip_data *pri) | 212 | int slip_user_read(int fd, void *buf, int len, struct slip_data *pri) |
192 | { | 213 | { |
193 | int i, n, size, start; | 214 | return slip_proto_read(fd, buf, len, &pri->slip); |
194 | |||
195 | if(pri->more>0) { | ||
196 | i = 0; | ||
197 | while(i < pri->more) { | ||
198 | size = slip_unesc(pri->ibuf[i++], | ||
199 | pri->ibuf, &pri->pos, &pri->esc); | ||
200 | if(size){ | ||
201 | memcpy(buf, pri->ibuf, size); | ||
202 | memmove(pri->ibuf, &pri->ibuf[i], pri->more-i); | ||
203 | pri->more=pri->more-i; | ||
204 | return(size); | ||
205 | } | ||
206 | } | ||
207 | pri->more=0; | ||
208 | } | ||
209 | |||
210 | n = net_read(fd, &pri->ibuf[pri->pos], sizeof(pri->ibuf) - pri->pos); | ||
211 | if(n <= 0) return(n); | ||
212 | |||
213 | start = pri->pos; | ||
214 | for(i = 0; i < n; i++){ | ||
215 | size = slip_unesc(pri->ibuf[start + i], | ||
216 | pri->ibuf, &pri->pos, &pri->esc); | ||
217 | if(size){ | ||
218 | memcpy(buf, pri->ibuf, size); | ||
219 | memmove(pri->ibuf, &pri->ibuf[start+i+1], n-(i+1)); | ||
220 | pri->more=n-(i+1); | ||
221 | return(size); | ||
222 | } | ||
223 | } | ||
224 | return(0); | ||
225 | } | 215 | } |
226 | 216 | ||
227 | int slip_user_write(int fd, void *buf, int len, struct slip_data *pri) | 217 | int slip_user_write(int fd, void *buf, int len, struct slip_data *pri) |
228 | { | 218 | { |
229 | int actual, n; | 219 | return slip_proto_write(fd, buf, len, &pri->slip); |
230 | |||
231 | actual = slip_esc(buf, pri->obuf, len); | ||
232 | n = net_write(fd, pri->obuf, actual); | ||
233 | if(n < 0) return(n); | ||
234 | else return(len); | ||
235 | } | 220 | } |
236 | 221 | ||
237 | static int slip_set_mtu(int mtu, void *data) | 222 | static int slip_set_mtu(int mtu, void *data) |
@@ -267,14 +252,3 @@ struct net_user_info slip_user_info = { | |||
267 | .delete_address = slip_del_addr, | 252 | .delete_address = slip_del_addr, |
268 | .max_packet = BUF_SIZE | 253 | .max_packet = BUF_SIZE |
269 | }; | 254 | }; |
270 | |||
271 | /* | ||
272 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
273 | * Emacs will notice this stuff at the end of the file and automatically | ||
274 | * adjust the settings for this buffer only. This must remain at the end | ||
275 | * of the file. | ||
276 | * --------------------------------------------------------------------------- | ||
277 | * Local variables: | ||
278 | * c-file-style: "linux" | ||
279 | * End: | ||
280 | */ | ||
diff --git a/arch/um/drivers/slirp.h b/arch/um/drivers/slirp.h index 04e407d1e44a..6cf88ab580c9 100644 --- a/arch/um/drivers/slirp.h +++ b/arch/um/drivers/slirp.h | |||
@@ -1,10 +1,7 @@ | |||
1 | #ifndef __UM_SLIRP_H | 1 | #ifndef __UM_SLIRP_H |
2 | #define __UM_SLIRP_H | 2 | #define __UM_SLIRP_H |
3 | 3 | ||
4 | #define BUF_SIZE 1500 | 4 | #include "slip_common.h" |
5 | /* two bytes each for a (pathological) max packet of escaped chars + * | ||
6 | * terminating END char + initial END char */ | ||
7 | #define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
8 | 5 | ||
9 | #define SLIRP_MAX_ARGS 100 | 6 | #define SLIRP_MAX_ARGS 100 |
10 | /* | 7 | /* |
@@ -24,28 +21,13 @@ struct slirp_data { | |||
24 | struct arg_list_dummy_wrapper argw; | 21 | struct arg_list_dummy_wrapper argw; |
25 | int pid; | 22 | int pid; |
26 | int slave; | 23 | int slave; |
27 | char ibuf[ENC_BUF_SIZE]; | 24 | struct slip_proto slip; |
28 | char obuf[ENC_BUF_SIZE]; | ||
29 | int more; /* more data: do not read fd until ibuf has been drained */ | ||
30 | int pos; | ||
31 | int esc; | ||
32 | }; | 25 | }; |
33 | 26 | ||
34 | extern struct net_user_info slirp_user_info; | 27 | extern struct net_user_info slirp_user_info; |
35 | 28 | ||
36 | extern int set_umn_addr(int fd, char *addr, char *ptp_addr); | ||
37 | extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri); | 29 | extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri); |
38 | extern int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri); | 30 | extern int slirp_user_write(int fd, void *buf, int len, |
31 | struct slirp_data *pri); | ||
39 | 32 | ||
40 | #endif | 33 | #endif |
41 | |||
42 | /* | ||
43 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
44 | * Emacs will notice this stuff at the end of the file and automatically | ||
45 | * adjust the settings for this buffer only. This must remain at the end | ||
46 | * of the file. | ||
47 | * --------------------------------------------------------------------------- | ||
48 | * Local variables: | ||
49 | * c-file-style: "linux" | ||
50 | * End: | ||
51 | */ | ||
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c index c9d6b52a831d..9864d27afdbe 100644 --- a/arch/um/drivers/slirp_kern.c +++ b/arch/um/drivers/slirp_kern.c | |||
@@ -25,10 +25,7 @@ void slirp_init(struct net_device *dev, void *data) | |||
25 | { .argw = init->argw, | 25 | { .argw = init->argw, |
26 | .pid = -1, | 26 | .pid = -1, |
27 | .slave = -1, | 27 | .slave = -1, |
28 | .ibuf = { '\0' }, | 28 | .slip = SLIP_PROTO_INIT, |
29 | .obuf = { '\0' }, | ||
30 | .pos = 0, | ||
31 | .esc = 0, | ||
32 | .dev = dev }); | 29 | .dev = dev }); |
33 | 30 | ||
34 | dev->init = NULL; | 31 | dev->init = NULL; |
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c index c322515c71cc..8d91f663d82c 100644 --- a/arch/um/drivers/slirp_user.c +++ b/arch/um/drivers/slirp_user.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "user.h" | 12 | #include "user.h" |
13 | #include "net_user.h" | 13 | #include "net_user.h" |
14 | #include "slirp.h" | 14 | #include "slirp.h" |
15 | #include "slip_proto.h" | 15 | #include "slip_common.h" |
16 | #include "helper.h" | 16 | #include "helper.h" |
17 | #include "os.h" | 17 | #include "os.h" |
18 | 18 | ||
@@ -48,47 +48,32 @@ static int slirp_tramp(char **argv, int fd) | |||
48 | return(pid); | 48 | return(pid); |
49 | } | 49 | } |
50 | 50 | ||
51 | /* XXX This is just a trivial wrapper around os_pipe */ | ||
52 | static int slirp_datachan(int *mfd, int *sfd) | ||
53 | { | ||
54 | int fds[2], err; | ||
55 | |||
56 | err = os_pipe(fds, 1, 1); | ||
57 | if(err < 0){ | ||
58 | printk("slirp_datachan: Failed to open pipe, err = %d\n", -err); | ||
59 | return(err); | ||
60 | } | ||
61 | |||
62 | *mfd = fds[0]; | ||
63 | *sfd = fds[1]; | ||
64 | return(0); | ||
65 | } | ||
66 | |||
67 | static int slirp_open(void *data) | 51 | static int slirp_open(void *data) |
68 | { | 52 | { |
69 | struct slirp_data *pri = data; | 53 | struct slirp_data *pri = data; |
70 | int sfd, mfd, pid, err; | 54 | int fds[2], pid, err; |
71 | 55 | ||
72 | err = slirp_datachan(&mfd, &sfd); | 56 | err = os_pipe(fds, 1, 1); |
73 | if(err) | 57 | if(err) |
74 | return(err); | 58 | return(err); |
75 | 59 | ||
76 | pid = slirp_tramp(pri->argw.argv, sfd); | 60 | err = slirp_tramp(pri->argw.argv, fds[1]); |
77 | 61 | if(err < 0){ | |
78 | if(pid < 0){ | 62 | printk("slirp_tramp failed - errno = %d\n", -err); |
79 | printk("slirp_tramp failed - errno = %d\n", -pid); | 63 | goto out; |
80 | os_close_file(sfd); | ||
81 | os_close_file(mfd); | ||
82 | return(pid); | ||
83 | } | 64 | } |
84 | 65 | pid = err; | |
85 | pri->slave = sfd; | 66 | |
86 | pri->pos = 0; | 67 | pri->slave = fds[1]; |
87 | pri->esc = 0; | 68 | pri->slip.pos = 0; |
88 | 69 | pri->slip.esc = 0; | |
89 | pri->pid = pid; | 70 | pri->pid = err; |
90 | 71 | ||
91 | return(mfd); | 72 | return(fds[0]); |
73 | out: | ||
74 | os_close_file(fds[0]); | ||
75 | os_close_file(fds[1]); | ||
76 | return err; | ||
92 | } | 77 | } |
93 | 78 | ||
94 | static void slirp_close(int fd, void *data) | 79 | static void slirp_close(int fd, void *data) |
@@ -129,48 +114,12 @@ static void slirp_close(int fd, void *data) | |||
129 | 114 | ||
130 | int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri) | 115 | int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri) |
131 | { | 116 | { |
132 | int i, n, size, start; | 117 | return slip_proto_read(fd, buf, len, &pri->slip); |
133 | |||
134 | if(pri->more>0) { | ||
135 | i = 0; | ||
136 | while(i < pri->more) { | ||
137 | size = slip_unesc(pri->ibuf[i++], | ||
138 | pri->ibuf,&pri->pos,&pri->esc); | ||
139 | if(size){ | ||
140 | memcpy(buf, pri->ibuf, size); | ||
141 | memmove(pri->ibuf, &pri->ibuf[i], pri->more-i); | ||
142 | pri->more=pri->more-i; | ||
143 | return(size); | ||
144 | } | ||
145 | } | ||
146 | pri->more=0; | ||
147 | } | ||
148 | |||
149 | n = net_read(fd, &pri->ibuf[pri->pos], sizeof(pri->ibuf) - pri->pos); | ||
150 | if(n <= 0) return(n); | ||
151 | |||
152 | start = pri->pos; | ||
153 | for(i = 0; i < n; i++){ | ||
154 | size = slip_unesc(pri->ibuf[start + i], | ||
155 | pri->ibuf,&pri->pos,&pri->esc); | ||
156 | if(size){ | ||
157 | memcpy(buf, pri->ibuf, size); | ||
158 | memmove(pri->ibuf, &pri->ibuf[start+i+1], n-(i+1)); | ||
159 | pri->more=n-(i+1); | ||
160 | return(size); | ||
161 | } | ||
162 | } | ||
163 | return(0); | ||
164 | } | 118 | } |
165 | 119 | ||
166 | int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri) | 120 | int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri) |
167 | { | 121 | { |
168 | int actual, n; | 122 | return slip_proto_write(fd, buf, len, &pri->slip); |
169 | |||
170 | actual = slip_esc(buf, pri->obuf, len); | ||
171 | n = net_write(fd, pri->obuf, actual); | ||
172 | if(n < 0) return(n); | ||
173 | else return(len); | ||
174 | } | 123 | } |
175 | 124 | ||
176 | static int slirp_set_mtu(int mtu, void *data) | 125 | static int slirp_set_mtu(int mtu, void *data) |
@@ -188,14 +137,3 @@ struct net_user_info slirp_user_info = { | |||
188 | .delete_address = NULL, | 137 | .delete_address = NULL, |
189 | .max_packet = BUF_SIZE | 138 | .max_packet = BUF_SIZE |
190 | }; | 139 | }; |
191 | |||
192 | /* | ||
193 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
194 | * Emacs will notice this stuff at the end of the file and automatically | ||
195 | * adjust the settings for this buffer only. This must remain at the end | ||
196 | * of the file. | ||
197 | * --------------------------------------------------------------------------- | ||
198 | * Local variables: | ||
199 | * c-file-style: "linux" | ||
200 | * End: | ||
201 | */ | ||
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index a2bac429f3d4..b32a77010fbe 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "init.h" | 22 | #include "init.h" |
23 | #include "irq_user.h" | 23 | #include "irq_user.h" |
24 | #include "mconsole_kern.h" | 24 | #include "mconsole_kern.h" |
25 | #include "2_5compat.h" | ||
26 | 25 | ||
27 | static int ssl_version = 1; | 26 | static int ssl_version = 1; |
28 | 27 | ||
diff --git a/arch/um/drivers/stderr_console.c b/arch/um/drivers/stderr_console.c index 98565b53d170..429ae8e6c7e5 100644 --- a/arch/um/drivers/stderr_console.c +++ b/arch/um/drivers/stderr_console.c | |||
@@ -22,9 +22,9 @@ static void stderr_console_write(struct console *console, const char *string, | |||
22 | } | 22 | } |
23 | 23 | ||
24 | static struct console stderr_console = { | 24 | static struct console stderr_console = { |
25 | .name "stderr", | 25 | .name = "stderr", |
26 | .write stderr_console_write, | 26 | .write = stderr_console_write, |
27 | .flags CON_PRINTBUFFER, | 27 | .flags = CON_PRINTBUFFER, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | static int __init stderr_console_init(void) | 30 | static int __init stderr_console_init(void) |
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 361d0be342b3..afbe1e71ed83 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "irq_user.h" | 28 | #include "irq_user.h" |
29 | #include "mconsole_kern.h" | 29 | #include "mconsole_kern.h" |
30 | #include "init.h" | 30 | #include "init.h" |
31 | #include "2_5compat.h" | ||
32 | 31 | ||
33 | #define MAX_TTYS (16) | 32 | #define MAX_TTYS (16) |
34 | 33 | ||
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 9a56ff94308d..2a7f6892c55c 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
@@ -49,13 +49,12 @@ | |||
49 | #include "irq_user.h" | 49 | #include "irq_user.h" |
50 | #include "irq_kern.h" | 50 | #include "irq_kern.h" |
51 | #include "ubd_user.h" | 51 | #include "ubd_user.h" |
52 | #include "2_5compat.h" | ||
53 | #include "os.h" | 52 | #include "os.h" |
54 | #include "mem.h" | 53 | #include "mem.h" |
55 | #include "mem_kern.h" | 54 | #include "mem_kern.h" |
56 | #include "cow.h" | 55 | #include "cow.h" |
57 | 56 | ||
58 | enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP }; | 57 | enum ubd_req { UBD_READ, UBD_WRITE }; |
59 | 58 | ||
60 | struct io_thread_req { | 59 | struct io_thread_req { |
61 | enum ubd_req op; | 60 | enum ubd_req op; |
@@ -68,8 +67,6 @@ struct io_thread_req { | |||
68 | unsigned long sector_mask; | 67 | unsigned long sector_mask; |
69 | unsigned long long cow_offset; | 68 | unsigned long long cow_offset; |
70 | unsigned long bitmap_words[2]; | 69 | unsigned long bitmap_words[2]; |
71 | int map_fd; | ||
72 | unsigned long long map_offset; | ||
73 | int error; | 70 | int error; |
74 | }; | 71 | }; |
75 | 72 | ||
@@ -122,10 +119,6 @@ static int ubd_ioctl(struct inode * inode, struct file * file, | |||
122 | 119 | ||
123 | #define MAX_DEV (8) | 120 | #define MAX_DEV (8) |
124 | 121 | ||
125 | /* Changed in early boot */ | ||
126 | static int ubd_do_mmap = 0; | ||
127 | #define UBD_MMAP_BLOCK_SIZE PAGE_SIZE | ||
128 | |||
129 | static struct block_device_operations ubd_blops = { | 122 | static struct block_device_operations ubd_blops = { |
130 | .owner = THIS_MODULE, | 123 | .owner = THIS_MODULE, |
131 | .open = ubd_open, | 124 | .open = ubd_open, |
@@ -175,12 +168,6 @@ struct ubd { | |||
175 | int no_cow; | 168 | int no_cow; |
176 | struct cow cow; | 169 | struct cow cow; |
177 | struct platform_device pdev; | 170 | struct platform_device pdev; |
178 | |||
179 | int map_writes; | ||
180 | int map_reads; | ||
181 | int nomap_writes; | ||
182 | int nomap_reads; | ||
183 | int write_maps; | ||
184 | }; | 171 | }; |
185 | 172 | ||
186 | #define DEFAULT_COW { \ | 173 | #define DEFAULT_COW { \ |
@@ -200,11 +187,6 @@ struct ubd { | |||
200 | .openflags = OPEN_FLAGS, \ | 187 | .openflags = OPEN_FLAGS, \ |
201 | .no_cow = 0, \ | 188 | .no_cow = 0, \ |
202 | .cow = DEFAULT_COW, \ | 189 | .cow = DEFAULT_COW, \ |
203 | .map_writes = 0, \ | ||
204 | .map_reads = 0, \ | ||
205 | .nomap_writes = 0, \ | ||
206 | .nomap_reads = 0, \ | ||
207 | .write_maps = 0, \ | ||
208 | } | 190 | } |
209 | 191 | ||
210 | struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; | 192 | struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; |
@@ -314,13 +296,6 @@ static int ubd_setup_common(char *str, int *index_out) | |||
314 | int major; | 296 | int major; |
315 | 297 | ||
316 | str++; | 298 | str++; |
317 | if(!strcmp(str, "mmap")){ | ||
318 | CHOOSE_MODE(printk("mmap not supported by the ubd " | ||
319 | "driver in tt mode\n"), | ||
320 | ubd_do_mmap = 1); | ||
321 | return(0); | ||
322 | } | ||
323 | |||
324 | if(!strcmp(str, "sync")){ | 299 | if(!strcmp(str, "sync")){ |
325 | global_openflags = of_sync(global_openflags); | 300 | global_openflags = of_sync(global_openflags); |
326 | return(0); | 301 | return(0); |
@@ -464,9 +439,9 @@ static int udb_setup(char *str) | |||
464 | __setup("udb", udb_setup); | 439 | __setup("udb", udb_setup); |
465 | __uml_help(udb_setup, | 440 | __uml_help(udb_setup, |
466 | "udb\n" | 441 | "udb\n" |
467 | " This option is here solely to catch ubd -> udb typos, which can be\n\n" | 442 | " This option is here solely to catch ubd -> udb typos, which can be\n" |
468 | " to impossible to catch visually unless you specifically look for\n\n" | 443 | " to impossible to catch visually unless you specifically look for\n" |
469 | " them. The only result of any option starting with 'udb' is an error\n\n" | 444 | " them. The only result of any option starting with 'udb' is an error\n" |
470 | " in the boot output.\n\n" | 445 | " in the boot output.\n\n" |
471 | ); | 446 | ); |
472 | 447 | ||
@@ -524,7 +499,7 @@ static void ubd_handler(void) | |||
524 | { | 499 | { |
525 | struct io_thread_req req; | 500 | struct io_thread_req req; |
526 | struct request *rq = elv_next_request(ubd_queue); | 501 | struct request *rq = elv_next_request(ubd_queue); |
527 | int n, err; | 502 | int n; |
528 | 503 | ||
529 | do_ubd = NULL; | 504 | do_ubd = NULL; |
530 | intr_count++; | 505 | intr_count++; |
@@ -538,19 +513,6 @@ static void ubd_handler(void) | |||
538 | return; | 513 | return; |
539 | } | 514 | } |
540 | 515 | ||
541 | if((req.op != UBD_MMAP) && | ||
542 | ((req.offset != ((__u64) (rq->sector)) << 9) || | ||
543 | (req.length != (rq->current_nr_sectors) << 9))) | ||
544 | panic("I/O op mismatch"); | ||
545 | |||
546 | if(req.map_fd != -1){ | ||
547 | err = physmem_subst_mapping(req.buffer, req.map_fd, | ||
548 | req.map_offset, 1); | ||
549 | if(err) | ||
550 | printk("ubd_handler - physmem_subst_mapping failed, " | ||
551 | "err = %d\n", -err); | ||
552 | } | ||
553 | |||
554 | ubd_finish(rq, req.error); | 516 | ubd_finish(rq, req.error); |
555 | reactivate_fd(thread_fd, UBD_IRQ); | 517 | reactivate_fd(thread_fd, UBD_IRQ); |
556 | do_ubd_request(ubd_queue); | 518 | do_ubd_request(ubd_queue); |
@@ -583,14 +545,10 @@ static int ubd_file_size(struct ubd *dev, __u64 *size_out) | |||
583 | 545 | ||
584 | static void ubd_close(struct ubd *dev) | 546 | static void ubd_close(struct ubd *dev) |
585 | { | 547 | { |
586 | if(ubd_do_mmap) | ||
587 | physmem_forget_descriptor(dev->fd); | ||
588 | os_close_file(dev->fd); | 548 | os_close_file(dev->fd); |
589 | if(dev->cow.file == NULL) | 549 | if(dev->cow.file == NULL) |
590 | return; | 550 | return; |
591 | 551 | ||
592 | if(ubd_do_mmap) | ||
593 | physmem_forget_descriptor(dev->cow.fd); | ||
594 | os_close_file(dev->cow.fd); | 552 | os_close_file(dev->cow.fd); |
595 | vfree(dev->cow.bitmap); | 553 | vfree(dev->cow.bitmap); |
596 | dev->cow.bitmap = NULL; | 554 | dev->cow.bitmap = NULL; |
@@ -1010,94 +968,13 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap, | |||
1010 | req->bitmap_words, bitmap_len); | 968 | req->bitmap_words, bitmap_len); |
1011 | } | 969 | } |
1012 | 970 | ||
1013 | static int mmap_fd(struct request *req, struct ubd *dev, __u64 offset) | ||
1014 | { | ||
1015 | __u64 sector; | ||
1016 | unsigned char *bitmap; | ||
1017 | int bit, i; | ||
1018 | |||
1019 | /* mmap must have been requested on the command line */ | ||
1020 | if(!ubd_do_mmap) | ||
1021 | return(-1); | ||
1022 | |||
1023 | /* The buffer must be page aligned */ | ||
1024 | if(((unsigned long) req->buffer % UBD_MMAP_BLOCK_SIZE) != 0) | ||
1025 | return(-1); | ||
1026 | |||
1027 | /* The request must be a page long */ | ||
1028 | if((req->current_nr_sectors << 9) != PAGE_SIZE) | ||
1029 | return(-1); | ||
1030 | |||
1031 | if(dev->cow.file == NULL) | ||
1032 | return(dev->fd); | ||
1033 | |||
1034 | sector = offset >> 9; | ||
1035 | bitmap = (unsigned char *) dev->cow.bitmap; | ||
1036 | bit = ubd_test_bit(sector, bitmap); | ||
1037 | |||
1038 | for(i = 1; i < req->current_nr_sectors; i++){ | ||
1039 | if(ubd_test_bit(sector + i, bitmap) != bit) | ||
1040 | return(-1); | ||
1041 | } | ||
1042 | |||
1043 | if(bit || (rq_data_dir(req) == WRITE)) | ||
1044 | offset += dev->cow.data_offset; | ||
1045 | |||
1046 | /* The data on disk must be page aligned */ | ||
1047 | if((offset % UBD_MMAP_BLOCK_SIZE) != 0) | ||
1048 | return(-1); | ||
1049 | |||
1050 | return(bit ? dev->fd : dev->cow.fd); | ||
1051 | } | ||
1052 | |||
1053 | static int prepare_mmap_request(struct ubd *dev, int fd, __u64 offset, | ||
1054 | struct request *req, | ||
1055 | struct io_thread_req *io_req) | ||
1056 | { | ||
1057 | int err; | ||
1058 | |||
1059 | if(rq_data_dir(req) == WRITE){ | ||
1060 | /* Writes are almost no-ops since the new data is already in the | ||
1061 | * host page cache | ||
1062 | */ | ||
1063 | dev->map_writes++; | ||
1064 | if(dev->cow.file != NULL) | ||
1065 | cowify_bitmap(io_req->offset, io_req->length, | ||
1066 | &io_req->sector_mask, &io_req->cow_offset, | ||
1067 | dev->cow.bitmap, dev->cow.bitmap_offset, | ||
1068 | io_req->bitmap_words, | ||
1069 | dev->cow.bitmap_len); | ||
1070 | } | ||
1071 | else { | ||
1072 | int w; | ||
1073 | |||
1074 | if((dev->cow.file != NULL) && (fd == dev->cow.fd)) | ||
1075 | w = 0; | ||
1076 | else w = dev->openflags.w; | ||
1077 | |||
1078 | if((dev->cow.file != NULL) && (fd == dev->fd)) | ||
1079 | offset += dev->cow.data_offset; | ||
1080 | |||
1081 | err = physmem_subst_mapping(req->buffer, fd, offset, w); | ||
1082 | if(err){ | ||
1083 | printk("physmem_subst_mapping failed, err = %d\n", | ||
1084 | -err); | ||
1085 | return(1); | ||
1086 | } | ||
1087 | dev->map_reads++; | ||
1088 | } | ||
1089 | io_req->op = UBD_MMAP; | ||
1090 | io_req->buffer = req->buffer; | ||
1091 | return(0); | ||
1092 | } | ||
1093 | |||
1094 | /* Called with ubd_io_lock held */ | 971 | /* Called with ubd_io_lock held */ |
1095 | static int prepare_request(struct request *req, struct io_thread_req *io_req) | 972 | static int prepare_request(struct request *req, struct io_thread_req *io_req) |
1096 | { | 973 | { |
1097 | struct gendisk *disk = req->rq_disk; | 974 | struct gendisk *disk = req->rq_disk; |
1098 | struct ubd *dev = disk->private_data; | 975 | struct ubd *dev = disk->private_data; |
1099 | __u64 offset; | 976 | __u64 offset; |
1100 | int len, fd; | 977 | int len; |
1101 | 978 | ||
1102 | if(req->rq_status == RQ_INACTIVE) return(1); | 979 | if(req->rq_status == RQ_INACTIVE) return(1); |
1103 | 980 | ||
@@ -1114,34 +991,12 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req) | |||
1114 | 991 | ||
1115 | io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; | 992 | io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; |
1116 | io_req->fds[1] = dev->fd; | 993 | io_req->fds[1] = dev->fd; |
1117 | io_req->map_fd = -1; | ||
1118 | io_req->cow_offset = -1; | 994 | io_req->cow_offset = -1; |
1119 | io_req->offset = offset; | 995 | io_req->offset = offset; |
1120 | io_req->length = len; | 996 | io_req->length = len; |
1121 | io_req->error = 0; | 997 | io_req->error = 0; |
1122 | io_req->sector_mask = 0; | 998 | io_req->sector_mask = 0; |
1123 | 999 | ||
1124 | fd = mmap_fd(req, dev, io_req->offset); | ||
1125 | if(fd > 0){ | ||
1126 | /* If mmapping is otherwise OK, but the first access to the | ||
1127 | * page is a write, then it's not mapped in yet. So we have | ||
1128 | * to write the data to disk first, then we can map the disk | ||
1129 | * page in and continue normally from there. | ||
1130 | */ | ||
1131 | if((rq_data_dir(req) == WRITE) && !is_remapped(req->buffer)){ | ||
1132 | io_req->map_fd = dev->fd; | ||
1133 | io_req->map_offset = io_req->offset + | ||
1134 | dev->cow.data_offset; | ||
1135 | dev->write_maps++; | ||
1136 | } | ||
1137 | else return(prepare_mmap_request(dev, fd, io_req->offset, req, | ||
1138 | io_req)); | ||
1139 | } | ||
1140 | |||
1141 | if(rq_data_dir(req) == READ) | ||
1142 | dev->nomap_reads++; | ||
1143 | else dev->nomap_writes++; | ||
1144 | |||
1145 | io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; | 1000 | io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; |
1146 | io_req->offsets[0] = 0; | 1001 | io_req->offsets[0] = 0; |
1147 | io_req->offsets[1] = dev->cow.data_offset; | 1002 | io_req->offsets[1] = dev->cow.data_offset; |
@@ -1229,143 +1084,6 @@ static int ubd_ioctl(struct inode * inode, struct file * file, | |||
1229 | return(-EINVAL); | 1084 | return(-EINVAL); |
1230 | } | 1085 | } |
1231 | 1086 | ||
1232 | static int ubd_check_remapped(int fd, unsigned long address, int is_write, | ||
1233 | __u64 offset) | ||
1234 | { | ||
1235 | __u64 bitmap_offset; | ||
1236 | unsigned long new_bitmap[2]; | ||
1237 | int i, err, n; | ||
1238 | |||
1239 | /* If it's not a write access, we can't do anything about it */ | ||
1240 | if(!is_write) | ||
1241 | return(0); | ||
1242 | |||
1243 | /* We have a write */ | ||
1244 | for(i = 0; i < sizeof(ubd_dev) / sizeof(ubd_dev[0]); i++){ | ||
1245 | struct ubd *dev = &ubd_dev[i]; | ||
1246 | |||
1247 | if((dev->fd != fd) && (dev->cow.fd != fd)) | ||
1248 | continue; | ||
1249 | |||
1250 | /* It's a write to a ubd device */ | ||
1251 | |||
1252 | /* This should be impossible now */ | ||
1253 | if(!dev->openflags.w){ | ||
1254 | /* It's a write access on a read-only device - probably | ||
1255 | * shouldn't happen. If the kernel is trying to change | ||
1256 | * something with no intention of writing it back out, | ||
1257 | * then this message will clue us in that this needs | ||
1258 | * fixing | ||
1259 | */ | ||
1260 | printk("Write access to mapped page from readonly ubd " | ||
1261 | "device %d\n", i); | ||
1262 | return(0); | ||
1263 | } | ||
1264 | |||
1265 | /* It's a write to a writeable ubd device - it must be COWed | ||
1266 | * because, otherwise, the page would have been mapped in | ||
1267 | * writeable | ||
1268 | */ | ||
1269 | |||
1270 | if(!dev->cow.file) | ||
1271 | panic("Write fault on writeable non-COW ubd device %d", | ||
1272 | i); | ||
1273 | |||
1274 | /* It should also be an access to the backing file since the | ||
1275 | * COW pages should be mapped in read-write | ||
1276 | */ | ||
1277 | |||
1278 | if(fd == dev->fd) | ||
1279 | panic("Write fault on a backing page of ubd " | ||
1280 | "device %d\n", i); | ||
1281 | |||
1282 | /* So, we do the write, copying the backing data to the COW | ||
1283 | * file... | ||
1284 | */ | ||
1285 | |||
1286 | err = os_seek_file(dev->fd, offset + dev->cow.data_offset); | ||
1287 | if(err < 0) | ||
1288 | panic("Couldn't seek to %lld in COW file of ubd " | ||
1289 | "device %d, err = %d", | ||
1290 | offset + dev->cow.data_offset, i, -err); | ||
1291 | |||
1292 | n = os_write_file(dev->fd, (void *) address, PAGE_SIZE); | ||
1293 | if(n != PAGE_SIZE) | ||
1294 | panic("Couldn't copy data to COW file of ubd " | ||
1295 | "device %d, err = %d", i, -n); | ||
1296 | |||
1297 | /* ... updating the COW bitmap... */ | ||
1298 | |||
1299 | cowify_bitmap(offset, PAGE_SIZE, NULL, &bitmap_offset, | ||
1300 | dev->cow.bitmap, dev->cow.bitmap_offset, | ||
1301 | new_bitmap, dev->cow.bitmap_len); | ||
1302 | |||
1303 | err = os_seek_file(dev->fd, bitmap_offset); | ||
1304 | if(err < 0) | ||
1305 | panic("Couldn't seek to %lld in COW file of ubd " | ||
1306 | "device %d, err = %d", bitmap_offset, i, -err); | ||
1307 | |||
1308 | n = os_write_file(dev->fd, new_bitmap, sizeof(new_bitmap)); | ||
1309 | if(n != sizeof(new_bitmap)) | ||
1310 | panic("Couldn't update bitmap of ubd device %d, " | ||
1311 | "err = %d", i, -n); | ||
1312 | |||
1313 | /* Maybe we can map the COW page in, and maybe we can't. If | ||
1314 | * it is a pre-V3 COW file, we can't, since the alignment will | ||
1315 | * be wrong. If it is a V3 or later COW file which has been | ||
1316 | * moved to a system with a larger page size, then maybe we | ||
1317 | * can't, depending on the exact location of the page. | ||
1318 | */ | ||
1319 | |||
1320 | offset += dev->cow.data_offset; | ||
1321 | |||
1322 | /* Remove the remapping, putting the original anonymous page | ||
1323 | * back. If the COW file can be mapped in, that is done. | ||
1324 | * Otherwise, the COW page is read in. | ||
1325 | */ | ||
1326 | |||
1327 | if(!physmem_remove_mapping((void *) address)) | ||
1328 | panic("Address 0x%lx not remapped by ubd device %d", | ||
1329 | address, i); | ||
1330 | if((offset % UBD_MMAP_BLOCK_SIZE) == 0) | ||
1331 | physmem_subst_mapping((void *) address, dev->fd, | ||
1332 | offset, 1); | ||
1333 | else { | ||
1334 | err = os_seek_file(dev->fd, offset); | ||
1335 | if(err < 0) | ||
1336 | panic("Couldn't seek to %lld in COW file of " | ||
1337 | "ubd device %d, err = %d", offset, i, | ||
1338 | -err); | ||
1339 | |||
1340 | n = os_read_file(dev->fd, (void *) address, PAGE_SIZE); | ||
1341 | if(n != PAGE_SIZE) | ||
1342 | panic("Failed to read page from offset %llx of " | ||
1343 | "COW file of ubd device %d, err = %d", | ||
1344 | offset, i, -n); | ||
1345 | } | ||
1346 | |||
1347 | return(1); | ||
1348 | } | ||
1349 | |||
1350 | /* It's not a write on a ubd device */ | ||
1351 | return(0); | ||
1352 | } | ||
1353 | |||
1354 | static struct remapper ubd_remapper = { | ||
1355 | .list = LIST_HEAD_INIT(ubd_remapper.list), | ||
1356 | .proc = ubd_check_remapped, | ||
1357 | }; | ||
1358 | |||
1359 | static int ubd_remapper_setup(void) | ||
1360 | { | ||
1361 | if(ubd_do_mmap) | ||
1362 | register_remapper(&ubd_remapper); | ||
1363 | |||
1364 | return(0); | ||
1365 | } | ||
1366 | |||
1367 | __initcall(ubd_remapper_setup); | ||
1368 | |||
1369 | static int same_backing_files(char *from_cmdline, char *from_cow, char *cow) | 1087 | static int same_backing_files(char *from_cmdline, char *from_cow, char *cow) |
1370 | { | 1088 | { |
1371 | struct uml_stat buf1, buf2; | 1089 | struct uml_stat buf1, buf2; |
@@ -1568,15 +1286,6 @@ void do_io(struct io_thread_req *req) | |||
1568 | int err; | 1286 | int err; |
1569 | __u64 off; | 1287 | __u64 off; |
1570 | 1288 | ||
1571 | if(req->op == UBD_MMAP){ | ||
1572 | /* Touch the page to force the host to do any necessary IO to | ||
1573 | * get it into memory | ||
1574 | */ | ||
1575 | n = *((volatile int *) req->buffer); | ||
1576 | req->error = update_bitmap(req); | ||
1577 | return; | ||
1578 | } | ||
1579 | |||
1580 | nsectors = req->length / req->sectorsize; | 1289 | nsectors = req->length / req->sectorsize; |
1581 | start = 0; | 1290 | start = 0; |
1582 | do { | 1291 | do { |
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c index 7917b9d1cec8..a4fdf3584ad2 100644 --- a/arch/um/drivers/xterm_kern.c +++ b/arch/um/drivers/xterm_kern.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include "linux/slab.h" | 7 | #include "linux/slab.h" |
8 | #include "linux/signal.h" | 8 | #include "linux/signal.h" |
9 | #include "linux/interrupt.h" | 9 | #include "linux/interrupt.h" |
10 | #include "asm/semaphore.h" | ||
11 | #include "asm/irq.h" | 10 | #include "asm/irq.h" |
12 | #include "irq_user.h" | 11 | #include "irq_user.h" |
13 | #include "irq_kern.h" | 12 | #include "irq_kern.h" |
diff --git a/arch/um/include/2_5compat.h b/arch/um/include/2_5compat.h deleted file mode 100644 index abdb015a4d71..000000000000 --- a/arch/um/include/2_5compat.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __2_5_COMPAT_H__ | ||
7 | #define __2_5_COMPAT_H__ | ||
8 | |||
9 | #define INIT_HARDSECT(arr, maj, sizes) | ||
10 | |||
11 | #define SET_PRI(task) do ; while(0) | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* | ||
16 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
17 | * Emacs will notice this stuff at the end of the file and automatically | ||
18 | * adjust the settings for this buffer only. This must remain at the end | ||
19 | * of the file. | ||
20 | * --------------------------------------------------------------------------- | ||
21 | * Local variables: | ||
22 | * c-file-style: "linux" | ||
23 | * End: | ||
24 | */ | ||
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h new file mode 100644 index 000000000000..d705daa2d854 --- /dev/null +++ b/arch/um/include/common-offsets.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* for use by sys-$SUBARCH/kernel-offsets.c */ | ||
2 | |||
3 | OFFSET(TASK_REGS, task_struct, thread.regs); | ||
4 | OFFSET(TASK_PID, task_struct, pid); | ||
5 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); | ||
6 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | ||
7 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); | ||
8 | DEFINE_STR(UM_KERN_ALERT, KERN_ALERT); | ||
9 | DEFINE_STR(UM_KERN_CRIT, KERN_CRIT); | ||
10 | DEFINE_STR(UM_KERN_ERR, KERN_ERR); | ||
11 | DEFINE_STR(UM_KERN_WARNING, KERN_WARNING); | ||
12 | DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); | ||
13 | DEFINE_STR(UM_KERN_INFO, KERN_INFO); | ||
14 | DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); | ||
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h index 15389c886b41..e5fec5570199 100644 --- a/arch/um/include/kern_util.h +++ b/arch/um/include/kern_util.h | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include "linux/threads.h" | 9 | #include "linux/threads.h" |
10 | #include "sysdep/ptrace.h" | 10 | #include "sysdep/ptrace.h" |
11 | #include "sysdep/faultinfo.h" | ||
11 | 12 | ||
12 | extern int ncpus; | 13 | extern int ncpus; |
13 | extern char *linux_prog; | 14 | extern char *linux_prog; |
@@ -31,8 +32,8 @@ extern int current_pid(void); | |||
31 | extern unsigned long alloc_stack(int order, int atomic); | 32 | extern unsigned long alloc_stack(int order, int atomic); |
32 | extern int do_signal(void); | 33 | extern int do_signal(void); |
33 | extern int is_stack_fault(unsigned long sp); | 34 | extern int is_stack_fault(unsigned long sp); |
34 | extern unsigned long segv(unsigned long address, unsigned long ip, | 35 | extern unsigned long segv(struct faultinfo fi, unsigned long ip, |
35 | int is_write, int is_user, void *sc); | 36 | int is_user, void *sc); |
36 | extern int handle_page_fault(unsigned long address, unsigned long ip, | 37 | extern int handle_page_fault(unsigned long address, unsigned long ip, |
37 | int is_write, int is_user, int *code_out); | 38 | int is_write, int is_user, int *code_out); |
38 | extern void syscall_ready(void); | 39 | extern void syscall_ready(void); |
@@ -82,7 +83,7 @@ extern void timer_irq(union uml_pt_regs *regs); | |||
82 | extern void unprotect_stack(unsigned long stack); | 83 | extern void unprotect_stack(unsigned long stack); |
83 | extern void do_uml_exitcalls(void); | 84 | extern void do_uml_exitcalls(void); |
84 | extern int attach_debugger(int idle_pid, int pid, int stop); | 85 | extern int attach_debugger(int idle_pid, int pid, int stop); |
85 | extern void bad_segv(unsigned long address, unsigned long ip, int is_write); | 86 | extern void bad_segv(struct faultinfo fi, unsigned long ip); |
86 | extern int config_gdb(char *str); | 87 | extern int config_gdb(char *str); |
87 | extern int remove_gdb(void); | 88 | extern int remove_gdb(void); |
88 | extern char *uml_strdup(char *string); | 89 | extern char *uml_strdup(char *string); |
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h index 9fbe3083fdd8..cfa368e045a5 100644 --- a/arch/um/include/mconsole.h +++ b/arch/um/include/mconsole.h | |||
@@ -56,7 +56,7 @@ struct mc_request | |||
56 | int as_interrupt; | 56 | int as_interrupt; |
57 | 57 | ||
58 | int originating_fd; | 58 | int originating_fd; |
59 | int originlen; | 59 | unsigned int originlen; |
60 | unsigned char origin[128]; /* sockaddr_un */ | 60 | unsigned char origin[128]; /* sockaddr_un */ |
61 | 61 | ||
62 | struct mconsole_request request; | 62 | struct mconsole_request request; |
diff --git a/arch/um/include/net_user.h b/arch/um/include/net_user.h index 36807b796e9f..89885a77a771 100644 --- a/arch/um/include/net_user.h +++ b/arch/um/include/net_user.h | |||
@@ -35,7 +35,7 @@ extern void *get_output_buffer(int *len_out); | |||
35 | extern void free_output_buffer(void *buffer); | 35 | extern void free_output_buffer(void *buffer); |
36 | 36 | ||
37 | extern int tap_open_common(void *dev, char *gate_addr); | 37 | extern int tap_open_common(void *dev, char *gate_addr); |
38 | extern void tap_check_ips(char *gate_addr, char *eth_addr); | 38 | extern void tap_check_ips(char *gate_addr, unsigned char *eth_addr); |
39 | 39 | ||
40 | extern void read_output(int fd, char *output_out, int len); | 40 | extern void read_output(int fd, char *output_out, int len); |
41 | 41 | ||
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 07340c8cf203..881d2988d2d8 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -136,7 +136,7 @@ extern int os_seek_file(int fd, __u64 offset); | |||
136 | extern int os_open_file(char *file, struct openflags flags, int mode); | 136 | extern int os_open_file(char *file, struct openflags flags, int mode); |
137 | extern int os_read_file(int fd, void *buf, int len); | 137 | extern int os_read_file(int fd, void *buf, int len); |
138 | extern int os_write_file(int fd, const void *buf, int count); | 138 | extern int os_write_file(int fd, const void *buf, int count); |
139 | extern int os_file_size(char *file, long long *size_out); | 139 | extern int os_file_size(char *file, unsigned long long *size_out); |
140 | extern int os_file_modtime(char *file, unsigned long *modtime); | 140 | extern int os_file_modtime(char *file, unsigned long *modtime); |
141 | extern int os_pipe(int *fd, int stream, int close_on_exec); | 141 | extern int os_pipe(int *fd, int stream, int close_on_exec); |
142 | extern int os_set_fd_async(int fd, int owner); | 142 | extern int os_set_fd_async(int fd, int owner); |
@@ -160,6 +160,7 @@ extern void os_kill_process(int pid, int reap_child); | |||
160 | extern void os_kill_ptraced_process(int pid, int reap_child); | 160 | extern void os_kill_ptraced_process(int pid, int reap_child); |
161 | extern void os_usr1_process(int pid); | 161 | extern void os_usr1_process(int pid); |
162 | extern int os_getpid(void); | 162 | extern int os_getpid(void); |
163 | extern int os_getpgrp(void); | ||
163 | 164 | ||
164 | extern int os_map_memory(void *virt, int fd, unsigned long long off, | 165 | extern int os_map_memory(void *virt, int fd, unsigned long long off, |
165 | unsigned long len, int r, int w, int x); | 166 | unsigned long len, int r, int w, int x); |
diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h index cfb5fb4f5b91..cd2327d09c8d 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/skas_ptrace.h | |||
@@ -6,22 +6,11 @@ | |||
6 | #ifndef __SKAS_PTRACE_H | 6 | #ifndef __SKAS_PTRACE_H |
7 | #define __SKAS_PTRACE_H | 7 | #define __SKAS_PTRACE_H |
8 | 8 | ||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct ptrace_ldt { | ||
15 | int func; | ||
16 | void *ptr; | ||
17 | unsigned long bytecount; | ||
18 | }; | ||
19 | |||
20 | #define PTRACE_FAULTINFO 52 | 9 | #define PTRACE_FAULTINFO 52 |
21 | #define PTRACE_SIGPENDING 53 | ||
22 | #define PTRACE_LDT 54 | ||
23 | #define PTRACE_SWITCH_MM 55 | 10 | #define PTRACE_SWITCH_MM 55 |
24 | 11 | ||
12 | #include "sysdep/skas_ptrace.h" | ||
13 | |||
25 | #endif | 14 | #endif |
26 | 15 | ||
27 | /* | 16 | /* |
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h index 3a2a45811aa3..764ba4db4788 100644 --- a/arch/um/include/sysdep-i386/checksum.h +++ b/arch/um/include/sysdep-i386/checksum.h | |||
@@ -24,19 +24,6 @@ unsigned int csum_partial(const unsigned char * buff, int len, | |||
24 | unsigned int sum); | 24 | unsigned int sum); |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * the same as csum_partial, but copies from src while it | ||
28 | * checksums, and handles user-space pointer exceptions correctly, when needed. | ||
29 | * | ||
30 | * here even more important to align src and dst on a 32-bit (or even | ||
31 | * better 64-bit) boundary | ||
32 | */ | ||
33 | |||
34 | unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst, | ||
35 | int len, int sum, int *err_ptr); | ||
36 | unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, | ||
37 | int len, int sum, int *err_ptr); | ||
38 | |||
39 | /* | ||
40 | * Note: when you get a NULL pointer exception here this means someone | 27 | * Note: when you get a NULL pointer exception here this means someone |
41 | * passed in an incorrect kernel address to one of these functions. | 28 | * passed in an incorrect kernel address to one of these functions. |
42 | * | 29 | * |
@@ -52,11 +39,24 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char * | |||
52 | return(csum_partial(dst, len, sum)); | 39 | return(csum_partial(dst, len, sum)); |
53 | } | 40 | } |
54 | 41 | ||
42 | /* | ||
43 | * the same as csum_partial, but copies from src while it | ||
44 | * checksums, and handles user-space pointer exceptions correctly, when needed. | ||
45 | * | ||
46 | * here even more important to align src and dst on a 32-bit (or even | ||
47 | * better 64-bit) boundary | ||
48 | */ | ||
49 | |||
55 | static __inline__ | 50 | static __inline__ |
56 | unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, | 51 | unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, |
57 | int len, int sum, int *err_ptr) | 52 | int len, int sum, int *err_ptr) |
58 | { | 53 | { |
59 | return csum_partial_copy_from(src, dst, len, sum, err_ptr); | 54 | if(copy_from_user(dst, src, len)){ |
55 | *err_ptr = -EFAULT; | ||
56 | return(-1); | ||
57 | } | ||
58 | |||
59 | return csum_partial(dst, len, sum); | ||
60 | } | 60 | } |
61 | 61 | ||
62 | /* | 62 | /* |
@@ -67,7 +67,6 @@ unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char | |||
67 | */ | 67 | */ |
68 | 68 | ||
69 | #define csum_partial_copy_fromuser csum_partial_copy_from_user | 69 | #define csum_partial_copy_fromuser csum_partial_copy_from_user |
70 | unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum); | ||
71 | 70 | ||
72 | /* | 71 | /* |
73 | * This is a version of ip_compute_csum() optimized for IP headers, | 72 | * This is a version of ip_compute_csum() optimized for IP headers, |
@@ -196,8 +195,14 @@ static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src, | |||
196 | unsigned char *dst, | 195 | unsigned char *dst, |
197 | int len, int sum, int *err_ptr) | 196 | int len, int sum, int *err_ptr) |
198 | { | 197 | { |
199 | if (access_ok(VERIFY_WRITE, dst, len)) | 198 | if (access_ok(VERIFY_WRITE, dst, len)){ |
200 | return(csum_partial_copy_to(src, dst, len, sum, err_ptr)); | 199 | if(copy_to_user(dst, src, len)){ |
200 | *err_ptr = -EFAULT; | ||
201 | return(-1); | ||
202 | } | ||
203 | |||
204 | return csum_partial(src, len, sum); | ||
205 | } | ||
201 | 206 | ||
202 | if (len) | 207 | if (len) |
203 | *err_ptr = -EFAULT; | 208 | *err_ptr = -EFAULT; |
diff --git a/arch/um/include/sysdep-i386/faultinfo.h b/arch/um/include/sysdep-i386/faultinfo.h new file mode 100644 index 000000000000..db437cc373bc --- /dev/null +++ b/arch/um/include/sysdep-i386/faultinfo.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Fujitsu Siemens Computers GmbH | ||
3 | * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __FAULTINFO_I386_H | ||
8 | #define __FAULTINFO_I386_H | ||
9 | |||
10 | /* this structure contains the full arch-specific faultinfo | ||
11 | * from the traps. | ||
12 | * On i386, ptrace_faultinfo unfortunately doesn't provide | ||
13 | * all the info, since trap_no is missing. | ||
14 | * All common elements are defined at the same position in | ||
15 | * both structures, thus making it easy to copy the | ||
16 | * contents without knowledge about the structure elements. | ||
17 | */ | ||
18 | struct faultinfo { | ||
19 | int error_code; /* in ptrace_faultinfo misleadingly called is_write */ | ||
20 | unsigned long cr2; /* in ptrace_faultinfo called addr */ | ||
21 | int trap_no; /* missing in ptrace_faultinfo */ | ||
22 | }; | ||
23 | |||
24 | #define FAULT_WRITE(fi) ((fi).error_code & 2) | ||
25 | #define FAULT_ADDRESS(fi) ((fi).cr2) | ||
26 | |||
27 | #define PTRACE_FULL_FAULTINFO 0 | ||
28 | |||
29 | #endif | ||
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h index 661d495e2044..c8ee9559f3ab 100644 --- a/arch/um/include/sysdep-i386/ptrace.h +++ b/arch/um/include/sysdep-i386/ptrace.h | |||
@@ -8,6 +8,8 @@ | |||
8 | 8 | ||
9 | #include "uml-config.h" | 9 | #include "uml-config.h" |
10 | #include "user_constants.h" | 10 | #include "user_constants.h" |
11 | #include "sysdep/faultinfo.h" | ||
12 | #include "choose-mode.h" | ||
11 | 13 | ||
12 | #define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long)) | 14 | #define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long)) |
13 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) | 15 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) |
@@ -53,24 +55,17 @@ extern int sysemu_supported; | |||
53 | 55 | ||
54 | #define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r)) | 56 | #define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r)) |
55 | 57 | ||
56 | #define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type) | ||
57 | |||
58 | #define REGS_FAULT_ADDR(r) ((r)->fault_addr) | ||
59 | |||
60 | #define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type) | ||
61 | |||
62 | #endif | 58 | #endif |
63 | #ifndef PTRACE_SYSEMU_SINGLESTEP | 59 | #ifndef PTRACE_SYSEMU_SINGLESTEP |
64 | #define PTRACE_SYSEMU_SINGLESTEP 32 | 60 | #define PTRACE_SYSEMU_SINGLESTEP 32 |
65 | #endif | 61 | #endif |
66 | 62 | ||
67 | #include "choose-mode.h" | ||
68 | |||
69 | union uml_pt_regs { | 63 | union uml_pt_regs { |
70 | #ifdef UML_CONFIG_MODE_TT | 64 | #ifdef UML_CONFIG_MODE_TT |
71 | struct tt_regs { | 65 | struct tt_regs { |
72 | long syscall; | 66 | long syscall; |
73 | void *sc; | 67 | void *sc; |
68 | struct faultinfo faultinfo; | ||
74 | } tt; | 69 | } tt; |
75 | #endif | 70 | #endif |
76 | #ifdef UML_CONFIG_MODE_SKAS | 71 | #ifdef UML_CONFIG_MODE_SKAS |
@@ -78,9 +73,7 @@ union uml_pt_regs { | |||
78 | unsigned long regs[HOST_FRAME_SIZE]; | 73 | unsigned long regs[HOST_FRAME_SIZE]; |
79 | unsigned long fp[HOST_FP_SIZE]; | 74 | unsigned long fp[HOST_FP_SIZE]; |
80 | unsigned long xfp[HOST_XFP_SIZE]; | 75 | unsigned long xfp[HOST_XFP_SIZE]; |
81 | unsigned long fault_addr; | 76 | struct faultinfo faultinfo; |
82 | unsigned long fault_type; | ||
83 | unsigned long trap_type; | ||
84 | long syscall; | 77 | long syscall; |
85 | int is_user; | 78 | int is_user; |
86 | } skas; | 79 | } skas; |
@@ -217,15 +210,8 @@ struct syscall_args { | |||
217 | #define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r) | 210 | #define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r) |
218 | #define UPT_SYSCALL_RET(r) UPT_EAX(r) | 211 | #define UPT_SYSCALL_RET(r) UPT_EAX(r) |
219 | 212 | ||
220 | #define UPT_SEGV_IS_FIXABLE(r) \ | 213 | #define UPT_FAULTINFO(r) \ |
221 | CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ | 214 | CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo)) |
222 | REGS_SEGV_IS_FIXABLE(&r->skas)) | ||
223 | |||
224 | #define UPT_FAULT_ADDR(r) \ | ||
225 | __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas)) | ||
226 | |||
227 | #define UPT_FAULT_WRITE(r) \ | ||
228 | CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas)) | ||
229 | 215 | ||
230 | #endif | 216 | #endif |
231 | 217 | ||
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h index dfee589de360..1fe729265167 100644 --- a/arch/um/include/sysdep-i386/sigcontext.h +++ b/arch/um/include/sysdep-i386/sigcontext.h | |||
@@ -13,15 +13,12 @@ | |||
13 | #define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc)) | 13 | #define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc)) |
14 | #define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result) | 14 | #define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result) |
15 | 15 | ||
16 | #define SC_FAULT_ADDR(sc) SC_CR2(sc) | 16 | #define GET_FAULTINFO_FROM_SC(fi,sc) \ |
17 | #define SC_FAULT_TYPE(sc) SC_ERR(sc) | 17 | { \ |
18 | 18 | (fi).cr2 = SC_CR2(sc); \ | |
19 | #define FAULT_WRITE(err) (err & 2) | 19 | (fi).error_code = SC_ERR(sc); \ |
20 | #define TO_SC_ERR(is_write) ((is_write) ? 2 : 0) | 20 | (fi).trap_no = SC_TRAPNO(sc); \ |
21 | 21 | } | |
22 | #define SC_FAULT_WRITE(sc) (FAULT_WRITE(SC_ERR(sc))) | ||
23 | |||
24 | #define SC_TRAP_TYPE(sc) SC_TRAPNO(sc) | ||
25 | 22 | ||
26 | /* ptrace expects that, at the start of a system call, %eax contains | 23 | /* ptrace expects that, at the start of a system call, %eax contains |
27 | * -ENOSYS, so this makes it so. | 24 | * -ENOSYS, so this makes it so. |
@@ -29,9 +26,7 @@ | |||
29 | #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) | 26 | #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) |
30 | 27 | ||
31 | /* This is Page Fault */ | 28 | /* This is Page Fault */ |
32 | #define SEGV_IS_FIXABLE(trap) (trap == 14) | 29 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) |
33 | |||
34 | #define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc))) | ||
35 | 30 | ||
36 | extern unsigned long *sc_sigmask(void *sc_ptr); | 31 | extern unsigned long *sc_sigmask(void *sc_ptr); |
37 | extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); | 32 | extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); |
diff --git a/arch/um/include/sysdep-i386/signal.h b/arch/um/include/sysdep-i386/signal.h index b1e1f7a77499..07518b162136 100644 --- a/arch/um/include/sysdep-i386/signal.h +++ b/arch/um/include/sysdep-i386/signal.h | |||
@@ -8,6 +8,8 @@ | |||
8 | 8 | ||
9 | #include <signal.h> | 9 | #include <signal.h> |
10 | 10 | ||
11 | #define ARCH_SIGHDLR_PARAM int sig | ||
12 | |||
11 | #define ARCH_GET_SIGCONTEXT(sc, sig) \ | 13 | #define ARCH_GET_SIGCONTEXT(sc, sig) \ |
12 | do sc = (struct sigcontext *) (&sig + 1); while(0) | 14 | do sc = (struct sigcontext *) (&sig + 1); while(0) |
13 | 15 | ||
diff --git a/arch/um/include/sysdep-i386/skas_ptrace.h b/arch/um/include/sysdep-i386/skas_ptrace.h new file mode 100644 index 000000000000..e27b8a791773 --- /dev/null +++ b/arch/um/include/sysdep-i386/skas_ptrace.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_I386_SKAS_PTRACE_H | ||
7 | #define __SYSDEP_I386_SKAS_PTRACE_H | ||
8 | |||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct ptrace_ldt { | ||
15 | int func; | ||
16 | void *ptr; | ||
17 | unsigned long bytecount; | ||
18 | }; | ||
19 | |||
20 | #define PTRACE_LDT 54 | ||
21 | |||
22 | #endif | ||
diff --git a/arch/um/include/sysdep-ia64/skas_ptrace.h b/arch/um/include/sysdep-ia64/skas_ptrace.h new file mode 100644 index 000000000000..25a38e715702 --- /dev/null +++ b/arch/um/include/sysdep-ia64/skas_ptrace.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_IA64_SKAS_PTRACE_H | ||
7 | #define __SYSDEP_IA64_SKAS_PTRACE_H | ||
8 | |||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct ptrace_ldt { | ||
15 | int func; | ||
16 | void *ptr; | ||
17 | unsigned long bytecount; | ||
18 | }; | ||
19 | |||
20 | #define PTRACE_LDT 54 | ||
21 | |||
22 | #endif | ||
diff --git a/arch/um/include/sysdep-ppc/skas_ptrace.h b/arch/um/include/sysdep-ppc/skas_ptrace.h new file mode 100644 index 000000000000..d9fbbac10de0 --- /dev/null +++ b/arch/um/include/sysdep-ppc/skas_ptrace.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_PPC_SKAS_PTRACE_H | ||
7 | #define __SYSDEP_PPC_SKAS_PTRACE_H | ||
8 | |||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct ptrace_ldt { | ||
15 | int func; | ||
16 | void *ptr; | ||
17 | unsigned long bytecount; | ||
18 | }; | ||
19 | |||
20 | #define PTRACE_LDT 54 | ||
21 | |||
22 | #endif | ||
diff --git a/arch/um/include/sysdep-x86_64/checksum.h b/arch/um/include/sysdep-x86_64/checksum.h index 572c6c19be33..ea97005af694 100644 --- a/arch/um/include/sysdep-x86_64/checksum.h +++ b/arch/um/include/sysdep-x86_64/checksum.h | |||
@@ -9,8 +9,6 @@ | |||
9 | #include "linux/in6.h" | 9 | #include "linux/in6.h" |
10 | #include "asm/uaccess.h" | 10 | #include "asm/uaccess.h" |
11 | 11 | ||
12 | extern unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, int len, | ||
13 | int sum, int *err_ptr); | ||
14 | extern unsigned csum_partial(const unsigned char *buff, unsigned len, | 12 | extern unsigned csum_partial(const unsigned char *buff, unsigned len, |
15 | unsigned sum); | 13 | unsigned sum); |
16 | 14 | ||
@@ -31,10 +29,15 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char * | |||
31 | } | 29 | } |
32 | 30 | ||
33 | static __inline__ | 31 | static __inline__ |
34 | unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, | 32 | unsigned int csum_partial_copy_from_user(const unsigned char *src, |
35 | int len, int sum, int *err_ptr) | 33 | unsigned char *dst, int len, int sum, |
34 | int *err_ptr) | ||
36 | { | 35 | { |
37 | return csum_partial_copy_from(src, dst, len, sum, err_ptr); | 36 | if(copy_from_user(dst, src, len)){ |
37 | *err_ptr = -EFAULT; | ||
38 | return(-1); | ||
39 | } | ||
40 | return csum_partial(dst, len, sum); | ||
38 | } | 41 | } |
39 | 42 | ||
40 | /** | 43 | /** |
@@ -137,15 +140,6 @@ static inline unsigned add32_with_carry(unsigned a, unsigned b) | |||
137 | return a; | 140 | return a; |
138 | } | 141 | } |
139 | 142 | ||
140 | #endif | 143 | extern unsigned short ip_compute_csum(unsigned char * buff, int len); |
141 | 144 | ||
142 | /* | 145 | #endif |
143 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
144 | * Emacs will notice this stuff at the end of the file and automatically | ||
145 | * adjust the settings for this buffer only. This must remain at the end | ||
146 | * of the file. | ||
147 | * --------------------------------------------------------------------------- | ||
148 | * Local variables: | ||
149 | * c-file-style: "linux" | ||
150 | * End: | ||
151 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/faultinfo.h b/arch/um/include/sysdep-x86_64/faultinfo.h new file mode 100644 index 000000000000..cb917b0d5660 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/faultinfo.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Fujitsu Siemens Computers GmbH | ||
3 | * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __FAULTINFO_X86_64_H | ||
8 | #define __FAULTINFO_X86_64_H | ||
9 | |||
10 | /* this structure contains the full arch-specific faultinfo | ||
11 | * from the traps. | ||
12 | * On i386, ptrace_faultinfo unfortunately doesn't provide | ||
13 | * all the info, since trap_no is missing. | ||
14 | * All common elements are defined at the same position in | ||
15 | * both structures, thus making it easy to copy the | ||
16 | * contents without knowledge about the structure elements. | ||
17 | */ | ||
18 | struct faultinfo { | ||
19 | int error_code; /* in ptrace_faultinfo misleadingly called is_write */ | ||
20 | unsigned long cr2; /* in ptrace_faultinfo called addr */ | ||
21 | int trap_no; /* missing in ptrace_faultinfo */ | ||
22 | }; | ||
23 | |||
24 | #define FAULT_WRITE(fi) ((fi).error_code & 2) | ||
25 | #define FAULT_ADDRESS(fi) ((fi).cr2) | ||
26 | |||
27 | #define PTRACE_FULL_FAULTINFO 1 | ||
28 | |||
29 | #endif | ||
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h index 915c82daffbd..be8acd5efd97 100644 --- a/arch/um/include/sysdep-x86_64/ptrace.h +++ b/arch/um/include/sysdep-x86_64/ptrace.h | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include "uml-config.h" | 10 | #include "uml-config.h" |
11 | #include "user_constants.h" | 11 | #include "user_constants.h" |
12 | #include "sysdep/faultinfo.h" | ||
12 | 13 | ||
13 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) | 14 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) |
14 | #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) | 15 | #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) |
@@ -83,6 +84,7 @@ union uml_pt_regs { | |||
83 | long syscall; | 84 | long syscall; |
84 | unsigned long orig_rax; | 85 | unsigned long orig_rax; |
85 | void *sc; | 86 | void *sc; |
87 | struct faultinfo faultinfo; | ||
86 | } tt; | 88 | } tt; |
87 | #endif | 89 | #endif |
88 | #ifdef UML_CONFIG_MODE_SKAS | 90 | #ifdef UML_CONFIG_MODE_SKAS |
@@ -90,9 +92,7 @@ union uml_pt_regs { | |||
90 | /* XXX */ | 92 | /* XXX */ |
91 | unsigned long regs[27]; | 93 | unsigned long regs[27]; |
92 | unsigned long fp[65]; | 94 | unsigned long fp[65]; |
93 | unsigned long fault_addr; | 95 | struct faultinfo faultinfo; |
94 | unsigned long fault_type; | ||
95 | unsigned long trap_type; | ||
96 | long syscall; | 96 | long syscall; |
97 | int is_user; | 97 | int is_user; |
98 | } skas; | 98 | } skas; |
@@ -135,6 +135,7 @@ extern int mode_tt; | |||
135 | __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs)) | 135 | __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs)) |
136 | #define UPT_SC(r) ((r)->tt.sc) | 136 | #define UPT_SC(r) ((r)->tt.sc) |
137 | #define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall) | 137 | #define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall) |
138 | #define UPT_SYSCALL_RET(r) UPT_RAX(r) | ||
138 | 139 | ||
139 | extern int user_context(unsigned long sp); | 140 | extern int user_context(unsigned long sp); |
140 | 141 | ||
@@ -196,32 +197,32 @@ struct syscall_args { | |||
196 | 197 | ||
197 | 198 | ||
198 | #define UPT_SET(regs, reg, val) \ | 199 | #define UPT_SET(regs, reg, val) \ |
199 | ({ unsigned long val; \ | 200 | ({ unsigned long __upt_val = val; \ |
200 | switch(reg){ \ | 201 | switch(reg){ \ |
201 | case R8: UPT_R8(regs) = val; break; \ | 202 | case R8: UPT_R8(regs) = __upt_val; break; \ |
202 | case R9: UPT_R9(regs) = val; break; \ | 203 | case R9: UPT_R9(regs) = __upt_val; break; \ |
203 | case R10: UPT_R10(regs) = val; break; \ | 204 | case R10: UPT_R10(regs) = __upt_val; break; \ |
204 | case R11: UPT_R11(regs) = val; break; \ | 205 | case R11: UPT_R11(regs) = __upt_val; break; \ |
205 | case R12: UPT_R12(regs) = val; break; \ | 206 | case R12: UPT_R12(regs) = __upt_val; break; \ |
206 | case R13: UPT_R13(regs) = val; break; \ | 207 | case R13: UPT_R13(regs) = __upt_val; break; \ |
207 | case R14: UPT_R14(regs) = val; break; \ | 208 | case R14: UPT_R14(regs) = __upt_val; break; \ |
208 | case R15: UPT_R15(regs) = val; break; \ | 209 | case R15: UPT_R15(regs) = __upt_val; break; \ |
209 | case RIP: UPT_IP(regs) = val; break; \ | 210 | case RIP: UPT_IP(regs) = __upt_val; break; \ |
210 | case RSP: UPT_SP(regs) = val; break; \ | 211 | case RSP: UPT_SP(regs) = __upt_val; break; \ |
211 | case RAX: UPT_RAX(regs) = val; break; \ | 212 | case RAX: UPT_RAX(regs) = __upt_val; break; \ |
212 | case RBX: UPT_RBX(regs) = val; break; \ | 213 | case RBX: UPT_RBX(regs) = __upt_val; break; \ |
213 | case RCX: UPT_RCX(regs) = val; break; \ | 214 | case RCX: UPT_RCX(regs) = __upt_val; break; \ |
214 | case RDX: UPT_RDX(regs) = val; break; \ | 215 | case RDX: UPT_RDX(regs) = __upt_val; break; \ |
215 | case RSI: UPT_RSI(regs) = val; break; \ | 216 | case RSI: UPT_RSI(regs) = __upt_val; break; \ |
216 | case RDI: UPT_RDI(regs) = val; break; \ | 217 | case RDI: UPT_RDI(regs) = __upt_val; break; \ |
217 | case RBP: UPT_RBP(regs) = val; break; \ | 218 | case RBP: UPT_RBP(regs) = __upt_val; break; \ |
218 | case ORIG_RAX: UPT_ORIG_RAX(regs) = val; break; \ | 219 | case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ |
219 | case CS: UPT_CS(regs) = val; break; \ | 220 | case CS: UPT_CS(regs) = __upt_val; break; \ |
220 | case DS: UPT_DS(regs) = val; break; \ | 221 | case DS: UPT_DS(regs) = __upt_val; break; \ |
221 | case ES: UPT_ES(regs) = val; break; \ | 222 | case ES: UPT_ES(regs) = __upt_val; break; \ |
222 | case FS: UPT_FS(regs) = val; break; \ | 223 | case FS: UPT_FS(regs) = __upt_val; break; \ |
223 | case GS: UPT_GS(regs) = val; break; \ | 224 | case GS: UPT_GS(regs) = __upt_val; break; \ |
224 | case EFLAGS: UPT_EFLAGS(regs) = val; break; \ | 225 | case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ |
225 | default : \ | 226 | default : \ |
226 | panic("Bad register in UPT_SET : %d\n", reg); \ | 227 | panic("Bad register in UPT_SET : %d\n", reg); \ |
227 | break; \ | 228 | break; \ |
@@ -241,24 +242,7 @@ struct syscall_args { | |||
241 | CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ | 242 | CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ |
242 | REGS_SEGV_IS_FIXABLE(&r->skas)) | 243 | REGS_SEGV_IS_FIXABLE(&r->skas)) |
243 | 244 | ||
244 | #define UPT_FAULT_ADDR(r) \ | 245 | #define UPT_FAULTINFO(r) \ |
245 | __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas)) | 246 | CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo)) |
246 | |||
247 | #define UPT_FAULT_WRITE(r) \ | ||
248 | CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas)) | ||
249 | |||
250 | #define UPT_TRAP(r) __CHOOSE_MODE(SC_TRAP_TYPE(UPT_SC(r)), REGS_TRAP(&r->skas)) | ||
251 | #define UPT_ERR(r) __CHOOSE_MODE(SC_FAULT_TYPE(UPT_SC(r)), REGS_ERR(&r->skas)) | ||
252 | 247 | ||
253 | #endif | 248 | #endif |
254 | |||
255 | /* | ||
256 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
257 | * Emacs will notice this stuff at the end of the file and automatically | ||
258 | * adjust the settings for this buffer only. This must remain at the end | ||
259 | * of the file. | ||
260 | * --------------------------------------------------------------------------- | ||
261 | * Local variables: | ||
262 | * c-file-style: "linux" | ||
263 | * End: | ||
264 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/include/sysdep-x86_64/sigcontext.h index 1e38a54ff4cf..2a78260d15a0 100644 --- a/arch/um/include/sysdep-x86_64/sigcontext.h +++ b/arch/um/include/sysdep-x86_64/sigcontext.h | |||
@@ -17,11 +17,12 @@ | |||
17 | #define SC_FAULT_ADDR(sc) SC_CR2(sc) | 17 | #define SC_FAULT_ADDR(sc) SC_CR2(sc) |
18 | #define SC_FAULT_TYPE(sc) SC_ERR(sc) | 18 | #define SC_FAULT_TYPE(sc) SC_ERR(sc) |
19 | 19 | ||
20 | #define FAULT_WRITE(err) ((err) & 2) | 20 | #define GET_FAULTINFO_FROM_SC(fi,sc) \ |
21 | 21 | { \ | |
22 | #define SC_FAULT_WRITE(sc) FAULT_WRITE(SC_FAULT_TYPE(sc)) | 22 | (fi).cr2 = SC_CR2(sc); \ |
23 | 23 | (fi).error_code = SC_ERR(sc); \ | |
24 | #define SC_TRAP_TYPE(sc) SC_TRAPNO(sc) | 24 | (fi).trap_no = SC_TRAPNO(sc); \ |
25 | } | ||
25 | 26 | ||
26 | /* ptrace expects that, at the start of a system call, %eax contains | 27 | /* ptrace expects that, at the start of a system call, %eax contains |
27 | * -ENOSYS, so this makes it so. | 28 | * -ENOSYS, so this makes it so. |
@@ -29,8 +30,8 @@ | |||
29 | 30 | ||
30 | #define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0) | 31 | #define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0) |
31 | 32 | ||
32 | #define SEGV_IS_FIXABLE(trap) ((trap) == 14) | 33 | /* This is Page Fault */ |
33 | #define SC_SEGV_IS_FIXABLE(sc) SEGV_IS_FIXABLE(SC_TRAP_TYPE(sc)) | 34 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) |
34 | 35 | ||
35 | extern unsigned long *sc_sigmask(void *sc_ptr); | 36 | extern unsigned long *sc_sigmask(void *sc_ptr); |
36 | 37 | ||
diff --git a/arch/um/include/sysdep-x86_64/signal.h b/arch/um/include/sysdep-x86_64/signal.h index e5e52756fab4..6142897af3d1 100644 --- a/arch/um/include/sysdep-x86_64/signal.h +++ b/arch/um/include/sysdep-x86_64/signal.h | |||
@@ -6,6 +6,8 @@ | |||
6 | #ifndef __X86_64_SIGNAL_H_ | 6 | #ifndef __X86_64_SIGNAL_H_ |
7 | #define __X86_64_SIGNAL_H_ | 7 | #define __X86_64_SIGNAL_H_ |
8 | 8 | ||
9 | #define ARCH_SIGHDLR_PARAM int sig | ||
10 | |||
9 | #define ARCH_GET_SIGCONTEXT(sc, sig_addr) \ | 11 | #define ARCH_GET_SIGCONTEXT(sc, sig_addr) \ |
10 | do { \ | 12 | do { \ |
11 | struct ucontext *__uc; \ | 13 | struct ucontext *__uc; \ |
diff --git a/arch/um/include/sysdep-x86_64/skas_ptrace.h b/arch/um/include/sysdep-x86_64/skas_ptrace.h new file mode 100644 index 000000000000..95db4be786e4 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/skas_ptrace.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_X86_64_SKAS_PTRACE_H | ||
7 | #define __SYSDEP_X86_64_SKAS_PTRACE_H | ||
8 | |||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct ptrace_ldt { | ||
15 | int func; | ||
16 | void *ptr; | ||
17 | unsigned long bytecount; | ||
18 | }; | ||
19 | |||
20 | #define PTRACE_LDT 54 | ||
21 | |||
22 | #endif | ||
diff --git a/arch/um/include/sysrq.h b/arch/um/include/sysrq.h index 2ce9423460b3..c8d332b56b98 100644 --- a/arch/um/include/sysrq.h +++ b/arch/um/include/sysrq.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __UM_SYSRQ_H | 1 | #ifndef __UM_SYSRQ_H |
2 | #define __UM_SYSRQ_H | 2 | #define __UM_SYSRQ_H |
3 | 3 | ||
4 | extern void show_trace(unsigned long *stack); | 4 | struct task_struct; |
5 | extern void show_trace(struct task_struct* task, unsigned long *stack); | ||
5 | 6 | ||
6 | #endif | 7 | #endif |
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h index 103cd320386c..7b6a24dfd302 100644 --- a/arch/um/include/user_util.h +++ b/arch/um/include/user_util.h | |||
@@ -41,9 +41,6 @@ extern unsigned long highmem; | |||
41 | extern char host_info[]; | 41 | extern char host_info[]; |
42 | 42 | ||
43 | extern char saved_command_line[]; | 43 | extern char saved_command_line[]; |
44 | extern char command_line[]; | ||
45 | |||
46 | extern char *tempdir; | ||
47 | 44 | ||
48 | extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; | 45 | extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; |
49 | extern unsigned long _unprotected_end; | 46 | extern unsigned long _unprotected_end; |
@@ -67,7 +64,6 @@ extern void *um_kmalloc(int size); | |||
67 | extern int switcheroo(int fd, int prot, void *from, void *to, int size); | 64 | extern int switcheroo(int fd, int prot, void *from, void *to, int size); |
68 | extern void setup_machinename(char *machine_out); | 65 | extern void setup_machinename(char *machine_out); |
69 | extern void setup_hostinfo(void); | 66 | extern void setup_hostinfo(void); |
70 | extern void add_arg(char *arg); | ||
71 | extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); | 67 | extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); |
72 | extern void init_new_thread_signals(int altstack); | 68 | extern void init_new_thread_signals(int altstack); |
73 | extern void do_exec(int old_pid, int new_pid); | 69 | extern void do_exec(int old_pid, int new_pid); |
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 246f0e7fb4cc..a8918e80df96 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -4,9 +4,9 @@ | |||
4 | # | 4 | # |
5 | 5 | ||
6 | extra-y := vmlinux.lds | 6 | extra-y := vmlinux.lds |
7 | clean-files := vmlinux.lds.S config.tmp | 7 | clean-files := |
8 | 8 | ||
9 | obj-y = checksum.o config.o exec_kern.o exitcode.o \ | 9 | obj-y = config.o exec_kern.o exitcode.o \ |
10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \ | 10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \ |
11 | physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \ | 11 | physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \ |
12 | sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ | 12 | sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ |
@@ -14,7 +14,7 @@ obj-y = checksum.o config.o exec_kern.o exitcode.o \ | |||
14 | tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \ | 14 | tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \ |
15 | user_util.o | 15 | user_util.o |
16 | 16 | ||
17 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o | 17 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
18 | obj-$(CONFIG_GPROF) += gprof_syms.o | 18 | obj-$(CONFIG_GPROF) += gprof_syms.o |
19 | obj-$(CONFIG_GCOV) += gmon_syms.o | 19 | obj-$(CONFIG_GCOV) += gmon_syms.o |
20 | obj-$(CONFIG_TTY_LOG) += tty_log.o | 20 | obj-$(CONFIG_TTY_LOG) += tty_log.o |
@@ -23,18 +23,14 @@ obj-$(CONFIG_SYSCALL_DEBUG) += syscall_user.o | |||
23 | obj-$(CONFIG_MODE_TT) += tt/ | 23 | obj-$(CONFIG_MODE_TT) += tt/ |
24 | obj-$(CONFIG_MODE_SKAS) += skas/ | 24 | obj-$(CONFIG_MODE_SKAS) += skas/ |
25 | 25 | ||
26 | # This needs be compiled with frame pointers regardless of how the rest of the | ||
27 | # kernel is built. | ||
28 | CFLAGS_frame.o := -fno-omit-frame-pointer | ||
29 | |||
30 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | 26 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o |
31 | 27 | ||
32 | USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \ | 28 | USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \ |
33 | time.o tty_log.o umid.o user_util.o frame.o | 29 | time.o tty_log.o umid.o user_util.o |
34 | 30 | ||
35 | include arch/um/scripts/Makefile.rules | 31 | include arch/um/scripts/Makefile.rules |
36 | 32 | ||
37 | targets += config.c | 33 | targets := config.c config.tmp |
38 | 34 | ||
39 | # Be careful with the below Sed code - sed is pitfall-rich! | 35 | # Be careful with the below Sed code - sed is pitfall-rich! |
40 | # We use sed to lower build requirements, for "embedded" builders for instance. | 36 | # We use sed to lower build requirements, for "embedded" builders for instance. |
diff --git a/arch/um/kernel/checksum.c b/arch/um/kernel/checksum.c deleted file mode 100644 index e69b2be951d1..000000000000 --- a/arch/um/kernel/checksum.c +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | #include "asm/uaccess.h" | ||
2 | #include "linux/errno.h" | ||
3 | #include "linux/module.h" | ||
4 | |||
5 | unsigned int arch_csum_partial(const unsigned char *buff, int len, int sum); | ||
6 | |||
7 | unsigned int csum_partial(unsigned char *buff, int len, int sum) | ||
8 | { | ||
9 | return arch_csum_partial(buff, len, sum); | ||
10 | } | ||
11 | |||
12 | EXPORT_SYMBOL(csum_partial); | ||
13 | |||
14 | unsigned int csum_partial_copy_to(const unsigned char *src, | ||
15 | unsigned char __user *dst, int len, int sum, | ||
16 | int *err_ptr) | ||
17 | { | ||
18 | if(copy_to_user(dst, src, len)){ | ||
19 | *err_ptr = -EFAULT; | ||
20 | return(-1); | ||
21 | } | ||
22 | |||
23 | return(arch_csum_partial(src, len, sum)); | ||
24 | } | ||
25 | |||
26 | unsigned int csum_partial_copy_from(const unsigned char __user *src, | ||
27 | unsigned char *dst, int len, int sum, | ||
28 | int *err_ptr) | ||
29 | { | ||
30 | if(copy_from_user(dst, src, len)){ | ||
31 | *err_ptr = -EFAULT; | ||
32 | return(-1); | ||
33 | } | ||
34 | |||
35 | return arch_csum_partial(dst, len, sum); | ||
36 | } | ||
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c index 49ddabe69be7..efd222ffe20e 100644 --- a/arch/um/kernel/exec_kern.c +++ b/arch/um/kernel/exec_kern.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include "kern.h" | 16 | #include "kern.h" |
17 | #include "irq_user.h" | 17 | #include "irq_user.h" |
18 | #include "tlb.h" | 18 | #include "tlb.h" |
19 | #include "2_5compat.h" | ||
20 | #include "os.h" | 19 | #include "os.h" |
21 | #include "time_user.h" | 20 | #include "time_user.h" |
22 | #include "choose-mode.h" | 21 | #include "choose-mode.h" |
diff --git a/arch/um/kernel/initrd_kern.c b/arch/um/kernel/initrd.c index fc568af468b9..82ecf904b09c 100644 --- a/arch/um/kernel/initrd_kern.c +++ b/arch/um/kernel/initrd.c | |||
@@ -41,12 +41,31 @@ static int __init uml_initrd_setup(char *line, int *add) | |||
41 | return 0; | 41 | return 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | __uml_setup("initrd=", uml_initrd_setup, | 44 | __uml_setup("initrd=", uml_initrd_setup, |
45 | "initrd=<initrd image>\n" | 45 | "initrd=<initrd image>\n" |
46 | " This is used to boot UML from an initrd image. The argument is the\n" | 46 | " This is used to boot UML from an initrd image. The argument is the\n" |
47 | " name of the file containing the image.\n\n" | 47 | " name of the file containing the image.\n\n" |
48 | ); | 48 | ); |
49 | 49 | ||
50 | int load_initrd(char *filename, void *buf, int size) | ||
51 | { | ||
52 | int fd, n; | ||
53 | |||
54 | fd = os_open_file(filename, of_read(OPENFLAGS()), 0); | ||
55 | if(fd < 0){ | ||
56 | printk("Opening '%s' failed - err = %d\n", filename, -fd); | ||
57 | return(-1); | ||
58 | } | ||
59 | n = os_read_file(fd, buf, size); | ||
60 | if(n != size){ | ||
61 | printk("Read of %d bytes from '%s' failed, err = %d\n", size, | ||
62 | filename, -n); | ||
63 | return(-1); | ||
64 | } | ||
65 | |||
66 | os_close_file(fd); | ||
67 | return(0); | ||
68 | } | ||
50 | /* | 69 | /* |
51 | * Overrides for Emacs so that we follow Linus's tabbing style. | 70 | * Overrides for Emacs so that we follow Linus's tabbing style. |
52 | * Emacs will notice this stuff at the end of the file and automatically | 71 | * Emacs will notice this stuff at the end of the file and automatically |
diff --git a/arch/um/kernel/initrd_user.c b/arch/um/kernel/initrd_user.c deleted file mode 100644 index cb90681e151c..000000000000 --- a/arch/um/kernel/initrd_user.c +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <unistd.h> | ||
7 | #include <sys/types.h> | ||
8 | #include <sys/stat.h> | ||
9 | #include <errno.h> | ||
10 | |||
11 | #include "user_util.h" | ||
12 | #include "kern_util.h" | ||
13 | #include "user.h" | ||
14 | #include "initrd.h" | ||
15 | #include "os.h" | ||
16 | |||
17 | int load_initrd(char *filename, void *buf, int size) | ||
18 | { | ||
19 | int fd, n; | ||
20 | |||
21 | fd = os_open_file(filename, of_read(OPENFLAGS()), 0); | ||
22 | if(fd < 0){ | ||
23 | printk("Opening '%s' failed - err = %d\n", filename, -fd); | ||
24 | return(-1); | ||
25 | } | ||
26 | n = os_read_file(fd, buf, size); | ||
27 | if(n != size){ | ||
28 | printk("Read of %d bytes from '%s' failed, err = %d\n", size, | ||
29 | filename, -n); | ||
30 | return(-1); | ||
31 | } | ||
32 | |||
33 | os_close_file(fd); | ||
34 | return(0); | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
39 | * Emacs will notice this stuff at the end of the file and automatically | ||
40 | * adjust the settings for this buffer only. This must remain at the end | ||
41 | * of the file. | ||
42 | * --------------------------------------------------------------------------- | ||
43 | * Local variables: | ||
44 | * c-file-style: "linux" | ||
45 | * End: | ||
46 | */ | ||
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c index d71e8f00810f..d44fb5282547 100644 --- a/arch/um/kernel/irq.c +++ b/arch/um/kernel/irq.c | |||
@@ -163,7 +163,6 @@ void __init init_IRQ(void) | |||
163 | irq_desc[i].handler = &SIGIO_irq_type; | 163 | irq_desc[i].handler = &SIGIO_irq_type; |
164 | enable_irq(i); | 164 | enable_irq(i); |
165 | } | 165 | } |
166 | init_irq_signals(0); | ||
167 | } | 166 | } |
168 | 167 | ||
169 | /* | 168 | /* |
diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c index 6d6f9484b884..b3074cbaa479 100644 --- a/arch/um/kernel/irq_user.c +++ b/arch/um/kernel/irq_user.c | |||
@@ -236,9 +236,15 @@ static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg) | |||
236 | (*prev)->fd, pollfds[i].fd); | 236 | (*prev)->fd, pollfds[i].fd); |
237 | goto out; | 237 | goto out; |
238 | } | 238 | } |
239 | memcpy(&pollfds[i], &pollfds[i + 1], | 239 | |
240 | (pollfds_num - i - 1) * sizeof(pollfds[0])); | ||
241 | pollfds_num--; | 240 | pollfds_num--; |
241 | |||
242 | /* This moves the *whole* array after pollfds[i] (though | ||
243 | * it doesn't spot as such)! */ | ||
244 | |||
245 | memmove(&pollfds[i], &pollfds[i + 1], | ||
246 | (pollfds_num - i) * sizeof(pollfds[0])); | ||
247 | |||
242 | if(last_irq_ptr == &old_fd->next) | 248 | if(last_irq_ptr == &old_fd->next) |
243 | last_irq_ptr = prev; | 249 | last_irq_ptr = prev; |
244 | *prev = (*prev)->next; | 250 | *prev = (*prev)->next; |
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c index b41d3397d07b..99439fa15ef4 100644 --- a/arch/um/kernel/ksyms.c +++ b/arch/um/kernel/ksyms.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include "linux/spinlock.h" | 10 | #include "linux/spinlock.h" |
11 | #include "linux/highmem.h" | 11 | #include "linux/highmem.h" |
12 | #include "asm/current.h" | 12 | #include "asm/current.h" |
13 | #include "asm/delay.h" | ||
14 | #include "asm/processor.h" | 13 | #include "asm/processor.h" |
15 | #include "asm/unistd.h" | 14 | #include "asm/unistd.h" |
16 | #include "asm/pgalloc.h" | 15 | #include "asm/pgalloc.h" |
@@ -28,8 +27,6 @@ EXPORT_SYMBOL(uml_physmem); | |||
28 | EXPORT_SYMBOL(set_signals); | 27 | EXPORT_SYMBOL(set_signals); |
29 | EXPORT_SYMBOL(get_signals); | 28 | EXPORT_SYMBOL(get_signals); |
30 | EXPORT_SYMBOL(kernel_thread); | 29 | EXPORT_SYMBOL(kernel_thread); |
31 | EXPORT_SYMBOL(__const_udelay); | ||
32 | EXPORT_SYMBOL(__udelay); | ||
33 | EXPORT_SYMBOL(sys_waitpid); | 30 | EXPORT_SYMBOL(sys_waitpid); |
34 | EXPORT_SYMBOL(task_size); | 31 | EXPORT_SYMBOL(task_size); |
35 | EXPORT_SYMBOL(flush_tlb_range); | 32 | EXPORT_SYMBOL(flush_tlb_range); |
@@ -60,6 +57,7 @@ EXPORT_SYMBOL(copy_to_user_tt); | |||
60 | EXPORT_SYMBOL(strncpy_from_user_skas); | 57 | EXPORT_SYMBOL(strncpy_from_user_skas); |
61 | EXPORT_SYMBOL(copy_to_user_skas); | 58 | EXPORT_SYMBOL(copy_to_user_skas); |
62 | EXPORT_SYMBOL(copy_from_user_skas); | 59 | EXPORT_SYMBOL(copy_from_user_skas); |
60 | EXPORT_SYMBOL(clear_user_skas); | ||
63 | #endif | 61 | #endif |
64 | EXPORT_SYMBOL(uml_strdup); | 62 | EXPORT_SYMBOL(uml_strdup); |
65 | 63 | ||
diff --git a/arch/um/kernel/main.c b/arch/um/kernel/main.c index a17c49703f9b..e59f58152678 100644 --- a/arch/um/kernel/main.c +++ b/arch/um/kernel/main.c | |||
@@ -24,8 +24,6 @@ | |||
24 | #include "mode.h" | 24 | #include "mode.h" |
25 | #include "choose-mode.h" | 25 | #include "choose-mode.h" |
26 | #include "uml-config.h" | 26 | #include "uml-config.h" |
27 | #include "irq_user.h" | ||
28 | #include "time_user.h" | ||
29 | #include "os.h" | 27 | #include "os.h" |
30 | 28 | ||
31 | /* Set in set_stklim, which is called from main and __wrap_malloc. | 29 | /* Set in set_stklim, which is called from main and __wrap_malloc. |
@@ -71,7 +69,7 @@ static __init void do_uml_initcalls(void) | |||
71 | 69 | ||
72 | static void last_ditch_exit(int sig) | 70 | static void last_ditch_exit(int sig) |
73 | { | 71 | { |
74 | CHOOSE_MODE(kmalloc_ok = 0, (void) 0); | 72 | kmalloc_ok = 0; |
75 | signal(SIGINT, SIG_DFL); | 73 | signal(SIGINT, SIG_DFL); |
76 | signal(SIGTERM, SIG_DFL); | 74 | signal(SIGTERM, SIG_DFL); |
77 | signal(SIGHUP, SIG_DFL); | 75 | signal(SIGHUP, SIG_DFL); |
@@ -87,7 +85,7 @@ int main(int argc, char **argv, char **envp) | |||
87 | { | 85 | { |
88 | char **new_argv; | 86 | char **new_argv; |
89 | sigset_t mask; | 87 | sigset_t mask; |
90 | int ret, i; | 88 | int ret, i, err; |
91 | 89 | ||
92 | /* Enable all signals except SIGIO - in some environments, we can | 90 | /* Enable all signals except SIGIO - in some environments, we can |
93 | * enter with some signals blocked | 91 | * enter with some signals blocked |
@@ -160,27 +158,29 @@ int main(int argc, char **argv, char **envp) | |||
160 | */ | 158 | */ |
161 | change_sig(SIGPROF, 0); | 159 | change_sig(SIGPROF, 0); |
162 | 160 | ||
163 | /* Reboot */ | 161 | /* This signal stuff used to be in the reboot case. However, |
164 | if(ret){ | 162 | * sometimes a SIGVTALRM can come in when we're halting (reproducably |
165 | int err; | 163 | * when writing out gcov information, presumably because that takes |
164 | * some time) and cause a segfault. | ||
165 | */ | ||
166 | 166 | ||
167 | printf("\n"); | 167 | /* stop timers and set SIG*ALRM to be ignored */ |
168 | disable_timer(); | ||
168 | 169 | ||
169 | /* stop timers and set SIG*ALRM to be ignored */ | 170 | /* disable SIGIO for the fds and set SIGIO to be ignored */ |
170 | disable_timer(); | 171 | err = deactivate_all_fds(); |
172 | if(err) | ||
173 | printf("deactivate_all_fds failed, errno = %d\n", -err); | ||
171 | 174 | ||
172 | /* disable SIGIO for the fds and set SIGIO to be ignored */ | 175 | /* Let any pending signals fire now. This ensures |
173 | err = deactivate_all_fds(); | 176 | * that they won't be delivered after the exec, when |
174 | if(err) | 177 | * they are definitely not expected. |
175 | printf("deactivate_all_fds failed, errno = %d\n", | 178 | */ |
176 | -err); | 179 | unblock_signals(); |
177 | |||
178 | /* Let any pending signals fire now. This ensures | ||
179 | * that they won't be delivered after the exec, when | ||
180 | * they are definitely not expected. | ||
181 | */ | ||
182 | unblock_signals(); | ||
183 | 180 | ||
181 | /* Reboot */ | ||
182 | if(ret){ | ||
183 | printf("\n"); | ||
184 | execvp(new_argv[0], new_argv); | 184 | execvp(new_argv[0], new_argv); |
185 | perror("Failed to exec kernel"); | 185 | perror("Failed to exec kernel"); |
186 | ret = 1; | 186 | ret = 1; |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index f156661781cb..c22825f13e40 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -100,12 +100,37 @@ void mem_init(void) | |||
100 | #endif | 100 | #endif |
101 | } | 101 | } |
102 | 102 | ||
103 | /* | ||
104 | * Create a page table and place a pointer to it in a middle page | ||
105 | * directory entry. | ||
106 | */ | ||
107 | static void __init one_page_table_init(pmd_t *pmd) | ||
108 | { | ||
109 | if (pmd_none(*pmd)) { | ||
110 | pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); | ||
111 | set_pmd(pmd, __pmd(_KERNPG_TABLE + | ||
112 | (unsigned long) __pa(pte))); | ||
113 | if (pte != pte_offset_kernel(pmd, 0)) | ||
114 | BUG(); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | static void __init one_md_table_init(pud_t *pud) | ||
119 | { | ||
120 | #ifdef CONFIG_3_LEVEL_PGTABLES | ||
121 | pmd_t *pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE); | ||
122 | set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table))); | ||
123 | if (pmd_table != pmd_offset(pud, 0)) | ||
124 | BUG(); | ||
125 | #endif | ||
126 | } | ||
127 | |||
103 | static void __init fixrange_init(unsigned long start, unsigned long end, | 128 | static void __init fixrange_init(unsigned long start, unsigned long end, |
104 | pgd_t *pgd_base) | 129 | pgd_t *pgd_base) |
105 | { | 130 | { |
106 | pgd_t *pgd; | 131 | pgd_t *pgd; |
132 | pud_t *pud; | ||
107 | pmd_t *pmd; | 133 | pmd_t *pmd; |
108 | pte_t *pte; | ||
109 | int i, j; | 134 | int i, j; |
110 | unsigned long vaddr; | 135 | unsigned long vaddr; |
111 | 136 | ||
@@ -115,15 +140,12 @@ static void __init fixrange_init(unsigned long start, unsigned long end, | |||
115 | pgd = pgd_base + i; | 140 | pgd = pgd_base + i; |
116 | 141 | ||
117 | for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) { | 142 | for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) { |
118 | pmd = (pmd_t *)pgd; | 143 | pud = pud_offset(pgd, vaddr); |
144 | if (pud_none(*pud)) | ||
145 | one_md_table_init(pud); | ||
146 | pmd = pmd_offset(pud, vaddr); | ||
119 | for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) { | 147 | for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) { |
120 | if (pmd_none(*pmd)) { | 148 | one_page_table_init(pmd); |
121 | pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); | ||
122 | set_pmd(pmd, __pmd(_KERNPG_TABLE + | ||
123 | (unsigned long) __pa(pte))); | ||
124 | if (pte != pte_offset_kernel(pmd, 0)) | ||
125 | BUG(); | ||
126 | } | ||
127 | vaddr += PMD_SIZE; | 149 | vaddr += PMD_SIZE; |
128 | } | 150 | } |
129 | j = 0; | 151 | j = 0; |
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index f76a2692adca..1b5ef3e96c71 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include "init.h" | 30 | #include "init.h" |
31 | #include "os.h" | 31 | #include "os.h" |
32 | #include "uml-config.h" | 32 | #include "uml-config.h" |
33 | #include "ptrace_user.h" | ||
34 | #include "choose-mode.h" | 33 | #include "choose-mode.h" |
35 | #include "mode.h" | 34 | #include "mode.h" |
36 | #ifdef UML_CONFIG_MODE_SKAS | 35 | #ifdef UML_CONFIG_MODE_SKAS |
@@ -65,8 +64,6 @@ void init_new_thread_signals(int altstack) | |||
65 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); | 64 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); |
66 | set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, | 65 | set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, |
67 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); | 66 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); |
68 | set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags, | ||
69 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); | ||
70 | set_handler(SIGUSR2, (__sighandler_t) sig_handler, | 67 | set_handler(SIGUSR2, (__sighandler_t) sig_handler, |
71 | flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); | 68 | flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); |
72 | signal(SIGHUP, SIG_IGN); | 69 | signal(SIGHUP, SIG_IGN); |
@@ -133,7 +130,7 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack, | |||
133 | return(arg.pid); | 130 | return(arg.pid); |
134 | } | 131 | } |
135 | 132 | ||
136 | static int ptrace_child(void *arg) | 133 | static int ptrace_child(void) |
137 | { | 134 | { |
138 | int ret; | 135 | int ret; |
139 | int pid = os_getpid(), ppid = getppid(); | 136 | int pid = os_getpid(), ppid = getppid(); |
@@ -162,20 +159,16 @@ static int ptrace_child(void *arg) | |||
162 | _exit(ret); | 159 | _exit(ret); |
163 | } | 160 | } |
164 | 161 | ||
165 | static int start_ptraced_child(void **stack_out) | 162 | static int start_ptraced_child(void) |
166 | { | 163 | { |
167 | void *stack; | ||
168 | unsigned long sp; | ||
169 | int pid, n, status; | 164 | int pid, n, status; |
170 | 165 | ||
171 | stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, | 166 | pid = fork(); |
172 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 167 | if(pid == 0) |
173 | if(stack == MAP_FAILED) | 168 | ptrace_child(); |
174 | panic("check_ptrace : mmap failed, errno = %d", errno); | 169 | |
175 | sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *); | ||
176 | pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL); | ||
177 | if(pid < 0) | 170 | if(pid < 0) |
178 | panic("check_ptrace : clone failed, errno = %d", errno); | 171 | panic("check_ptrace : fork failed, errno = %d", errno); |
179 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 172 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
180 | if(n < 0) | 173 | if(n < 0) |
181 | panic("check_ptrace : wait failed, errno = %d", errno); | 174 | panic("check_ptrace : wait failed, errno = %d", errno); |
@@ -183,7 +176,6 @@ static int start_ptraced_child(void **stack_out) | |||
183 | panic("check_ptrace : expected SIGSTOP, got status = %d", | 176 | panic("check_ptrace : expected SIGSTOP, got status = %d", |
184 | status); | 177 | status); |
185 | 178 | ||
186 | *stack_out = stack; | ||
187 | return(pid); | 179 | return(pid); |
188 | } | 180 | } |
189 | 181 | ||
@@ -191,12 +183,12 @@ static int start_ptraced_child(void **stack_out) | |||
191 | * just avoid using sysemu, not panic, but only if SYSEMU features are broken. | 183 | * just avoid using sysemu, not panic, but only if SYSEMU features are broken. |
192 | * So only for SYSEMU features we test mustpanic, while normal host features | 184 | * So only for SYSEMU features we test mustpanic, while normal host features |
193 | * must work anyway!*/ | 185 | * must work anyway!*/ |
194 | static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic) | 186 | static int stop_ptraced_child(int pid, int exitcode, int mustexit) |
195 | { | 187 | { |
196 | int status, n, ret = 0; | 188 | int status, n, ret = 0; |
197 | 189 | ||
198 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) | 190 | if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) |
199 | panic("check_ptrace : ptrace failed, errno = %d", errno); | 191 | panic("stop_ptraced_child : ptrace failed, errno = %d", errno); |
200 | CATCH_EINTR(n = waitpid(pid, &status, 0)); | 192 | CATCH_EINTR(n = waitpid(pid, &status, 0)); |
201 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { | 193 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { |
202 | int exit_with = WEXITSTATUS(status); | 194 | int exit_with = WEXITSTATUS(status); |
@@ -207,15 +199,13 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic) | |||
207 | printk("check_ptrace : child exited with exitcode %d, while " | 199 | printk("check_ptrace : child exited with exitcode %d, while " |
208 | "expecting %d; status 0x%x", exit_with, | 200 | "expecting %d; status 0x%x", exit_with, |
209 | exitcode, status); | 201 | exitcode, status); |
210 | if (mustpanic) | 202 | if (mustexit) |
211 | panic("\n"); | 203 | panic("\n"); |
212 | else | 204 | else |
213 | printk("\n"); | 205 | printk("\n"); |
214 | ret = -1; | 206 | ret = -1; |
215 | } | 207 | } |
216 | 208 | ||
217 | if(munmap(stack, PAGE_SIZE) < 0) | ||
218 | panic("check_ptrace : munmap failed, errno = %d", errno); | ||
219 | return ret; | 209 | return ret; |
220 | } | 210 | } |
221 | 211 | ||
@@ -237,12 +227,11 @@ __uml_setup("nosysemu", nosysemu_cmd_param, | |||
237 | 227 | ||
238 | static void __init check_sysemu(void) | 228 | static void __init check_sysemu(void) |
239 | { | 229 | { |
240 | void *stack; | ||
241 | int pid, syscall, n, status, count=0; | 230 | int pid, syscall, n, status, count=0; |
242 | 231 | ||
243 | printk("Checking syscall emulation patch for ptrace..."); | 232 | printk("Checking syscall emulation patch for ptrace..."); |
244 | sysemu_supported = 0; | 233 | sysemu_supported = 0; |
245 | pid = start_ptraced_child(&stack); | 234 | pid = start_ptraced_child(); |
246 | 235 | ||
247 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) | 236 | if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0) |
248 | goto fail; | 237 | goto fail; |
@@ -260,7 +249,7 @@ static void __init check_sysemu(void) | |||
260 | panic("check_sysemu : failed to modify system " | 249 | panic("check_sysemu : failed to modify system " |
261 | "call return, errno = %d", errno); | 250 | "call return, errno = %d", errno); |
262 | 251 | ||
263 | if (stop_ptraced_child(pid, stack, 0, 0) < 0) | 252 | if (stop_ptraced_child(pid, 0, 0) < 0) |
264 | goto fail_stopped; | 253 | goto fail_stopped; |
265 | 254 | ||
266 | sysemu_supported = 1; | 255 | sysemu_supported = 1; |
@@ -268,7 +257,7 @@ static void __init check_sysemu(void) | |||
268 | set_using_sysemu(!force_sysemu_disabled); | 257 | set_using_sysemu(!force_sysemu_disabled); |
269 | 258 | ||
270 | printk("Checking advanced syscall emulation patch for ptrace..."); | 259 | printk("Checking advanced syscall emulation patch for ptrace..."); |
271 | pid = start_ptraced_child(&stack); | 260 | pid = start_ptraced_child(); |
272 | while(1){ | 261 | while(1){ |
273 | count++; | 262 | count++; |
274 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) | 263 | if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0) |
@@ -293,7 +282,7 @@ static void __init check_sysemu(void) | |||
293 | break; | 282 | break; |
294 | } | 283 | } |
295 | } | 284 | } |
296 | if (stop_ptraced_child(pid, stack, 0, 0) < 0) | 285 | if (stop_ptraced_child(pid, 0, 0) < 0) |
297 | goto fail_stopped; | 286 | goto fail_stopped; |
298 | 287 | ||
299 | sysemu_supported = 2; | 288 | sysemu_supported = 2; |
@@ -304,18 +293,17 @@ static void __init check_sysemu(void) | |||
304 | return; | 293 | return; |
305 | 294 | ||
306 | fail: | 295 | fail: |
307 | stop_ptraced_child(pid, stack, 1, 0); | 296 | stop_ptraced_child(pid, 1, 0); |
308 | fail_stopped: | 297 | fail_stopped: |
309 | printk("missing\n"); | 298 | printk("missing\n"); |
310 | } | 299 | } |
311 | 300 | ||
312 | void __init check_ptrace(void) | 301 | void __init check_ptrace(void) |
313 | { | 302 | { |
314 | void *stack; | ||
315 | int pid, syscall, n, status; | 303 | int pid, syscall, n, status; |
316 | 304 | ||
317 | printk("Checking that ptrace can change system call numbers..."); | 305 | printk("Checking that ptrace can change system call numbers..."); |
318 | pid = start_ptraced_child(&stack); | 306 | pid = start_ptraced_child(); |
319 | 307 | ||
320 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) | 308 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) |
321 | panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); | 309 | panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); |
@@ -342,7 +330,7 @@ void __init check_ptrace(void) | |||
342 | break; | 330 | break; |
343 | } | 331 | } |
344 | } | 332 | } |
345 | stop_ptraced_child(pid, stack, 0, 1); | 333 | stop_ptraced_child(pid, 0, 1); |
346 | printk("OK\n"); | 334 | printk("OK\n"); |
347 | check_sysemu(); | 335 | check_sysemu(); |
348 | } | 336 | } |
@@ -374,11 +362,10 @@ void forward_pending_sigio(int target) | |||
374 | static inline int check_skas3_ptrace_support(void) | 362 | static inline int check_skas3_ptrace_support(void) |
375 | { | 363 | { |
376 | struct ptrace_faultinfo fi; | 364 | struct ptrace_faultinfo fi; |
377 | void *stack; | ||
378 | int pid, n, ret = 1; | 365 | int pid, n, ret = 1; |
379 | 366 | ||
380 | printf("Checking for the skas3 patch in the host..."); | 367 | printf("Checking for the skas3 patch in the host..."); |
381 | pid = start_ptraced_child(&stack); | 368 | pid = start_ptraced_child(); |
382 | 369 | ||
383 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 370 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
384 | if (n < 0) { | 371 | if (n < 0) { |
@@ -393,7 +380,7 @@ static inline int check_skas3_ptrace_support(void) | |||
393 | } | 380 | } |
394 | 381 | ||
395 | init_registers(pid); | 382 | init_registers(pid); |
396 | stop_ptraced_child(pid, stack, 1, 1); | 383 | stop_ptraced_child(pid, 1, 1); |
397 | 384 | ||
398 | return(ret); | 385 | return(ret); |
399 | } | 386 | } |
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index 7a943696f950..804c6bbdf67c 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include "tlb.h" | 43 | #include "tlb.h" |
44 | #include "frame_kern.h" | 44 | #include "frame_kern.h" |
45 | #include "sigcontext.h" | 45 | #include "sigcontext.h" |
46 | #include "2_5compat.h" | ||
47 | #include "os.h" | 46 | #include "os.h" |
48 | #include "mode.h" | 47 | #include "mode.h" |
49 | #include "mode_kern.h" | 48 | #include "mode_kern.h" |
@@ -55,18 +54,6 @@ | |||
55 | */ | 54 | */ |
56 | struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } }; | 55 | struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } }; |
57 | 56 | ||
58 | struct task_struct *get_task(int pid, int require) | ||
59 | { | ||
60 | struct task_struct *ret; | ||
61 | |||
62 | read_lock(&tasklist_lock); | ||
63 | ret = find_task_by_pid(pid); | ||
64 | read_unlock(&tasklist_lock); | ||
65 | |||
66 | if(require && (ret == NULL)) panic("get_task couldn't find a task\n"); | ||
67 | return(ret); | ||
68 | } | ||
69 | |||
70 | int external_pid(void *t) | 57 | int external_pid(void *t) |
71 | { | 58 | { |
72 | struct task_struct *task = t ? t : current; | 59 | struct task_struct *task = t ? t : current; |
@@ -115,16 +102,6 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | |||
115 | return(pid); | 102 | return(pid); |
116 | } | 103 | } |
117 | 104 | ||
118 | void switch_mm(struct mm_struct *prev, struct mm_struct *next, | ||
119 | struct task_struct *tsk) | ||
120 | { | ||
121 | int cpu = smp_processor_id(); | ||
122 | |||
123 | if (prev != next) | ||
124 | cpu_clear(cpu, prev->cpu_vm_mask); | ||
125 | cpu_set(cpu, next->cpu_vm_mask); | ||
126 | } | ||
127 | |||
128 | void set_current(void *t) | 105 | void set_current(void *t) |
129 | { | 106 | { |
130 | struct task_struct *task = t; | 107 | struct task_struct *task = t; |
@@ -152,7 +129,6 @@ void release_thread(struct task_struct *task) | |||
152 | 129 | ||
153 | void exit_thread(void) | 130 | void exit_thread(void) |
154 | { | 131 | { |
155 | CHOOSE_MODE(exit_thread_tt(), exit_thread_skas()); | ||
156 | unprotect_stack((unsigned long) current_thread); | 132 | unprotect_stack((unsigned long) current_thread); |
157 | } | 133 | } |
158 | 134 | ||
@@ -200,7 +176,6 @@ void default_idle(void) | |||
200 | 176 | ||
201 | while(1){ | 177 | while(1){ |
202 | /* endless idle loop with no priority at all */ | 178 | /* endless idle loop with no priority at all */ |
203 | SET_PRI(current); | ||
204 | 179 | ||
205 | /* | 180 | /* |
206 | * although we are an idle CPU, we do not want to | 181 | * although we are an idle CPU, we do not want to |
@@ -223,11 +198,6 @@ int page_size(void) | |||
223 | return(PAGE_SIZE); | 198 | return(PAGE_SIZE); |
224 | } | 199 | } |
225 | 200 | ||
226 | unsigned long page_mask(void) | ||
227 | { | ||
228 | return(PAGE_MASK); | ||
229 | } | ||
230 | |||
231 | void *um_virt_to_phys(struct task_struct *task, unsigned long addr, | 201 | void *um_virt_to_phys(struct task_struct *task, unsigned long addr, |
232 | pte_t *pte_out) | 202 | pte_t *pte_out) |
233 | { | 203 | { |
@@ -360,11 +330,6 @@ char *uml_strdup(char *string) | |||
360 | return(new); | 330 | return(new); |
361 | } | 331 | } |
362 | 332 | ||
363 | void *get_init_task(void) | ||
364 | { | ||
365 | return(&init_thread_union.thread_info.task); | ||
366 | } | ||
367 | |||
368 | int copy_to_user_proc(void __user *to, void *from, int size) | 333 | int copy_to_user_proc(void __user *to, void *from, int size) |
369 | { | 334 | { |
370 | return(copy_to_user(to, from, size)); | 335 | return(copy_to_user(to, from, size)); |
@@ -476,21 +441,18 @@ int singlestepping(void * t) | |||
476 | return 2; | 441 | return 2; |
477 | } | 442 | } |
478 | 443 | ||
444 | /* | ||
445 | * Only x86 and x86_64 have an arch_align_stack(). | ||
446 | * All other arches have "#define arch_align_stack(x) (x)" | ||
447 | * in their asm/system.h | ||
448 | * As this is included in UML from asm-um/system-generic.h, | ||
449 | * we can use it to behave as the subarch does. | ||
450 | */ | ||
451 | #ifndef arch_align_stack | ||
479 | unsigned long arch_align_stack(unsigned long sp) | 452 | unsigned long arch_align_stack(unsigned long sp) |
480 | { | 453 | { |
481 | if (randomize_va_space) | 454 | if (randomize_va_space) |
482 | sp -= get_random_int() % 8192; | 455 | sp -= get_random_int() % 8192; |
483 | return sp & ~0xf; | 456 | return sp & ~0xf; |
484 | } | 457 | } |
485 | 458 | #endif | |
486 | |||
487 | /* | ||
488 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
489 | * Emacs will notice this stuff at the end of the file and automatically | ||
490 | * adjust the settings for this buffer only. This must remain at the end | ||
491 | * of the file. | ||
492 | * --------------------------------------------------------------------------- | ||
493 | * Local variables: | ||
494 | * c-file-style: "linux" | ||
495 | * End: | ||
496 | */ | ||
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index e50e60ff5d27..71af4d503899 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c | |||
@@ -19,15 +19,30 @@ | |||
19 | #include "skas_ptrace.h" | 19 | #include "skas_ptrace.h" |
20 | #include "sysdep/ptrace.h" | 20 | #include "sysdep/ptrace.h" |
21 | 21 | ||
22 | static inline void set_singlestepping(struct task_struct *child, int on) | ||
23 | { | ||
24 | if (on) | ||
25 | child->ptrace |= PT_DTRACE; | ||
26 | else | ||
27 | child->ptrace &= ~PT_DTRACE; | ||
28 | child->thread.singlestep_syscall = 0; | ||
29 | |||
30 | #ifdef SUBARCH_SET_SINGLESTEPPING | ||
31 | SUBARCH_SET_SINGLESTEPPING(child, on); | ||
32 | #endif | ||
33 | } | ||
34 | |||
22 | /* | 35 | /* |
23 | * Called by kernel/ptrace.c when detaching.. | 36 | * Called by kernel/ptrace.c when detaching.. |
24 | */ | 37 | */ |
25 | void ptrace_disable(struct task_struct *child) | 38 | void ptrace_disable(struct task_struct *child) |
26 | { | 39 | { |
27 | child->ptrace &= ~PT_DTRACE; | 40 | set_singlestepping(child,0); |
28 | child->thread.singlestep_syscall = 0; | ||
29 | } | 41 | } |
30 | 42 | ||
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); | ||
45 | |||
31 | long sys_ptrace(long request, long pid, long addr, long data) | 46 | long sys_ptrace(long request, long pid, long addr, long data) |
32 | { | 47 | { |
33 | struct task_struct *child; | 48 | struct task_struct *child; |
@@ -67,6 +82,10 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
67 | goto out_tsk; | 82 | goto out_tsk; |
68 | } | 83 | } |
69 | 84 | ||
85 | #ifdef SUBACH_PTRACE_SPECIAL | ||
86 | SUBARCH_PTRACE_SPECIAL(child,request,addr,data); | ||
87 | #endif | ||
88 | |||
70 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | 89 | ret = ptrace_check_attach(child, request == PTRACE_KILL); |
71 | if (ret < 0) | 90 | if (ret < 0) |
72 | goto out_tsk; | 91 | goto out_tsk; |
@@ -87,26 +106,9 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
87 | } | 106 | } |
88 | 107 | ||
89 | /* read the word at location addr in the USER area. */ | 108 | /* read the word at location addr in the USER area. */ |
90 | case PTRACE_PEEKUSR: { | 109 | case PTRACE_PEEKUSR: |
91 | unsigned long tmp; | 110 | ret = peek_user(child, addr, data); |
92 | 111 | break; | |
93 | ret = -EIO; | ||
94 | if ((addr & 3) || addr < 0) | ||
95 | break; | ||
96 | |||
97 | tmp = 0; /* Default return condition */ | ||
98 | if(addr < MAX_REG_OFFSET){ | ||
99 | tmp = getreg(child, addr); | ||
100 | } | ||
101 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
102 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
103 | addr -= offsetof(struct user, u_debugreg[0]); | ||
104 | addr = addr >> 2; | ||
105 | tmp = child->thread.arch.debugregs[addr]; | ||
106 | } | ||
107 | ret = put_user(tmp, (unsigned long __user *) data); | ||
108 | break; | ||
109 | } | ||
110 | 112 | ||
111 | /* when I and D space are separate, this will have to be fixed. */ | 113 | /* when I and D space are separate, this will have to be fixed. */ |
112 | case PTRACE_POKETEXT: /* write the word at location addr. */ | 114 | case PTRACE_POKETEXT: /* write the word at location addr. */ |
@@ -119,26 +121,8 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
119 | break; | 121 | break; |
120 | 122 | ||
121 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ | 123 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ |
122 | ret = -EIO; | 124 | ret = poke_user(child, addr, data); |
123 | if ((addr & 3) || addr < 0) | 125 | break; |
124 | break; | ||
125 | |||
126 | if (addr < MAX_REG_OFFSET) { | ||
127 | ret = putreg(child, addr, data); | ||
128 | break; | ||
129 | } | ||
130 | #if 0 /* XXX x86_64 */ | ||
131 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
132 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
133 | addr -= offsetof(struct user, u_debugreg[0]); | ||
134 | addr = addr >> 2; | ||
135 | if((addr == 4) || (addr == 5)) break; | ||
136 | child->thread.arch.debugregs[addr] = data; | ||
137 | ret = 0; | ||
138 | } | ||
139 | #endif | ||
140 | |||
141 | break; | ||
142 | 126 | ||
143 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ | 127 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ |
144 | case PTRACE_CONT: { /* restart after signal. */ | 128 | case PTRACE_CONT: { /* restart after signal. */ |
@@ -146,8 +130,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
146 | if (!valid_signal(data)) | 130 | if (!valid_signal(data)) |
147 | break; | 131 | break; |
148 | 132 | ||
149 | child->ptrace &= ~PT_DTRACE; | 133 | set_singlestepping(child, 0); |
150 | child->thread.singlestep_syscall = 0; | ||
151 | if (request == PTRACE_SYSCALL) { | 134 | if (request == PTRACE_SYSCALL) { |
152 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 135 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); |
153 | } | 136 | } |
@@ -170,8 +153,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
170 | if (child->exit_state == EXIT_ZOMBIE) /* already dead */ | 153 | if (child->exit_state == EXIT_ZOMBIE) /* already dead */ |
171 | break; | 154 | break; |
172 | 155 | ||
173 | child->ptrace &= ~PT_DTRACE; | 156 | set_singlestepping(child, 0); |
174 | child->thread.singlestep_syscall = 0; | ||
175 | child->exit_code = SIGKILL; | 157 | child->exit_code = SIGKILL; |
176 | wake_up_process(child); | 158 | wake_up_process(child); |
177 | break; | 159 | break; |
@@ -182,8 +164,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
182 | if (!valid_signal(data)) | 164 | if (!valid_signal(data)) |
183 | break; | 165 | break; |
184 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 166 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); |
185 | child->ptrace |= PT_DTRACE; | 167 | set_singlestepping(child, 1); |
186 | child->thread.singlestep_syscall = 0; | ||
187 | child->exit_code = data; | 168 | child->exit_code = data; |
188 | /* give it a chance to run. */ | 169 | /* give it a chance to run. */ |
189 | wake_up_process(child); | 170 | wake_up_process(child); |
@@ -250,23 +231,19 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
250 | break; | 231 | break; |
251 | #endif | 232 | #endif |
252 | case PTRACE_FAULTINFO: { | 233 | case PTRACE_FAULTINFO: { |
253 | struct ptrace_faultinfo fault; | 234 | /* Take the info from thread->arch->faultinfo, |
254 | 235 | * but transfer max. sizeof(struct ptrace_faultinfo). | |
255 | fault = ((struct ptrace_faultinfo) | 236 | * On i386, ptrace_faultinfo is smaller! |
256 | { .is_write = child->thread.err, | 237 | */ |
257 | .addr = child->thread.cr2 }); | 238 | ret = copy_to_user((unsigned long __user *) data, |
258 | ret = copy_to_user((unsigned long __user *) data, &fault, | 239 | &child->thread.arch.faultinfo, |
259 | sizeof(fault)); | 240 | sizeof(struct ptrace_faultinfo)); |
260 | if(ret) | 241 | if(ret) |
261 | break; | 242 | break; |
262 | break; | 243 | break; |
263 | } | 244 | } |
264 | case PTRACE_SIGPENDING: | ||
265 | ret = copy_to_user((unsigned long __user *) data, | ||
266 | &child->pending.signal, | ||
267 | sizeof(child->pending.signal)); | ||
268 | break; | ||
269 | 245 | ||
246 | #ifdef PTRACE_LDT | ||
270 | case PTRACE_LDT: { | 247 | case PTRACE_LDT: { |
271 | struct ptrace_ldt ldt; | 248 | struct ptrace_ldt ldt; |
272 | 249 | ||
@@ -282,6 +259,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
282 | ret = -EIO; | 259 | ret = -EIO; |
283 | break; | 260 | break; |
284 | } | 261 | } |
262 | #endif | ||
285 | #ifdef CONFIG_PROC_MM | 263 | #ifdef CONFIG_PROC_MM |
286 | case PTRACE_SWITCH_MM: { | 264 | case PTRACE_SWITCH_MM: { |
287 | struct mm_struct *old = child->mm; | 265 | struct mm_struct *old = child->mm; |
@@ -337,15 +315,16 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit) | |||
337 | 315 | ||
338 | if (unlikely(current->audit_context)) { | 316 | if (unlikely(current->audit_context)) { |
339 | if (!entryexit) | 317 | if (!entryexit) |
340 | audit_syscall_entry(current, | 318 | audit_syscall_entry(current, |
341 | UPT_SYSCALL_NR(®s->regs), | 319 | HOST_AUDIT_ARCH, |
342 | UPT_SYSCALL_ARG1(®s->regs), | 320 | UPT_SYSCALL_NR(regs), |
343 | UPT_SYSCALL_ARG2(®s->regs), | 321 | UPT_SYSCALL_ARG1(regs), |
344 | UPT_SYSCALL_ARG3(®s->regs), | 322 | UPT_SYSCALL_ARG2(regs), |
345 | UPT_SYSCALL_ARG4(®s->regs)); | 323 | UPT_SYSCALL_ARG3(regs), |
346 | else | 324 | UPT_SYSCALL_ARG4(regs)); |
347 | audit_syscall_exit(current, | 325 | else audit_syscall_exit(current, |
348 | UPT_SYSCALL_RET(®s->regs)); | 326 | AUDITSC_RESULT(UPT_SYSCALL_RET(regs)), |
327 | UPT_SYSCALL_RET(regs)); | ||
349 | } | 328 | } |
350 | 329 | ||
351 | /* Fake a debug trap */ | 330 | /* Fake a debug trap */ |
@@ -375,14 +354,3 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit) | |||
375 | current->exit_code = 0; | 354 | current->exit_code = 0; |
376 | } | 355 | } |
377 | } | 356 | } |
378 | |||
379 | /* | ||
380 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
381 | * Emacs will notice this stuff at the end of the file and automatically | ||
382 | * adjust the settings for this buffer only. This must remain at the end | ||
383 | * of the file. | ||
384 | * --------------------------------------------------------------------------- | ||
385 | * Local variables: | ||
386 | * c-file-style: "linux" | ||
387 | * End: | ||
388 | */ | ||
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c index 668df13d8c9d..e89218958f38 100644 --- a/arch/um/kernel/sigio_user.c +++ b/arch/um/kernel/sigio_user.c | |||
@@ -182,6 +182,7 @@ static int write_sigio_thread(void *unused) | |||
182 | int i, n, respond_fd; | 182 | int i, n, respond_fd; |
183 | char c; | 183 | char c; |
184 | 184 | ||
185 | signal(SIGWINCH, SIG_IGN); | ||
185 | fds = ¤t_poll; | 186 | fds = ¤t_poll; |
186 | while(1){ | 187 | while(1){ |
187 | n = poll(fds->poll, fds->used, -1); | 188 | n = poll(fds->poll, fds->used, -1); |
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h index 94c564962378..e48490028111 100644 --- a/arch/um/kernel/skas/include/mode_kern-skas.h +++ b/arch/um/kernel/skas/include/mode_kern-skas.h | |||
@@ -18,7 +18,6 @@ extern int copy_thread_skas(int nr, unsigned long clone_flags, | |||
18 | unsigned long sp, unsigned long stack_top, | 18 | unsigned long sp, unsigned long stack_top, |
19 | struct task_struct *p, struct pt_regs *regs); | 19 | struct task_struct *p, struct pt_regs *regs); |
20 | extern void release_thread_skas(struct task_struct *task); | 20 | extern void release_thread_skas(struct task_struct *task); |
21 | extern void exit_thread_skas(void); | ||
22 | extern void initial_thread_cb_skas(void (*proc)(void *), void *arg); | 21 | extern void initial_thread_cb_skas(void (*proc)(void *), void *arg); |
23 | extern void init_idle_skas(void); | 22 | extern void init_idle_skas(void); |
24 | extern void flush_tlb_kernel_range_skas(unsigned long start, | 23 | extern void flush_tlb_kernel_range_skas(unsigned long start, |
diff --git a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h index f0702c2c7204..96b51dba3471 100644 --- a/arch/um/kernel/skas/include/skas.h +++ b/arch/um/kernel/skas/include/skas.h | |||
@@ -27,9 +27,10 @@ extern void map(int fd, unsigned long virt, unsigned long len, int r, int w, | |||
27 | extern int unmap(int fd, void *addr, unsigned long len); | 27 | extern int unmap(int fd, void *addr, unsigned long len); |
28 | extern int protect(int fd, unsigned long addr, unsigned long len, | 28 | extern int protect(int fd, unsigned long addr, unsigned long len, |
29 | int r, int w, int x); | 29 | int r, int w, int x); |
30 | extern void user_signal(int sig, union uml_pt_regs *regs); | 30 | extern void user_signal(int sig, union uml_pt_regs *regs, int pid); |
31 | extern int new_mm(int from); | 31 | extern int new_mm(int from); |
32 | extern void start_userspace(int cpu); | 32 | extern void start_userspace(int cpu); |
33 | extern void get_skas_faultinfo(int pid, struct faultinfo * fi); | ||
33 | extern long execute_syscall_skas(void *r); | 34 | extern long execute_syscall_skas(void *r); |
34 | 35 | ||
35 | #endif | 36 | #endif |
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h index c35620385da0..cd6c280482cb 100644 --- a/arch/um/kernel/skas/include/uaccess-skas.h +++ b/arch/um/kernel/skas/include/uaccess-skas.h | |||
@@ -18,8 +18,8 @@ | |||
18 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | 18 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ |
19 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) | 19 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) |
20 | 20 | ||
21 | static inline int __deprecated verify_area_skas(int type, const void * addr, | 21 | static inline int verify_area_skas(int type, const void * addr, |
22 | unsigned long size) | 22 | unsigned long size) |
23 | { | 23 | { |
24 | return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); | 24 | return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); |
25 | } | 25 | } |
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c index b4ffaaa81241..773cd2b525fc 100644 --- a/arch/um/kernel/skas/process.c +++ b/arch/um/kernel/skas/process.c | |||
@@ -4,6 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <string.h> | ||
7 | #include <unistd.h> | 8 | #include <unistd.h> |
8 | #include <errno.h> | 9 | #include <errno.h> |
9 | #include <signal.h> | 10 | #include <signal.h> |
@@ -27,27 +28,37 @@ | |||
27 | #include "chan_user.h" | 28 | #include "chan_user.h" |
28 | #include "signal_user.h" | 29 | #include "signal_user.h" |
29 | #include "registers.h" | 30 | #include "registers.h" |
31 | #include "process.h" | ||
30 | 32 | ||
31 | int is_skas_winch(int pid, int fd, void *data) | 33 | int is_skas_winch(int pid, int fd, void *data) |
32 | { | 34 | { |
33 | if(pid != os_getpid()) | 35 | if(pid != os_getpgrp()) |
34 | return(0); | 36 | return(0); |
35 | 37 | ||
36 | register_winch_irq(-1, fd, -1, data); | 38 | register_winch_irq(-1, fd, -1, data); |
37 | return(1); | 39 | return(1); |
38 | } | 40 | } |
39 | 41 | ||
40 | static void handle_segv(int pid) | 42 | void get_skas_faultinfo(int pid, struct faultinfo * fi) |
41 | { | 43 | { |
42 | struct ptrace_faultinfo fault; | ||
43 | int err; | 44 | int err; |
44 | 45 | ||
45 | err = ptrace(PTRACE_FAULTINFO, pid, 0, &fault); | 46 | err = ptrace(PTRACE_FAULTINFO, pid, 0, fi); |
46 | if(err) | 47 | if(err) |
47 | panic("handle_segv - PTRACE_FAULTINFO failed, errno = %d\n", | 48 | panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, " |
48 | errno); | 49 | "errno = %d\n", errno); |
50 | |||
51 | /* Special handling for i386, which has different structs */ | ||
52 | if (sizeof(struct ptrace_faultinfo) < sizeof(struct faultinfo)) | ||
53 | memset((char *)fi + sizeof(struct ptrace_faultinfo), 0, | ||
54 | sizeof(struct faultinfo) - | ||
55 | sizeof(struct ptrace_faultinfo)); | ||
56 | } | ||
49 | 57 | ||
50 | segv(fault.addr, 0, FAULT_WRITE(fault.is_write), 1, NULL); | 58 | static void handle_segv(int pid, union uml_pt_regs * regs) |
59 | { | ||
60 | get_skas_faultinfo(pid, ®s->skas.faultinfo); | ||
61 | segv(regs->skas.faultinfo, 0, 1, NULL); | ||
51 | } | 62 | } |
52 | 63 | ||
53 | /*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/ | 64 | /*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/ |
@@ -163,7 +174,7 @@ void userspace(union uml_pt_regs *regs) | |||
163 | if(WIFSTOPPED(status)){ | 174 | if(WIFSTOPPED(status)){ |
164 | switch(WSTOPSIG(status)){ | 175 | switch(WSTOPSIG(status)){ |
165 | case SIGSEGV: | 176 | case SIGSEGV: |
166 | handle_segv(pid); | 177 | handle_segv(pid, regs); |
167 | break; | 178 | break; |
168 | case SIGTRAP + 0x80: | 179 | case SIGTRAP + 0x80: |
169 | handle_trap(pid, regs, local_using_sysemu); | 180 | handle_trap(pid, regs, local_using_sysemu); |
@@ -177,7 +188,7 @@ void userspace(union uml_pt_regs *regs) | |||
177 | case SIGBUS: | 188 | case SIGBUS: |
178 | case SIGFPE: | 189 | case SIGFPE: |
179 | case SIGWINCH: | 190 | case SIGWINCH: |
180 | user_signal(WSTOPSIG(status), regs); | 191 | user_signal(WSTOPSIG(status), regs, pid); |
181 | break; | 192 | break; |
182 | default: | 193 | default: |
183 | printk("userspace - child stopped with signal " | 194 | printk("userspace - child stopped with signal " |
@@ -190,6 +201,11 @@ void userspace(union uml_pt_regs *regs) | |||
190 | } | 201 | } |
191 | } | 202 | } |
192 | } | 203 | } |
204 | #define INIT_JMP_NEW_THREAD 0 | ||
205 | #define INIT_JMP_REMOVE_SIGSTACK 1 | ||
206 | #define INIT_JMP_CALLBACK 2 | ||
207 | #define INIT_JMP_HALT 3 | ||
208 | #define INIT_JMP_REBOOT 4 | ||
193 | 209 | ||
194 | void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, | 210 | void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, |
195 | void (*handler)(int)) | 211 | void (*handler)(int)) |
@@ -225,7 +241,7 @@ void thread_wait(void *sw, void *fb) | |||
225 | *switch_buf = &buf; | 241 | *switch_buf = &buf; |
226 | fork_buf = fb; | 242 | fork_buf = fb; |
227 | if(sigsetjmp(buf, 1) == 0) | 243 | if(sigsetjmp(buf, 1) == 0) |
228 | siglongjmp(*fork_buf, 1); | 244 | siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK); |
229 | } | 245 | } |
230 | 246 | ||
231 | void switch_threads(void *me, void *next) | 247 | void switch_threads(void *me, void *next) |
@@ -249,23 +265,31 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) | |||
249 | sigjmp_buf **switch_buf = switch_buf_ptr; | 265 | sigjmp_buf **switch_buf = switch_buf_ptr; |
250 | int n; | 266 | int n; |
251 | 267 | ||
268 | set_handler(SIGWINCH, (__sighandler_t) sig_handler, | ||
269 | SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM, | ||
270 | SIGVTALRM, -1); | ||
271 | |||
252 | *fork_buf_ptr = &initial_jmpbuf; | 272 | *fork_buf_ptr = &initial_jmpbuf; |
253 | n = sigsetjmp(initial_jmpbuf, 1); | 273 | n = sigsetjmp(initial_jmpbuf, 1); |
254 | if(n == 0) | 274 | switch(n){ |
255 | new_thread_proc((void *) stack, new_thread_handler); | 275 | case INIT_JMP_NEW_THREAD: |
256 | else if(n == 1) | 276 | new_thread_proc((void *) stack, new_thread_handler); |
257 | remove_sigstack(); | 277 | break; |
258 | else if(n == 2){ | 278 | case INIT_JMP_REMOVE_SIGSTACK: |
279 | remove_sigstack(); | ||
280 | break; | ||
281 | case INIT_JMP_CALLBACK: | ||
259 | (*cb_proc)(cb_arg); | 282 | (*cb_proc)(cb_arg); |
260 | siglongjmp(*cb_back, 1); | 283 | siglongjmp(*cb_back, 1); |
261 | } | 284 | break; |
262 | else if(n == 3){ | 285 | case INIT_JMP_HALT: |
263 | kmalloc_ok = 0; | 286 | kmalloc_ok = 0; |
264 | return(0); | 287 | return(0); |
265 | } | 288 | case INIT_JMP_REBOOT: |
266 | else if(n == 4){ | ||
267 | kmalloc_ok = 0; | 289 | kmalloc_ok = 0; |
268 | return(1); | 290 | return(1); |
291 | default: | ||
292 | panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); | ||
269 | } | 293 | } |
270 | siglongjmp(**switch_buf, 1); | 294 | siglongjmp(**switch_buf, 1); |
271 | } | 295 | } |
@@ -290,7 +314,7 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) | |||
290 | 314 | ||
291 | block_signals(); | 315 | block_signals(); |
292 | if(sigsetjmp(here, 1) == 0) | 316 | if(sigsetjmp(here, 1) == 0) |
293 | siglongjmp(initial_jmpbuf, 2); | 317 | siglongjmp(initial_jmpbuf, INIT_JMP_CALLBACK); |
294 | unblock_signals(); | 318 | unblock_signals(); |
295 | 319 | ||
296 | cb_proc = NULL; | 320 | cb_proc = NULL; |
@@ -301,13 +325,13 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) | |||
301 | void halt_skas(void) | 325 | void halt_skas(void) |
302 | { | 326 | { |
303 | block_signals(); | 327 | block_signals(); |
304 | siglongjmp(initial_jmpbuf, 3); | 328 | siglongjmp(initial_jmpbuf, INIT_JMP_HALT); |
305 | } | 329 | } |
306 | 330 | ||
307 | void reboot_skas(void) | 331 | void reboot_skas(void) |
308 | { | 332 | { |
309 | block_signals(); | 333 | block_signals(); |
310 | siglongjmp(initial_jmpbuf, 4); | 334 | siglongjmp(initial_jmpbuf, INIT_JMP_REBOOT); |
311 | } | 335 | } |
312 | 336 | ||
313 | void switch_mm_skas(int mm_fd) | 337 | void switch_mm_skas(int mm_fd) |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index 5d096ea63b97..fc71ef295782 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -68,8 +68,11 @@ void new_thread_handler(int sig) | |||
68 | * 0 if it just exits | 68 | * 0 if it just exits |
69 | */ | 69 | */ |
70 | n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf); | 70 | n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf); |
71 | if(n == 1) | 71 | if(n == 1){ |
72 | /* Handle any immediate reschedules or signals */ | ||
73 | interrupt_end(); | ||
72 | userspace(¤t->thread.regs.regs); | 74 | userspace(¤t->thread.regs.regs); |
75 | } | ||
73 | else do_exit(0); | 76 | else do_exit(0); |
74 | } | 77 | } |
75 | 78 | ||
@@ -83,10 +86,6 @@ void release_thread_skas(struct task_struct *task) | |||
83 | { | 86 | { |
84 | } | 87 | } |
85 | 88 | ||
86 | void exit_thread_skas(void) | ||
87 | { | ||
88 | } | ||
89 | |||
90 | void fork_handler(int sig) | 89 | void fork_handler(int sig) |
91 | { | 90 | { |
92 | change_sig(SIGUSR1, 1); | 91 | change_sig(SIGUSR1, 1); |
@@ -100,6 +99,8 @@ void fork_handler(int sig) | |||
100 | schedule_tail(current->thread.prev_sched); | 99 | schedule_tail(current->thread.prev_sched); |
101 | current->thread.prev_sched = NULL; | 100 | current->thread.prev_sched = NULL; |
102 | 101 | ||
102 | /* Handle any immediate reschedules or signals */ | ||
103 | interrupt_end(); | ||
103 | userspace(¤t->thread.regs.regs); | 104 | userspace(¤t->thread.regs.regs); |
104 | } | 105 | } |
105 | 106 | ||
diff --git a/arch/um/kernel/skas/trap_user.c b/arch/um/kernel/skas/trap_user.c index 8e9b46d4702e..0dee1d95c806 100644 --- a/arch/um/kernel/skas/trap_user.c +++ b/arch/um/kernel/skas/trap_user.c | |||
@@ -5,12 +5,15 @@ | |||
5 | 5 | ||
6 | #include <signal.h> | 6 | #include <signal.h> |
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include "sysdep/ptrace.h" | ||
9 | #include "signal_user.h" | 8 | #include "signal_user.h" |
10 | #include "user_util.h" | 9 | #include "user_util.h" |
11 | #include "kern_util.h" | 10 | #include "kern_util.h" |
12 | #include "task.h" | 11 | #include "task.h" |
13 | #include "sigcontext.h" | 12 | #include "sigcontext.h" |
13 | #include "skas.h" | ||
14 | #include "ptrace_user.h" | ||
15 | #include "sysdep/ptrace.h" | ||
16 | #include "sysdep/ptrace_user.h" | ||
14 | 17 | ||
15 | void sig_handler_common_skas(int sig, void *sc_ptr) | 18 | void sig_handler_common_skas(int sig, void *sc_ptr) |
16 | { | 19 | { |
@@ -31,9 +34,11 @@ void sig_handler_common_skas(int sig, void *sc_ptr) | |||
31 | r = &TASK_REGS(get_current())->skas; | 34 | r = &TASK_REGS(get_current())->skas; |
32 | save_user = r->is_user; | 35 | save_user = r->is_user; |
33 | r->is_user = 0; | 36 | r->is_user = 0; |
34 | r->fault_addr = SC_FAULT_ADDR(sc); | 37 | if ( sig == SIGFPE || sig == SIGSEGV || |
35 | r->fault_type = SC_FAULT_TYPE(sc); | 38 | sig == SIGBUS || sig == SIGILL || |
36 | r->trap_type = SC_TRAP_TYPE(sc); | 39 | sig == SIGTRAP ) { |
40 | GET_FAULTINFO_FROM_SC(r->faultinfo, sc); | ||
41 | } | ||
37 | 42 | ||
38 | change_sig(SIGUSR1, 1); | 43 | change_sig(SIGUSR1, 1); |
39 | info = &sig_info[sig]; | 44 | info = &sig_info[sig]; |
@@ -45,14 +50,17 @@ void sig_handler_common_skas(int sig, void *sc_ptr) | |||
45 | r->is_user = save_user; | 50 | r->is_user = save_user; |
46 | } | 51 | } |
47 | 52 | ||
48 | void user_signal(int sig, union uml_pt_regs *regs) | 53 | extern int ptrace_faultinfo; |
54 | |||
55 | void user_signal(int sig, union uml_pt_regs *regs, int pid) | ||
49 | { | 56 | { |
50 | struct signal_info *info; | 57 | struct signal_info *info; |
58 | int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) || | ||
59 | (sig == SIGILL) || (sig == SIGTRAP)); | ||
51 | 60 | ||
52 | regs->skas.is_user = 1; | 61 | regs->skas.is_user = 1; |
53 | regs->skas.fault_addr = 0; | 62 | if (segv) |
54 | regs->skas.fault_type = 0; | 63 | get_skas_faultinfo(pid, ®s->skas.faultinfo); |
55 | regs->skas.trap_type = 0; | ||
56 | info = &sig_info[sig]; | 64 | info = &sig_info[sig]; |
57 | (*info->handler)(sig, regs); | 65 | (*info->handler)(sig, regs); |
58 | 66 | ||
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c index f7da9d027672..75195281081e 100644 --- a/arch/um/kernel/skas/uaccess.c +++ b/arch/um/kernel/skas/uaccess.c | |||
@@ -29,9 +29,12 @@ static unsigned long maybe_map(unsigned long virt, int is_write) | |||
29 | if(IS_ERR(phys) || (is_write && !pte_write(pte))){ | 29 | if(IS_ERR(phys) || (is_write && !pte_write(pte))){ |
30 | err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); | 30 | err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); |
31 | if(err) | 31 | if(err) |
32 | return(0); | 32 | return(-1UL); |
33 | phys = um_virt_to_phys(current, virt, NULL); | 33 | phys = um_virt_to_phys(current, virt, NULL); |
34 | } | 34 | } |
35 | if(IS_ERR(phys)) | ||
36 | phys = (void *) -1; | ||
37 | |||
35 | return((unsigned long) phys); | 38 | return((unsigned long) phys); |
36 | } | 39 | } |
37 | 40 | ||
@@ -42,7 +45,7 @@ static int do_op(unsigned long addr, int len, int is_write, | |||
42 | int n; | 45 | int n; |
43 | 46 | ||
44 | addr = maybe_map(addr, is_write); | 47 | addr = maybe_map(addr, is_write); |
45 | if(addr == -1) | 48 | if(addr == -1UL) |
46 | return(-1); | 49 | return(-1); |
47 | 50 | ||
48 | page = phys_to_page(addr); | 51 | page = phys_to_page(addr); |
diff --git a/arch/um/kernel/skas/util/Makefile b/arch/um/kernel/skas/util/Makefile index 17f5909d60f7..f7b7eba83340 100644 --- a/arch/um/kernel/skas/util/Makefile +++ b/arch/um/kernel/skas/util/Makefile | |||
@@ -2,3 +2,4 @@ hostprogs-y := mk_ptregs | |||
2 | always := $(hostprogs-y) | 2 | always := $(hostprogs-y) |
3 | 3 | ||
4 | mk_ptregs-objs := mk_ptregs-$(SUBARCH).o | 4 | mk_ptregs-objs := mk_ptregs-$(SUBARCH).o |
5 | HOSTCFLAGS_mk_ptregs-$(SUBARCH).o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/kernel/skas/util/mk_ptregs-i386.c b/arch/um/kernel/skas/util/mk_ptregs-i386.c index 0788dd05bcac..1f96e1eeb8a7 100644 --- a/arch/um/kernel/skas/util/mk_ptregs-i386.c +++ b/arch/um/kernel/skas/util/mk_ptregs-i386.c | |||
@@ -1,8 +1,7 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <asm/ptrace.h> | 2 | #include <user-offsets.h> |
3 | #include <asm/user.h> | ||
4 | 3 | ||
5 | #define PRINT_REG(name, val) printf("#define HOST_%s %d\n", (name), (val)) | 4 | #define SHOW(name) printf("#define %s %d\n", #name, name) |
6 | 5 | ||
7 | int main(int argc, char **argv) | 6 | int main(int argc, char **argv) |
8 | { | 7 | { |
@@ -12,28 +11,27 @@ int main(int argc, char **argv) | |||
12 | printf("#ifndef __SKAS_PT_REGS_\n"); | 11 | printf("#ifndef __SKAS_PT_REGS_\n"); |
13 | printf("#define __SKAS_PT_REGS_\n"); | 12 | printf("#define __SKAS_PT_REGS_\n"); |
14 | printf("\n"); | 13 | printf("\n"); |
15 | printf("#define HOST_FRAME_SIZE %d\n", FRAME_SIZE); | 14 | SHOW(HOST_FRAME_SIZE); |
16 | printf("#define HOST_FP_SIZE %d\n", | 15 | SHOW(HOST_FP_SIZE); |
17 | sizeof(struct user_i387_struct) / sizeof(unsigned long)); | 16 | SHOW(HOST_XFP_SIZE); |
18 | printf("#define HOST_XFP_SIZE %d\n", | 17 | |
19 | sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); | 18 | SHOW(HOST_IP); |
19 | SHOW(HOST_SP); | ||
20 | SHOW(HOST_EFLAGS); | ||
21 | SHOW(HOST_EAX); | ||
22 | SHOW(HOST_EBX); | ||
23 | SHOW(HOST_ECX); | ||
24 | SHOW(HOST_EDX); | ||
25 | SHOW(HOST_ESI); | ||
26 | SHOW(HOST_EDI); | ||
27 | SHOW(HOST_EBP); | ||
28 | SHOW(HOST_CS); | ||
29 | SHOW(HOST_SS); | ||
30 | SHOW(HOST_DS); | ||
31 | SHOW(HOST_FS); | ||
32 | SHOW(HOST_ES); | ||
33 | SHOW(HOST_GS); | ||
20 | 34 | ||
21 | PRINT_REG("IP", EIP); | ||
22 | PRINT_REG("SP", UESP); | ||
23 | PRINT_REG("EFLAGS", EFL); | ||
24 | PRINT_REG("EAX", EAX); | ||
25 | PRINT_REG("EBX", EBX); | ||
26 | PRINT_REG("ECX", ECX); | ||
27 | PRINT_REG("EDX", EDX); | ||
28 | PRINT_REG("ESI", ESI); | ||
29 | PRINT_REG("EDI", EDI); | ||
30 | PRINT_REG("EBP", EBP); | ||
31 | PRINT_REG("CS", CS); | ||
32 | PRINT_REG("SS", SS); | ||
33 | PRINT_REG("DS", DS); | ||
34 | PRINT_REG("FS", FS); | ||
35 | PRINT_REG("ES", ES); | ||
36 | PRINT_REG("GS", GS); | ||
37 | printf("\n"); | 35 | printf("\n"); |
38 | printf("#endif\n"); | 36 | printf("#endif\n"); |
39 | return(0); | 37 | return(0); |
diff --git a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c index 67aee92a70ef..5fccbfe35f78 100644 --- a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c +++ b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c | |||
@@ -5,11 +5,10 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #define __FRAME_OFFSETS | 8 | #include <user-offsets.h> |
9 | #include <asm/ptrace.h> | ||
10 | 9 | ||
11 | #define PRINT_REG(name, val) \ | 10 | #define SHOW(name) \ |
12 | printf("#define HOST_%s (%d / sizeof(unsigned long))\n", (name), (val)) | 11 | printf("#define %s (%d / sizeof(unsigned long))\n", #name, name) |
13 | 12 | ||
14 | int main(int argc, char **argv) | 13 | int main(int argc, char **argv) |
15 | { | 14 | { |
@@ -18,36 +17,35 @@ int main(int argc, char **argv) | |||
18 | printf("\n"); | 17 | printf("\n"); |
19 | printf("#ifndef __SKAS_PT_REGS_\n"); | 18 | printf("#ifndef __SKAS_PT_REGS_\n"); |
20 | printf("#define __SKAS_PT_REGS_\n"); | 19 | printf("#define __SKAS_PT_REGS_\n"); |
21 | printf("#define HOST_FRAME_SIZE (%d / sizeof(unsigned long))\n", | 20 | SHOW(HOST_FRAME_SIZE); |
22 | FRAME_SIZE); | 21 | SHOW(HOST_RBX); |
23 | PRINT_REG("RBX", RBX); | 22 | SHOW(HOST_RCX); |
24 | PRINT_REG("RCX", RCX); | 23 | SHOW(HOST_RDI); |
25 | PRINT_REG("RDI", RDI); | 24 | SHOW(HOST_RSI); |
26 | PRINT_REG("RSI", RSI); | 25 | SHOW(HOST_RDX); |
27 | PRINT_REG("RDX", RDX); | 26 | SHOW(HOST_RBP); |
28 | PRINT_REG("RBP", RBP); | 27 | SHOW(HOST_RAX); |
29 | PRINT_REG("RAX", RAX); | 28 | SHOW(HOST_R8); |
30 | PRINT_REG("R8", R8); | 29 | SHOW(HOST_R9); |
31 | PRINT_REG("R9", R9); | 30 | SHOW(HOST_R10); |
32 | PRINT_REG("R10", R10); | 31 | SHOW(HOST_R11); |
33 | PRINT_REG("R11", R11); | 32 | SHOW(HOST_R12); |
34 | PRINT_REG("R12", R12); | 33 | SHOW(HOST_R13); |
35 | PRINT_REG("R13", R13); | 34 | SHOW(HOST_R14); |
36 | PRINT_REG("R14", R14); | 35 | SHOW(HOST_R15); |
37 | PRINT_REG("R15", R15); | 36 | SHOW(HOST_ORIG_RAX); |
38 | PRINT_REG("ORIG_RAX", ORIG_RAX); | 37 | SHOW(HOST_CS); |
39 | PRINT_REG("CS", CS); | 38 | SHOW(HOST_SS); |
40 | PRINT_REG("SS", SS); | 39 | SHOW(HOST_EFLAGS); |
41 | PRINT_REG("EFLAGS", EFLAGS); | ||
42 | #if 0 | 40 | #if 0 |
43 | PRINT_REG("FS", FS); | 41 | SHOW(HOST_FS); |
44 | PRINT_REG("GS", GS); | 42 | SHOW(HOST_GS); |
45 | PRINT_REG("DS", DS); | 43 | SHOW(HOST_DS); |
46 | PRINT_REG("ES", ES); | 44 | SHOW(HOST_ES); |
47 | #endif | 45 | #endif |
48 | 46 | ||
49 | PRINT_REG("IP", RIP); | 47 | SHOW(HOST_IP); |
50 | PRINT_REG("SP", RSP); | 48 | SHOW(HOST_SP); |
51 | printf("#define HOST_FP_SIZE 0\n"); | 49 | printf("#define HOST_FP_SIZE 0\n"); |
52 | printf("#define HOST_XFP_SIZE 0\n"); | 50 | printf("#define HOST_XFP_SIZE 0\n"); |
53 | printf("\n"); | 51 | printf("\n"); |
diff --git a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c index 42731e04f50f..b7a55251e897 100644 --- a/arch/um/kernel/syscall_kern.c +++ b/arch/um/kernel/syscall_kern.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include "linux/utime.h" | 17 | #include "linux/utime.h" |
18 | #include "asm/mman.h" | 18 | #include "asm/mman.h" |
19 | #include "asm/uaccess.h" | 19 | #include "asm/uaccess.h" |
20 | #include "asm/ipc.h" | ||
21 | #include "kern_util.h" | 20 | #include "kern_util.h" |
22 | #include "user_util.h" | 21 | #include "user_util.h" |
23 | #include "sysdep/syscalls.h" | 22 | #include "sysdep/syscalls.h" |
diff --git a/arch/um/kernel/sysrq.c b/arch/um/kernel/sysrq.c index e630438f9e73..f80850091e79 100644 --- a/arch/um/kernel/sysrq.c +++ b/arch/um/kernel/sysrq.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/config.h" | ||
6 | #include "linux/sched.h" | 7 | #include "linux/sched.h" |
7 | #include "linux/kernel.h" | 8 | #include "linux/kernel.h" |
8 | #include "linux/module.h" | 9 | #include "linux/module.h" |
@@ -12,14 +13,14 @@ | |||
12 | #include "sysrq.h" | 13 | #include "sysrq.h" |
13 | #include "user_util.h" | 14 | #include "user_util.h" |
14 | 15 | ||
15 | void show_trace(unsigned long * stack) | 16 | /* Catch non-i386 SUBARCH's. */ |
17 | #if !defined(CONFIG_UML_X86) || defined(CONFIG_64BIT) | ||
18 | void show_trace(struct task_struct *task, unsigned long * stack) | ||
16 | { | 19 | { |
17 | /* XXX: Copy the CONFIG_FRAME_POINTER stack-walking backtrace from | ||
18 | * arch/i386/kernel/traps.c, and then move this to sys-i386/sysrq.c.*/ | ||
19 | unsigned long addr; | 20 | unsigned long addr; |
20 | 21 | ||
21 | if (!stack) { | 22 | if (!stack) { |
22 | stack = (unsigned long*) &stack; | 23 | stack = (unsigned long*) &stack; |
23 | WARN_ON(1); | 24 | WARN_ON(1); |
24 | } | 25 | } |
25 | 26 | ||
@@ -35,6 +36,7 @@ void show_trace(unsigned long * stack) | |||
35 | } | 36 | } |
36 | printk("\n"); | 37 | printk("\n"); |
37 | } | 38 | } |
39 | #endif | ||
38 | 40 | ||
39 | /* | 41 | /* |
40 | * stack dumps generator - this is used by arch-independent code. | 42 | * stack dumps generator - this is used by arch-independent code. |
@@ -44,7 +46,7 @@ void dump_stack(void) | |||
44 | { | 46 | { |
45 | unsigned long stack; | 47 | unsigned long stack; |
46 | 48 | ||
47 | show_trace(&stack); | 49 | show_trace(current, &stack); |
48 | } | 50 | } |
49 | EXPORT_SYMBOL(dump_stack); | 51 | EXPORT_SYMBOL(dump_stack); |
50 | 52 | ||
@@ -59,7 +61,11 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
59 | int i; | 61 | int i; |
60 | 62 | ||
61 | if (esp == NULL) { | 63 | if (esp == NULL) { |
62 | if (task != current) { | 64 | if (task != current && task != NULL) { |
65 | /* XXX: Isn't this bogus? I.e. isn't this the | ||
66 | * *userspace* stack of this task? If not so, use this | ||
67 | * even when task == current (as in i386). | ||
68 | */ | ||
63 | esp = (unsigned long *) KSTK_ESP(task); | 69 | esp = (unsigned long *) KSTK_ESP(task); |
64 | /* Which one? No actual difference - just coding style.*/ | 70 | /* Which one? No actual difference - just coding style.*/ |
65 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); | 71 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); |
@@ -77,5 +83,6 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
77 | printk("%08lx ", *stack++); | 83 | printk("%08lx ", *stack++); |
78 | } | 84 | } |
79 | 85 | ||
80 | show_trace(esp); | 86 | printk("Call Trace: \n"); |
87 | show_trace(current, esp); | ||
81 | } | 88 | } |
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c index 2461cd73ca87..6516fc52afe0 100644 --- a/arch/um/kernel/time_kern.c +++ b/arch/um/kernel/time_kern.c | |||
@@ -48,8 +48,6 @@ static unsigned long long prev_usecs; | |||
48 | static long long delta; /* Deviation per interval */ | 48 | static long long delta; /* Deviation per interval */ |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #define MILLION 1000000 | ||
52 | |||
53 | void timer_irq(union uml_pt_regs *regs) | 51 | void timer_irq(union uml_pt_regs *regs) |
54 | { | 52 | { |
55 | unsigned long long ticks = 0; | 53 | unsigned long long ticks = 0; |
@@ -136,22 +134,6 @@ long um_stime(int __user *tptr) | |||
136 | return 0; | 134 | return 0; |
137 | } | 135 | } |
138 | 136 | ||
139 | void __udelay(unsigned long usecs) | ||
140 | { | ||
141 | int i, n; | ||
142 | |||
143 | n = (loops_per_jiffy * HZ * usecs) / MILLION; | ||
144 | for(i=0;i<n;i++) ; | ||
145 | } | ||
146 | |||
147 | void __const_udelay(unsigned long usecs) | ||
148 | { | ||
149 | int i, n; | ||
150 | |||
151 | n = (loops_per_jiffy * HZ * usecs) / MILLION; | ||
152 | for(i=0;i<n;i++) ; | ||
153 | } | ||
154 | |||
155 | void timer_handler(int sig, union uml_pt_regs *regs) | 137 | void timer_handler(int sig, union uml_pt_regs *regs) |
156 | { | 138 | { |
157 | local_irq_disable(); | 139 | local_irq_disable(); |
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c index 47e766e6ba10..c20aef120598 100644 --- a/arch/um/kernel/trap_kern.c +++ b/arch/um/kernel/trap_kern.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "kern.h" | 23 | #include "kern.h" |
24 | #include "chan_kern.h" | 24 | #include "chan_kern.h" |
25 | #include "mconsole_kern.h" | 25 | #include "mconsole_kern.h" |
26 | #include "2_5compat.h" | ||
27 | #include "mem.h" | 26 | #include "mem.h" |
28 | #include "mem_kern.h" | 27 | #include "mem_kern.h" |
29 | 28 | ||
@@ -48,7 +47,7 @@ int handle_page_fault(unsigned long address, unsigned long ip, | |||
48 | goto good_area; | 47 | goto good_area; |
49 | else if(!(vma->vm_flags & VM_GROWSDOWN)) | 48 | else if(!(vma->vm_flags & VM_GROWSDOWN)) |
50 | goto out; | 49 | goto out; |
51 | else if(!ARCH_IS_STACKGROW(address)) | 50 | else if(is_user && !ARCH_IS_STACKGROW(address)) |
52 | goto out; | 51 | goto out; |
53 | else if(expand_stack(vma, address)) | 52 | else if(expand_stack(vma, address)) |
54 | goto out; | 53 | goto out; |
@@ -57,10 +56,11 @@ int handle_page_fault(unsigned long address, unsigned long ip, | |||
57 | *code_out = SEGV_ACCERR; | 56 | *code_out = SEGV_ACCERR; |
58 | if(is_write && !(vma->vm_flags & VM_WRITE)) | 57 | if(is_write && !(vma->vm_flags & VM_WRITE)) |
59 | goto out; | 58 | goto out; |
59 | |||
60 | if(!(vma->vm_flags & (VM_READ | VM_EXEC))) | ||
61 | goto out; | ||
62 | |||
60 | page = address & PAGE_MASK; | 63 | page = address & PAGE_MASK; |
61 | pgd = pgd_offset(mm, page); | ||
62 | pud = pud_offset(pgd, page); | ||
63 | pmd = pmd_offset(pud, page); | ||
64 | do { | 64 | do { |
65 | survive: | 65 | survive: |
66 | switch (handle_mm_fault(mm, vma, address, is_write)){ | 66 | switch (handle_mm_fault(mm, vma, address, is_write)){ |
@@ -106,46 +106,24 @@ out_of_memory: | |||
106 | goto out; | 106 | goto out; |
107 | } | 107 | } |
108 | 108 | ||
109 | LIST_HEAD(physmem_remappers); | 109 | /* |
110 | 110 | * We give a *copy* of the faultinfo in the regs to segv. | |
111 | void register_remapper(struct remapper *info) | 111 | * This must be done, since nesting SEGVs could overwrite |
112 | { | 112 | * the info in the regs. A pointer to the info then would |
113 | list_add(&info->list, &physmem_remappers); | 113 | * give us bad data! |
114 | } | 114 | */ |
115 | 115 | unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc) | |
116 | static int check_remapped_addr(unsigned long address, int is_write) | ||
117 | { | ||
118 | struct remapper *remapper; | ||
119 | struct list_head *ele; | ||
120 | __u64 offset; | ||
121 | int fd; | ||
122 | |||
123 | fd = phys_mapping(__pa(address), &offset); | ||
124 | if(fd == -1) | ||
125 | return(0); | ||
126 | |||
127 | list_for_each(ele, &physmem_remappers){ | ||
128 | remapper = list_entry(ele, struct remapper, list); | ||
129 | if((*remapper->proc)(fd, address, is_write, offset)) | ||
130 | return(1); | ||
131 | } | ||
132 | |||
133 | return(0); | ||
134 | } | ||
135 | |||
136 | unsigned long segv(unsigned long address, unsigned long ip, int is_write, | ||
137 | int is_user, void *sc) | ||
138 | { | 116 | { |
139 | struct siginfo si; | 117 | struct siginfo si; |
140 | void *catcher; | 118 | void *catcher; |
141 | int err; | 119 | int err; |
120 | int is_write = FAULT_WRITE(fi); | ||
121 | unsigned long address = FAULT_ADDRESS(fi); | ||
142 | 122 | ||
143 | if(!is_user && (address >= start_vm) && (address < end_vm)){ | 123 | if(!is_user && (address >= start_vm) && (address < end_vm)){ |
144 | flush_tlb_kernel_vm(); | 124 | flush_tlb_kernel_vm(); |
145 | return(0); | 125 | return(0); |
146 | } | 126 | } |
147 | else if(check_remapped_addr(address & PAGE_MASK, is_write)) | ||
148 | return(0); | ||
149 | else if(current->mm == NULL) | 127 | else if(current->mm == NULL) |
150 | panic("Segfault with no mm"); | 128 | panic("Segfault with no mm"); |
151 | err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); | 129 | err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); |
@@ -159,7 +137,7 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write, | |||
159 | } | 137 | } |
160 | else if(current->thread.fault_addr != NULL) | 138 | else if(current->thread.fault_addr != NULL) |
161 | panic("fault_addr set but no fault catcher"); | 139 | panic("fault_addr set but no fault catcher"); |
162 | else if(arch_fixup(ip, sc)) | 140 | else if(!is_user && arch_fixup(ip, sc)) |
163 | return(0); | 141 | return(0); |
164 | 142 | ||
165 | if(!is_user) | 143 | if(!is_user) |
@@ -171,6 +149,7 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write, | |||
171 | si.si_errno = 0; | 149 | si.si_errno = 0; |
172 | si.si_code = BUS_ADRERR; | 150 | si.si_code = BUS_ADRERR; |
173 | si.si_addr = (void *)address; | 151 | si.si_addr = (void *)address; |
152 | current->thread.arch.faultinfo = fi; | ||
174 | force_sig_info(SIGBUS, &si, current); | 153 | force_sig_info(SIGBUS, &si, current); |
175 | } | 154 | } |
176 | else if(err == -ENOMEM){ | 155 | else if(err == -ENOMEM){ |
@@ -180,22 +159,20 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write, | |||
180 | else { | 159 | else { |
181 | si.si_signo = SIGSEGV; | 160 | si.si_signo = SIGSEGV; |
182 | si.si_addr = (void *) address; | 161 | si.si_addr = (void *) address; |
183 | current->thread.cr2 = address; | 162 | current->thread.arch.faultinfo = fi; |
184 | current->thread.err = is_write; | ||
185 | force_sig_info(SIGSEGV, &si, current); | 163 | force_sig_info(SIGSEGV, &si, current); |
186 | } | 164 | } |
187 | return(0); | 165 | return(0); |
188 | } | 166 | } |
189 | 167 | ||
190 | void bad_segv(unsigned long address, unsigned long ip, int is_write) | 168 | void bad_segv(struct faultinfo fi, unsigned long ip) |
191 | { | 169 | { |
192 | struct siginfo si; | 170 | struct siginfo si; |
193 | 171 | ||
194 | si.si_signo = SIGSEGV; | 172 | si.si_signo = SIGSEGV; |
195 | si.si_code = SEGV_ACCERR; | 173 | si.si_code = SEGV_ACCERR; |
196 | si.si_addr = (void *) address; | 174 | si.si_addr = (void *) FAULT_ADDRESS(fi); |
197 | current->thread.cr2 = address; | 175 | current->thread.arch.faultinfo = fi; |
198 | current->thread.err = is_write; | ||
199 | force_sig_info(SIGSEGV, &si, current); | 176 | force_sig_info(SIGSEGV, &si, current); |
200 | } | 177 | } |
201 | 178 | ||
@@ -204,6 +181,7 @@ void relay_signal(int sig, union uml_pt_regs *regs) | |||
204 | if(arch_handle_signal(sig, regs)) return; | 181 | if(arch_handle_signal(sig, regs)) return; |
205 | if(!UPT_IS_USER(regs)) | 182 | if(!UPT_IS_USER(regs)) |
206 | panic("Kernel mode signal %d", sig); | 183 | panic("Kernel mode signal %d", sig); |
184 | current->thread.arch.faultinfo = *UPT_FAULTINFO(regs); | ||
207 | force_sig(sig, current); | 185 | force_sig(sig, current); |
208 | } | 186 | } |
209 | 187 | ||
diff --git a/arch/um/kernel/trap_user.c b/arch/um/kernel/trap_user.c index 50a4042a509f..f825a6eda3f5 100644 --- a/arch/um/kernel/trap_user.c +++ b/arch/um/kernel/trap_user.c | |||
@@ -54,23 +54,22 @@ struct { | |||
54 | void segv_handler(int sig, union uml_pt_regs *regs) | 54 | void segv_handler(int sig, union uml_pt_regs *regs) |
55 | { | 55 | { |
56 | int index, max; | 56 | int index, max; |
57 | struct faultinfo * fi = UPT_FAULTINFO(regs); | ||
57 | 58 | ||
58 | if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){ | 59 | if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){ |
59 | bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), | 60 | bad_segv(*fi, UPT_IP(regs)); |
60 | UPT_FAULT_WRITE(regs)); | ||
61 | return; | 61 | return; |
62 | } | 62 | } |
63 | max = sizeof(segfault_record)/sizeof(segfault_record[0]); | 63 | max = sizeof(segfault_record)/sizeof(segfault_record[0]); |
64 | index = next_trap_index(max); | 64 | index = next_trap_index(max); |
65 | 65 | ||
66 | nsegfaults++; | 66 | nsegfaults++; |
67 | segfault_record[index].address = UPT_FAULT_ADDR(regs); | 67 | segfault_record[index].address = FAULT_ADDRESS(*fi); |
68 | segfault_record[index].pid = os_getpid(); | 68 | segfault_record[index].pid = os_getpid(); |
69 | segfault_record[index].is_write = UPT_FAULT_WRITE(regs); | 69 | segfault_record[index].is_write = FAULT_WRITE(*fi); |
70 | segfault_record[index].sp = UPT_SP(regs); | 70 | segfault_record[index].sp = UPT_SP(regs); |
71 | segfault_record[index].is_user = UPT_IS_USER(regs); | 71 | segfault_record[index].is_user = UPT_IS_USER(regs); |
72 | segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs), | 72 | segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); |
73 | UPT_IS_USER(regs), regs); | ||
74 | } | 73 | } |
75 | 74 | ||
76 | void usr2_handler(int sig, union uml_pt_regs *regs) | 75 | void usr2_handler(int sig, union uml_pt_regs *regs) |
diff --git a/arch/um/kernel/tt/Makefile b/arch/um/kernel/tt/Makefile index 3d5177df3504..c3faea21a996 100644 --- a/arch/um/kernel/tt/Makefile +++ b/arch/um/kernel/tt/Makefile | |||
@@ -4,6 +4,7 @@ | |||
4 | # | 4 | # |
5 | 5 | ||
6 | extra-y := unmap_fin.o | 6 | extra-y := unmap_fin.o |
7 | targets := unmap.o | ||
7 | clean-files := unmap_tmp.o | 8 | clean-files := unmap_tmp.o |
8 | 9 | ||
9 | obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \ | 10 | obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \ |
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h index 28aaab3448fa..e0ca0e0b2516 100644 --- a/arch/um/kernel/tt/include/mode_kern-tt.h +++ b/arch/um/kernel/tt/include/mode_kern-tt.h | |||
@@ -19,7 +19,6 @@ extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp, | |||
19 | unsigned long stack_top, struct task_struct *p, | 19 | unsigned long stack_top, struct task_struct *p, |
20 | struct pt_regs *regs); | 20 | struct pt_regs *regs); |
21 | extern void release_thread_tt(struct task_struct *task); | 21 | extern void release_thread_tt(struct task_struct *task); |
22 | extern void exit_thread_tt(void); | ||
23 | extern void initial_thread_cb_tt(void (*proc)(void *), void *arg); | 22 | extern void initial_thread_cb_tt(void (*proc)(void *), void *arg); |
24 | extern void init_idle_tt(void); | 23 | extern void init_idle_tt(void); |
25 | extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end); | 24 | extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end); |
diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h index bb69d6b7d022..3fbb5fe26f49 100644 --- a/arch/um/kernel/tt/include/uaccess-tt.h +++ b/arch/um/kernel/tt/include/uaccess-tt.h | |||
@@ -33,8 +33,8 @@ extern unsigned long uml_physmem; | |||
33 | (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ | 33 | (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ |
34 | (under_task_size(addr, size) || is_stack(addr, size)))) | 34 | (under_task_size(addr, size) || is_stack(addr, size)))) |
35 | 35 | ||
36 | static inline int __deprecated verify_area_tt(int type, const void * addr, | 36 | static inline int verify_area_tt(int type, const void * addr, |
37 | unsigned long size) | 37 | unsigned long size) |
38 | { | 38 | { |
39 | return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); | 39 | return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); |
40 | } | 40 | } |
diff --git a/arch/um/kernel/tt/ksyms.c b/arch/um/kernel/tt/ksyms.c index 92ec85d67c7c..84a9385a8fef 100644 --- a/arch/um/kernel/tt/ksyms.c +++ b/arch/um/kernel/tt/ksyms.c | |||
@@ -12,6 +12,7 @@ EXPORT_SYMBOL(__do_copy_to_user); | |||
12 | EXPORT_SYMBOL(__do_strncpy_from_user); | 12 | EXPORT_SYMBOL(__do_strncpy_from_user); |
13 | EXPORT_SYMBOL(__do_strnlen_user); | 13 | EXPORT_SYMBOL(__do_strnlen_user); |
14 | EXPORT_SYMBOL(__do_clear_user); | 14 | EXPORT_SYMBOL(__do_clear_user); |
15 | EXPORT_SYMBOL(clear_user_tt); | ||
15 | 16 | ||
16 | EXPORT_SYMBOL(tracing_pid); | 17 | EXPORT_SYMBOL(tracing_pid); |
17 | EXPORT_SYMBOL(honeypot); | 18 | EXPORT_SYMBOL(honeypot); |
diff --git a/arch/um/kernel/tt/mem.c b/arch/um/kernel/tt/mem.c index 74346a04a2b2..bcb8796c3cb1 100644 --- a/arch/um/kernel/tt/mem.c +++ b/arch/um/kernel/tt/mem.c | |||
@@ -21,14 +21,8 @@ void before_mem_tt(unsigned long brk_start) | |||
21 | remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1); | 21 | remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1); |
22 | } | 22 | } |
23 | 23 | ||
24 | #ifdef CONFIG_HOST_2G_2G | ||
25 | #define TOP 0x80000000 | ||
26 | #else | ||
27 | #define TOP 0xc0000000 | ||
28 | #endif | ||
29 | |||
30 | #define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000) | 24 | #define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000) |
31 | #define START (TOP - SIZE) | 25 | #define START (CONFIG_TOP_ADDR - SIZE) |
32 | 26 | ||
33 | unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, | 27 | unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, |
34 | unsigned long *task_size_out) | 28 | unsigned long *task_size_out) |
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c index f19f7c18febe..776310fd5b8b 100644 --- a/arch/um/kernel/tt/process_kern.c +++ b/arch/um/kernel/tt/process_kern.c | |||
@@ -32,10 +32,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
32 | unsigned long flags; | 32 | unsigned long flags; |
33 | int err, vtalrm, alrm, prof, cpu; | 33 | int err, vtalrm, alrm, prof, cpu; |
34 | char c; | 34 | char c; |
35 | /* jailing and SMP are incompatible, so this doesn't need to be | ||
36 | * made per-cpu | ||
37 | */ | ||
38 | static int reading; | ||
39 | 35 | ||
40 | from = prev; | 36 | from = prev; |
41 | to = next; | 37 | to = next; |
@@ -59,14 +55,11 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
59 | c = 0; | 55 | c = 0; |
60 | set_current(to); | 56 | set_current(to); |
61 | 57 | ||
62 | reading = 0; | ||
63 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); | 58 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); |
64 | if(err != sizeof(c)) | 59 | if(err != sizeof(c)) |
65 | panic("write of switch_pipe failed, err = %d", -err); | 60 | panic("write of switch_pipe failed, err = %d", -err); |
66 | 61 | ||
67 | reading = 1; | 62 | if(from->thread.mode.tt.switch_pipe[0] == -1) |
68 | if((from->exit_state == EXIT_ZOMBIE) || | ||
69 | (from->exit_state == EXIT_DEAD)) | ||
70 | os_kill_process(os_getpid(), 0); | 63 | os_kill_process(os_getpid(), 0); |
71 | 64 | ||
72 | err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c)); | 65 | err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c)); |
@@ -81,8 +74,7 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
81 | * in case it has not already killed itself. | 74 | * in case it has not already killed itself. |
82 | */ | 75 | */ |
83 | prev_sched = current->thread.prev_sched; | 76 | prev_sched = current->thread.prev_sched; |
84 | if((prev_sched->exit_state == EXIT_ZOMBIE) || | 77 | if(prev_sched->thread.mode.tt.switch_pipe[0] == -1) |
85 | (prev_sched->exit_state == EXIT_DEAD)) | ||
86 | os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1); | 78 | os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1); |
87 | 79 | ||
88 | change_sig(SIGVTALRM, vtalrm); | 80 | change_sig(SIGVTALRM, vtalrm); |
@@ -101,14 +93,18 @@ void release_thread_tt(struct task_struct *task) | |||
101 | { | 93 | { |
102 | int pid = task->thread.mode.tt.extern_pid; | 94 | int pid = task->thread.mode.tt.extern_pid; |
103 | 95 | ||
96 | /* | ||
97 | * We first have to kill the other process, before | ||
98 | * closing its switch_pipe. Else it might wake up | ||
99 | * and receive "EOF" before we could kill it. | ||
100 | */ | ||
104 | if(os_getpid() != pid) | 101 | if(os_getpid() != pid) |
105 | os_kill_process(pid, 0); | 102 | os_kill_process(pid, 0); |
106 | } | ||
107 | 103 | ||
108 | void exit_thread_tt(void) | 104 | os_close_file(task->thread.mode.tt.switch_pipe[0]); |
109 | { | 105 | os_close_file(task->thread.mode.tt.switch_pipe[1]); |
110 | os_close_file(current->thread.mode.tt.switch_pipe[0]); | 106 | /* use switch_pipe as flag: thread is released */ |
111 | os_close_file(current->thread.mode.tt.switch_pipe[1]); | 107 | task->thread.mode.tt.switch_pipe[0] = -1; |
112 | } | 108 | } |
113 | 109 | ||
114 | void suspend_new_thread(int fd) | 110 | void suspend_new_thread(int fd) |
diff --git a/arch/um/kernel/tt/syscall_user.c b/arch/um/kernel/tt/syscall_user.c index e4e7e9c2224c..b218316cfdb2 100644 --- a/arch/um/kernel/tt/syscall_user.c +++ b/arch/um/kernel/tt/syscall_user.c | |||
@@ -63,6 +63,10 @@ void do_syscall(void *task, int pid, int local_using_sysemu) | |||
63 | 63 | ||
64 | UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs); | 64 | UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs); |
65 | 65 | ||
66 | #ifdef UPT_ORIGGPR2 | ||
67 | UPT_ORIGGPR2(TASK_REGS(task)) = REGS_ORIGGPR2(proc_regs); | ||
68 | #endif | ||
69 | |||
66 | if(((unsigned long *) PT_IP(proc_regs) >= &_stext) && | 70 | if(((unsigned long *) PT_IP(proc_regs) >= &_stext) && |
67 | ((unsigned long *) PT_IP(proc_regs) <= &_etext)) | 71 | ((unsigned long *) PT_IP(proc_regs) <= &_etext)) |
68 | tracer_panic("I'm tracing myself and I can't get out"); | 72 | tracer_panic("I'm tracing myself and I can't get out"); |
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c index 7b5d937e5955..d11e7399d7a1 100644 --- a/arch/um/kernel/tt/tracer.c +++ b/arch/um/kernel/tt/tracer.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "kern_util.h" | 26 | #include "kern_util.h" |
27 | #include "chan_user.h" | 27 | #include "chan_user.h" |
28 | #include "ptrace_user.h" | 28 | #include "ptrace_user.h" |
29 | #include "irq_user.h" | ||
29 | #include "mode.h" | 30 | #include "mode.h" |
30 | #include "tt.h" | 31 | #include "tt.h" |
31 | 32 | ||
@@ -33,7 +34,7 @@ static int tracer_winch[2]; | |||
33 | 34 | ||
34 | int is_tracer_winch(int pid, int fd, void *data) | 35 | int is_tracer_winch(int pid, int fd, void *data) |
35 | { | 36 | { |
36 | if(pid != tracing_pid) | 37 | if(pid != os_getpgrp()) |
37 | return(0); | 38 | return(0); |
38 | 39 | ||
39 | register_winch_irq(tracer_winch[0], fd, -1, data); | 40 | register_winch_irq(tracer_winch[0], fd, -1, data); |
@@ -89,8 +90,10 @@ void tracer_panic(char *format, ...) | |||
89 | 90 | ||
90 | static void tracer_segv(int sig, struct sigcontext sc) | 91 | static void tracer_segv(int sig, struct sigcontext sc) |
91 | { | 92 | { |
93 | struct faultinfo fi; | ||
94 | GET_FAULTINFO_FROM_SC(fi, &sc); | ||
92 | printf("Tracing thread segfault at address 0x%lx, ip 0x%lx\n", | 95 | printf("Tracing thread segfault at address 0x%lx, ip 0x%lx\n", |
93 | SC_FAULT_ADDR(&sc), SC_IP(&sc)); | 96 | FAULT_ADDRESS(fi), SC_IP(&sc)); |
94 | while(1) | 97 | while(1) |
95 | pause(); | 98 | pause(); |
96 | } | 99 | } |
@@ -117,6 +120,7 @@ static int signal_tramp(void *arg) | |||
117 | signal(SIGSEGV, (__sighandler_t) sig_handler); | 120 | signal(SIGSEGV, (__sighandler_t) sig_handler); |
118 | set_cmdline("(idle thread)"); | 121 | set_cmdline("(idle thread)"); |
119 | set_init_pid(os_getpid()); | 122 | set_init_pid(os_getpid()); |
123 | init_irq_signals(0); | ||
120 | proc = arg; | 124 | proc = arg; |
121 | return((*proc)(NULL)); | 125 | return((*proc)(NULL)); |
122 | } | 126 | } |
diff --git a/arch/um/kernel/tt/trap_user.c b/arch/um/kernel/tt/trap_user.c index 92a3820ca543..fc108615beaf 100644 --- a/arch/um/kernel/tt/trap_user.c +++ b/arch/um/kernel/tt/trap_user.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include <signal.h> | 8 | #include <signal.h> |
9 | #include "sysdep/ptrace.h" | 9 | #include "sysdep/ptrace.h" |
10 | #include "sysdep/sigcontext.h" | ||
10 | #include "signal_user.h" | 11 | #include "signal_user.h" |
11 | #include "user_util.h" | 12 | #include "user_util.h" |
12 | #include "kern_util.h" | 13 | #include "kern_util.h" |
@@ -28,6 +29,11 @@ void sig_handler_common_tt(int sig, void *sc_ptr) | |||
28 | change_sig(SIGSEGV, 1); | 29 | change_sig(SIGSEGV, 1); |
29 | 30 | ||
30 | r = &TASK_REGS(get_current())->tt; | 31 | r = &TASK_REGS(get_current())->tt; |
32 | if ( sig == SIGFPE || sig == SIGSEGV || | ||
33 | sig == SIGBUS || sig == SIGILL || | ||
34 | sig == SIGTRAP ) { | ||
35 | GET_FAULTINFO_FROM_SC(r->faultinfo, sc); | ||
36 | } | ||
31 | save_regs = *r; | 37 | save_regs = *r; |
32 | is_user = user_context(SC_SP(sc)); | 38 | is_user = user_context(SC_SP(sc)); |
33 | r->sc = sc; | 39 | r->sc = sc; |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 5c49d88eed3d..8736d098f0ee 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -23,9 +23,9 @@ | |||
23 | #include "asm/ptrace.h" | 23 | #include "asm/ptrace.h" |
24 | #include "asm/elf.h" | 24 | #include "asm/elf.h" |
25 | #include "asm/user.h" | 25 | #include "asm/user.h" |
26 | #include "asm/setup.h" | ||
26 | #include "ubd_user.h" | 27 | #include "ubd_user.h" |
27 | #include "asm/current.h" | 28 | #include "asm/current.h" |
28 | #include "asm/setup.h" | ||
29 | #include "user_util.h" | 29 | #include "user_util.h" |
30 | #include "kern_util.h" | 30 | #include "kern_util.h" |
31 | #include "kern.h" | 31 | #include "kern.h" |
@@ -42,9 +42,9 @@ | |||
42 | #define DEFAULT_COMMAND_LINE "root=98:0" | 42 | #define DEFAULT_COMMAND_LINE "root=98:0" |
43 | 43 | ||
44 | /* Changed in linux_main and setup_arch, which run before SMP is started */ | 44 | /* Changed in linux_main and setup_arch, which run before SMP is started */ |
45 | char command_line[COMMAND_LINE_SIZE] = { 0 }; | 45 | static char command_line[COMMAND_LINE_SIZE] = { 0 }; |
46 | 46 | ||
47 | void add_arg(char *arg) | 47 | static void add_arg(char *arg) |
48 | { | 48 | { |
49 | if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) { | 49 | if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) { |
50 | printf("add_arg: Too many command line arguments!\n"); | 50 | printf("add_arg: Too many command line arguments!\n"); |
@@ -110,12 +110,6 @@ struct seq_operations cpuinfo_op = { | |||
110 | .show = show_cpuinfo, | 110 | .show = show_cpuinfo, |
111 | }; | 111 | }; |
112 | 112 | ||
113 | pte_t * __bad_pagetable(void) | ||
114 | { | ||
115 | panic("Someone should implement __bad_pagetable"); | ||
116 | return(NULL); | ||
117 | } | ||
118 | |||
119 | /* Set in linux_main */ | 113 | /* Set in linux_main */ |
120 | unsigned long host_task_size; | 114 | unsigned long host_task_size; |
121 | unsigned long task_size; | 115 | unsigned long task_size; |
@@ -449,7 +443,7 @@ void __init setup_arch(char **cmdline_p) | |||
449 | { | 443 | { |
450 | notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); | 444 | notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); |
451 | paging_init(); | 445 | paging_init(); |
452 | strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); | 446 | strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); |
453 | *cmdline_p = command_line; | 447 | *cmdline_p = command_line; |
454 | setup_hostinfo(); | 448 | setup_hostinfo(); |
455 | } | 449 | } |
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 76eadb309189..dd5355500bdc 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S | |||
@@ -73,6 +73,8 @@ SECTIONS | |||
73 | 73 | ||
74 | .got : { *(.got.plt) *(.got) } | 74 | .got : { *(.got.plt) *(.got) } |
75 | .dynamic : { *(.dynamic) } | 75 | .dynamic : { *(.dynamic) } |
76 | .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } | ||
77 | .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } | ||
76 | /* We want the small data sections together, so single-instruction offsets | 78 | /* We want the small data sections together, so single-instruction offsets |
77 | can access them all, and initialized data all before uninitialized, so | 79 | can access them all, and initialized data all before uninitialized, so |
78 | we can shorten the on-disk segment size. */ | 80 | we can shorten the on-disk segment size. */ |
diff --git a/arch/um/kernel/vmlinux.lds.S b/arch/um/kernel/vmlinux.lds.S new file mode 100644 index 000000000000..1660a769674b --- /dev/null +++ b/arch/um/kernel/vmlinux.lds.S | |||
@@ -0,0 +1,6 @@ | |||
1 | #include <linux/config.h> | ||
2 | #ifdef CONFIG_LD_SCRIPT_STATIC | ||
3 | #include "uml.lds.S" | ||
4 | #else | ||
5 | #include "dyn.lds.S" | ||
6 | #endif | ||
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index 9aee0b62ebca..f0d6060e3e57 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c | |||
@@ -45,7 +45,11 @@ __init void scan_elf_aux( char **envp) | |||
45 | elf_aux_hwcap = auxv->a_un.a_val; | 45 | elf_aux_hwcap = auxv->a_un.a_val; |
46 | break; | 46 | break; |
47 | case AT_PLATFORM: | 47 | case AT_PLATFORM: |
48 | elf_aux_platform = auxv->a_un.a_ptr; | 48 | /* elf.h removed the pointer elements from |
49 | * a_un, so we have to use a_val, which is | ||
50 | * all that's left. | ||
51 | */ | ||
52 | elf_aux_platform = (char *) auxv->a_un.a_val; | ||
49 | break; | 53 | break; |
50 | case AT_PAGESZ: | 54 | case AT_PAGESZ: |
51 | page_size = auxv->a_un.a_val; | 55 | page_size = auxv->a_un.a_val; |
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 77d4066d1af8..fd45bb260907 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -363,7 +363,7 @@ int os_write_file(int fd, const void *buf, int len) | |||
363 | (int (*)(int, void *, int)) write, copy_to_user_proc)); | 363 | (int (*)(int, void *, int)) write, copy_to_user_proc)); |
364 | } | 364 | } |
365 | 365 | ||
366 | int os_file_size(char *file, long long *size_out) | 366 | int os_file_size(char *file, unsigned long long *size_out) |
367 | { | 367 | { |
368 | struct uml_stat buf; | 368 | struct uml_stat buf; |
369 | int err; | 369 | int err; |
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index ba9ca1cc790a..1e126bfd31a7 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -123,6 +123,11 @@ int os_getpid(void) | |||
123 | return(getpid()); | 123 | return(getpid()); |
124 | } | 124 | } |
125 | 125 | ||
126 | int os_getpgrp(void) | ||
127 | { | ||
128 | return getpgrp(); | ||
129 | } | ||
130 | |||
126 | int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len, | 131 | int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len, |
127 | int r, int w, int x) | 132 | int r, int w, int x) |
128 | { | 133 | { |
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 7eac1baf5975..c7bfd5ee3925 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include "mode.h" | 8 | #include "mode.h" |
9 | #include "sysdep/signal.h" | 9 | #include "sysdep/signal.h" |
10 | 10 | ||
11 | void sig_handler(int sig) | 11 | void sig_handler(ARCH_SIGHDLR_PARAM) |
12 | { | 12 | { |
13 | struct sigcontext *sc; | 13 | struct sigcontext *sc; |
14 | 14 | ||
@@ -19,7 +19,7 @@ void sig_handler(int sig) | |||
19 | 19 | ||
20 | extern int timer_irq_inited; | 20 | extern int timer_irq_inited; |
21 | 21 | ||
22 | void alarm_handler(int sig) | 22 | void alarm_handler(ARCH_SIGHDLR_PARAM) |
23 | { | 23 | { |
24 | struct sigcontext *sc; | 24 | struct sigcontext *sc; |
25 | 25 | ||
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile index fb00ddf969bd..9778aed0c314 100644 --- a/arch/um/os-Linux/util/Makefile +++ b/arch/um/os-Linux/util/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | hostprogs-y := mk_user_constants | 1 | hostprogs-y := mk_user_constants |
2 | always := $(hostprogs-y) | 2 | always := $(hostprogs-y) |
3 | 3 | ||
4 | mk_user_constants-objs := mk_user_constants.o | 4 | HOSTCFLAGS_mk_user_constants.o := -I$(objtree)/arch/um |
diff --git a/arch/um/os-Linux/util/mk_user_constants.c b/arch/um/os-Linux/util/mk_user_constants.c index 0933518aa8bd..4838f30eecf0 100644 --- a/arch/um/os-Linux/util/mk_user_constants.c +++ b/arch/um/os-Linux/util/mk_user_constants.c | |||
@@ -1,11 +1,5 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <asm/types.h> | 2 | #include <user-offsets.h> |
3 | /* For some reason, x86_64 nowhere defines u64 and u32, even though they're | ||
4 | * used throughout the headers. | ||
5 | */ | ||
6 | typedef __u64 u64; | ||
7 | typedef __u32 u32; | ||
8 | #include <asm/user.h> | ||
9 | 3 | ||
10 | int main(int argc, char **argv) | 4 | int main(int argc, char **argv) |
11 | { | 5 | { |
@@ -20,7 +14,7 @@ int main(int argc, char **argv) | |||
20 | * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on | 14 | * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on |
21 | * both x86_64 and i386. | 15 | * both x86_64 and i386. |
22 | */ | 16 | */ |
23 | printf("#define UM_FRAME_SIZE %d\n", (int) sizeof(struct user_regs_struct)); | 17 | printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE); |
24 | 18 | ||
25 | printf("\n"); | 19 | printf("\n"); |
26 | printf("#endif\n"); | 20 | printf("#endif\n"); |
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index 143f6fea0763..98346c711493 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules | |||
@@ -2,12 +2,27 @@ | |||
2 | # arch/um: Generic definitions | 2 | # arch/um: Generic definitions |
3 | # =========================================================================== | 3 | # =========================================================================== |
4 | 4 | ||
5 | USER_SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs)) | 5 | USER_SINGLE_OBJS := \ |
6 | USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) | 6 | $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs)) |
7 | 7 | USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) | |
8 | USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) | 8 | USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) |
9 | 9 | ||
10 | $(USER_OBJS): c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@)) | 10 | $(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ |
11 | $(CFLAGS_$(notdir $@)) | ||
11 | 12 | ||
12 | quiet_cmd_make_link = SYMLINK $@ | 13 | quiet_cmd_make_link = SYMLINK $@ |
13 | cmd_make_link = rm -f $@; ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ | 14 | cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ |
15 | |||
16 | # this needs to be before the foreach, because targets does not accept | ||
17 | # complete paths like $(obj)/$(f). To make sure this works, use a := assignment | ||
18 | # or we will get $(obj)/$(f) in the "targets" value. | ||
19 | # Also, this forces you to use the := syntax when assigning to targets. | ||
20 | # Otherwise the line below will cause an infinite loop (if you don't know why, | ||
21 | # just do it). | ||
22 | |||
23 | targets := $(targets) $(SYMLINKS) | ||
24 | |||
25 | SYMLINKS := $(foreach f,$(SYMLINKS),$(obj)/$(f)) | ||
26 | |||
27 | $(SYMLINKS): FORCE | ||
28 | $(call if_changed,make_link) | ||
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile index 950781e354de..4351e5605506 100644 --- a/arch/um/sys-i386/Makefile +++ b/arch/um/sys-i386/Makefile | |||
@@ -7,24 +7,13 @@ obj-$(CONFIG_MODULES) += module.o | |||
7 | 7 | ||
8 | USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o | 8 | USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o |
9 | 9 | ||
10 | include arch/um/scripts/Makefile.rules | ||
11 | |||
12 | SYMLINKS = bitops.c semaphore.c highmem.c module.c | 10 | SYMLINKS = bitops.c semaphore.c highmem.c module.c |
13 | 11 | ||
14 | # this needs to be before the foreach, because clean-files does not accept | 12 | include arch/um/scripts/Makefile.rules |
15 | # complete paths like $(src)/$f. | ||
16 | clean-files := $(SYMLINKS) | ||
17 | |||
18 | targets += $(SYMLINKS) | ||
19 | |||
20 | SYMLINKS := $(foreach f,$(SYMLINKS),$(obj)/$f) | ||
21 | 13 | ||
22 | bitops.c-dir = lib | 14 | bitops.c-dir = lib |
23 | semaphore.c-dir = kernel | 15 | semaphore.c-dir = kernel |
24 | highmem.c-dir = mm | 16 | highmem.c-dir = mm |
25 | module.c-dir = kernel | 17 | module.c-dir = kernel |
26 | 18 | ||
27 | $(SYMLINKS): FORCE | ||
28 | $(call if_changed,make_link) | ||
29 | |||
30 | subdir- := util | 19 | subdir- := util |
diff --git a/arch/um/sys-i386/checksum.S b/arch/um/sys-i386/checksum.S index a11171fb6223..d98b2fff3d08 100644 --- a/arch/um/sys-i386/checksum.S +++ b/arch/um/sys-i386/checksum.S | |||
@@ -38,7 +38,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) | |||
38 | 38 | ||
39 | .text | 39 | .text |
40 | .align 4 | 40 | .align 4 |
41 | .globl arch_csum_partial | 41 | .globl csum_partial |
42 | 42 | ||
43 | #ifndef CONFIG_X86_USE_PPRO_CHECKSUM | 43 | #ifndef CONFIG_X86_USE_PPRO_CHECKSUM |
44 | 44 | ||
@@ -49,7 +49,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) | |||
49 | * Fortunately, it is easy to convert 2-byte alignment to 4-byte | 49 | * Fortunately, it is easy to convert 2-byte alignment to 4-byte |
50 | * alignment for the unrolled loop. | 50 | * alignment for the unrolled loop. |
51 | */ | 51 | */ |
52 | arch_csum_partial: | 52 | csum_partial: |
53 | pushl %esi | 53 | pushl %esi |
54 | pushl %ebx | 54 | pushl %ebx |
55 | movl 20(%esp),%eax # Function arg: unsigned int sum | 55 | movl 20(%esp),%eax # Function arg: unsigned int sum |
@@ -119,7 +119,7 @@ arch_csum_partial: | |||
119 | 119 | ||
120 | /* Version for PentiumII/PPro */ | 120 | /* Version for PentiumII/PPro */ |
121 | 121 | ||
122 | arch_csum_partial: | 122 | csum_partial: |
123 | pushl %esi | 123 | pushl %esi |
124 | pushl %ebx | 124 | pushl %ebx |
125 | movl 20(%esp),%eax # Function arg: unsigned int sum | 125 | movl 20(%esp),%eax # Function arg: unsigned int sum |
diff --git a/arch/um/sys-i386/delay.c b/arch/um/sys-i386/delay.c index 20d37dbbaf08..2c11b9770e8b 100644 --- a/arch/um/sys-i386/delay.c +++ b/arch/um/sys-i386/delay.c | |||
@@ -1,3 +1,8 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/delay.h> | ||
4 | #include <asm/param.h> | ||
5 | |||
1 | void __delay(unsigned long time) | 6 | void __delay(unsigned long time) |
2 | { | 7 | { |
3 | /* Stolen from the i386 __loop_delay */ | 8 | /* Stolen from the i386 __loop_delay */ |
@@ -12,3 +17,24 @@ void __delay(unsigned long time) | |||
12 | :"0" (time)); | 17 | :"0" (time)); |
13 | } | 18 | } |
14 | 19 | ||
20 | void __udelay(unsigned long usecs) | ||
21 | { | ||
22 | int i, n; | ||
23 | |||
24 | n = (loops_per_jiffy * HZ * usecs) / MILLION; | ||
25 | for(i=0;i<n;i++) | ||
26 | cpu_relax(); | ||
27 | } | ||
28 | |||
29 | EXPORT_SYMBOL(__udelay); | ||
30 | |||
31 | void __const_udelay(unsigned long usecs) | ||
32 | { | ||
33 | int i, n; | ||
34 | |||
35 | n = (loops_per_jiffy * HZ * usecs) / MILLION; | ||
36 | for(i=0;i<n;i++) | ||
37 | cpu_relax(); | ||
38 | } | ||
39 | |||
40 | EXPORT_SYMBOL(__const_udelay); | ||
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/sys-i386/kernel-offsets.c new file mode 100644 index 000000000000..9f8ecd1fdd96 --- /dev/null +++ b/arch/um/sys-i386/kernel-offsets.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #include <linux/config.h> | ||
2 | #include <linux/stddef.h> | ||
3 | #include <linux/sched.h> | ||
4 | #include <linux/time.h> | ||
5 | #include <asm/page.h> | ||
6 | |||
7 | #define DEFINE(sym, val) \ | ||
8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
9 | |||
10 | #define STR(x) #x | ||
11 | #define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : ) | ||
12 | |||
13 | #define BLANK() asm volatile("\n->" : : ) | ||
14 | |||
15 | #define OFFSET(sym, str, mem) \ | ||
16 | DEFINE(sym, offsetof(struct str, mem)); | ||
17 | |||
18 | void foo(void) | ||
19 | { | ||
20 | OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs); | ||
21 | #ifdef CONFIG_MODE_TT | ||
22 | OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); | ||
23 | #endif | ||
24 | #include <common-offsets.h> | ||
25 | } | ||
diff --git a/arch/um/sys-i386/ksyms.c b/arch/um/sys-i386/ksyms.c index 74f70a120458..db524ab3f743 100644 --- a/arch/um/sys-i386/ksyms.c +++ b/arch/um/sys-i386/ksyms.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "linux/in6.h" | 2 | #include "linux/in6.h" |
3 | #include "linux/rwsem.h" | 3 | #include "linux/rwsem.h" |
4 | #include "asm/byteorder.h" | 4 | #include "asm/byteorder.h" |
5 | #include "asm/delay.h" | ||
5 | #include "asm/semaphore.h" | 6 | #include "asm/semaphore.h" |
6 | #include "asm/uaccess.h" | 7 | #include "asm/uaccess.h" |
7 | #include "asm/checksum.h" | 8 | #include "asm/checksum.h" |
@@ -13,5 +14,8 @@ EXPORT_SYMBOL(__down_failed_trylock); | |||
13 | EXPORT_SYMBOL(__up_wakeup); | 14 | EXPORT_SYMBOL(__up_wakeup); |
14 | 15 | ||
15 | /* Networking helper routines. */ | 16 | /* Networking helper routines. */ |
16 | EXPORT_SYMBOL(csum_partial_copy_from); | 17 | EXPORT_SYMBOL(csum_partial); |
17 | EXPORT_SYMBOL(csum_partial_copy_to); | 18 | |
19 | /* delay core functions */ | ||
20 | EXPORT_SYMBOL(__const_udelay); | ||
21 | EXPORT_SYMBOL(__udelay); | ||
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c index 31bcb2f997d4..dc755b0b9db8 100644 --- a/arch/um/sys-i386/ldt.c +++ b/arch/um/sys-i386/ldt.c | |||
@@ -25,7 +25,7 @@ int sys_modify_ldt_tt(int func, void __user *ptr, unsigned long bytecount) | |||
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #ifdef CONFIG_MODE_SKAS | 27 | #ifdef CONFIG_MODE_SKAS |
28 | extern int userspace_pid; | 28 | extern int userspace_pid[]; |
29 | 29 | ||
30 | #include "skas_ptrace.h" | 30 | #include "skas_ptrace.h" |
31 | 31 | ||
@@ -56,7 +56,8 @@ int sys_modify_ldt_skas(int func, void __user *ptr, unsigned long bytecount) | |||
56 | ldt = ((struct ptrace_ldt) { .func = func, | 56 | ldt = ((struct ptrace_ldt) { .func = func, |
57 | .ptr = buf, | 57 | .ptr = buf, |
58 | .bytecount = bytecount }); | 58 | .bytecount = bytecount }); |
59 | res = ptrace(PTRACE_LDT, userspace_pid, 0, (unsigned long) &ldt); | 59 | #warning Need to look up userspace_pid by cpu |
60 | res = ptrace(PTRACE_LDT, userspace_pid[0], 0, (unsigned long) &ldt); | ||
60 | if(res < 0) | 61 | if(res < 0) |
61 | goto out; | 62 | goto out; |
62 | 63 | ||
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c index e470d28cdf84..e839ce65ad28 100644 --- a/arch/um/sys-i386/ptrace.c +++ b/arch/um/sys-i386/ptrace.c | |||
@@ -73,6 +73,25 @@ int putreg(struct task_struct *child, int regno, unsigned long value) | |||
73 | return 0; | 73 | return 0; |
74 | } | 74 | } |
75 | 75 | ||
76 | int poke_user(struct task_struct *child, long addr, long data) | ||
77 | { | ||
78 | if ((addr & 3) || addr < 0) | ||
79 | return -EIO; | ||
80 | |||
81 | if (addr < MAX_REG_OFFSET) | ||
82 | return putreg(child, addr, data); | ||
83 | |||
84 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
85 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
86 | addr -= offsetof(struct user, u_debugreg[0]); | ||
87 | addr = addr >> 2; | ||
88 | if((addr == 4) || (addr == 5)) return -EIO; | ||
89 | child->thread.arch.debugregs[addr] = data; | ||
90 | return 0; | ||
91 | } | ||
92 | return -EIO; | ||
93 | } | ||
94 | |||
76 | unsigned long getreg(struct task_struct *child, int regno) | 95 | unsigned long getreg(struct task_struct *child, int regno) |
77 | { | 96 | { |
78 | unsigned long retval = ~0UL; | 97 | unsigned long retval = ~0UL; |
@@ -93,6 +112,27 @@ unsigned long getreg(struct task_struct *child, int regno) | |||
93 | return retval; | 112 | return retval; |
94 | } | 113 | } |
95 | 114 | ||
115 | int peek_user(struct task_struct *child, long addr, long data) | ||
116 | { | ||
117 | /* read the word at location addr in the USER area. */ | ||
118 | unsigned long tmp; | ||
119 | |||
120 | if ((addr & 3) || addr < 0) | ||
121 | return -EIO; | ||
122 | |||
123 | tmp = 0; /* Default return condition */ | ||
124 | if(addr < MAX_REG_OFFSET){ | ||
125 | tmp = getreg(child, addr); | ||
126 | } | ||
127 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
128 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
129 | addr -= offsetof(struct user, u_debugreg[0]); | ||
130 | addr = addr >> 2; | ||
131 | tmp = child->thread.arch.debugregs[addr]; | ||
132 | } | ||
133 | return put_user(tmp, (unsigned long *) data); | ||
134 | } | ||
135 | |||
96 | struct i387_fxsave_struct { | 136 | struct i387_fxsave_struct { |
97 | unsigned short cwd; | 137 | unsigned short cwd; |
98 | unsigned short swd; | 138 | unsigned short swd; |
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c index 76ba87254b25..03913ca5d256 100644 --- a/arch/um/sys-i386/signal.c +++ b/arch/um/sys-i386/signal.c | |||
@@ -47,9 +47,6 @@ static int copy_sc_from_user_skas(struct pt_regs *regs, | |||
47 | REGS_CS(regs->regs.skas.regs) = sc.cs; | 47 | REGS_CS(regs->regs.skas.regs) = sc.cs; |
48 | REGS_EFLAGS(regs->regs.skas.regs) = sc.eflags; | 48 | REGS_EFLAGS(regs->regs.skas.regs) = sc.eflags; |
49 | REGS_SS(regs->regs.skas.regs) = sc.ss; | 49 | REGS_SS(regs->regs.skas.regs) = sc.ss; |
50 | regs->regs.skas.fault_addr = sc.cr2; | ||
51 | regs->regs.skas.fault_type = FAULT_WRITE(sc.err); | ||
52 | regs->regs.skas.trap_type = sc.trapno; | ||
53 | 50 | ||
54 | err = restore_fp_registers(userspace_pid[0], fpregs); | 51 | err = restore_fp_registers(userspace_pid[0], fpregs); |
55 | if(err < 0){ | 52 | if(err < 0){ |
@@ -62,11 +59,11 @@ static int copy_sc_from_user_skas(struct pt_regs *regs, | |||
62 | } | 59 | } |
63 | 60 | ||
64 | int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, | 61 | int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, |
65 | struct pt_regs *regs, unsigned long fault_addr, | 62 | struct pt_regs *regs) |
66 | int fault_type) | ||
67 | { | 63 | { |
68 | struct sigcontext sc; | 64 | struct sigcontext sc; |
69 | unsigned long fpregs[HOST_FP_SIZE]; | 65 | unsigned long fpregs[HOST_FP_SIZE]; |
66 | struct faultinfo * fi = ¤t->thread.arch.faultinfo; | ||
70 | int err; | 67 | int err; |
71 | 68 | ||
72 | sc.gs = REGS_GS(regs->regs.skas.regs); | 69 | sc.gs = REGS_GS(regs->regs.skas.regs); |
@@ -86,9 +83,9 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, | |||
86 | sc.eflags = REGS_EFLAGS(regs->regs.skas.regs); | 83 | sc.eflags = REGS_EFLAGS(regs->regs.skas.regs); |
87 | sc.esp_at_signal = regs->regs.skas.regs[UESP]; | 84 | sc.esp_at_signal = regs->regs.skas.regs[UESP]; |
88 | sc.ss = regs->regs.skas.regs[SS]; | 85 | sc.ss = regs->regs.skas.regs[SS]; |
89 | sc.cr2 = fault_addr; | 86 | sc.cr2 = fi->cr2; |
90 | sc.err = TO_SC_ERR(fault_type); | 87 | sc.err = fi->error_code; |
91 | sc.trapno = regs->regs.skas.trap_type; | 88 | sc.trapno = fi->trap_no; |
92 | 89 | ||
93 | err = save_fp_registers(userspace_pid[0], fpregs); | 90 | err = save_fp_registers(userspace_pid[0], fpregs); |
94 | if(err < 0){ | 91 | if(err < 0){ |
@@ -167,9 +164,7 @@ static int copy_sc_to_user(struct sigcontext *to, struct _fpstate *fp, | |||
167 | { | 164 | { |
168 | return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), | 165 | return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), |
169 | sizeof(*fp)), | 166 | sizeof(*fp)), |
170 | copy_sc_to_user_skas(to, fp, from, | 167 | copy_sc_to_user_skas(to, fp, from))); |
171 | current->thread.cr2, | ||
172 | current->thread.err))); | ||
173 | } | 168 | } |
174 | 169 | ||
175 | static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp, | 170 | static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp, |
diff --git a/arch/um/sys-i386/sysrq.c b/arch/um/sys-i386/sysrq.c index 281fc7b8ca00..e3706d15c4f5 100644 --- a/arch/um/sys-i386/sysrq.c +++ b/arch/um/sys-i386/sysrq.c | |||
@@ -3,12 +3,15 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/config.h" | ||
6 | #include "linux/kernel.h" | 7 | #include "linux/kernel.h" |
7 | #include "linux/smp.h" | 8 | #include "linux/smp.h" |
8 | #include "linux/sched.h" | 9 | #include "linux/sched.h" |
10 | #include "linux/kallsyms.h" | ||
9 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
10 | #include "sysrq.h" | 12 | #include "sysrq.h" |
11 | 13 | ||
14 | /* This is declared by <linux/sched.h> */ | ||
12 | void show_regs(struct pt_regs *regs) | 15 | void show_regs(struct pt_regs *regs) |
13 | { | 16 | { |
14 | printk("\n"); | 17 | printk("\n"); |
@@ -31,5 +34,80 @@ void show_regs(struct pt_regs *regs) | |||
31 | 0xffff & PT_REGS_DS(regs), | 34 | 0xffff & PT_REGS_DS(regs), |
32 | 0xffff & PT_REGS_ES(regs)); | 35 | 0xffff & PT_REGS_ES(regs)); |
33 | 36 | ||
34 | show_trace((unsigned long *) ®s); | 37 | show_trace(NULL, (unsigned long *) ®s); |
35 | } | 38 | } |
39 | |||
40 | /* Copied from i386. */ | ||
41 | static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) | ||
42 | { | ||
43 | return p > (void *)tinfo && | ||
44 | p < (void *)tinfo + THREAD_SIZE - 3; | ||
45 | } | ||
46 | |||
47 | /* Adapted from i386 (we also print the address we read from). */ | ||
48 | static inline unsigned long print_context_stack(struct thread_info *tinfo, | ||
49 | unsigned long *stack, unsigned long ebp) | ||
50 | { | ||
51 | unsigned long addr; | ||
52 | |||
53 | #ifdef CONFIG_FRAME_POINTER | ||
54 | while (valid_stack_ptr(tinfo, (void *)ebp)) { | ||
55 | addr = *(unsigned long *)(ebp + 4); | ||
56 | printk("%08lx: [<%08lx>]", ebp + 4, addr); | ||
57 | print_symbol(" %s", addr); | ||
58 | printk("\n"); | ||
59 | ebp = *(unsigned long *)ebp; | ||
60 | } | ||
61 | #else | ||
62 | while (valid_stack_ptr(tinfo, stack)) { | ||
63 | addr = *stack; | ||
64 | if (__kernel_text_address(addr)) { | ||
65 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
66 | print_symbol(" %s", addr); | ||
67 | printk("\n"); | ||
68 | } | ||
69 | stack++; | ||
70 | } | ||
71 | #endif | ||
72 | return ebp; | ||
73 | } | ||
74 | |||
75 | void show_trace(struct task_struct* task, unsigned long * stack) | ||
76 | { | ||
77 | unsigned long ebp; | ||
78 | struct thread_info *context; | ||
79 | |||
80 | /* Turn this into BUG_ON if possible. */ | ||
81 | if (!stack) { | ||
82 | stack = (unsigned long*) &stack; | ||
83 | printk("show_trace: got NULL stack, implicit assumption task == current"); | ||
84 | WARN_ON(1); | ||
85 | } | ||
86 | |||
87 | if (!task) | ||
88 | task = current; | ||
89 | |||
90 | if (task != current) { | ||
91 | //ebp = (unsigned long) KSTK_EBP(task); | ||
92 | /* Which one? No actual difference - just coding style.*/ | ||
93 | ebp = (unsigned long) PT_REGS_EBP(&task->thread.regs); | ||
94 | } else { | ||
95 | asm ("movl %%ebp, %0" : "=r" (ebp) : ); | ||
96 | } | ||
97 | |||
98 | context = (struct thread_info *) | ||
99 | ((unsigned long)stack & (~(THREAD_SIZE - 1))); | ||
100 | print_context_stack(context, stack, ebp); | ||
101 | |||
102 | /*while (((long) stack & (THREAD_SIZE-1)) != 0) { | ||
103 | addr = *stack; | ||
104 | if (__kernel_text_address(addr)) { | ||
105 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
106 | print_symbol(" %s", addr); | ||
107 | printk("\n"); | ||
108 | } | ||
109 | stack++; | ||
110 | }*/ | ||
111 | printk("\n"); | ||
112 | } | ||
113 | |||
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c new file mode 100644 index 000000000000..3ceaabceb3d7 --- /dev/null +++ b/arch/um/sys-i386/user-offsets.c | |||
@@ -0,0 +1,69 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <signal.h> | ||
3 | #include <asm/ptrace.h> | ||
4 | #include <asm/user.h> | ||
5 | #include <linux/stddef.h> | ||
6 | |||
7 | #define DEFINE(sym, val) \ | ||
8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
9 | |||
10 | #define OFFSET(sym, str, mem) \ | ||
11 | DEFINE(sym, offsetof(struct str, mem)); | ||
12 | |||
13 | void foo(void) | ||
14 | { | ||
15 | OFFSET(SC_IP, sigcontext, eip); | ||
16 | OFFSET(SC_SP, sigcontext, esp); | ||
17 | OFFSET(SC_FS, sigcontext, fs); | ||
18 | OFFSET(SC_GS, sigcontext, gs); | ||
19 | OFFSET(SC_DS, sigcontext, ds); | ||
20 | OFFSET(SC_ES, sigcontext, es); | ||
21 | OFFSET(SC_SS, sigcontext, ss); | ||
22 | OFFSET(SC_CS, sigcontext, cs); | ||
23 | OFFSET(SC_EFLAGS, sigcontext, eflags); | ||
24 | OFFSET(SC_EAX, sigcontext, eax); | ||
25 | OFFSET(SC_EBX, sigcontext, ebx); | ||
26 | OFFSET(SC_ECX, sigcontext, ecx); | ||
27 | OFFSET(SC_EDX, sigcontext, edx); | ||
28 | OFFSET(SC_EDI, sigcontext, edi); | ||
29 | OFFSET(SC_ESI, sigcontext, esi); | ||
30 | OFFSET(SC_EBP, sigcontext, ebp); | ||
31 | OFFSET(SC_TRAPNO, sigcontext, trapno); | ||
32 | OFFSET(SC_ERR, sigcontext, err); | ||
33 | OFFSET(SC_CR2, sigcontext, cr2); | ||
34 | OFFSET(SC_FPSTATE, sigcontext, fpstate); | ||
35 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | ||
36 | OFFSET(SC_FP_CW, _fpstate, cw); | ||
37 | OFFSET(SC_FP_SW, _fpstate, sw); | ||
38 | OFFSET(SC_FP_TAG, _fpstate, tag); | ||
39 | OFFSET(SC_FP_IPOFF, _fpstate, ipoff); | ||
40 | OFFSET(SC_FP_CSSEL, _fpstate, cssel); | ||
41 | OFFSET(SC_FP_DATAOFF, _fpstate, dataoff); | ||
42 | OFFSET(SC_FP_DATASEL, _fpstate, datasel); | ||
43 | OFFSET(SC_FP_ST, _fpstate, _st); | ||
44 | OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env); | ||
45 | |||
46 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | ||
47 | DEFINE(HOST_FP_SIZE, | ||
48 | sizeof(struct user_i387_struct) / sizeof(unsigned long)); | ||
49 | DEFINE(HOST_XFP_SIZE, | ||
50 | sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); | ||
51 | |||
52 | DEFINE(HOST_IP, EIP); | ||
53 | DEFINE(HOST_SP, UESP); | ||
54 | DEFINE(HOST_EFLAGS, EFL); | ||
55 | DEFINE(HOST_EAX, EAX); | ||
56 | DEFINE(HOST_EBX, EBX); | ||
57 | DEFINE(HOST_ECX, ECX); | ||
58 | DEFINE(HOST_EDX, EDX); | ||
59 | DEFINE(HOST_ESI, ESI); | ||
60 | DEFINE(HOST_EDI, EDI); | ||
61 | DEFINE(HOST_EBP, EBP); | ||
62 | DEFINE(HOST_CS, CS); | ||
63 | DEFINE(HOST_SS, SS); | ||
64 | DEFINE(HOST_DS, DS); | ||
65 | DEFINE(HOST_FS, FS); | ||
66 | DEFINE(HOST_ES, ES); | ||
67 | DEFINE(HOST_GS, GS); | ||
68 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | ||
69 | } | ||
diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile index 34860f9ca7b0..bf61afd0b045 100644 --- a/arch/um/sys-i386/util/Makefile +++ b/arch/um/sys-i386/util/Makefile | |||
@@ -1,8 +1,5 @@ | |||
1 | |||
2 | hostprogs-y := mk_sc mk_thread | 1 | hostprogs-y := mk_sc mk_thread |
3 | always := $(hostprogs-y) | 2 | always := $(hostprogs-y) |
4 | 3 | ||
5 | mk_thread-objs := mk_thread_kern.o mk_thread_user.o | 4 | HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um |
6 | 5 | HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um | |
7 | HOSTCFLAGS_mk_thread_kern.o := $(CFLAGS) $(CPPFLAGS) | ||
8 | HOSTCFLAGS_mk_thread_user.o := $(USER_CFLAGS) | ||
diff --git a/arch/um/sys-i386/util/mk_sc.c b/arch/um/sys-i386/util/mk_sc.c index 85cbd30396f7..04c0d73433aa 100644 --- a/arch/um/sys-i386/util/mk_sc.c +++ b/arch/um/sys-i386/util/mk_sc.c | |||
@@ -1,52 +1,51 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <signal.h> | 2 | #include <user-offsets.h> |
3 | #include <linux/stddef.h> | ||
4 | 3 | ||
5 | #define SC_OFFSET(name, field) \ | 4 | #define SC_OFFSET(name, field) \ |
6 | printf("#define " name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ | 5 | printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ |
7 | offsetof(struct sigcontext, field)) | 6 | name) |
8 | 7 | ||
9 | #define SC_FP_OFFSET(name, field) \ | 8 | #define SC_FP_OFFSET(name, field) \ |
10 | printf("#define " name \ | 9 | printf("#define " #name \ |
11 | "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | 10 | "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ |
12 | offsetof(struct _fpstate, field)) | 11 | name) |
13 | 12 | ||
14 | #define SC_FP_OFFSET_PTR(name, field, type) \ | 13 | #define SC_FP_OFFSET_PTR(name, field, type) \ |
15 | printf("#define " name \ | 14 | printf("#define " #name \ |
16 | "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | 15 | "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ |
17 | offsetof(struct _fpstate, field)) | 16 | name) |
18 | 17 | ||
19 | int main(int argc, char **argv) | 18 | int main(int argc, char **argv) |
20 | { | 19 | { |
21 | SC_OFFSET("SC_IP", eip); | 20 | SC_OFFSET(SC_IP, eip); |
22 | SC_OFFSET("SC_SP", esp); | 21 | SC_OFFSET(SC_SP, esp); |
23 | SC_OFFSET("SC_FS", fs); | 22 | SC_OFFSET(SC_FS, fs); |
24 | SC_OFFSET("SC_GS", gs); | 23 | SC_OFFSET(SC_GS, gs); |
25 | SC_OFFSET("SC_DS", ds); | 24 | SC_OFFSET(SC_DS, ds); |
26 | SC_OFFSET("SC_ES", es); | 25 | SC_OFFSET(SC_ES, es); |
27 | SC_OFFSET("SC_SS", ss); | 26 | SC_OFFSET(SC_SS, ss); |
28 | SC_OFFSET("SC_CS", cs); | 27 | SC_OFFSET(SC_CS, cs); |
29 | SC_OFFSET("SC_EFLAGS", eflags); | 28 | SC_OFFSET(SC_EFLAGS, eflags); |
30 | SC_OFFSET("SC_EAX", eax); | 29 | SC_OFFSET(SC_EAX, eax); |
31 | SC_OFFSET("SC_EBX", ebx); | 30 | SC_OFFSET(SC_EBX, ebx); |
32 | SC_OFFSET("SC_ECX", ecx); | 31 | SC_OFFSET(SC_ECX, ecx); |
33 | SC_OFFSET("SC_EDX", edx); | 32 | SC_OFFSET(SC_EDX, edx); |
34 | SC_OFFSET("SC_EDI", edi); | 33 | SC_OFFSET(SC_EDI, edi); |
35 | SC_OFFSET("SC_ESI", esi); | 34 | SC_OFFSET(SC_ESI, esi); |
36 | SC_OFFSET("SC_EBP", ebp); | 35 | SC_OFFSET(SC_EBP, ebp); |
37 | SC_OFFSET("SC_TRAPNO", trapno); | 36 | SC_OFFSET(SC_TRAPNO, trapno); |
38 | SC_OFFSET("SC_ERR", err); | 37 | SC_OFFSET(SC_ERR, err); |
39 | SC_OFFSET("SC_CR2", cr2); | 38 | SC_OFFSET(SC_CR2, cr2); |
40 | SC_OFFSET("SC_FPSTATE", fpstate); | 39 | SC_OFFSET(SC_FPSTATE, fpstate); |
41 | SC_OFFSET("SC_SIGMASK", oldmask); | 40 | SC_OFFSET(SC_SIGMASK, oldmask); |
42 | SC_FP_OFFSET("SC_FP_CW", cw); | 41 | SC_FP_OFFSET(SC_FP_CW, cw); |
43 | SC_FP_OFFSET("SC_FP_SW", sw); | 42 | SC_FP_OFFSET(SC_FP_SW, sw); |
44 | SC_FP_OFFSET("SC_FP_TAG", tag); | 43 | SC_FP_OFFSET(SC_FP_TAG, tag); |
45 | SC_FP_OFFSET("SC_FP_IPOFF", ipoff); | 44 | SC_FP_OFFSET(SC_FP_IPOFF, ipoff); |
46 | SC_FP_OFFSET("SC_FP_CSSEL", cssel); | 45 | SC_FP_OFFSET(SC_FP_CSSEL, cssel); |
47 | SC_FP_OFFSET("SC_FP_DATAOFF", dataoff); | 46 | SC_FP_OFFSET(SC_FP_DATAOFF, dataoff); |
48 | SC_FP_OFFSET("SC_FP_DATASEL", datasel); | 47 | SC_FP_OFFSET(SC_FP_DATASEL, datasel); |
49 | SC_FP_OFFSET_PTR("SC_FP_ST", _st, "struct _fpstate"); | 48 | SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate"); |
50 | SC_FP_OFFSET_PTR("SC_FXSR_ENV", _fxsr_env, "void"); | 49 | SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void"); |
51 | return(0); | 50 | return(0); |
52 | } | 51 | } |
diff --git a/arch/um/sys-i386/util/mk_thread.c b/arch/um/sys-i386/util/mk_thread.c new file mode 100644 index 000000000000..7470d0dda67e --- /dev/null +++ b/arch/um/sys-i386/util/mk_thread.c | |||
@@ -0,0 +1,22 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | int main(int argc, char **argv) | ||
5 | { | ||
6 | printf("/*\n"); | ||
7 | printf(" * Generated by mk_thread\n"); | ||
8 | printf(" */\n"); | ||
9 | printf("\n"); | ||
10 | printf("#ifndef __UM_THREAD_H\n"); | ||
11 | printf("#define __UM_THREAD_H\n"); | ||
12 | printf("\n"); | ||
13 | printf("#define TASK_DEBUGREGS(task) ((unsigned long *) " | ||
14 | "&(((char *) (task))[%d]))\n", TASK_DEBUGREGS); | ||
15 | #ifdef TASK_EXTERN_PID | ||
16 | printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n", | ||
17 | TASK_EXTERN_PID); | ||
18 | #endif | ||
19 | printf("\n"); | ||
20 | printf("#endif\n"); | ||
21 | return(0); | ||
22 | } | ||
diff --git a/arch/um/sys-i386/util/mk_thread_kern.c b/arch/um/sys-i386/util/mk_thread_kern.c deleted file mode 100644 index 948b1ce85230..000000000000 --- a/arch/um/sys-i386/util/mk_thread_kern.c +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #include "linux/config.h" | ||
2 | #include "linux/stddef.h" | ||
3 | #include "linux/sched.h" | ||
4 | |||
5 | extern void print_head(void); | ||
6 | extern void print_constant_ptr(char *name, int value); | ||
7 | extern void print_constant(char *name, char *type, int value); | ||
8 | extern void print_tail(void); | ||
9 | |||
10 | #define THREAD_OFFSET(field) offsetof(struct task_struct, thread.field) | ||
11 | |||
12 | int main(int argc, char **argv) | ||
13 | { | ||
14 | print_head(); | ||
15 | print_constant_ptr("TASK_DEBUGREGS", THREAD_OFFSET(arch.debugregs)); | ||
16 | #ifdef CONFIG_MODE_TT | ||
17 | print_constant("TASK_EXTERN_PID", "int", THREAD_OFFSET(mode.tt.extern_pid)); | ||
18 | #endif | ||
19 | print_tail(); | ||
20 | return(0); | ||
21 | } | ||
22 | |||
diff --git a/arch/um/sys-i386/util/mk_thread_user.c b/arch/um/sys-i386/util/mk_thread_user.c deleted file mode 100644 index 2620cd6aa1f1..000000000000 --- a/arch/um/sys-i386/util/mk_thread_user.c +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | |||
3 | void print_head(void) | ||
4 | { | ||
5 | printf("/*\n"); | ||
6 | printf(" * Generated by mk_thread\n"); | ||
7 | printf(" */\n"); | ||
8 | printf("\n"); | ||
9 | printf("#ifndef __UM_THREAD_H\n"); | ||
10 | printf("#define __UM_THREAD_H\n"); | ||
11 | printf("\n"); | ||
12 | } | ||
13 | |||
14 | void print_constant_ptr(char *name, int value) | ||
15 | { | ||
16 | printf("#define %s(task) ((unsigned long *) " | ||
17 | "&(((char *) (task))[%d]))\n", name, value); | ||
18 | } | ||
19 | |||
20 | void print_constant(char *name, char *type, int value) | ||
21 | { | ||
22 | printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, | ||
23 | value); | ||
24 | } | ||
25 | |||
26 | void print_tail(void) | ||
27 | { | ||
28 | printf("\n"); | ||
29 | printf("#endif\n"); | ||
30 | } | ||
diff --git a/arch/um/sys-ppc/ptrace.c b/arch/um/sys-ppc/ptrace.c index a971366d3277..8e71b47f2b8e 100644 --- a/arch/um/sys-ppc/ptrace.c +++ b/arch/um/sys-ppc/ptrace.c | |||
@@ -8,6 +8,25 @@ int putreg(struct task_struct *child, unsigned long regno, | |||
8 | return 0; | 8 | return 0; |
9 | } | 9 | } |
10 | 10 | ||
11 | int poke_user(struct task_struct *child, long addr, long data) | ||
12 | { | ||
13 | if ((addr & 3) || addr < 0) | ||
14 | return -EIO; | ||
15 | |||
16 | if (addr < MAX_REG_OFFSET) | ||
17 | return putreg(child, addr, data); | ||
18 | |||
19 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
20 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
21 | addr -= offsetof(struct user, u_debugreg[0]); | ||
22 | addr = addr >> 2; | ||
23 | if((addr == 4) || (addr == 5)) return -EIO; | ||
24 | child->thread.arch.debugregs[addr] = data; | ||
25 | return 0; | ||
26 | } | ||
27 | return -EIO; | ||
28 | } | ||
29 | |||
11 | unsigned long getreg(struct task_struct *child, unsigned long regno) | 30 | unsigned long getreg(struct task_struct *child, unsigned long regno) |
12 | { | 31 | { |
13 | unsigned long retval = ~0UL; | 32 | unsigned long retval = ~0UL; |
@@ -16,6 +35,27 @@ unsigned long getreg(struct task_struct *child, unsigned long regno) | |||
16 | return retval; | 35 | return retval; |
17 | } | 36 | } |
18 | 37 | ||
38 | int peek_user(struct task_struct *child, long addr, long data) | ||
39 | { | ||
40 | /* read the word at location addr in the USER area. */ | ||
41 | unsigned long tmp; | ||
42 | |||
43 | if ((addr & 3) || addr < 0) | ||
44 | return -EIO; | ||
45 | |||
46 | tmp = 0; /* Default return condition */ | ||
47 | if(addr < MAX_REG_OFFSET){ | ||
48 | tmp = getreg(child, addr); | ||
49 | } | ||
50 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
51 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
52 | addr -= offsetof(struct user, u_debugreg[0]); | ||
53 | addr = addr >> 2; | ||
54 | tmp = child->thread.arch.debugregs[addr]; | ||
55 | } | ||
56 | return put_user(tmp, (unsigned long *) data); | ||
57 | } | ||
58 | |||
19 | /* | 59 | /* |
20 | * Overrides for Emacs so that we follow Linus's tabbing style. | 60 | * Overrides for Emacs so that we follow Linus's tabbing style. |
21 | * Emacs will notice this stuff at the end of the file and automatically | 61 | * Emacs will notice this stuff at the end of the file and automatically |
diff --git a/arch/um/sys-ppc/sysrq.c b/arch/um/sys-ppc/sysrq.c index 82d6e9335bb6..2f816f1a0ff4 100644 --- a/arch/um/sys-ppc/sysrq.c +++ b/arch/um/sys-ppc/sysrq.c | |||
@@ -27,17 +27,5 @@ void show_regs(struct pt_regs_subarch *regs) | |||
27 | 0xffff & regs->xds, 0xffff & regs->xes); | 27 | 0xffff & regs->xds, 0xffff & regs->xes); |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | show_trace(®s->gpr[1]); | 30 | show_trace(current, ®s->gpr[1]); |
31 | } | 31 | } |
32 | |||
33 | |||
34 | /* | ||
35 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
36 | * Emacs will notice this stuff at the end of the file and automatically | ||
37 | * adjust the settings for this buffer only. This must remain at the end | ||
38 | * of the file. | ||
39 | * --------------------------------------------------------------------------- | ||
40 | * Local variables: | ||
41 | * c-file-style: "linux" | ||
42 | * End: | ||
43 | */ | ||
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index d7ed2f7908df..608466ad6b22 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile | |||
@@ -4,24 +4,20 @@ | |||
4 | # Licensed under the GPL | 4 | # Licensed under the GPL |
5 | # | 5 | # |
6 | 6 | ||
7 | #XXX: why into lib-y? | ||
7 | 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 mem.o memcpy.o \ |
8 | ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o \ | 9 | ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o \ |
9 | syscalls.o sysrq.o thunk.o syscall_table.o | 10 | syscalls.o sysrq.o thunk.o syscall_table.o |
10 | 11 | ||
11 | USER_OBJS := ptrace_user.o sigcontext.o | 12 | obj-y := ksyms.o |
13 | obj-$(CONFIG_MODULES) += module.o um_module.o | ||
12 | 14 | ||
13 | include arch/um/scripts/Makefile.rules | 15 | USER_OBJS := ptrace_user.o sigcontext.o |
14 | 16 | ||
15 | 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 memcpy.S \ |
16 | semaphore.c thunk.S | 18 | semaphore.c thunk.S module.c |
17 | |||
18 | # this needs to be before the foreach, because clean-files does not accept | ||
19 | # complete paths like $(src)/$f. | ||
20 | clean-files := $(SYMLINKS) | ||
21 | 19 | ||
22 | targets += $(SYMLINKS) | 20 | include arch/um/scripts/Makefile.rules |
23 | |||
24 | SYMLINKS := $(foreach f,$(SYMLINKS),$(obj)/$f) | ||
25 | 21 | ||
26 | bitops.c-dir = lib | 22 | bitops.c-dir = lib |
27 | csum-copy.S-dir = lib | 23 | csum-copy.S-dir = lib |
@@ -30,8 +26,6 @@ csum-wrappers.c-dir = lib | |||
30 | memcpy.S-dir = lib | 26 | memcpy.S-dir = lib |
31 | semaphore.c-dir = kernel | 27 | semaphore.c-dir = kernel |
32 | thunk.S-dir = lib | 28 | thunk.S-dir = lib |
29 | module.c-dir = kernel | ||
33 | 30 | ||
34 | $(SYMLINKS): FORCE | 31 | subdir- := util |
35 | $(call if_changed,make_link) | ||
36 | |||
37 | CFLAGS_csum-partial.o := -Dcsum_partial=arch_csum_partial | ||
diff --git a/arch/um/sys-x86_64/delay.c b/arch/um/sys-x86_64/delay.c index f3b5187942b4..137f4446b439 100644 --- a/arch/um/sys-x86_64/delay.c +++ b/arch/um/sys-x86_64/delay.c | |||
@@ -5,22 +5,37 @@ | |||
5 | * Licensed under the GPL | 5 | * Licensed under the GPL |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "asm/processor.h" | 8 | #include <linux/module.h> |
9 | #include <linux/delay.h> | ||
10 | #include <asm/processor.h> | ||
11 | #include <asm/param.h> | ||
9 | 12 | ||
10 | void __delay(unsigned long loops) | 13 | void __delay(unsigned long loops) |
11 | { | 14 | { |
12 | unsigned long i; | 15 | unsigned long i; |
13 | 16 | ||
14 | for(i = 0; i < loops; i++) ; | 17 | for(i = 0; i < loops; i++) |
18 | cpu_relax(); | ||
15 | } | 19 | } |
16 | 20 | ||
17 | /* | 21 | void __udelay(unsigned long usecs) |
18 | * Overrides for Emacs so that we follow Linus's tabbing style. | 22 | { |
19 | * Emacs will notice this stuff at the end of the file and automatically | 23 | unsigned long i, n; |
20 | * adjust the settings for this buffer only. This must remain at the end | 24 | |
21 | * of the file. | 25 | n = (loops_per_jiffy * HZ * usecs) / MILLION; |
22 | * --------------------------------------------------------------------------- | 26 | for(i=0;i<n;i++) |
23 | * Local variables: | 27 | cpu_relax(); |
24 | * c-file-style: "linux" | 28 | } |
25 | * End: | 29 | |
26 | */ | 30 | EXPORT_SYMBOL(__udelay); |
31 | |||
32 | void __const_udelay(unsigned long usecs) | ||
33 | { | ||
34 | unsigned long i, n; | ||
35 | |||
36 | n = (loops_per_jiffy * HZ * usecs) / MILLION; | ||
37 | for(i=0;i<n;i++) | ||
38 | cpu_relax(); | ||
39 | } | ||
40 | |||
41 | EXPORT_SYMBOL(__const_udelay); | ||
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/sys-x86_64/kernel-offsets.c new file mode 100644 index 000000000000..220e875cbe29 --- /dev/null +++ b/arch/um/sys-x86_64/kernel-offsets.c | |||
@@ -0,0 +1,24 @@ | |||
1 | #include <linux/config.h> | ||
2 | #include <linux/stddef.h> | ||
3 | #include <linux/sched.h> | ||
4 | #include <linux/time.h> | ||
5 | #include <asm/page.h> | ||
6 | |||
7 | #define DEFINE(sym, val) \ | ||
8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
9 | |||
10 | #define DEFINE_STR1(x) #x | ||
11 | #define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : ) | ||
12 | |||
13 | #define BLANK() asm volatile("\n->" : : ) | ||
14 | |||
15 | #define OFFSET(sym, str, mem) \ | ||
16 | DEFINE(sym, offsetof(struct str, mem)); | ||
17 | |||
18 | void foo(void) | ||
19 | { | ||
20 | #ifdef CONFIG_MODE_TT | ||
21 | OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); | ||
22 | #endif | ||
23 | #include <common-offsets.h> | ||
24 | } | ||
diff --git a/arch/um/sys-x86_64/ksyms.c b/arch/um/sys-x86_64/ksyms.c new file mode 100644 index 000000000000..859273808203 --- /dev/null +++ b/arch/um/sys-x86_64/ksyms.c | |||
@@ -0,0 +1,19 @@ | |||
1 | #include "linux/module.h" | ||
2 | #include "linux/in6.h" | ||
3 | #include "linux/rwsem.h" | ||
4 | #include "asm/byteorder.h" | ||
5 | #include "asm/semaphore.h" | ||
6 | #include "asm/uaccess.h" | ||
7 | #include "asm/checksum.h" | ||
8 | #include "asm/errno.h" | ||
9 | |||
10 | EXPORT_SYMBOL(__down_failed); | ||
11 | EXPORT_SYMBOL(__down_failed_interruptible); | ||
12 | EXPORT_SYMBOL(__down_failed_trylock); | ||
13 | EXPORT_SYMBOL(__up_wakeup); | ||
14 | |||
15 | /*XXX: we need them because they would be exported by x86_64 */ | ||
16 | EXPORT_SYMBOL(__memcpy); | ||
17 | |||
18 | /* Networking helper routines. */ | ||
19 | EXPORT_SYMBOL(ip_compute_csum); | ||
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c index 8c146b2a1e00..74eee5c7c6dd 100644 --- a/arch/um/sys-x86_64/ptrace.c +++ b/arch/um/sys-x86_64/ptrace.c | |||
@@ -5,10 +5,11 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #define __FRAME_OFFSETS | 7 | #define __FRAME_OFFSETS |
8 | #include "asm/ptrace.h" | 8 | #include <asm/ptrace.h> |
9 | #include "linux/sched.h" | 9 | #include <linux/sched.h> |
10 | #include "linux/errno.h" | 10 | #include <linux/errno.h> |
11 | #include "asm/elf.h" | 11 | #include <asm/uaccess.h> |
12 | #include <asm/elf.h> | ||
12 | 13 | ||
13 | /* XXX x86_64 */ | 14 | /* XXX x86_64 */ |
14 | unsigned long not_ss; | 15 | unsigned long not_ss; |
@@ -62,6 +63,27 @@ int putreg(struct task_struct *child, int regno, unsigned long value) | |||
62 | return 0; | 63 | return 0; |
63 | } | 64 | } |
64 | 65 | ||
66 | int poke_user(struct task_struct *child, long addr, long data) | ||
67 | { | ||
68 | if ((addr & 3) || addr < 0) | ||
69 | return -EIO; | ||
70 | |||
71 | if (addr < MAX_REG_OFFSET) | ||
72 | return putreg(child, addr, data); | ||
73 | |||
74 | #if 0 /* Need x86_64 debugregs handling */ | ||
75 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
76 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
77 | addr -= offsetof(struct user, u_debugreg[0]); | ||
78 | addr = addr >> 2; | ||
79 | if((addr == 4) || (addr == 5)) return -EIO; | ||
80 | child->thread.arch.debugregs[addr] = data; | ||
81 | return 0; | ||
82 | } | ||
83 | #endif | ||
84 | return -EIO; | ||
85 | } | ||
86 | |||
65 | unsigned long getreg(struct task_struct *child, int regno) | 87 | unsigned long getreg(struct task_struct *child, int regno) |
66 | { | 88 | { |
67 | unsigned long retval = ~0UL; | 89 | unsigned long retval = ~0UL; |
@@ -84,6 +106,29 @@ unsigned long getreg(struct task_struct *child, int regno) | |||
84 | return retval; | 106 | return retval; |
85 | } | 107 | } |
86 | 108 | ||
109 | int peek_user(struct task_struct *child, long addr, long data) | ||
110 | { | ||
111 | /* read the word at location addr in the USER area. */ | ||
112 | unsigned long tmp; | ||
113 | |||
114 | if ((addr & 3) || addr < 0) | ||
115 | return -EIO; | ||
116 | |||
117 | tmp = 0; /* Default return condition */ | ||
118 | if(addr < MAX_REG_OFFSET){ | ||
119 | tmp = getreg(child, addr); | ||
120 | } | ||
121 | #if 0 /* Need x86_64 debugregs handling */ | ||
122 | else if((addr >= offsetof(struct user, u_debugreg[0])) && | ||
123 | (addr <= offsetof(struct user, u_debugreg[7]))){ | ||
124 | addr -= offsetof(struct user, u_debugreg[0]); | ||
125 | addr = addr >> 2; | ||
126 | tmp = child->thread.arch.debugregs[addr]; | ||
127 | } | ||
128 | #endif | ||
129 | return put_user(tmp, (unsigned long *) data); | ||
130 | } | ||
131 | |||
87 | void arch_switch(void) | 132 | void arch_switch(void) |
88 | { | 133 | { |
89 | /* XXX | 134 | /* XXX |
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c index 5bc5a0d796e5..73a7926f7370 100644 --- a/arch/um/sys-x86_64/signal.c +++ b/arch/um/sys-x86_64/signal.c | |||
@@ -57,7 +57,7 @@ static int copy_sc_from_user_skas(struct pt_regs *regs, | |||
57 | int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, | 57 | int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, |
58 | struct pt_regs *regs, unsigned long mask) | 58 | struct pt_regs *regs, unsigned long mask) |
59 | { | 59 | { |
60 | unsigned long eflags; | 60 | struct faultinfo * fi = ¤t->thread.arch.faultinfo; |
61 | int err = 0; | 61 | int err = 0; |
62 | 62 | ||
63 | err |= __put_user(0, &to->gs); | 63 | err |= __put_user(0, &to->gs); |
@@ -84,14 +84,16 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, | |||
84 | err |= PUTREG(regs, R14, to, r14); | 84 | err |= PUTREG(regs, R14, to, r14); |
85 | err |= PUTREG(regs, R15, to, r15); | 85 | err |= PUTREG(regs, R15, to, r15); |
86 | err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */ | 86 | err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */ |
87 | err |= __put_user(current->thread.err, &to->err); | 87 | |
88 | err |= __put_user(current->thread.trap_no, &to->trapno); | 88 | err |= __put_user(fi->cr2, &to->cr2); |
89 | err |= __put_user(fi->error_code, &to->err); | ||
90 | err |= __put_user(fi->trap_no, &to->trapno); | ||
91 | |||
89 | err |= PUTREG(regs, RIP, to, rip); | 92 | err |= PUTREG(regs, RIP, to, rip); |
90 | err |= PUTREG(regs, EFLAGS, to, eflags); | 93 | err |= PUTREG(regs, EFLAGS, to, eflags); |
91 | #undef PUTREG | 94 | #undef PUTREG |
92 | 95 | ||
93 | err |= __put_user(mask, &to->oldmask); | 96 | err |= __put_user(mask, &to->oldmask); |
94 | err |= __put_user(current->thread.cr2, &to->cr2); | ||
95 | 97 | ||
96 | return(err); | 98 | return(err); |
97 | } | 99 | } |
@@ -166,7 +168,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
166 | 168 | ||
167 | frame = (struct rt_sigframe __user *) | 169 | frame = (struct rt_sigframe __user *) |
168 | round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8; | 170 | round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8; |
169 | frame -= 128; | 171 | ((unsigned char *) frame) -= 128; |
170 | 172 | ||
171 | if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) | 173 | if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) |
172 | goto out; | 174 | goto out; |
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c index ab4b0abf8af3..6f44f40204ed 100644 --- a/arch/um/sys-x86_64/syscalls.c +++ b/arch/um/sys-x86_64/syscalls.c | |||
@@ -7,12 +7,15 @@ | |||
7 | #include "linux/linkage.h" | 7 | #include "linux/linkage.h" |
8 | #include "linux/slab.h" | 8 | #include "linux/slab.h" |
9 | #include "linux/shm.h" | 9 | #include "linux/shm.h" |
10 | #include "linux/utsname.h" | ||
11 | #include "linux/personality.h" | ||
10 | #include "asm/uaccess.h" | 12 | #include "asm/uaccess.h" |
11 | #define __FRAME_OFFSETS | 13 | #define __FRAME_OFFSETS |
12 | #include "asm/ptrace.h" | 14 | #include "asm/ptrace.h" |
13 | #include "asm/unistd.h" | 15 | #include "asm/unistd.h" |
14 | #include "asm/prctl.h" /* XXX This should get the constants from libc */ | 16 | #include "asm/prctl.h" /* XXX This should get the constants from libc */ |
15 | #include "choose-mode.h" | 17 | #include "choose-mode.h" |
18 | #include "kern.h" | ||
16 | 19 | ||
17 | asmlinkage long sys_uname64(struct new_utsname __user * name) | 20 | asmlinkage long sys_uname64(struct new_utsname __user * name) |
18 | { | 21 | { |
@@ -42,6 +45,8 @@ long sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount) | |||
42 | #ifdef CONFIG_MODE_SKAS | 45 | #ifdef CONFIG_MODE_SKAS |
43 | extern int userspace_pid[]; | 46 | extern int userspace_pid[]; |
44 | 47 | ||
48 | #include "skas_ptrace.h" | ||
49 | |||
45 | long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount) | 50 | long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount) |
46 | { | 51 | { |
47 | struct ptrace_ldt ldt; | 52 | struct ptrace_ldt ldt; |
@@ -128,23 +133,27 @@ static long arch_prctl_tt(int code, unsigned long addr) | |||
128 | 133 | ||
129 | #ifdef CONFIG_MODE_SKAS | 134 | #ifdef CONFIG_MODE_SKAS |
130 | 135 | ||
136 | /* XXX: Must also call arch_prctl in the host, beside saving the segment bases! */ | ||
131 | static long arch_prctl_skas(int code, unsigned long addr) | 137 | static long arch_prctl_skas(int code, unsigned long addr) |
132 | { | 138 | { |
133 | long ret = 0; | 139 | long ret = 0; |
134 | 140 | ||
135 | switch(code){ | 141 | switch(code){ |
136 | case ARCH_SET_GS: | ||
137 | current->thread.regs.regs.skas.regs[GS_BASE / sizeof(unsigned long)] = addr; | ||
138 | break; | ||
139 | case ARCH_SET_FS: | 142 | case ARCH_SET_FS: |
140 | current->thread.regs.regs.skas.regs[FS_BASE / sizeof(unsigned long)] = addr; | 143 | current->thread.regs.regs.skas.regs[FS_BASE / sizeof(unsigned long)] = addr; |
141 | break; | 144 | break; |
145 | case ARCH_SET_GS: | ||
146 | current->thread.regs.regs.skas.regs[GS_BASE / sizeof(unsigned long)] = addr; | ||
147 | break; | ||
142 | case ARCH_GET_FS: | 148 | case ARCH_GET_FS: |
143 | ret = put_user(current->thread.regs.regs.skas.regs[GS / sizeof(unsigned long)], &addr); | 149 | ret = put_user(current->thread.regs.regs.skas. |
150 | regs[FS_BASE / sizeof(unsigned long)], | ||
151 | (unsigned long __user *)addr); | ||
144 | break; | 152 | break; |
145 | case ARCH_GET_GS: | 153 | case ARCH_GET_GS: |
146 | ret = put_user(current->thread.regs.regs.skas.regs[FS / sizeof(unsigned \ | 154 | ret = put_user(current->thread.regs.regs.skas. |
147 | long)], &addr); | 155 | regs[GS_BASE / sizeof(unsigned long)], |
156 | (unsigned long __user *)addr); | ||
148 | break; | 157 | break; |
149 | default: | 158 | default: |
150 | ret = -EINVAL; | 159 | ret = -EINVAL; |
diff --git a/arch/um/sys-x86_64/sysrq.c b/arch/um/sys-x86_64/sysrq.c index ddf74691a610..d0a25af19a5b 100644 --- a/arch/um/sys-x86_64/sysrq.c +++ b/arch/um/sys-x86_64/sysrq.c | |||
@@ -36,14 +36,5 @@ void __show_regs(struct pt_regs * regs) | |||
36 | void show_regs(struct pt_regs *regs) | 36 | void show_regs(struct pt_regs *regs) |
37 | { | 37 | { |
38 | __show_regs(regs); | 38 | __show_regs(regs); |
39 | show_trace((unsigned long *) ®s); | 39 | show_trace(current, (unsigned long *) ®s); |
40 | } | 40 | } |
41 | |||
42 | /* Emacs will notice this stuff at the end of the file and automatically | ||
43 | * adjust the settings for this buffer only. This must remain at the end | ||
44 | * of the file. | ||
45 | * --------------------------------------------------------------------------- | ||
46 | * Local variables: | ||
47 | * c-file-style: "linux" | ||
48 | * End: | ||
49 | */ | ||
diff --git a/arch/um/sys-x86_64/um_module.c b/arch/um/sys-x86_64/um_module.c new file mode 100644 index 000000000000..8b8eff1bd977 --- /dev/null +++ b/arch/um/sys-x86_64/um_module.c | |||
@@ -0,0 +1,19 @@ | |||
1 | #include <linux/vmalloc.h> | ||
2 | #include <linux/moduleloader.h> | ||
3 | |||
4 | /*Copied from i386 arch/i386/kernel/module.c */ | ||
5 | void *module_alloc(unsigned long size) | ||
6 | { | ||
7 | if (size == 0) | ||
8 | return NULL; | ||
9 | return vmalloc_exec(size); | ||
10 | } | ||
11 | |||
12 | /* Free memory returned from module_alloc */ | ||
13 | void module_free(struct module *mod, void *module_region) | ||
14 | { | ||
15 | vfree(module_region); | ||
16 | /* FIXME: If module_region == mod->init_region, trim exception | ||
17 | table entries. */ | ||
18 | } | ||
19 | |||
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c new file mode 100644 index 000000000000..513d17ceafd4 --- /dev/null +++ b/arch/um/sys-x86_64/user-offsets.c | |||
@@ -0,0 +1,86 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stddef.h> | ||
3 | #include <signal.h> | ||
4 | #define __FRAME_OFFSETS | ||
5 | #include <asm/ptrace.h> | ||
6 | #include <asm/types.h> | ||
7 | /* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I | ||
8 | * refuse to include here, even though they're used throughout the headers. | ||
9 | * These are used in asm/user.h, and that include can't be avoided because of | ||
10 | * the sizeof(struct user_regs_struct) below. | ||
11 | */ | ||
12 | typedef __u64 u64; | ||
13 | typedef __u32 u32; | ||
14 | #include <asm/user.h> | ||
15 | |||
16 | #define DEFINE(sym, val) \ | ||
17 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
18 | |||
19 | #define OFFSET(sym, str, mem) \ | ||
20 | DEFINE(sym, offsetof(struct str, mem)); | ||
21 | |||
22 | void foo(void) | ||
23 | { | ||
24 | OFFSET(SC_RBX, sigcontext, rbx); | ||
25 | OFFSET(SC_RCX, sigcontext, rcx); | ||
26 | OFFSET(SC_RDX, sigcontext, rdx); | ||
27 | OFFSET(SC_RSI, sigcontext, rsi); | ||
28 | OFFSET(SC_RDI, sigcontext, rdi); | ||
29 | OFFSET(SC_RBP, sigcontext, rbp); | ||
30 | OFFSET(SC_RAX, sigcontext, rax); | ||
31 | OFFSET(SC_R8, sigcontext, r8); | ||
32 | OFFSET(SC_R9, sigcontext, r9); | ||
33 | OFFSET(SC_R10, sigcontext, r10); | ||
34 | OFFSET(SC_R11, sigcontext, r11); | ||
35 | OFFSET(SC_R12, sigcontext, r12); | ||
36 | OFFSET(SC_R13, sigcontext, r13); | ||
37 | OFFSET(SC_R14, sigcontext, r14); | ||
38 | OFFSET(SC_R15, sigcontext, r15); | ||
39 | OFFSET(SC_IP, sigcontext, rip); | ||
40 | OFFSET(SC_SP, sigcontext, rsp); | ||
41 | OFFSET(SC_CR2, sigcontext, cr2); | ||
42 | OFFSET(SC_ERR, sigcontext, err); | ||
43 | OFFSET(SC_TRAPNO, sigcontext, trapno); | ||
44 | OFFSET(SC_CS, sigcontext, cs); | ||
45 | OFFSET(SC_FS, sigcontext, fs); | ||
46 | OFFSET(SC_GS, sigcontext, gs); | ||
47 | OFFSET(SC_EFLAGS, sigcontext, eflags); | ||
48 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | ||
49 | #if 0 | ||
50 | OFFSET(SC_ORIG_RAX, sigcontext, orig_rax); | ||
51 | OFFSET(SC_DS, sigcontext, ds); | ||
52 | OFFSET(SC_ES, sigcontext, es); | ||
53 | OFFSET(SC_SS, sigcontext, ss); | ||
54 | #endif | ||
55 | |||
56 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | ||
57 | DEFINE(HOST_RBX, RBX); | ||
58 | DEFINE(HOST_RCX, RCX); | ||
59 | DEFINE(HOST_RDI, RDI); | ||
60 | DEFINE(HOST_RSI, RSI); | ||
61 | DEFINE(HOST_RDX, RDX); | ||
62 | DEFINE(HOST_RBP, RBP); | ||
63 | DEFINE(HOST_RAX, RAX); | ||
64 | DEFINE(HOST_R8, R8); | ||
65 | DEFINE(HOST_R9, R9); | ||
66 | DEFINE(HOST_R10, R10); | ||
67 | DEFINE(HOST_R11, R11); | ||
68 | DEFINE(HOST_R12, R12); | ||
69 | DEFINE(HOST_R13, R13); | ||
70 | DEFINE(HOST_R14, R14); | ||
71 | DEFINE(HOST_R15, R15); | ||
72 | DEFINE(HOST_ORIG_RAX, ORIG_RAX); | ||
73 | DEFINE(HOST_CS, CS); | ||
74 | DEFINE(HOST_SS, SS); | ||
75 | DEFINE(HOST_EFLAGS, EFLAGS); | ||
76 | #if 0 | ||
77 | DEFINE(HOST_FS, FS); | ||
78 | DEFINE(HOST_GS, GS); | ||
79 | DEFINE(HOST_DS, DS); | ||
80 | DEFINE(HOST_ES, ES); | ||
81 | #endif | ||
82 | |||
83 | DEFINE(HOST_IP, RIP); | ||
84 | DEFINE(HOST_SP, RSP); | ||
85 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | ||
86 | } | ||
diff --git a/arch/um/sys-x86_64/util/Makefile b/arch/um/sys-x86_64/util/Makefile index 002607980864..75b052cfc206 100644 --- a/arch/um/sys-x86_64/util/Makefile +++ b/arch/um/sys-x86_64/util/Makefile | |||
@@ -4,7 +4,5 @@ | |||
4 | hostprogs-y := mk_sc mk_thread | 4 | hostprogs-y := mk_sc mk_thread |
5 | always := $(hostprogs-y) | 5 | always := $(hostprogs-y) |
6 | 6 | ||
7 | mk_thread-objs := mk_thread_kern.o mk_thread_user.o | 7 | HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um |
8 | 8 | HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um | |
9 | HOSTCFLAGS_mk_thread_kern.o := $(CFLAGS) $(CPPFLAGS) | ||
10 | HOSTCFLAGS_mk_thread_user.o := $(USER_CFLAGS) | ||
diff --git a/arch/um/sys-x86_64/util/mk_sc.c b/arch/um/sys-x86_64/util/mk_sc.c index c236e213918d..7619bc377c1f 100644 --- a/arch/um/sys-x86_64/util/mk_sc.c +++ b/arch/um/sys-x86_64/util/mk_sc.c | |||
@@ -3,56 +3,45 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <signal.h> | 6 | #include <user-offsets.h> |
7 | #include <linux/stddef.h> | ||
8 | 7 | ||
9 | #define SC_OFFSET(name, field) \ | 8 | #define SC_OFFSET(name) \ |
10 | printf("#define " name \ | 9 | printf("#define " #name \ |
11 | "(sc) *((unsigned long *) &(((char *) (sc))[%ld]))\n",\ | 10 | "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ |
12 | offsetof(struct sigcontext, field)) | 11 | name) |
13 | |||
14 | #define SC_FP_OFFSET(name, field) \ | ||
15 | printf("#define " name \ | ||
16 | "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%ld]))\n",\ | ||
17 | offsetof(struct _fpstate, field)) | ||
18 | |||
19 | #define SC_FP_OFFSET_PTR(name, field, type) \ | ||
20 | printf("#define " name \ | ||
21 | "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | ||
22 | offsetof(struct _fpstate, field)) | ||
23 | 12 | ||
24 | int main(int argc, char **argv) | 13 | int main(int argc, char **argv) |
25 | { | 14 | { |
26 | SC_OFFSET("SC_RBX", rbx); | 15 | SC_OFFSET(SC_RBX); |
27 | SC_OFFSET("SC_RCX", rcx); | 16 | SC_OFFSET(SC_RCX); |
28 | SC_OFFSET("SC_RDX", rdx); | 17 | SC_OFFSET(SC_RDX); |
29 | SC_OFFSET("SC_RSI", rsi); | 18 | SC_OFFSET(SC_RSI); |
30 | SC_OFFSET("SC_RDI", rdi); | 19 | SC_OFFSET(SC_RDI); |
31 | SC_OFFSET("SC_RBP", rbp); | 20 | SC_OFFSET(SC_RBP); |
32 | SC_OFFSET("SC_RAX", rax); | 21 | SC_OFFSET(SC_RAX); |
33 | SC_OFFSET("SC_R8", r8); | 22 | SC_OFFSET(SC_R8); |
34 | SC_OFFSET("SC_R9", r9); | 23 | SC_OFFSET(SC_R9); |
35 | SC_OFFSET("SC_R10", r10); | 24 | SC_OFFSET(SC_R10); |
36 | SC_OFFSET("SC_R11", r11); | 25 | SC_OFFSET(SC_R11); |
37 | SC_OFFSET("SC_R12", r12); | 26 | SC_OFFSET(SC_R12); |
38 | SC_OFFSET("SC_R13", r13); | 27 | SC_OFFSET(SC_R13); |
39 | SC_OFFSET("SC_R14", r14); | 28 | SC_OFFSET(SC_R14); |
40 | SC_OFFSET("SC_R15", r15); | 29 | SC_OFFSET(SC_R15); |
41 | SC_OFFSET("SC_IP", rip); | 30 | SC_OFFSET(SC_IP); |
42 | SC_OFFSET("SC_SP", rsp); | 31 | SC_OFFSET(SC_SP); |
43 | SC_OFFSET("SC_CR2", cr2); | 32 | SC_OFFSET(SC_CR2); |
44 | SC_OFFSET("SC_ERR", err); | 33 | SC_OFFSET(SC_ERR); |
45 | SC_OFFSET("SC_TRAPNO", trapno); | 34 | SC_OFFSET(SC_TRAPNO); |
46 | SC_OFFSET("SC_CS", cs); | 35 | SC_OFFSET(SC_CS); |
47 | SC_OFFSET("SC_FS", fs); | 36 | SC_OFFSET(SC_FS); |
48 | SC_OFFSET("SC_GS", gs); | 37 | SC_OFFSET(SC_GS); |
49 | SC_OFFSET("SC_EFLAGS", eflags); | 38 | SC_OFFSET(SC_EFLAGS); |
50 | SC_OFFSET("SC_SIGMASK", oldmask); | 39 | SC_OFFSET(SC_SIGMASK); |
51 | #if 0 | 40 | #if 0 |
52 | SC_OFFSET("SC_ORIG_RAX", orig_rax); | 41 | SC_OFFSET(SC_ORIG_RAX); |
53 | SC_OFFSET("SC_DS", ds); | 42 | SC_OFFSET(SC_DS); |
54 | SC_OFFSET("SC_ES", es); | 43 | SC_OFFSET(SC_ES); |
55 | SC_OFFSET("SC_SS", ss); | 44 | SC_OFFSET(SC_SS); |
56 | #endif | 45 | #endif |
57 | return(0); | 46 | return(0); |
58 | } | 47 | } |
diff --git a/arch/um/sys-x86_64/util/mk_thread.c b/arch/um/sys-x86_64/util/mk_thread.c new file mode 100644 index 000000000000..15517396e9cf --- /dev/null +++ b/arch/um/sys-x86_64/util/mk_thread.c | |||
@@ -0,0 +1,20 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | int main(int argc, char **argv) | ||
5 | { | ||
6 | printf("/*\n"); | ||
7 | printf(" * Generated by mk_thread\n"); | ||
8 | printf(" */\n"); | ||
9 | printf("\n"); | ||
10 | printf("#ifndef __UM_THREAD_H\n"); | ||
11 | printf("#define __UM_THREAD_H\n"); | ||
12 | printf("\n"); | ||
13 | #ifdef TASK_EXTERN_PID | ||
14 | printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n", | ||
15 | TASK_EXTERN_PID); | ||
16 | #endif | ||
17 | printf("\n"); | ||
18 | printf("#endif\n"); | ||
19 | return(0); | ||
20 | } | ||
diff --git a/arch/um/sys-x86_64/util/mk_thread_kern.c b/arch/um/sys-x86_64/util/mk_thread_kern.c deleted file mode 100644 index a281673f02b2..000000000000 --- a/arch/um/sys-x86_64/util/mk_thread_kern.c +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | #include "linux/config.h" | ||
2 | #include "linux/stddef.h" | ||
3 | #include "linux/sched.h" | ||
4 | |||
5 | extern void print_head(void); | ||
6 | extern void print_constant_ptr(char *name, int value); | ||
7 | extern void print_constant(char *name, char *type, int value); | ||
8 | extern void print_tail(void); | ||
9 | |||
10 | #define THREAD_OFFSET(field) offsetof(struct task_struct, thread.field) | ||
11 | |||
12 | int main(int argc, char **argv) | ||
13 | { | ||
14 | print_head(); | ||
15 | #ifdef CONFIG_MODE_TT | ||
16 | print_constant("TASK_EXTERN_PID", "int", THREAD_OFFSET(mode.tt.extern_pid)); | ||
17 | #endif | ||
18 | print_tail(); | ||
19 | return(0); | ||
20 | } | ||
21 | |||
diff --git a/arch/um/sys-x86_64/util/mk_thread_user.c b/arch/um/sys-x86_64/util/mk_thread_user.c deleted file mode 100644 index 7989725568b8..000000000000 --- a/arch/um/sys-x86_64/util/mk_thread_user.c +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | |||
3 | void print_head(void) | ||
4 | { | ||
5 | printf("/*\n"); | ||
6 | printf(" * Generated by mk_thread\n"); | ||
7 | printf(" */\n"); | ||
8 | printf("\n"); | ||
9 | printf("#ifndef __UM_THREAD_H\n"); | ||
10 | printf("#define __UM_THREAD_H\n"); | ||
11 | printf("\n"); | ||
12 | } | ||
13 | |||
14 | void print_constant_ptr(char *name, int value) | ||
15 | { | ||
16 | printf("#define %s(task) ((unsigned long *) " | ||
17 | "&(((char *) (task))[%d]))\n", name, value); | ||
18 | } | ||
19 | |||
20 | void print_constant(char *name, char *type, int value) | ||
21 | { | ||
22 | printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, | ||
23 | value); | ||
24 | } | ||
25 | |||
26 | void print_tail(void) | ||
27 | { | ||
28 | printf("\n"); | ||
29 | printf("#endif\n"); | ||
30 | } | ||
diff --git a/arch/um/util/Makefile b/arch/um/util/Makefile index e2ab71209f3f..4c7551c28033 100644 --- a/arch/um/util/Makefile +++ b/arch/um/util/Makefile | |||
@@ -1,8 +1,5 @@ | |||
1 | hostprogs-y := mk_task mk_constants | 1 | hostprogs-y := mk_task mk_constants |
2 | always := $(hostprogs-y) | 2 | always := $(hostprogs-y) |
3 | 3 | ||
4 | mk_task-objs := mk_task_user.o mk_task_kern.o | 4 | HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um |
5 | mk_constants-objs := mk_constants_user.o mk_constants_kern.o | 5 | HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um |
6 | |||
7 | HOSTCFLAGS_mk_task_kern.o := $(CFLAGS) $(CPPFLAGS) | ||
8 | HOSTCFLAGS_mk_constants_kern.o := $(CFLAGS) $(CPPFLAGS) | ||
diff --git a/arch/um/util/mk_constants.c b/arch/um/util/mk_constants.c new file mode 100644 index 000000000000..ab217becc36a --- /dev/null +++ b/arch/um/util/mk_constants.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | #define SHOW_INT(sym) printf("#define %s %d\n", #sym, sym) | ||
5 | #define SHOW_STR(sym) printf("#define %s %s\n", #sym, sym) | ||
6 | |||
7 | int main(int argc, char **argv) | ||
8 | { | ||
9 | printf("/*\n"); | ||
10 | printf(" * Generated by mk_constants\n"); | ||
11 | printf(" */\n"); | ||
12 | printf("\n"); | ||
13 | printf("#ifndef __UM_CONSTANTS_H\n"); | ||
14 | printf("#define __UM_CONSTANTS_H\n"); | ||
15 | printf("\n"); | ||
16 | |||
17 | SHOW_INT(UM_KERN_PAGE_SIZE); | ||
18 | |||
19 | SHOW_STR(UM_KERN_EMERG); | ||
20 | SHOW_STR(UM_KERN_ALERT); | ||
21 | SHOW_STR(UM_KERN_CRIT); | ||
22 | SHOW_STR(UM_KERN_ERR); | ||
23 | SHOW_STR(UM_KERN_WARNING); | ||
24 | SHOW_STR(UM_KERN_NOTICE); | ||
25 | SHOW_STR(UM_KERN_INFO); | ||
26 | SHOW_STR(UM_KERN_DEBUG); | ||
27 | |||
28 | SHOW_INT(UM_NSEC_PER_SEC); | ||
29 | printf("\n"); | ||
30 | printf("#endif\n"); | ||
31 | return(0); | ||
32 | } | ||
diff --git a/arch/um/util/mk_constants_kern.c b/arch/um/util/mk_constants_kern.c deleted file mode 100644 index cdcb1232a1ea..000000000000 --- a/arch/um/util/mk_constants_kern.c +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #include "linux/kernel.h" | ||
2 | #include "linux/stringify.h" | ||
3 | #include "linux/time.h" | ||
4 | #include "asm/page.h" | ||
5 | |||
6 | extern void print_head(void); | ||
7 | extern void print_constant_str(char *name, char *value); | ||
8 | extern void print_constant_int(char *name, int value); | ||
9 | extern void print_tail(void); | ||
10 | |||
11 | int main(int argc, char **argv) | ||
12 | { | ||
13 | print_head(); | ||
14 | print_constant_int("UM_KERN_PAGE_SIZE", PAGE_SIZE); | ||
15 | |||
16 | print_constant_str("UM_KERN_EMERG", KERN_EMERG); | ||
17 | print_constant_str("UM_KERN_ALERT", KERN_ALERT); | ||
18 | print_constant_str("UM_KERN_CRIT", KERN_CRIT); | ||
19 | print_constant_str("UM_KERN_ERR", KERN_ERR); | ||
20 | print_constant_str("UM_KERN_WARNING", KERN_WARNING); | ||
21 | print_constant_str("UM_KERN_NOTICE", KERN_NOTICE); | ||
22 | print_constant_str("UM_KERN_INFO", KERN_INFO); | ||
23 | print_constant_str("UM_KERN_DEBUG", KERN_DEBUG); | ||
24 | |||
25 | print_constant_int("UM_NSEC_PER_SEC", NSEC_PER_SEC); | ||
26 | print_tail(); | ||
27 | return(0); | ||
28 | } | ||
diff --git a/arch/um/util/mk_constants_user.c b/arch/um/util/mk_constants_user.c deleted file mode 100644 index 8f4d7e50be7c..000000000000 --- a/arch/um/util/mk_constants_user.c +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | |||
3 | void print_head(void) | ||
4 | { | ||
5 | printf("/*\n"); | ||
6 | printf(" * Generated by mk_constants\n"); | ||
7 | printf(" */\n"); | ||
8 | printf("\n"); | ||
9 | printf("#ifndef __UM_CONSTANTS_H\n"); | ||
10 | printf("#define __UM_CONSTANTS_H\n"); | ||
11 | printf("\n"); | ||
12 | } | ||
13 | |||
14 | void print_constant_str(char *name, char *value) | ||
15 | { | ||
16 | printf("#define %s \"%s\"\n", name, value); | ||
17 | } | ||
18 | |||
19 | void print_constant_int(char *name, int value) | ||
20 | { | ||
21 | printf("#define %s %d\n", name, value); | ||
22 | } | ||
23 | |||
24 | void print_tail(void) | ||
25 | { | ||
26 | printf("\n"); | ||
27 | printf("#endif\n"); | ||
28 | } | ||
diff --git a/arch/um/util/mk_task_user.c b/arch/um/util/mk_task.c index 9db849f3f3ac..36c9606505e2 100644 --- a/arch/um/util/mk_task_user.c +++ b/arch/um/util/mk_task.c | |||
@@ -1,18 +1,19 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <kernel-offsets.h> | ||
2 | 3 | ||
3 | void print(char *name, char *type, int offset) | 4 | void print_ptr(char *name, char *type, int offset) |
4 | { | 5 | { |
5 | printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, | 6 | printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type, |
6 | offset); | 7 | offset); |
7 | } | 8 | } |
8 | 9 | ||
9 | void print_ptr(char *name, char *type, int offset) | 10 | void print(char *name, char *type, int offset) |
10 | { | 11 | { |
11 | printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type, | 12 | printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, |
12 | offset); | 13 | offset); |
13 | } | 14 | } |
14 | 15 | ||
15 | void print_head(void) | 16 | int main(int argc, char **argv) |
16 | { | 17 | { |
17 | printf("/*\n"); | 18 | printf("/*\n"); |
18 | printf(" * Generated by mk_task\n"); | 19 | printf(" * Generated by mk_task\n"); |
@@ -21,10 +22,9 @@ void print_head(void) | |||
21 | printf("#ifndef __TASK_H\n"); | 22 | printf("#ifndef __TASK_H\n"); |
22 | printf("#define __TASK_H\n"); | 23 | printf("#define __TASK_H\n"); |
23 | printf("\n"); | 24 | printf("\n"); |
24 | } | 25 | print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS); |
25 | 26 | print("TASK_PID", "int", TASK_PID); | |
26 | void print_tail(void) | ||
27 | { | ||
28 | printf("\n"); | 27 | printf("\n"); |
29 | printf("#endif\n"); | 28 | printf("#endif\n"); |
29 | return(0); | ||
30 | } | 30 | } |
diff --git a/arch/um/util/mk_task_kern.c b/arch/um/util/mk_task_kern.c deleted file mode 100644 index c218103315ed..000000000000 --- a/arch/um/util/mk_task_kern.c +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | #include "linux/sched.h" | ||
2 | #include "linux/stddef.h" | ||
3 | |||
4 | extern void print(char *name, char *type, int offset); | ||
5 | extern void print_ptr(char *name, char *type, int offset); | ||
6 | extern void print_head(void); | ||
7 | extern void print_tail(void); | ||
8 | |||
9 | int main(int argc, char **argv) | ||
10 | { | ||
11 | print_head(); | ||
12 | print_ptr("TASK_REGS", "union uml_pt_regs", | ||
13 | offsetof(struct task_struct, thread.regs)); | ||
14 | print("TASK_PID", "int", offsetof(struct task_struct, pid)); | ||
15 | print_tail(); | ||
16 | return(0); | ||
17 | } | ||