diff options
Diffstat (limited to 'arch/um')
57 files changed, 846 insertions, 1029 deletions
diff --git a/arch/um/Makefile b/arch/um/Makefile index 5b5af95721ab..e1ffad224605 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,9 +43,7 @@ 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 | ||
| @@ -87,10 +83,6 @@ CONFIG_KERNEL_HALF_GIGS ?= 0 | |||
| 87 | 83 | ||
| 88 | SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) | 84 | SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) |
| 89 | 85 | ||
| 90 | ifeq ($(CONFIG_MODE_SKAS), y) | ||
| 91 | $(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h | ||
| 92 | endif | ||
| 93 | |||
| 94 | .PHONY: linux | 86 | .PHONY: linux |
| 95 | 87 | ||
| 96 | all: linux | 88 | all: linux |
| @@ -111,7 +103,8 @@ else | |||
| 111 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) | 103 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) |
| 112 | endif | 104 | endif |
| 113 | 105 | ||
| 114 | 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 | ||
| 115 | 108 | ||
| 116 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static | 109 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static |
| 117 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib | 110 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib |
| @@ -146,22 +139,20 @@ endef | |||
| 146 | #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 |
| 147 | #TT or skas makefiles and don't clean skas_ptregs.h. | 140 | #TT or skas makefiles and don't clean skas_ptregs.h. |
| 148 | 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 \ |
| 149 | $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \ | 142 | $(ARCH_DIR)/include/user_constants.h \ |
| 150 | $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch | 143 | $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch |
| 151 | 144 | ||
| 152 | MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ | 145 | MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ |
| 153 | $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os | 146 | $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os |
| 154 | 147 | ||
| 155 | archclean: | 148 | archclean: |
| 156 | $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util | ||
| 157 | $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util | ||
| 158 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ | 149 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ |
| 159 | -o -name '*.gcov' \) -type f -print | xargs rm -f | 150 | -o -name '*.gcov' \) -type f -print | xargs rm -f |
| 160 | 151 | ||
| 161 | $(SYMLINK_HEADERS): | 152 | $(SYMLINK_HEADERS): |
| 162 | @echo ' SYMLINK $@' | 153 | @echo ' SYMLINK $@' |
| 163 | ifneq ($(KBUILD_SRC),) | 154 | ifneq ($(KBUILD_SRC),) |
| 164 | ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ | 155 | $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ |
| 165 | else | 156 | else |
| 166 | $(Q)cd $(TOPDIR)/$(dir $@) ; \ | 157 | $(Q)cd $(TOPDIR)/$(dir $@) ; \ |
| 167 | ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) | 158 | ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) |
| @@ -180,9 +171,7 @@ $(ARCH_DIR)/include/sysdep: | |||
| 180 | @echo ' SYMLINK $@' | 171 | @echo ' SYMLINK $@' |
| 181 | ifneq ($(KBUILD_SRC),) | 172 | ifneq ($(KBUILD_SRC),) |
| 182 | $(Q)mkdir -p $(ARCH_DIR)/include | 173 | $(Q)mkdir -p $(ARCH_DIR)/include |
| 183 | $(Q)mkdir -p $(ARCH_DIR)/include2 | 174 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep |
| 184 | $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep | ||
| 185 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep | ||
| 186 | else | 175 | else |
| 187 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep | 176 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep |
| 188 | endif | 177 | endif |
| @@ -202,8 +191,6 @@ endef | |||
| 202 | 191 | ||
| 203 | define filechk_gen-asm-offsets | 192 | define filechk_gen-asm-offsets |
| 204 | (set -e; \ | 193 | (set -e; \ |
| 205 | echo "#ifndef __ASM_OFFSETS_H__"; \ | ||
| 206 | echo "#define __ASM_OFFSETS_H__"; \ | ||
| 207 | echo "/*"; \ | 194 | echo "/*"; \ |
| 208 | echo " * DO NOT MODIFY."; \ | 195 | echo " * DO NOT MODIFY."; \ |
| 209 | echo " *"; \ | 196 | echo " *"; \ |
| @@ -212,8 +199,7 @@ define filechk_gen-asm-offsets | |||
| 212 | echo " */"; \ | 199 | echo " */"; \ |
| 213 | echo ""; \ | 200 | echo ""; \ |
| 214 | sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ | 201 | sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ |
| 215 | echo ""; \ | 202 | echo ""; ) |
| 216 | echo "#endif" ) | ||
| 217 | endef | 203 | endef |
| 218 | 204 | ||
| 219 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | 205 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h |
| @@ -222,50 +208,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | |||
| 222 | $(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 |
| 223 | $(CC) $(USER_CFLAGS) -S -o $@ $< | 209 | $(CC) $(USER_CFLAGS) -S -o $@ $< |
| 224 | 210 | ||
| 225 | $(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s | 211 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s |
| 226 | $(call filechk,gen-asm-offsets) | 212 | $(call filechk,gen-asm-offsets) |
| 227 | 213 | ||
| 228 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h | 214 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s |
| 229 | 215 | ||
| 230 | $(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 \ |
| 231 | $(ARCH_SYMLINKS) \ | 217 | archprepare |
| 232 | $(SYS_DIR)/sc.h \ | ||
| 233 | include/asm include/linux/version.h \ | ||
| 234 | include/config/MARKER \ | ||
| 235 | $(ARCH_DIR)/include/user_constants.h | ||
| 236 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< | 218 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< |
| 237 | 219 | ||
| 238 | $(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s | 220 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s |
| 239 | $(call filechk,gen-asm-offsets) | 221 | $(call filechk,gen-asm-offsets) |
| 240 | 222 | ||
| 241 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h | 223 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s |
| 242 | |||
| 243 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task | ||
| 244 | $(call filechk,gen_header) | ||
| 245 | |||
| 246 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants | ||
| 247 | $(call filechk,gen_header) | ||
| 248 | |||
| 249 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants | ||
| 250 | $(call filechk,gen_header) | ||
| 251 | |||
| 252 | $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs | ||
| 253 | $(call filechk,gen_header) | ||
| 254 | |||
| 255 | $(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ; | ||
| 256 | |||
| 257 | $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ | ||
| 258 | FORCE ; | ||
| 259 | |||
| 260 | $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; | ||
| 261 | |||
| 262 | $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE | ||
| 263 | $(Q)$(MAKE) $(build)=$@ | ||
| 264 | |||
| 265 | $(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
| 266 | $(Q)$(MAKE) $(build)=$@ | ||
| 267 | |||
| 268 | $(ARCH_DIR)/os-$(OS)/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
| 269 | $(Q)$(MAKE) $(build)=$@ | ||
| 270 | 224 | ||
| 271 | 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/Makefile b/arch/um/drivers/Makefile index 783e18cae090..de17d4c6e02d 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile | |||
| @@ -13,7 +13,7 @@ mcast-objs := mcast_kern.o mcast_user.o | |||
| 13 | net-objs := net_kern.o net_user.o | 13 | net-objs := net_kern.o net_user.o |
| 14 | mconsole-objs := mconsole_kern.o mconsole_user.o | 14 | mconsole-objs := mconsole_kern.o mconsole_user.o |
| 15 | hostaudio-objs := hostaudio_kern.o | 15 | hostaudio-objs := hostaudio_kern.o |
| 16 | ubd-objs := ubd_kern.o | 16 | ubd-objs := ubd_kern.o ubd_user.o |
| 17 | port-objs := port_kern.o port_user.o | 17 | port-objs := port_kern.o port_user.o |
| 18 | harddog-objs := harddog_kern.o harddog_user.o | 18 | harddog-objs := harddog_kern.o harddog_user.o |
| 19 | 19 | ||
diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h index 4fcf3a8d13f4..dc36b222100b 100644 --- a/arch/um/drivers/cow.h +++ b/arch/um/drivers/cow.h | |||
| @@ -3,15 +3,40 @@ | |||
| 3 | 3 | ||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | #if defined(__BIG_ENDIAN) | 6 | #if defined(__KERNEL__) |
| 7 | # define ntohll(x) (x) | 7 | |
| 8 | # define htonll(x) (x) | 8 | # include <asm/byteorder.h> |
| 9 | #elif defined(__LITTLE_ENDIAN) | 9 | |
| 10 | # define ntohll(x) bswap_64(x) | 10 | # if defined(__BIG_ENDIAN) |
| 11 | # define htonll(x) bswap_64(x) | 11 | # define ntohll(x) (x) |
| 12 | # define htonll(x) (x) | ||
| 13 | # elif defined(__LITTLE_ENDIAN) | ||
| 14 | # define ntohll(x) be64_to_cpu(x) | ||
| 15 | # define htonll(x) cpu_to_be64(x) | ||
| 16 | # else | ||
| 17 | # error "Could not determine byte order" | ||
| 18 | # endif | ||
| 19 | |||
| 12 | #else | 20 | #else |
| 13 | #error "__BYTE_ORDER not defined" | 21 | /* For the definition of ntohl, htonl and __BYTE_ORDER */ |
| 22 | #include <endian.h> | ||
| 23 | #include <netinet/in.h> | ||
| 24 | #if defined(__BYTE_ORDER) | ||
| 25 | |||
| 26 | # if __BYTE_ORDER == __BIG_ENDIAN | ||
| 27 | # define ntohll(x) (x) | ||
| 28 | # define htonll(x) (x) | ||
| 29 | # elif __BYTE_ORDER == __LITTLE_ENDIAN | ||
| 30 | # define ntohll(x) bswap_64(x) | ||
| 31 | # define htonll(x) bswap_64(x) | ||
| 32 | # else | ||
| 33 | # error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" | ||
| 34 | # endif | ||
| 35 | |||
| 36 | #else /* ! defined(__BYTE_ORDER) */ | ||
| 37 | # error "Could not determine byte order: __BYTE_ORDER not defined" | ||
| 14 | #endif | 38 | #endif |
| 39 | #endif /* ! defined(__KERNEL__) */ | ||
| 15 | 40 | ||
| 16 | extern int init_cow_file(int fd, char *cow_file, char *backing_file, | 41 | extern int init_cow_file(int fd, char *cow_file, char *backing_file, |
| 17 | int sectorsize, int alignment, int *bitmap_offset_out, | 42 | int sectorsize, int alignment, int *bitmap_offset_out, |
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c index a8ce6fc3ef26..fbe2217db5dd 100644 --- a/arch/um/drivers/cow_user.c +++ b/arch/um/drivers/cow_user.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include <sys/time.h> | 9 | #include <sys/time.h> |
| 10 | #include <sys/param.h> | 10 | #include <sys/param.h> |
| 11 | #include <sys/user.h> | 11 | #include <sys/user.h> |
| 12 | #include <netinet/in.h> | ||
| 13 | 12 | ||
| 14 | #include "os.h" | 13 | #include "os.h" |
| 15 | 14 | ||
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index 04383f98f4d5..310c1f823f26 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c | |||
| @@ -23,7 +23,7 @@ static struct mconsole_command commands[] = { | |||
| 23 | { "reboot", mconsole_reboot, MCONSOLE_PROC }, | 23 | { "reboot", mconsole_reboot, MCONSOLE_PROC }, |
| 24 | { "config", mconsole_config, MCONSOLE_PROC }, | 24 | { "config", mconsole_config, MCONSOLE_PROC }, |
| 25 | { "remove", mconsole_remove, MCONSOLE_PROC }, | 25 | { "remove", mconsole_remove, MCONSOLE_PROC }, |
| 26 | { "sysrq", mconsole_sysrq, MCONSOLE_PROC }, | 26 | { "sysrq", mconsole_sysrq, MCONSOLE_INTR }, |
| 27 | { "help", mconsole_help, MCONSOLE_INTR }, | 27 | { "help", mconsole_help, MCONSOLE_INTR }, |
| 28 | { "cad", mconsole_cad, MCONSOLE_INTR }, | 28 | { "cad", mconsole_cad, MCONSOLE_INTR }, |
| 29 | { "stop", mconsole_stop, MCONSOLE_PROC }, | 29 | { "stop", mconsole_stop, MCONSOLE_PROC }, |
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/ubd_kern.c b/arch/um/drivers/ubd_kern.c index e77a38da4350..f73134333f64 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
| @@ -35,7 +35,6 @@ | |||
| 35 | #include "linux/blkpg.h" | 35 | #include "linux/blkpg.h" |
| 36 | #include "linux/genhd.h" | 36 | #include "linux/genhd.h" |
| 37 | #include "linux/spinlock.h" | 37 | #include "linux/spinlock.h" |
| 38 | #include "asm/atomic.h" | ||
| 39 | #include "asm/segment.h" | 38 | #include "asm/segment.h" |
| 40 | #include "asm/uaccess.h" | 39 | #include "asm/uaccess.h" |
| 41 | #include "asm/irq.h" | 40 | #include "asm/irq.h" |
| @@ -54,21 +53,20 @@ | |||
| 54 | #include "mem.h" | 53 | #include "mem.h" |
| 55 | #include "mem_kern.h" | 54 | #include "mem_kern.h" |
| 56 | #include "cow.h" | 55 | #include "cow.h" |
| 57 | #include "aio.h" | ||
| 58 | 56 | ||
| 59 | enum ubd_req { UBD_READ, UBD_WRITE }; | 57 | enum ubd_req { UBD_READ, UBD_WRITE }; |
| 60 | 58 | ||
| 61 | struct io_thread_req { | 59 | struct io_thread_req { |
| 62 | enum aio_type op; | 60 | enum ubd_req op; |
| 63 | int fds[2]; | 61 | int fds[2]; |
| 64 | unsigned long offsets[2]; | 62 | unsigned long offsets[2]; |
| 65 | unsigned long long offset; | 63 | unsigned long long offset; |
| 66 | unsigned long length; | 64 | unsigned long length; |
| 67 | char *buffer; | 65 | char *buffer; |
| 68 | int sectorsize; | 66 | int sectorsize; |
| 69 | int bitmap_offset; | 67 | unsigned long sector_mask; |
| 70 | long bitmap_start; | 68 | unsigned long long cow_offset; |
| 71 | long bitmap_end; | 69 | unsigned long bitmap_words[2]; |
| 72 | int error; | 70 | int error; |
| 73 | }; | 71 | }; |
| 74 | 72 | ||
| @@ -82,31 +80,28 @@ extern int create_cow_file(char *cow_file, char *backing_file, | |||
| 82 | unsigned long *bitmap_len_out, | 80 | unsigned long *bitmap_len_out, |
| 83 | int *data_offset_out); | 81 | int *data_offset_out); |
| 84 | extern int read_cow_bitmap(int fd, void *buf, int offset, int len); | 82 | extern int read_cow_bitmap(int fd, void *buf, int offset, int len); |
| 85 | extern void do_io(struct io_thread_req *req, struct request *r, | 83 | extern void do_io(struct io_thread_req *req); |
| 86 | unsigned long *bitmap); | ||
| 87 | 84 | ||
| 88 | static inline int ubd_test_bit(__u64 bit, void *data) | 85 | static inline int ubd_test_bit(__u64 bit, unsigned char *data) |
| 89 | { | 86 | { |
| 90 | unsigned char *buffer = data; | ||
| 91 | __u64 n; | 87 | __u64 n; |
| 92 | int bits, off; | 88 | int bits, off; |
| 93 | 89 | ||
| 94 | bits = sizeof(buffer[0]) * 8; | 90 | bits = sizeof(data[0]) * 8; |
| 95 | n = bit / bits; | 91 | n = bit / bits; |
| 96 | off = bit % bits; | 92 | off = bit % bits; |
| 97 | return((buffer[n] & (1 << off)) != 0); | 93 | return((data[n] & (1 << off)) != 0); |
| 98 | } | 94 | } |
| 99 | 95 | ||
| 100 | static inline void ubd_set_bit(__u64 bit, void *data) | 96 | static inline void ubd_set_bit(__u64 bit, unsigned char *data) |
| 101 | { | 97 | { |
| 102 | unsigned char *buffer = data; | ||
| 103 | __u64 n; | 98 | __u64 n; |
| 104 | int bits, off; | 99 | int bits, off; |
| 105 | 100 | ||
| 106 | bits = sizeof(buffer[0]) * 8; | 101 | bits = sizeof(data[0]) * 8; |
| 107 | n = bit / bits; | 102 | n = bit / bits; |
| 108 | off = bit % bits; | 103 | off = bit % bits; |
| 109 | buffer[n] |= (1 << off); | 104 | data[n] |= (1 << off); |
| 110 | } | 105 | } |
| 111 | /*End stuff from ubd_user.h*/ | 106 | /*End stuff from ubd_user.h*/ |
| 112 | 107 | ||
| @@ -115,6 +110,8 @@ static inline void ubd_set_bit(__u64 bit, void *data) | |||
| 115 | static DEFINE_SPINLOCK(ubd_io_lock); | 110 | static DEFINE_SPINLOCK(ubd_io_lock); |
| 116 | static DEFINE_SPINLOCK(ubd_lock); | 111 | static DEFINE_SPINLOCK(ubd_lock); |
| 117 | 112 | ||
| 113 | static void (*do_ubd)(void); | ||
| 114 | |||
| 118 | static int ubd_open(struct inode * inode, struct file * filp); | 115 | static int ubd_open(struct inode * inode, struct file * filp); |
| 119 | static int ubd_release(struct inode * inode, struct file * file); | 116 | static int ubd_release(struct inode * inode, struct file * file); |
| 120 | static int ubd_ioctl(struct inode * inode, struct file * file, | 117 | static int ubd_ioctl(struct inode * inode, struct file * file, |
| @@ -161,8 +158,6 @@ struct cow { | |||
| 161 | int data_offset; | 158 | int data_offset; |
| 162 | }; | 159 | }; |
| 163 | 160 | ||
| 164 | #define MAX_SG 64 | ||
| 165 | |||
| 166 | struct ubd { | 161 | struct ubd { |
| 167 | char *file; | 162 | char *file; |
| 168 | int count; | 163 | int count; |
| @@ -173,7 +168,6 @@ struct ubd { | |||
| 173 | int no_cow; | 168 | int no_cow; |
| 174 | struct cow cow; | 169 | struct cow cow; |
| 175 | struct platform_device pdev; | 170 | struct platform_device pdev; |
| 176 | struct scatterlist sg[MAX_SG]; | ||
| 177 | }; | 171 | }; |
| 178 | 172 | ||
| 179 | #define DEFAULT_COW { \ | 173 | #define DEFAULT_COW { \ |
| @@ -466,114 +460,81 @@ __uml_help(fakehd, | |||
| 466 | ); | 460 | ); |
| 467 | 461 | ||
| 468 | static void do_ubd_request(request_queue_t * q); | 462 | static void do_ubd_request(request_queue_t * q); |
| 469 | static int in_ubd; | 463 | |
| 464 | /* Only changed by ubd_init, which is an initcall. */ | ||
| 465 | int thread_fd = -1; | ||
| 470 | 466 | ||
| 471 | /* Changed by ubd_handler, which is serialized because interrupts only | 467 | /* Changed by ubd_handler, which is serialized because interrupts only |
| 472 | * happen on CPU 0. | 468 | * happen on CPU 0. |
| 473 | */ | 469 | */ |
| 474 | int intr_count = 0; | 470 | int intr_count = 0; |
| 475 | 471 | ||
| 476 | static void ubd_end_request(struct request *req, int bytes, int uptodate) | 472 | /* call ubd_finish if you need to serialize */ |
| 473 | static void __ubd_finish(struct request *req, int error) | ||
| 477 | { | 474 | { |
| 478 | if (!end_that_request_first(req, uptodate, bytes >> 9)) { | 475 | int nsect; |
| 479 | add_disk_randomness(req->rq_disk); | 476 | |
| 480 | end_that_request_last(req); | 477 | if(error){ |
| 478 | end_request(req, 0); | ||
| 479 | return; | ||
| 481 | } | 480 | } |
| 481 | nsect = req->current_nr_sectors; | ||
| 482 | req->sector += nsect; | ||
| 483 | req->buffer += nsect << 9; | ||
| 484 | req->errors = 0; | ||
| 485 | req->nr_sectors -= nsect; | ||
| 486 | req->current_nr_sectors = 0; | ||
| 487 | end_request(req, 1); | ||
| 482 | } | 488 | } |
| 483 | 489 | ||
| 484 | /* call ubd_finish if you need to serialize */ | 490 | static inline void ubd_finish(struct request *req, int error) |
| 485 | static void __ubd_finish(struct request *req, int bytes) | ||
| 486 | { | 491 | { |
| 487 | if(bytes < 0){ | 492 | spin_lock(&ubd_io_lock); |
| 488 | ubd_end_request(req, 0, 0); | 493 | __ubd_finish(req, error); |
| 489 | return; | 494 | spin_unlock(&ubd_io_lock); |
| 490 | } | ||
| 491 | |||
| 492 | ubd_end_request(req, bytes, 1); | ||
| 493 | } | 495 | } |
| 494 | 496 | ||
| 495 | static inline void ubd_finish(struct request *req, int bytes) | 497 | /* Called without ubd_io_lock held */ |
| 498 | static void ubd_handler(void) | ||
| 496 | { | 499 | { |
| 497 | spin_lock(&ubd_io_lock); | 500 | struct io_thread_req req; |
| 498 | __ubd_finish(req, bytes); | 501 | struct request *rq = elv_next_request(ubd_queue); |
| 499 | spin_unlock(&ubd_io_lock); | 502 | int n; |
| 503 | |||
| 504 | do_ubd = NULL; | ||
| 505 | intr_count++; | ||
| 506 | n = os_read_file(thread_fd, &req, sizeof(req)); | ||
| 507 | if(n != sizeof(req)){ | ||
| 508 | printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, " | ||
| 509 | "err = %d\n", os_getpid(), -n); | ||
| 510 | spin_lock(&ubd_io_lock); | ||
| 511 | end_request(rq, 0); | ||
| 512 | spin_unlock(&ubd_io_lock); | ||
| 513 | return; | ||
| 514 | } | ||
| 515 | |||
| 516 | ubd_finish(rq, req.error); | ||
| 517 | reactivate_fd(thread_fd, UBD_IRQ); | ||
| 518 | do_ubd_request(ubd_queue); | ||
| 500 | } | 519 | } |
| 501 | 520 | ||
| 502 | struct bitmap_io { | ||
| 503 | atomic_t count; | ||
| 504 | struct aio_context aio; | ||
| 505 | }; | ||
| 506 | |||
| 507 | struct ubd_aio { | ||
| 508 | struct aio_context aio; | ||
| 509 | struct request *req; | ||
| 510 | int len; | ||
| 511 | struct bitmap_io *bitmap; | ||
| 512 | void *bitmap_buf; | ||
| 513 | }; | ||
| 514 | |||
| 515 | static int ubd_reply_fd = -1; | ||
| 516 | |||
| 517 | static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused) | 521 | static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused) |
| 518 | { | 522 | { |
| 519 | struct aio_thread_reply reply; | 523 | ubd_handler(); |
| 520 | struct ubd_aio *aio; | 524 | return(IRQ_HANDLED); |
| 521 | struct request *req; | 525 | } |
| 522 | int err, n, fd = (int) (long) dev; | ||
| 523 | |||
| 524 | while(1){ | ||
| 525 | err = os_read_file(fd, &reply, sizeof(reply)); | ||
| 526 | if(err == -EAGAIN) | ||
| 527 | break; | ||
| 528 | if(err < 0){ | ||
| 529 | printk("ubd_aio_handler - read returned err %d\n", | ||
| 530 | -err); | ||
| 531 | break; | ||
| 532 | } | ||
| 533 | |||
| 534 | aio = container_of(reply.data, struct ubd_aio, aio); | ||
| 535 | n = reply.err; | ||
| 536 | |||
| 537 | if(n == 0){ | ||
| 538 | req = aio->req; | ||
| 539 | req->nr_sectors -= aio->len >> 9; | ||
| 540 | |||
| 541 | if((aio->bitmap != NULL) && | ||
| 542 | (atomic_dec_and_test(&aio->bitmap->count))){ | ||
| 543 | aio->aio = aio->bitmap->aio; | ||
| 544 | aio->len = 0; | ||
| 545 | kfree(aio->bitmap); | ||
| 546 | aio->bitmap = NULL; | ||
| 547 | submit_aio(&aio->aio); | ||
| 548 | } | ||
| 549 | else { | ||
| 550 | if((req->nr_sectors == 0) && | ||
| 551 | (aio->bitmap == NULL)){ | ||
| 552 | int len = req->hard_nr_sectors << 9; | ||
| 553 | ubd_finish(req, len); | ||
| 554 | } | ||
| 555 | |||
| 556 | if(aio->bitmap_buf != NULL) | ||
| 557 | kfree(aio->bitmap_buf); | ||
| 558 | kfree(aio); | ||
| 559 | } | ||
| 560 | } | ||
| 561 | else if(n < 0){ | ||
| 562 | ubd_finish(aio->req, n); | ||
| 563 | if(aio->bitmap != NULL) | ||
| 564 | kfree(aio->bitmap); | ||
| 565 | if(aio->bitmap_buf != NULL) | ||
| 566 | kfree(aio->bitmap_buf); | ||
| 567 | kfree(aio); | ||
| 568 | } | ||
| 569 | } | ||
| 570 | reactivate_fd(fd, UBD_IRQ); | ||
| 571 | 526 | ||
| 572 | do_ubd_request(ubd_queue); | 527 | /* Only changed by ubd_init, which is an initcall. */ |
| 528 | static int io_pid = -1; | ||
| 573 | 529 | ||
| 574 | return(IRQ_HANDLED); | 530 | void kill_io_thread(void) |
| 531 | { | ||
| 532 | if(io_pid != -1) | ||
| 533 | os_kill_process(io_pid, 1); | ||
| 575 | } | 534 | } |
| 576 | 535 | ||
| 536 | __uml_exitcall(kill_io_thread); | ||
| 537 | |||
| 577 | static int ubd_file_size(struct ubd *dev, __u64 *size_out) | 538 | static int ubd_file_size(struct ubd *dev, __u64 *size_out) |
| 578 | { | 539 | { |
| 579 | char *file; | 540 | char *file; |
| @@ -608,7 +569,7 @@ static int ubd_open_dev(struct ubd *dev) | |||
| 608 | &dev->cow.data_offset, create_ptr); | 569 | &dev->cow.data_offset, create_ptr); |
| 609 | 570 | ||
| 610 | if((dev->fd == -ENOENT) && create_cow){ | 571 | if((dev->fd == -ENOENT) && create_cow){ |
| 611 | dev->fd = create_cow_file(dev->file, dev->cow.file, | 572 | dev->fd = create_cow_file(dev->file, dev->cow.file, |
| 612 | dev->openflags, 1 << 9, PAGE_SIZE, | 573 | dev->openflags, 1 << 9, PAGE_SIZE, |
| 613 | &dev->cow.bitmap_offset, | 574 | &dev->cow.bitmap_offset, |
| 614 | &dev->cow.bitmap_len, | 575 | &dev->cow.bitmap_len, |
| @@ -870,10 +831,6 @@ int ubd_init(void) | |||
| 870 | { | 831 | { |
| 871 | int i; | 832 | int i; |
| 872 | 833 | ||
| 873 | ubd_reply_fd = init_aio_irq(UBD_IRQ, "ubd", ubd_intr); | ||
| 874 | if(ubd_reply_fd < 0) | ||
| 875 | printk("Setting up ubd AIO failed, err = %d\n", ubd_reply_fd); | ||
| 876 | |||
| 877 | devfs_mk_dir("ubd"); | 834 | devfs_mk_dir("ubd"); |
| 878 | if (register_blkdev(MAJOR_NR, "ubd")) | 835 | if (register_blkdev(MAJOR_NR, "ubd")) |
| 879 | return -1; | 836 | return -1; |
| @@ -884,7 +841,6 @@ int ubd_init(void) | |||
| 884 | return -1; | 841 | return -1; |
| 885 | } | 842 | } |
| 886 | 843 | ||
| 887 | blk_queue_max_hw_segments(ubd_queue, MAX_SG); | ||
| 888 | if (fake_major != MAJOR_NR) { | 844 | if (fake_major != MAJOR_NR) { |
| 889 | char name[sizeof("ubd_nnn\0")]; | 845 | char name[sizeof("ubd_nnn\0")]; |
| 890 | 846 | ||
| @@ -896,12 +852,40 @@ int ubd_init(void) | |||
| 896 | driver_register(&ubd_driver); | 852 | driver_register(&ubd_driver); |
| 897 | for (i = 0; i < MAX_DEV; i++) | 853 | for (i = 0; i < MAX_DEV; i++) |
| 898 | ubd_add(i); | 854 | ubd_add(i); |
| 899 | |||
| 900 | return 0; | 855 | return 0; |
| 901 | } | 856 | } |
| 902 | 857 | ||
| 903 | late_initcall(ubd_init); | 858 | late_initcall(ubd_init); |
| 904 | 859 | ||
| 860 | int ubd_driver_init(void){ | ||
| 861 | unsigned long stack; | ||
| 862 | int err; | ||
| 863 | |||
| 864 | /* Set by CONFIG_BLK_DEV_UBD_SYNC or ubd=sync.*/ | ||
| 865 | if(global_openflags.s){ | ||
| 866 | printk(KERN_INFO "ubd: Synchronous mode\n"); | ||
| 867 | /* Letting ubd=sync be like using ubd#s= instead of ubd#= is | ||
| 868 | * enough. So use anyway the io thread. */ | ||
| 869 | } | ||
| 870 | stack = alloc_stack(0, 0); | ||
| 871 | io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *), | ||
| 872 | &thread_fd); | ||
| 873 | if(io_pid < 0){ | ||
| 874 | printk(KERN_ERR | ||
| 875 | "ubd : Failed to start I/O thread (errno = %d) - " | ||
| 876 | "falling back to synchronous I/O\n", -io_pid); | ||
| 877 | io_pid = -1; | ||
| 878 | return(0); | ||
| 879 | } | ||
| 880 | err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, | ||
| 881 | SA_INTERRUPT, "ubd", ubd_dev); | ||
| 882 | if(err != 0) | ||
| 883 | printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err); | ||
| 884 | return(err); | ||
| 885 | } | ||
| 886 | |||
| 887 | device_initcall(ubd_driver_init); | ||
| 888 | |||
| 905 | static int ubd_open(struct inode *inode, struct file *filp) | 889 | static int ubd_open(struct inode *inode, struct file *filp) |
| 906 | { | 890 | { |
| 907 | struct gendisk *disk = inode->i_bdev->bd_disk; | 891 | struct gendisk *disk = inode->i_bdev->bd_disk; |
| @@ -939,55 +923,105 @@ static int ubd_release(struct inode * inode, struct file * file) | |||
| 939 | return(0); | 923 | return(0); |
| 940 | } | 924 | } |
| 941 | 925 | ||
| 942 | static void cowify_bitmap(struct io_thread_req *req, unsigned long *bitmap) | 926 | static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask, |
| 927 | __u64 *cow_offset, unsigned long *bitmap, | ||
| 928 | __u64 bitmap_offset, unsigned long *bitmap_words, | ||
| 929 | __u64 bitmap_len) | ||
| 943 | { | 930 | { |
| 944 | __u64 sector = req->offset / req->sectorsize; | 931 | __u64 sector = io_offset >> 9; |
| 945 | int i; | 932 | int i, update_bitmap = 0; |
| 933 | |||
| 934 | for(i = 0; i < length >> 9; i++){ | ||
| 935 | if(cow_mask != NULL) | ||
| 936 | ubd_set_bit(i, (unsigned char *) cow_mask); | ||
| 937 | if(ubd_test_bit(sector + i, (unsigned char *) bitmap)) | ||
| 938 | continue; | ||
| 946 | 939 | ||
| 947 | for(i = 0; i < req->length / req->sectorsize; i++){ | 940 | update_bitmap = 1; |
| 948 | if(ubd_test_bit(sector + i, bitmap)) | 941 | ubd_set_bit(sector + i, (unsigned char *) bitmap); |
| 949 | continue; | 942 | } |
| 943 | |||
| 944 | if(!update_bitmap) | ||
| 945 | return; | ||
| 950 | 946 | ||
| 951 | if(req->bitmap_start == -1) | 947 | *cow_offset = sector / (sizeof(unsigned long) * 8); |
| 952 | req->bitmap_start = sector + i; | ||
| 953 | req->bitmap_end = sector + i + 1; | ||
| 954 | 948 | ||
| 955 | ubd_set_bit(sector + i, bitmap); | 949 | /* This takes care of the case where we're exactly at the end of the |
| 956 | } | 950 | * device, and *cow_offset + 1 is off the end. So, just back it up |
| 951 | * by one word. Thanks to Lynn Kerby for the fix and James McMechan | ||
| 952 | * for the original diagnosis. | ||
| 953 | */ | ||
| 954 | if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) / | ||
| 955 | sizeof(unsigned long) - 1)) | ||
| 956 | (*cow_offset)--; | ||
| 957 | |||
| 958 | bitmap_words[0] = bitmap[*cow_offset]; | ||
| 959 | bitmap_words[1] = bitmap[*cow_offset + 1]; | ||
| 960 | |||
| 961 | *cow_offset *= sizeof(unsigned long); | ||
| 962 | *cow_offset += bitmap_offset; | ||
| 963 | } | ||
| 964 | |||
| 965 | static void cowify_req(struct io_thread_req *req, unsigned long *bitmap, | ||
| 966 | __u64 bitmap_offset, __u64 bitmap_len) | ||
| 967 | { | ||
| 968 | __u64 sector = req->offset >> 9; | ||
| 969 | int i; | ||
| 970 | |||
| 971 | if(req->length > (sizeof(req->sector_mask) * 8) << 9) | ||
| 972 | panic("Operation too long"); | ||
| 973 | |||
| 974 | if(req->op == UBD_READ) { | ||
| 975 | for(i = 0; i < req->length >> 9; i++){ | ||
| 976 | if(ubd_test_bit(sector + i, (unsigned char *) bitmap)) | ||
| 977 | ubd_set_bit(i, (unsigned char *) | ||
| 978 | &req->sector_mask); | ||
| 979 | } | ||
| 980 | } | ||
| 981 | else cowify_bitmap(req->offset, req->length, &req->sector_mask, | ||
| 982 | &req->cow_offset, bitmap, bitmap_offset, | ||
| 983 | req->bitmap_words, bitmap_len); | ||
| 957 | } | 984 | } |
| 958 | 985 | ||
| 959 | /* Called with ubd_io_lock held */ | 986 | /* Called with ubd_io_lock held */ |
| 960 | static int prepare_request(struct request *req, struct io_thread_req *io_req, | 987 | static int prepare_request(struct request *req, struct io_thread_req *io_req) |
| 961 | unsigned long long offset, int page_offset, | ||
| 962 | int len, struct page *page) | ||
| 963 | { | 988 | { |
| 964 | struct gendisk *disk = req->rq_disk; | 989 | struct gendisk *disk = req->rq_disk; |
| 965 | struct ubd *dev = disk->private_data; | 990 | struct ubd *dev = disk->private_data; |
| 991 | __u64 offset; | ||
| 992 | int len; | ||
| 993 | |||
| 994 | if(req->rq_status == RQ_INACTIVE) return(1); | ||
| 966 | 995 | ||
| 967 | /* This should be impossible now */ | 996 | /* This should be impossible now */ |
| 968 | if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ | 997 | if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ |
| 969 | printk("Write attempted on readonly ubd device %s\n", | 998 | printk("Write attempted on readonly ubd device %s\n", |
| 970 | disk->disk_name); | 999 | disk->disk_name); |
| 971 | ubd_end_request(req, 0, 0); | 1000 | end_request(req, 0); |
| 972 | return(1); | 1001 | return(1); |
| 973 | } | 1002 | } |
| 974 | 1003 | ||
| 1004 | offset = ((__u64) req->sector) << 9; | ||
| 1005 | len = req->current_nr_sectors << 9; | ||
| 1006 | |||
| 975 | io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; | 1007 | io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; |
| 976 | io_req->fds[1] = dev->fd; | 1008 | io_req->fds[1] = dev->fd; |
| 1009 | io_req->cow_offset = -1; | ||
| 977 | io_req->offset = offset; | 1010 | io_req->offset = offset; |
| 978 | io_req->length = len; | 1011 | io_req->length = len; |
| 979 | io_req->error = 0; | 1012 | io_req->error = 0; |
| 980 | io_req->op = (rq_data_dir(req) == READ) ? AIO_READ : AIO_WRITE; | 1013 | io_req->sector_mask = 0; |
| 1014 | |||
| 1015 | io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; | ||
| 981 | io_req->offsets[0] = 0; | 1016 | io_req->offsets[0] = 0; |
| 982 | io_req->offsets[1] = dev->cow.data_offset; | 1017 | io_req->offsets[1] = dev->cow.data_offset; |
| 983 | io_req->buffer = page_address(page) + page_offset; | 1018 | io_req->buffer = req->buffer; |
| 984 | io_req->sectorsize = 1 << 9; | 1019 | io_req->sectorsize = 1 << 9; |
| 985 | io_req->bitmap_offset = dev->cow.bitmap_offset; | ||
| 986 | io_req->bitmap_start = -1; | ||
| 987 | io_req->bitmap_end = -1; | ||
| 988 | 1020 | ||
| 989 | if((dev->cow.file != NULL) && (io_req->op == UBD_WRITE)) | 1021 | if(dev->cow.file != NULL) |
| 990 | cowify_bitmap(io_req, dev->cow.bitmap); | 1022 | cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset, |
| 1023 | dev->cow.bitmap_len); | ||
| 1024 | |||
| 991 | return(0); | 1025 | return(0); |
| 992 | } | 1026 | } |
| 993 | 1027 | ||
| @@ -996,36 +1030,30 @@ static void do_ubd_request(request_queue_t *q) | |||
| 996 | { | 1030 | { |
| 997 | struct io_thread_req io_req; | 1031 | struct io_thread_req io_req; |
| 998 | struct request *req; | 1032 | struct request *req; |
| 999 | __u64 sector; | 1033 | int err, n; |
| 1000 | int err; | 1034 | |
| 1001 | 1035 | if(thread_fd == -1){ | |
| 1002 | if(in_ubd) | 1036 | while((req = elv_next_request(q)) != NULL){ |
| 1003 | return; | 1037 | err = prepare_request(req, &io_req); |
| 1004 | in_ubd = 1; | 1038 | if(!err){ |
| 1005 | while((req = elv_next_request(q)) != NULL){ | 1039 | do_io(&io_req); |
| 1006 | struct gendisk *disk = req->rq_disk; | 1040 | __ubd_finish(req, io_req.error); |
| 1007 | struct ubd *dev = disk->private_data; | 1041 | } |
| 1008 | int n, i; | 1042 | } |
| 1009 | 1043 | } | |
| 1010 | blkdev_dequeue_request(req); | 1044 | else { |
| 1011 | 1045 | if(do_ubd || (req = elv_next_request(q)) == NULL) | |
| 1012 | sector = req->sector; | 1046 | return; |
| 1013 | n = blk_rq_map_sg(q, req, dev->sg); | 1047 | err = prepare_request(req, &io_req); |
| 1014 | 1048 | if(!err){ | |
| 1015 | for(i = 0; i < n; i++){ | 1049 | do_ubd = ubd_handler; |
| 1016 | struct scatterlist *sg = &dev->sg[i]; | 1050 | n = os_write_file(thread_fd, (char *) &io_req, |
| 1017 | 1051 | sizeof(io_req)); | |
| 1018 | err = prepare_request(req, &io_req, sector << 9, | 1052 | if(n != sizeof(io_req)) |
| 1019 | sg->offset, sg->length, | 1053 | printk("write to io thread failed, " |
| 1020 | sg->page); | 1054 | "errno = %d\n", -n); |
| 1021 | if(err) | ||
| 1022 | continue; | ||
| 1023 | |||
| 1024 | sector += sg->length >> 9; | ||
| 1025 | do_io(&io_req, req, dev->cow.bitmap); | ||
| 1026 | } | 1055 | } |
| 1027 | } | 1056 | } |
| 1028 | in_ubd = 0; | ||
| 1029 | } | 1057 | } |
| 1030 | 1058 | ||
| 1031 | static int ubd_ioctl(struct inode * inode, struct file * file, | 1059 | static int ubd_ioctl(struct inode * inode, struct file * file, |
| @@ -1241,95 +1269,131 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags, | |||
| 1241 | return(err); | 1269 | return(err); |
| 1242 | } | 1270 | } |
| 1243 | 1271 | ||
| 1244 | void do_io(struct io_thread_req *req, struct request *r, unsigned long *bitmap) | 1272 | static int update_bitmap(struct io_thread_req *req) |
| 1245 | { | 1273 | { |
| 1246 | struct ubd_aio *aio; | 1274 | int n; |
| 1247 | struct bitmap_io *bitmap_io = NULL; | ||
| 1248 | char *buf; | ||
| 1249 | void *bitmap_buf = NULL; | ||
| 1250 | unsigned long len, sector; | ||
| 1251 | int nsectors, start, end, bit, err; | ||
| 1252 | __u64 off; | ||
| 1253 | |||
| 1254 | if(req->bitmap_start != -1){ | ||
| 1255 | /* Round up to the nearest word */ | ||
| 1256 | int round = sizeof(unsigned long); | ||
| 1257 | len = (req->bitmap_end - req->bitmap_start + | ||
| 1258 | round * 8 - 1) / (round * 8); | ||
| 1259 | len *= round; | ||
| 1260 | |||
| 1261 | off = req->bitmap_start / (8 * round); | ||
| 1262 | off *= round; | ||
| 1263 | |||
| 1264 | bitmap_io = kmalloc(sizeof(*bitmap_io), GFP_KERNEL); | ||
| 1265 | if(bitmap_io == NULL){ | ||
| 1266 | printk("Failed to kmalloc bitmap IO\n"); | ||
| 1267 | req->error = 1; | ||
| 1268 | return; | ||
| 1269 | } | ||
| 1270 | 1275 | ||
| 1271 | bitmap_buf = kmalloc(len, GFP_KERNEL); | 1276 | if(req->cow_offset == -1) |
| 1272 | if(bitmap_buf == NULL){ | 1277 | return(0); |
| 1273 | printk("do_io : kmalloc of bitmap chunk " | ||
| 1274 | "failed\n"); | ||
| 1275 | kfree(bitmap_io); | ||
| 1276 | req->error = 1; | ||
| 1277 | return; | ||
| 1278 | } | ||
| 1279 | memcpy(bitmap_buf, &bitmap[off / sizeof(bitmap[0])], len); | ||
| 1280 | |||
| 1281 | *bitmap_io = ((struct bitmap_io) | ||
| 1282 | { .count = ATOMIC_INIT(0), | ||
| 1283 | .aio = INIT_AIO(AIO_WRITE, req->fds[1], | ||
| 1284 | bitmap_buf, len, | ||
| 1285 | req->bitmap_offset + off, | ||
| 1286 | ubd_reply_fd) } ); | ||
| 1287 | } | ||
| 1288 | 1278 | ||
| 1289 | nsectors = req->length / req->sectorsize; | 1279 | n = os_seek_file(req->fds[1], req->cow_offset); |
| 1290 | start = 0; | 1280 | if(n < 0){ |
| 1291 | end = nsectors; | 1281 | printk("do_io - bitmap lseek failed : err = %d\n", -n); |
| 1292 | bit = 0; | 1282 | return(1); |
| 1293 | do { | 1283 | } |
| 1294 | if(bitmap != NULL){ | ||
| 1295 | sector = req->offset / req->sectorsize; | ||
| 1296 | bit = ubd_test_bit(sector + start, bitmap); | ||
| 1297 | end = start; | ||
| 1298 | while((end < nsectors) && | ||
| 1299 | (ubd_test_bit(sector + end, bitmap) == bit)) | ||
| 1300 | end++; | ||
| 1301 | } | ||
| 1302 | 1284 | ||
| 1303 | off = req->offsets[bit] + req->offset + | 1285 | n = os_write_file(req->fds[1], &req->bitmap_words, |
| 1304 | start * req->sectorsize; | 1286 | sizeof(req->bitmap_words)); |
| 1305 | len = (end - start) * req->sectorsize; | 1287 | if(n != sizeof(req->bitmap_words)){ |
| 1306 | buf = &req->buffer[start * req->sectorsize]; | 1288 | printk("do_io - bitmap update failed, err = %d fd = %d\n", -n, |
| 1289 | req->fds[1]); | ||
| 1290 | return(1); | ||
| 1291 | } | ||
| 1307 | 1292 | ||
| 1308 | aio = kmalloc(sizeof(*aio), GFP_KERNEL); | 1293 | return(0); |
| 1309 | if(aio == NULL){ | 1294 | } |
| 1310 | req->error = 1; | ||
| 1311 | return; | ||
| 1312 | } | ||
| 1313 | 1295 | ||
| 1314 | *aio = ((struct ubd_aio) | 1296 | void do_io(struct io_thread_req *req) |
| 1315 | { .aio = INIT_AIO(req->op, req->fds[bit], buf, | 1297 | { |
| 1316 | len, off, ubd_reply_fd), | 1298 | char *buf; |
| 1317 | .len = len, | 1299 | unsigned long len; |
| 1318 | .req = r, | 1300 | int n, nsectors, start, end, bit; |
| 1319 | .bitmap = bitmap_io, | 1301 | int err; |
| 1320 | .bitmap_buf = bitmap_buf }); | 1302 | __u64 off; |
| 1321 | 1303 | ||
| 1322 | if(aio->bitmap != NULL) | 1304 | nsectors = req->length / req->sectorsize; |
| 1323 | atomic_inc(&aio->bitmap->count); | 1305 | start = 0; |
| 1324 | 1306 | do { | |
| 1325 | err = submit_aio(&aio->aio); | 1307 | bit = ubd_test_bit(start, (unsigned char *) &req->sector_mask); |
| 1326 | if(err){ | 1308 | end = start; |
| 1327 | printk("do_io - submit_aio failed, " | 1309 | while((end < nsectors) && |
| 1328 | "err = %d\n", err); | 1310 | (ubd_test_bit(end, (unsigned char *) |
| 1329 | req->error = 1; | 1311 | &req->sector_mask) == bit)) |
| 1330 | return; | 1312 | end++; |
| 1331 | } | 1313 | |
| 1314 | off = req->offset + req->offsets[bit] + | ||
| 1315 | start * req->sectorsize; | ||
| 1316 | len = (end - start) * req->sectorsize; | ||
| 1317 | buf = &req->buffer[start * req->sectorsize]; | ||
| 1318 | |||
| 1319 | err = os_seek_file(req->fds[bit], off); | ||
| 1320 | if(err < 0){ | ||
| 1321 | printk("do_io - lseek failed : err = %d\n", -err); | ||
| 1322 | req->error = 1; | ||
| 1323 | return; | ||
| 1324 | } | ||
| 1325 | if(req->op == UBD_READ){ | ||
| 1326 | n = 0; | ||
| 1327 | do { | ||
| 1328 | buf = &buf[n]; | ||
| 1329 | len -= n; | ||
| 1330 | n = os_read_file(req->fds[bit], buf, len); | ||
| 1331 | if (n < 0) { | ||
| 1332 | printk("do_io - read failed, err = %d " | ||
| 1333 | "fd = %d\n", -n, req->fds[bit]); | ||
| 1334 | req->error = 1; | ||
| 1335 | return; | ||
| 1336 | } | ||
| 1337 | } while((n < len) && (n != 0)); | ||
| 1338 | if (n < len) memset(&buf[n], 0, len - n); | ||
| 1339 | } else { | ||
| 1340 | n = os_write_file(req->fds[bit], buf, len); | ||
| 1341 | if(n != len){ | ||
| 1342 | printk("do_io - write failed err = %d " | ||
| 1343 | "fd = %d\n", -n, req->fds[bit]); | ||
| 1344 | req->error = 1; | ||
| 1345 | return; | ||
| 1346 | } | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | start = end; | ||
| 1350 | } while(start < nsectors); | ||
| 1332 | 1351 | ||
| 1333 | start = end; | 1352 | req->error = update_bitmap(req); |
| 1334 | } while(start < nsectors); | ||
| 1335 | } | 1353 | } |
| 1354 | |||
| 1355 | /* Changed in start_io_thread, which is serialized by being called only | ||
| 1356 | * from ubd_init, which is an initcall. | ||
| 1357 | */ | ||
| 1358 | int kernel_fd = -1; | ||
| 1359 | |||
| 1360 | /* Only changed by the io thread */ | ||
| 1361 | int io_count = 0; | ||
| 1362 | |||
| 1363 | int io_thread(void *arg) | ||
| 1364 | { | ||
| 1365 | struct io_thread_req req; | ||
| 1366 | int n; | ||
| 1367 | |||
| 1368 | ignore_sigwinch_sig(); | ||
| 1369 | while(1){ | ||
| 1370 | n = os_read_file(kernel_fd, &req, sizeof(req)); | ||
| 1371 | if(n != sizeof(req)){ | ||
| 1372 | if(n < 0) | ||
| 1373 | printk("io_thread - read failed, fd = %d, " | ||
| 1374 | "err = %d\n", kernel_fd, -n); | ||
| 1375 | else { | ||
| 1376 | printk("io_thread - short read, fd = %d, " | ||
| 1377 | "length = %d\n", kernel_fd, n); | ||
| 1378 | } | ||
| 1379 | continue; | ||
| 1380 | } | ||
| 1381 | io_count++; | ||
| 1382 | do_io(&req); | ||
| 1383 | n = os_write_file(kernel_fd, &req, sizeof(req)); | ||
| 1384 | if(n != sizeof(req)) | ||
| 1385 | printk("io_thread - write failed, fd = %d, err = %d\n", | ||
| 1386 | kernel_fd, -n); | ||
| 1387 | } | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | /* | ||
| 1391 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 1392 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 1393 | * adjust the settings for this buffer only. This must remain at the end | ||
| 1394 | * of the file. | ||
| 1395 | * --------------------------------------------------------------------------- | ||
| 1396 | * Local variables: | ||
| 1397 | * c-file-style: "linux" | ||
| 1398 | * End: | ||
| 1399 | */ | ||
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c new file mode 100644 index 000000000000..b94d2bc4fe06 --- /dev/null +++ b/arch/um/drivers/ubd_user.c | |||
| @@ -0,0 +1,75 @@ | |||
| 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/include/aio.h b/arch/um/include/aio.h index 83f16877ab08..423bae9153f8 100644 --- a/arch/um/include/aio.h +++ b/arch/um/include/aio.h | |||
| @@ -14,27 +14,15 @@ struct aio_thread_reply { | |||
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | struct aio_context { | 16 | struct aio_context { |
| 17 | enum aio_type type; | ||
| 18 | int fd; | ||
| 19 | void *data; | ||
| 20 | int len; | ||
| 21 | unsigned long long offset; | ||
| 22 | int reply_fd; | 17 | int reply_fd; |
| 23 | struct aio_context *next; | 18 | struct aio_context *next; |
| 24 | }; | 19 | }; |
| 25 | 20 | ||
| 26 | #define INIT_AIO(aio_type, aio_fd, aio_data, aio_len, aio_offset, \ | ||
| 27 | aio_reply_fd) \ | ||
| 28 | { .type = aio_type, \ | ||
| 29 | .fd = aio_fd, \ | ||
| 30 | .data = aio_data, \ | ||
| 31 | .len = aio_len, \ | ||
| 32 | .offset = aio_offset, \ | ||
| 33 | .reply_fd = aio_reply_fd } | ||
| 34 | |||
| 35 | #define INIT_AIO_CONTEXT { .reply_fd = -1, \ | 21 | #define INIT_AIO_CONTEXT { .reply_fd = -1, \ |
| 36 | .next = NULL } | 22 | .next = NULL } |
| 37 | 23 | ||
| 38 | extern int submit_aio(struct aio_context *aio); | 24 | extern int submit_aio(enum aio_type type, int fd, char *buf, int len, |
| 25 | unsigned long long offset, int reply_fd, | ||
| 26 | struct aio_context *aio); | ||
| 39 | 27 | ||
| 40 | #endif | 28 | #endif |
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h index 782ac3a3baf9..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); |
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 583329d0a539..2e58e304b8be 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #ifndef __OS_H__ | 6 | #ifndef __OS_H__ |
| 7 | #define __OS_H__ | 7 | #define __OS_H__ |
| 8 | 8 | ||
| 9 | #include "uml-config.h" | ||
| 9 | #include "asm/types.h" | 10 | #include "asm/types.h" |
| 10 | #include "../os/include/file.h" | 11 | #include "../os/include/file.h" |
| 11 | 12 | ||
| @@ -157,6 +158,14 @@ extern int os_lock_file(int fd, int excl); | |||
| 157 | extern void os_early_checks(void); | 158 | extern void os_early_checks(void); |
| 158 | extern int can_do_skas(void); | 159 | extern int can_do_skas(void); |
| 159 | 160 | ||
| 161 | /* Make sure they are clear when running in TT mode. Required by | ||
| 162 | * SEGV_MAYBE_FIXABLE */ | ||
| 163 | #ifdef UML_CONFIG_MODE_SKAS | ||
| 164 | #define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0) | ||
| 165 | #else | ||
| 166 | #define clear_can_do_skas() do {} while (0) | ||
| 167 | #endif | ||
| 168 | |||
| 160 | /* mem.c */ | 169 | /* mem.c */ |
| 161 | extern int create_mem_file(unsigned long len); | 170 | extern int create_mem_file(unsigned long len); |
| 162 | 171 | ||
diff --git a/arch/um/include/registers.h b/arch/um/include/registers.h index 0a35e6d0baa0..4892e5fcef07 100644 --- a/arch/um/include/registers.h +++ b/arch/um/include/registers.h | |||
| @@ -15,16 +15,6 @@ extern void save_registers(int pid, union uml_pt_regs *regs); | |||
| 15 | extern void restore_registers(int pid, union uml_pt_regs *regs); | 15 | extern void restore_registers(int pid, union uml_pt_regs *regs); |
| 16 | extern void init_registers(int pid); | 16 | extern void init_registers(int pid); |
| 17 | extern void get_safe_registers(unsigned long * regs); | 17 | extern void get_safe_registers(unsigned long * regs); |
| 18 | extern void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer); | ||
| 18 | 19 | ||
| 19 | #endif | 20 | #endif |
| 20 | |||
| 21 | /* | ||
| 22 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 23 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 24 | * adjust the settings for this buffer only. This must remain at the end | ||
| 25 | * of the file. | ||
| 26 | * --------------------------------------------------------------------------- | ||
| 27 | * Local variables: | ||
| 28 | * c-file-style: "linux" | ||
| 29 | * End: | ||
| 30 | */ | ||
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/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h index 331aa2d1f3f5..8d353f0feec1 100644 --- a/arch/um/include/sysdep-x86_64/ptrace.h +++ b/arch/um/include/sysdep-x86_64/ptrace.h | |||
| @@ -183,10 +183,6 @@ struct syscall_args { | |||
| 183 | case RBP: val = UPT_RBP(regs); break; \ | 183 | case RBP: val = UPT_RBP(regs); break; \ |
| 184 | case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ | 184 | case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ |
| 185 | case CS: val = UPT_CS(regs); break; \ | 185 | case CS: val = UPT_CS(regs); break; \ |
| 186 | case DS: val = UPT_DS(regs); break; \ | ||
| 187 | case ES: val = UPT_ES(regs); break; \ | ||
| 188 | case FS: val = UPT_FS(regs); break; \ | ||
| 189 | case GS: val = UPT_GS(regs); break; \ | ||
| 190 | case EFLAGS: val = UPT_EFLAGS(regs); break; \ | 186 | case EFLAGS: val = UPT_EFLAGS(regs); break; \ |
| 191 | default : \ | 187 | default : \ |
| 192 | panic("Bad register in UPT_REG : %d\n", reg); \ | 188 | panic("Bad register in UPT_REG : %d\n", reg); \ |
| @@ -218,10 +214,6 @@ struct syscall_args { | |||
| 218 | case RBP: UPT_RBP(regs) = __upt_val; break; \ | 214 | case RBP: UPT_RBP(regs) = __upt_val; break; \ |
| 219 | case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ | 215 | case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ |
| 220 | case CS: UPT_CS(regs) = __upt_val; break; \ | 216 | case CS: UPT_CS(regs) = __upt_val; break; \ |
| 221 | case DS: UPT_DS(regs) = __upt_val; break; \ | ||
| 222 | case ES: UPT_ES(regs) = __upt_val; break; \ | ||
| 223 | case FS: UPT_FS(regs) = __upt_val; break; \ | ||
| 224 | case GS: UPT_GS(regs) = __upt_val; break; \ | ||
| 225 | case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ | 217 | case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ |
| 226 | default : \ | 218 | default : \ |
| 227 | panic("Bad register in UPT_SET : %d\n", reg); \ | 219 | panic("Bad register in UPT_SET : %d\n", reg); \ |
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/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/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/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/sysrq.c b/arch/um/kernel/sysrq.c index f80850091e79..b331e970002f 100644 --- a/arch/um/kernel/sysrq.c +++ b/arch/um/kernel/sysrq.c | |||
| @@ -62,13 +62,7 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
| 62 | 62 | ||
| 63 | if (esp == NULL) { | 63 | if (esp == NULL) { |
| 64 | if (task != current && task != NULL) { | 64 | if (task != current && task != NULL) { |
| 65 | /* XXX: Isn't this bogus? I.e. isn't this the | ||
| 66 | * *userspace* stack of this task? If not so, use this | ||
| 67 | * even when task == current (as in i386). | ||
| 68 | */ | ||
| 69 | esp = (unsigned long *) KSTK_ESP(task); | 65 | esp = (unsigned long *) KSTK_ESP(task); |
| 70 | /* Which one? No actual difference - just coding style.*/ | ||
| 71 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); | ||
| 72 | } else { | 66 | } else { |
| 73 | esp = (unsigned long *) &esp; | 67 | esp = (unsigned long *) &esp; |
| 74 | } | 68 | } |
| @@ -84,5 +78,5 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
| 84 | } | 78 | } |
| 85 | 79 | ||
| 86 | printk("Call Trace: \n"); | 80 | printk("Call Trace: \n"); |
| 87 | show_trace(current, esp); | 81 | show_trace(task, esp); |
| 88 | } | 82 | } |
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c index d297429ac360..95c8f8733baf 100644 --- a/arch/um/kernel/trap_kern.c +++ b/arch/um/kernel/trap_kern.c | |||
| @@ -26,6 +26,9 @@ | |||
| 26 | #include "mconsole_kern.h" | 26 | #include "mconsole_kern.h" |
| 27 | #include "mem.h" | 27 | #include "mem.h" |
| 28 | #include "mem_kern.h" | 28 | #include "mem_kern.h" |
| 29 | #ifdef CONFIG_MODE_SKAS | ||
| 30 | #include "skas.h" | ||
| 31 | #endif | ||
| 29 | 32 | ||
| 30 | /* 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(). */ |
| 31 | int handle_page_fault(unsigned long address, unsigned long ip, | 34 | int handle_page_fault(unsigned long address, unsigned long ip, |
| @@ -134,7 +137,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc) | |||
| 134 | else if(current->mm == NULL) | 137 | else if(current->mm == NULL) |
| 135 | panic("Segfault with no mm"); | 138 | panic("Segfault with no mm"); |
| 136 | 139 | ||
| 137 | if (SEGV_IS_FIXABLE(&fi)) | 140 | if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi)) |
| 138 | err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); | 141 | err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); |
| 139 | else { | 142 | else { |
| 140 | err = -EFAULT; | 143 | err = -EFAULT; |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index f0a275947d34..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) { |
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index f6e64026f995..41cfb0944201 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| 7 | #include <unistd.h> | 7 | #include <unistd.h> |
| 8 | #include <signal.h> | 8 | #include <signal.h> |
| 9 | #include <string.h> | ||
| 10 | #include <errno.h> | 9 | #include <errno.h> |
| 11 | #include <sched.h> | 10 | #include <sched.h> |
| 12 | #include <sys/syscall.h> | 11 | #include <sys/syscall.h> |
| @@ -17,31 +16,18 @@ | |||
| 17 | #include "user.h" | 16 | #include "user.h" |
| 18 | #include "mode.h" | 17 | #include "mode.h" |
| 19 | 18 | ||
| 19 | struct aio_thread_req { | ||
| 20 | enum aio_type type; | ||
| 21 | int io_fd; | ||
| 22 | unsigned long long offset; | ||
| 23 | char *buf; | ||
| 24 | int len; | ||
| 25 | struct aio_context *aio; | ||
| 26 | }; | ||
| 27 | |||
| 20 | static int aio_req_fd_r = -1; | 28 | static int aio_req_fd_r = -1; |
| 21 | static int aio_req_fd_w = -1; | 29 | static int aio_req_fd_w = -1; |
| 22 | 30 | ||
| 23 | static int update_aio(struct aio_context *aio, int res) | ||
| 24 | { | ||
| 25 | if(res < 0) | ||
| 26 | aio->len = res; | ||
| 27 | else if((res == 0) && (aio->type == AIO_READ)){ | ||
| 28 | /* This is the EOF case - we have hit the end of the file | ||
| 29 | * and it ends in a partial block, so we fill the end of | ||
| 30 | * the block with zeros and claim success. | ||
| 31 | */ | ||
| 32 | memset(aio->data, 0, aio->len); | ||
| 33 | aio->len = 0; | ||
| 34 | } | ||
| 35 | else if(res > 0){ | ||
| 36 | aio->len -= res; | ||
| 37 | aio->data += res; | ||
| 38 | aio->offset += res; | ||
| 39 | return aio->len; | ||
| 40 | } | ||
| 41 | |||
| 42 | return 0; | ||
| 43 | } | ||
| 44 | |||
| 45 | #if defined(HAVE_AIO_ABI) | 31 | #if defined(HAVE_AIO_ABI) |
| 46 | #include <linux/aio_abi.h> | 32 | #include <linux/aio_abi.h> |
| 47 | 33 | ||
| @@ -80,7 +66,8 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr, | |||
| 80 | * that it now backs the mmapped area. | 66 | * that it now backs the mmapped area. |
| 81 | */ | 67 | */ |
| 82 | 68 | ||
| 83 | static int do_aio(aio_context_t ctx, struct aio_context *aio) | 69 | static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf, |
| 70 | int len, unsigned long long offset, struct aio_context *aio) | ||
| 84 | { | 71 | { |
| 85 | struct iocb iocb, *iocbp = &iocb; | 72 | struct iocb iocb, *iocbp = &iocb; |
| 86 | char c; | 73 | char c; |
| @@ -88,39 +75,40 @@ static int do_aio(aio_context_t ctx, struct aio_context *aio) | |||
| 88 | 75 | ||
| 89 | iocb = ((struct iocb) { .aio_data = (unsigned long) aio, | 76 | iocb = ((struct iocb) { .aio_data = (unsigned long) aio, |
| 90 | .aio_reqprio = 0, | 77 | .aio_reqprio = 0, |
| 91 | .aio_fildes = aio->fd, | 78 | .aio_fildes = fd, |
| 92 | .aio_buf = (unsigned long) aio->data, | 79 | .aio_buf = (unsigned long) buf, |
| 93 | .aio_nbytes = aio->len, | 80 | .aio_nbytes = len, |
| 94 | .aio_offset = aio->offset, | 81 | .aio_offset = offset, |
| 95 | .aio_reserved1 = 0, | 82 | .aio_reserved1 = 0, |
| 96 | .aio_reserved2 = 0, | 83 | .aio_reserved2 = 0, |
| 97 | .aio_reserved3 = 0 }); | 84 | .aio_reserved3 = 0 }); |
| 98 | 85 | ||
| 99 | switch(aio->type){ | 86 | switch(type){ |
| 100 | case AIO_READ: | 87 | case AIO_READ: |
| 101 | iocb.aio_lio_opcode = IOCB_CMD_PREAD; | 88 | iocb.aio_lio_opcode = IOCB_CMD_PREAD; |
| 89 | err = io_submit(ctx, 1, &iocbp); | ||
| 102 | break; | 90 | break; |
| 103 | case AIO_WRITE: | 91 | case AIO_WRITE: |
| 104 | iocb.aio_lio_opcode = IOCB_CMD_PWRITE; | 92 | iocb.aio_lio_opcode = IOCB_CMD_PWRITE; |
| 93 | err = io_submit(ctx, 1, &iocbp); | ||
| 105 | break; | 94 | break; |
| 106 | case AIO_MMAP: | 95 | case AIO_MMAP: |
| 107 | iocb.aio_lio_opcode = IOCB_CMD_PREAD; | 96 | iocb.aio_lio_opcode = IOCB_CMD_PREAD; |
| 108 | iocb.aio_buf = (unsigned long) &c; | 97 | iocb.aio_buf = (unsigned long) &c; |
| 109 | iocb.aio_nbytes = sizeof(c); | 98 | iocb.aio_nbytes = sizeof(c); |
| 99 | err = io_submit(ctx, 1, &iocbp); | ||
| 110 | break; | 100 | break; |
| 111 | default: | 101 | default: |
| 112 | printk("Bogus op in do_aio - %d\n", aio->type); | 102 | printk("Bogus op in do_aio - %d\n", type); |
| 113 | err = -EINVAL; | 103 | err = -EINVAL; |
| 114 | goto out; | 104 | break; |
| 115 | } | 105 | } |
| 116 | 106 | ||
| 117 | err = io_submit(ctx, 1, &iocbp); | ||
| 118 | if(err > 0) | 107 | if(err > 0) |
| 119 | err = 0; | 108 | err = 0; |
| 120 | else | 109 | else |
| 121 | err = -errno; | 110 | err = -errno; |
| 122 | 111 | ||
| 123 | out: | ||
| 124 | return err; | 112 | return err; |
| 125 | } | 113 | } |
| 126 | 114 | ||
| @@ -129,9 +117,8 @@ static aio_context_t ctx = 0; | |||
| 129 | static int aio_thread(void *arg) | 117 | static int aio_thread(void *arg) |
| 130 | { | 118 | { |
| 131 | struct aio_thread_reply reply; | 119 | struct aio_thread_reply reply; |
| 132 | struct aio_context *aio; | ||
| 133 | struct io_event event; | 120 | struct io_event event; |
| 134 | int err, n; | 121 | int err, n, reply_fd; |
| 135 | 122 | ||
| 136 | signal(SIGWINCH, SIG_IGN); | 123 | signal(SIGWINCH, SIG_IGN); |
| 137 | 124 | ||
| @@ -144,22 +131,14 @@ static int aio_thread(void *arg) | |||
| 144 | "errno = %d\n", errno); | 131 | "errno = %d\n", errno); |
| 145 | } | 132 | } |
| 146 | else { | 133 | else { |
| 147 | /* This is safe as we've just a pointer here. */ | ||
| 148 | aio = (struct aio_context *) (long) event.data; | ||
| 149 | if(update_aio(aio, event.res)){ | ||
| 150 | do_aio(ctx, aio); | ||
| 151 | continue; | ||
| 152 | } | ||
| 153 | |||
| 154 | reply = ((struct aio_thread_reply) | 134 | reply = ((struct aio_thread_reply) |
| 155 | { .data = aio, | 135 | { .data = (void *) (long) event.data, |
| 156 | .err = aio->len }); | 136 | .err = event.res }); |
| 157 | err = os_write_file(aio->reply_fd, &reply, | 137 | reply_fd = ((struct aio_context *) reply.data)->reply_fd; |
| 158 | sizeof(reply)); | 138 | err = os_write_file(reply_fd, &reply, sizeof(reply)); |
| 159 | if(err != sizeof(reply)) | 139 | if(err != sizeof(reply)) |
| 160 | printk("aio_thread - write failed, " | 140 | printk("aio_thread - write failed, fd = %d, " |
| 161 | "fd = %d, err = %d\n", aio->reply_fd, | 141 | "err = %d\n", aio_req_fd_r, -err); |
| 162 | -err); | ||
| 163 | } | 142 | } |
| 164 | } | 143 | } |
| 165 | return 0; | 144 | return 0; |
| @@ -167,35 +146,35 @@ static int aio_thread(void *arg) | |||
| 167 | 146 | ||
| 168 | #endif | 147 | #endif |
| 169 | 148 | ||
| 170 | static int do_not_aio(struct aio_context *aio) | 149 | static int do_not_aio(struct aio_thread_req *req) |
| 171 | { | 150 | { |
| 172 | char c; | 151 | char c; |
| 173 | int err; | 152 | int err; |
| 174 | 153 | ||
| 175 | switch(aio->type){ | 154 | switch(req->type){ |
| 176 | case AIO_READ: | 155 | case AIO_READ: |
| 177 | err = os_seek_file(aio->fd, aio->offset); | 156 | err = os_seek_file(req->io_fd, req->offset); |
| 178 | if(err) | 157 | if(err) |
| 179 | goto out; | 158 | goto out; |
| 180 | 159 | ||
| 181 | err = os_read_file(aio->fd, aio->data, aio->len); | 160 | err = os_read_file(req->io_fd, req->buf, req->len); |
| 182 | break; | 161 | break; |
| 183 | case AIO_WRITE: | 162 | case AIO_WRITE: |
| 184 | err = os_seek_file(aio->fd, aio->offset); | 163 | err = os_seek_file(req->io_fd, req->offset); |
| 185 | if(err) | 164 | if(err) |
| 186 | goto out; | 165 | goto out; |
| 187 | 166 | ||
| 188 | err = os_write_file(aio->fd, aio->data, aio->len); | 167 | err = os_write_file(req->io_fd, req->buf, req->len); |
| 189 | break; | 168 | break; |
| 190 | case AIO_MMAP: | 169 | case AIO_MMAP: |
| 191 | err = os_seek_file(aio->fd, aio->offset); | 170 | err = os_seek_file(req->io_fd, req->offset); |
| 192 | if(err) | 171 | if(err) |
| 193 | goto out; | 172 | goto out; |
| 194 | 173 | ||
| 195 | err = os_read_file(aio->fd, &c, sizeof(c)); | 174 | err = os_read_file(req->io_fd, &c, sizeof(c)); |
| 196 | break; | 175 | break; |
| 197 | default: | 176 | default: |
| 198 | printk("do_not_aio - bad request type : %d\n", aio->type); | 177 | printk("do_not_aio - bad request type : %d\n", req->type); |
| 199 | err = -EINVAL; | 178 | err = -EINVAL; |
| 200 | break; | 179 | break; |
| 201 | } | 180 | } |
| @@ -206,14 +185,14 @@ static int do_not_aio(struct aio_context *aio) | |||
| 206 | 185 | ||
| 207 | static int not_aio_thread(void *arg) | 186 | static int not_aio_thread(void *arg) |
| 208 | { | 187 | { |
| 209 | struct aio_context *aio; | 188 | struct aio_thread_req req; |
| 210 | struct aio_thread_reply reply; | 189 | struct aio_thread_reply reply; |
| 211 | int err; | 190 | int err; |
| 212 | 191 | ||
| 213 | signal(SIGWINCH, SIG_IGN); | 192 | signal(SIGWINCH, SIG_IGN); |
| 214 | while(1){ | 193 | while(1){ |
| 215 | err = os_read_file(aio_req_fd_r, &aio, sizeof(aio)); | 194 | err = os_read_file(aio_req_fd_r, &req, sizeof(req)); |
| 216 | if(err != sizeof(aio)){ | 195 | if(err != sizeof(req)){ |
| 217 | if(err < 0) | 196 | if(err < 0) |
| 218 | printk("not_aio_thread - read failed, " | 197 | printk("not_aio_thread - read failed, " |
| 219 | "fd = %d, err = %d\n", aio_req_fd_r, | 198 | "fd = %d, err = %d\n", aio_req_fd_r, |
| @@ -224,34 +203,17 @@ static int not_aio_thread(void *arg) | |||
| 224 | } | 203 | } |
| 225 | continue; | 204 | continue; |
| 226 | } | 205 | } |
| 227 | again: | 206 | err = do_not_aio(&req); |
| 228 | err = do_not_aio(aio); | 207 | reply = ((struct aio_thread_reply) { .data = req.aio, |
| 229 | 208 | .err = err }); | |
| 230 | if(update_aio(aio, err)) | 209 | err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); |
| 231 | goto again; | ||
| 232 | |||
| 233 | reply = ((struct aio_thread_reply) { .data = aio, | ||
| 234 | .err = aio->len }); | ||
| 235 | err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); | ||
| 236 | if(err != sizeof(reply)) | 210 | if(err != sizeof(reply)) |
| 237 | printk("not_aio_thread - write failed, fd = %d, " | 211 | printk("not_aio_thread - write failed, fd = %d, " |
| 238 | "err = %d\n", aio_req_fd_r, -err); | 212 | "err = %d\n", aio_req_fd_r, -err); |
| 239 | } | 213 | } |
| 240 | } | 214 | } |
| 241 | 215 | ||
| 242 | static int submit_aio_24(struct aio_context *aio) | ||
| 243 | { | ||
| 244 | int err; | ||
| 245 | |||
| 246 | err = os_write_file(aio_req_fd_w, &aio, sizeof(aio)); | ||
| 247 | if(err == sizeof(aio)) | ||
| 248 | err = 0; | ||
| 249 | |||
| 250 | return err; | ||
| 251 | } | ||
| 252 | |||
| 253 | static int aio_pid = -1; | 216 | static int aio_pid = -1; |
| 254 | static int (*submit_proc)(struct aio_context *aio); | ||
| 255 | 217 | ||
| 256 | static int init_aio_24(void) | 218 | static int init_aio_24(void) |
| 257 | { | 219 | { |
| @@ -283,33 +245,11 @@ static int init_aio_24(void) | |||
| 283 | #endif | 245 | #endif |
| 284 | printk("2.6 host AIO support not used - falling back to I/O " | 246 | printk("2.6 host AIO support not used - falling back to I/O " |
| 285 | "thread\n"); | 247 | "thread\n"); |
| 286 | |||
| 287 | submit_proc = submit_aio_24; | ||
| 288 | |||
| 289 | return 0; | 248 | return 0; |
| 290 | } | 249 | } |
| 291 | 250 | ||
| 292 | #ifdef HAVE_AIO_ABI | 251 | #ifdef HAVE_AIO_ABI |
| 293 | #define DEFAULT_24_AIO 0 | 252 | #define DEFAULT_24_AIO 0 |
| 294 | static int submit_aio_26(struct aio_context *aio) | ||
| 295 | { | ||
| 296 | struct aio_thread_reply reply; | ||
| 297 | int err; | ||
| 298 | |||
| 299 | err = do_aio(ctx, aio); | ||
| 300 | if(err){ | ||
| 301 | reply = ((struct aio_thread_reply) { .data = aio, | ||
| 302 | .err = err }); | ||
| 303 | err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); | ||
| 304 | if(err != sizeof(reply)) | ||
| 305 | printk("submit_aio_26 - write failed, " | ||
| 306 | "fd = %d, err = %d\n", aio->reply_fd, -err); | ||
| 307 | else err = 0; | ||
| 308 | } | ||
| 309 | |||
| 310 | return err; | ||
| 311 | } | ||
| 312 | |||
| 313 | static int init_aio_26(void) | 253 | static int init_aio_26(void) |
| 314 | { | 254 | { |
| 315 | unsigned long stack; | 255 | unsigned long stack; |
| @@ -330,22 +270,39 @@ static int init_aio_26(void) | |||
| 330 | aio_pid = err; | 270 | aio_pid = err; |
| 331 | 271 | ||
| 332 | printk("Using 2.6 host AIO\n"); | 272 | printk("Using 2.6 host AIO\n"); |
| 273 | return 0; | ||
| 274 | } | ||
| 275 | |||
| 276 | static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len, | ||
| 277 | unsigned long long offset, struct aio_context *aio) | ||
| 278 | { | ||
| 279 | struct aio_thread_reply reply; | ||
| 280 | int err; | ||
| 333 | 281 | ||
| 334 | submit_proc = submit_aio_26; | 282 | err = do_aio(ctx, type, io_fd, buf, len, offset, aio); |
| 283 | if(err){ | ||
| 284 | reply = ((struct aio_thread_reply) { .data = aio, | ||
| 285 | .err = err }); | ||
| 286 | err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); | ||
| 287 | if(err != sizeof(reply)) | ||
| 288 | printk("submit_aio_26 - write failed, " | ||
| 289 | "fd = %d, err = %d\n", aio->reply_fd, -err); | ||
| 290 | else err = 0; | ||
| 291 | } | ||
| 335 | 292 | ||
| 336 | return 0; | 293 | return err; |
| 337 | } | 294 | } |
| 338 | 295 | ||
| 339 | #else | 296 | #else |
| 340 | #define DEFAULT_24_AIO 1 | 297 | #define DEFAULT_24_AIO 1 |
| 341 | static int submit_aio_26(struct aio_context *aio) | 298 | static int init_aio_26(void) |
| 342 | { | 299 | { |
| 343 | return -ENOSYS; | 300 | return -ENOSYS; |
| 344 | } | 301 | } |
| 345 | 302 | ||
| 346 | static int init_aio_26(void) | 303 | static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len, |
| 304 | unsigned long long offset, struct aio_context *aio) | ||
| 347 | { | 305 | { |
| 348 | submit_proc = submit_aio_26; | ||
| 349 | return -ENOSYS; | 306 | return -ENOSYS; |
| 350 | } | 307 | } |
| 351 | #endif | 308 | #endif |
| @@ -412,7 +369,33 @@ static void exit_aio(void) | |||
| 412 | 369 | ||
| 413 | __uml_exitcall(exit_aio); | 370 | __uml_exitcall(exit_aio); |
| 414 | 371 | ||
| 415 | int submit_aio(struct aio_context *aio) | 372 | static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len, |
| 373 | unsigned long long offset, struct aio_context *aio) | ||
| 416 | { | 374 | { |
| 417 | return (*submit_proc)(aio); | 375 | struct aio_thread_req req = { .type = type, |
| 376 | .io_fd = io_fd, | ||
| 377 | .offset = offset, | ||
| 378 | .buf = buf, | ||
| 379 | .len = len, | ||
| 380 | .aio = aio, | ||
| 381 | }; | ||
| 382 | int err; | ||
| 383 | |||
| 384 | err = os_write_file(aio_req_fd_w, &req, sizeof(req)); | ||
| 385 | if(err == sizeof(req)) | ||
| 386 | err = 0; | ||
| 387 | |||
| 388 | return err; | ||
| 389 | } | ||
| 390 | |||
| 391 | int submit_aio(enum aio_type type, int io_fd, char *buf, int len, | ||
| 392 | unsigned long long offset, int reply_fd, | ||
| 393 | struct aio_context *aio) | ||
| 394 | { | ||
| 395 | aio->reply_fd = reply_fd; | ||
| 396 | if(aio_24) | ||
| 397 | return submit_aio_24(type, io_fd, buf, len, offset, aio); | ||
| 398 | else { | ||
| 399 | return submit_aio_26(type, io_fd, buf, len, offset, aio); | ||
| 400 | } | ||
| 418 | } | 401 | } |
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index ab33cb3c74ec..5a99dd3fbed0 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c | |||
| @@ -12,7 +12,7 @@ | |||
| 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 | /* Use the one from the kernel - the host may miss it, if having old headers. */ | 17 | /* Use the one from the kernel - the host may miss it, if having old headers. */ |
| 18 | #if UM_ELF_CLASS == UM_ELFCLASS32 | 18 | #if UM_ELF_CLASS == UM_ELFCLASS32 |
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 6af83171ca4e..b99ab414542f 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
| @@ -143,11 +143,22 @@ static int __init skas0_cmd_param(char *str, int* add) | |||
| 143 | return 0; | 143 | return 0; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | /* The two __uml_setup would conflict, without this stupid alias. */ | ||
| 147 | |||
| 148 | static int __init mode_skas0_cmd_param(char *str, int* add) | ||
| 149 | __attribute__((alias("skas0_cmd_param"))); | ||
| 150 | |||
| 146 | __uml_setup("skas0", skas0_cmd_param, | 151 | __uml_setup("skas0", skas0_cmd_param, |
| 147 | "skas0\n" | 152 | "skas0\n" |
| 148 | " Disables SKAS3 usage, so that SKAS0 is used, unless \n" | 153 | " Disables SKAS3 usage, so that SKAS0 is used, unless \n" |
| 149 | " you specify mode=tt.\n\n"); | 154 | " you specify mode=tt.\n\n"); |
| 150 | 155 | ||
| 156 | __uml_setup("mode=skas0", mode_skas0_cmd_param, | ||
| 157 | "mode=skas0\n" | ||
| 158 | " Disables SKAS3 usage, so that SKAS0 is used, unless you \n" | ||
| 159 | " specify mode=tt. Note that this was recently added - on \n" | ||
| 160 | " older kernels you must use simply \"skas0\".\n\n"); | ||
| 161 | |||
| 151 | static int force_sysemu_disabled = 0; | 162 | static int force_sysemu_disabled = 0; |
| 152 | 163 | ||
| 153 | static int __init nosysemu_cmd_param(char *str, int* add) | 164 | static int __init nosysemu_cmd_param(char *str, int* add) |
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c index 3125d320722c..aee4812333c6 100644 --- a/arch/um/os-Linux/sys-i386/registers.c +++ b/arch/um/os-Linux/sys-i386/registers.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <errno.h> | 6 | #include <errno.h> |
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | #include <setjmp.h> | ||
| 8 | #include "sysdep/ptrace_user.h" | 9 | #include "sysdep/ptrace_user.h" |
| 9 | #include "sysdep/ptrace.h" | 10 | #include "sysdep/ptrace.h" |
| 10 | #include "uml-config.h" | 11 | #include "uml-config.h" |
| @@ -126,13 +127,11 @@ void get_safe_registers(unsigned long *regs) | |||
| 126 | memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); | 127 | memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | /* | 130 | void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer) |
| 130 | * Overrides for Emacs so that we follow Linus's tabbing style. | 131 | { |
| 131 | * Emacs will notice this stuff at the end of the file and automatically | 132 | struct __jmp_buf_tag *jmpbuf = buffer; |
| 132 | * adjust the settings for this buffer only. This must remain at the end | 133 | |
| 133 | * of the file. | 134 | UPT_SET(uml_regs, EIP, jmpbuf->__jmpbuf[JB_PC]); |
| 134 | * --------------------------------------------------------------------------- | 135 | UPT_SET(uml_regs, UESP, jmpbuf->__jmpbuf[JB_SP]); |
| 135 | * Local variables: | 136 | UPT_SET(uml_regs, EBP, jmpbuf->__jmpbuf[JB_BP]); |
| 136 | * c-file-style: "linux" | 137 | } |
| 137 | * End: | ||
| 138 | */ | ||
diff --git a/arch/um/os-Linux/sys-x86_64/registers.c b/arch/um/os-Linux/sys-x86_64/registers.c index 44438d15c3d6..4b638dfb52b0 100644 --- a/arch/um/os-Linux/sys-x86_64/registers.c +++ b/arch/um/os-Linux/sys-x86_64/registers.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <errno.h> | 6 | #include <errno.h> |
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | #include <setjmp.h> | ||
| 8 | #include "ptrace_user.h" | 9 | #include "ptrace_user.h" |
| 9 | #include "uml-config.h" | 10 | #include "uml-config.h" |
| 10 | #include "skas_ptregs.h" | 11 | #include "skas_ptregs.h" |
| @@ -74,13 +75,11 @@ void get_safe_registers(unsigned long *regs) | |||
| 74 | memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); | 75 | memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | /* | 78 | void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer) |
| 78 | * Overrides for Emacs so that we follow Linus's tabbing style. | 79 | { |
| 79 | * Emacs will notice this stuff at the end of the file and automatically | 80 | struct __jmp_buf_tag *jmpbuf = buffer; |
| 80 | * adjust the settings for this buffer only. This must remain at the end | 81 | |
| 81 | * of the file. | 82 | UPT_SET(uml_regs, RIP, jmpbuf->__jmpbuf[JB_PC]); |
| 82 | * --------------------------------------------------------------------------- | 83 | UPT_SET(uml_regs, RSP, jmpbuf->__jmpbuf[JB_RSP]); |
| 83 | * Local variables: | 84 | UPT_SET(uml_regs, RBP, jmpbuf->__jmpbuf[JB_RBP]); |
| 84 | * c-file-style: "linux" | 85 | } |
| 85 | * End: | ||
| 86 | */ | ||
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/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index 59a1291f477e..651d9d88b656 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules | |||
| @@ -7,8 +7,8 @@ USER_SINGLE_OBJS := \ | |||
| 7 | USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) | 7 | USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) |
| 8 | USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) | 8 | USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) |
| 9 | 9 | ||
| 10 | $(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ | 10 | $(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \ |
| 11 | $(CFLAGS_$(notdir $@)) | 11 | c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@)) |
| 12 | $(USER_OBJS): cmd_checksrc = | 12 | $(USER_OBJS): cmd_checksrc = |
| 13 | $(USER_OBJS): quiet_cmd_checksrc = | 13 | $(USER_OBJS): quiet_cmd_checksrc = |
| 14 | $(USER_OBJS): cmd_force_checksrc = | 14 | $(USER_OBJS): cmd_force_checksrc = |
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/sysrq.c b/arch/um/sys-i386/sysrq.c index e3706d15c4f5..d5244f070539 100644 --- a/arch/um/sys-i386/sysrq.c +++ b/arch/um/sys-i386/sysrq.c | |||
| @@ -88,9 +88,7 @@ void show_trace(struct task_struct* task, unsigned long * stack) | |||
| 88 | task = current; | 88 | task = current; |
| 89 | 89 | ||
| 90 | if (task != current) { | 90 | if (task != current) { |
| 91 | //ebp = (unsigned long) KSTK_EBP(task); | 91 | ebp = (unsigned long) KSTK_EBP(task); |
| 92 | /* Which one? No actual difference - just coding style.*/ | ||
| 93 | ebp = (unsigned long) PT_REGS_EBP(&task->thread.regs); | ||
| 94 | } else { | 92 | } else { |
| 95 | asm ("movl %%ebp, %0" : "=r" (ebp) : ); | 93 | asm ("movl %%ebp, %0" : "=r" (ebp) : ); |
| 96 | } | 94 | } |
| @@ -99,15 +97,6 @@ void show_trace(struct task_struct* task, unsigned long * stack) | |||
| 99 | ((unsigned long)stack & (~(THREAD_SIZE - 1))); | 97 | ((unsigned long)stack & (~(THREAD_SIZE - 1))); |
| 100 | print_context_stack(context, stack, ebp); | 98 | print_context_stack(context, stack, ebp); |
| 101 | 99 | ||
| 102 | /*while (((long) stack & (THREAD_SIZE-1)) != 0) { | ||
| 103 | addr = *stack; | ||
| 104 | if (__kernel_text_address(addr)) { | ||
| 105 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
| 106 | print_symbol(" %s", addr); | ||
| 107 | printk("\n"); | ||
| 108 | } | ||
| 109 | stack++; | ||
| 110 | }*/ | ||
| 111 | printk("\n"); | 100 | printk("\n"); |
| 112 | } | 101 | } |
| 113 | 102 | ||
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c index 3ceaabceb3d7..26b68675053d 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(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/stub_segv.c b/arch/um/sys-x86_64/stub_segv.c index 65a131b362b6..d1e53bdf2e85 100644 --- a/arch/um/sys-x86_64/stub_segv.c +++ b/arch/um/sys-x86_64/stub_segv.c | |||
| @@ -10,6 +10,22 @@ | |||
| 10 | #include "uml-config.h" | 10 | #include "uml-config.h" |
| 11 | #include "sysdep/sigcontext.h" | 11 | #include "sysdep/sigcontext.h" |
| 12 | #include "sysdep/faultinfo.h" | 12 | #include "sysdep/faultinfo.h" |
| 13 | #include <stddef.h> | ||
| 14 | |||
| 15 | /* Copied from sys-x86_64/signal.c - Can't find an equivalent definition | ||
| 16 | * in the libc headers anywhere. | ||
| 17 | */ | ||
| 18 | struct rt_sigframe | ||
| 19 | { | ||
| 20 | char *pretcode; | ||
| 21 | struct ucontext uc; | ||
| 22 | struct siginfo info; | ||
| 23 | }; | ||
| 24 | |||
| 25 | /* Copied here from <linux/kernel.h> - we're userspace. */ | ||
| 26 | #define container_of(ptr, type, member) ({ \ | ||
| 27 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
| 28 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
| 13 | 29 | ||
| 14 | void __attribute__ ((__section__ (".__syscall_stub"))) | 30 | void __attribute__ ((__section__ (".__syscall_stub"))) |
| 15 | stub_segv_handler(int sig) | 31 | stub_segv_handler(int sig) |
| @@ -17,16 +33,19 @@ stub_segv_handler(int sig) | |||
| 17 | struct ucontext *uc; | 33 | struct ucontext *uc; |
| 18 | 34 | ||
| 19 | __asm__("movq %%rdx, %0" : "=g" (uc) :); | 35 | __asm__("movq %%rdx, %0" : "=g" (uc) :); |
| 20 | GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), | 36 | GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), |
| 21 | &uc->uc_mcontext); | 37 | &uc->uc_mcontext); |
| 22 | 38 | ||
| 23 | __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid)); | 39 | __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid)); |
| 24 | __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;" | 40 | __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;" |
| 25 | "syscall": : "g" (__NR_kill), "g" (SIGUSR1)); | 41 | "syscall": : "g" (__NR_kill), "g" (SIGUSR1) : |
| 26 | /* Two popqs to restore the stack to the state just before entering | 42 | "%rdi", "%rax", "%rsi"); |
| 27 | * the handler, one pops the return address, the other pops the frame | 43 | /* sys_sigreturn expects that the stack pointer will be 8 bytes into |
| 28 | * pointer. | 44 | * the signal frame. So, we use the ucontext pointer, which we know |
| 45 | * already, to get the signal frame pointer, and add 8 to that. | ||
| 29 | */ | 46 | */ |
| 30 | __asm__("popq %%rax ; popq %%rax ; movq %0, %%rax ; syscall" : : "g" | 47 | __asm__("movq %0, %%rsp": : |
| 31 | (__NR_rt_sigreturn)); | 48 | "g" ((unsigned long) container_of(uc, struct rt_sigframe, |
| 49 | uc) + 8)); | ||
| 50 | __asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn)); | ||
| 32 | } | 51 | } |
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 | } | ||
