diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-10-06 05:51:07 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-06 05:51:07 -0400 |
commit | 012e060c95e547eceea4a12c6f58592473bf4011 (patch) | |
tree | b57d3eafb50ce517577d2cf366c9ef0b4b286589 /arch/um | |
parent | 923f122573851d18a3832ca808269fa2d5046fb1 (diff) | |
parent | ed39f731ab2e77e58122232f6e27333331d7793d (diff) |
Merge branch 'master'
Diffstat (limited to 'arch/um')
79 files changed, 856 insertions, 1204 deletions
diff --git a/arch/um/Kconfig.i386 b/arch/um/Kconfig.i386 index 8ad156a00499..5d92cacd56c6 100644 --- a/arch/um/Kconfig.i386 +++ b/arch/um/Kconfig.i386 | |||
@@ -42,3 +42,7 @@ config ARCH_HAS_SC_SIGNALS | |||
42 | config ARCH_REUSE_HOST_VSYSCALL_AREA | 42 | config ARCH_REUSE_HOST_VSYSCALL_AREA |
43 | bool | 43 | bool |
44 | default y | 44 | default y |
45 | |||
46 | config X86_CMPXCHG | ||
47 | bool | ||
48 | default y | ||
diff --git a/arch/um/Makefile b/arch/um/Makefile index ce987266dac6..7af37e342e33 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -28,8 +28,6 @@ SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) | |||
28 | ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ | 28 | ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ |
29 | $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h | 29 | $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h |
30 | 30 | ||
31 | GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h | ||
32 | |||
33 | um-modes-$(CONFIG_MODE_TT) += tt | 31 | um-modes-$(CONFIG_MODE_TT) += tt |
34 | um-modes-$(CONFIG_MODE_SKAS) += skas | 32 | um-modes-$(CONFIG_MODE_SKAS) += skas |
35 | 33 | ||
@@ -45,17 +43,19 @@ endif | |||
45 | 43 | ||
46 | ARCH_INCLUDE := -I$(ARCH_DIR)/include | 44 | ARCH_INCLUDE := -I$(ARCH_DIR)/include |
47 | ifneq ($(KBUILD_SRC),) | 45 | ifneq ($(KBUILD_SRC),) |
48 | ARCH_INCLUDE += -I$(ARCH_DIR)/include2 | ||
49 | ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include | 46 | ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include |
50 | MRPROPER_DIRS += $(ARCH_DIR)/include2 | ||
51 | endif | 47 | endif |
52 | SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) | 48 | SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) |
53 | 49 | ||
54 | # -Dvmap=kernel_vmap affects everything, and prevents anything from | 50 | # -Dvmap=kernel_vmap affects everything, and prevents anything from |
55 | # referencing the libpcap.o symbol so named. | 51 | # referencing the libpcap.o symbol so named. |
52 | # | ||
53 | # Same things for in6addr_loopback - found in libc. | ||
56 | 54 | ||
57 | CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ | 55 | CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ |
58 | $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap | 56 | $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ |
57 | -Din6addr_loopback=kernel_in6addr_loopback | ||
58 | |||
59 | AFLAGS += $(ARCH_INCLUDE) | 59 | AFLAGS += $(ARCH_INCLUDE) |
60 | 60 | ||
61 | USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) | 61 | USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) |
@@ -83,10 +83,6 @@ CONFIG_KERNEL_HALF_GIGS ?= 0 | |||
83 | 83 | ||
84 | SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) | 84 | SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) |
85 | 85 | ||
86 | ifeq ($(CONFIG_MODE_SKAS), y) | ||
87 | $(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h | ||
88 | endif | ||
89 | |||
90 | .PHONY: linux | 86 | .PHONY: linux |
91 | 87 | ||
92 | all: linux | 88 | all: linux |
@@ -107,7 +103,8 @@ else | |||
107 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) | 103 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) |
108 | endif | 104 | endif |
109 | 105 | ||
110 | archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) | 106 | archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h |
107 | prepare: $(ARCH_DIR)/include/kern_constants.h | ||
111 | 108 | ||
112 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static | 109 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static |
113 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib | 110 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib |
@@ -142,15 +139,13 @@ endef | |||
142 | #When cleaning we don't include .config, so we don't include | 139 | #When cleaning we don't include .config, so we don't include |
143 | #TT or skas makefiles and don't clean skas_ptregs.h. | 140 | #TT or skas makefiles and don't clean skas_ptregs.h. |
144 | CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \ | 141 | CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \ |
145 | $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \ | 142 | $(ARCH_DIR)/include/user_constants.h \ |
146 | $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch | 143 | $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch |
147 | 144 | ||
148 | MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ | 145 | MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ |
149 | $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os | 146 | $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os |
150 | 147 | ||
151 | archclean: | 148 | archclean: |
152 | $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util | ||
153 | $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util | ||
154 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ | 149 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ |
155 | -o -name '*.gcov' \) -type f -print | xargs rm -f | 150 | -o -name '*.gcov' \) -type f -print | xargs rm -f |
156 | 151 | ||
@@ -176,9 +171,7 @@ $(ARCH_DIR)/include/sysdep: | |||
176 | @echo ' SYMLINK $@' | 171 | @echo ' SYMLINK $@' |
177 | ifneq ($(KBUILD_SRC),) | 172 | ifneq ($(KBUILD_SRC),) |
178 | $(Q)mkdir -p $(ARCH_DIR)/include | 173 | $(Q)mkdir -p $(ARCH_DIR)/include |
179 | $(Q)mkdir -p $(ARCH_DIR)/include2 | 174 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep |
180 | $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep | ||
181 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep | ||
182 | else | 175 | else |
183 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep | 176 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep |
184 | endif | 177 | endif |
@@ -198,8 +191,6 @@ endef | |||
198 | 191 | ||
199 | define filechk_gen-asm-offsets | 192 | define filechk_gen-asm-offsets |
200 | (set -e; \ | 193 | (set -e; \ |
201 | echo "#ifndef __ASM_OFFSETS_H__"; \ | ||
202 | echo "#define __ASM_OFFSETS_H__"; \ | ||
203 | echo "/*"; \ | 194 | echo "/*"; \ |
204 | echo " * DO NOT MODIFY."; \ | 195 | echo " * DO NOT MODIFY."; \ |
205 | echo " *"; \ | 196 | echo " *"; \ |
@@ -208,8 +199,7 @@ define filechk_gen-asm-offsets | |||
208 | echo " */"; \ | 199 | echo " */"; \ |
209 | echo ""; \ | 200 | echo ""; \ |
210 | sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ | 201 | sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ |
211 | echo ""; \ | 202 | echo ""; ) |
212 | echo "#endif" ) | ||
213 | endef | 203 | endef |
214 | 204 | ||
215 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | 205 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h |
@@ -218,50 +208,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | |||
218 | $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c | 208 | $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c |
219 | $(CC) $(USER_CFLAGS) -S -o $@ $< | 209 | $(CC) $(USER_CFLAGS) -S -o $@ $< |
220 | 210 | ||
221 | $(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s | 211 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s |
222 | $(call filechk,gen-asm-offsets) | 212 | $(call filechk,gen-asm-offsets) |
223 | 213 | ||
224 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h | 214 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s |
225 | 215 | ||
226 | $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ | 216 | $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ |
227 | $(ARCH_SYMLINKS) \ | 217 | archprepare |
228 | $(SYS_DIR)/sc.h \ | ||
229 | include/asm include/linux/version.h \ | ||
230 | include/config/MARKER \ | ||
231 | $(ARCH_DIR)/include/user_constants.h | ||
232 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< | 218 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< |
233 | 219 | ||
234 | $(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s | 220 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s |
235 | $(call filechk,gen-asm-offsets) | 221 | $(call filechk,gen-asm-offsets) |
236 | 222 | ||
237 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h | 223 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s |
238 | |||
239 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task | ||
240 | $(call filechk,gen_header) | ||
241 | |||
242 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants | ||
243 | $(call filechk,gen_header) | ||
244 | |||
245 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants | ||
246 | $(call filechk,gen_header) | ||
247 | |||
248 | $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs | ||
249 | $(call filechk,gen_header) | ||
250 | |||
251 | $(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ; | ||
252 | |||
253 | $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ | ||
254 | FORCE ; | ||
255 | |||
256 | $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; | ||
257 | |||
258 | $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE | ||
259 | $(Q)$(MAKE) $(build)=$@ | ||
260 | |||
261 | $(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
262 | $(Q)$(MAKE) $(build)=$@ | ||
263 | |||
264 | $(ARCH_DIR)/os-$(OS)/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
265 | $(Q)$(MAKE) $(build)=$@ | ||
266 | 224 | ||
267 | export SUBARCH USER_CFLAGS OS | 225 | export SUBARCH USER_CFLAGS OS |
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386 index 1ab431a53ac3..2ee8a2858117 100644 --- a/arch/um/Makefile-i386 +++ b/arch/um/Makefile-i386 | |||
@@ -32,25 +32,3 @@ CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) | |||
32 | ifneq ($(CONFIG_GPROF),y) | 32 | ifneq ($(CONFIG_GPROF),y) |
33 | ARCH_CFLAGS += -DUM_FASTCALL | 33 | ARCH_CFLAGS += -DUM_FASTCALL |
34 | endif | 34 | endif |
35 | |||
36 | SYS_UTIL_DIR := $(ARCH_DIR)/sys-i386/util | ||
37 | SYS_HEADERS := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h | ||
38 | |||
39 | prepare: $(SYS_HEADERS) | ||
40 | |||
41 | $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc | ||
42 | $(call filechk,gen_header) | ||
43 | |||
44 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread | ||
45 | $(call filechk,gen_header) | ||
46 | |||
47 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
48 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
49 | |||
50 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE | ||
51 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
52 | |||
53 | $(SYS_UTIL_DIR): scripts_basic include/asm FORCE | ||
54 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) | ||
55 | |||
56 | CLEAN_FILES += $(SYS_HEADERS) | ||
diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas index fd18ec572271..ac35de5316a6 100644 --- a/arch/um/Makefile-skas +++ b/arch/um/Makefile-skas | |||
@@ -10,5 +10,3 @@ CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT) | |||
10 | CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) | 10 | CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) |
11 | LINK-$(CONFIG_GCOV) += $(GCOV_OPT) | 11 | LINK-$(CONFIG_GCOV) += $(GCOV_OPT) |
12 | LINK-$(CONFIG_GPROF) += $(GPROF_OPT) | 12 | LINK-$(CONFIG_GPROF) += $(GPROF_OPT) |
13 | |||
14 | GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h | ||
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64 index 436abbba409b..4f118d5cc2ee 100644 --- a/arch/um/Makefile-x86_64 +++ b/arch/um/Makefile-x86_64 | |||
@@ -12,24 +12,3 @@ CHECKFLAGS += -m64 | |||
12 | 12 | ||
13 | ELF_ARCH := i386:x86-64 | 13 | ELF_ARCH := i386:x86-64 |
14 | ELF_FORMAT := elf64-x86-64 | 14 | ELF_FORMAT := elf64-x86-64 |
15 | |||
16 | SYS_UTIL_DIR := $(ARCH_DIR)/sys-x86_64/util | ||
17 | SYS_DIR := $(ARCH_DIR)/include/sysdep-x86_64 | ||
18 | |||
19 | SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h | ||
20 | |||
21 | prepare: $(SYS_HEADERS) | ||
22 | |||
23 | $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc | ||
24 | $(call filechk,gen_header) | ||
25 | |||
26 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread | ||
27 | $(call filechk,gen_header) | ||
28 | |||
29 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
30 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
31 | |||
32 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE | ||
33 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
34 | |||
35 | CLEAN_FILES += $(SYS_HEADERS) | ||
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 14a12d6b3df6..16e7dc89f61d 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c | |||
@@ -19,18 +19,44 @@ | |||
19 | #include "line.h" | 19 | #include "line.h" |
20 | #include "os.h" | 20 | #include "os.h" |
21 | 21 | ||
22 | #ifdef CONFIG_NOCONFIG_CHAN | 22 | /* XXX: could well be moved to somewhere else, if needed. */ |
23 | static int my_printf(const char * fmt, ...) | ||
24 | __attribute__ ((format (printf, 1, 2))); | ||
25 | |||
26 | static int my_printf(const char * fmt, ...) | ||
27 | { | ||
28 | /* Yes, can be called on atomic context.*/ | ||
29 | char *buf = kmalloc(4096, GFP_ATOMIC); | ||
30 | va_list args; | ||
31 | int r; | ||
32 | |||
33 | if (!buf) { | ||
34 | /* We print directly fmt. | ||
35 | * Yes, yes, yes, feel free to complain. */ | ||
36 | r = strlen(fmt); | ||
37 | } else { | ||
38 | va_start(args, fmt); | ||
39 | r = vsprintf(buf, fmt, args); | ||
40 | va_end(args); | ||
41 | fmt = buf; | ||
42 | } | ||
23 | 43 | ||
24 | /* The printk's here are wrong because we are complaining that there is no | 44 | if (r) |
25 | * output device, but printk is printing to that output device. The user will | 45 | r = os_write_file(1, fmt, r); |
26 | * never see the error. printf would be better, except it can't run on a | 46 | return r; |
27 | * kernel stack because it will overflow it. | 47 | |
28 | * Use printk for now since that will avoid crashing. | 48 | } |
29 | */ | 49 | |
50 | #ifdef CONFIG_NOCONFIG_CHAN | ||
51 | /* Despite its name, there's no added trailing newline. */ | ||
52 | static int my_puts(const char * buf) | ||
53 | { | ||
54 | return os_write_file(1, buf, strlen(buf)); | ||
55 | } | ||
30 | 56 | ||
31 | static void *not_configged_init(char *str, int device, struct chan_opts *opts) | 57 | static void *not_configged_init(char *str, int device, struct chan_opts *opts) |
32 | { | 58 | { |
33 | printk(KERN_ERR "Using a channel type which is configured out of " | 59 | my_puts("Using a channel type which is configured out of " |
34 | "UML\n"); | 60 | "UML\n"); |
35 | return(NULL); | 61 | return(NULL); |
36 | } | 62 | } |
@@ -38,27 +64,27 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts) | |||
38 | static int not_configged_open(int input, int output, int primary, void *data, | 64 | static int not_configged_open(int input, int output, int primary, void *data, |
39 | char **dev_out) | 65 | char **dev_out) |
40 | { | 66 | { |
41 | printk(KERN_ERR "Using a channel type which is configured out of " | 67 | my_puts("Using a channel type which is configured out of " |
42 | "UML\n"); | 68 | "UML\n"); |
43 | return(-ENODEV); | 69 | return(-ENODEV); |
44 | } | 70 | } |
45 | 71 | ||
46 | static void not_configged_close(int fd, void *data) | 72 | static void not_configged_close(int fd, void *data) |
47 | { | 73 | { |
48 | printk(KERN_ERR "Using a channel type which is configured out of " | 74 | my_puts("Using a channel type which is configured out of " |
49 | "UML\n"); | 75 | "UML\n"); |
50 | } | 76 | } |
51 | 77 | ||
52 | static int not_configged_read(int fd, char *c_out, void *data) | 78 | static int not_configged_read(int fd, char *c_out, void *data) |
53 | { | 79 | { |
54 | printk(KERN_ERR "Using a channel type which is configured out of " | 80 | my_puts("Using a channel type which is configured out of " |
55 | "UML\n"); | 81 | "UML\n"); |
56 | return(-EIO); | 82 | return(-EIO); |
57 | } | 83 | } |
58 | 84 | ||
59 | static int not_configged_write(int fd, const char *buf, int len, void *data) | 85 | static int not_configged_write(int fd, const char *buf, int len, void *data) |
60 | { | 86 | { |
61 | printk(KERN_ERR "Using a channel type which is configured out of " | 87 | my_puts("Using a channel type which is configured out of " |
62 | "UML\n"); | 88 | "UML\n"); |
63 | return(-EIO); | 89 | return(-EIO); |
64 | } | 90 | } |
@@ -66,7 +92,7 @@ static int not_configged_write(int fd, const char *buf, int len, void *data) | |||
66 | static int not_configged_console_write(int fd, const char *buf, int len, | 92 | static int not_configged_console_write(int fd, const char *buf, int len, |
67 | void *data) | 93 | void *data) |
68 | { | 94 | { |
69 | printk(KERN_ERR "Using a channel type which is configured out of " | 95 | my_puts("Using a channel type which is configured out of " |
70 | "UML\n"); | 96 | "UML\n"); |
71 | return(-EIO); | 97 | return(-EIO); |
72 | } | 98 | } |
@@ -74,14 +100,14 @@ static int not_configged_console_write(int fd, const char *buf, int len, | |||
74 | static int not_configged_window_size(int fd, void *data, unsigned short *rows, | 100 | static int not_configged_window_size(int fd, void *data, unsigned short *rows, |
75 | unsigned short *cols) | 101 | unsigned short *cols) |
76 | { | 102 | { |
77 | printk(KERN_ERR "Using a channel type which is configured out of " | 103 | my_puts("Using a channel type which is configured out of " |
78 | "UML\n"); | 104 | "UML\n"); |
79 | return(-ENODEV); | 105 | return(-ENODEV); |
80 | } | 106 | } |
81 | 107 | ||
82 | static void not_configged_free(void *data) | 108 | static void not_configged_free(void *data) |
83 | { | 109 | { |
84 | printf(KERN_ERR "Using a channel type which is configured out of " | 110 | my_puts("Using a channel type which is configured out of " |
85 | "UML\n"); | 111 | "UML\n"); |
86 | } | 112 | } |
87 | 113 | ||
@@ -457,7 +483,7 @@ static struct chan *parse_chan(char *str, int pri, int device, | |||
457 | } | 483 | } |
458 | } | 484 | } |
459 | if(ops == NULL){ | 485 | if(ops == NULL){ |
460 | printk(KERN_ERR "parse_chan couldn't parse \"%s\"\n", | 486 | my_printf("parse_chan couldn't parse \"%s\"\n", |
461 | str); | 487 | str); |
462 | return(NULL); | 488 | return(NULL); |
463 | } | 489 | } |
@@ -465,7 +491,7 @@ static struct chan *parse_chan(char *str, int pri, int device, | |||
465 | data = (*ops->init)(str, device, opts); | 491 | data = (*ops->init)(str, device, opts); |
466 | if(data == NULL) return(NULL); | 492 | if(data == NULL) return(NULL); |
467 | 493 | ||
468 | chan = kmalloc(sizeof(*chan), GFP_KERNEL); | 494 | chan = kmalloc(sizeof(*chan), GFP_ATOMIC); |
469 | if(chan == NULL) return(NULL); | 495 | if(chan == NULL) return(NULL); |
470 | *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), | 496 | *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), |
471 | .primary = 1, | 497 | .primary = 1, |
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 7a0d115b29d0..5db136e2651c 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #include <errno.h> | 14 | #include <errno.h> |
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | #include <linux/inet.h> | ||
17 | #include <sys/socket.h> | 16 | #include <sys/socket.h> |
18 | #include <sys/un.h> | 17 | #include <sys/un.h> |
19 | #include <sys/time.h> | 18 | #include <sys/time.h> |
@@ -55,7 +54,7 @@ static int mcast_open(void *data) | |||
55 | struct mcast_data *pri = data; | 54 | struct mcast_data *pri = data; |
56 | struct sockaddr_in *sin = pri->mcast_addr; | 55 | struct sockaddr_in *sin = pri->mcast_addr; |
57 | struct ip_mreq mreq; | 56 | struct ip_mreq mreq; |
58 | int fd = -EINVAL, yes = 1, err = -EINVAL;; | 57 | int fd, yes = 1, err = 0; |
59 | 58 | ||
60 | 59 | ||
61 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) | 60 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) |
@@ -66,13 +65,14 @@ static int mcast_open(void *data) | |||
66 | if (fd < 0){ | 65 | if (fd < 0){ |
67 | printk("mcast_open : data socket failed, errno = %d\n", | 66 | printk("mcast_open : data socket failed, errno = %d\n", |
68 | errno); | 67 | errno); |
69 | fd = -errno; | 68 | err = -errno; |
70 | goto out; | 69 | goto out; |
71 | } | 70 | } |
72 | 71 | ||
73 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { | 72 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { |
74 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", | 73 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", |
75 | errno); | 74 | errno); |
75 | err = -errno; | ||
76 | goto out_close; | 76 | goto out_close; |
77 | } | 77 | } |
78 | 78 | ||
@@ -81,6 +81,7 @@ static int mcast_open(void *data) | |||
81 | sizeof(pri->ttl)) < 0) { | 81 | sizeof(pri->ttl)) < 0) { |
82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", | 82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", |
83 | errno); | 83 | errno); |
84 | err = -errno; | ||
84 | goto out_close; | 85 | goto out_close; |
85 | } | 86 | } |
86 | 87 | ||
@@ -88,12 +89,14 @@ static int mcast_open(void *data) | |||
88 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { | 89 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { |
89 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", | 90 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", |
90 | errno); | 91 | errno); |
92 | err = -errno; | ||
91 | goto out_close; | 93 | goto out_close; |
92 | } | 94 | } |
93 | 95 | ||
94 | /* bind socket to mcast address */ | 96 | /* bind socket to mcast address */ |
95 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { | 97 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { |
96 | printk("mcast_open : data bind failed, errno = %d\n", errno); | 98 | printk("mcast_open : data bind failed, errno = %d\n", errno); |
99 | err = -errno; | ||
97 | goto out_close; | 100 | goto out_close; |
98 | } | 101 | } |
99 | 102 | ||
@@ -108,14 +111,15 @@ static int mcast_open(void *data) | |||
108 | "interface on the host.\n"); | 111 | "interface on the host.\n"); |
109 | printk("eth0 should be configured in order to use the " | 112 | printk("eth0 should be configured in order to use the " |
110 | "multicast transport.\n"); | 113 | "multicast transport.\n"); |
114 | err = -errno; | ||
111 | goto out_close; | 115 | goto out_close; |
112 | } | 116 | } |
113 | 117 | ||
114 | out: | ||
115 | return fd; | 118 | return fd; |
116 | 119 | ||
117 | out_close: | 120 | out_close: |
118 | os_close_file(fd); | 121 | os_close_file(fd); |
122 | out: | ||
119 | return err; | 123 | return err; |
120 | } | 124 | } |
121 | 125 | ||
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index c190c2414197..12c95368124a 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "os.h" | 32 | #include "os.h" |
33 | #include "umid.h" | 33 | #include "umid.h" |
34 | #include "irq_kern.h" | 34 | #include "irq_kern.h" |
35 | #include "choose-mode.h" | ||
35 | 36 | ||
36 | static int do_unlink_socket(struct notifier_block *notifier, | 37 | static int do_unlink_socket(struct notifier_block *notifier, |
37 | unsigned long what, void *data) | 38 | unsigned long what, void *data) |
@@ -276,6 +277,7 @@ void mconsole_proc(struct mc_request *req) | |||
276 | go - continue the UML after a 'stop' \n\ | 277 | go - continue the UML after a 'stop' \n\ |
277 | log <string> - make UML enter <string> into the kernel log\n\ | 278 | log <string> - make UML enter <string> into the kernel log\n\ |
278 | proc <file> - returns the contents of the UML's /proc/<file>\n\ | 279 | proc <file> - returns the contents of the UML's /proc/<file>\n\ |
280 | stack <pid> - returns the stack of the specified pid\n\ | ||
279 | " | 281 | " |
280 | 282 | ||
281 | void mconsole_help(struct mc_request *req) | 283 | void mconsole_help(struct mc_request *req) |
@@ -479,6 +481,56 @@ void mconsole_sysrq(struct mc_request *req) | |||
479 | } | 481 | } |
480 | #endif | 482 | #endif |
481 | 483 | ||
484 | /* Mconsole stack trace | ||
485 | * Added by Allan Graves, Jeff Dike | ||
486 | * Dumps a stacks registers to the linux console. | ||
487 | * Usage stack <pid>. | ||
488 | */ | ||
489 | void do_stack(struct mc_request *req) | ||
490 | { | ||
491 | char *ptr = req->request.data; | ||
492 | int pid_requested= -1; | ||
493 | struct task_struct *from = NULL; | ||
494 | struct task_struct *to = NULL; | ||
495 | |||
496 | /* Would be nice: | ||
497 | * 1) Send showregs output to mconsole. | ||
498 | * 2) Add a way to stack dump all pids. | ||
499 | */ | ||
500 | |||
501 | ptr += strlen("stack"); | ||
502 | while(isspace(*ptr)) ptr++; | ||
503 | |||
504 | /* Should really check for multiple pids or reject bad args here */ | ||
505 | /* What do the arguments in mconsole_reply mean? */ | ||
506 | if(sscanf(ptr, "%d", &pid_requested) == 0){ | ||
507 | mconsole_reply(req, "Please specify a pid", 1, 0); | ||
508 | return; | ||
509 | } | ||
510 | |||
511 | from = current; | ||
512 | to = find_task_by_pid(pid_requested); | ||
513 | |||
514 | if((to == NULL) || (pid_requested == 0)) { | ||
515 | mconsole_reply(req, "Couldn't find that pid", 1, 0); | ||
516 | return; | ||
517 | } | ||
518 | to->thread.saved_task = current; | ||
519 | |||
520 | switch_to(from, to, from); | ||
521 | mconsole_reply(req, "Stack Dumped to console and message log", 0, 0); | ||
522 | } | ||
523 | |||
524 | void mconsole_stack(struct mc_request *req) | ||
525 | { | ||
526 | /* This command doesn't work in TT mode, so let's check and then | ||
527 | * get out of here | ||
528 | */ | ||
529 | CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode", | ||
530 | 1, 0), | ||
531 | do_stack(req)); | ||
532 | } | ||
533 | |||
482 | /* Changed by mconsole_setup, which is __setup, and called before SMP is | 534 | /* Changed by mconsole_setup, which is __setup, and called before SMP is |
483 | * active. | 535 | * active. |
484 | */ | 536 | */ |
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index fe5afb13252c..310c1f823f26 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c | |||
@@ -30,6 +30,7 @@ static struct mconsole_command commands[] = { | |||
30 | { "go", mconsole_go, MCONSOLE_INTR }, | 30 | { "go", mconsole_go, MCONSOLE_INTR }, |
31 | { "log", mconsole_log, MCONSOLE_INTR }, | 31 | { "log", mconsole_log, MCONSOLE_INTR }, |
32 | { "proc", mconsole_proc, MCONSOLE_PROC }, | 32 | { "proc", mconsole_proc, MCONSOLE_PROC }, |
33 | { "stack", mconsole_stack, MCONSOLE_INTR }, | ||
33 | }; | 34 | }; |
34 | 35 | ||
35 | /* Initialized in mconsole_init, which is an initcall */ | 36 | /* Initialized in mconsole_init, which is an initcall */ |
@@ -172,9 +173,9 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
172 | if(notify_sock < 0){ | 173 | if(notify_sock < 0){ |
173 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 174 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
174 | if(notify_sock < 0){ | 175 | if(notify_sock < 0){ |
175 | printk("mconsole_notify - socket failed, errno = %d\n", | ||
176 | errno); | ||
177 | err = -errno; | 176 | err = -errno; |
177 | printk("mconsole_notify - socket failed, errno = %d\n", | ||
178 | err); | ||
178 | } | 179 | } |
179 | } | 180 | } |
180 | unlock_notify(); | 181 | unlock_notify(); |
@@ -197,8 +198,8 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
197 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, | 198 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, |
198 | sizeof(target)); | 199 | sizeof(target)); |
199 | if(n < 0){ | 200 | if(n < 0){ |
200 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | ||
201 | err = -errno; | 201 | err = -errno; |
202 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | ||
202 | } | 203 | } |
203 | return(err); | 204 | return(err); |
204 | } | 205 | } |
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c index c41efd207fcc..189839e4f1d4 100644 --- a/arch/um/drivers/port_kern.c +++ b/arch/um/drivers/port_kern.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include "linux/sched.h" | 7 | #include "linux/sched.h" |
8 | #include "linux/slab.h" | 8 | #include "linux/slab.h" |
9 | #include "linux/interrupt.h" | 9 | #include "linux/interrupt.h" |
10 | #include "linux/irq.h" | ||
11 | #include "linux/spinlock.h" | 10 | #include "linux/spinlock.h" |
12 | #include "linux/errno.h" | 11 | #include "linux/errno.h" |
13 | #include "asm/atomic.h" | 12 | #include "asm/atomic.h" |
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c index ed84d01df6cc..0306a1b215b7 100644 --- a/arch/um/drivers/pty.c +++ b/arch/um/drivers/pty.c | |||
@@ -43,8 +43,9 @@ static int pts_open(int input, int output, int primary, void *d, | |||
43 | 43 | ||
44 | fd = get_pty(); | 44 | fd = get_pty(); |
45 | if(fd < 0){ | 45 | if(fd < 0){ |
46 | err = -errno; | ||
46 | printk("open_pts : Failed to open pts\n"); | 47 | printk("open_pts : Failed to open pts\n"); |
47 | return(-errno); | 48 | return err; |
48 | } | 49 | } |
49 | if(data->raw){ | 50 | if(data->raw){ |
50 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); | 51 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); |
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c deleted file mode 100644 index b94d2bc4fe06..000000000000 --- a/arch/um/drivers/ubd_user.c +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Copyright (C) 2001 Ridgerun,Inc (glonnon@ridgerun.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <stddef.h> | ||
8 | #include <unistd.h> | ||
9 | #include <errno.h> | ||
10 | #include <sched.h> | ||
11 | #include <signal.h> | ||
12 | #include <string.h> | ||
13 | #include <netinet/in.h> | ||
14 | #include <sys/time.h> | ||
15 | #include <sys/socket.h> | ||
16 | #include <sys/mman.h> | ||
17 | #include <sys/param.h> | ||
18 | #include "asm/types.h" | ||
19 | #include "user_util.h" | ||
20 | #include "kern_util.h" | ||
21 | #include "user.h" | ||
22 | #include "ubd_user.h" | ||
23 | #include "os.h" | ||
24 | #include "cow.h" | ||
25 | |||
26 | #include <endian.h> | ||
27 | #include <byteswap.h> | ||
28 | |||
29 | void ignore_sigwinch_sig(void) | ||
30 | { | ||
31 | signal(SIGWINCH, SIG_IGN); | ||
32 | } | ||
33 | |||
34 | int start_io_thread(unsigned long sp, int *fd_out) | ||
35 | { | ||
36 | int pid, fds[2], err; | ||
37 | |||
38 | err = os_pipe(fds, 1, 1); | ||
39 | if(err < 0){ | ||
40 | printk("start_io_thread - os_pipe failed, err = %d\n", -err); | ||
41 | goto out; | ||
42 | } | ||
43 | |||
44 | kernel_fd = fds[0]; | ||
45 | *fd_out = fds[1]; | ||
46 | |||
47 | pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD, | ||
48 | NULL); | ||
49 | if(pid < 0){ | ||
50 | printk("start_io_thread - clone failed : errno = %d\n", errno); | ||
51 | err = -errno; | ||
52 | goto out_close; | ||
53 | } | ||
54 | |||
55 | return(pid); | ||
56 | |||
57 | out_close: | ||
58 | os_close_file(fds[0]); | ||
59 | os_close_file(fds[1]); | ||
60 | kernel_fd = -1; | ||
61 | *fd_out = -1; | ||
62 | out: | ||
63 | return(err); | ||
64 | } | ||
65 | |||
66 | /* | ||
67 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
68 | * Emacs will notice this stuff at the end of the file and automatically | ||
69 | * adjust the settings for this buffer only. This must remain at the end | ||
70 | * of the file. | ||
71 | * --------------------------------------------------------------------------- | ||
72 | * Local variables: | ||
73 | * c-file-style: "linux" | ||
74 | * End: | ||
75 | */ | ||
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 93dc1911363f..90e0e5ff451e 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c | |||
@@ -110,13 +110,15 @@ int xterm_open(int input, int output, int primary, void *d, | |||
110 | 110 | ||
111 | fd = mkstemp(file); | 111 | fd = mkstemp(file); |
112 | if(fd < 0){ | 112 | if(fd < 0){ |
113 | err = -errno; | ||
113 | printk("xterm_open : mkstemp failed, errno = %d\n", errno); | 114 | printk("xterm_open : mkstemp failed, errno = %d\n", errno); |
114 | return(-errno); | 115 | return err; |
115 | } | 116 | } |
116 | 117 | ||
117 | if(unlink(file)){ | 118 | if(unlink(file)){ |
119 | err = -errno; | ||
118 | printk("xterm_open : unlink failed, errno = %d\n", errno); | 120 | printk("xterm_open : unlink failed, errno = %d\n", errno); |
119 | return(-errno); | 121 | return err; |
120 | } | 122 | } |
121 | os_close_file(fd); | 123 | os_close_file(fd); |
122 | 124 | ||
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h index 0aa620970adb..356390d1f8b9 100644 --- a/arch/um/include/common-offsets.h +++ b/arch/um/include/common-offsets.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* for use by sys-$SUBARCH/kernel-offsets.c */ | 1 | /* for use by sys-$SUBARCH/kernel-offsets.c */ |
2 | 2 | ||
3 | OFFSET(TASK_REGS, task_struct, thread.regs); | 3 | OFFSET(HOST_TASK_REGS, task_struct, thread.regs); |
4 | OFFSET(TASK_PID, task_struct, pid); | 4 | OFFSET(HOST_TASK_PID, task_struct, pid); |
5 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); | 5 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); |
6 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | 6 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); |
7 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); | 7 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); |
@@ -12,4 +12,6 @@ DEFINE_STR(UM_KERN_WARNING, KERN_WARNING); | |||
12 | DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); | 12 | DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); |
13 | DEFINE_STR(UM_KERN_INFO, KERN_INFO); | 13 | DEFINE_STR(UM_KERN_INFO, KERN_INFO); |
14 | DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); | 14 | DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); |
15 | DEFINE(HOST_ELF_CLASS, ELF_CLASS); | 15 | DEFINE(UM_ELF_CLASS, ELF_CLASS); |
16 | DEFINE(UM_ELFCLASS32, ELFCLASS32); | ||
17 | DEFINE(UM_ELFCLASS64, ELFCLASS64); | ||
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h index cfa368e045a5..b1b512f47035 100644 --- a/arch/um/include/mconsole.h +++ b/arch/um/include/mconsole.h | |||
@@ -81,6 +81,7 @@ extern void mconsole_stop(struct mc_request *req); | |||
81 | extern void mconsole_go(struct mc_request *req); | 81 | extern void mconsole_go(struct mc_request *req); |
82 | extern void mconsole_log(struct mc_request *req); | 82 | extern void mconsole_log(struct mc_request *req); |
83 | extern void mconsole_proc(struct mc_request *req); | 83 | extern void mconsole_proc(struct mc_request *req); |
84 | extern void mconsole_stack(struct mc_request *req); | ||
84 | 85 | ||
85 | extern int mconsole_get_request(int fd, struct mc_request *req); | 86 | extern int mconsole_get_request(int fd, struct mc_request *req); |
86 | extern int mconsole_notify(char *sock_name, int type, const void *data, | 87 | extern int mconsole_notify(char *sock_name, int type, const void *data, |
diff --git a/arch/um/include/mem_user.h b/arch/um/include/mem_user.h index d6404bb64662..9fef4123a65a 100644 --- a/arch/um/include/mem_user.h +++ b/arch/um/include/mem_user.h | |||
@@ -51,7 +51,6 @@ extern unsigned long task_size; | |||
51 | 51 | ||
52 | extern void check_devanon(void); | 52 | extern void check_devanon(void); |
53 | extern int init_mem_user(void); | 53 | extern int init_mem_user(void); |
54 | extern int create_mem_file(unsigned long len); | ||
55 | extern void setup_memory(void *entry); | 54 | extern void setup_memory(void *entry); |
56 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); | 55 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); |
57 | extern int init_maps(unsigned long physmem, unsigned long iomem, | 56 | extern int init_maps(unsigned long physmem, unsigned long iomem, |
@@ -64,20 +63,6 @@ extern unsigned long phys_offset(unsigned long phys); | |||
64 | extern void unmap_physmem(void); | 63 | extern void unmap_physmem(void); |
65 | extern void map_memory(unsigned long virt, unsigned long phys, | 64 | extern void map_memory(unsigned long virt, unsigned long phys, |
66 | unsigned long len, int r, int w, int x); | 65 | unsigned long len, int r, int w, int x); |
67 | extern int protect_memory(unsigned long addr, unsigned long len, | ||
68 | int r, int w, int x, int must_succeed); | ||
69 | extern unsigned long get_kmem_end(void); | 66 | extern unsigned long get_kmem_end(void); |
70 | extern void check_tmpexec(void); | ||
71 | 67 | ||
72 | #endif | 68 | #endif |
73 | |||
74 | /* | ||
75 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
76 | * Emacs will notice this stuff at the end of the file and automatically | ||
77 | * adjust the settings for this buffer only. This must remain at the end | ||
78 | * of the file. | ||
79 | * --------------------------------------------------------------------------- | ||
80 | * Local variables: | ||
81 | * c-file-style: "linux" | ||
82 | * End: | ||
83 | */ | ||
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 4c362458052c..6f766e1faecc 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -157,6 +157,13 @@ extern int os_lock_file(int fd, int excl); | |||
157 | extern void os_early_checks(void); | 157 | extern void os_early_checks(void); |
158 | extern int can_do_skas(void); | 158 | extern int can_do_skas(void); |
159 | 159 | ||
160 | /* Make sure they are clear when running in TT mode. Required by | ||
161 | * SEGV_MAYBE_FIXABLE */ | ||
162 | #define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0) | ||
163 | |||
164 | /* mem.c */ | ||
165 | extern int create_mem_file(unsigned long len); | ||
166 | |||
160 | /* process.c */ | 167 | /* process.c */ |
161 | extern unsigned long os_process_pc(int pid); | 168 | extern unsigned long os_process_pc(int pid); |
162 | extern int os_process_parent(int pid); | 169 | extern int os_process_parent(int pid); |
@@ -181,6 +188,8 @@ extern unsigned long long os_usecs(void); | |||
181 | /* tt.c | 188 | /* tt.c |
182 | * for tt mode only (will be deleted in future...) | 189 | * for tt mode only (will be deleted in future...) |
183 | */ | 190 | */ |
191 | extern int protect_memory(unsigned long addr, unsigned long len, | ||
192 | int r, int w, int x, int must_succeed); | ||
184 | extern void forward_pending_sigio(int target); | 193 | extern void forward_pending_sigio(int target); |
185 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, | 194 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, |
186 | int clone_flags, int (*tramp)(void *)); | 195 | int clone_flags, int (*tramp)(void *)); |
diff --git a/arch/um/include/skas_ptregs.h b/arch/um/include/skas_ptregs.h new file mode 100644 index 000000000000..73db19e9c077 --- /dev/null +++ b/arch/um/include/skas_ptregs.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __SKAS_PT_REGS_ | ||
2 | #define __SKAS_PT_REGS_ | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/sysdep-i386/sc.h b/arch/um/include/sysdep-i386/sc.h new file mode 100644 index 000000000000..c57d1780ad37 --- /dev/null +++ b/arch/um/include/sysdep-i386/sc.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __SYSDEP_I386_SC_H | ||
2 | #define __SYSDEP_I386_SC_H | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #define SC_OFFSET(sc, field) \ | ||
7 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
8 | #define SC_FP_OFFSET(sc, field) \ | ||
9 | *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) | ||
10 | #define SC_FP_OFFSET_PTR(sc, field, type) \ | ||
11 | ((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) | ||
12 | |||
13 | #define SC_IP(sc) SC_OFFSET(sc, SC_IP) | ||
14 | #define SC_SP(sc) SC_OFFSET(sc, SC_SP) | ||
15 | #define SC_FS(sc) SC_OFFSET(sc, SC_FS) | ||
16 | #define SC_GS(sc) SC_OFFSET(sc, SC_GS) | ||
17 | #define SC_DS(sc) SC_OFFSET(sc, SC_DS) | ||
18 | #define SC_ES(sc) SC_OFFSET(sc, SC_ES) | ||
19 | #define SC_SS(sc) SC_OFFSET(sc, SC_SS) | ||
20 | #define SC_CS(sc) SC_OFFSET(sc, SC_CS) | ||
21 | #define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) | ||
22 | #define SC_EAX(sc) SC_OFFSET(sc, SC_EAX) | ||
23 | #define SC_EBX(sc) SC_OFFSET(sc, SC_EBX) | ||
24 | #define SC_ECX(sc) SC_OFFSET(sc, SC_ECX) | ||
25 | #define SC_EDX(sc) SC_OFFSET(sc, SC_EDX) | ||
26 | #define SC_EDI(sc) SC_OFFSET(sc, SC_EDI) | ||
27 | #define SC_ESI(sc) SC_OFFSET(sc, SC_ESI) | ||
28 | #define SC_EBP(sc) SC_OFFSET(sc, SC_EBP) | ||
29 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
30 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
31 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
32 | #define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE) | ||
33 | #define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) | ||
34 | #define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW) | ||
35 | #define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW) | ||
36 | #define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG) | ||
37 | #define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF) | ||
38 | #define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL) | ||
39 | #define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF) | ||
40 | #define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL) | ||
41 | #define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate) | ||
42 | #define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void) | ||
43 | |||
44 | #endif | ||
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h index 1fe729265167..23fd2644d7ed 100644 --- a/arch/um/include/sysdep-i386/sigcontext.h +++ b/arch/um/include/sysdep-i386/sigcontext.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #ifndef __SYS_SIGCONTEXT_I386_H | 6 | #ifndef __SYS_SIGCONTEXT_I386_H |
7 | #define __SYS_SIGCONTEXT_I386_H | 7 | #define __SYS_SIGCONTEXT_I386_H |
8 | 8 | ||
9 | #include "uml-config.h" | ||
9 | #include <sysdep/sc.h> | 10 | #include <sysdep/sc.h> |
10 | 11 | ||
11 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) | 12 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) |
@@ -26,7 +27,14 @@ | |||
26 | #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) | 27 | #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) |
27 | 28 | ||
28 | /* This is Page Fault */ | 29 | /* This is Page Fault */ |
29 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) | 30 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) |
31 | |||
32 | /* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */ | ||
33 | #ifdef UML_CONFIG_MODE_SKAS | ||
34 | #define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo) | ||
35 | #else | ||
36 | #define SEGV_MAYBE_FIXABLE(fi) 0 | ||
37 | #endif | ||
30 | 38 | ||
31 | extern unsigned long *sc_sigmask(void *sc_ptr); | 39 | extern unsigned long *sc_sigmask(void *sc_ptr); |
32 | extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); | 40 | extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); |
diff --git a/arch/um/include/sysdep-i386/thread.h b/arch/um/include/sysdep-i386/thread.h new file mode 100644 index 000000000000..e2bd6bae8b8a --- /dev/null +++ b/arch/um/include/sysdep-i386/thread.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __UM_THREAD_H | ||
2 | #define __UM_THREAD_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS])) | ||
7 | #ifdef CONFIG_MODE_TT | ||
8 | #define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID])) | ||
9 | #endif | ||
10 | |||
11 | #endif | ||
diff --git a/arch/um/include/sysdep-x86_64/sc.h b/arch/um/include/sysdep-x86_64/sc.h new file mode 100644 index 000000000000..a160d9fcc596 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/sc.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef __SYSDEP_X86_64_SC_H | ||
2 | #define __SYSDEP_X86_64_SC_H | ||
3 | |||
4 | /* Copyright (C) 2003 - 2004 PathScale, Inc | ||
5 | * Released under the GPL | ||
6 | */ | ||
7 | |||
8 | #include <user_constants.h> | ||
9 | |||
10 | #define SC_OFFSET(sc, field) \ | ||
11 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
12 | |||
13 | #define SC_RBX(sc) SC_OFFSET(sc, SC_RBX) | ||
14 | #define SC_RCX(sc) SC_OFFSET(sc, SC_RCX) | ||
15 | #define SC_RDX(sc) SC_OFFSET(sc, SC_RDX) | ||
16 | #define SC_RSI(sc) SC_OFFSET(sc, SC_RSI) | ||
17 | #define SC_RDI(sc) SC_OFFSET(sc, SC_RDI) | ||
18 | #define SC_RBP(sc) SC_OFFSET(sc, SC_RBP) | ||
19 | #define SC_RAX(sc) SC_OFFSET(sc, SC_RAX) | ||
20 | #define SC_R8(sc) SC_OFFSET(sc, SC_R8) | ||
21 | #define SC_R9(sc) SC_OFFSET(sc, SC_R9) | ||
22 | #define SC_R10(sc) SC_OFFSET(sc, SC_R10) | ||
23 | #define SC_R11(sc) SC_OFFSET(sc, SC_R11) | ||
24 | #define SC_R12(sc) SC_OFFSET(sc, SC_R12) | ||
25 | #define SC_R13(sc) SC_OFFSET(sc, SC_R13) | ||
26 | #define SC_R14(sc) SC_OFFSET(sc, SC_R14) | ||
27 | #define SC_R15(sc) SC_OFFSET(sc, SC_R15) | ||
28 | #define SC_IP(sc) SC_OFFSET(sc, SC_IP) | ||
29 | #define SC_SP(sc) SC_OFFSET(sc, SC_SP) | ||
30 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
31 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
32 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
33 | #define SC_CS(sc) SC_OFFSET(sc, SC_CS) | ||
34 | #define SC_FS(sc) SC_OFFSET(sc, SC_FS) | ||
35 | #define SC_GS(sc) SC_OFFSET(sc, SC_GS) | ||
36 | #define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) | ||
37 | #define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) | ||
38 | #if 0 | ||
39 | #define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX) | ||
40 | #define SC_DS(sc) SC_OFFSET(sc, SC_DS) | ||
41 | #define SC_ES(sc) SC_OFFSET(sc, SC_ES) | ||
42 | #define SC_SS(sc) SC_OFFSET(sc, SC_SS) | ||
43 | #endif | ||
44 | |||
45 | #endif | ||
diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/include/sysdep-x86_64/sigcontext.h index 2a78260d15a0..41073235e7ad 100644 --- a/arch/um/include/sysdep-x86_64/sigcontext.h +++ b/arch/um/include/sysdep-x86_64/sigcontext.h | |||
@@ -31,7 +31,10 @@ | |||
31 | #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) |
32 | 32 | ||
33 | /* This is Page Fault */ | 33 | /* This is Page Fault */ |
34 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) | 34 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) |
35 | |||
36 | /* No broken SKAS API, which doesn't pass trap_no, here. */ | ||
37 | #define SEGV_MAYBE_FIXABLE(fi) 0 | ||
35 | 38 | ||
36 | extern unsigned long *sc_sigmask(void *sc_ptr); | 39 | extern unsigned long *sc_sigmask(void *sc_ptr); |
37 | 40 | ||
diff --git a/arch/um/include/sysdep-x86_64/thread.h b/arch/um/include/sysdep-x86_64/thread.h new file mode 100644 index 000000000000..6a76a7f3683f --- /dev/null +++ b/arch/um/include/sysdep-x86_64/thread.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __UM_THREAD_H | ||
2 | #define __UM_THREAD_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #ifdef CONFIG_MODE_TT | ||
7 | #define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID])) | ||
8 | #endif | ||
9 | |||
10 | #endif | ||
diff --git a/arch/um/include/task.h b/arch/um/include/task.h new file mode 100644 index 000000000000..6375ba7203c9 --- /dev/null +++ b/arch/um/include/task.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __TASK_H | ||
2 | #define __TASK_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) | ||
7 | #define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) | ||
8 | |||
9 | #endif | ||
diff --git a/arch/um/include/user.h b/arch/um/include/user.h index 57ee9e261228..0f865ef46918 100644 --- a/arch/um/include/user.h +++ b/arch/um/include/user.h | |||
@@ -14,7 +14,9 @@ extern void *um_kmalloc_atomic(int size); | |||
14 | extern void kfree(void *ptr); | 14 | extern void kfree(void *ptr); |
15 | extern int in_aton(char *str); | 15 | extern int in_aton(char *str); |
16 | extern int open_gdb_chan(void); | 16 | extern int open_gdb_chan(void); |
17 | extern int strlcpy(char *, const char *, int); | 17 | /* These use size_t, however unsigned long is correct on both i386 and x86_64. */ |
18 | extern unsigned long strlcpy(char *, const char *, unsigned long); | ||
19 | extern unsigned long strlcat(char *, const char *, unsigned long); | ||
18 | extern void *um_vmalloc(int size); | 20 | extern void *um_vmalloc(int size); |
19 | extern void vfree(void *ptr); | 21 | extern void vfree(void *ptr); |
20 | 22 | ||
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 614b8ebeb0ed..1a0001b3850c 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # | 1 | # |
2 | # Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | # Copyright (C) 2002 Jeff Dike (jdike@karaya.com) |
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
@@ -7,11 +7,11 @@ extra-y := vmlinux.lds | |||
7 | clean-files := | 7 | clean-files := |
8 | 8 | ||
9 | obj-y = config.o exec_kern.o exitcode.o \ | 9 | obj-y = config.o exec_kern.o exitcode.o \ |
10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \ | 10 | helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o physmem.o \ |
11 | physmem.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
12 | sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o \ | 12 | signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ |
13 | tempfile.o time.o time_kern.o tlb.o trap_kern.o trap_user.o \ | 13 | time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \ |
14 | uaccess_user.o um_arch.o umid.o user_util.o | 14 | umid.o user_util.o |
15 | 15 | ||
16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o | 16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
17 | obj-$(CONFIG_GPROF) += gprof_syms.o | 17 | obj-$(CONFIG_GPROF) += gprof_syms.o |
@@ -24,8 +24,8 @@ obj-$(CONFIG_MODE_SKAS) += skas/ | |||
24 | 24 | ||
25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | 25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o |
26 | 26 | ||
27 | USER_OBJS := $(user-objs-y) config.o helper.o main.o tempfile.o time.o \ | 27 | USER_OBJS := $(user-objs-y) config.o helper.o main.o time.o tty_log.o umid.o \ |
28 | tty_log.o umid.o user_util.o | 28 | user_util.o |
29 | 29 | ||
30 | include arch/um/scripts/Makefile.rules | 30 | include arch/um/scripts/Makefile.rules |
31 | 31 | ||
diff --git a/arch/um/kernel/helper.c b/arch/um/kernel/helper.c index f83e1e8e2392..33fb0bd3b11a 100644 --- a/arch/um/kernel/helper.c +++ b/arch/um/kernel/helper.c | |||
@@ -85,8 +85,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
85 | data.fd = fds[1]; | 85 | data.fd = fds[1]; |
86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); | 86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); |
87 | if(pid < 0){ | 87 | if(pid < 0){ |
88 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
89 | ret = -errno; | 88 | ret = -errno; |
89 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
90 | goto out_close; | 90 | goto out_close; |
91 | } | 91 | } |
92 | 92 | ||
@@ -122,7 +122,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
122 | unsigned long *stack_out, int stack_order) | 122 | unsigned long *stack_out, int stack_order) |
123 | { | 123 | { |
124 | unsigned long stack, sp; | 124 | unsigned long stack, sp; |
125 | int pid, status; | 125 | int pid, status, err; |
126 | 126 | ||
127 | stack = alloc_stack(stack_order, um_in_interrupt()); | 127 | stack = alloc_stack(stack_order, um_in_interrupt()); |
128 | if(stack == 0) return(-ENOMEM); | 128 | if(stack == 0) return(-ENOMEM); |
@@ -130,16 +130,18 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
130 | sp = stack + (page_size() << stack_order) - sizeof(void *); | 130 | sp = stack + (page_size() << stack_order) - sizeof(void *); |
131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); | 131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
132 | if(pid < 0){ | 132 | if(pid < 0){ |
133 | err = -errno; | ||
133 | printk("run_helper_thread : clone failed, errno = %d\n", | 134 | printk("run_helper_thread : clone failed, errno = %d\n", |
134 | errno); | 135 | errno); |
135 | return(-errno); | 136 | return err; |
136 | } | 137 | } |
137 | if(stack_out == NULL){ | 138 | if(stack_out == NULL){ |
138 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); | 139 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); |
139 | if(pid < 0){ | 140 | if(pid < 0){ |
141 | err = -errno; | ||
140 | printk("run_helper_thread - wait failed, errno = %d\n", | 142 | printk("run_helper_thread - wait failed, errno = %d\n", |
141 | errno); | 143 | errno); |
142 | pid = -errno; | 144 | pid = err; |
143 | } | 145 | } |
144 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) | 146 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) |
145 | printk("run_helper_thread - thread returned status " | 147 | printk("run_helper_thread - thread returned status " |
@@ -156,8 +158,8 @@ int helper_wait(int pid) | |||
156 | 158 | ||
157 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); | 159 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); |
158 | if(ret < 0){ | 160 | if(ret < 0){ |
161 | ret = -errno; | ||
159 | printk("helper_wait : waitpid failed, errno = %d\n", errno); | 162 | printk("helper_wait : waitpid failed, errno = %d\n", errno); |
160 | return(-errno); | ||
161 | } | 163 | } |
162 | return(ret); | 164 | return(ret); |
163 | } | 165 | } |
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c index cd7c85be0a1b..49ed5ddf0704 100644 --- a/arch/um/kernel/init_task.c +++ b/arch/um/kernel/init_task.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "asm/pgtable.h" | 13 | #include "asm/pgtable.h" |
14 | #include "user_util.h" | 14 | #include "user_util.h" |
15 | #include "mem_user.h" | 15 | #include "mem_user.h" |
16 | #include "os.h" | ||
16 | 17 | ||
17 | static struct fs_struct init_fs = INIT_FS; | 18 | static struct fs_struct init_fs = INIT_FS; |
18 | struct mm_struct init_mm = INIT_MM(init_mm); | 19 | struct mm_struct init_mm = INIT_MM(init_mm); |
@@ -45,8 +46,8 @@ __attribute__((__section__(".data.init_task"))) = | |||
45 | 46 | ||
46 | void unprotect_stack(unsigned long stack) | 47 | void unprotect_stack(unsigned long stack) |
47 | { | 48 | { |
48 | protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, | 49 | os_protect_memory((void *) stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, |
49 | 1, 1, 0, 1); | 50 | 1, 1, 0); |
50 | } | 51 | } |
51 | 52 | ||
52 | /* | 53 | /* |
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c index dcd814971995..bbf94bf2921e 100644 --- a/arch/um/kernel/irq.c +++ b/arch/um/kernel/irq.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include "linux/kernel.h" | 9 | #include "linux/kernel.h" |
10 | #include "linux/module.h" | 10 | #include "linux/module.h" |
11 | #include "linux/smp.h" | 11 | #include "linux/smp.h" |
12 | #include "linux/irq.h" | ||
13 | #include "linux/kernel_stat.h" | 12 | #include "linux/kernel_stat.h" |
14 | #include "linux/interrupt.h" | 13 | #include "linux/interrupt.h" |
15 | #include "linux/random.h" | 14 | #include "linux/random.h" |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 64fa062cc119..ea008b031a8f 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) | 2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -19,6 +19,10 @@ | |||
19 | #include "mem_user.h" | 19 | #include "mem_user.h" |
20 | #include "uml_uaccess.h" | 20 | #include "uml_uaccess.h" |
21 | #include "os.h" | 21 | #include "os.h" |
22 | #include "linux/types.h" | ||
23 | #include "linux/string.h" | ||
24 | #include "init.h" | ||
25 | #include "kern_constants.h" | ||
22 | 26 | ||
23 | extern char __binary_start; | 27 | extern char __binary_start; |
24 | 28 | ||
@@ -368,6 +372,16 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) | |||
368 | return pte; | 372 | return pte; |
369 | } | 373 | } |
370 | 374 | ||
375 | struct iomem_region *iomem_regions = NULL; | ||
376 | int iomem_size = 0; | ||
377 | |||
378 | extern int parse_iomem(char *str, int *add) __init; | ||
379 | |||
380 | __uml_setup("iomem=", parse_iomem, | ||
381 | "iomem=<name>,<file>\n" | ||
382 | " Configure <file> as an IO memory region named <name>.\n\n" | ||
383 | ); | ||
384 | |||
371 | /* | 385 | /* |
372 | * Overrides for Emacs so that we follow Linus's tabbing style. | 386 | * Overrides for Emacs so that we follow Linus's tabbing style. |
373 | * Emacs will notice this stuff at the end of the file and automatically | 387 | * Emacs will notice this stuff at the end of the file and automatically |
diff --git a/arch/um/kernel/mem_user.c b/arch/um/kernel/mem_user.c deleted file mode 100644 index 4a663fd434bb..000000000000 --- a/arch/um/kernel/mem_user.c +++ /dev/null | |||
@@ -1,273 +0,0 @@ | |||
1 | /* | ||
2 | * arch/um/kernel/mem_user.c | ||
3 | * | ||
4 | * BRIEF MODULE DESCRIPTION | ||
5 | * user side memory routines for supporting IO memory inside user mode linux | ||
6 | * | ||
7 | * Copyright (C) 2001 RidgeRun, Inc. | ||
8 | * Author: RidgeRun, Inc. | ||
9 | * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
19 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
22 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
23 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | */ | ||
31 | |||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <stddef.h> | ||
35 | #include <stdarg.h> | ||
36 | #include <unistd.h> | ||
37 | #include <errno.h> | ||
38 | #include <string.h> | ||
39 | #include <fcntl.h> | ||
40 | #include <sys/types.h> | ||
41 | #include <sys/mman.h> | ||
42 | #include "kern_util.h" | ||
43 | #include "user.h" | ||
44 | #include "user_util.h" | ||
45 | #include "mem_user.h" | ||
46 | #include "init.h" | ||
47 | #include "os.h" | ||
48 | #include "tempfile.h" | ||
49 | #include "kern_constants.h" | ||
50 | |||
51 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | ||
52 | |||
53 | static int create_tmp_file(unsigned long len) | ||
54 | { | ||
55 | int fd, err; | ||
56 | char zero; | ||
57 | |||
58 | fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); | ||
59 | if(fd < 0) { | ||
60 | os_print_error(fd, "make_tempfile"); | ||
61 | exit(1); | ||
62 | } | ||
63 | |||
64 | err = os_mode_fd(fd, 0777); | ||
65 | if(err < 0){ | ||
66 | os_print_error(err, "os_mode_fd"); | ||
67 | exit(1); | ||
68 | } | ||
69 | err = os_seek_file(fd, len); | ||
70 | if(err < 0){ | ||
71 | os_print_error(err, "os_seek_file"); | ||
72 | exit(1); | ||
73 | } | ||
74 | zero = 0; | ||
75 | err = os_write_file(fd, &zero, 1); | ||
76 | if(err != 1){ | ||
77 | os_print_error(err, "os_write_file"); | ||
78 | exit(1); | ||
79 | } | ||
80 | |||
81 | return(fd); | ||
82 | } | ||
83 | |||
84 | void check_tmpexec(void) | ||
85 | { | ||
86 | void *addr; | ||
87 | int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE); | ||
88 | |||
89 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | ||
90 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | ||
91 | printf("Checking PROT_EXEC mmap in /tmp..."); | ||
92 | fflush(stdout); | ||
93 | if(addr == MAP_FAILED){ | ||
94 | err = errno; | ||
95 | perror("failed"); | ||
96 | if(err == EPERM) | ||
97 | printf("/tmp must be not mounted noexec\n"); | ||
98 | exit(1); | ||
99 | } | ||
100 | printf("OK\n"); | ||
101 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
102 | |||
103 | os_close_file(fd); | ||
104 | } | ||
105 | |||
106 | static int have_devanon = 0; | ||
107 | |||
108 | void check_devanon(void) | ||
109 | { | ||
110 | int fd; | ||
111 | |||
112 | printk("Checking for /dev/anon on the host..."); | ||
113 | fd = open("/dev/anon", O_RDWR); | ||
114 | if(fd < 0){ | ||
115 | printk("Not available (open failed with errno %d)\n", errno); | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | printk("OK\n"); | ||
120 | have_devanon = 1; | ||
121 | } | ||
122 | |||
123 | static int create_anon_file(unsigned long len) | ||
124 | { | ||
125 | void *addr; | ||
126 | int fd; | ||
127 | |||
128 | fd = open("/dev/anon", O_RDWR); | ||
129 | if(fd < 0) { | ||
130 | os_print_error(fd, "opening /dev/anon"); | ||
131 | exit(1); | ||
132 | } | ||
133 | |||
134 | addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); | ||
135 | if(addr == MAP_FAILED){ | ||
136 | perror("mapping physmem file"); | ||
137 | exit(1); | ||
138 | } | ||
139 | munmap(addr, len); | ||
140 | |||
141 | return(fd); | ||
142 | } | ||
143 | |||
144 | int create_mem_file(unsigned long len) | ||
145 | { | ||
146 | int err, fd; | ||
147 | |||
148 | if(have_devanon) | ||
149 | fd = create_anon_file(len); | ||
150 | else fd = create_tmp_file(len); | ||
151 | |||
152 | err = os_set_exec_close(fd, 1); | ||
153 | if(err < 0) | ||
154 | os_print_error(err, "exec_close"); | ||
155 | return(fd); | ||
156 | } | ||
157 | |||
158 | struct iomem_region *iomem_regions = NULL; | ||
159 | int iomem_size = 0; | ||
160 | |||
161 | static int __init parse_iomem(char *str, int *add) | ||
162 | { | ||
163 | struct iomem_region *new; | ||
164 | struct uml_stat buf; | ||
165 | char *file, *driver; | ||
166 | int fd, err, size; | ||
167 | |||
168 | driver = str; | ||
169 | file = strchr(str,','); | ||
170 | if(file == NULL){ | ||
171 | printf("parse_iomem : failed to parse iomem\n"); | ||
172 | goto out; | ||
173 | } | ||
174 | *file = '\0'; | ||
175 | file++; | ||
176 | fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0); | ||
177 | if(fd < 0){ | ||
178 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | ||
179 | goto out; | ||
180 | } | ||
181 | |||
182 | err = os_stat_fd(fd, &buf); | ||
183 | if(err < 0){ | ||
184 | os_print_error(err, "parse_iomem - cannot stat_fd file"); | ||
185 | goto out_close; | ||
186 | } | ||
187 | |||
188 | new = malloc(sizeof(*new)); | ||
189 | if(new == NULL){ | ||
190 | perror("Couldn't allocate iomem_region struct"); | ||
191 | goto out_close; | ||
192 | } | ||
193 | |||
194 | size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1); | ||
195 | |||
196 | *new = ((struct iomem_region) { .next = iomem_regions, | ||
197 | .driver = driver, | ||
198 | .fd = fd, | ||
199 | .size = size, | ||
200 | .phys = 0, | ||
201 | .virt = 0 }); | ||
202 | iomem_regions = new; | ||
203 | iomem_size += new->size + UM_KERN_PAGE_SIZE; | ||
204 | |||
205 | return(0); | ||
206 | out_close: | ||
207 | os_close_file(fd); | ||
208 | out: | ||
209 | return(1); | ||
210 | } | ||
211 | |||
212 | __uml_setup("iomem=", parse_iomem, | ||
213 | "iomem=<name>,<file>\n" | ||
214 | " Configure <file> as an IO memory region named <name>.\n\n" | ||
215 | ); | ||
216 | |||
217 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, | ||
218 | int must_succeed) | ||
219 | { | ||
220 | int err; | ||
221 | |||
222 | err = os_protect_memory((void *) addr, len, r, w, x); | ||
223 | if(err < 0){ | ||
224 | if(must_succeed) | ||
225 | panic("protect failed, err = %d", -err); | ||
226 | else return(err); | ||
227 | } | ||
228 | return(0); | ||
229 | } | ||
230 | |||
231 | #if 0 | ||
232 | /* Debugging facility for dumping stuff out to the host, avoiding the timing | ||
233 | * problems that come with printf and breakpoints. | ||
234 | * Enable in case of emergency. | ||
235 | */ | ||
236 | |||
237 | int logging = 1; | ||
238 | int logging_fd = -1; | ||
239 | |||
240 | int logging_line = 0; | ||
241 | char logging_buf[512]; | ||
242 | |||
243 | void log(char *fmt, ...) | ||
244 | { | ||
245 | va_list ap; | ||
246 | struct timeval tv; | ||
247 | struct openflags flags; | ||
248 | |||
249 | if(logging == 0) return; | ||
250 | if(logging_fd < 0){ | ||
251 | flags = of_create(of_trunc(of_rdwr(OPENFLAGS()))); | ||
252 | logging_fd = os_open_file("log", flags, 0644); | ||
253 | } | ||
254 | gettimeofday(&tv, NULL); | ||
255 | sprintf(logging_buf, "%d\t %u.%u ", logging_line++, tv.tv_sec, | ||
256 | tv.tv_usec); | ||
257 | va_start(ap, fmt); | ||
258 | vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap); | ||
259 | va_end(ap); | ||
260 | write(logging_fd, logging_buf, strlen(logging_buf)); | ||
261 | } | ||
262 | #endif | ||
263 | |||
264 | /* | ||
265 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
266 | * Emacs will notice this stuff at the end of the file and automatically | ||
267 | * adjust the settings for this buffer only. This must remain at the end | ||
268 | * of the file. | ||
269 | * --------------------------------------------------------------------------- | ||
270 | * Local variables: | ||
271 | * c-file-style: "linux" | ||
272 | * End: | ||
273 | */ | ||
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index c23d8a08d0ff..ea65db679e9c 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -82,7 +82,8 @@ unsigned long alloc_stack(int order, int atomic) | |||
82 | unsigned long page; | 82 | unsigned long page; |
83 | int flags = GFP_KERNEL; | 83 | int flags = GFP_KERNEL; |
84 | 84 | ||
85 | if(atomic) flags |= GFP_ATOMIC; | 85 | if (atomic) |
86 | flags = GFP_ATOMIC; | ||
86 | page = __get_free_pages(flags, order); | 87 | page = __get_free_pages(flags, order); |
87 | if(page == 0) | 88 | if(page == 0) |
88 | return(0); | 89 | return(0); |
@@ -113,8 +114,23 @@ void set_current(void *t) | |||
113 | 114 | ||
114 | void *_switch_to(void *prev, void *next, void *last) | 115 | void *_switch_to(void *prev, void *next, void *last) |
115 | { | 116 | { |
116 | return(CHOOSE_MODE(switch_to_tt(prev, next), | 117 | struct task_struct *from = prev; |
117 | switch_to_skas(prev, next))); | 118 | struct task_struct *to= next; |
119 | |||
120 | to->thread.prev_sched = from; | ||
121 | set_current(to); | ||
122 | |||
123 | do { | ||
124 | current->thread.saved_task = NULL ; | ||
125 | CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next); | ||
126 | if(current->thread.saved_task) | ||
127 | show_regs(&(current->thread.regs)); | ||
128 | next= current->thread.saved_task; | ||
129 | prev= current; | ||
130 | } while(current->thread.saved_task); | ||
131 | |||
132 | return(current->thread.prev_sched); | ||
133 | |||
118 | } | 134 | } |
119 | 135 | ||
120 | void interrupt_end(void) | 136 | void interrupt_end(void) |
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c index e89218958f38..a52751108aa1 100644 --- a/arch/um/kernel/sigio_user.c +++ b/arch/um/kernel/sigio_user.c | |||
@@ -340,7 +340,7 @@ static int setup_initial_poll(int fd) | |||
340 | { | 340 | { |
341 | struct pollfd *p; | 341 | struct pollfd *p; |
342 | 342 | ||
343 | p = um_kmalloc(sizeof(struct pollfd)); | 343 | p = um_kmalloc_atomic(sizeof(struct pollfd)); |
344 | if(p == NULL){ | 344 | if(p == NULL){ |
345 | printk("setup_initial_poll : failed to allocate poll\n"); | 345 | printk("setup_initial_poll : failed to allocate poll\n"); |
346 | return(-1); | 346 | return(-1); |
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile index db36c7c95940..8de471b59c1c 100644 --- a/arch/um/kernel/skas/Makefile +++ b/arch/um/kernel/skas/Makefile | |||
@@ -6,8 +6,6 @@ | |||
6 | obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ | 6 | obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ |
7 | syscall.o tlb.o trap_user.o uaccess.o | 7 | syscall.o tlb.o trap_user.o uaccess.o |
8 | 8 | ||
9 | subdir- := util | ||
10 | |||
11 | USER_OBJS := process.o clone.o | 9 | USER_OBJS := process.o clone.o |
12 | 10 | ||
13 | include arch/um/scripts/Makefile.rules | 11 | include arch/um/scripts/Makefile.rules |
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h index e48490028111..c97a80dfe370 100644 --- a/arch/um/kernel/skas/include/mode_kern-skas.h +++ b/arch/um/kernel/skas/include/mode_kern-skas.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
12 | 12 | ||
13 | extern void flush_thread_skas(void); | 13 | extern void flush_thread_skas(void); |
14 | extern void *switch_to_skas(void *prev, void *next); | 14 | extern void switch_to_skas(void *prev, void *next); |
15 | extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, | 15 | extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, |
16 | unsigned long esp); | 16 | unsigned long esp); |
17 | extern int copy_thread_skas(int nr, unsigned long clone_flags, | 17 | extern int copy_thread_skas(int nr, unsigned long clone_flags, |
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h index 6ee3f3902e68..7da0c2def0ef 100644 --- a/arch/um/kernel/skas/include/uaccess-skas.h +++ b/arch/um/kernel/skas/include/uaccess-skas.h | |||
@@ -18,12 +18,6 @@ | |||
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 verify_area_skas(int type, const void __user * addr, | ||
22 | unsigned long size) | ||
23 | { | ||
24 | return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); | ||
25 | } | ||
26 | |||
27 | extern int copy_from_user_skas(void *to, const void __user *from, int n); | 21 | extern int copy_from_user_skas(void *to, const void __user *from, int n); |
28 | extern int copy_to_user_skas(void __user *to, const void *from, int n); | 22 | extern int copy_to_user_skas(void __user *to, const void *from, int n); |
29 | extern int strncpy_from_user_skas(char *dst, const char __user *src, int count); | 23 | extern int strncpy_from_user_skas(char *dst, const char __user *src, int count); |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index 3d1b227226e6..efe92e8aa2a9 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "proc_mm.h" | 24 | #include "proc_mm.h" |
25 | #include "registers.h" | 25 | #include "registers.h" |
26 | 26 | ||
27 | void *switch_to_skas(void *prev, void *next) | 27 | void switch_to_skas(void *prev, void *next) |
28 | { | 28 | { |
29 | struct task_struct *from, *to; | 29 | struct task_struct *from, *to; |
30 | 30 | ||
@@ -35,16 +35,11 @@ void *switch_to_skas(void *prev, void *next) | |||
35 | if(current->pid == 0) | 35 | if(current->pid == 0) |
36 | switch_timers(0); | 36 | switch_timers(0); |
37 | 37 | ||
38 | to->thread.prev_sched = from; | ||
39 | set_current(to); | ||
40 | |||
41 | switch_threads(&from->thread.mode.skas.switch_buf, | 38 | switch_threads(&from->thread.mode.skas.switch_buf, |
42 | to->thread.mode.skas.switch_buf); | 39 | to->thread.mode.skas.switch_buf); |
43 | 40 | ||
44 | if(current->pid == 0) | 41 | if(current->pid == 0) |
45 | switch_timers(1); | 42 | switch_timers(1); |
46 | |||
47 | return(current->thread.prev_sched); | ||
48 | } | 43 | } |
49 | 44 | ||
50 | extern void schedule_tail(struct task_struct *prev); | 45 | extern void schedule_tail(struct task_struct *prev); |
diff --git a/arch/um/kernel/skas/util/Makefile b/arch/um/kernel/skas/util/Makefile deleted file mode 100644 index f7b7eba83340..000000000000 --- a/arch/um/kernel/skas/util/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | hostprogs-y := mk_ptregs | ||
2 | always := $(hostprogs-y) | ||
3 | |||
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 deleted file mode 100644 index 1f96e1eeb8a7..000000000000 --- a/arch/um/kernel/skas/util/mk_ptregs-i386.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <user-offsets.h> | ||
3 | |||
4 | #define SHOW(name) printf("#define %s %d\n", #name, name) | ||
5 | |||
6 | int main(int argc, char **argv) | ||
7 | { | ||
8 | printf("/* Automatically generated by " | ||
9 | "arch/um/kernel/skas/util/mk_ptregs */\n"); | ||
10 | printf("\n"); | ||
11 | printf("#ifndef __SKAS_PT_REGS_\n"); | ||
12 | printf("#define __SKAS_PT_REGS_\n"); | ||
13 | printf("\n"); | ||
14 | SHOW(HOST_FRAME_SIZE); | ||
15 | SHOW(HOST_FP_SIZE); | ||
16 | SHOW(HOST_XFP_SIZE); | ||
17 | |||
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); | ||
34 | |||
35 | printf("\n"); | ||
36 | printf("#endif\n"); | ||
37 | return(0); | ||
38 | } | ||
39 | |||
40 | /* | ||
41 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
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/kernel/skas/util/mk_ptregs-x86_64.c b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c deleted file mode 100644 index 5fccbfe35f78..000000000000 --- a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <stdio.h> | ||
8 | #include <user-offsets.h> | ||
9 | |||
10 | #define SHOW(name) \ | ||
11 | printf("#define %s (%d / sizeof(unsigned long))\n", #name, name) | ||
12 | |||
13 | int main(int argc, char **argv) | ||
14 | { | ||
15 | printf("/* Automatically generated by " | ||
16 | "arch/um/kernel/skas/util/mk_ptregs */\n"); | ||
17 | printf("\n"); | ||
18 | printf("#ifndef __SKAS_PT_REGS_\n"); | ||
19 | printf("#define __SKAS_PT_REGS_\n"); | ||
20 | SHOW(HOST_FRAME_SIZE); | ||
21 | SHOW(HOST_RBX); | ||
22 | SHOW(HOST_RCX); | ||
23 | SHOW(HOST_RDI); | ||
24 | SHOW(HOST_RSI); | ||
25 | SHOW(HOST_RDX); | ||
26 | SHOW(HOST_RBP); | ||
27 | SHOW(HOST_RAX); | ||
28 | SHOW(HOST_R8); | ||
29 | SHOW(HOST_R9); | ||
30 | SHOW(HOST_R10); | ||
31 | SHOW(HOST_R11); | ||
32 | SHOW(HOST_R12); | ||
33 | SHOW(HOST_R13); | ||
34 | SHOW(HOST_R14); | ||
35 | SHOW(HOST_R15); | ||
36 | SHOW(HOST_ORIG_RAX); | ||
37 | SHOW(HOST_CS); | ||
38 | SHOW(HOST_SS); | ||
39 | SHOW(HOST_EFLAGS); | ||
40 | #if 0 | ||
41 | SHOW(HOST_FS); | ||
42 | SHOW(HOST_GS); | ||
43 | SHOW(HOST_DS); | ||
44 | SHOW(HOST_ES); | ||
45 | #endif | ||
46 | |||
47 | SHOW(HOST_IP); | ||
48 | SHOW(HOST_SP); | ||
49 | printf("#define HOST_FP_SIZE 0\n"); | ||
50 | printf("#define HOST_XFP_SIZE 0\n"); | ||
51 | printf("\n"); | ||
52 | printf("\n"); | ||
53 | printf("#endif\n"); | ||
54 | return(0); | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
59 | * Emacs will notice this stuff at the end of the file and automatically | ||
60 | * adjust the settings for this buffer only. This must remain at the end | ||
61 | * of the file. | ||
62 | * --------------------------------------------------------------------------- | ||
63 | * Local variables: | ||
64 | * c-file-style: "linux" | ||
65 | * End: | ||
66 | */ | ||
diff --git a/arch/um/kernel/tempfile.c b/arch/um/kernel/tempfile.c deleted file mode 100644 index b1674bc1395d..000000000000 --- a/arch/um/kernel/tempfile.c +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <unistd.h> | ||
9 | #include <string.h> | ||
10 | #include <errno.h> | ||
11 | #include <sys/param.h> | ||
12 | #include "init.h" | ||
13 | |||
14 | /* Modified from create_mem_file and start_debugger */ | ||
15 | static char *tempdir = NULL; | ||
16 | |||
17 | static void __init find_tempdir(void) | ||
18 | { | ||
19 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | ||
20 | int i; | ||
21 | char *dir = NULL; | ||
22 | |||
23 | if(tempdir != NULL) return; /* We've already been called */ | ||
24 | for(i = 0; dirs[i]; i++){ | ||
25 | dir = getenv(dirs[i]); | ||
26 | if((dir != NULL) && (*dir != '\0')) | ||
27 | break; | ||
28 | } | ||
29 | if((dir == NULL) || (*dir == '\0')) | ||
30 | dir = "/tmp"; | ||
31 | |||
32 | tempdir = malloc(strlen(dir) + 2); | ||
33 | if(tempdir == NULL){ | ||
34 | fprintf(stderr, "Failed to malloc tempdir, " | ||
35 | "errno = %d\n", errno); | ||
36 | return; | ||
37 | } | ||
38 | strcpy(tempdir, dir); | ||
39 | strcat(tempdir, "/"); | ||
40 | } | ||
41 | |||
42 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | ||
43 | { | ||
44 | char tempname[MAXPATHLEN]; | ||
45 | int fd; | ||
46 | |||
47 | find_tempdir(); | ||
48 | if (*template != '/') | ||
49 | strcpy(tempname, tempdir); | ||
50 | else | ||
51 | *tempname = 0; | ||
52 | strcat(tempname, template); | ||
53 | fd = mkstemp(tempname); | ||
54 | if(fd < 0){ | ||
55 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | ||
56 | strerror(errno)); | ||
57 | return -1; | ||
58 | } | ||
59 | if(do_unlink && (unlink(tempname) < 0)){ | ||
60 | perror("unlink"); | ||
61 | return -1; | ||
62 | } | ||
63 | if(out_tempname){ | ||
64 | *out_tempname = strdup(tempname); | ||
65 | if(*out_tempname == NULL){ | ||
66 | perror("strdup"); | ||
67 | return -1; | ||
68 | } | ||
69 | } | ||
70 | return(fd); | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
75 | * Emacs will notice this stuff at the end of the file and automatically | ||
76 | * adjust the settings for this buffer only. This must remain at the end | ||
77 | * of the file. | ||
78 | * --------------------------------------------------------------------------- | ||
79 | * Local variables: | ||
80 | * c-file-style: "linux" | ||
81 | * End: | ||
82 | */ | ||
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index 80ed6188e8a2..f5b0636f9ad7 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c | |||
@@ -193,12 +193,12 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr, | |||
193 | r = pte_read(*npte); | 193 | r = pte_read(*npte); |
194 | w = pte_write(*npte); | 194 | w = pte_write(*npte); |
195 | x = pte_exec(*npte); | 195 | x = pte_exec(*npte); |
196 | if(!pte_dirty(*npte)) | 196 | if (!pte_young(*npte)) { |
197 | w = 0; | 197 | r = 0; |
198 | if(!pte_young(*npte)){ | 198 | w = 0; |
199 | r = 0; | 199 | } else if (!pte_dirty(*npte)) { |
200 | w = 0; | 200 | w = 0; |
201 | } | 201 | } |
202 | if(force || pte_newpage(*npte)){ | 202 | if(force || pte_newpage(*npte)){ |
203 | if(pte_present(*npte)) | 203 | if(pte_present(*npte)) |
204 | ret = add_mmap(addr, | 204 | ret = add_mmap(addr, |
@@ -307,7 +307,7 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end) | |||
307 | } | 307 | } |
308 | else if(pte_newprot(*pte)){ | 308 | else if(pte_newprot(*pte)){ |
309 | updated = 1; | 309 | updated = 1; |
310 | protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1); | 310 | os_protect_memory((void *) addr, PAGE_SIZE, 1, 1, 1); |
311 | } | 311 | } |
312 | addr += PAGE_SIZE; | 312 | addr += PAGE_SIZE; |
313 | } | 313 | } |
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c index 87cc6fd76ced..95c8f8733baf 100644 --- a/arch/um/kernel/trap_kern.c +++ b/arch/um/kernel/trap_kern.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include "asm/a.out.h" | 18 | #include "asm/a.out.h" |
19 | #include "asm/current.h" | 19 | #include "asm/current.h" |
20 | #include "asm/irq.h" | 20 | #include "asm/irq.h" |
21 | #include "sysdep/sigcontext.h" | ||
21 | #include "user_util.h" | 22 | #include "user_util.h" |
22 | #include "kern_util.h" | 23 | #include "kern_util.h" |
23 | #include "kern.h" | 24 | #include "kern.h" |
@@ -25,6 +26,9 @@ | |||
25 | #include "mconsole_kern.h" | 26 | #include "mconsole_kern.h" |
26 | #include "mem.h" | 27 | #include "mem.h" |
27 | #include "mem_kern.h" | 28 | #include "mem_kern.h" |
29 | #ifdef CONFIG_MODE_SKAS | ||
30 | #include "skas.h" | ||
31 | #endif | ||
28 | 32 | ||
29 | /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ | 33 | /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ |
30 | int handle_page_fault(unsigned long address, unsigned long ip, | 34 | int handle_page_fault(unsigned long address, unsigned long ip, |
@@ -39,6 +43,12 @@ int handle_page_fault(unsigned long address, unsigned long ip, | |||
39 | int err = -EFAULT; | 43 | int err = -EFAULT; |
40 | 44 | ||
41 | *code_out = SEGV_MAPERR; | 45 | *code_out = SEGV_MAPERR; |
46 | |||
47 | /* If the fault was during atomic operation, don't take the fault, just | ||
48 | * fail. */ | ||
49 | if (in_atomic()) | ||
50 | goto out_nosemaphore; | ||
51 | |||
42 | down_read(&mm->mmap_sem); | 52 | down_read(&mm->mmap_sem); |
43 | vma = find_vma(mm, address); | 53 | vma = find_vma(mm, address); |
44 | if(!vma) | 54 | if(!vma) |
@@ -89,6 +99,7 @@ survive: | |||
89 | flush_tlb_page(vma, address); | 99 | flush_tlb_page(vma, address); |
90 | out: | 100 | out: |
91 | up_read(&mm->mmap_sem); | 101 | up_read(&mm->mmap_sem); |
102 | out_nosemaphore: | ||
92 | return(err); | 103 | return(err); |
93 | 104 | ||
94 | /* | 105 | /* |
@@ -125,7 +136,15 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc) | |||
125 | } | 136 | } |
126 | else if(current->mm == NULL) | 137 | else if(current->mm == NULL) |
127 | panic("Segfault with no mm"); | 138 | panic("Segfault with no mm"); |
128 | err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); | 139 | |
140 | if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi)) | ||
141 | err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); | ||
142 | else { | ||
143 | err = -EFAULT; | ||
144 | /* A thread accessed NULL, we get a fault, but CR2 is invalid. | ||
145 | * This code is used in __do_copy_from_user() of TT mode. */ | ||
146 | address = 0; | ||
147 | } | ||
129 | 148 | ||
130 | catcher = current->thread.fault_catcher; | 149 | catcher = current->thread.fault_catcher; |
131 | if(!err) | 150 | if(!err) |
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h index e0ca0e0b2516..2a35b15c5fef 100644 --- a/arch/um/kernel/tt/include/mode_kern-tt.h +++ b/arch/um/kernel/tt/include/mode_kern-tt.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
12 | #include "asm/uaccess.h" | 12 | #include "asm/uaccess.h" |
13 | 13 | ||
14 | extern void *switch_to_tt(void *prev, void *next); | 14 | extern void switch_to_tt(void *prev, void *next); |
15 | extern void flush_thread_tt(void); | 15 | extern void flush_thread_tt(void); |
16 | extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, | 16 | extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, |
17 | unsigned long esp); | 17 | unsigned long esp); |
diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h index aa6db384af80..dc2ebfa8c54f 100644 --- a/arch/um/kernel/tt/include/uaccess-tt.h +++ b/arch/um/kernel/tt/include/uaccess-tt.h | |||
@@ -33,12 +33,6 @@ 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 verify_area_tt(int type, const void __user * addr, | ||
37 | unsigned long size) | ||
38 | { | ||
39 | return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); | ||
40 | } | ||
41 | |||
42 | extern unsigned long get_fault_addr(void); | 36 | extern unsigned long get_fault_addr(void); |
43 | 37 | ||
44 | extern int __do_copy_from_user(void *to, const void *from, int n, | 38 | extern int __do_copy_from_user(void *to, const void *from, int n, |
diff --git a/arch/um/kernel/tt/mem_user.c b/arch/um/kernel/tt/mem_user.c index 3085267459b1..03e589895388 100644 --- a/arch/um/kernel/tt/mem_user.c +++ b/arch/um/kernel/tt/mem_user.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "tt.h" | 12 | #include "tt.h" |
13 | #include "mem_user.h" | 13 | #include "mem_user.h" |
14 | #include "user_util.h" | 14 | #include "user_util.h" |
15 | #include "os.h" | ||
15 | 16 | ||
16 | void remap_data(void *segment_start, void *segment_end, int w) | 17 | void remap_data(void *segment_start, void *segment_end, int w) |
17 | { | 18 | { |
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c index a189a2b92935..cfaa373a6e77 100644 --- a/arch/um/kernel/tt/process_kern.c +++ b/arch/um/kernel/tt/process_kern.c | |||
@@ -23,10 +23,11 @@ | |||
23 | #include "mem_user.h" | 23 | #include "mem_user.h" |
24 | #include "tlb.h" | 24 | #include "tlb.h" |
25 | #include "mode.h" | 25 | #include "mode.h" |
26 | #include "mode_kern.h" | ||
26 | #include "init.h" | 27 | #include "init.h" |
27 | #include "tt.h" | 28 | #include "tt.h" |
28 | 29 | ||
29 | void *switch_to_tt(void *prev, void *next, void *last) | 30 | void switch_to_tt(void *prev, void *next) |
30 | { | 31 | { |
31 | struct task_struct *from, *to, *prev_sched; | 32 | struct task_struct *from, *to, *prev_sched; |
32 | unsigned long flags; | 33 | unsigned long flags; |
@@ -36,8 +37,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
36 | from = prev; | 37 | from = prev; |
37 | to = next; | 38 | to = next; |
38 | 39 | ||
39 | to->thread.prev_sched = from; | ||
40 | |||
41 | cpu = from->thread_info->cpu; | 40 | cpu = from->thread_info->cpu; |
42 | if(cpu == 0) | 41 | if(cpu == 0) |
43 | forward_interrupts(to->thread.mode.tt.extern_pid); | 42 | forward_interrupts(to->thread.mode.tt.extern_pid); |
@@ -53,7 +52,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
53 | forward_pending_sigio(to->thread.mode.tt.extern_pid); | 52 | forward_pending_sigio(to->thread.mode.tt.extern_pid); |
54 | 53 | ||
55 | c = 0; | 54 | c = 0; |
56 | set_current(to); | ||
57 | 55 | ||
58 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); | 56 | err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); |
59 | if(err != sizeof(c)) | 57 | if(err != sizeof(c)) |
@@ -85,8 +83,6 @@ void *switch_to_tt(void *prev, void *next, void *last) | |||
85 | 83 | ||
86 | flush_tlb_all(); | 84 | flush_tlb_all(); |
87 | local_irq_restore(flags); | 85 | local_irq_restore(flags); |
88 | |||
89 | return(current->thread.prev_sched); | ||
90 | } | 86 | } |
91 | 87 | ||
92 | void release_thread_tt(struct task_struct *task) | 88 | void release_thread_tt(struct task_struct *task) |
diff --git a/arch/um/kernel/tt/uaccess_user.c b/arch/um/kernel/tt/uaccess_user.c index f01475512ecb..8c220f054b61 100644 --- a/arch/um/kernel/tt/uaccess_user.c +++ b/arch/um/kernel/tt/uaccess_user.c | |||
@@ -22,8 +22,15 @@ int __do_copy_from_user(void *to, const void *from, int n, | |||
22 | __do_copy, &faulted); | 22 | __do_copy, &faulted); |
23 | TASK_REGS(get_current())->tt = save; | 23 | TASK_REGS(get_current())->tt = save; |
24 | 24 | ||
25 | if(!faulted) return(0); | 25 | if(!faulted) |
26 | else return(n - (fault - (unsigned long) from)); | 26 | return 0; |
27 | else if (fault) | ||
28 | return n - (fault - (unsigned long) from); | ||
29 | else | ||
30 | /* In case of a general protection fault, we don't have the | ||
31 | * fault address, so NULL is used instead. Pretend we didn't | ||
32 | * copy anything. */ | ||
33 | return n; | ||
27 | } | 34 | } |
28 | 35 | ||
29 | static void __do_strncpy(void *dst, const void *src, int count) | 36 | static void __do_strncpy(void *dst, const void *src, int count) |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 09f6f7ce4695..93dc782dc1cc 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -334,6 +334,8 @@ int linux_main(int argc, char **argv) | |||
334 | add_arg(DEFAULT_COMMAND_LINE); | 334 | add_arg(DEFAULT_COMMAND_LINE); |
335 | 335 | ||
336 | os_early_checks(); | 336 | os_early_checks(); |
337 | if (force_tt) | ||
338 | clear_can_do_skas(); | ||
337 | mode_tt = force_tt ? 1 : !can_do_skas(); | 339 | mode_tt = force_tt ? 1 : !can_do_skas(); |
338 | #ifndef CONFIG_MODE_TT | 340 | #ifndef CONFIG_MODE_TT |
339 | if (mode_tt) { | 341 | if (mode_tt) { |
@@ -361,11 +363,6 @@ int linux_main(int argc, char **argv) | |||
361 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, | 363 | uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, |
362 | &host_task_size, &task_size); | 364 | &host_task_size, &task_size); |
363 | 365 | ||
364 | /* Need to check this early because mmapping happens before the | ||
365 | * kernel is running. | ||
366 | */ | ||
367 | check_tmpexec(); | ||
368 | |||
369 | brk_start = (unsigned long) sbrk(0); | 366 | brk_start = (unsigned long) sbrk(0); |
370 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); | 367 | CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); |
371 | /* Increase physical memory size for exec-shield users | 368 | /* Increase physical memory size for exec-shield users |
diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c index 186c28885016..0b21d59ba0cd 100644 --- a/arch/um/kernel/umid.c +++ b/arch/um/kernel/umid.c | |||
@@ -31,6 +31,8 @@ static char *uml_dir = UML_DIR; | |||
31 | /* Changed by set_umid */ | 31 | /* Changed by set_umid */ |
32 | static int umid_is_random = 1; | 32 | static int umid_is_random = 1; |
33 | static int umid_inited = 0; | 33 | static int umid_inited = 0; |
34 | /* Have we created the files? Should we remove them? */ | ||
35 | static int umid_owned = 0; | ||
34 | 36 | ||
35 | static int make_umid(int (*printer)(const char *fmt, ...)); | 37 | static int make_umid(int (*printer)(const char *fmt, ...)); |
36 | 38 | ||
@@ -82,20 +84,21 @@ int __init umid_file_name(char *name, char *buf, int len) | |||
82 | 84 | ||
83 | extern int tracing_pid; | 85 | extern int tracing_pid; |
84 | 86 | ||
85 | static int __init create_pid_file(void) | 87 | static void __init create_pid_file(void) |
86 | { | 88 | { |
87 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; | 89 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; |
88 | char pid[sizeof("nnnnn\0")]; | 90 | char pid[sizeof("nnnnn\0")]; |
89 | int fd, n; | 91 | int fd, n; |
90 | 92 | ||
91 | if(umid_file_name("pid", file, sizeof(file))) return 0; | 93 | if(umid_file_name("pid", file, sizeof(file))) |
94 | return; | ||
92 | 95 | ||
93 | fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), | 96 | fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), |
94 | 0644); | 97 | 0644); |
95 | if(fd < 0){ | 98 | if(fd < 0){ |
96 | printf("Open of machine pid file \"%s\" failed: %s\n", | 99 | printf("Open of machine pid file \"%s\" failed: %s\n", |
97 | file, strerror(-fd)); | 100 | file, strerror(-fd)); |
98 | return 0; | 101 | return; |
99 | } | 102 | } |
100 | 103 | ||
101 | sprintf(pid, "%d\n", os_getpid()); | 104 | sprintf(pid, "%d\n", os_getpid()); |
@@ -103,7 +106,6 @@ static int __init create_pid_file(void) | |||
103 | if(n != strlen(pid)) | 106 | if(n != strlen(pid)) |
104 | printf("Write of pid file failed - err = %d\n", -n); | 107 | printf("Write of pid file failed - err = %d\n", -n); |
105 | os_close_file(fd); | 108 | os_close_file(fd); |
106 | return 0; | ||
107 | } | 109 | } |
108 | 110 | ||
109 | static int actually_do_remove(char *dir) | 111 | static int actually_do_remove(char *dir) |
@@ -147,7 +149,8 @@ static int actually_do_remove(char *dir) | |||
147 | void remove_umid_dir(void) | 149 | void remove_umid_dir(void) |
148 | { | 150 | { |
149 | char dir[strlen(uml_dir) + UMID_LEN + 1]; | 151 | char dir[strlen(uml_dir) + UMID_LEN + 1]; |
150 | if(!umid_inited) return; | 152 | if (!umid_owned) |
153 | return; | ||
151 | 154 | ||
152 | sprintf(dir, "%s%s", uml_dir, umid); | 155 | sprintf(dir, "%s%s", uml_dir, umid); |
153 | actually_do_remove(dir); | 156 | actually_do_remove(dir); |
@@ -155,11 +158,12 @@ void remove_umid_dir(void) | |||
155 | 158 | ||
156 | char *get_umid(int only_if_set) | 159 | char *get_umid(int only_if_set) |
157 | { | 160 | { |
158 | if(only_if_set && umid_is_random) return(NULL); | 161 | if(only_if_set && umid_is_random) |
159 | return(umid); | 162 | return NULL; |
163 | return umid; | ||
160 | } | 164 | } |
161 | 165 | ||
162 | int not_dead_yet(char *dir) | 166 | static int not_dead_yet(char *dir) |
163 | { | 167 | { |
164 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; | 168 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; |
165 | char pid[sizeof("nnnnn\0")], *end; | 169 | char pid[sizeof("nnnnn\0")], *end; |
@@ -193,7 +197,8 @@ int not_dead_yet(char *dir) | |||
193 | (p == CHOOSE_MODE(tracing_pid, os_getpid()))) | 197 | (p == CHOOSE_MODE(tracing_pid, os_getpid()))) |
194 | dead = 1; | 198 | dead = 1; |
195 | } | 199 | } |
196 | if(!dead) return(1); | 200 | if(!dead) |
201 | return(1); | ||
197 | return(actually_do_remove(dir)); | 202 | return(actually_do_remove(dir)); |
198 | } | 203 | } |
199 | 204 | ||
@@ -232,16 +237,13 @@ static int __init make_uml_dir(void) | |||
232 | strlcpy(dir, home, sizeof(dir)); | 237 | strlcpy(dir, home, sizeof(dir)); |
233 | uml_dir++; | 238 | uml_dir++; |
234 | } | 239 | } |
240 | strlcat(dir, uml_dir, sizeof(dir)); | ||
235 | len = strlen(dir); | 241 | len = strlen(dir); |
236 | strncat(dir, uml_dir, sizeof(dir) - len); | 242 | if (len > 0 && dir[len - 1] != '/') |
237 | len = strlen(dir); | 243 | strlcat(dir, "/", sizeof(dir)); |
238 | if((len > 0) && (len < sizeof(dir) - 1) && (dir[len - 1] != '/')){ | ||
239 | dir[len] = '/'; | ||
240 | dir[len + 1] = '\0'; | ||
241 | } | ||
242 | 244 | ||
243 | uml_dir = malloc(strlen(dir) + 1); | 245 | uml_dir = malloc(strlen(dir) + 1); |
244 | if(uml_dir == NULL){ | 246 | if (uml_dir == NULL) { |
245 | printf("make_uml_dir : malloc failed, errno = %d\n", errno); | 247 | printf("make_uml_dir : malloc failed, errno = %d\n", errno); |
246 | exit(1); | 248 | exit(1); |
247 | } | 249 | } |
@@ -286,6 +288,7 @@ static int __init make_umid(int (*printer)(const char *fmt, ...)) | |||
286 | if(errno == EEXIST){ | 288 | if(errno == EEXIST){ |
287 | if(not_dead_yet(tmp)){ | 289 | if(not_dead_yet(tmp)){ |
288 | (*printer)("umid '%s' is in use\n", umid); | 290 | (*printer)("umid '%s' is in use\n", umid); |
291 | umid_owned = 0; | ||
289 | return(-1); | 292 | return(-1); |
290 | } | 293 | } |
291 | err = mkdir(tmp, 0777); | 294 | err = mkdir(tmp, 0777); |
@@ -296,7 +299,8 @@ static int __init make_umid(int (*printer)(const char *fmt, ...)) | |||
296 | return(-1); | 299 | return(-1); |
297 | } | 300 | } |
298 | 301 | ||
299 | return(0); | 302 | umid_owned = 1; |
303 | return 0; | ||
300 | } | 304 | } |
301 | 305 | ||
302 | __uml_setup("uml_dir=", set_uml_dir, | 306 | __uml_setup("uml_dir=", set_uml_dir, |
@@ -309,7 +313,8 @@ static int __init make_umid_setup(void) | |||
309 | /* one function with the ordering we need ... */ | 313 | /* one function with the ordering we need ... */ |
310 | make_uml_dir(); | 314 | make_uml_dir(); |
311 | make_umid(printf); | 315 | make_umid(printf); |
312 | return create_pid_file(); | 316 | create_pid_file(); |
317 | return 0; | ||
313 | } | 318 | } |
314 | __uml_postsetup(make_umid_setup); | 319 | __uml_postsetup(make_umid_setup); |
315 | 320 | ||
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c index 954ff67cc8b3..41d17c71511c 100644 --- a/arch/um/kernel/user_util.c +++ b/arch/um/kernel/user_util.c | |||
@@ -109,18 +109,14 @@ int raw(int fd) | |||
109 | int err; | 109 | int err; |
110 | 110 | ||
111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); | 111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); |
112 | if (err < 0) { | 112 | if(err < 0) |
113 | printk("tcgetattr failed, errno = %d\n", errno); | 113 | return -errno; |
114 | return(-errno); | ||
115 | } | ||
116 | 114 | ||
117 | cfmakeraw(&tt); | 115 | cfmakeraw(&tt); |
118 | 116 | ||
119 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); | 117 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); |
120 | if (err < 0) { | 118 | if(err < 0) |
121 | printk("tcsetattr failed, errno = %d\n", errno); | 119 | return -errno; |
122 | return(-errno); | ||
123 | } | ||
124 | 120 | ||
125 | /* XXX tcsetattr could have applied only some changes | 121 | /* XXX tcsetattr could have applied only some changes |
126 | * (and cfmakeraw() is a set of changes) */ | 122 | * (and cfmakeraw() is a set of changes) */ |
@@ -132,6 +128,12 @@ void setup_machinename(char *machine_out) | |||
132 | struct utsname host; | 128 | struct utsname host; |
133 | 129 | ||
134 | uname(&host); | 130 | uname(&host); |
131 | #if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT) | ||
132 | if (!strcmp(host.machine, "x86_64")) { | ||
133 | strcpy(machine_out, "i686"); | ||
134 | return; | ||
135 | } | ||
136 | #endif | ||
135 | strcpy(machine_out, host.machine); | 137 | strcpy(machine_out, host.machine); |
136 | } | 138 | } |
137 | 139 | ||
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 7a1662419c0c..d15ec2af6a22 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile | |||
@@ -3,11 +3,11 @@ | |||
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y = aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \ | 6 | obj-y = aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o time.o \ |
7 | tty.o user_syms.o drivers/ sys-$(SUBARCH)/ | 7 | tt.o tty.o user_syms.o drivers/ sys-$(SUBARCH)/ |
8 | 8 | ||
9 | USER_OBJS := aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \ | 9 | USER_OBJS := aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o \ |
10 | tty.o | 10 | time.o tt.o tty.o |
11 | 11 | ||
12 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h | 12 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h |
13 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um | 13 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um |
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index b04897cd995d..f6e64026f995 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c | |||
@@ -117,6 +117,8 @@ static int do_aio(aio_context_t ctx, struct aio_context *aio) | |||
117 | err = io_submit(ctx, 1, &iocbp); | 117 | err = io_submit(ctx, 1, &iocbp); |
118 | if(err > 0) | 118 | if(err > 0) |
119 | err = 0; | 119 | err = 0; |
120 | else | ||
121 | err = -errno; | ||
120 | 122 | ||
121 | out: | 123 | out: |
122 | return err; | 124 | return err; |
@@ -142,7 +144,8 @@ static int aio_thread(void *arg) | |||
142 | "errno = %d\n", errno); | 144 | "errno = %d\n", errno); |
143 | } | 145 | } |
144 | else { | 146 | else { |
145 | aio = (struct aio_context *) event.data; | 147 | /* This is safe as we've just a pointer here. */ |
148 | aio = (struct aio_context *) (long) event.data; | ||
146 | if(update_aio(aio, event.res)){ | 149 | if(update_aio(aio, event.res)){ |
147 | do_aio(ctx, aio); | 150 | do_aio(ctx, aio); |
148 | continue; | 151 | continue; |
@@ -313,15 +316,16 @@ static int init_aio_26(void) | |||
313 | int err; | 316 | int err; |
314 | 317 | ||
315 | if(io_setup(256, &ctx)){ | 318 | if(io_setup(256, &ctx)){ |
319 | err = -errno; | ||
316 | printk("aio_thread failed to initialize context, err = %d\n", | 320 | printk("aio_thread failed to initialize context, err = %d\n", |
317 | errno); | 321 | errno); |
318 | return -errno; | 322 | return err; |
319 | } | 323 | } |
320 | 324 | ||
321 | err = run_helper_thread(aio_thread, NULL, | 325 | err = run_helper_thread(aio_thread, NULL, |
322 | CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); | 326 | CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); |
323 | if(err < 0) | 327 | if(err < 0) |
324 | return -errno; | 328 | return err; |
325 | 329 | ||
326 | aio_pid = err; | 330 | aio_pid = err; |
327 | 331 | ||
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 4b83c6c3f48d..4ba9b17adf13 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c | |||
@@ -75,7 +75,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
75 | struct msghdr msg; | 75 | struct msghdr msg; |
76 | struct cmsghdr *cmsg; | 76 | struct cmsghdr *cmsg; |
77 | struct iovec iov; | 77 | struct iovec iov; |
78 | int pid, n; | 78 | int pid, n, err; |
79 | 79 | ||
80 | sprintf(version_buf, "%d", UML_NET_VERSION); | 80 | sprintf(version_buf, "%d", UML_NET_VERSION); |
81 | 81 | ||
@@ -105,9 +105,10 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
105 | n = recvmsg(me, &msg, 0); | 105 | n = recvmsg(me, &msg, 0); |
106 | *used_out = n; | 106 | *used_out = n; |
107 | if(n < 0){ | 107 | if(n < 0){ |
108 | err = -errno; | ||
108 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", | 109 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", |
109 | errno); | 110 | errno); |
110 | return(-errno); | 111 | return err; |
111 | } | 112 | } |
112 | CATCH_EINTR(waitpid(pid, NULL, 0)); | 113 | CATCH_EINTR(waitpid(pid, NULL, 0)); |
113 | 114 | ||
@@ -147,9 +148,10 @@ static int tuntap_open(void *data) | |||
147 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; | 148 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; |
148 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); | 149 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); |
149 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ | 150 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ |
151 | err = -errno; | ||
150 | printk("TUNSETIFF failed, errno = %d\n", errno); | 152 | printk("TUNSETIFF failed, errno = %d\n", errno); |
151 | os_close_file(pri->fd); | 153 | os_close_file(pri->fd); |
152 | return(-errno); | 154 | return err; |
153 | } | 155 | } |
154 | } | 156 | } |
155 | else { | 157 | else { |
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index 1399520a8588..5a99dd3fbed0 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c | |||
@@ -12,9 +12,10 @@ | |||
12 | #include "init.h" | 12 | #include "init.h" |
13 | #include "elf_user.h" | 13 | #include "elf_user.h" |
14 | #include "mem_user.h" | 14 | #include "mem_user.h" |
15 | #include <kernel-offsets.h> | 15 | #include <kern_constants.h> |
16 | 16 | ||
17 | #if HOST_ELF_CLASS == ELFCLASS32 | 17 | /* Use the one from the kernel - the host may miss it, if having old headers. */ |
18 | #if UM_ELF_CLASS == UM_ELFCLASS32 | ||
18 | typedef Elf32_auxv_t elf_auxv_t; | 19 | typedef Elf32_auxv_t elf_auxv_t; |
19 | #else | 20 | #else |
20 | typedef Elf64_auxv_t elf_auxv_t; | 21 | typedef Elf64_auxv_t elf_auxv_t; |
@@ -54,7 +55,8 @@ __init void scan_elf_aux( char **envp) | |||
54 | * a_un, so we have to use a_val, which is | 55 | * a_un, so we have to use a_val, which is |
55 | * all that's left. | 56 | * all that's left. |
56 | */ | 57 | */ |
57 | elf_aux_platform = (char *) auxv->a_un.a_val; | 58 | elf_aux_platform = |
59 | (char *) (long) auxv->a_un.a_val; | ||
58 | break; | 60 | break; |
59 | case AT_PAGESZ: | 61 | case AT_PAGESZ: |
60 | page_size = auxv->a_un.a_val; | 62 | page_size = auxv->a_un.a_val; |
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index fd45bb260907..f55773c819e6 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -119,15 +119,11 @@ int os_window_size(int fd, int *rows, int *cols) | |||
119 | 119 | ||
120 | int os_new_tty_pgrp(int fd, int pid) | 120 | int os_new_tty_pgrp(int fd, int pid) |
121 | { | 121 | { |
122 | if(ioctl(fd, TIOCSCTTY, 0) < 0){ | 122 | if(ioctl(fd, TIOCSCTTY, 0) < 0) |
123 | printk("TIOCSCTTY failed, errno = %d\n", errno); | 123 | return -errno; |
124 | return(-errno); | ||
125 | } | ||
126 | 124 | ||
127 | if(tcsetpgrp(fd, pid) < 0){ | 125 | if(tcsetpgrp(fd, pid) < 0) |
128 | printk("tcsetpgrp failed, errno = %d\n", errno); | 126 | return -errno; |
129 | return(-errno); | ||
130 | } | ||
131 | 127 | ||
132 | return(0); | 128 | return(0); |
133 | } | 129 | } |
@@ -146,18 +142,12 @@ int os_set_slip(int fd) | |||
146 | int disc, sencap; | 142 | int disc, sencap; |
147 | 143 | ||
148 | disc = N_SLIP; | 144 | disc = N_SLIP; |
149 | if(ioctl(fd, TIOCSETD, &disc) < 0){ | 145 | if(ioctl(fd, TIOCSETD, &disc) < 0) |
150 | printk("Failed to set slip line discipline - " | 146 | return -errno; |
151 | "errno = %d\n", errno); | ||
152 | return(-errno); | ||
153 | } | ||
154 | 147 | ||
155 | sencap = 0; | 148 | sencap = 0; |
156 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0){ | 149 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) |
157 | printk("Failed to set slip encapsulation - " | 150 | return -errno; |
158 | "errno = %d\n", errno); | ||
159 | return(-errno); | ||
160 | } | ||
161 | 151 | ||
162 | return(0); | 152 | return(0); |
163 | } | 153 | } |
@@ -180,22 +170,15 @@ int os_sigio_async(int master, int slave) | |||
180 | int flags; | 170 | int flags; |
181 | 171 | ||
182 | flags = fcntl(master, F_GETFL); | 172 | flags = fcntl(master, F_GETFL); |
183 | if(flags < 0) { | 173 | if(flags < 0) |
184 | printk("fcntl F_GETFL failed, errno = %d\n", errno); | 174 | return errno; |
185 | return(-errno); | ||
186 | } | ||
187 | 175 | ||
188 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || | 176 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || |
189 | (fcntl(master, F_SETOWN, os_getpid()) < 0)){ | 177 | (fcntl(master, F_SETOWN, os_getpid()) < 0)) |
190 | printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", | 178 | return -errno; |
191 | errno); | ||
192 | return(-errno); | ||
193 | } | ||
194 | 179 | ||
195 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)){ | 180 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)) |
196 | printk("fcntl F_SETFL failed, errno = %d\n", errno); | 181 | return -errno; |
197 | return(-errno); | ||
198 | } | ||
199 | 182 | ||
200 | return(0); | 183 | return(0); |
201 | } | 184 | } |
@@ -255,7 +238,7 @@ int os_file_mode(char *file, struct openflags *mode_out) | |||
255 | 238 | ||
256 | int os_open_file(char *file, struct openflags flags, int mode) | 239 | int os_open_file(char *file, struct openflags flags, int mode) |
257 | { | 240 | { |
258 | int fd, f = 0; | 241 | int fd, err, f = 0; |
259 | 242 | ||
260 | if(flags.r && flags.w) f = O_RDWR; | 243 | if(flags.r && flags.w) f = O_RDWR; |
261 | else if(flags.r) f = O_RDONLY; | 244 | else if(flags.r) f = O_RDONLY; |
@@ -272,8 +255,9 @@ int os_open_file(char *file, struct openflags flags, int mode) | |||
272 | return(-errno); | 255 | return(-errno); |
273 | 256 | ||
274 | if(flags.cl && fcntl(fd, F_SETFD, 1)){ | 257 | if(flags.cl && fcntl(fd, F_SETFD, 1)){ |
258 | err = -errno; | ||
275 | os_close_file(fd); | 259 | os_close_file(fd); |
276 | return(-errno); | 260 | return err; |
277 | } | 261 | } |
278 | 262 | ||
279 | return(fd); | 263 | return(fd); |
@@ -383,9 +367,9 @@ int os_file_size(char *file, unsigned long long *size_out) | |||
383 | return(fd); | 367 | return(fd); |
384 | } | 368 | } |
385 | if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ | 369 | if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ |
370 | err = -errno; | ||
386 | printk("Couldn't get the block size of \"%s\", " | 371 | printk("Couldn't get the block size of \"%s\", " |
387 | "errno = %d\n", file, errno); | 372 | "errno = %d\n", file, errno); |
388 | err = -errno; | ||
389 | os_close_file(fd); | 373 | os_close_file(fd); |
390 | return(err); | 374 | return(err); |
391 | } | 375 | } |
@@ -473,11 +457,14 @@ int os_pipe(int *fds, int stream, int close_on_exec) | |||
473 | 457 | ||
474 | int os_set_fd_async(int fd, int owner) | 458 | int os_set_fd_async(int fd, int owner) |
475 | { | 459 | { |
460 | int err; | ||
461 | |||
476 | /* XXX This should do F_GETFL first */ | 462 | /* XXX This should do F_GETFL first */ |
477 | if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ | 463 | if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ |
464 | err = -errno; | ||
478 | printk("os_set_fd_async : failed to set O_ASYNC and " | 465 | printk("os_set_fd_async : failed to set O_ASYNC and " |
479 | "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); | 466 | "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); |
480 | return(-errno); | 467 | return err; |
481 | } | 468 | } |
482 | #ifdef notdef | 469 | #ifdef notdef |
483 | if(fcntl(fd, F_SETFD, 1) < 0){ | 470 | if(fcntl(fd, F_SETFD, 1) < 0){ |
@@ -488,10 +475,11 @@ int os_set_fd_async(int fd, int owner) | |||
488 | 475 | ||
489 | if((fcntl(fd, F_SETSIG, SIGIO) < 0) || | 476 | if((fcntl(fd, F_SETSIG, SIGIO) < 0) || |
490 | (fcntl(fd, F_SETOWN, owner) < 0)){ | 477 | (fcntl(fd, F_SETOWN, owner) < 0)){ |
478 | err = -errno; | ||
491 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " | 479 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " |
492 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, | 480 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, |
493 | owner, errno); | 481 | owner, errno); |
494 | return(-errno); | 482 | return err; |
495 | } | 483 | } |
496 | 484 | ||
497 | return(0); | 485 | return(0); |
@@ -516,11 +504,9 @@ int os_set_fd_block(int fd, int blocking) | |||
516 | if(blocking) flags &= ~O_NONBLOCK; | 504 | if(blocking) flags &= ~O_NONBLOCK; |
517 | else flags |= O_NONBLOCK; | 505 | else flags |= O_NONBLOCK; |
518 | 506 | ||
519 | if(fcntl(fd, F_SETFL, flags) < 0){ | 507 | if(fcntl(fd, F_SETFL, flags) < 0) |
520 | printk("Failed to change blocking on fd # %d, errno = %d\n", | 508 | return -errno; |
521 | fd, errno); | 509 | |
522 | return(-errno); | ||
523 | } | ||
524 | return(0); | 510 | return(0); |
525 | } | 511 | } |
526 | 512 | ||
@@ -609,11 +595,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
609 | int sock, err; | 595 | int sock, err; |
610 | 596 | ||
611 | sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 597 | sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
612 | if (sock < 0){ | 598 | if(sock < 0) |
613 | printk("create_unix_socket - socket failed, errno = %d\n", | 599 | return -errno; |
614 | errno); | ||
615 | return(-errno); | ||
616 | } | ||
617 | 600 | ||
618 | if(close_on_exec) { | 601 | if(close_on_exec) { |
619 | err = os_set_exec_close(sock, 1); | 602 | err = os_set_exec_close(sock, 1); |
@@ -628,11 +611,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
628 | snprintf(addr.sun_path, len, "%s", file); | 611 | snprintf(addr.sun_path, len, "%s", file); |
629 | 612 | ||
630 | err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); | 613 | err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); |
631 | if (err < 0){ | 614 | if(err < 0) |
632 | printk("create_listening_socket at '%s' - bind failed, " | 615 | return -errno; |
633 | "errno = %d\n", file, errno); | ||
634 | return(-errno); | ||
635 | } | ||
636 | 616 | ||
637 | return(sock); | 617 | return(sock); |
638 | } | 618 | } |
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c new file mode 100644 index 000000000000..8e71edaaf80b --- /dev/null +++ b/arch/um/os-Linux/mem.c | |||
@@ -0,0 +1,161 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <stddef.h> | ||
4 | #include <stdarg.h> | ||
5 | #include <unistd.h> | ||
6 | #include <errno.h> | ||
7 | #include <string.h> | ||
8 | #include <fcntl.h> | ||
9 | #include <sys/types.h> | ||
10 | #include <sys/mman.h> | ||
11 | #include "kern_util.h" | ||
12 | #include "user.h" | ||
13 | #include "user_util.h" | ||
14 | #include "mem_user.h" | ||
15 | #include "init.h" | ||
16 | #include "os.h" | ||
17 | #include "tempfile.h" | ||
18 | #include "kern_constants.h" | ||
19 | |||
20 | #include <sys/param.h> | ||
21 | |||
22 | static char *tempdir = NULL; | ||
23 | |||
24 | static void __init find_tempdir(void) | ||
25 | { | ||
26 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | ||
27 | int i; | ||
28 | char *dir = NULL; | ||
29 | |||
30 | if(tempdir != NULL) return; /* We've already been called */ | ||
31 | for(i = 0; dirs[i]; i++){ | ||
32 | dir = getenv(dirs[i]); | ||
33 | if((dir != NULL) && (*dir != '\0')) | ||
34 | break; | ||
35 | } | ||
36 | if((dir == NULL) || (*dir == '\0')) | ||
37 | dir = "/tmp"; | ||
38 | |||
39 | tempdir = malloc(strlen(dir) + 2); | ||
40 | if(tempdir == NULL){ | ||
41 | fprintf(stderr, "Failed to malloc tempdir, " | ||
42 | "errno = %d\n", errno); | ||
43 | return; | ||
44 | } | ||
45 | strcpy(tempdir, dir); | ||
46 | strcat(tempdir, "/"); | ||
47 | } | ||
48 | |||
49 | /* | ||
50 | * This proc still used in tt-mode | ||
51 | * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger). | ||
52 | * So it isn't 'static' yet. | ||
53 | */ | ||
54 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | ||
55 | { | ||
56 | char tempname[MAXPATHLEN]; | ||
57 | int fd; | ||
58 | |||
59 | find_tempdir(); | ||
60 | if (*template != '/') | ||
61 | strcpy(tempname, tempdir); | ||
62 | else | ||
63 | *tempname = 0; | ||
64 | strcat(tempname, template); | ||
65 | fd = mkstemp(tempname); | ||
66 | if(fd < 0){ | ||
67 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | ||
68 | strerror(errno)); | ||
69 | return -1; | ||
70 | } | ||
71 | if(do_unlink && (unlink(tempname) < 0)){ | ||
72 | perror("unlink"); | ||
73 | return -1; | ||
74 | } | ||
75 | if(out_tempname){ | ||
76 | *out_tempname = strdup(tempname); | ||
77 | if(*out_tempname == NULL){ | ||
78 | perror("strdup"); | ||
79 | return -1; | ||
80 | } | ||
81 | } | ||
82 | return(fd); | ||
83 | } | ||
84 | |||
85 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | ||
86 | |||
87 | /* | ||
88 | * This proc is used in start_up.c | ||
89 | * So it isn't 'static'. | ||
90 | */ | ||
91 | int create_tmp_file(unsigned long len) | ||
92 | { | ||
93 | int fd, err; | ||
94 | char zero; | ||
95 | |||
96 | fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); | ||
97 | if(fd < 0) { | ||
98 | exit(1); | ||
99 | } | ||
100 | |||
101 | err = fchmod(fd, 0777); | ||
102 | if(err < 0){ | ||
103 | perror("os_mode_fd"); | ||
104 | exit(1); | ||
105 | } | ||
106 | |||
107 | if (lseek64(fd, len, SEEK_SET) < 0) { | ||
108 | perror("os_seek_file"); | ||
109 | exit(1); | ||
110 | } | ||
111 | |||
112 | zero = 0; | ||
113 | |||
114 | err = os_write_file(fd, &zero, 1); | ||
115 | if(err != 1){ | ||
116 | errno = -err; | ||
117 | perror("os_write_file"); | ||
118 | exit(1); | ||
119 | } | ||
120 | |||
121 | return(fd); | ||
122 | } | ||
123 | |||
124 | static int create_anon_file(unsigned long len) | ||
125 | { | ||
126 | void *addr; | ||
127 | int fd; | ||
128 | |||
129 | fd = open("/dev/anon", O_RDWR); | ||
130 | if(fd < 0) { | ||
131 | perror("opening /dev/anon"); | ||
132 | exit(1); | ||
133 | } | ||
134 | |||
135 | addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); | ||
136 | if(addr == MAP_FAILED){ | ||
137 | perror("mapping physmem file"); | ||
138 | exit(1); | ||
139 | } | ||
140 | munmap(addr, len); | ||
141 | |||
142 | return(fd); | ||
143 | } | ||
144 | |||
145 | extern int have_devanon; | ||
146 | |||
147 | int create_mem_file(unsigned long len) | ||
148 | { | ||
149 | int err, fd; | ||
150 | |||
151 | if(have_devanon) | ||
152 | fd = create_anon_file(len); | ||
153 | else fd = create_tmp_file(len); | ||
154 | |||
155 | err = os_set_exec_close(fd, 1); | ||
156 | if(err < 0){ | ||
157 | errno = -err; | ||
158 | perror("exec_close"); | ||
159 | } | ||
160 | return(fd); | ||
161 | } | ||
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index d32413e4b4ce..d9c52387c4a1 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <unistd.h> | ||
6 | #include <stdio.h> | 7 | #include <stdio.h> |
7 | #include <errno.h> | 8 | #include <errno.h> |
8 | #include <signal.h> | 9 | #include <signal.h> |
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 040cc1472bc7..6af83171ca4e 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -4,18 +4,22 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stddef.h> | ||
8 | #include <stdarg.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <string.h> | ||
7 | #include <unistd.h> | 11 | #include <unistd.h> |
8 | #include <signal.h> | 12 | #include <signal.h> |
9 | #include <sched.h> | 13 | #include <sched.h> |
14 | #include <fcntl.h> | ||
10 | #include <errno.h> | 15 | #include <errno.h> |
11 | #include <stdarg.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <setjmp.h> | 16 | #include <setjmp.h> |
14 | #include <sys/time.h> | 17 | #include <sys/time.h> |
15 | #include <sys/wait.h> | 18 | #include <sys/wait.h> |
16 | #include <sys/mman.h> | 19 | #include <sys/mman.h> |
17 | #include <asm/unistd.h> | 20 | #include <asm/unistd.h> |
18 | #include <asm/page.h> | 21 | #include <asm/page.h> |
22 | #include <sys/types.h> | ||
19 | #include "user_util.h" | 23 | #include "user_util.h" |
20 | #include "kern_util.h" | 24 | #include "kern_util.h" |
21 | #include "user.h" | 25 | #include "user.h" |
@@ -25,6 +29,7 @@ | |||
25 | #include "sysdep/sigcontext.h" | 29 | #include "sysdep/sigcontext.h" |
26 | #include "irq_user.h" | 30 | #include "irq_user.h" |
27 | #include "ptrace_user.h" | 31 | #include "ptrace_user.h" |
32 | #include "mem_user.h" | ||
28 | #include "time_user.h" | 33 | #include "time_user.h" |
29 | #include "init.h" | 34 | #include "init.h" |
30 | #include "os.h" | 35 | #include "os.h" |
@@ -32,6 +37,8 @@ | |||
32 | #include "choose-mode.h" | 37 | #include "choose-mode.h" |
33 | #include "mode.h" | 38 | #include "mode.h" |
34 | #include "tempfile.h" | 39 | #include "tempfile.h" |
40 | #include "kern_constants.h" | ||
41 | |||
35 | #ifdef UML_CONFIG_MODE_SKAS | 42 | #ifdef UML_CONFIG_MODE_SKAS |
36 | #include "skas.h" | 43 | #include "skas.h" |
37 | #include "skas_ptrace.h" | 44 | #include "skas_ptrace.h" |
@@ -276,9 +283,38 @@ static void __init check_ptrace(void) | |||
276 | check_sysemu(); | 283 | check_sysemu(); |
277 | } | 284 | } |
278 | 285 | ||
286 | extern int create_tmp_file(unsigned long len); | ||
287 | |||
288 | static void check_tmpexec(void) | ||
289 | { | ||
290 | void *addr; | ||
291 | int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE); | ||
292 | |||
293 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | ||
294 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | ||
295 | printf("Checking PROT_EXEC mmap in /tmp..."); | ||
296 | fflush(stdout); | ||
297 | if(addr == MAP_FAILED){ | ||
298 | err = errno; | ||
299 | perror("failed"); | ||
300 | if(err == EPERM) | ||
301 | printf("/tmp must be not mounted noexec\n"); | ||
302 | exit(1); | ||
303 | } | ||
304 | printf("OK\n"); | ||
305 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
306 | |||
307 | close(fd); | ||
308 | } | ||
309 | |||
279 | void os_early_checks(void) | 310 | void os_early_checks(void) |
280 | { | 311 | { |
281 | check_ptrace(); | 312 | check_ptrace(); |
313 | |||
314 | /* Need to check this early because mmapping happens before the | ||
315 | * kernel is running. | ||
316 | */ | ||
317 | check_tmpexec(); | ||
282 | } | 318 | } |
283 | 319 | ||
284 | static int __init noprocmm_cmd_param(char *str, int* add) | 320 | static int __init noprocmm_cmd_param(char *str, int* add) |
@@ -357,3 +393,72 @@ int can_do_skas(void) | |||
357 | return(0); | 393 | return(0); |
358 | } | 394 | } |
359 | #endif | 395 | #endif |
396 | |||
397 | int have_devanon = 0; | ||
398 | |||
399 | void check_devanon(void) | ||
400 | { | ||
401 | int fd; | ||
402 | |||
403 | printk("Checking for /dev/anon on the host..."); | ||
404 | fd = open("/dev/anon", O_RDWR); | ||
405 | if(fd < 0){ | ||
406 | printk("Not available (open failed with errno %d)\n", errno); | ||
407 | return; | ||
408 | } | ||
409 | |||
410 | printk("OK\n"); | ||
411 | have_devanon = 1; | ||
412 | } | ||
413 | |||
414 | int __init parse_iomem(char *str, int *add) | ||
415 | { | ||
416 | struct iomem_region *new; | ||
417 | struct uml_stat buf; | ||
418 | char *file, *driver; | ||
419 | int fd, err, size; | ||
420 | |||
421 | driver = str; | ||
422 | file = strchr(str,','); | ||
423 | if(file == NULL){ | ||
424 | printf("parse_iomem : failed to parse iomem\n"); | ||
425 | goto out; | ||
426 | } | ||
427 | *file = '\0'; | ||
428 | file++; | ||
429 | fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0); | ||
430 | if(fd < 0){ | ||
431 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | ||
432 | goto out; | ||
433 | } | ||
434 | |||
435 | err = os_stat_fd(fd, &buf); | ||
436 | if(err < 0){ | ||
437 | os_print_error(err, "parse_iomem - cannot stat_fd file"); | ||
438 | goto out_close; | ||
439 | } | ||
440 | |||
441 | new = malloc(sizeof(*new)); | ||
442 | if(new == NULL){ | ||
443 | perror("Couldn't allocate iomem_region struct"); | ||
444 | goto out_close; | ||
445 | } | ||
446 | |||
447 | size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1); | ||
448 | |||
449 | *new = ((struct iomem_region) { .next = iomem_regions, | ||
450 | .driver = driver, | ||
451 | .fd = fd, | ||
452 | .size = size, | ||
453 | .phys = 0, | ||
454 | .virt = 0 }); | ||
455 | iomem_regions = new; | ||
456 | iomem_size += new->size + UM_KERN_PAGE_SIZE; | ||
457 | |||
458 | return(0); | ||
459 | out_close: | ||
460 | os_close_file(fd); | ||
461 | out: | ||
462 | return(1); | ||
463 | } | ||
464 | |||
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c index 5b047ab8416a..a6db8877931a 100644 --- a/arch/um/os-Linux/tt.c +++ b/arch/um/os-Linux/tt.c | |||
@@ -36,6 +36,20 @@ | |||
36 | #include "mode.h" | 36 | #include "mode.h" |
37 | #include "tempfile.h" | 37 | #include "tempfile.h" |
38 | 38 | ||
39 | int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, | ||
40 | int must_succeed) | ||
41 | { | ||
42 | int err; | ||
43 | |||
44 | err = os_protect_memory((void *) addr, len, r, w, x); | ||
45 | if(err < 0){ | ||
46 | if(must_succeed) | ||
47 | panic("protect failed, err = %d", -err); | ||
48 | else return(err); | ||
49 | } | ||
50 | return(0); | ||
51 | } | ||
52 | |||
39 | /* | 53 | /* |
40 | *------------------------- | 54 | *------------------------- |
41 | * only for tt mode (will be deleted in future...) | 55 | * only for tt mode (will be deleted in future...) |
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile deleted file mode 100644 index 9778aed0c314..000000000000 --- a/arch/um/os-Linux/util/Makefile +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | hostprogs-y := mk_user_constants | ||
2 | always := $(hostprogs-y) | ||
3 | |||
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 deleted file mode 100644 index 4838f30eecf0..000000000000 --- a/arch/um/os-Linux/util/mk_user_constants.c +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <user-offsets.h> | ||
3 | |||
4 | int main(int argc, char **argv) | ||
5 | { | ||
6 | printf("/*\n"); | ||
7 | printf(" * Generated by mk_user_constants\n"); | ||
8 | printf(" */\n"); | ||
9 | printf("\n"); | ||
10 | printf("#ifndef __UM_USER_CONSTANTS_H\n"); | ||
11 | printf("#define __UM_USER_CONSTANTS_H\n"); | ||
12 | printf("\n"); | ||
13 | /* I'd like to use FRAME_SIZE from ptrace.h here, but that's wrong on | ||
14 | * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on | ||
15 | * both x86_64 and i386. | ||
16 | */ | ||
17 | printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE); | ||
18 | |||
19 | printf("\n"); | ||
20 | printf("#endif\n"); | ||
21 | |||
22 | return(0); | ||
23 | } | ||
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile index 4ca2a229da49..6dfeb70f6957 100644 --- a/arch/um/sys-i386/Makefile +++ b/arch/um/sys-i386/Makefile | |||
@@ -18,6 +18,4 @@ module.c-dir = kernel | |||
18 | 18 | ||
19 | $(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS)) | 19 | $(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS)) |
20 | 20 | ||
21 | subdir- := util | ||
22 | |||
23 | include arch/um/scripts/Makefile.unmap | 21 | include arch/um/scripts/Makefile.unmap |
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/sys-i386/kernel-offsets.c index a1070af2bcd8..35db85057506 100644 --- a/arch/um/sys-i386/kernel-offsets.c +++ b/arch/um/sys-i386/kernel-offsets.c | |||
@@ -18,9 +18,9 @@ | |||
18 | 18 | ||
19 | void foo(void) | 19 | void foo(void) |
20 | { | 20 | { |
21 | OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs); | 21 | OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs); |
22 | #ifdef CONFIG_MODE_TT | 22 | #ifdef CONFIG_MODE_TT |
23 | OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); | 23 | OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); |
24 | #endif | 24 | #endif |
25 | #include <common-offsets.h> | 25 | #include <common-offsets.h> |
26 | } | 26 | } |
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c index bd3c34aa52e5..36b5c2c13289 100644 --- a/arch/um/sys-i386/ldt.c +++ b/arch/um/sys-i386/ldt.c | |||
@@ -83,6 +83,7 @@ int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) | |||
83 | goto out; | 83 | goto out; |
84 | } | 84 | } |
85 | p = buf; | 85 | p = buf; |
86 | break; | ||
86 | default: | 87 | default: |
87 | res = -ENOSYS; | 88 | res = -ENOSYS; |
88 | goto out; | 89 | goto out; |
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c index 3ceaabceb3d7..677fc26a9bbe 100644 --- a/arch/um/sys-i386/user-offsets.c +++ b/arch/um/sys-i386/user-offsets.c | |||
@@ -7,47 +7,48 @@ | |||
7 | #define DEFINE(sym, val) \ | 7 | #define DEFINE(sym, val) \ |
8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | 8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
9 | 9 | ||
10 | #define DEFINE_LONGS(sym, val) \ | ||
11 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) | ||
12 | |||
10 | #define OFFSET(sym, str, mem) \ | 13 | #define OFFSET(sym, str, mem) \ |
11 | DEFINE(sym, offsetof(struct str, mem)); | 14 | DEFINE(sym, offsetof(struct str, mem)); |
12 | 15 | ||
13 | void foo(void) | 16 | void foo(void) |
14 | { | 17 | { |
15 | OFFSET(SC_IP, sigcontext, eip); | 18 | OFFSET(HOST_SC_IP, sigcontext, eip); |
16 | OFFSET(SC_SP, sigcontext, esp); | 19 | OFFSET(HOST_SC_SP, sigcontext, esp); |
17 | OFFSET(SC_FS, sigcontext, fs); | 20 | OFFSET(HOST_SC_FS, sigcontext, fs); |
18 | OFFSET(SC_GS, sigcontext, gs); | 21 | OFFSET(HOST_SC_GS, sigcontext, gs); |
19 | OFFSET(SC_DS, sigcontext, ds); | 22 | OFFSET(HOST_SC_DS, sigcontext, ds); |
20 | OFFSET(SC_ES, sigcontext, es); | 23 | OFFSET(HOST_SC_ES, sigcontext, es); |
21 | OFFSET(SC_SS, sigcontext, ss); | 24 | OFFSET(HOST_SC_SS, sigcontext, ss); |
22 | OFFSET(SC_CS, sigcontext, cs); | 25 | OFFSET(HOST_SC_CS, sigcontext, cs); |
23 | OFFSET(SC_EFLAGS, sigcontext, eflags); | 26 | OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); |
24 | OFFSET(SC_EAX, sigcontext, eax); | 27 | OFFSET(HOST_SC_EAX, sigcontext, eax); |
25 | OFFSET(SC_EBX, sigcontext, ebx); | 28 | OFFSET(HOST_SC_EBX, sigcontext, ebx); |
26 | OFFSET(SC_ECX, sigcontext, ecx); | 29 | OFFSET(HOST_SC_ECX, sigcontext, ecx); |
27 | OFFSET(SC_EDX, sigcontext, edx); | 30 | OFFSET(HOST_SC_EDX, sigcontext, edx); |
28 | OFFSET(SC_EDI, sigcontext, edi); | 31 | OFFSET(HOST_SC_EDI, sigcontext, edi); |
29 | OFFSET(SC_ESI, sigcontext, esi); | 32 | OFFSET(HOST_SC_ESI, sigcontext, esi); |
30 | OFFSET(SC_EBP, sigcontext, ebp); | 33 | OFFSET(HOST_SC_EBP, sigcontext, ebp); |
31 | OFFSET(SC_TRAPNO, sigcontext, trapno); | 34 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
32 | OFFSET(SC_ERR, sigcontext, err); | 35 | OFFSET(HOST_SC_ERR, sigcontext, err); |
33 | OFFSET(SC_CR2, sigcontext, cr2); | 36 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
34 | OFFSET(SC_FPSTATE, sigcontext, fpstate); | 37 | OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate); |
35 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | 38 | OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); |
36 | OFFSET(SC_FP_CW, _fpstate, cw); | 39 | OFFSET(HOST_SC_FP_CW, _fpstate, cw); |
37 | OFFSET(SC_FP_SW, _fpstate, sw); | 40 | OFFSET(HOST_SC_FP_SW, _fpstate, sw); |
38 | OFFSET(SC_FP_TAG, _fpstate, tag); | 41 | OFFSET(HOST_SC_FP_TAG, _fpstate, tag); |
39 | OFFSET(SC_FP_IPOFF, _fpstate, ipoff); | 42 | OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff); |
40 | OFFSET(SC_FP_CSSEL, _fpstate, cssel); | 43 | OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel); |
41 | OFFSET(SC_FP_DATAOFF, _fpstate, dataoff); | 44 | OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff); |
42 | OFFSET(SC_FP_DATASEL, _fpstate, datasel); | 45 | OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel); |
43 | OFFSET(SC_FP_ST, _fpstate, _st); | 46 | OFFSET(HOST_SC_FP_ST, _fpstate, _st); |
44 | OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env); | 47 | OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env); |
45 | 48 | ||
46 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | 49 | DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE); |
47 | DEFINE(HOST_FP_SIZE, | 50 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct)); |
48 | sizeof(struct user_i387_struct) / sizeof(unsigned long)); | 51 | DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct)); |
49 | DEFINE(HOST_XFP_SIZE, | ||
50 | sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); | ||
51 | 52 | ||
52 | DEFINE(HOST_IP, EIP); | 53 | DEFINE(HOST_IP, EIP); |
53 | DEFINE(HOST_SP, UESP); | 54 | DEFINE(HOST_SP, UESP); |
@@ -65,5 +66,5 @@ void foo(void) | |||
65 | DEFINE(HOST_FS, FS); | 66 | DEFINE(HOST_FS, FS); |
66 | DEFINE(HOST_ES, ES); | 67 | DEFINE(HOST_ES, ES); |
67 | DEFINE(HOST_GS, GS); | 68 | DEFINE(HOST_GS, GS); |
68 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | 69 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
69 | } | 70 | } |
diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile deleted file mode 100644 index bf61afd0b045..000000000000 --- a/arch/um/sys-i386/util/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | hostprogs-y := mk_sc mk_thread | ||
2 | always := $(hostprogs-y) | ||
3 | |||
4 | HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um | ||
5 | HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/sys-i386/util/mk_sc.c b/arch/um/sys-i386/util/mk_sc.c deleted file mode 100644 index 04c0d73433aa..000000000000 --- a/arch/um/sys-i386/util/mk_sc.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <user-offsets.h> | ||
3 | |||
4 | #define SC_OFFSET(name, field) \ | ||
5 | printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ | ||
6 | name) | ||
7 | |||
8 | #define SC_FP_OFFSET(name, field) \ | ||
9 | printf("#define " #name \ | ||
10 | "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | ||
11 | name) | ||
12 | |||
13 | #define SC_FP_OFFSET_PTR(name, field, type) \ | ||
14 | printf("#define " #name \ | ||
15 | "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | ||
16 | name) | ||
17 | |||
18 | int main(int argc, char **argv) | ||
19 | { | ||
20 | SC_OFFSET(SC_IP, eip); | ||
21 | SC_OFFSET(SC_SP, esp); | ||
22 | SC_OFFSET(SC_FS, fs); | ||
23 | SC_OFFSET(SC_GS, gs); | ||
24 | SC_OFFSET(SC_DS, ds); | ||
25 | SC_OFFSET(SC_ES, es); | ||
26 | SC_OFFSET(SC_SS, ss); | ||
27 | SC_OFFSET(SC_CS, cs); | ||
28 | SC_OFFSET(SC_EFLAGS, eflags); | ||
29 | SC_OFFSET(SC_EAX, eax); | ||
30 | SC_OFFSET(SC_EBX, ebx); | ||
31 | SC_OFFSET(SC_ECX, ecx); | ||
32 | SC_OFFSET(SC_EDX, edx); | ||
33 | SC_OFFSET(SC_EDI, edi); | ||
34 | SC_OFFSET(SC_ESI, esi); | ||
35 | SC_OFFSET(SC_EBP, ebp); | ||
36 | SC_OFFSET(SC_TRAPNO, trapno); | ||
37 | SC_OFFSET(SC_ERR, err); | ||
38 | SC_OFFSET(SC_CR2, cr2); | ||
39 | SC_OFFSET(SC_FPSTATE, fpstate); | ||
40 | SC_OFFSET(SC_SIGMASK, oldmask); | ||
41 | SC_FP_OFFSET(SC_FP_CW, cw); | ||
42 | SC_FP_OFFSET(SC_FP_SW, sw); | ||
43 | SC_FP_OFFSET(SC_FP_TAG, tag); | ||
44 | SC_FP_OFFSET(SC_FP_IPOFF, ipoff); | ||
45 | SC_FP_OFFSET(SC_FP_CSSEL, cssel); | ||
46 | SC_FP_OFFSET(SC_FP_DATAOFF, dataoff); | ||
47 | SC_FP_OFFSET(SC_FP_DATASEL, datasel); | ||
48 | SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate"); | ||
49 | SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void"); | ||
50 | return(0); | ||
51 | } | ||
diff --git a/arch/um/sys-i386/util/mk_thread.c b/arch/um/sys-i386/util/mk_thread.c deleted file mode 100644 index 7470d0dda67e..000000000000 --- a/arch/um/sys-i386/util/mk_thread.c +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
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-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index f0ab574d1e95..06c3633457a2 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile | |||
@@ -29,6 +29,4 @@ module.c-dir = kernel | |||
29 | 29 | ||
30 | $(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS)) | 30 | $(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS)) |
31 | 31 | ||
32 | subdir- := util | ||
33 | |||
34 | include arch/um/scripts/Makefile.unmap | 32 | include arch/um/scripts/Makefile.unmap |
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/sys-x86_64/kernel-offsets.c index 998541eade41..bfcb104b846e 100644 --- a/arch/um/sys-x86_64/kernel-offsets.c +++ b/arch/um/sys-x86_64/kernel-offsets.c | |||
@@ -19,7 +19,7 @@ | |||
19 | void foo(void) | 19 | void foo(void) |
20 | { | 20 | { |
21 | #ifdef CONFIG_MODE_TT | 21 | #ifdef CONFIG_MODE_TT |
22 | OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); | 22 | OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); |
23 | #endif | 23 | #endif |
24 | #include <common-offsets.h> | 24 | #include <common-offsets.h> |
25 | } | 25 | } |
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c index 513d17ceafd4..5a585bfbb8c2 100644 --- a/arch/um/sys-x86_64/user-offsets.c +++ b/arch/um/sys-x86_64/user-offsets.c | |||
@@ -16,71 +16,76 @@ typedef __u32 u32; | |||
16 | #define DEFINE(sym, val) \ | 16 | #define DEFINE(sym, val) \ |
17 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | 17 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
18 | 18 | ||
19 | #define DEFINE_LONGS(sym, val) \ | ||
20 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) | ||
21 | |||
19 | #define OFFSET(sym, str, mem) \ | 22 | #define OFFSET(sym, str, mem) \ |
20 | DEFINE(sym, offsetof(struct str, mem)); | 23 | DEFINE(sym, offsetof(struct str, mem)); |
21 | 24 | ||
22 | void foo(void) | 25 | void foo(void) |
23 | { | 26 | { |
24 | OFFSET(SC_RBX, sigcontext, rbx); | 27 | OFFSET(HOST_SC_RBX, sigcontext, rbx); |
25 | OFFSET(SC_RCX, sigcontext, rcx); | 28 | OFFSET(HOST_SC_RCX, sigcontext, rcx); |
26 | OFFSET(SC_RDX, sigcontext, rdx); | 29 | OFFSET(HOST_SC_RDX, sigcontext, rdx); |
27 | OFFSET(SC_RSI, sigcontext, rsi); | 30 | OFFSET(HOST_SC_RSI, sigcontext, rsi); |
28 | OFFSET(SC_RDI, sigcontext, rdi); | 31 | OFFSET(HOST_SC_RDI, sigcontext, rdi); |
29 | OFFSET(SC_RBP, sigcontext, rbp); | 32 | OFFSET(HOST_SC_RBP, sigcontext, rbp); |
30 | OFFSET(SC_RAX, sigcontext, rax); | 33 | OFFSET(HOST_SC_RAX, sigcontext, rax); |
31 | OFFSET(SC_R8, sigcontext, r8); | 34 | OFFSET(HOST_SC_R8, sigcontext, r8); |
32 | OFFSET(SC_R9, sigcontext, r9); | 35 | OFFSET(HOST_SC_R9, sigcontext, r9); |
33 | OFFSET(SC_R10, sigcontext, r10); | 36 | OFFSET(HOST_SC_R10, sigcontext, r10); |
34 | OFFSET(SC_R11, sigcontext, r11); | 37 | OFFSET(HOST_SC_R11, sigcontext, r11); |
35 | OFFSET(SC_R12, sigcontext, r12); | 38 | OFFSET(HOST_SC_R12, sigcontext, r12); |
36 | OFFSET(SC_R13, sigcontext, r13); | 39 | OFFSET(HOST_SC_R13, sigcontext, r13); |
37 | OFFSET(SC_R14, sigcontext, r14); | 40 | OFFSET(HOST_SC_R14, sigcontext, r14); |
38 | OFFSET(SC_R15, sigcontext, r15); | 41 | OFFSET(HOST_SC_R15, sigcontext, r15); |
39 | OFFSET(SC_IP, sigcontext, rip); | 42 | OFFSET(HOST_SC_IP, sigcontext, rip); |
40 | OFFSET(SC_SP, sigcontext, rsp); | 43 | OFFSET(HOST_SC_SP, sigcontext, rsp); |
41 | OFFSET(SC_CR2, sigcontext, cr2); | 44 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
42 | OFFSET(SC_ERR, sigcontext, err); | 45 | OFFSET(HOST_SC_ERR, sigcontext, err); |
43 | OFFSET(SC_TRAPNO, sigcontext, trapno); | 46 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
44 | OFFSET(SC_CS, sigcontext, cs); | 47 | OFFSET(HOST_SC_CS, sigcontext, cs); |
45 | OFFSET(SC_FS, sigcontext, fs); | 48 | OFFSET(HOST_SC_FS, sigcontext, fs); |
46 | OFFSET(SC_GS, sigcontext, gs); | 49 | OFFSET(HOST_SC_GS, sigcontext, gs); |
47 | OFFSET(SC_EFLAGS, sigcontext, eflags); | 50 | OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); |
48 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | 51 | OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); |
49 | #if 0 | 52 | #if 0 |
50 | OFFSET(SC_ORIG_RAX, sigcontext, orig_rax); | 53 | OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax); |
51 | OFFSET(SC_DS, sigcontext, ds); | 54 | OFFSET(HOST_SC_DS, sigcontext, ds); |
52 | OFFSET(SC_ES, sigcontext, es); | 55 | OFFSET(HOST_SC_ES, sigcontext, es); |
53 | OFFSET(SC_SS, sigcontext, ss); | 56 | OFFSET(HOST_SC_SS, sigcontext, ss); |
54 | #endif | 57 | #endif |
55 | 58 | ||
56 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | 59 | DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE); |
57 | DEFINE(HOST_RBX, RBX); | 60 | DEFINE(HOST_FP_SIZE, 0); |
58 | DEFINE(HOST_RCX, RCX); | 61 | DEFINE(HOST_XFP_SIZE, 0); |
59 | DEFINE(HOST_RDI, RDI); | 62 | DEFINE_LONGS(HOST_RBX, RBX); |
60 | DEFINE(HOST_RSI, RSI); | 63 | DEFINE_LONGS(HOST_RCX, RCX); |
61 | DEFINE(HOST_RDX, RDX); | 64 | DEFINE_LONGS(HOST_RDI, RDI); |
62 | DEFINE(HOST_RBP, RBP); | 65 | DEFINE_LONGS(HOST_RSI, RSI); |
63 | DEFINE(HOST_RAX, RAX); | 66 | DEFINE_LONGS(HOST_RDX, RDX); |
64 | DEFINE(HOST_R8, R8); | 67 | DEFINE_LONGS(HOST_RBP, RBP); |
65 | DEFINE(HOST_R9, R9); | 68 | DEFINE_LONGS(HOST_RAX, RAX); |
66 | DEFINE(HOST_R10, R10); | 69 | DEFINE_LONGS(HOST_R8, R8); |
67 | DEFINE(HOST_R11, R11); | 70 | DEFINE_LONGS(HOST_R9, R9); |
68 | DEFINE(HOST_R12, R12); | 71 | DEFINE_LONGS(HOST_R10, R10); |
69 | DEFINE(HOST_R13, R13); | 72 | DEFINE_LONGS(HOST_R11, R11); |
70 | DEFINE(HOST_R14, R14); | 73 | DEFINE_LONGS(HOST_R12, R12); |
71 | DEFINE(HOST_R15, R15); | 74 | DEFINE_LONGS(HOST_R13, R13); |
72 | DEFINE(HOST_ORIG_RAX, ORIG_RAX); | 75 | DEFINE_LONGS(HOST_R14, R14); |
73 | DEFINE(HOST_CS, CS); | 76 | DEFINE_LONGS(HOST_R15, R15); |
74 | DEFINE(HOST_SS, SS); | 77 | DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX); |
75 | DEFINE(HOST_EFLAGS, EFLAGS); | 78 | DEFINE_LONGS(HOST_CS, CS); |
79 | DEFINE_LONGS(HOST_SS, SS); | ||
80 | DEFINE_LONGS(HOST_EFLAGS, EFLAGS); | ||
76 | #if 0 | 81 | #if 0 |
77 | DEFINE(HOST_FS, FS); | 82 | DEFINE_LONGS(HOST_FS, FS); |
78 | DEFINE(HOST_GS, GS); | 83 | DEFINE_LONGS(HOST_GS, GS); |
79 | DEFINE(HOST_DS, DS); | 84 | DEFINE_LONGS(HOST_DS, DS); |
80 | DEFINE(HOST_ES, ES); | 85 | DEFINE_LONGS(HOST_ES, ES); |
81 | #endif | 86 | #endif |
82 | 87 | ||
83 | DEFINE(HOST_IP, RIP); | 88 | DEFINE_LONGS(HOST_IP, RIP); |
84 | DEFINE(HOST_SP, RSP); | 89 | DEFINE_LONGS(HOST_SP, RSP); |
85 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | 90 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
86 | } | 91 | } |
diff --git a/arch/um/sys-x86_64/util/Makefile b/arch/um/sys-x86_64/util/Makefile deleted file mode 100644 index 75b052cfc206..000000000000 --- a/arch/um/sys-x86_64/util/Makefile +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | # Copyright 2003 - 2004 Pathscale, Inc | ||
2 | # Released under the GPL | ||
3 | |||
4 | hostprogs-y := mk_sc mk_thread | ||
5 | always := $(hostprogs-y) | ||
6 | |||
7 | HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um | ||
8 | HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/sys-x86_64/util/mk_sc.c b/arch/um/sys-x86_64/util/mk_sc.c deleted file mode 100644 index 7619bc377c1f..000000000000 --- a/arch/um/sys-x86_64/util/mk_sc.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* Copyright (C) 2003 - 2004 PathScale, Inc | ||
2 | * Released under the GPL | ||
3 | */ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <user-offsets.h> | ||
7 | |||
8 | #define SC_OFFSET(name) \ | ||
9 | printf("#define " #name \ | ||
10 | "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ | ||
11 | name) | ||
12 | |||
13 | int main(int argc, char **argv) | ||
14 | { | ||
15 | SC_OFFSET(SC_RBX); | ||
16 | SC_OFFSET(SC_RCX); | ||
17 | SC_OFFSET(SC_RDX); | ||
18 | SC_OFFSET(SC_RSI); | ||
19 | SC_OFFSET(SC_RDI); | ||
20 | SC_OFFSET(SC_RBP); | ||
21 | SC_OFFSET(SC_RAX); | ||
22 | SC_OFFSET(SC_R8); | ||
23 | SC_OFFSET(SC_R9); | ||
24 | SC_OFFSET(SC_R10); | ||
25 | SC_OFFSET(SC_R11); | ||
26 | SC_OFFSET(SC_R12); | ||
27 | SC_OFFSET(SC_R13); | ||
28 | SC_OFFSET(SC_R14); | ||
29 | SC_OFFSET(SC_R15); | ||
30 | SC_OFFSET(SC_IP); | ||
31 | SC_OFFSET(SC_SP); | ||
32 | SC_OFFSET(SC_CR2); | ||
33 | SC_OFFSET(SC_ERR); | ||
34 | SC_OFFSET(SC_TRAPNO); | ||
35 | SC_OFFSET(SC_CS); | ||
36 | SC_OFFSET(SC_FS); | ||
37 | SC_OFFSET(SC_GS); | ||
38 | SC_OFFSET(SC_EFLAGS); | ||
39 | SC_OFFSET(SC_SIGMASK); | ||
40 | #if 0 | ||
41 | SC_OFFSET(SC_ORIG_RAX); | ||
42 | SC_OFFSET(SC_DS); | ||
43 | SC_OFFSET(SC_ES); | ||
44 | SC_OFFSET(SC_SS); | ||
45 | #endif | ||
46 | return(0); | ||
47 | } | ||
diff --git a/arch/um/sys-x86_64/util/mk_thread.c b/arch/um/sys-x86_64/util/mk_thread.c deleted file mode 100644 index 15517396e9cf..000000000000 --- a/arch/um/sys-x86_64/util/mk_thread.c +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
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/util/Makefile b/arch/um/util/Makefile deleted file mode 100644 index 4c7551c28033..000000000000 --- a/arch/um/util/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | hostprogs-y := mk_task mk_constants | ||
2 | always := $(hostprogs-y) | ||
3 | |||
4 | HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um | ||
5 | HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/util/mk_constants.c b/arch/um/util/mk_constants.c deleted file mode 100644 index ab217becc36a..000000000000 --- a/arch/um/util/mk_constants.c +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
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_task.c b/arch/um/util/mk_task.c deleted file mode 100644 index 36c9606505e2..000000000000 --- a/arch/um/util/mk_task.c +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | void print_ptr(char *name, char *type, int offset) | ||
5 | { | ||
6 | printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type, | ||
7 | offset); | ||
8 | } | ||
9 | |||
10 | void print(char *name, char *type, int offset) | ||
11 | { | ||
12 | printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, | ||
13 | offset); | ||
14 | } | ||
15 | |||
16 | int main(int argc, char **argv) | ||
17 | { | ||
18 | printf("/*\n"); | ||
19 | printf(" * Generated by mk_task\n"); | ||
20 | printf(" */\n"); | ||
21 | printf("\n"); | ||
22 | printf("#ifndef __TASK_H\n"); | ||
23 | printf("#define __TASK_H\n"); | ||
24 | printf("\n"); | ||
25 | print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS); | ||
26 | print("TASK_PID", "int", TASK_PID); | ||
27 | printf("\n"); | ||
28 | printf("#endif\n"); | ||
29 | return(0); | ||
30 | } | ||