From 3d72210bdc1ef67b72ffbd3e74873cae7287f2c6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:00:39 +0100 Subject: um: make copy_sc() static ... and kill it in amd64 - not used. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/kern_util.h | 1 - 1 file changed, 1 deletion(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/kern_util.h b/arch/um/include/shared/kern_util.h index 3c341222d25..0f148385246 100644 --- a/arch/um/include/shared/kern_util.h +++ b/arch/um/include/shared/kern_util.h @@ -21,7 +21,6 @@ extern unsigned long alloc_stack(int order, int atomic); extern void free_stack(unsigned long stack, int order); extern int do_signal(void); -extern void copy_sc(struct uml_pt_regs *regs, void *from); extern void interrupt_end(void); extern void relay_signal(int sig, struct uml_pt_regs *regs); -- cgit v1.2.3-70-g09d2 From 9f270de8361d9cbbfd79e874de125a02b2d73697 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:01:09 +0100 Subject: um: kill skas_ptregs.h It's a plain include of user_constants.h and all (2) users are including user_constants.h directly prior to that. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/skas_ptregs.h | 6 ------ arch/um/sys-i386/shared/sysdep/ptrace.h | 2 -- arch/um/sys-x86_64/shared/sysdep/ptrace.h | 2 -- 3 files changed, 10 deletions(-) delete mode 100644 arch/um/include/shared/skas_ptregs.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/skas_ptregs.h b/arch/um/include/shared/skas_ptregs.h deleted file mode 100644 index 73db19e9c07..00000000000 --- a/arch/um/include/shared/skas_ptregs.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __SKAS_PT_REGS_ -#define __SKAS_PT_REGS_ - -#include - -#endif diff --git a/arch/um/sys-i386/shared/sysdep/ptrace.h b/arch/um/sys-i386/shared/sysdep/ptrace.h index c398a507611..c4142315f22 100644 --- a/arch/um/sys-i386/shared/sysdep/ptrace.h +++ b/arch/um/sys-i386/shared/sysdep/ptrace.h @@ -24,8 +24,6 @@ void set_using_sysemu(int value); int get_using_sysemu(void); extern int sysemu_supported; -#include "skas_ptregs.h" - #define REGS_IP(r) ((r)[HOST_IP]) #define REGS_SP(r) ((r)[HOST_SP]) #define REGS_EFLAGS(r) ((r)[HOST_EFLAGS]) diff --git a/arch/um/sys-x86_64/shared/sysdep/ptrace.h b/arch/um/sys-x86_64/shared/sysdep/ptrace.h index 8ee8f8e12af..1a199606009 100644 --- a/arch/um/sys-x86_64/shared/sysdep/ptrace.h +++ b/arch/um/sys-x86_64/shared/sysdep/ptrace.h @@ -14,8 +14,6 @@ #define MAX_REG_OFFSET (UM_FRAME_SIZE) #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) -#include "skas_ptregs.h" - #define REGS_IP(r) ((r)[HOST_IP]) #define REGS_SP(r) ((r)[HOST_SP]) -- cgit v1.2.3-70-g09d2 From 9e636452d0714b08e4f8f4c58b76c4b7d15ffffa Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:01:49 +0100 Subject: um: get rid of kern_constants.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/Makefile | 11 +---------- arch/um/include/shared/as-layout.h | 2 +- arch/um/include/shared/task.h | 2 +- arch/um/include/shared/um_malloc.h | 2 +- arch/um/include/shared/user.h | 2 +- 5 files changed, 5 insertions(+), 14 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/Makefile b/arch/um/Makefile index 3aded4e04f8..649aebcc6a4 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -25,9 +25,6 @@ include $(srctree)/$(ARCH_DIR)/Makefile-skas SHARED_HEADERS := $(ARCH_DIR)/include/shared ARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared -ifneq ($(KBUILD_SRC),) -ARCH_INCLUDE += -I$(SHARED_HEADERS) -endif KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so @@ -87,7 +84,6 @@ endef KBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH) archprepare: include/generated/user_constants.h -archprepare: $(SHARED_HEADERS)/kern_constants.h LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib @@ -118,8 +114,7 @@ endef # When cleaning we don't include .config, so we don't include # TT or skas makefiles and don't clean skas_ptregs.h. -CLEAN_FILES += linux x.i gmon.out \ - $(SHARED_HEADERS)/kern_constants.h +CLEAN_FILES += linux x.i gmon.out archclean: @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ @@ -146,8 +141,4 @@ endef include/generated/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s $(call filechk,gen-asm-offsets) -$(SHARED_HEADERS)/kern_constants.h: - $(Q)mkdir -p $(dir $@) - $(Q)echo '#include ' >$@ - export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h index a92b678503c..896e1660217 100644 --- a/arch/um/include/shared/as-layout.h +++ b/arch/um/include/shared/as-layout.h @@ -6,7 +6,7 @@ #ifndef __START_H__ #define __START_H__ -#include "kern_constants.h" +#include /* * Stolen from linux/const.h, which can't be directly included since diff --git a/arch/um/include/shared/task.h b/arch/um/include/shared/task.h index 3fe726b3cf4..3db6b58b505 100644 --- a/arch/um/include/shared/task.h +++ b/arch/um/include/shared/task.h @@ -1,7 +1,7 @@ #ifndef __TASK_H #define __TASK_H -#include +#include #define TASK_REGS(task) ((struct uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) #define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) diff --git a/arch/um/include/shared/um_malloc.h b/arch/um/include/shared/um_malloc.h index c554d706d10..6395fef6b69 100644 --- a/arch/um/include/shared/um_malloc.h +++ b/arch/um/include/shared/um_malloc.h @@ -6,7 +6,7 @@ #ifndef __UM_MALLOC_H__ #define __UM_MALLOC_H__ -#include "kern_constants.h" +#include extern void *uml_kmalloc(int size, int flags); extern void kfree(const void *ptr); diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h index 293f7c794fa..2d46f6329ae 100644 --- a/arch/um/include/shared/user.h +++ b/arch/um/include/shared/user.h @@ -6,7 +6,7 @@ #ifndef __USER_H__ #define __USER_H__ -#include "kern_constants.h" +#include /* * The usual definition - copied here because the kernel provides its own, -- cgit v1.2.3-70-g09d2 From 16b7c5737d2c46c8772ca11ac219273362a9a29e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:01:59 +0100 Subject: um: trim unused junk from user.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/user.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h index 2d46f6329ae..58c058165e0 100644 --- a/arch/um/include/shared/user.h +++ b/arch/um/include/shared/user.h @@ -36,9 +36,7 @@ static inline int printk(const char *fmt, ...) } #endif -extern void schedule(void); extern int in_aton(char *str); -extern int open_gdb_chan(void); extern size_t strlcpy(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t); -- cgit v1.2.3-70-g09d2 From c16d56a37ac6889ae9b199c02e76a03ec8a8c419 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:02:09 +0100 Subject: um: get rid of sysdep/checksum.h Move those to sys-.../asm/checksum.h, kill include/asm/checksum.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/checksum.h | 6 - arch/um/sys-i386/asm/checksum.h | 201 ++++++++++++++++++++++++++++ arch/um/sys-i386/shared/sysdep/checksum.h | 201 ---------------------------- arch/um/sys-x86_64/asm/checksum.h | 144 ++++++++++++++++++++ arch/um/sys-x86_64/shared/sysdep/checksum.h | 144 -------------------- 5 files changed, 345 insertions(+), 351 deletions(-) delete mode 100644 arch/um/include/asm/checksum.h create mode 100644 arch/um/sys-i386/asm/checksum.h delete mode 100644 arch/um/sys-i386/shared/sysdep/checksum.h create mode 100644 arch/um/sys-x86_64/asm/checksum.h delete mode 100644 arch/um/sys-x86_64/shared/sysdep/checksum.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/checksum.h b/arch/um/include/asm/checksum.h deleted file mode 100644 index 5b501361e36..00000000000 --- a/arch/um/include/asm/checksum.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __UM_CHECKSUM_H -#define __UM_CHECKSUM_H - -#include "sysdep/checksum.h" - -#endif diff --git a/arch/um/sys-i386/asm/checksum.h b/arch/um/sys-i386/asm/checksum.h new file mode 100644 index 00000000000..caab74252e2 --- /dev/null +++ b/arch/um/sys-i386/asm/checksum.h @@ -0,0 +1,201 @@ +/* + * Licensed under the GPL + */ + +#ifndef __UM_SYSDEP_CHECKSUM_H +#define __UM_SYSDEP_CHECKSUM_H + +#include "linux/in6.h" +#include "linux/string.h" + +/* + * computes the checksum of a memory block at buff, length len, + * and adds in "sum" (32-bit) + * + * returns a 32-bit number suitable for feeding into itself + * or csum_tcpudp_magic + * + * this function must be called with even lengths, except + * for the last fragment, which may be odd + * + * it's best to have buff aligned on a 32-bit boundary + */ +__wsum csum_partial(const void *buff, int len, __wsum sum); + +/* + * Note: when you get a NULL pointer exception here this means someone + * passed in an incorrect kernel address to one of these functions. + * + * If you use these functions directly please don't forget the + * access_ok(). + */ + +static __inline__ +__wsum csum_partial_copy_nocheck(const void *src, void *dst, + int len, __wsum sum) +{ + memcpy(dst, src, len); + return csum_partial(dst, len, sum); +} + +/* + * the same as csum_partial, but copies from src while it + * checksums, and handles user-space pointer exceptions correctly, when needed. + * + * here even more important to align src and dst on a 32-bit (or even + * better 64-bit) boundary + */ + +static __inline__ +__wsum csum_partial_copy_from_user(const void __user *src, void *dst, + int len, __wsum sum, int *err_ptr) +{ + if (copy_from_user(dst, src, len)) { + *err_ptr = -EFAULT; + return (__force __wsum)-1; + } + + return csum_partial(dst, len, sum); +} + +/* + * This is a version of ip_compute_csum() optimized for IP headers, + * which always checksum on 4 octet boundaries. + * + * By Jorge Cwik , adapted for linux by + * Arnt Gulbrandsen. + */ +static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) +{ + unsigned int sum; + + __asm__ __volatile__( + "movl (%1), %0 ;\n" + "subl $4, %2 ;\n" + "jbe 2f ;\n" + "addl 4(%1), %0 ;\n" + "adcl 8(%1), %0 ;\n" + "adcl 12(%1), %0 ;\n" +"1: adcl 16(%1), %0 ;\n" + "lea 4(%1), %1 ;\n" + "decl %2 ;\n" + "jne 1b ;\n" + "adcl $0, %0 ;\n" + "movl %0, %2 ;\n" + "shrl $16, %0 ;\n" + "addw %w2, %w0 ;\n" + "adcl $0, %0 ;\n" + "notl %0 ;\n" +"2: ;\n" + /* Since the input registers which are loaded with iph and ipl + are modified, we must also specify them as outputs, or gcc + will assume they contain their original values. */ + : "=r" (sum), "=r" (iph), "=r" (ihl) + : "1" (iph), "2" (ihl) + : "memory"); + return (__force __sum16)sum; +} + +/* + * Fold a partial checksum + */ + +static inline __sum16 csum_fold(__wsum sum) +{ + __asm__( + "addl %1, %0 ;\n" + "adcl $0xffff, %0 ;\n" + : "=r" (sum) + : "r" ((__force u32)sum << 16), + "0" ((__force u32)sum & 0xffff0000) + ); + return (__force __sum16)(~(__force u32)sum >> 16); +} + +static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, + unsigned short len, + unsigned short proto, + __wsum sum) +{ + __asm__( + "addl %1, %0 ;\n" + "adcl %2, %0 ;\n" + "adcl %3, %0 ;\n" + "adcl $0, %0 ;\n" + : "=r" (sum) + : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum)); + return sum; +} + +/* + * computes the checksum of the TCP/UDP pseudo-header + * returns a 16-bit checksum, already complemented + */ +static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, + unsigned short len, + unsigned short proto, + __wsum sum) +{ + return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); +} + +/* + * this routine is used for miscellaneous IP-like checksums, mainly + * in icmp.c + */ + +static inline __sum16 ip_compute_csum(const void *buff, int len) +{ + return csum_fold (csum_partial(buff, len, 0)); +} + +#define _HAVE_ARCH_IPV6_CSUM +static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, + const struct in6_addr *daddr, + __u32 len, unsigned short proto, + __wsum sum) +{ + __asm__( + "addl 0(%1), %0 ;\n" + "adcl 4(%1), %0 ;\n" + "adcl 8(%1), %0 ;\n" + "adcl 12(%1), %0 ;\n" + "adcl 0(%2), %0 ;\n" + "adcl 4(%2), %0 ;\n" + "adcl 8(%2), %0 ;\n" + "adcl 12(%2), %0 ;\n" + "adcl %3, %0 ;\n" + "adcl %4, %0 ;\n" + "adcl $0, %0 ;\n" + : "=&r" (sum) + : "r" (saddr), "r" (daddr), + "r"(htonl(len)), "r"(htonl(proto)), "0"(sum)); + + return csum_fold(sum); +} + +/* + * Copy and checksum to user + */ +#define HAVE_CSUM_COPY_USER +static __inline__ __wsum csum_and_copy_to_user(const void *src, + void __user *dst, + int len, __wsum sum, int *err_ptr) +{ + if (access_ok(VERIFY_WRITE, dst, len)) { + if (copy_to_user(dst, src, len)) { + *err_ptr = -EFAULT; + return (__force __wsum)-1; + } + + return csum_partial(src, len, sum); + } + + if (len) + *err_ptr = -EFAULT; + + return (__force __wsum)-1; /* invalid checksum */ +} + +#endif + diff --git a/arch/um/sys-i386/shared/sysdep/checksum.h b/arch/um/sys-i386/shared/sysdep/checksum.h deleted file mode 100644 index ed47445f390..00000000000 --- a/arch/um/sys-i386/shared/sysdep/checksum.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed under the GPL - */ - -#ifndef __UM_SYSDEP_CHECKSUM_H -#define __UM_SYSDEP_CHECKSUM_H - -#include "linux/in6.h" -#include "linux/string.h" - -/* - * computes the checksum of a memory block at buff, length len, - * and adds in "sum" (32-bit) - * - * returns a 32-bit number suitable for feeding into itself - * or csum_tcpudp_magic - * - * this function must be called with even lengths, except - * for the last fragment, which may be odd - * - * it's best to have buff aligned on a 32-bit boundary - */ -__wsum csum_partial(const void *buff, int len, __wsum sum); - -/* - * Note: when you get a NULL pointer exception here this means someone - * passed in an incorrect kernel address to one of these functions. - * - * If you use these functions directly please don't forget the - * access_ok(). - */ - -static __inline__ -__wsum csum_partial_copy_nocheck(const void *src, void *dst, - int len, __wsum sum) -{ - memcpy(dst, src, len); - return csum_partial(dst, len, sum); -} - -/* - * the same as csum_partial, but copies from src while it - * checksums, and handles user-space pointer exceptions correctly, when needed. - * - * here even more important to align src and dst on a 32-bit (or even - * better 64-bit) boundary - */ - -static __inline__ -__wsum csum_partial_copy_from_user(const void __user *src, void *dst, - int len, __wsum sum, int *err_ptr) -{ - if (copy_from_user(dst, src, len)) { - *err_ptr = -EFAULT; - return (__force __wsum)-1; - } - - return csum_partial(dst, len, sum); -} - -/* - * This is a version of ip_compute_csum() optimized for IP headers, - * which always checksum on 4 octet boundaries. - * - * By Jorge Cwik , adapted for linux by - * Arnt Gulbrandsen. - */ -static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) -{ - unsigned int sum; - - __asm__ __volatile__( - "movl (%1), %0 ;\n" - "subl $4, %2 ;\n" - "jbe 2f ;\n" - "addl 4(%1), %0 ;\n" - "adcl 8(%1), %0 ;\n" - "adcl 12(%1), %0 ;\n" -"1: adcl 16(%1), %0 ;\n" - "lea 4(%1), %1 ;\n" - "decl %2 ;\n" - "jne 1b ;\n" - "adcl $0, %0 ;\n" - "movl %0, %2 ;\n" - "shrl $16, %0 ;\n" - "addw %w2, %w0 ;\n" - "adcl $0, %0 ;\n" - "notl %0 ;\n" -"2: ;\n" - /* Since the input registers which are loaded with iph and ipl - are modified, we must also specify them as outputs, or gcc - will assume they contain their original values. */ - : "=r" (sum), "=r" (iph), "=r" (ihl) - : "1" (iph), "2" (ihl) - : "memory"); - return (__force __sum16)sum; -} - -/* - * Fold a partial checksum - */ - -static inline __sum16 csum_fold(__wsum sum) -{ - __asm__( - "addl %1, %0 ;\n" - "adcl $0xffff, %0 ;\n" - : "=r" (sum) - : "r" ((__force u32)sum << 16), - "0" ((__force u32)sum & 0xffff0000) - ); - return (__force __sum16)(~(__force u32)sum >> 16); -} - -static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, - unsigned short len, - unsigned short proto, - __wsum sum) -{ - __asm__( - "addl %1, %0 ;\n" - "adcl %2, %0 ;\n" - "adcl %3, %0 ;\n" - "adcl $0, %0 ;\n" - : "=r" (sum) - : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum)); - return sum; -} - -/* - * computes the checksum of the TCP/UDP pseudo-header - * returns a 16-bit checksum, already complemented - */ -static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, - unsigned short len, - unsigned short proto, - __wsum sum) -{ - return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); -} - -/* - * this routine is used for miscellaneous IP-like checksums, mainly - * in icmp.c - */ - -static inline __sum16 ip_compute_csum(const void *buff, int len) -{ - return csum_fold (csum_partial(buff, len, 0)); -} - -#define _HAVE_ARCH_IPV6_CSUM -static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, - const struct in6_addr *daddr, - __u32 len, unsigned short proto, - __wsum sum) -{ - __asm__( - "addl 0(%1), %0 ;\n" - "adcl 4(%1), %0 ;\n" - "adcl 8(%1), %0 ;\n" - "adcl 12(%1), %0 ;\n" - "adcl 0(%2), %0 ;\n" - "adcl 4(%2), %0 ;\n" - "adcl 8(%2), %0 ;\n" - "adcl 12(%2), %0 ;\n" - "adcl %3, %0 ;\n" - "adcl %4, %0 ;\n" - "adcl $0, %0 ;\n" - : "=&r" (sum) - : "r" (saddr), "r" (daddr), - "r"(htonl(len)), "r"(htonl(proto)), "0"(sum)); - - return csum_fold(sum); -} - -/* - * Copy and checksum to user - */ -#define HAVE_CSUM_COPY_USER -static __inline__ __wsum csum_and_copy_to_user(const void *src, - void __user *dst, - int len, __wsum sum, int *err_ptr) -{ - if (access_ok(VERIFY_WRITE, dst, len)) { - if (copy_to_user(dst, src, len)) { - *err_ptr = -EFAULT; - return (__force __wsum)-1; - } - - return csum_partial(src, len, sum); - } - - if (len) - *err_ptr = -EFAULT; - - return (__force __wsum)-1; /* invalid checksum */ -} - -#endif - diff --git a/arch/um/sys-x86_64/asm/checksum.h b/arch/um/sys-x86_64/asm/checksum.h new file mode 100644 index 00000000000..a5be9031ea8 --- /dev/null +++ b/arch/um/sys-x86_64/asm/checksum.h @@ -0,0 +1,144 @@ +/* + * Licensed under the GPL + */ + +#ifndef __UM_SYSDEP_CHECKSUM_H +#define __UM_SYSDEP_CHECKSUM_H + +#include "linux/string.h" +#include "linux/in6.h" +#include "asm/uaccess.h" + +extern __wsum csum_partial(const void *buff, int len, __wsum sum); + +/* + * Note: when you get a NULL pointer exception here this means someone + * passed in an incorrect kernel address to one of these functions. + * + * If you use these functions directly please don't forget the + * access_ok(). + */ + +static __inline__ +__wsum csum_partial_copy_nocheck(const void *src, void *dst, + int len, __wsum sum) +{ + memcpy(dst, src, len); + return(csum_partial(dst, len, sum)); +} + +static __inline__ +__wsum csum_partial_copy_from_user(const void __user *src, + void *dst, int len, __wsum sum, + int *err_ptr) +{ + if (copy_from_user(dst, src, len)) { + *err_ptr = -EFAULT; + return (__force __wsum)-1; + } + return csum_partial(dst, len, sum); +} + +/** + * csum_fold - Fold and invert a 32bit checksum. + * sum: 32bit unfolded sum + * + * Fold a 32bit running checksum to 16bit and invert it. This is usually + * the last step before putting a checksum into a packet. + * Make sure not to mix with 64bit checksums. + */ +static inline __sum16 csum_fold(__wsum sum) +{ + __asm__( + " addl %1,%0\n" + " adcl $0xffff,%0" + : "=r" (sum) + : "r" ((__force u32)sum << 16), + "0" ((__force u32)sum & 0xffff0000) + ); + return (__force __sum16)(~(__force u32)sum >> 16); +} + +/** + * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum. + * @saddr: source address + * @daddr: destination address + * @len: length of packet + * @proto: ip protocol of packet + * @sum: initial sum to be added in (32bit unfolded) + * + * Returns the pseudo header checksum the input data. Result is + * 32bit unfolded. + */ +static inline __wsum +csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, + unsigned short proto, __wsum sum) +{ + asm(" addl %1, %0\n" + " adcl %2, %0\n" + " adcl %3, %0\n" + " adcl $0, %0\n" + : "=r" (sum) + : "g" (daddr), "g" (saddr), "g" ((len + proto) << 8), "0" (sum)); + return sum; +} + +/* + * computes the checksum of the TCP/UDP pseudo-header + * returns a 16-bit checksum, already complemented + */ +static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, + unsigned short len, + unsigned short proto, + __wsum sum) +{ + return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); +} + +/** + * ip_fast_csum - Compute the IPv4 header checksum efficiently. + * iph: ipv4 header + * ihl: length of header / 4 + */ +static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) +{ + unsigned int sum; + + asm( " movl (%1), %0\n" + " subl $4, %2\n" + " jbe 2f\n" + " addl 4(%1), %0\n" + " adcl 8(%1), %0\n" + " adcl 12(%1), %0\n" + "1: adcl 16(%1), %0\n" + " lea 4(%1), %1\n" + " decl %2\n" + " jne 1b\n" + " adcl $0, %0\n" + " movl %0, %2\n" + " shrl $16, %0\n" + " addw %w2, %w0\n" + " adcl $0, %0\n" + " notl %0\n" + "2:" + /* Since the input registers which are loaded with iph and ipl + are modified, we must also specify them as outputs, or gcc + will assume they contain their original values. */ + : "=r" (sum), "=r" (iph), "=r" (ihl) + : "1" (iph), "2" (ihl) + : "memory"); + return (__force __sum16)sum; +} + +static inline unsigned add32_with_carry(unsigned a, unsigned b) +{ + asm("addl %2,%0\n\t" + "adcl $0,%0" + : "=r" (a) + : "0" (a), "r" (b)); + return a; +} + +extern __sum16 ip_compute_csum(const void *buff, int len); + +#endif diff --git a/arch/um/sys-x86_64/shared/sysdep/checksum.h b/arch/um/sys-x86_64/shared/sysdep/checksum.h deleted file mode 100644 index a5be9031ea8..00000000000 --- a/arch/um/sys-x86_64/shared/sysdep/checksum.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed under the GPL - */ - -#ifndef __UM_SYSDEP_CHECKSUM_H -#define __UM_SYSDEP_CHECKSUM_H - -#include "linux/string.h" -#include "linux/in6.h" -#include "asm/uaccess.h" - -extern __wsum csum_partial(const void *buff, int len, __wsum sum); - -/* - * Note: when you get a NULL pointer exception here this means someone - * passed in an incorrect kernel address to one of these functions. - * - * If you use these functions directly please don't forget the - * access_ok(). - */ - -static __inline__ -__wsum csum_partial_copy_nocheck(const void *src, void *dst, - int len, __wsum sum) -{ - memcpy(dst, src, len); - return(csum_partial(dst, len, sum)); -} - -static __inline__ -__wsum csum_partial_copy_from_user(const void __user *src, - void *dst, int len, __wsum sum, - int *err_ptr) -{ - if (copy_from_user(dst, src, len)) { - *err_ptr = -EFAULT; - return (__force __wsum)-1; - } - return csum_partial(dst, len, sum); -} - -/** - * csum_fold - Fold and invert a 32bit checksum. - * sum: 32bit unfolded sum - * - * Fold a 32bit running checksum to 16bit and invert it. This is usually - * the last step before putting a checksum into a packet. - * Make sure not to mix with 64bit checksums. - */ -static inline __sum16 csum_fold(__wsum sum) -{ - __asm__( - " addl %1,%0\n" - " adcl $0xffff,%0" - : "=r" (sum) - : "r" ((__force u32)sum << 16), - "0" ((__force u32)sum & 0xffff0000) - ); - return (__force __sum16)(~(__force u32)sum >> 16); -} - -/** - * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum. - * @saddr: source address - * @daddr: destination address - * @len: length of packet - * @proto: ip protocol of packet - * @sum: initial sum to be added in (32bit unfolded) - * - * Returns the pseudo header checksum the input data. Result is - * 32bit unfolded. - */ -static inline __wsum -csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, - unsigned short proto, __wsum sum) -{ - asm(" addl %1, %0\n" - " adcl %2, %0\n" - " adcl %3, %0\n" - " adcl $0, %0\n" - : "=r" (sum) - : "g" (daddr), "g" (saddr), "g" ((len + proto) << 8), "0" (sum)); - return sum; -} - -/* - * computes the checksum of the TCP/UDP pseudo-header - * returns a 16-bit checksum, already complemented - */ -static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, - unsigned short len, - unsigned short proto, - __wsum sum) -{ - return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); -} - -/** - * ip_fast_csum - Compute the IPv4 header checksum efficiently. - * iph: ipv4 header - * ihl: length of header / 4 - */ -static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) -{ - unsigned int sum; - - asm( " movl (%1), %0\n" - " subl $4, %2\n" - " jbe 2f\n" - " addl 4(%1), %0\n" - " adcl 8(%1), %0\n" - " adcl 12(%1), %0\n" - "1: adcl 16(%1), %0\n" - " lea 4(%1), %1\n" - " decl %2\n" - " jne 1b\n" - " adcl $0, %0\n" - " movl %0, %2\n" - " shrl $16, %0\n" - " addw %w2, %w0\n" - " adcl $0, %0\n" - " notl %0\n" - "2:" - /* Since the input registers which are loaded with iph and ipl - are modified, we must also specify them as outputs, or gcc - will assume they contain their original values. */ - : "=r" (sum), "=r" (iph), "=r" (ihl) - : "1" (iph), "2" (ihl) - : "memory"); - return (__force __sum16)sum; -} - -static inline unsigned add32_with_carry(unsigned a, unsigned b) -{ - asm("addl %2,%0\n\t" - "adcl $0,%0" - : "=r" (a) - : "0" (a), "r" (b)); - return a; -} - -extern __sum16 ip_compute_csum(const void *buff, int len); - -#endif -- cgit v1.2.3-70-g09d2 From ab785c1dd4bef85f308504c83bcf47ce787e1565 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:02:19 +0100 Subject: um: take vm-flags.h to sys-*/asm Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/page.h | 2 +- arch/um/sys-i386/asm/vm-flags.h | 14 ++++++++++++++ arch/um/sys-i386/shared/sysdep/vm-flags.h | 14 -------------- arch/um/sys-x86_64/asm/vm-flags.h | 15 +++++++++++++++ arch/um/sys-x86_64/shared/sysdep/vm-flags.h | 15 --------------- 5 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 arch/um/sys-i386/asm/vm-flags.h delete mode 100644 arch/um/sys-i386/shared/sysdep/vm-flags.h create mode 100644 arch/um/sys-x86_64/asm/vm-flags.h delete mode 100644 arch/um/sys-x86_64/shared/sysdep/vm-flags.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h index 4cc9b6cf480..7cfc3cedce8 100644 --- a/arch/um/include/asm/page.h +++ b/arch/um/include/asm/page.h @@ -19,7 +19,7 @@ struct page; #include -#include +#include /* * These are used to make use of C type-checking.. diff --git a/arch/um/sys-i386/asm/vm-flags.h b/arch/um/sys-i386/asm/vm-flags.h new file mode 100644 index 00000000000..e0d24c568db --- /dev/null +++ b/arch/um/sys-i386/asm/vm-flags.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Licensed under the GPL + */ + +#ifndef __VM_FLAGS_I386_H +#define __VM_FLAGS_I386_H + +#define VM_DATA_DEFAULT_FLAGS \ + (VM_READ | VM_WRITE | \ + ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) + +#endif diff --git a/arch/um/sys-i386/shared/sysdep/vm-flags.h b/arch/um/sys-i386/shared/sysdep/vm-flags.h deleted file mode 100644 index e0d24c568db..00000000000 --- a/arch/um/sys-i386/shared/sysdep/vm-flags.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) - * Licensed under the GPL - */ - -#ifndef __VM_FLAGS_I386_H -#define __VM_FLAGS_I386_H - -#define VM_DATA_DEFAULT_FLAGS \ - (VM_READ | VM_WRITE | \ - ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) - -#endif diff --git a/arch/um/sys-x86_64/asm/vm-flags.h b/arch/um/sys-x86_64/asm/vm-flags.h new file mode 100644 index 00000000000..3978e55132d --- /dev/null +++ b/arch/um/sys-x86_64/asm/vm-flags.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Copyright 2003 PathScale, Inc. + * Licensed under the GPL + */ + +#ifndef __VM_FLAGS_X86_64_H +#define __VM_FLAGS_X86_64_H + +#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) +#define VM_STACK_DEFAULT_FLAGS (VM_GROWSDOWN | VM_READ | VM_WRITE | \ + VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) + +#endif diff --git a/arch/um/sys-x86_64/shared/sysdep/vm-flags.h b/arch/um/sys-x86_64/shared/sysdep/vm-flags.h deleted file mode 100644 index 3978e55132d..00000000000 --- a/arch/um/sys-x86_64/shared/sysdep/vm-flags.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) - * Copyright 2003 PathScale, Inc. - * Licensed under the GPL - */ - -#ifndef __VM_FLAGS_X86_64_H -#define __VM_FLAGS_X86_64_H - -#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#define VM_STACK_DEFAULT_FLAGS (VM_GROWSDOWN | VM_READ | VM_WRITE | \ - VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) - -#endif -- cgit v1.2.3-70-g09d2 From 412f90ed13c86f066a4ab14ed5bcd0793ef0355d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:02:29 +0100 Subject: um: Get rid of UPT_SET/UPT_REG macros the only users are arch getreg()/putreg() and it's easier to handle it there instead of playing with macros from hell Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/ptrace-generic.h | 3 - arch/um/sys-i386/ptrace.c | 69 ++++++++++++++++---- arch/um/sys-i386/shared/sysdep/ptrace.h | 53 --------------- arch/um/sys-x86_64/ptrace.c | 103 +++++++++++++++++++++++++----- arch/um/sys-x86_64/shared/sysdep/ptrace.h | 75 ---------------------- 5 files changed, 145 insertions(+), 158 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index 1a7d2757fe0..c3b8a041c13 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -23,9 +23,6 @@ struct pt_regs { #define PT_REGS_IP(r) UPT_IP(&(r)->regs) #define PT_REGS_SP(r) UPT_SP(&(r)->regs) -#define PT_REG(r, reg) UPT_REG(&(r)->regs, reg) -#define PT_REGS_SET(r, reg, val) UPT_SET(&(r)->regs, reg, val) - #define PT_REGS_SET_SYSCALL_RETURN(r, res) \ UPT_SET_SYSCALL_RETURN(&(r)->regs, res) #define PT_REGS_RESTART_SYSCALL(r) UPT_RESTART_SYSCALL(&(r)->regs) diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c index 3375c271785..a174fde2531 100644 --- a/arch/um/sys-i386/ptrace.c +++ b/arch/um/sys-i386/ptrace.c @@ -50,20 +50,47 @@ int is_syscall(unsigned long addr) /* 1 = access 0 = no access */ #define FLAG_MASK 0x00044dd5 +static const int reg_offsets[] = { + [EBX] = HOST_EBX, + [ECX] = HOST_ECX, + [EDX] = HOST_EDX, + [ESI] = HOST_ESI, + [EDI] = HOST_EDI, + [EBP] = HOST_EBP, + [EAX] = HOST_EAX, + [DS] = HOST_DS, + [ES] = HOST_ES, + [FS] = HOST_FS, + [GS] = HOST_GS, + [EIP] = HOST_IP, + [CS] = HOST_CS, + [EFL] = HOST_EFLAGS, + [UESP] = HOST_SP, + [SS] = HOST_SS, +}; + int putreg(struct task_struct *child, int regno, unsigned long value) { regno >>= 2; switch (regno) { + case EBX: + case ECX: + case EDX: + case ESI: + case EDI: + case EBP: + case EAX: + case EIP: + case UESP: + break; case FS: if (value && (value & 3) != 3) return -EIO; - PT_REGS_FS(&child->thread.regs) = value; - return 0; + break; case GS: if (value && (value & 3) != 3) return -EIO; - PT_REGS_GS(&child->thread.regs) = value; - return 0; + break; case DS: case ES: if (value && (value & 3) != 3) @@ -78,10 +105,15 @@ int putreg(struct task_struct *child, int regno, unsigned long value) break; case EFL: value &= FLAG_MASK; - value |= PT_REGS_EFLAGS(&child->thread.regs); - break; + child->thread.regs.regs.gp[HOST_EFLAGS] |= value; + return 0; + case ORIG_EAX: + child->thread.regs.regs.syscall = value; + return 0; + default : + panic("Bad register in putreg() : %d\n", regno); } - PT_REGS_SET(&child->thread.regs, regno, value); + child->thread.regs.regs.gp[reg_offsets[regno]] = value; return 0; } @@ -106,22 +138,35 @@ int poke_user(struct task_struct *child, long addr, long data) unsigned long getreg(struct task_struct *child, int regno) { - unsigned long retval = ~0UL; + unsigned long mask = ~0UL; regno >>= 2; switch (regno) { + case ORIG_EAX: + return child->thread.regs.regs.syscall; case FS: case GS: case DS: case ES: case SS: case CS: - retval = 0xffff; - /* fall through */ + mask = 0xffff; + break; + case EIP: + case UESP: + case EAX: + case EBX: + case ECX: + case EDX: + case ESI: + case EDI: + case EBP: + case EFL: + break; default: - retval &= PT_REG(&child->thread.regs, regno); + panic("Bad register in getreg() : %d\n", regno); } - return retval; + return mask & child->thread.regs.regs.gp[reg_offsets[regno]]; } /* read the word at location addr in the USER area. */ diff --git a/arch/um/sys-i386/shared/sysdep/ptrace.h b/arch/um/sys-i386/shared/sysdep/ptrace.h index 36006994148..6096c8f89f4 100644 --- a/arch/um/sys-i386/shared/sysdep/ptrace.h +++ b/arch/um/sys-i386/shared/sysdep/ptrace.h @@ -100,59 +100,6 @@ struct syscall_args { UPT_SYSCALL_ARG5(r), \ UPT_SYSCALL_ARG6(r) } } ) -#define UPT_REG(regs, reg) \ - ({ unsigned long val; \ - switch(reg){ \ - case EIP: val = UPT_IP(regs); break; \ - case UESP: val = UPT_SP(regs); break; \ - case EAX: val = UPT_EAX(regs); break; \ - case EBX: val = UPT_EBX(regs); break; \ - case ECX: val = UPT_ECX(regs); break; \ - case EDX: val = UPT_EDX(regs); break; \ - case ESI: val = UPT_ESI(regs); break; \ - case EDI: val = UPT_EDI(regs); break; \ - case EBP: val = UPT_EBP(regs); break; \ - case ORIG_EAX: val = UPT_ORIG_EAX(regs); break; \ - case CS: val = UPT_CS(regs); break; \ - case SS: val = UPT_SS(regs); break; \ - case DS: val = UPT_DS(regs); break; \ - case ES: val = UPT_ES(regs); break; \ - case FS: val = UPT_FS(regs); break; \ - case GS: val = UPT_GS(regs); break; \ - case EFL: val = UPT_EFLAGS(regs); break; \ - default : \ - panic("Bad register in UPT_REG : %d\n", reg); \ - val = -1; \ - } \ - val; \ - }) - -#define UPT_SET(regs, reg, val) \ - do { \ - switch(reg){ \ - case EIP: UPT_IP(regs) = val; break; \ - case UESP: UPT_SP(regs) = val; break; \ - case EAX: UPT_EAX(regs) = val; break; \ - case EBX: UPT_EBX(regs) = val; break; \ - case ECX: UPT_ECX(regs) = val; break; \ - case EDX: UPT_EDX(regs) = val; break; \ - case ESI: UPT_ESI(regs) = val; break; \ - case EDI: UPT_EDI(regs) = val; break; \ - case EBP: UPT_EBP(regs) = val; break; \ - case ORIG_EAX: UPT_ORIG_EAX(regs) = val; break; \ - case CS: UPT_CS(regs) = val; break; \ - case SS: UPT_SS(regs) = val; break; \ - case DS: UPT_DS(regs) = val; break; \ - case ES: UPT_ES(regs) = val; break; \ - case FS: UPT_FS(regs) = val; break; \ - case GS: UPT_GS(regs) = val; break; \ - case EFL: UPT_EFLAGS(regs) = val; break; \ - default : \ - panic("Bad register in UPT_SET : %d\n", reg); \ - break; \ - } \ - } while (0) - #define UPT_SET_SYSCALL_RETURN(r, res) \ REGS_SET_SYSCALL_RETURN((r)->regs, (res)) diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c index 4005506834f..44e68e0c0d1 100644 --- a/arch/um/sys-x86_64/ptrace.c +++ b/arch/um/sys-x86_64/ptrace.c @@ -18,10 +18,39 @@ */ #define FLAG_MASK 0x44dd5UL -int putreg(struct task_struct *child, int regno, unsigned long value) +static const int reg_offsets[] = { - unsigned long tmp; + [R8 >> 3] = HOST_R8, + [R9 >> 3] = HOST_R9, + [R10 >> 3] = HOST_R10, + [R11 >> 3] = HOST_R11, + [R12 >> 3] = HOST_R12, + [R13 >> 3] = HOST_R13, + [R14 >> 3] = HOST_R14, + [R15 >> 3] = HOST_R15, + [RIP >> 3] = HOST_IP, + [RSP >> 3] = HOST_SP, + [RAX >> 3] = HOST_RAX, + [RBX >> 3] = HOST_RBX, + [RCX >> 3] = HOST_RCX, + [RDX >> 3] = HOST_RDX, + [RSI >> 3] = HOST_RSI, + [RDI >> 3] = HOST_RDI, + [RBP >> 3] = HOST_RBP, + [CS >> 3] = HOST_CS, + [SS >> 3] = HOST_SS, + [FS_BASE >> 3] = HOST_FS_BASE, + [GS_BASE >> 3] = HOST_GS_BASE, + [DS >> 3] = HOST_DS, + [ES >> 3] = HOST_ES, + [FS >> 3] = HOST_FS, + [GS >> 3] = HOST_GS, + [EFLAGS >> 3] = HOST_EFLAGS, + [ORIG_RAX >> 3] = HOST_ORIG_RAX, +}; +int putreg(struct task_struct *child, int regno, unsigned long value) +{ #ifdef TIF_IA32 /* * Some code in the 64bit emulation may not be 64bit clean. @@ -31,6 +60,26 @@ int putreg(struct task_struct *child, int regno, unsigned long value) value &= 0xffffffff; #endif switch (regno) { + case R8: + case R9: + case R10: + case R11: + case R12: + case R13: + case R14: + case R15: + case RIP: + case RSP: + case RAX: + case RBX: + case RCX: + case RDX: + case RSI: + case RDI: + case RBP: + case ORIG_RAX: + break; + case FS: case GS: case DS: @@ -50,12 +99,14 @@ int putreg(struct task_struct *child, int regno, unsigned long value) case EFLAGS: value &= FLAG_MASK; - tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK; - value |= tmp; - break; + child->thread.regs.regs.gp[HOST_EFLAGS] |= value; + return 0; + + default: + panic("Bad register in putreg(): %d\n", regno); } - PT_REGS_SET(&child->thread.regs, regno, value); + child->thread.regs.regs.gp[reg_offsets[regno >> 3]] = value; return 0; } @@ -80,24 +131,46 @@ int poke_user(struct task_struct *child, long addr, long data) unsigned long getreg(struct task_struct *child, int regno) { - unsigned long retval = ~0UL; + unsigned long mask = ~0UL; +#ifdef TIF_IA32 + if (test_tsk_thread_flag(child, TIF_IA32)) + mask = 0xffffffff; +#endif switch (regno) { + case R8: + case R9: + case R10: + case R11: + case R12: + case R13: + case R14: + case R15: + case RIP: + case RSP: + case RAX: + case RBX: + case RCX: + case RDX: + case RSI: + case RDI: + case RBP: + case ORIG_RAX: + case EFLAGS: + case FS_BASE: + case GS_BASE: + break; case FS: case GS: case DS: case ES: case SS: case CS: - retval = 0xffff; - /* fall through */ + mask = 0xffff; + break; default: - retval &= PT_REG(&child->thread.regs, regno); -#ifdef TIF_IA32 - if (test_tsk_thread_flag(child, TIF_IA32)) - retval &= 0xffffffff; -#endif + panic("Bad register in getreg: %d\n", regno); } - return retval; + return mask & child->thread.regs.regs.gp[reg_offsets[regno >> 3]]; } int peek_user(struct task_struct *child, long addr, long data) diff --git a/arch/um/sys-x86_64/shared/sysdep/ptrace.h b/arch/um/sys-x86_64/shared/sysdep/ptrace.h index ea5d7c1783c..9ed4597fa94 100644 --- a/arch/um/sys-x86_64/shared/sysdep/ptrace.h +++ b/arch/um/sys-x86_64/shared/sysdep/ptrace.h @@ -147,81 +147,6 @@ struct syscall_args { UPT_SYSCALL_ARG5(r), \ UPT_SYSCALL_ARG6(r) } } ) -#define UPT_REG(regs, reg) \ - ({ unsigned long val; \ - switch(reg){ \ - case R8: val = UPT_R8(regs); break; \ - case R9: val = UPT_R9(regs); break; \ - case R10: val = UPT_R10(regs); break; \ - case R11: val = UPT_R11(regs); break; \ - case R12: val = UPT_R12(regs); break; \ - case R13: val = UPT_R13(regs); break; \ - case R14: val = UPT_R14(regs); break; \ - case R15: val = UPT_R15(regs); break; \ - case RIP: val = UPT_IP(regs); break; \ - case RSP: val = UPT_SP(regs); break; \ - case RAX: val = UPT_RAX(regs); break; \ - case RBX: val = UPT_RBX(regs); break; \ - case RCX: val = UPT_RCX(regs); break; \ - case RDX: val = UPT_RDX(regs); break; \ - case RSI: val = UPT_RSI(regs); break; \ - case RDI: val = UPT_RDI(regs); break; \ - case RBP: val = UPT_RBP(regs); break; \ - case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ - case CS: val = UPT_CS(regs); break; \ - case SS: val = UPT_SS(regs); break; \ - case FS_BASE: val = UPT_FS_BASE(regs); break; \ - case GS_BASE: val = UPT_GS_BASE(regs); break; \ - case DS: val = UPT_DS(regs); break; \ - case ES: val = UPT_ES(regs); break; \ - case FS : val = UPT_FS (regs); break; \ - case GS: val = UPT_GS(regs); break; \ - case EFLAGS: val = UPT_EFLAGS(regs); break; \ - default : \ - panic("Bad register in UPT_REG : %d\n", reg); \ - val = -1; \ - } \ - val; \ - }) - - -#define UPT_SET(regs, reg, val) \ - ({ unsigned long __upt_val = val; \ - switch(reg){ \ - case R8: UPT_R8(regs) = __upt_val; break; \ - case R9: UPT_R9(regs) = __upt_val; break; \ - case R10: UPT_R10(regs) = __upt_val; break; \ - case R11: UPT_R11(regs) = __upt_val; break; \ - case R12: UPT_R12(regs) = __upt_val; break; \ - case R13: UPT_R13(regs) = __upt_val; break; \ - case R14: UPT_R14(regs) = __upt_val; break; \ - case R15: UPT_R15(regs) = __upt_val; break; \ - case RIP: UPT_IP(regs) = __upt_val; break; \ - case RSP: UPT_SP(regs) = __upt_val; break; \ - case RAX: UPT_RAX(regs) = __upt_val; break; \ - case RBX: UPT_RBX(regs) = __upt_val; break; \ - case RCX: UPT_RCX(regs) = __upt_val; break; \ - case RDX: UPT_RDX(regs) = __upt_val; break; \ - case RSI: UPT_RSI(regs) = __upt_val; break; \ - case RDI: UPT_RDI(regs) = __upt_val; break; \ - case RBP: UPT_RBP(regs) = __upt_val; break; \ - case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ - case CS: UPT_CS(regs) = __upt_val; break; \ - case SS: UPT_SS(regs) = __upt_val; break; \ - case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \ - case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \ - case DS: UPT_DS(regs) = __upt_val; break; \ - case ES: UPT_ES(regs) = __upt_val; break; \ - case FS: UPT_FS(regs) = __upt_val; break; \ - case GS: UPT_GS(regs) = __upt_val; break; \ - case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ - default : \ - panic("Bad register in UPT_SET : %d\n", reg); \ - break; \ - } \ - __upt_val; \ - }) - #define UPT_SET_SYSCALL_RETURN(r, res) \ REGS_SET_SYSCALL_RETURN((r)->regs, (res)) -- cgit v1.2.3-70-g09d2 From 5d40de0f6e726dc9c48fb35815e0a6153e59e1dc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:03:29 +0100 Subject: um: kill dead code around uaccess Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/os.h | 6 ------ arch/um/include/shared/um_uaccess.h | 3 --- arch/um/kernel/Makefile | 2 +- arch/um/kernel/uaccess.c | 33 --------------------------------- arch/um/os-Linux/Makefile | 4 ++-- arch/um/os-Linux/uaccess.c | 32 -------------------------------- 6 files changed, 3 insertions(+), 77 deletions(-) delete mode 100644 arch/um/kernel/uaccess.c delete mode 100644 arch/um/os-Linux/uaccess.c (limited to 'arch/um/include') diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 83c7c2ecd61..2e2663a8e91 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -203,12 +203,6 @@ extern int os_drop_memory(void *addr, int length); extern int can_drop_memory(void); extern void os_flush_stdout(void); -/* uaccess.c */ -extern unsigned long __do_user_copy(void *to, const void *from, int n, - void **fault_addr, jmp_buf **fault_catcher, - void (*op)(void *to, const void *from, - int n), int *faulted_out); - /* execvp.c */ extern int execvp_noalloc(char *buf, const char *file, char *const argv[]); /* helper.c */ diff --git a/arch/um/include/shared/um_uaccess.h b/arch/um/include/shared/um_uaccess.h index 45c04999d67..51e1cce92d3 100644 --- a/arch/um/include/shared/um_uaccess.h +++ b/arch/um/include/shared/um_uaccess.h @@ -32,9 +32,6 @@ extern int copy_from_user(void *to, const void __user *from, int n); extern int copy_to_user(void __user *to, const void *from, int n); -extern int __do_copy_to_user(void *to, const void *from, int n, - void **fault_addr, jmp_buf **fault_catcher); - /* * strncpy_from_user: - Copy a NUL terminated string from userspace. * @dst: Destination address, in kernel space. This buffer must be at diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index c4491c15afb..bc494741b1f 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -11,7 +11,7 @@ clean-files := obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \ physmem.o process.o ptrace.o reboot.o sigio.o \ - signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o uaccess.o \ + signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \ um_arch.o umid.o skas/ obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o diff --git a/arch/um/kernel/uaccess.c b/arch/um/kernel/uaccess.c deleted file mode 100644 index dd33f040c52..00000000000 --- a/arch/um/kernel/uaccess.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) - * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -/* - * These are here rather than tt/uaccess.c because skas mode needs them in - * order to do SIGBUS recovery when a tmpfs mount runs out of room. - */ - -#include -#include "os.h" - -static void __do_copy(void *to, const void *from, int n) -{ - memcpy(to, from, n); -} - - -int __do_copy_to_user(void *to, const void *from, int n, - void **fault_addr, jmp_buf **fault_catcher) -{ - unsigned long fault; - int faulted; - - fault = __do_user_copy(to, from, n, fault_addr, fault_catcher, - __do_copy, &faulted); - if (!faulted) - return 0; - else - return n - (fault - (unsigned long) to); -} diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index b33f4dfe7ae..7aec5bfea33 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -4,14 +4,14 @@ # obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ - registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ + registers.o sigio.o signal.o start_up.o time.o tty.o \ umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ - tty.o tls.o uaccess.o umid.o util.o + tty.o tls.o umid.o util.o CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) diff --git a/arch/um/os-Linux/uaccess.c b/arch/um/os-Linux/uaccess.c deleted file mode 100644 index 087ed74ffca..00000000000 --- a/arch/um/os-Linux/uaccess.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) - * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#include -#include "longjmp.h" - -unsigned long __do_user_copy(void *to, const void *from, int n, - void **fault_addr, jmp_buf **fault_catcher, - void (*op)(void *to, const void *from, - int n), int *faulted_out) -{ - unsigned long *faddrp = (unsigned long *) fault_addr, ret; - - jmp_buf jbuf; - *fault_catcher = &jbuf; - if (UML_SETJMP(&jbuf) == 0) { - (*op)(to, from, n); - ret = 0; - *faulted_out = 0; - } - else { - ret = *faddrp; - *faulted_out = 1; - } - *fault_addr = NULL; - *fault_catcher = NULL; - return ret; -} - -- cgit v1.2.3-70-g09d2 From e87df986ed053d25dbd57b8b137edec5022874f8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:04:29 +0100 Subject: um: simplify set_handler() For one thing, we always block the same signals (IRQ ones - IO, WINCH, VTALRM), so there's no need to pass sa_mask elements in arguments. For another, the flags depend only on whether it's an IRQ signal or not (we add SA_RESTART for them). Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/os.h | 2 +- arch/um/os-Linux/process.c | 19 ++++++------------- arch/um/os-Linux/signal.c | 22 +++++++++++----------- arch/um/os-Linux/skas/process.c | 3 +-- 4 files changed, 19 insertions(+), 27 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 2e2663a8e91..598ca825ea9 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -225,7 +225,7 @@ extern char *get_umid(void); extern void timer_init(void); extern void set_sigstack(void *sig_stack, int size); extern void remove_sigstack(void); -extern void set_handler(int sig, void (*handler)(int), int flags, ...); +extern void set_handler(int sig, void (*handler)(int)); extern int change_sig(int signal, int on); extern void block_signals(void); extern void unblock_signals(void); diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index c1a8fa74ebb..075ae920143 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -235,20 +235,13 @@ out: void init_new_thread_signals(void) { - set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK, - SIGIO, SIGWINCH, SIGVTALRM, -1); - set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK, - SIGIO, SIGWINCH, SIGVTALRM, -1); - set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK, - SIGIO, SIGWINCH, SIGVTALRM, -1); - set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK, - SIGIO, SIGWINCH, SIGVTALRM, -1); - set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK, - SIGIO, SIGWINCH, SIGVTALRM, -1); + set_handler(SIGSEGV, (__sighandler_t) sig_handler); + set_handler(SIGTRAP, (__sighandler_t) sig_handler); + set_handler(SIGFPE, (__sighandler_t) sig_handler); + set_handler(SIGILL, (__sighandler_t) sig_handler); + set_handler(SIGBUS, (__sighandler_t) sig_handler); signal(SIGHUP, SIG_IGN); - - set_handler(SIGIO, (__sighandler_t) sig_handler, - SA_ONSTACK | SA_RESTART, SIGIO, SIGWINCH, SIGVTALRM, -1); + set_handler(SIGIO, (__sighandler_t) sig_handler); signal(SIGWINCH, SIG_IGN); signal(SIGTERM, SIG_DFL); } diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 75c3e9c9cab..f248fb2ab58 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -111,8 +111,7 @@ void alarm_handler(int sig, struct sigcontext *sc) void timer_init(void) { - set_handler(SIGVTALRM, (__sighandler_t) alarm_handler, - SA_ONSTACK | SA_RESTART, SIGIO, SIGWINCH, -1); + set_handler(SIGVTALRM, (__sighandler_t) alarm_handler); } void set_sigstack(void *sig_stack, int size) @@ -174,27 +173,28 @@ static void hard_handler(int sig, siginfo_t *info, void *p) handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext); } -void set_handler(int sig, void (*handler)(int), int flags, ...) +void set_handler(int sig, void (*handler)(int)) { struct sigaction action; - va_list ap; + int flags = SA_SIGINFO | SA_ONSTACK; sigset_t sig_mask; - int mask; handlers[sig] = (void (*)(int, struct sigcontext *)) handler; action.sa_sigaction = hard_handler; + /* block irq ones */ sigemptyset(&action.sa_mask); - - va_start(ap, flags); - while ((mask = va_arg(ap, int)) != -1) - sigaddset(&action.sa_mask, mask); - va_end(ap); + sigaddset(&action.sa_mask, SIGVTALRM); + sigaddset(&action.sa_mask, SIGIO); + sigaddset(&action.sa_mask, SIGWINCH); if (sig == SIGSEGV) flags |= SA_NODEFER; - action.sa_flags = flags | SA_SIGINFO; + if (sigismember(&action.sa_mask, sig)) + flags |= SA_RESTART; /* if it's an irq signal */ + + action.sa_flags = flags; action.sa_restorer = NULL; if (sigaction(sig, &action, NULL) < 0) panic("sigaction failed - errno = %d\n", errno); diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 20b34dcb090..31743f1d119 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -659,8 +659,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf) { int n; - set_handler(SIGWINCH, (__sighandler_t) sig_handler, - SA_ONSTACK | SA_RESTART, SIGIO, SIGVTALRM, -1); + set_handler(SIGWINCH, (__sighandler_t) sig_handler); /* * Can't use UML_SETJMP or UML_LONGJMP here because they save -- cgit v1.2.3-70-g09d2 From 00361683ce562402a189362f43370a459b166645 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:04:39 +0100 Subject: um: fill the handlers array at build time Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/os.h | 2 +- arch/um/os-Linux/process.c | 12 ++++++------ arch/um/os-Linux/signal.c | 17 +++++++++++++---- arch/um/os-Linux/skas/process.c | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 598ca825ea9..caa66619a9b 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -225,7 +225,7 @@ extern char *get_umid(void); extern void timer_init(void); extern void set_sigstack(void *sig_stack, int size); extern void remove_sigstack(void); -extern void set_handler(int sig, void (*handler)(int)); +extern void set_handler(int sig); extern int change_sig(int signal, int on); extern void block_signals(void); extern void unblock_signals(void); diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 075ae920143..e08fe305beb 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -235,13 +235,13 @@ out: void init_new_thread_signals(void) { - set_handler(SIGSEGV, (__sighandler_t) sig_handler); - set_handler(SIGTRAP, (__sighandler_t) sig_handler); - set_handler(SIGFPE, (__sighandler_t) sig_handler); - set_handler(SIGILL, (__sighandler_t) sig_handler); - set_handler(SIGBUS, (__sighandler_t) sig_handler); + set_handler(SIGSEGV); + set_handler(SIGTRAP); + set_handler(SIGFPE); + set_handler(SIGILL); + set_handler(SIGBUS); signal(SIGHUP, SIG_IGN); - set_handler(SIGIO, (__sighandler_t) sig_handler); + set_handler(SIGIO); signal(SIGWINCH, SIG_IGN); signal(SIGTERM, SIG_DFL); } diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index f248fb2ab58..c4a4e202663 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -111,7 +111,7 @@ void alarm_handler(int sig, struct sigcontext *sc) void timer_init(void) { - set_handler(SIGVTALRM, (__sighandler_t) alarm_handler); + set_handler(SIGVTALRM); } void set_sigstack(void *sig_stack, int size) @@ -124,7 +124,17 @@ void set_sigstack(void *sig_stack, int size) panic("enabling signal stack failed, errno = %d\n", errno); } -static void (*handlers[_NSIG])(int sig, struct sigcontext *sc); +static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = { + [SIGSEGV] = sig_handler, + [SIGBUS] = sig_handler, + [SIGILL] = sig_handler, + [SIGFPE] = sig_handler, + [SIGTRAP] = sig_handler, + + [SIGIO] = sig_handler, + [SIGWINCH] = sig_handler, + [SIGVTALRM] = alarm_handler +}; static void handle_signal(int sig, struct sigcontext *sc) { @@ -173,13 +183,12 @@ static void hard_handler(int sig, siginfo_t *info, void *p) handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext); } -void set_handler(int sig, void (*handler)(int)) +void set_handler(int sig) { struct sigaction action; int flags = SA_SIGINFO | SA_ONSTACK; sigset_t sig_mask; - handlers[sig] = (void (*)(int, struct sigcontext *)) handler; action.sa_sigaction = hard_handler; /* block irq ones */ diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 31743f1d119..f4e02ad72e1 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -659,7 +659,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf) { int n; - set_handler(SIGWINCH, (__sighandler_t) sig_handler); + set_handler(SIGWINCH); /* * Can't use UML_SETJMP or UML_LONGJMP here because they save -- cgit v1.2.3-70-g09d2 From dd768c56da44f6c06486da3b33b41e9c13e985c5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:04:49 +0100 Subject: um: take system.h out of shared/sysdep Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/system-um.h | 45 +++++++++++ arch/um/include/asm/system.h | 47 ------------ arch/um/sys-x86/asm/system.h | 133 +++++++++++++++++++++++++++++++++ arch/um/sys-x86/shared/sysdep/system.h | 132 -------------------------------- 4 files changed, 178 insertions(+), 179 deletions(-) create mode 100644 arch/um/include/asm/system-um.h delete mode 100644 arch/um/include/asm/system.h create mode 100644 arch/um/sys-x86/asm/system.h delete mode 100644 arch/um/sys-x86/shared/sysdep/system.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/system-um.h b/arch/um/include/asm/system-um.h new file mode 100644 index 00000000000..0eec2457928 --- /dev/null +++ b/arch/um/include/asm/system-um.h @@ -0,0 +1,45 @@ +#ifndef __UM_SYSTEM_GENERIC_H +#define __UM_SYSTEM_GENERIC_H + +extern int get_signals(void); +extern int set_signals(int enable); +extern void block_signals(void); +extern void unblock_signals(void); + +static inline unsigned long arch_local_save_flags(void) +{ + return get_signals(); +} + +static inline void arch_local_irq_restore(unsigned long flags) +{ + set_signals(flags); +} + +static inline void arch_local_irq_enable(void) +{ + unblock_signals(); +} + +static inline void arch_local_irq_disable(void) +{ + block_signals(); +} + +static inline unsigned long arch_local_irq_save(void) +{ + unsigned long flags; + flags = arch_local_save_flags(); + arch_local_irq_disable(); + return flags; +} + +static inline bool arch_irqs_disabled(void) +{ + return arch_local_save_flags() == 0; +} + +extern void *_switch_to(void *prev, void *next, void *last); +#define switch_to(prev, next, last) prev = _switch_to(prev, next, last) + +#endif diff --git a/arch/um/include/asm/system.h b/arch/um/include/asm/system.h deleted file mode 100644 index 68a90ecd145..00000000000 --- a/arch/um/include/asm/system.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __UM_SYSTEM_GENERIC_H -#define __UM_SYSTEM_GENERIC_H - -#include "sysdep/system.h" - -extern int get_signals(void); -extern int set_signals(int enable); -extern void block_signals(void); -extern void unblock_signals(void); - -static inline unsigned long arch_local_save_flags(void) -{ - return get_signals(); -} - -static inline void arch_local_irq_restore(unsigned long flags) -{ - set_signals(flags); -} - -static inline void arch_local_irq_enable(void) -{ - unblock_signals(); -} - -static inline void arch_local_irq_disable(void) -{ - block_signals(); -} - -static inline unsigned long arch_local_irq_save(void) -{ - unsigned long flags; - flags = arch_local_save_flags(); - arch_local_irq_disable(); - return flags; -} - -static inline bool arch_irqs_disabled(void) -{ - return arch_local_save_flags() == 0; -} - -extern void *_switch_to(void *prev, void *next, void *last); -#define switch_to(prev, next, last) prev = _switch_to(prev, next, last) - -#endif diff --git a/arch/um/sys-x86/asm/system.h b/arch/um/sys-x86/asm/system.h new file mode 100644 index 00000000000..a89113bc74f --- /dev/null +++ b/arch/um/sys-x86/asm/system.h @@ -0,0 +1,133 @@ +#ifndef _ASM_X86_SYSTEM_H_ +#define _ASM_X86_SYSTEM_H_ + +#include +#include +#include +#include +#include +#include + +#include +#include + +/* entries in ARCH_DLINFO: */ +#ifdef CONFIG_IA32_EMULATION +# define AT_VECTOR_SIZE_ARCH 2 +#else +# define AT_VECTOR_SIZE_ARCH 1 +#endif + +extern unsigned long arch_align_stack(unsigned long sp); + +void default_idle(void); + +/* + * Force strict CPU ordering. + * And yes, this is required on UP too when we're talking + * to devices. + */ +#ifdef CONFIG_X86_32 +/* + * Some non-Intel clones support out of order store. wmb() ceases to be a + * nop for these. + */ +#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) +#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) +#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) +#else +#define mb() asm volatile("mfence":::"memory") +#define rmb() asm volatile("lfence":::"memory") +#define wmb() asm volatile("sfence" ::: "memory") +#endif + +/** + * read_barrier_depends - Flush all pending reads that subsequents reads + * depend on. + * + * No data-dependent reads from memory-like regions are ever reordered + * over this barrier. All reads preceding this primitive are guaranteed + * to access memory (but not necessarily other CPUs' caches) before any + * reads following this primitive that depend on the data return by + * any of the preceding reads. This primitive is much lighter weight than + * rmb() on most CPUs, and is never heavier weight than is + * rmb(). + * + * These ordering constraints are respected by both the local CPU + * and the compiler. + * + * Ordering is not guaranteed by anything other than these primitives, + * not even by data dependencies. See the documentation for + * memory_barrier() for examples and URLs to more information. + * + * For example, the following code would force ordering (the initial + * value of "a" is zero, "b" is one, and "p" is "&a"): + * + * + * CPU 0 CPU 1 + * + * b = 2; + * memory_barrier(); + * p = &b; q = p; + * read_barrier_depends(); + * d = *q; + * + * + * because the read of "*q" depends on the read of "p" and these + * two reads are separated by a read_barrier_depends(). However, + * the following code, with the same initial values for "a" and "b": + * + * + * CPU 0 CPU 1 + * + * a = 2; + * memory_barrier(); + * b = 3; y = b; + * read_barrier_depends(); + * x = a; + * + * + * does not enforce ordering, since there is no data dependency between + * the read of "a" and the read of "b". Therefore, on some CPUs, such + * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() + * in cases like this where there are no data dependencies. + **/ + +#define read_barrier_depends() do { } while (0) + +#ifdef CONFIG_SMP +#define smp_mb() mb() +#ifdef CONFIG_X86_PPRO_FENCE +# define smp_rmb() rmb() +#else +# define smp_rmb() barrier() +#endif +#ifdef CONFIG_X86_OOSTORE +# define smp_wmb() wmb() +#else +# define smp_wmb() barrier() +#endif +#define smp_read_barrier_depends() read_barrier_depends() +#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) +#else +#define smp_mb() barrier() +#define smp_rmb() barrier() +#define smp_wmb() barrier() +#define smp_read_barrier_depends() do { } while (0) +#define set_mb(var, value) do { var = value; barrier(); } while (0) +#endif + +/* + * Stop RDTSC speculation. This is needed when you need to use RDTSC + * (or get_cycles or vread that possibly accesses the TSC) in a defined + * code region. + * + * (Could use an alternative three way for this if there was one.) + */ +static inline void rdtsc_barrier(void) +{ + alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC); + alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC); +} + +#endif diff --git a/arch/um/sys-x86/shared/sysdep/system.h b/arch/um/sys-x86/shared/sysdep/system.h deleted file mode 100644 index d1b93c43620..00000000000 --- a/arch/um/sys-x86/shared/sysdep/system.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef _ASM_X86_SYSTEM_H_ -#define _ASM_X86_SYSTEM_H_ - -#include -#include -#include -#include -#include - -#include -#include - -/* entries in ARCH_DLINFO: */ -#ifdef CONFIG_IA32_EMULATION -# define AT_VECTOR_SIZE_ARCH 2 -#else -# define AT_VECTOR_SIZE_ARCH 1 -#endif - -extern unsigned long arch_align_stack(unsigned long sp); - -void default_idle(void); - -/* - * Force strict CPU ordering. - * And yes, this is required on UP too when we're talking - * to devices. - */ -#ifdef CONFIG_X86_32 -/* - * Some non-Intel clones support out of order store. wmb() ceases to be a - * nop for these. - */ -#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) -#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) -#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) -#else -#define mb() asm volatile("mfence":::"memory") -#define rmb() asm volatile("lfence":::"memory") -#define wmb() asm volatile("sfence" ::: "memory") -#endif - -/** - * read_barrier_depends - Flush all pending reads that subsequents reads - * depend on. - * - * No data-dependent reads from memory-like regions are ever reordered - * over this barrier. All reads preceding this primitive are guaranteed - * to access memory (but not necessarily other CPUs' caches) before any - * reads following this primitive that depend on the data return by - * any of the preceding reads. This primitive is much lighter weight than - * rmb() on most CPUs, and is never heavier weight than is - * rmb(). - * - * These ordering constraints are respected by both the local CPU - * and the compiler. - * - * Ordering is not guaranteed by anything other than these primitives, - * not even by data dependencies. See the documentation for - * memory_barrier() for examples and URLs to more information. - * - * For example, the following code would force ordering (the initial - * value of "a" is zero, "b" is one, and "p" is "&a"): - * - * - * CPU 0 CPU 1 - * - * b = 2; - * memory_barrier(); - * p = &b; q = p; - * read_barrier_depends(); - * d = *q; - * - * - * because the read of "*q" depends on the read of "p" and these - * two reads are separated by a read_barrier_depends(). However, - * the following code, with the same initial values for "a" and "b": - * - * - * CPU 0 CPU 1 - * - * a = 2; - * memory_barrier(); - * b = 3; y = b; - * read_barrier_depends(); - * x = a; - * - * - * does not enforce ordering, since there is no data dependency between - * the read of "a" and the read of "b". Therefore, on some CPUs, such - * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() - * in cases like this where there are no data dependencies. - **/ - -#define read_barrier_depends() do { } while (0) - -#ifdef CONFIG_SMP -#define smp_mb() mb() -#ifdef CONFIG_X86_PPRO_FENCE -# define smp_rmb() rmb() -#else -# define smp_rmb() barrier() -#endif -#ifdef CONFIG_X86_OOSTORE -# define smp_wmb() wmb() -#else -# define smp_wmb() barrier() -#endif -#define smp_read_barrier_depends() read_barrier_depends() -#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) -#else -#define smp_mb() barrier() -#define smp_rmb() barrier() -#define smp_wmb() barrier() -#define smp_read_barrier_depends() do { } while (0) -#define set_mb(var, value) do { var = value; barrier(); } while (0) -#endif - -/* - * Stop RDTSC speculation. This is needed when you need to use RDTSC - * (or get_cycles or vread that possibly accesses the TSC) in a defined - * code region. - * - * (Could use an alternative three way for this if there was one.) - */ -static inline void rdtsc_barrier(void) -{ - alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC); - alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC); -} - -#endif -- cgit v1.2.3-70-g09d2 From 05c46db4d7d51af969e09f9f1adbff66ee2e84b4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:04:59 +0100 Subject: um: take userland definition of barrier() to user.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/process.h | 3 --- arch/um/include/shared/user.h | 3 +++ arch/um/os-Linux/signal.c | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/process.h b/arch/um/include/shared/process.h index bb873a51262..28215300fc6 100644 --- a/arch/um/include/shared/process.h +++ b/arch/um/include/shared/process.h @@ -8,9 +8,6 @@ #include -/* Copied from linux/compiler-gcc.h since we can't include it directly */ -#define barrier() __asm__ __volatile__("": : :"memory") - extern void sig_handler(int sig, struct sigcontext *sc); extern void alarm_handler(int sig, struct sigcontext *sc); diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h index 58c058165e0..4fa82c055aa 100644 --- a/arch/um/include/shared/user.h +++ b/arch/um/include/shared/user.h @@ -40,4 +40,7 @@ extern int in_aton(char *str); extern size_t strlcpy(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t); +/* Copied from linux/compiler-gcc.h since we can't include it directly */ +#define barrier() __asm__ __volatile__("": : :"memory") + #endif diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index c4a4e202663..08d30617699 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -16,9 +16,6 @@ #include "sysdep/barrier.h" #include "sysdep/sigcontext.h" -/* Copied from linux/compiler-gcc.h since we can't include it directly */ -#define barrier() __asm__ __volatile__("": : :"memory") - void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { [SIGTRAP] = relay_signal, [SIGFPE] = relay_signal, -- cgit v1.2.3-70-g09d2 From 248b74c79ebb9fb55e146797a808836d90418c4b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:05:09 +0100 Subject: um: start switching the references to host mcontext_t to its userland type Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/process.h | 5 ---- arch/um/os-Linux/internal.h | 1 + arch/um/os-Linux/signal.c | 35 ++++++++++++--------------- arch/um/os-Linux/time.c | 2 +- arch/um/sys-x86/shared/sysdep/sigcontext_32.h | 7 ++++++ arch/um/sys-x86/shared/sysdep/sigcontext_64.h | 7 ++++++ arch/um/sys-x86/stub_segv.c | 2 +- 7 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 arch/um/os-Linux/internal.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/process.h b/arch/um/include/shared/process.h index 28215300fc6..2ba310e1b65 100644 --- a/arch/um/include/shared/process.h +++ b/arch/um/include/shared/process.h @@ -6,9 +6,4 @@ #ifndef __PROCESS_H__ #define __PROCESS_H__ -#include - -extern void sig_handler(int sig, struct sigcontext *sc); -extern void alarm_handler(int sig, struct sigcontext *sc); - #endif diff --git a/arch/um/os-Linux/internal.h b/arch/um/os-Linux/internal.h new file mode 100644 index 00000000000..2c3c3ecd8c0 --- /dev/null +++ b/arch/um/os-Linux/internal.h @@ -0,0 +1 @@ +void alarm_handler(int, mcontext_t *); diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 08d30617699..07d9905e44e 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -26,7 +26,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { [SIGIO] = sigio_handler, [SIGVTALRM] = timer_handler }; -static void sig_handler_common(int sig, struct sigcontext *sc) +static void sig_handler_common(int sig, mcontext_t *mc) { struct uml_pt_regs r; int save_errno = errno; @@ -34,8 +34,8 @@ static void sig_handler_common(int sig, struct sigcontext *sc) r.is_user = 0; if (sig == SIGSEGV) { /* For segfaults, we want the data from the sigcontext. */ - copy_sc(&r, sc); - GET_FAULTINFO_FROM_SC(r.faultinfo, sc); + copy_sc(&r, (struct sigcontext *)mc); + GET_FAULTINFO_FROM_MC(r.faultinfo, mc); } /* enable signals if sig isn't IRQ signal */ @@ -62,7 +62,7 @@ static void sig_handler_common(int sig, struct sigcontext *sc) static int signals_enabled; static unsigned int signals_pending; -void sig_handler(int sig, struct sigcontext *sc) +void sig_handler(int sig, mcontext_t *mc) { int enabled; @@ -74,23 +74,23 @@ void sig_handler(int sig, struct sigcontext *sc) block_signals(); - sig_handler_common(sig, sc); + sig_handler_common(sig, mc); set_signals(enabled); } -static void real_alarm_handler(struct sigcontext *sc) +static void real_alarm_handler(mcontext_t *mc) { struct uml_pt_regs regs; - if (sc != NULL) - copy_sc(®s, sc); + if (mc != NULL) + copy_sc(®s, (struct sigcontext *)mc); regs.is_user = 0; unblock_signals(); timer_handler(SIGVTALRM, ®s); } -void alarm_handler(int sig, struct sigcontext *sc) +void alarm_handler(int sig, mcontext_t *mc) { int enabled; @@ -102,7 +102,7 @@ void alarm_handler(int sig, struct sigcontext *sc) block_signals(); - real_alarm_handler(sc); + real_alarm_handler(mc); set_signals(enabled); } @@ -121,7 +121,7 @@ void set_sigstack(void *sig_stack, int size) panic("enabling signal stack failed, errno = %d\n", errno); } -static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = { +static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = { [SIGSEGV] = sig_handler, [SIGBUS] = sig_handler, [SIGILL] = sig_handler, @@ -133,8 +133,11 @@ static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = { [SIGVTALRM] = alarm_handler }; -static void handle_signal(int sig, struct sigcontext *sc) + +static void hard_handler(int sig, siginfo_t *info, void *p) { + struct ucontext *uc = p; + mcontext_t *mc = &uc->uc_mcontext; unsigned long pending = 1UL << sig; do { @@ -160,7 +163,7 @@ static void handle_signal(int sig, struct sigcontext *sc) while ((sig = ffs(pending)) != 0){ sig--; pending &= ~(1 << sig); - (*handlers[sig])(sig, sc); + (*handlers[sig])(sig, mc); } /* @@ -174,12 +177,6 @@ static void handle_signal(int sig, struct sigcontext *sc) } while (pending); } -static void hard_handler(int sig, siginfo_t *info, void *p) -{ - struct ucontext *uc = p; - handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext); -} - void set_handler(int sig) { struct sigaction action; diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index 995ca304f1c..910499d76a6 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c @@ -10,7 +10,7 @@ #include #include "kern_util.h" #include "os.h" -#include "process.h" +#include "internal.h" int set_interval(void) { diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext_32.h b/arch/um/sys-x86/shared/sysdep/sigcontext_32.h index aebc2dd61f0..548c3cdb743 100644 --- a/arch/um/sys-x86/shared/sysdep/sigcontext_32.h +++ b/arch/um/sys-x86/shared/sysdep/sigcontext_32.h @@ -22,4 +22,11 @@ (fi).trap_no = SC_TRAPNO(sc); \ } +#define GET_FAULTINFO_FROM_MC(fi, mc) \ + { \ + (fi).cr2 = (mc)->cr2; \ + (fi).error_code = (mc)->gregs[REG_ERR]; \ + (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \ + } + #endif diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext_64.h b/arch/um/sys-x86/shared/sysdep/sigcontext_64.h index 60d89a2fba0..5c4a6a35914 100644 --- a/arch/um/sys-x86/shared/sysdep/sigcontext_64.h +++ b/arch/um/sys-x86/shared/sysdep/sigcontext_64.h @@ -22,4 +22,11 @@ (fi).trap_no = SC_TRAPNO(sc); \ } +#define GET_FAULTINFO_FROM_MC(fi, mc) \ + { \ + (fi).cr2 = (mc)->gregs[REG_CR2]; \ + (fi).error_code = (mc)->gregs[REG_ERR]; \ + (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \ + } + #endif diff --git a/arch/um/sys-x86/stub_segv.c b/arch/um/sys-x86/stub_segv.c index f62771cf236..bd2eaf69103 100644 --- a/arch/um/sys-x86/stub_segv.c +++ b/arch/um/sys-x86/stub_segv.c @@ -12,7 +12,7 @@ stub_segv_handler(int sig, siginfo_t *info, void *p) { struct ucontext *uc = p; - GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), + GET_FAULTINFO_FROM_MC(*((struct faultinfo *) STUB_DATA), &uc->uc_mcontext); trap_myself(); } -- cgit v1.2.3-70-g09d2 From 0de021f797e7bd785796071aab8e14827c87d6bf Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:05:29 +0100 Subject: um: shared/process.h is empty now; kill it Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/process.h | 9 --------- arch/um/os-Linux/irq.c | 1 - arch/um/os-Linux/process.c | 1 - arch/um/os-Linux/sigio.c | 1 - arch/um/os-Linux/signal.c | 1 - arch/um/os-Linux/skas/process.c | 1 - 6 files changed, 14 deletions(-) delete mode 100644 arch/um/include/shared/process.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/process.h b/arch/um/include/shared/process.h deleted file mode 100644 index 2ba310e1b65..00000000000 --- a/arch/um/include/shared/process.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (C) 2000 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#ifndef __PROCESS_H__ -#define __PROCESS_H__ - -#endif diff --git a/arch/um/os-Linux/irq.c b/arch/um/os-Linux/irq.c index 59c592cca25..9a49908b576 100644 --- a/arch/um/os-Linux/irq.c +++ b/arch/um/os-Linux/irq.c @@ -10,7 +10,6 @@ #include #include "irq_user.h" #include "os.h" -#include "process.h" #include "um_malloc.h" /* diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index e08fe305beb..307f173e7f8 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -15,7 +15,6 @@ #include "init.h" #include "longjmp.h" #include "os.h" -#include "process.h" #include "skas_ptrace.h" #define ARBITRARY_ADDR -1 diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index 34bb59bfa00..3c161218c67 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c @@ -14,7 +14,6 @@ #include "kern_util.h" #include "init.h" #include "os.h" -#include "process.h" #include "sigio.h" #include "um_malloc.h" diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 9f2c2228f7a..4d31688b22b 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -12,7 +12,6 @@ #include "as-layout.h" #include "kern_util.h" #include "os.h" -#include "process.h" #include "sysdep/barrier.h" #include "sysdep/mcontext.h" diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index f4e02ad72e1..30f1bb43a23 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -17,7 +17,6 @@ #include "kern_util.h" #include "mem.h" #include "os.h" -#include "process.h" #include "proc_mm.h" #include "ptrace_user.h" #include "registers.h" -- cgit v1.2.3-70-g09d2 From 9aecaa6a8a43965821fbc4373240ae338f7eaf14 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:06:09 +0100 Subject: um: arch_hweight.h is needed only on uml-x86 Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/arch_hweight.h | 6 ------ arch/um/sys-x86/asm/arch_hweight.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 arch/um/include/asm/arch_hweight.h create mode 100644 arch/um/sys-x86/asm/arch_hweight.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/arch_hweight.h b/arch/um/include/asm/arch_hweight.h deleted file mode 100644 index c656cf443f4..00000000000 --- a/arch/um/include/asm/arch_hweight.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASM_UM_HWEIGHT_H -#define _ASM_UM_HWEIGHT_H - -#include - -#endif diff --git a/arch/um/sys-x86/asm/arch_hweight.h b/arch/um/sys-x86/asm/arch_hweight.h new file mode 100644 index 00000000000..c656cf443f4 --- /dev/null +++ b/arch/um/sys-x86/asm/arch_hweight.h @@ -0,0 +1,6 @@ +#ifndef _ASM_UM_HWEIGHT_H +#define _ASM_UM_HWEIGHT_H + +#include + +#endif -- cgit v1.2.3-70-g09d2 From 0acdbbeb6dd435f5f3f1648fc3a2ab5fd07b5545 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:06:49 +0100 Subject: um: bury unused macros around ptrace.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/ptrace-generic.h | 4 ---- arch/x86/um/shared/sysdep/ptrace_32.h | 3 --- arch/x86/um/shared/sysdep/ptrace_64.h | 3 --- 3 files changed, 10 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index c3b8a041c13..f605d3c4844 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -23,14 +23,10 @@ struct pt_regs { #define PT_REGS_IP(r) UPT_IP(&(r)->regs) #define PT_REGS_SP(r) UPT_SP(&(r)->regs) -#define PT_REGS_SET_SYSCALL_RETURN(r, res) \ - UPT_SET_SYSCALL_RETURN(&(r)->regs, res) #define PT_REGS_RESTART_SYSCALL(r) UPT_RESTART_SYSCALL(&(r)->regs) #define PT_REGS_SYSCALL_NR(r) UPT_SYSCALL_NR(&(r)->regs) -#define PT_REGS_SC(r) UPT_SC(&(r)->regs) - #define instruction_pointer(regs) PT_REGS_IP(regs) struct task_struct; diff --git a/arch/x86/um/shared/sysdep/ptrace_32.h b/arch/x86/um/shared/sysdep/ptrace_32.h index ce77fa1e2a1..bad747a239c 100644 --- a/arch/x86/um/shared/sysdep/ptrace_32.h +++ b/arch/x86/um/shared/sysdep/ptrace_32.h @@ -101,9 +101,6 @@ struct syscall_args { UPT_SYSCALL_ARG5(r), \ UPT_SYSCALL_ARG6(r) } } ) -#define UPT_SET_SYSCALL_RETURN(r, res) \ - REGS_SET_SYSCALL_RETURN((r)->regs, (res)) - #define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp) #define UPT_ORIG_SYSCALL(r) UPT_EAX(r) diff --git a/arch/x86/um/shared/sysdep/ptrace_64.h b/arch/x86/um/shared/sysdep/ptrace_64.h index 866fe7e4736..a360fe25431 100644 --- a/arch/x86/um/shared/sysdep/ptrace_64.h +++ b/arch/x86/um/shared/sysdep/ptrace_64.h @@ -146,9 +146,6 @@ struct syscall_args { UPT_SYSCALL_ARG5(r), \ UPT_SYSCALL_ARG6(r) } } ) -#define UPT_SET_SYSCALL_RETURN(r, res) \ - REGS_SET_SYSCALL_RETURN((r)->regs, (res)) - #define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp) #define UPT_FAULTINFO(r) (&(r)->faultinfo) -- cgit v1.2.3-70-g09d2 From 549e78db9438374cb6a58201cc5f2194b222688f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:06:59 +0100 Subject: um: make load_initrd() static, kill shared/initrd.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/initrd.h | 12 ------------ arch/um/kernel/initrd.c | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 arch/um/include/shared/initrd.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/initrd.h b/arch/um/include/shared/initrd.h deleted file mode 100644 index 22673bcc273..00000000000 --- a/arch/um/include/shared/initrd.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __INITRD_USER_H__ -#define __INITRD_USER_H__ - -extern int load_initrd(char *filename, void *buf, int size); - -#endif - diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c index d386c75c88e..10cc18f729f 100644 --- a/arch/um/kernel/initrd.c +++ b/arch/um/kernel/initrd.c @@ -7,12 +7,12 @@ #include "linux/bootmem.h" #include "linux/initrd.h" #include "asm/types.h" -#include "initrd.h" #include "init.h" #include "os.h" /* Changed by uml_initrd_setup, which is a setup */ static char *initrd __initdata = NULL; +static int load_initrd(char *filename, void *buf, int size); static int __init read_initrd(void) { @@ -62,7 +62,7 @@ __uml_setup("initrd=", uml_initrd_setup, " name of the file containing the image.\n\n" ); -int load_initrd(char *filename, void *buf, int size) +static int load_initrd(char *filename, void *buf, int size) { int fd, n; -- cgit v1.2.3-70-g09d2 From 429172ccf058e67974dd1ab3d8b82075383efe84 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:07:09 +0100 Subject: um: trim kern.h most of the functions in there are not used in anything that ends up including that header... Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/kern.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/kern.h b/arch/um/include/shared/kern.h index 4ce3fc650e5..6cd01240bbf 100644 --- a/arch/um/include/shared/kern.h +++ b/arch/um/include/shared/kern.h @@ -13,28 +13,10 @@ * includes. */ -extern int errno; - -extern int clone(int (*proc)(void *), void *sp, int flags, void *data); -extern int sleep(int); extern int printf(const char *fmt, ...); -extern char *strerror(int errnum); -extern char *ptsname(int __fd); -extern int munmap(void *, int); extern void *sbrk(int increment); -extern void *malloc(int size); -extern void perror(char *err); -extern int kill(int pid, int sig); -extern int getuid(void); -extern int getgid(void); extern int pause(void); -extern int write(int, const void *, int); extern void exit(int); -extern int close(int); -extern int read(unsigned int, char *, int); -extern int pipe(int *); -extern int sched_yield(void); -extern int ptrace(int op, int pid, long addr, long data); #endif -- cgit v1.2.3-70-g09d2 From 1cf5e62ab939022b43634d6608afd10a809b02b9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:07:29 +0100 Subject: um: shared/syscall.h is not even included ... and functions declared in it do not exist Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/syscall.h | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 arch/um/include/shared/syscall.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/syscall.h b/arch/um/include/shared/syscall.h deleted file mode 100644 index dda1df901a0..00000000000 --- a/arch/um/include/shared/syscall.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __SYSCALL_USER_H -#define __SYSCALL_USER_H - -extern int record_syscall_start(int syscall); -extern void record_syscall_end(int index, long result); - -#endif -- cgit v1.2.3-70-g09d2 From 5ade8878e03a9a298a71efbf2895aa482e45448a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:07:39 +0100 Subject: um: kill shared/task.h and HOST_TASK_REGS Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/common-offsets.h | 1 - arch/um/include/shared/task.h | 9 --------- arch/x86/um/bugs_32.c | 4 +++- 3 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 arch/um/include/shared/task.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/common-offsets.h b/arch/um/include/shared/common-offsets.h index 72009c7e321..d7fe563aa7e 100644 --- a/arch/um/include/shared/common-offsets.h +++ b/arch/um/include/shared/common-offsets.h @@ -2,7 +2,6 @@ DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE); -OFFSET(HOST_TASK_REGS, task_struct, thread.regs); OFFSET(HOST_TASK_PID, task_struct, pid); DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); diff --git a/arch/um/include/shared/task.h b/arch/um/include/shared/task.h deleted file mode 100644 index 3db6b58b505..00000000000 --- a/arch/um/include/shared/task.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __TASK_H -#define __TASK_H - -#include - -#define TASK_REGS(task) ((struct uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) -#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) - -#endif diff --git a/arch/x86/um/bugs_32.c b/arch/x86/um/bugs_32.c index 7058e1fa903..a1fba5fb9db 100644 --- a/arch/x86/um/bugs_32.c +++ b/arch/x86/um/bugs_32.c @@ -6,13 +6,15 @@ #include #include "kern_util.h" #include "longjmp.h" -#include "task.h" #include "sysdep/ptrace.h" +#include /* Set during early boot */ static int host_has_cmov = 1; static jmp_buf cmov_test_return; +#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) + static void cmov_sigill_test_handler(int sig) { host_has_cmov = 0; -- cgit v1.2.3-70-g09d2 From c75d053b701cc098d44b729c8266a2df5ca5206e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:07:49 +0100 Subject: um: make flush_tlb_kernel_range_common() static Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/tlb.h | 2 -- arch/um/kernel/tlb.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/tlb.h b/arch/um/include/shared/tlb.h index ecd2265b301..8a50ce11707 100644 --- a/arch/um/include/shared/tlb.h +++ b/arch/um/include/shared/tlb.h @@ -9,7 +9,5 @@ #include "um_mmu.h" extern void force_flush_all(void); -extern int flush_tlb_kernel_range_common(unsigned long start, - unsigned long end); #endif diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index d175d0566af..d1da8acd918 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c @@ -287,7 +287,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr, } } -int flush_tlb_kernel_range_common(unsigned long start, unsigned long end) +static int flush_tlb_kernel_range_common(unsigned long start, unsigned long end) { struct mm_struct *mm; pgd_t *pgd; -- cgit v1.2.3-70-g09d2 From 445c5786c9ce02b6816bb11fd3394a134fa6d244 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:07:59 +0100 Subject: um: kill shared/tlb.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/tlb.h | 13 ------------- arch/um/kernel/process.c | 2 +- arch/um/kernel/tlb.c | 1 - 3 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 arch/um/include/shared/tlb.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/tlb.h b/arch/um/include/shared/tlb.h deleted file mode 100644 index 8a50ce11707..00000000000 --- a/arch/um/include/shared/tlb.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __TLB_H__ -#define __TLB_H__ - -#include "um_mmu.h" - -extern void force_flush_all(void); - -#endif diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 21c1ae7c3d7..db44142d126 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -20,12 +20,12 @@ #include #include #include +#include #include #include "as-layout.h" #include "kern_util.h" #include "os.h" #include "skas.h" -#include "tlb.h" /* * This is a per-cpu array. A processor only modifies its entry and it only diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index d1da8acd918..11cadb225f0 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c @@ -11,7 +11,6 @@ #include "mem_user.h" #include "os.h" #include "skas.h" -#include "tlb.h" struct host_vm_change { struct host_vm_op { -- cgit v1.2.3-70-g09d2 From 0a9e70b1cd0f7ee82a65d19edfcd31664ef65f69 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:08:09 +0100 Subject: um: kill shared/mem_kern.h ... nothing declared there exists Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/ubd_kern.c | 1 - arch/um/include/shared/mem_kern.h | 20 -------------------- 2 files changed, 21 deletions(-) delete mode 100644 arch/um/include/shared/mem_kern.h (limited to 'arch/um/include') diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 0136be194e1..b3c854523e6 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -53,7 +53,6 @@ #include "ubd_user.h" #include "os.h" #include "mem.h" -#include "mem_kern.h" #include "cow.h" enum ubd_req { UBD_READ, UBD_WRITE }; diff --git a/arch/um/include/shared/mem_kern.h b/arch/um/include/shared/mem_kern.h deleted file mode 100644 index 69be0fd0ce4..00000000000 --- a/arch/um/include/shared/mem_kern.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2003 Jeff Dike (jdike@addtoit.com) - * Licensed under the GPL - */ - -#ifndef __MEM_KERN_H__ -#define __MEM_KERN_H__ - -#include "linux/list.h" -#include "linux/types.h" - -struct remapper { - struct list_head list; - int (*proc)(int, unsigned long, int, __u64); -}; - -extern void register_remapper(struct remapper *info); - -#endif - -- cgit v1.2.3-70-g09d2 From 510c72a3cf51c9463db64eb6c21347f4940a202f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:08:29 +0100 Subject: um: take chan_*.h and line.h to arch/um/drivers Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/chan.h | 50 +++++++++++++++++ arch/um/drivers/chan_kern.c | 2 +- arch/um/drivers/chan_user.h | 55 +++++++++++++++++++ arch/um/drivers/line.c | 2 +- arch/um/drivers/line.h | 106 +++++++++++++++++++++++++++++++++++++ arch/um/drivers/ssl.c | 3 +- arch/um/drivers/stdio_console.c | 3 +- arch/um/include/shared/chan_kern.h | 50 ----------------- arch/um/include/shared/chan_user.h | 55 ------------------- arch/um/include/shared/line.h | 106 ------------------------------------- arch/um/os-Linux/skas/process.c | 2 +- 11 files changed, 216 insertions(+), 218 deletions(-) create mode 100644 arch/um/drivers/chan.h create mode 100644 arch/um/drivers/chan_user.h create mode 100644 arch/um/drivers/line.h delete mode 100644 arch/um/include/shared/chan_kern.h delete mode 100644 arch/um/include/shared/chan_user.h delete mode 100644 arch/um/include/shared/line.h (limited to 'arch/um/include') diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h new file mode 100644 index 00000000000..8df0fd9024d --- /dev/null +++ b/arch/um/drivers/chan.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __CHAN_KERN_H__ +#define __CHAN_KERN_H__ + +#include +#include +#include +#include "chan_user.h" +#include "line.h" + +struct chan { + struct list_head list; + struct list_head free_list; + struct line *line; + char *dev; + unsigned int primary:1; + unsigned int input:1; + unsigned int output:1; + unsigned int opened:1; + unsigned int enabled:1; + int fd; + const struct chan_ops *ops; + void *data; +}; + +extern void chan_interrupt(struct list_head *chans, struct delayed_work *task, + struct tty_struct *tty, int irq); +extern int parse_chan_pair(char *str, struct line *line, int device, + const struct chan_opts *opts, char **error_out); +extern int write_chan(struct list_head *chans, const char *buf, int len, + int write_irq); +extern int console_write_chan(struct list_head *chans, const char *buf, + int len); +extern int console_open_chan(struct line *line, struct console *co); +extern void deactivate_chan(struct list_head *chans, int irq); +extern void reactivate_chan(struct list_head *chans, int irq); +extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); +extern int enable_chan(struct line *line); +extern void close_chan(struct list_head *chans, int delay_free_irq); +extern int chan_window_size(struct list_head *chans, + unsigned short *rows_out, + unsigned short *cols_out); +extern int chan_config_string(struct list_head *chans, char *str, int size, + char **error_out); + +#endif diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index d4191fe1ced..e0406832df8 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -6,7 +6,7 @@ #include #include #include -#include "chan_kern.h" +#include "chan.h" #include "os.h" #ifdef CONFIG_NOCONFIG_CHAN diff --git a/arch/um/drivers/chan_user.h b/arch/um/drivers/chan_user.h new file mode 100644 index 00000000000..9b9ced85b70 --- /dev/null +++ b/arch/um/drivers/chan_user.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __CHAN_USER_H__ +#define __CHAN_USER_H__ + +#include "init.h" + +struct chan_opts { + void (*const announce)(char *dev_name, int dev); + char *xterm_title; + const int raw; +}; + +enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE }; + +struct chan_ops { + char *type; + void *(*init)(char *, int, const struct chan_opts *); + int (*open)(int, int, int, void *, char **); + void (*close)(int, void *); + int (*read)(int, char *, void *); + int (*write)(int, const char *, int, void *); + int (*console_write)(int, const char *, int); + int (*window_size)(int, void *, unsigned short *, unsigned short *); + void (*free)(void *); + int winch; +}; + +extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, + tty_ops, xterm_ops; + +extern void generic_close(int fd, void *unused); +extern int generic_read(int fd, char *c_out, void *unused); +extern int generic_write(int fd, const char *buf, int n, void *unused); +extern int generic_console_write(int fd, const char *buf, int n); +extern int generic_window_size(int fd, void *unused, unsigned short *rows_out, + unsigned short *cols_out); +extern void generic_free(void *data); + +struct tty_struct; +extern void register_winch(int fd, struct tty_struct *tty); +extern void register_winch_irq(int fd, int tty_fd, int pid, + struct tty_struct *tty, unsigned long stack); + +#define __channel_help(fn, prefix) \ +__uml_help(fn, prefix "[0-9]*=\n" \ +" Attach a console or serial line to a host channel. See\n" \ +" http://user-mode-linux.sourceforge.net/old/input.html for a complete\n" \ +" description of this switch.\n\n" \ +); + +#endif diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 364c8a15c4c..c1cf2206b84 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -7,7 +7,7 @@ #include "linux/kd.h" #include "linux/sched.h" #include "linux/slab.h" -#include "chan_kern.h" +#include "chan.h" #include "irq_kern.h" #include "irq_user.h" #include "kern_util.h" diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h new file mode 100644 index 00000000000..63df3ca02ac --- /dev/null +++ b/arch/um/drivers/line.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __LINE_H__ +#define __LINE_H__ + +#include "linux/list.h" +#include "linux/workqueue.h" +#include "linux/tty.h" +#include "linux/interrupt.h" +#include "linux/spinlock.h" +#include "linux/mutex.h" +#include "chan_user.h" +#include "mconsole_kern.h" + +/* There's only one modifiable field in this - .mc.list */ +struct line_driver { + const char *name; + const char *device_name; + const short major; + const short minor_start; + const short type; + const short subtype; + const int read_irq; + const char *read_irq_name; + const int write_irq; + const char *write_irq_name; + struct mc_device mc; +}; + +struct line { + struct tty_struct *tty; + spinlock_t count_lock; + unsigned long count; + int valid; + + char *init_str; + int init_pri; + struct list_head chan_list; + + /*This lock is actually, mostly, local to*/ + spinlock_t lock; + int throttled; + /* Yes, this is a real circular buffer. + * XXX: And this should become a struct kfifo! + * + * buffer points to a buffer allocated on demand, of length + * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ + char *buffer; + char *head; + char *tail; + + int sigio; + struct delayed_work task; + const struct line_driver *driver; + int have_irq; +}; + +#define LINE_INIT(str, d) \ + { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \ + .init_str = str, \ + .init_pri = INIT_STATIC, \ + .valid = 1, \ + .lock = __SPIN_LOCK_UNLOCKED((str).lock), \ + .driver = d } + +extern void line_close(struct tty_struct *tty, struct file * filp); +extern int line_open(struct line *lines, struct tty_struct *tty); +extern int line_setup(struct line *lines, unsigned int sizeof_lines, + char *init, char **error_out); +extern int line_write(struct tty_struct *tty, const unsigned char *buf, + int len); +extern int line_put_char(struct tty_struct *tty, unsigned char ch); +extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); +extern int line_chars_in_buffer(struct tty_struct *tty); +extern void line_flush_buffer(struct tty_struct *tty); +extern void line_flush_chars(struct tty_struct *tty); +extern int line_write_room(struct tty_struct *tty); +extern int line_ioctl(struct tty_struct *tty, unsigned int cmd, + unsigned long arg); +extern void line_throttle(struct tty_struct *tty); +extern void line_unthrottle(struct tty_struct *tty); + +extern char *add_xterm_umid(char *base); +extern int line_setup_irq(int fd, int input, int output, struct line *line, + void *data); +extern void line_close_chan(struct line *line); +extern struct tty_driver *register_lines(struct line_driver *line_driver, + const struct tty_operations *driver, + struct line *lines, int nlines); +extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); +extern void close_lines(struct line *lines, int nlines); + +extern int line_config(struct line *lines, unsigned int sizeof_lines, + char *str, const struct chan_opts *opts, + char **error_out); +extern int line_id(char **str, int *start_out, int *end_out); +extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, + char **error_out); +extern int line_get_config(char *dev, struct line *lines, + unsigned int sizeof_lines, char *str, + int size, char **error_out); + +#endif diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 678e205adf2..9d8c20af6f8 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -12,9 +12,8 @@ #include "linux/console.h" #include "asm/termbits.h" #include "asm/irq.h" -#include "line.h" #include "ssl.h" -#include "chan_kern.h" +#include "chan.h" #include "init.h" #include "irq_user.h" #include "mconsole_kern.h" diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 49266f6108c..088776f0190 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -20,8 +20,7 @@ #include "asm/current.h" #include "asm/irq.h" #include "stdio_console.h" -#include "line.h" -#include "chan_kern.h" +#include "chan.h" #include "irq_user.h" #include "mconsole_kern.h" #include "init.h" diff --git a/arch/um/include/shared/chan_kern.h b/arch/um/include/shared/chan_kern.h deleted file mode 100644 index 1e651457e04..00000000000 --- a/arch/um/include/shared/chan_kern.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __CHAN_KERN_H__ -#define __CHAN_KERN_H__ - -#include "linux/tty.h" -#include "linux/list.h" -#include "linux/console.h" -#include "chan_user.h" -#include "line.h" - -struct chan { - struct list_head list; - struct list_head free_list; - struct line *line; - char *dev; - unsigned int primary:1; - unsigned int input:1; - unsigned int output:1; - unsigned int opened:1; - unsigned int enabled:1; - int fd; - const struct chan_ops *ops; - void *data; -}; - -extern void chan_interrupt(struct list_head *chans, struct delayed_work *task, - struct tty_struct *tty, int irq); -extern int parse_chan_pair(char *str, struct line *line, int device, - const struct chan_opts *opts, char **error_out); -extern int write_chan(struct list_head *chans, const char *buf, int len, - int write_irq); -extern int console_write_chan(struct list_head *chans, const char *buf, - int len); -extern int console_open_chan(struct line *line, struct console *co); -extern void deactivate_chan(struct list_head *chans, int irq); -extern void reactivate_chan(struct list_head *chans, int irq); -extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); -extern int enable_chan(struct line *line); -extern void close_chan(struct list_head *chans, int delay_free_irq); -extern int chan_window_size(struct list_head *chans, - unsigned short *rows_out, - unsigned short *cols_out); -extern int chan_config_string(struct list_head *chans, char *str, int size, - char **error_out); - -#endif diff --git a/arch/um/include/shared/chan_user.h b/arch/um/include/shared/chan_user.h deleted file mode 100644 index 9b9ced85b70..00000000000 --- a/arch/um/include/shared/chan_user.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __CHAN_USER_H__ -#define __CHAN_USER_H__ - -#include "init.h" - -struct chan_opts { - void (*const announce)(char *dev_name, int dev); - char *xterm_title; - const int raw; -}; - -enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE }; - -struct chan_ops { - char *type; - void *(*init)(char *, int, const struct chan_opts *); - int (*open)(int, int, int, void *, char **); - void (*close)(int, void *); - int (*read)(int, char *, void *); - int (*write)(int, const char *, int, void *); - int (*console_write)(int, const char *, int); - int (*window_size)(int, void *, unsigned short *, unsigned short *); - void (*free)(void *); - int winch; -}; - -extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, - tty_ops, xterm_ops; - -extern void generic_close(int fd, void *unused); -extern int generic_read(int fd, char *c_out, void *unused); -extern int generic_write(int fd, const char *buf, int n, void *unused); -extern int generic_console_write(int fd, const char *buf, int n); -extern int generic_window_size(int fd, void *unused, unsigned short *rows_out, - unsigned short *cols_out); -extern void generic_free(void *data); - -struct tty_struct; -extern void register_winch(int fd, struct tty_struct *tty); -extern void register_winch_irq(int fd, int tty_fd, int pid, - struct tty_struct *tty, unsigned long stack); - -#define __channel_help(fn, prefix) \ -__uml_help(fn, prefix "[0-9]*=\n" \ -" Attach a console or serial line to a host channel. See\n" \ -" http://user-mode-linux.sourceforge.net/old/input.html for a complete\n" \ -" description of this switch.\n\n" \ -); - -#endif diff --git a/arch/um/include/shared/line.h b/arch/um/include/shared/line.h deleted file mode 100644 index 63df3ca02ac..00000000000 --- a/arch/um/include/shared/line.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __LINE_H__ -#define __LINE_H__ - -#include "linux/list.h" -#include "linux/workqueue.h" -#include "linux/tty.h" -#include "linux/interrupt.h" -#include "linux/spinlock.h" -#include "linux/mutex.h" -#include "chan_user.h" -#include "mconsole_kern.h" - -/* There's only one modifiable field in this - .mc.list */ -struct line_driver { - const char *name; - const char *device_name; - const short major; - const short minor_start; - const short type; - const short subtype; - const int read_irq; - const char *read_irq_name; - const int write_irq; - const char *write_irq_name; - struct mc_device mc; -}; - -struct line { - struct tty_struct *tty; - spinlock_t count_lock; - unsigned long count; - int valid; - - char *init_str; - int init_pri; - struct list_head chan_list; - - /*This lock is actually, mostly, local to*/ - spinlock_t lock; - int throttled; - /* Yes, this is a real circular buffer. - * XXX: And this should become a struct kfifo! - * - * buffer points to a buffer allocated on demand, of length - * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ - char *buffer; - char *head; - char *tail; - - int sigio; - struct delayed_work task; - const struct line_driver *driver; - int have_irq; -}; - -#define LINE_INIT(str, d) \ - { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \ - .init_str = str, \ - .init_pri = INIT_STATIC, \ - .valid = 1, \ - .lock = __SPIN_LOCK_UNLOCKED((str).lock), \ - .driver = d } - -extern void line_close(struct tty_struct *tty, struct file * filp); -extern int line_open(struct line *lines, struct tty_struct *tty); -extern int line_setup(struct line *lines, unsigned int sizeof_lines, - char *init, char **error_out); -extern int line_write(struct tty_struct *tty, const unsigned char *buf, - int len); -extern int line_put_char(struct tty_struct *tty, unsigned char ch); -extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); -extern int line_chars_in_buffer(struct tty_struct *tty); -extern void line_flush_buffer(struct tty_struct *tty); -extern void line_flush_chars(struct tty_struct *tty); -extern int line_write_room(struct tty_struct *tty); -extern int line_ioctl(struct tty_struct *tty, unsigned int cmd, - unsigned long arg); -extern void line_throttle(struct tty_struct *tty); -extern void line_unthrottle(struct tty_struct *tty); - -extern char *add_xterm_umid(char *base); -extern int line_setup_irq(int fd, int input, int output, struct line *line, - void *data); -extern void line_close_chan(struct line *line); -extern struct tty_driver *register_lines(struct line_driver *line_driver, - const struct tty_operations *driver, - struct line *lines, int nlines); -extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); -extern void close_lines(struct line *lines, int nlines); - -extern int line_config(struct line *lines, unsigned int sizeof_lines, - char *str, const struct chan_opts *opts, - char **error_out); -extern int line_id(char **str, int *start_out, int *end_out); -extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, - char **error_out); -extern int line_get_config(char *dev, struct line *lines, - unsigned int sizeof_lines, char *str, - int size, char **error_out); - -#endif diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 29e4ab7eb36..6c34f14708a 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -13,7 +13,7 @@ #include #include #include "as-layout.h" -#include "chan_user.h" +#include "init.h" #include "kern_util.h" #include "mem.h" #include "os.h" -- cgit v1.2.3-70-g09d2 From ece67c8697f32699f6977d3d1ae2ae9f7892a913 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:08:39 +0100 Subject: um: take mconsole*.h to arch/um/drivers Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/mconsole.h | 98 ++++++++++++++++++++++++++++++++++ arch/um/drivers/mconsole_kern.h | 52 ++++++++++++++++++ arch/um/include/shared/mconsole.h | 98 ---------------------------------- arch/um/include/shared/mconsole_kern.h | 52 ------------------ 4 files changed, 150 insertions(+), 150 deletions(-) create mode 100644 arch/um/drivers/mconsole.h create mode 100644 arch/um/drivers/mconsole_kern.h delete mode 100644 arch/um/include/shared/mconsole.h delete mode 100644 arch/um/include/shared/mconsole_kern.h (limited to 'arch/um/include') diff --git a/arch/um/drivers/mconsole.h b/arch/um/drivers/mconsole.h new file mode 100644 index 00000000000..c139ae1d682 --- /dev/null +++ b/arch/um/drivers/mconsole.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __MCONSOLE_H__ +#define __MCONSOLE_H__ + +#ifndef __KERNEL__ +#include +#define u32 uint32_t +#endif + +#include "sysdep/ptrace.h" + +#define MCONSOLE_MAGIC (0xcafebabe) +#define MCONSOLE_MAX_DATA (512) +#define MCONSOLE_VERSION 2 + +struct mconsole_request { + u32 magic; + u32 version; + u32 len; + char data[MCONSOLE_MAX_DATA]; +}; + +struct mconsole_reply { + u32 err; + u32 more; + u32 len; + char data[MCONSOLE_MAX_DATA]; +}; + +struct mconsole_notify { + u32 magic; + u32 version; + enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, + MCONSOLE_USER_NOTIFY } type; + u32 len; + char data[MCONSOLE_MAX_DATA]; +}; + +struct mc_request; + +enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC }; + +struct mconsole_command +{ + char *command; + void (*handler)(struct mc_request *req); + enum mc_context context; +}; + +struct mc_request +{ + int len; + int as_interrupt; + + int originating_fd; + unsigned int originlen; + unsigned char origin[128]; /* sockaddr_un */ + + struct mconsole_request request; + struct mconsole_command *cmd; + struct uml_pt_regs regs; +}; + +extern char mconsole_socket_name[]; + +extern int mconsole_unlink_socket(void); +extern int mconsole_reply_len(struct mc_request *req, const char *reply, + int len, int err, int more); +extern int mconsole_reply(struct mc_request *req, const char *str, int err, + int more); + +extern void mconsole_version(struct mc_request *req); +extern void mconsole_help(struct mc_request *req); +extern void mconsole_halt(struct mc_request *req); +extern void mconsole_reboot(struct mc_request *req); +extern void mconsole_config(struct mc_request *req); +extern void mconsole_remove(struct mc_request *req); +extern void mconsole_sysrq(struct mc_request *req); +extern void mconsole_cad(struct mc_request *req); +extern void mconsole_stop(struct mc_request *req); +extern void mconsole_go(struct mc_request *req); +extern void mconsole_log(struct mc_request *req); +extern void mconsole_proc(struct mc_request *req); +extern void mconsole_stack(struct mc_request *req); + +extern int mconsole_get_request(int fd, struct mc_request *req); +extern int mconsole_notify(char *sock_name, int type, const void *data, + int len); +extern char *mconsole_notify_socket(void); +extern void lock_notify(void); +extern void unlock_notify(void); + +#endif diff --git a/arch/um/drivers/mconsole_kern.h b/arch/um/drivers/mconsole_kern.h new file mode 100644 index 00000000000..d2fe07e7895 --- /dev/null +++ b/arch/um/drivers/mconsole_kern.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __MCONSOLE_KERN_H__ +#define __MCONSOLE_KERN_H__ + +#include "linux/list.h" +#include "mconsole.h" + +struct mconsole_entry { + struct list_head list; + struct mc_request request; +}; + +/* All these methods are called in process context. */ +struct mc_device { + struct list_head list; + char *name; + int (*config)(char *, char **); + int (*get_config)(char *, char *, int, char **); + int (*id)(char **, int *, int *); + int (*remove)(int, char **); +}; + +#define CONFIG_CHUNK(str, size, current, chunk, end) \ +do { \ + current += strlen(chunk); \ + if(current >= size) \ + str = NULL; \ + if(str != NULL){ \ + strcpy(str, chunk); \ + str += strlen(chunk); \ + } \ + if(end) \ + current++; \ +} while(0) + +#ifdef CONFIG_MCONSOLE + +extern void mconsole_register_dev(struct mc_device *new); + +#else + +static inline void mconsole_register_dev(struct mc_device *new) +{ +} + +#endif + +#endif diff --git a/arch/um/include/shared/mconsole.h b/arch/um/include/shared/mconsole.h deleted file mode 100644 index c139ae1d682..00000000000 --- a/arch/um/include/shared/mconsole.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) - * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#ifndef __MCONSOLE_H__ -#define __MCONSOLE_H__ - -#ifndef __KERNEL__ -#include -#define u32 uint32_t -#endif - -#include "sysdep/ptrace.h" - -#define MCONSOLE_MAGIC (0xcafebabe) -#define MCONSOLE_MAX_DATA (512) -#define MCONSOLE_VERSION 2 - -struct mconsole_request { - u32 magic; - u32 version; - u32 len; - char data[MCONSOLE_MAX_DATA]; -}; - -struct mconsole_reply { - u32 err; - u32 more; - u32 len; - char data[MCONSOLE_MAX_DATA]; -}; - -struct mconsole_notify { - u32 magic; - u32 version; - enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, - MCONSOLE_USER_NOTIFY } type; - u32 len; - char data[MCONSOLE_MAX_DATA]; -}; - -struct mc_request; - -enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC }; - -struct mconsole_command -{ - char *command; - void (*handler)(struct mc_request *req); - enum mc_context context; -}; - -struct mc_request -{ - int len; - int as_interrupt; - - int originating_fd; - unsigned int originlen; - unsigned char origin[128]; /* sockaddr_un */ - - struct mconsole_request request; - struct mconsole_command *cmd; - struct uml_pt_regs regs; -}; - -extern char mconsole_socket_name[]; - -extern int mconsole_unlink_socket(void); -extern int mconsole_reply_len(struct mc_request *req, const char *reply, - int len, int err, int more); -extern int mconsole_reply(struct mc_request *req, const char *str, int err, - int more); - -extern void mconsole_version(struct mc_request *req); -extern void mconsole_help(struct mc_request *req); -extern void mconsole_halt(struct mc_request *req); -extern void mconsole_reboot(struct mc_request *req); -extern void mconsole_config(struct mc_request *req); -extern void mconsole_remove(struct mc_request *req); -extern void mconsole_sysrq(struct mc_request *req); -extern void mconsole_cad(struct mc_request *req); -extern void mconsole_stop(struct mc_request *req); -extern void mconsole_go(struct mc_request *req); -extern void mconsole_log(struct mc_request *req); -extern void mconsole_proc(struct mc_request *req); -extern void mconsole_stack(struct mc_request *req); - -extern int mconsole_get_request(int fd, struct mc_request *req); -extern int mconsole_notify(char *sock_name, int type, const void *data, - int len); -extern char *mconsole_notify_socket(void); -extern void lock_notify(void); -extern void unlock_notify(void); - -#endif diff --git a/arch/um/include/shared/mconsole_kern.h b/arch/um/include/shared/mconsole_kern.h deleted file mode 100644 index d2fe07e7895..00000000000 --- a/arch/um/include/shared/mconsole_kern.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __MCONSOLE_KERN_H__ -#define __MCONSOLE_KERN_H__ - -#include "linux/list.h" -#include "mconsole.h" - -struct mconsole_entry { - struct list_head list; - struct mc_request request; -}; - -/* All these methods are called in process context. */ -struct mc_device { - struct list_head list; - char *name; - int (*config)(char *, char **); - int (*get_config)(char *, char *, int, char **); - int (*id)(char **, int *, int *); - int (*remove)(int, char **); -}; - -#define CONFIG_CHUNK(str, size, current, chunk, end) \ -do { \ - current += strlen(chunk); \ - if(current >= size) \ - str = NULL; \ - if(str != NULL){ \ - strcpy(str, chunk); \ - str += strlen(chunk); \ - } \ - if(end) \ - current++; \ -} while(0) - -#ifdef CONFIG_MCONSOLE - -extern void mconsole_register_dev(struct mc_device *new); - -#else - -static inline void mconsole_register_dev(struct mc_device *new) -{ -} - -#endif - -#endif -- cgit v1.2.3-70-g09d2 From fced95cacfc21b441ab33f5e7bbc750327e80325 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:08:49 +0100 Subject: um: kill um_uaccess.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/uaccess.h | 89 +++++++++++++++++++++++++++++++++-- arch/um/include/shared/um_uaccess.h | 94 ------------------------------------- 2 files changed, 84 insertions(+), 99 deletions(-) delete mode 100644 arch/um/include/shared/um_uaccess.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h index b9a895d6fa1..3f22fbf7ca1 100644 --- a/arch/um/include/asm/uaccess.h +++ b/arch/um/include/asm/uaccess.h @@ -6,15 +6,15 @@ #ifndef __UM_UACCESS_H #define __UM_UACCESS_H -#include -#include - /* thread_info has a mm_segment_t in it, so put the definition up here */ typedef struct { unsigned long seg; } mm_segment_t; -#include "linux/thread_info.h" +#include +#include +#include +#include #define VERIFY_READ 0 #define VERIFY_WRITE 1 @@ -38,7 +38,86 @@ typedef struct { #define segment_eq(a, b) ((a).seg == (b).seg) -#include "um_uaccess.h" +#define __under_task_size(addr, size) \ + (((unsigned long) (addr) < TASK_SIZE) && \ + (((unsigned long) (addr) + (size)) < TASK_SIZE)) + +#define __access_ok_vsyscall(type, addr, size) \ + ((type == VERIFY_READ) && \ + ((unsigned long) (addr) >= FIXADDR_USER_START) && \ + ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ + ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) + +#define __addr_range_nowrap(addr, size) \ + ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) + +#define access_ok(type, addr, size) \ + (__addr_range_nowrap(addr, size) && \ + (__under_task_size(addr, size) || \ + __access_ok_vsyscall(type, addr, size) || \ + segment_eq(get_fs(), KERNEL_DS))) + +extern int copy_from_user(void *to, const void __user *from, int n); +extern int copy_to_user(void __user *to, const void *from, int n); + +/* + * strncpy_from_user: - Copy a NUL terminated string from userspace. + * @dst: Destination address, in kernel space. This buffer must be at + * least @count bytes long. + * @src: Source address, in user space. + * @count: Maximum number of bytes to copy, including the trailing NUL. + * + * Copies a NUL-terminated string from userspace to kernel space. + * + * On success, returns the length of the string (not including the trailing + * NUL). + * + * If access to userspace fails, returns -EFAULT (some data may have been + * copied). + * + * If @count is smaller than the length of the string, copies @count bytes + * and returns @count. + */ + +extern int strncpy_from_user(char *dst, const char __user *src, int count); + +/* + * __clear_user: - Zero a block of memory in user space, with less checking. + * @to: Destination address, in user space. + * @n: Number of bytes to zero. + * + * Zero a block of memory in user space. Caller must check + * the specified block with access_ok() before calling this function. + * + * Returns number of bytes that could not be cleared. + * On success, this will be zero. + */ +extern int __clear_user(void __user *mem, int len); + +/* + * clear_user: - Zero a block of memory in user space. + * @to: Destination address, in user space. + * @n: Number of bytes to zero. + * + * Zero a block of memory in user space. + * + * Returns number of bytes that could not be cleared. + * On success, this will be zero. + */ +extern int clear_user(void __user *mem, int len); + +/* + * strlen_user: - Get the size of a string in user space. + * @str: The string to measure. + * @n: The maximum valid length + * + * Get the size of a NUL-terminated string in user space. + * + * Returns the size of the string INCLUDING the terminating NUL. + * On exception, returns 0. + * If the string is too long, returns a value greater than @n. + */ +extern int strnlen_user(const void __user *str, int len); #define __copy_from_user(to, from, n) copy_from_user(to, from, n) diff --git a/arch/um/include/shared/um_uaccess.h b/arch/um/include/shared/um_uaccess.h deleted file mode 100644 index 51e1cce92d3..00000000000 --- a/arch/um/include/shared/um_uaccess.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#ifndef __ARCH_UM_UACCESS_H -#define __ARCH_UM_UACCESS_H - -#include -#include -#include "sysdep/archsetjmp.h" - -#define __under_task_size(addr, size) \ - (((unsigned long) (addr) < TASK_SIZE) && \ - (((unsigned long) (addr) + (size)) < TASK_SIZE)) - -#define __access_ok_vsyscall(type, addr, size) \ - ((type == VERIFY_READ) && \ - ((unsigned long) (addr) >= FIXADDR_USER_START) && \ - ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ - ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) - -#define __addr_range_nowrap(addr, size) \ - ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) - -#define access_ok(type, addr, size) \ - (__addr_range_nowrap(addr, size) && \ - (__under_task_size(addr, size) || \ - __access_ok_vsyscall(type, addr, size) || \ - segment_eq(get_fs(), KERNEL_DS))) - -extern int copy_from_user(void *to, const void __user *from, int n); -extern int copy_to_user(void __user *to, const void *from, int n); - -/* - * strncpy_from_user: - Copy a NUL terminated string from userspace. - * @dst: Destination address, in kernel space. This buffer must be at - * least @count bytes long. - * @src: Source address, in user space. - * @count: Maximum number of bytes to copy, including the trailing NUL. - * - * Copies a NUL-terminated string from userspace to kernel space. - * - * On success, returns the length of the string (not including the trailing - * NUL). - * - * If access to userspace fails, returns -EFAULT (some data may have been - * copied). - * - * If @count is smaller than the length of the string, copies @count bytes - * and returns @count. - */ - -extern int strncpy_from_user(char *dst, const char __user *src, int count); - -/* - * __clear_user: - Zero a block of memory in user space, with less checking. - * @to: Destination address, in user space. - * @n: Number of bytes to zero. - * - * Zero a block of memory in user space. Caller must check - * the specified block with access_ok() before calling this function. - * - * Returns number of bytes that could not be cleared. - * On success, this will be zero. - */ -extern int __clear_user(void __user *mem, int len); - -/* - * clear_user: - Zero a block of memory in user space. - * @to: Destination address, in user space. - * @n: Number of bytes to zero. - * - * Zero a block of memory in user space. - * - * Returns number of bytes that could not be cleared. - * On success, this will be zero. - */ -extern int clear_user(void __user *mem, int len); - -/* - * strlen_user: - Get the size of a string in user space. - * @str: The string to measure. - * @n: The maximum valid length - * - * Get the size of a NUL-terminated string in user space. - * - * Returns the size of the string INCLUDING the terminating NUL. - * On exception, returns 0. - * If the string is too long, returns a value greater than @n. - */ -extern int strnlen_user(const void __user *str, int len); - -#endif -- cgit v1.2.3-70-g09d2 From 4dc706c2f292b2c28016a27f400af84a62ec4a63 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:09:09 +0100 Subject: um: take um_mmu.h to asm/mmu.h, clean asm/mmu_context.h a bit Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/mmu.h | 22 +++++++++++++++++----- arch/um/include/asm/mmu_context.h | 7 ++----- arch/um/include/shared/um_mmu.h | 24 ------------------------ 3 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 arch/um/include/shared/um_mmu.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h index cf259de5153..b1a7e47d102 100644 --- a/arch/um/include/asm/mmu.h +++ b/arch/um/include/asm/mmu.h @@ -1,12 +1,24 @@ /* - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#ifndef __MMU_H -#define __MMU_H +#ifndef __ARCH_UM_MMU_H +#define __ARCH_UM_MMU_H -#include "um_mmu.h" +#include "mm_id.h" +#include "ldt.h" -#endif +typedef struct mm_context { + struct mm_id id; + struct uml_ldt ldt; + struct page **stub_pages; +} mm_context_t; + +extern void __switch_mm(struct mm_id * mm_idp); +/* Avoid tangled inclusion with asm/ldt.h */ +extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm); +extern void free_ldt(struct mm_context *mm); + +#endif diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h index 34d813011b7..591b3d8d761 100644 --- a/arch/um/include/asm/mmu_context.h +++ b/arch/um/include/asm/mmu_context.h @@ -6,15 +6,12 @@ #ifndef __UM_MMU_CONTEXT_H #define __UM_MMU_CONTEXT_H -#include "linux/sched.h" -#include "um_mmu.h" +#include +#include extern void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm); extern void arch_exit_mmap(struct mm_struct *mm); -#define get_mmu_context(task) do ; while(0) -#define activate_context(tsk) do ; while(0) - #define deactivate_mm(tsk,mm) do { } while (0) extern void force_flush_all(void); diff --git a/arch/um/include/shared/um_mmu.h b/arch/um/include/shared/um_mmu.h deleted file mode 100644 index b1a7e47d102..00000000000 --- a/arch/um/include/shared/um_mmu.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#ifndef __ARCH_UM_MMU_H -#define __ARCH_UM_MMU_H - -#include "mm_id.h" -#include "ldt.h" - -typedef struct mm_context { - struct mm_id id; - struct uml_ldt ldt; - struct page **stub_pages; -} mm_context_t; - -extern void __switch_mm(struct mm_id * mm_idp); - -/* Avoid tangled inclusion with asm/ldt.h */ -extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm); -extern void free_ldt(struct mm_context *mm); - -#endif -- cgit v1.2.3-70-g09d2 From c5cc32fe14ccbc19484202d20cf7d6bad45e3567 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:09:39 +0100 Subject: um: move asm/desc.h into arch/x86/um/asm its only purpose is to shadow the x86 asm/desc.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/desc.h | 16 ---------------- arch/x86/um/asm/desc.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 arch/um/include/asm/desc.h create mode 100644 arch/x86/um/asm/desc.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/desc.h b/arch/um/include/asm/desc.h deleted file mode 100644 index 4ec34a51b62..00000000000 --- a/arch/um/include/asm/desc.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __UM_DESC_H -#define __UM_DESC_H - -/* Taken from asm-i386/desc.h, it's the only thing we need. The rest wouldn't - * compile, and has never been used. */ -#define LDT_empty(info) (\ - (info)->base_addr == 0 && \ - (info)->limit == 0 && \ - (info)->contents == 0 && \ - (info)->read_exec_only == 1 && \ - (info)->seg_32bit == 0 && \ - (info)->limit_in_pages == 0 && \ - (info)->seg_not_present == 1 && \ - (info)->useable == 0 ) - -#endif diff --git a/arch/x86/um/asm/desc.h b/arch/x86/um/asm/desc.h new file mode 100644 index 00000000000..4ec34a51b62 --- /dev/null +++ b/arch/x86/um/asm/desc.h @@ -0,0 +1,16 @@ +#ifndef __UM_DESC_H +#define __UM_DESC_H + +/* Taken from asm-i386/desc.h, it's the only thing we need. The rest wouldn't + * compile, and has never been used. */ +#define LDT_empty(info) (\ + (info)->base_addr == 0 && \ + (info)->limit == 0 && \ + (info)->contents == 0 && \ + (info)->read_exec_only == 1 && \ + (info)->seg_32bit == 0 && \ + (info)->limit_in_pages == 0 && \ + (info)->seg_not_present == 1 && \ + (info)->useable == 0 ) + +#endif -- cgit v1.2.3-70-g09d2 From 1bbd5f21f426d99660ea8120b79595a282e5ff8a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:09:49 +0100 Subject: um: merge os-Linux/tls.c into arch/x86/um/os-Linux/tls.c it's i386-specific; moreover, analogs on other targets have incompatible interface - PTRACE_GET_THREAD_AREA does exist elsewhere, but struct user_desc does *not* Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/os.h | 5 ----- arch/um/os-Linux/Makefile | 4 ++-- arch/um/os-Linux/tls.c | 35 ----------------------------------- arch/x86/um/os-Linux/tls.c | 34 +++++++++++++++++++++++++++++++++- arch/x86/um/shared/sysdep/tls.h | 3 +++ 5 files changed, 38 insertions(+), 43 deletions(-) delete mode 100644 arch/um/os-Linux/tls.c (limited to 'arch/um/include') diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index caa66619a9b..89b686c1a3e 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -10,7 +10,6 @@ #include "irq_user.h" #include "longjmp.h" #include "mm_id.h" -#include "sysdep/tls.h" #define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR)) @@ -212,10 +211,6 @@ extern int run_helper_thread(int (*proc)(void *), void *arg, extern int helper_wait(int pid); -/* tls.c */ -extern int os_set_thread_area(user_desc_t *info, int pid); -extern int os_get_thread_area(user_desc_t *info, int pid); - /* umid.c */ extern int umid_file_name(char *name, char *buf, int len); extern int set_umid(char *name); diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 015d0005766..dd764101e48 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -5,13 +5,13 @@ obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ registers.o sigio.o signal.o start_up.o time.o tty.o \ - umid.o tls.o user_syms.o util.o drivers/ skas/ + umid.o user_syms.o util.o drivers/ skas/ obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ - tty.o tls.o umid.o util.o + tty.o umid.o util.o CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) diff --git a/arch/um/os-Linux/tls.c b/arch/um/os-Linux/tls.c deleted file mode 100644 index 73277801ef1..00000000000 --- a/arch/um/os-Linux/tls.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include "sysdep/tls.h" - -/* TLS support - we basically rely on the host's one.*/ - -#ifndef PTRACE_GET_THREAD_AREA -#define PTRACE_GET_THREAD_AREA 25 -#endif - -#ifndef PTRACE_SET_THREAD_AREA -#define PTRACE_SET_THREAD_AREA 26 -#endif - -int os_set_thread_area(user_desc_t *info, int pid) -{ - int ret; - - ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number, - (unsigned long) info); - if (ret < 0) - ret = -errno; - return ret; -} - -int os_get_thread_area(user_desc_t *info, int pid) -{ - int ret; - - ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number, - (unsigned long) info); - if (ret < 0) - ret = -errno; - return ret; -} diff --git a/arch/x86/um/os-Linux/tls.c b/arch/x86/um/os-Linux/tls.c index 281e83ecce3..82276b6071a 100644 --- a/arch/x86/um/os-Linux/tls.c +++ b/arch/x86/um/os-Linux/tls.c @@ -1,15 +1,25 @@ #include #include +#include #include #include #include "sysdep/tls.h" +#ifndef PTRACE_GET_THREAD_AREA +#define PTRACE_GET_THREAD_AREA 25 +#endif + +#ifndef PTRACE_SET_THREAD_AREA +#define PTRACE_SET_THREAD_AREA 26 +#endif + /* Checks whether host supports TLS, and sets *tls_min according to the value * valid on the host. * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */ -void check_host_supports_tls(int *supports_tls, int *tls_min) { +void check_host_supports_tls(int *supports_tls, int *tls_min) +{ /* Values for x86 and x86_64.*/ int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64}; int i; @@ -33,3 +43,25 @@ void check_host_supports_tls(int *supports_tls, int *tls_min) { *supports_tls = 0; } + +int os_set_thread_area(user_desc_t *info, int pid) +{ + int ret; + + ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number, + (unsigned long) info); + if (ret < 0) + ret = -errno; + return ret; +} + +int os_get_thread_area(user_desc_t *info, int pid) +{ + int ret; + + ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number, + (unsigned long) info); + if (ret < 0) + ret = -errno; + return ret; +} diff --git a/arch/x86/um/shared/sysdep/tls.h b/arch/x86/um/shared/sysdep/tls.h index db2ae9c12e2..f2f30bd67b9 100644 --- a/arch/x86/um/shared/sysdep/tls.h +++ b/arch/x86/um/shared/sysdep/tls.h @@ -29,6 +29,9 @@ typedef struct user_desc user_desc_t; # endif /* __KERNEL__ */ +extern int os_set_thread_area(user_desc_t *info, int pid); +extern int os_get_thread_area(user_desc_t *info, int pid); + #ifdef __i386__ #define GDT_ENTRY_TLS_MIN_I386 6 #define GDT_ENTRY_TLS_MIN_X86_64 12 -- cgit v1.2.3-70-g09d2 From b3ee571e58120de30c3d15657022bf2c72477e02 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:10:49 +0100 Subject: um: take ldt.h to arch/x86/um/asm/mm_context.h it's x86-only and we have no business playing with it in asm/mmu.h; make the latter have struct uml_arch_mm_context arch; instead of struct uml_ldt ldt; and let arch//um/asm/mm_context.h decide what'll be in there. While we are at it, kill host_ldt.h - it's not needed in part of places that include it (we want asm/ldt.h in those) and it can be trivially expanded into the single remaining one. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/mmu.h | 4 +- arch/um/include/shared/ldt.h | 37 ------------------ arch/x86/um/asm/mm_context.h | 72 ++++++++++++++++++++++++++++++++++++ arch/x86/um/asm/processor_32.h | 2 +- arch/x86/um/ldt.c | 36 +++++++++--------- arch/x86/um/shared/sysdep/host_ldt.h | 37 ------------------ arch/x86/um/shared/sysdep/tls.h | 1 - 7 files changed, 93 insertions(+), 96 deletions(-) delete mode 100644 arch/um/include/shared/ldt.h create mode 100644 arch/x86/um/asm/mm_context.h delete mode 100644 arch/x86/um/shared/sysdep/host_ldt.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h index b1a7e47d102..30509b9f37f 100644 --- a/arch/um/include/asm/mmu.h +++ b/arch/um/include/asm/mmu.h @@ -7,11 +7,11 @@ #define __ARCH_UM_MMU_H #include "mm_id.h" -#include "ldt.h" +#include typedef struct mm_context { struct mm_id id; - struct uml_ldt ldt; + struct uml_arch_mm_context arch; struct page **stub_pages; } mm_context_t; diff --git a/arch/um/include/shared/ldt.h b/arch/um/include/shared/ldt.h deleted file mode 100644 index a7f999a5877..00000000000 --- a/arch/um/include/shared/ldt.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2004 Fujitsu Siemens Computers GmbH - * Licensed under the GPL - * - * Author: Bodo Stroesser - */ - -#ifndef __ASM_LDT_H -#define __ASM_LDT_H - -#include -#include - -extern void ldt_host_info(void); - -#define LDT_PAGES_MAX \ - ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE) -#define LDT_ENTRIES_PER_PAGE \ - (PAGE_SIZE/LDT_ENTRY_SIZE) -#define LDT_DIRECT_ENTRIES \ - ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE) - -struct ldt_entry { - __u32 a; - __u32 b; -}; - -typedef struct uml_ldt { - int entry_count; - struct mutex lock; - union { - struct ldt_entry * pages[LDT_PAGES_MAX]; - struct ldt_entry entries[LDT_DIRECT_ENTRIES]; - } u; -} uml_ldt_t; - -#endif diff --git a/arch/x86/um/asm/mm_context.h b/arch/x86/um/asm/mm_context.h new file mode 100644 index 00000000000..4a73d63e476 --- /dev/null +++ b/arch/x86/um/asm/mm_context.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2004 Fujitsu Siemens Computers GmbH + * Licensed under the GPL + * + * Author: Bodo Stroesser + */ + +#ifndef __ASM_LDT_H +#define __ASM_LDT_H + +#include +#include + +extern void ldt_host_info(void); + +#define LDT_PAGES_MAX \ + ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE) +#define LDT_ENTRIES_PER_PAGE \ + (PAGE_SIZE/LDT_ENTRY_SIZE) +#define LDT_DIRECT_ENTRIES \ + ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE) + +struct ldt_entry { + __u32 a; + __u32 b; +}; + +typedef struct uml_ldt { + int entry_count; + struct mutex lock; + union { + struct ldt_entry * pages[LDT_PAGES_MAX]; + struct ldt_entry entries[LDT_DIRECT_ENTRIES]; + } u; +} uml_ldt_t; + +#define LDT_entry_a(info) \ + ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) + +#define LDT_entry_b(info) \ + (((info)->base_addr & 0xff000000) | \ + (((info)->base_addr & 0x00ff0000) >> 16) | \ + ((info)->limit & 0xf0000) | \ + (((info)->read_exec_only ^ 1) << 9) | \ + ((info)->contents << 10) | \ + (((info)->seg_not_present ^ 1) << 15) | \ + ((info)->seg_32bit << 22) | \ + ((info)->limit_in_pages << 23) | \ + ((info)->useable << 20) | \ + 0x7000) + +#define _LDT_empty(info) (\ + (info)->base_addr == 0 && \ + (info)->limit == 0 && \ + (info)->contents == 0 && \ + (info)->read_exec_only == 1 && \ + (info)->seg_32bit == 0 && \ + (info)->limit_in_pages == 0 && \ + (info)->seg_not_present == 1 && \ + (info)->useable == 0 ) + +#ifdef CONFIG_X86_64 +#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0)) +#else +#define LDT_empty(info) (_LDT_empty(info)) +#endif + +struct uml_arch_mm_context { + uml_ldt_t ldt; +}; + +#endif diff --git a/arch/x86/um/asm/processor_32.h b/arch/x86/um/asm/processor_32.h index e5b72faea0f..c4078b581df 100644 --- a/arch/x86/um/asm/processor_32.h +++ b/arch/x86/um/asm/processor_32.h @@ -7,8 +7,8 @@ #define __UM_PROCESSOR_I386_H #include -#include #include +#include extern int host_has_cmov; diff --git a/arch/x86/um/ldt.c b/arch/x86/um/ldt.c index 3f2bf208d88..26b0e39d2ce 100644 --- a/arch/x86/um/ldt.c +++ b/arch/x86/um/ldt.c @@ -137,7 +137,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount) { int i, err = 0; unsigned long size; - uml_ldt_t * ldt = ¤t->mm->context.ldt; + uml_ldt_t *ldt = ¤t->mm->context.arch.ldt; if (!ldt->entry_count) goto out; @@ -205,7 +205,7 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount) static int write_ldt(void __user * ptr, unsigned long bytecount, int func) { - uml_ldt_t * ldt = ¤t->mm->context.ldt; + uml_ldt_t *ldt = ¤t->mm->context.arch.ldt; struct mm_id * mm_idp = ¤t->mm->context.id; int i, err; struct user_desc ldt_info; @@ -397,7 +397,7 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm) if (!ptrace_ldt) - mutex_init(&new_mm->ldt.lock); + mutex_init(&new_mm->arch.ldt.lock); if (!from_mm) { memset(&desc, 0, sizeof(desc)); @@ -429,7 +429,7 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm) break; } } - new_mm->ldt.entry_count = 0; + new_mm->arch.ldt.entry_count = 0; goto out; } @@ -457,26 +457,26 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm) * i.e., we have to use the stub for modify_ldt, which * can't handle the big read buffer of up to 64kB. */ - mutex_lock(&from_mm->ldt.lock); - if (from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES) - memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries, - sizeof(new_mm->ldt.u.entries)); + mutex_lock(&from_mm->arch.ldt.lock); + if (from_mm->arch.ldt.entry_count <= LDT_DIRECT_ENTRIES) + memcpy(new_mm->arch.ldt.u.entries, from_mm->arch.ldt.u.entries, + sizeof(new_mm->arch.ldt.u.entries)); else { - i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; + i = from_mm->arch.ldt.entry_count / LDT_ENTRIES_PER_PAGE; while (i-->0) { page = __get_free_page(GFP_KERNEL|__GFP_ZERO); if (!page) { err = -ENOMEM; break; } - new_mm->ldt.u.pages[i] = + new_mm->arch.ldt.u.pages[i] = (struct ldt_entry *) page; - memcpy(new_mm->ldt.u.pages[i], - from_mm->ldt.u.pages[i], PAGE_SIZE); + memcpy(new_mm->arch.ldt.u.pages[i], + from_mm->arch.ldt.u.pages[i], PAGE_SIZE); } } - new_mm->ldt.entry_count = from_mm->ldt.entry_count; - mutex_unlock(&from_mm->ldt.lock); + new_mm->arch.ldt.entry_count = from_mm->arch.ldt.entry_count; + mutex_unlock(&from_mm->arch.ldt.lock); } out: @@ -488,12 +488,12 @@ void free_ldt(struct mm_context *mm) { int i; - if (!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES) { - i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; + if (!ptrace_ldt && mm->arch.ldt.entry_count > LDT_DIRECT_ENTRIES) { + i = mm->arch.ldt.entry_count / LDT_ENTRIES_PER_PAGE; while (i-- > 0) - free_page((long) mm->ldt.u.pages[i]); + free_page((long) mm->arch.ldt.u.pages[i]); } - mm->ldt.entry_count = 0; + mm->arch.ldt.entry_count = 0; } int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) diff --git a/arch/x86/um/shared/sysdep/host_ldt.h b/arch/x86/um/shared/sysdep/host_ldt.h deleted file mode 100644 index 246ff7ace5e..00000000000 --- a/arch/x86/um/shared/sysdep/host_ldt.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __ASM_HOST_LDT_H -#define __ASM_HOST_LDT_H - -#include - -#define LDT_entry_a(info) \ - ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) - -#define LDT_entry_b(info) \ - (((info)->base_addr & 0xff000000) | \ - (((info)->base_addr & 0x00ff0000) >> 16) | \ - ((info)->limit & 0xf0000) | \ - (((info)->read_exec_only ^ 1) << 9) | \ - ((info)->contents << 10) | \ - (((info)->seg_not_present ^ 1) << 15) | \ - ((info)->seg_32bit << 22) | \ - ((info)->limit_in_pages << 23) | \ - ((info)->useable << 20) | \ - 0x7000) - -#define _LDT_empty(info) (\ - (info)->base_addr == 0 && \ - (info)->limit == 0 && \ - (info)->contents == 0 && \ - (info)->read_exec_only == 1 && \ - (info)->seg_32bit == 0 && \ - (info)->limit_in_pages == 0 && \ - (info)->seg_not_present == 1 && \ - (info)->useable == 0 ) - -#ifdef CONFIG_X86_64 -#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0)) -#else -#define LDT_empty(info) (_LDT_empty(info)) -#endif - -#endif diff --git a/arch/x86/um/shared/sysdep/tls.h b/arch/x86/um/shared/sysdep/tls.h index f2f30bd67b9..27cce00c6b3 100644 --- a/arch/x86/um/shared/sysdep/tls.h +++ b/arch/x86/um/shared/sysdep/tls.h @@ -24,7 +24,6 @@ typedef struct um_dup_user_desc { # else /* __KERNEL__ */ -# include typedef struct user_desc user_desc_t; # endif /* __KERNEL__ */ -- cgit v1.2.3-70-g09d2 From c506c0e4a730b436b082fa398ec1d8ae9433b2eb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:10:59 +0100 Subject: um: take ubd_user.h to its users... Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/ubd_user.h | 16 ++++++++++++++++ arch/um/include/shared/ubd_user.h | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 arch/um/drivers/ubd_user.h delete mode 100644 arch/um/include/shared/ubd_user.h (limited to 'arch/um/include') diff --git a/arch/um/drivers/ubd_user.h b/arch/um/drivers/ubd_user.h new file mode 100644 index 00000000000..3845051f1b1 --- /dev/null +++ b/arch/um/drivers/ubd_user.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) + * Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com) + * Licensed under the GPL + */ + +#ifndef __UM_UBD_USER_H +#define __UM_UBD_USER_H + +extern void ignore_sigwinch_sig(void); +extern int start_io_thread(unsigned long sp, int *fds_out); +extern int io_thread(void *arg); +extern int kernel_fd; + +#endif + diff --git a/arch/um/include/shared/ubd_user.h b/arch/um/include/shared/ubd_user.h deleted file mode 100644 index 3845051f1b1..00000000000 --- a/arch/um/include/shared/ubd_user.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) - * Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com) - * Licensed under the GPL - */ - -#ifndef __UM_UBD_USER_H -#define __UM_UBD_USER_H - -extern void ignore_sigwinch_sig(void); -extern int start_io_thread(unsigned long sp, int *fds_out); -extern int io_thread(void *arg); -extern int kernel_fd; - -#endif - -- cgit v1.2.3-70-g09d2 From 8807c1d56121269a27ad973c6adda18cc4c6a099 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:11:09 +0100 Subject: um: asm/apic.h is there only to shadow the x86 one... ... so take it to arch/um/x86/asm. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/apic.h | 4 ---- arch/x86/um/asm/apic.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 arch/um/include/asm/apic.h create mode 100644 arch/x86/um/asm/apic.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/apic.h b/arch/um/include/asm/apic.h deleted file mode 100644 index 876dee84ab1..00000000000 --- a/arch/um/include/asm/apic.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __UM_APIC_H -#define __UM_APIC_H - -#endif diff --git a/arch/x86/um/asm/apic.h b/arch/x86/um/asm/apic.h new file mode 100644 index 00000000000..876dee84ab1 --- /dev/null +++ b/arch/x86/um/asm/apic.h @@ -0,0 +1,4 @@ +#ifndef __UM_APIC_H +#define __UM_APIC_H + +#endif -- cgit v1.2.3-70-g09d2 From ff9586e98feaf6c2df0c936075e3cbb31045b99e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:11:19 +0100 Subject: um: required-features.h is there only to shadow x86 one... Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/required-features.h | 9 --------- arch/x86/um/asm/required-features.h | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 arch/um/include/asm/required-features.h create mode 100644 arch/x86/um/asm/required-features.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/required-features.h b/arch/um/include/asm/required-features.h deleted file mode 100644 index dfb967b2d2f..00000000000 --- a/arch/um/include/asm/required-features.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __UM_REQUIRED_FEATURES_H -#define __UM_REQUIRED_FEATURES_H - -/* - * Nothing to see, just need something for the i386 and x86_64 asm - * headers to include. - */ - -#endif diff --git a/arch/x86/um/asm/required-features.h b/arch/x86/um/asm/required-features.h new file mode 100644 index 00000000000..dfb967b2d2f --- /dev/null +++ b/arch/x86/um/asm/required-features.h @@ -0,0 +1,9 @@ +#ifndef __UM_REQUIRED_FEATURES_H +#define __UM_REQUIRED_FEATURES_H + +/* + * Nothing to see, just need something for the i386 and x86_64 asm + * headers to include. + */ + +#endif -- cgit v1.2.3-70-g09d2 From 3fb77d7256f442e8e15d51f111bb6cf096d4a9f8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:11:29 +0100 Subject: um: irq_vectors.h just shadows x86 one Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/irq_vectors.h | 10 ---------- arch/x86/um/asm/irq_vectors.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 arch/um/include/asm/irq_vectors.h create mode 100644 arch/x86/um/asm/irq_vectors.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/irq_vectors.h b/arch/um/include/asm/irq_vectors.h deleted file mode 100644 index 272a81e0ce1..00000000000 --- a/arch/um/include/asm/irq_vectors.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __UM_IRQ_VECTORS_H -#define __UM_IRQ_VECTORS_H - -#endif - diff --git a/arch/x86/um/asm/irq_vectors.h b/arch/x86/um/asm/irq_vectors.h new file mode 100644 index 00000000000..272a81e0ce1 --- /dev/null +++ b/arch/x86/um/asm/irq_vectors.h @@ -0,0 +1,10 @@ +/* + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __UM_IRQ_VECTORS_H +#define __UM_IRQ_VECTORS_H + +#endif + -- cgit v1.2.3-70-g09d2 From c32324e31270514638d6d2df38436590862e0d8f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:11:39 +0100 Subject: um: page_offset.h is never used ... and neither is the only define in it Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/page_offset.h | 1 - 1 file changed, 1 deletion(-) delete mode 100644 arch/um/include/asm/page_offset.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/page_offset.h b/arch/um/include/asm/page_offset.h deleted file mode 100644 index 1c168dfbf35..00000000000 --- a/arch/um/include/asm/page_offset.h +++ /dev/null @@ -1 +0,0 @@ -#define PAGE_OFFSET_RAW (uml_physmem) -- cgit v1.2.3-70-g09d2 From 966e803ab12538faf2b236dbe83f7fb796a031d6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:12:19 +0100 Subject: um: unify ptrace_user.h Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/shared/ptrace_user.h | 3 ++- arch/um/os-Linux/skas/process.c | 3 +-- arch/um/os-Linux/start_up.c | 9 ++++--- arch/x86/um/ptrace_64.c | 2 +- arch/x86/um/shared/sysdep/ptrace_64.h | 2 +- arch/x86/um/shared/sysdep/ptrace_user.h | 26 ++++++++++++++++++-- arch/x86/um/shared/sysdep/ptrace_user_32.h | 26 -------------------- arch/x86/um/shared/sysdep/ptrace_user_64.h | 38 ------------------------------ arch/x86/um/user-offsets.c | 3 ++- 9 files changed, 35 insertions(+), 77 deletions(-) delete mode 100644 arch/x86/um/shared/sysdep/ptrace_user_32.h delete mode 100644 arch/x86/um/shared/sysdep/ptrace_user_64.h (limited to 'arch/um/include') diff --git a/arch/um/include/shared/ptrace_user.h b/arch/um/include/shared/ptrace_user.h index 7fd8539bc19..56b2f284b10 100644 --- a/arch/um/include/shared/ptrace_user.h +++ b/arch/um/include/shared/ptrace_user.h @@ -6,7 +6,8 @@ #ifndef __PTRACE_USER_H__ #define __PTRACE_USER_H__ -#include "sysdep/ptrace_user.h" +#include +#include extern int ptrace_getregs(long pid, unsigned long *regs_out); extern int ptrace_setregs(long pid, unsigned long *regs_in); diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 6c34f14708a..cd65727854e 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include "as-layout.h" @@ -162,7 +161,7 @@ static void handle_trap(int pid, struct uml_pt_regs *regs, if (!local_using_sysemu) { - err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, + err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid); if (err < 0) { printk(UM_KERN_ERR "handle_trap - nullifying syscall " diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index b6986809b8e..425162e22af 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -224,7 +223,7 @@ static void __init check_sysemu(void) goto fail; } - n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); + n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); if (n < 0) { non_fatal("check_sysemu : failed to modify system call " "return"); @@ -260,7 +259,7 @@ static void __init check_sysemu(void) "doesn't singlestep"); goto fail; } - n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, + n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); if (n < 0) fatal_perror("check_sysemu : failed to modify " @@ -316,10 +315,10 @@ static void __init check_ptrace(void) fatal("check_ptrace : expected (SIGTRAP|0x80), " "got status = %d", status); - syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, + syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET, 0); if (syscall == __NR_getpid) { - n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, + n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getppid); if (n < 0) fatal_perror("check_ptrace : failed to modify " diff --git a/arch/x86/um/ptrace_64.c b/arch/x86/um/ptrace_64.c index 6e6343e7329..3b52bf0b418 100644 --- a/arch/x86/um/ptrace_64.c +++ b/arch/x86/um/ptrace_64.c @@ -46,7 +46,7 @@ static const int reg_offsets[] = [FS >> 3] = HOST_FS, [GS >> 3] = HOST_GS, [EFLAGS >> 3] = HOST_EFLAGS, - [ORIG_RAX >> 3] = HOST_ORIG_RAX, + [ORIG_RAX >> 3] = HOST_ORIG_AX, }; int putreg(struct task_struct *child, int regno, unsigned long value) diff --git a/arch/x86/um/shared/sysdep/ptrace_64.h b/arch/x86/um/shared/sysdep/ptrace_64.h index 430dedc2505..031edc53ac5 100644 --- a/arch/x86/um/shared/sysdep/ptrace_64.h +++ b/arch/x86/um/shared/sysdep/ptrace_64.h @@ -65,7 +65,7 @@ #define REGS_FS(r) ((r)[HOST_FS]) #define REGS_GS(r) ((r)[HOST_GS]) -#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_RAX]) +#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_AX]) #define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res) diff --git a/arch/x86/um/shared/sysdep/ptrace_user.h b/arch/x86/um/shared/sysdep/ptrace_user.h index a92f883264e..16cd6b5e71f 100644 --- a/arch/x86/um/shared/sysdep/ptrace_user.h +++ b/arch/x86/um/shared/sysdep/ptrace_user.h @@ -1,5 +1,27 @@ +#include + +#define PT_OFFSET(r) ((r) * sizeof(long)) + +#define PT_SYSCALL_NR(regs) ((regs)[HOST_ORIG_AX]) +#define PT_SYSCALL_NR_OFFSET PT_OFFSET(HOST_ORIG_AX) + +#define PT_SYSCALL_RET_OFFSET PT_OFFSET(HOST_AX) + +#define REGS_IP_INDEX HOST_IP +#define REGS_SP_INDEX HOST_SP + #ifdef __i386__ -#include "ptrace_user_32.h" +#define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE) #else -#include "ptrace_user_64.h" +#define FP_SIZE HOST_FP_SIZE + +/* + * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though + * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the + * 2.4 name and value for 2.4 host compatibility. + */ +#ifndef PTRACE_OLDSETOPTIONS +#define PTRACE_OLDSETOPTIONS 21 +#endif + #endif diff --git a/arch/x86/um/shared/sysdep/ptrace_user_32.h b/arch/x86/um/shared/sysdep/ptrace_user_32.h deleted file mode 100644 index 9d88a79a138..00000000000 --- a/arch/x86/um/shared/sysdep/ptrace_user_32.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __SYSDEP_I386_PTRACE_USER_H__ -#define __SYSDEP_I386_PTRACE_USER_H__ - -#include -#include -#include -#include - -#define PT_OFFSET(r) ((r) * sizeof(long)) - -#define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX]) -#define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX) - -#define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX) - -#define REGS_IP_INDEX EIP -#define REGS_SP_INDEX UESP - -#define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE) - -#endif diff --git a/arch/x86/um/shared/sysdep/ptrace_user_64.h b/arch/x86/um/shared/sysdep/ptrace_user_64.h deleted file mode 100644 index 2f1b6e33d59..00000000000 --- a/arch/x86/um/shared/sysdep/ptrace_user_64.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2003 PathScale, Inc. - * - * Licensed under the GPL - */ - -#ifndef __SYSDEP_X86_64_PTRACE_USER_H__ -#define __SYSDEP_X86_64_PTRACE_USER_H__ - -#define __FRAME_OFFSETS -#include -#include -#include -#undef __FRAME_OFFSETS -#include - -#define PT_INDEX(off) ((off) / sizeof(unsigned long)) - -#define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)]) -#define PT_SYSCALL_NR_OFFSET (ORIG_RAX) - -#define PT_SYSCALL_RET_OFFSET (RAX) - -/* - * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though - * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the - * 2.4 name and value for 2.4 host compatibility. - */ -#ifndef PTRACE_OLDSETOPTIONS -#define PTRACE_OLDSETOPTIONS 21 -#endif - -#define REGS_IP_INDEX PT_INDEX(RIP) -#define REGS_SP_INDEX PT_INDEX(RSP) - -#define FP_SIZE (HOST_FP_SIZE) - -#endif diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c index 88d125516ee..ca49be8ddd0 100644 --- a/arch/x86/um/user-offsets.c +++ b/arch/x86/um/user-offsets.c @@ -36,6 +36,7 @@ void foo(void) DEFINE(HOST_FS, FS); DEFINE(HOST_ES, ES); DEFINE(HOST_GS, GS); + DEFINE(HOST_ORIG_AX, ORIG_EAX); #else DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); DEFINE_LONGS(HOST_BX, RBX); @@ -53,7 +54,7 @@ void foo(void) DEFINE_LONGS(HOST_R13, R13); DEFINE_LONGS(HOST_R14, R14); DEFINE_LONGS(HOST_R15, R15); - DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX); + DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX); DEFINE_LONGS(HOST_CS, CS); DEFINE_LONGS(HOST_SS, SS); DEFINE_LONGS(HOST_EFLAGS, EFLAGS); -- cgit v1.2.3-70-g09d2 From f5e900770f387d7a4c633b7cef105039f32a85c1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:13:10 +0100 Subject: um: switch to generic-y kill wrapper headers Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/Kbuild | 2 ++ arch/um/include/asm/bug.h | 6 ------ arch/um/include/asm/cputime.h | 6 ------ arch/um/include/asm/device.h | 7 ------- arch/um/include/asm/emergency-restart.h | 6 ------ arch/um/include/asm/futex.h | 6 ------ arch/um/include/asm/hardirq.h | 1 - arch/um/include/asm/irq_regs.h | 1 - arch/um/include/asm/kdebug.h | 1 - arch/um/include/asm/percpu.h | 6 ------ arch/um/include/asm/sections.h | 7 ------- arch/um/include/asm/topology.h | 6 ------ arch/um/include/asm/xor.h | 6 ------ 13 files changed, 2 insertions(+), 59 deletions(-) create mode 100644 arch/um/include/asm/Kbuild delete mode 100644 arch/um/include/asm/bug.h delete mode 100644 arch/um/include/asm/cputime.h delete mode 100644 arch/um/include/asm/device.h delete mode 100644 arch/um/include/asm/emergency-restart.h delete mode 100644 arch/um/include/asm/futex.h delete mode 100644 arch/um/include/asm/hardirq.h delete mode 100644 arch/um/include/asm/irq_regs.h delete mode 100644 arch/um/include/asm/kdebug.h delete mode 100644 arch/um/include/asm/percpu.h delete mode 100644 arch/um/include/asm/sections.h delete mode 100644 arch/um/include/asm/topology.h delete mode 100644 arch/um/include/asm/xor.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild new file mode 100644 index 00000000000..e16895decf4 --- /dev/null +++ b/arch/um/include/asm/Kbuild @@ -0,0 +1,2 @@ +generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h +generic-y += irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h diff --git a/arch/um/include/asm/bug.h b/arch/um/include/asm/bug.h deleted file mode 100644 index 9e33b864c35..00000000000 --- a/arch/um/include/asm/bug.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __UM_BUG_H -#define __UM_BUG_H - -#include - -#endif diff --git a/arch/um/include/asm/cputime.h b/arch/um/include/asm/cputime.h deleted file mode 100644 index c84acbadfa2..00000000000 --- a/arch/um/include/asm/cputime.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __UM_CPUTIME_H -#define __UM_CPUTIME_H - -#include - -#endif /* __UM_CPUTIME_H */ diff --git a/arch/um/include/asm/device.h b/arch/um/include/asm/device.h deleted file mode 100644 index d8f9872b0e2..00000000000 --- a/arch/um/include/asm/device.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Arch specific extensions to struct device - * - * This file is released under the GPLv2 - */ -#include - diff --git a/arch/um/include/asm/emergency-restart.h b/arch/um/include/asm/emergency-restart.h deleted file mode 100644 index 108d8c48e42..00000000000 --- a/arch/um/include/asm/emergency-restart.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASM_EMERGENCY_RESTART_H -#define _ASM_EMERGENCY_RESTART_H - -#include - -#endif /* _ASM_EMERGENCY_RESTART_H */ diff --git a/arch/um/include/asm/futex.h b/arch/um/include/asm/futex.h deleted file mode 100644 index 6a332a9f099..00000000000 --- a/arch/um/include/asm/futex.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASM_FUTEX_H -#define _ASM_FUTEX_H - -#include - -#endif diff --git a/arch/um/include/asm/hardirq.h b/arch/um/include/asm/hardirq.h deleted file mode 100644 index fb3c05a0cbb..00000000000 --- a/arch/um/include/asm/hardirq.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/arch/um/include/asm/irq_regs.h b/arch/um/include/asm/irq_regs.h deleted file mode 100644 index 3dd9c0b7027..00000000000 --- a/arch/um/include/asm/irq_regs.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/arch/um/include/asm/kdebug.h b/arch/um/include/asm/kdebug.h deleted file mode 100644 index 6ece1b03766..00000000000 --- a/arch/um/include/asm/kdebug.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/arch/um/include/asm/percpu.h b/arch/um/include/asm/percpu.h deleted file mode 100644 index efe7508d8ab..00000000000 --- a/arch/um/include/asm/percpu.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __UM_PERCPU_H -#define __UM_PERCPU_H - -#include - -#endif /* __UM_PERCPU_H */ diff --git a/arch/um/include/asm/sections.h b/arch/um/include/asm/sections.h deleted file mode 100644 index 6b0231eefea..00000000000 --- a/arch/um/include/asm/sections.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _UM_SECTIONS_H -#define _UM_SECTIONS_H - -/* nothing to see, move along */ -#include - -#endif diff --git a/arch/um/include/asm/topology.h b/arch/um/include/asm/topology.h deleted file mode 100644 index 0905e4f21d4..00000000000 --- a/arch/um/include/asm/topology.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASM_UM_TOPOLOGY_H -#define _ASM_UM_TOPOLOGY_H - -#include - -#endif diff --git a/arch/um/include/asm/xor.h b/arch/um/include/asm/xor.h deleted file mode 100644 index a19db3e1724..00000000000 --- a/arch/um/include/asm/xor.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __UM_XOR_H -#define __UM_XOR_H - -#include "asm-generic/xor.h" - -#endif -- cgit v1.2.3-70-g09d2 From 8e66cda4af84321b308825f1c70aff6bffa30b35 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:13:20 +0100 Subject: um: hw_irq.h can go generic as well Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/Kbuild | 2 +- arch/um/include/asm/hw_irq.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 arch/um/include/asm/hw_irq.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index e16895decf4..5962826ac20 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild @@ -1,2 +1,2 @@ generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h -generic-y += irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h +generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h diff --git a/arch/um/include/asm/hw_irq.h b/arch/um/include/asm/hw_irq.h deleted file mode 100644 index 1cf84cf5f21..00000000000 --- a/arch/um/include/asm/hw_irq.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ASM_UM_HW_IRQ_H -#define _ASM_UM_HW_IRQ_H - -#include "asm/irq.h" -#include "asm/archparam.h" - -#endif -- cgit v1.2.3-70-g09d2 From c2ad3ad009cbef8eb2f550809d2c2c3ed8e04a8d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:13:30 +0100 Subject: um: asm/pda.h is not needed anymore Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/pda.h | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 arch/um/include/asm/pda.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/pda.h b/arch/um/include/asm/pda.h deleted file mode 100644 index ddcd774fc2a..00000000000 --- a/arch/um/include/asm/pda.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2003 PathScale, Inc. - * - * Licensed under the GPL - */ - -#ifndef __UM_PDA_X86_64_H -#define __UM_PDA_X86_64_H - -/* XXX */ -struct foo { - unsigned int __softirq_pending; - unsigned int __nmi_count; -}; - -extern struct foo me; - -#define read_pda(me) (&me) - -#endif - -- cgit v1.2.3-70-g09d2 From 46ecca8ae1540abe73000d0fb4878de6956a208f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:13:40 +0100 Subject: um: segment.h is x86-only and needed only there Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/segment.h | 10 ---------- arch/x86/um/asm/segment.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 arch/um/include/asm/segment.h create mode 100644 arch/x86/um/asm/segment.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/segment.h b/arch/um/include/asm/segment.h deleted file mode 100644 index 45183fcd10b..00000000000 --- a/arch/um/include/asm/segment.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __UM_SEGMENT_H -#define __UM_SEGMENT_H - -extern int host_gdt_entry_tls_min; - -#define GDT_ENTRY_TLS_ENTRIES 3 -#define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min -#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) - -#endif diff --git a/arch/x86/um/asm/segment.h b/arch/x86/um/asm/segment.h new file mode 100644 index 00000000000..45183fcd10b --- /dev/null +++ b/arch/x86/um/asm/segment.h @@ -0,0 +1,10 @@ +#ifndef __UM_SEGMENT_H +#define __UM_SEGMENT_H + +extern int host_gdt_entry_tls_min; + +#define GDT_ENTRY_TLS_ENTRIES 3 +#define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min +#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) + +#endif -- cgit v1.2.3-70-g09d2 From b8c655d727ebfe78769b62a0349227d5a656e967 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:13:50 +0100 Subject: um: generic ftrace.h will do... Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/Kbuild | 1 + arch/um/include/asm/ftrace.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 arch/um/include/asm/ftrace.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index 5962826ac20..451f4517b33 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild @@ -1,2 +1,3 @@ generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h +generic-y += ftrace.h diff --git a/arch/um/include/asm/ftrace.h b/arch/um/include/asm/ftrace.h deleted file mode 100644 index 40a8c178f10..00000000000 --- a/arch/um/include/asm/ftrace.h +++ /dev/null @@ -1 +0,0 @@ -/* empty */ -- cgit v1.2.3-70-g09d2 From a34978cbd977ab62c744f63daacd9dc1474482be Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:14:00 +0100 Subject: um: kill system-um.h most of it belonged in irqflags.h, actually Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/include/asm/irqflags.h | 38 +++++++++++++++++++++++++++++++++- arch/um/include/asm/system-um.h | 45 ----------------------------------------- arch/x86/um/asm/system.h | 4 +++- 3 files changed, 40 insertions(+), 47 deletions(-) delete mode 100644 arch/um/include/asm/system-um.h (limited to 'arch/um/include') diff --git a/arch/um/include/asm/irqflags.h b/arch/um/include/asm/irqflags.h index 659b9abdfdb..c780d8a1677 100644 --- a/arch/um/include/asm/irqflags.h +++ b/arch/um/include/asm/irqflags.h @@ -1,6 +1,42 @@ #ifndef __UM_IRQFLAGS_H #define __UM_IRQFLAGS_H -/* Empty for now */ +extern int get_signals(void); +extern int set_signals(int enable); +extern void block_signals(void); +extern void unblock_signals(void); + +static inline unsigned long arch_local_save_flags(void) +{ + return get_signals(); +} + +static inline void arch_local_irq_restore(unsigned long flags) +{ + set_signals(flags); +} + +static inline void arch_local_irq_enable(void) +{ + unblock_signals(); +} + +static inline void arch_local_irq_disable(void) +{ + block_signals(); +} + +static inline unsigned long arch_local_irq_save(void) +{ + unsigned long flags; + flags = arch_local_save_flags(); + arch_local_irq_disable(); + return flags; +} + +static inline bool arch_irqs_disabled(void) +{ + return arch_local_save_flags() == 0; +} #endif diff --git a/arch/um/include/asm/system-um.h b/arch/um/include/asm/system-um.h deleted file mode 100644 index 0eec2457928..00000000000 --- a/arch/um/include/asm/system-um.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __UM_SYSTEM_GENERIC_H -#define __UM_SYSTEM_GENERIC_H - -extern int get_signals(void); -extern int set_signals(int enable); -extern void block_signals(void); -extern void unblock_signals(void); - -static inline unsigned long arch_local_save_flags(void) -{ - return get_signals(); -} - -static inline void arch_local_irq_restore(unsigned long flags) -{ - set_signals(flags); -} - -static inline void arch_local_irq_enable(void) -{ - unblock_signals(); -} - -static inline void arch_local_irq_disable(void) -{ - block_signals(); -} - -static inline unsigned long arch_local_irq_save(void) -{ - unsigned long flags; - flags = arch_local_save_flags(); - arch_local_irq_disable(); - return flags; -} - -static inline bool arch_irqs_disabled(void) -{ - return arch_local_save_flags() == 0; -} - -extern void *_switch_to(void *prev, void *next, void *last); -#define switch_to(prev, next, last) prev = _switch_to(prev, next, last) - -#endif diff --git a/arch/x86/um/asm/system.h b/arch/x86/um/asm/system.h index a89113bc74f..a459fd9b759 100644 --- a/arch/x86/um/asm/system.h +++ b/arch/x86/um/asm/system.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -130,4 +129,7 @@ static inline void rdtsc_barrier(void) alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC); } +extern void *_switch_to(void *prev, void *next, void *last); +#define switch_to(prev, next, last) prev = _switch_to(prev, next, last) + #endif -- cgit v1.2.3-70-g09d2