aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/sys-x86_64')
-rw-r--r--arch/um/sys-x86_64/Makefile27
-rw-r--r--arch/um/sys-x86_64/asm/archparam.h16
-rw-r--r--arch/um/sys-x86_64/asm/elf.h132
-rw-r--r--arch/um/sys-x86_64/asm/module.h20
-rw-r--r--arch/um/sys-x86_64/asm/processor.h56
-rw-r--r--arch/um/sys-x86_64/asm/ptrace.h72
-rw-r--r--arch/um/sys-x86_64/bug.c21
-rw-r--r--arch/um/sys-x86_64/bugs.c15
-rw-r--r--arch/um/sys-x86_64/delay.c60
-rw-r--r--arch/um/sys-x86_64/fault.c28
-rw-r--r--arch/um/sys-x86_64/ksyms.c11
-rw-r--r--arch/um/sys-x86_64/mem.c26
-rw-r--r--arch/um/sys-x86_64/ptrace.c198
-rw-r--r--arch/um/sys-x86_64/ptrace_user.c22
-rw-r--r--arch/um/sys-x86_64/setjmp.S54
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/archsetjmp.h24
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/barrier.h7
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/checksum.h144
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/faultinfo.h29
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/host_ldt.h38
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h23
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/ptrace.h240
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/ptrace_user.h77
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/sc.h45
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/sigcontext.h27
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h22
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/stub.h107
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/syscalls.h33
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/system.h132
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/tls.h29
-rw-r--r--arch/um/sys-x86_64/shared/sysdep/vm-flags.h15
-rw-r--r--arch/um/sys-x86_64/signal.c290
-rw-r--r--arch/um/sys-x86_64/stub.S66
-rw-r--r--arch/um/sys-x86_64/stub_segv.c22
-rw-r--r--arch/um/sys-x86_64/syscall_table.c65
-rw-r--r--arch/um/sys-x86_64/syscalls.c102
-rw-r--r--arch/um/sys-x86_64/sysrq.c41
-rw-r--r--arch/um/sys-x86_64/tls.c17
-rw-r--r--arch/um/sys-x86_64/user-offsets.c65
-rw-r--r--arch/um/sys-x86_64/vdso/Makefile90
-rw-r--r--arch/um/sys-x86_64/vdso/checkundef.sh10
-rw-r--r--arch/um/sys-x86_64/vdso/um_vdso.c71
-rw-r--r--arch/um/sys-x86_64/vdso/vdso-layout.lds.S64
-rw-r--r--arch/um/sys-x86_64/vdso/vdso-note.S12
-rw-r--r--arch/um/sys-x86_64/vdso/vdso.S10
-rw-r--r--arch/um/sys-x86_64/vdso/vdso.lds.S32
-rw-r--r--arch/um/sys-x86_64/vdso/vma.c74
47 files changed, 0 insertions, 2781 deletions
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
deleted file mode 100644
index bd4d1d3ba919..000000000000
--- a/arch/um/sys-x86_64/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
1#
2# Copyright 2003 PathScale, Inc.
3#
4# Licensed under the GPL
5#
6
7obj-y = bug.o bugs.o delay.o fault.o ldt.o ptrace.o ptrace_user.o mem.o \
8 setjmp.o signal.o stub.o stub_segv.o syscalls.o syscall_table.o \
9 sysrq.o ksyms.o tls.o
10
11obj-y += vdso/
12
13subarch-obj-y = lib/csum-partial_64.o lib/memcpy_64.o lib/thunk_64.o \
14 lib/rwsem.o
15subarch-obj-$(CONFIG_MODULES) += kernel/module.o
16
17ldt-y = ../sys-i386/ldt.o
18
19USER_OBJS := ptrace_user.o
20
21USER_OBJS += user-offsets.s
22extra-y += user-offsets.s
23
24UNPROFILE_OBJS := stub_segv.o
25CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
26
27include arch/um/scripts/Makefile.rules
diff --git a/arch/um/sys-x86_64/asm/archparam.h b/arch/um/sys-x86_64/asm/archparam.h
deleted file mode 100644
index 6c083663b8d9..000000000000
--- a/arch/um/sys-x86_64/asm/archparam.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __UM_ARCHPARAM_X86_64_H
8#define __UM_ARCHPARAM_X86_64_H
9
10
11/* No user-accessible fixmap addresses, i.e. vsyscall */
12#define FIXADDR_USER_START 0
13#define FIXADDR_USER_END 0
14
15#endif
16
diff --git a/arch/um/sys-x86_64/asm/elf.h b/arch/um/sys-x86_64/asm/elf.h
deleted file mode 100644
index 11a2bfb38859..000000000000
--- a/arch/um/sys-x86_64/asm/elf.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 *
5 * Licensed under the GPL
6 */
7#ifndef __UM_ELF_X86_64_H
8#define __UM_ELF_X86_64_H
9
10#include <asm/user.h>
11#include "skas.h"
12
13/* x86-64 relocation types, taken from asm-x86_64/elf.h */
14#define R_X86_64_NONE 0 /* No reloc */
15#define R_X86_64_64 1 /* Direct 64 bit */
16#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
17#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
18#define R_X86_64_PLT32 4 /* 32 bit PLT address */
19#define R_X86_64_COPY 5 /* Copy symbol at runtime */
20#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
21#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
22#define R_X86_64_RELATIVE 8 /* Adjust by program base */
23#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative
24 offset to GOT */
25#define R_X86_64_32 10 /* Direct 32 bit zero extended */
26#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
27#define R_X86_64_16 12 /* Direct 16 bit zero extended */
28#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
29#define R_X86_64_8 14 /* Direct 8 bit sign extended */
30#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
31
32#define R_X86_64_NUM 16
33
34typedef unsigned long elf_greg_t;
35
36#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
37typedef elf_greg_t elf_gregset_t[ELF_NGREG];
38
39typedef struct user_i387_struct elf_fpregset_t;
40
41/*
42 * This is used to ensure we don't load something for the wrong architecture.
43 */
44#define elf_check_arch(x) \
45 ((x)->e_machine == EM_X86_64)
46
47#define ELF_CLASS ELFCLASS64
48#define ELF_DATA ELFDATA2LSB
49#define ELF_ARCH EM_X86_64
50
51#define ELF_PLAT_INIT(regs, load_addr) do { \
52 PT_REGS_RBX(regs) = 0; \
53 PT_REGS_RCX(regs) = 0; \
54 PT_REGS_RDX(regs) = 0; \
55 PT_REGS_RSI(regs) = 0; \
56 PT_REGS_RDI(regs) = 0; \
57 PT_REGS_RBP(regs) = 0; \
58 PT_REGS_RAX(regs) = 0; \
59 PT_REGS_R8(regs) = 0; \
60 PT_REGS_R9(regs) = 0; \
61 PT_REGS_R10(regs) = 0; \
62 PT_REGS_R11(regs) = 0; \
63 PT_REGS_R12(regs) = 0; \
64 PT_REGS_R13(regs) = 0; \
65 PT_REGS_R14(regs) = 0; \
66 PT_REGS_R15(regs) = 0; \
67} while (0)
68
69#define ELF_CORE_COPY_REGS(pr_reg, _regs) \
70 (pr_reg)[0] = (_regs)->regs.gp[0]; \
71 (pr_reg)[1] = (_regs)->regs.gp[1]; \
72 (pr_reg)[2] = (_regs)->regs.gp[2]; \
73 (pr_reg)[3] = (_regs)->regs.gp[3]; \
74 (pr_reg)[4] = (_regs)->regs.gp[4]; \
75 (pr_reg)[5] = (_regs)->regs.gp[5]; \
76 (pr_reg)[6] = (_regs)->regs.gp[6]; \
77 (pr_reg)[7] = (_regs)->regs.gp[7]; \
78 (pr_reg)[8] = (_regs)->regs.gp[8]; \
79 (pr_reg)[9] = (_regs)->regs.gp[9]; \
80 (pr_reg)[10] = (_regs)->regs.gp[10]; \
81 (pr_reg)[11] = (_regs)->regs.gp[11]; \
82 (pr_reg)[12] = (_regs)->regs.gp[12]; \
83 (pr_reg)[13] = (_regs)->regs.gp[13]; \
84 (pr_reg)[14] = (_regs)->regs.gp[14]; \
85 (pr_reg)[15] = (_regs)->regs.gp[15]; \
86 (pr_reg)[16] = (_regs)->regs.gp[16]; \
87 (pr_reg)[17] = (_regs)->regs.gp[17]; \
88 (pr_reg)[18] = (_regs)->regs.gp[18]; \
89 (pr_reg)[19] = (_regs)->regs.gp[19]; \
90 (pr_reg)[20] = (_regs)->regs.gp[20]; \
91 (pr_reg)[21] = current->thread.arch.fs; \
92 (pr_reg)[22] = 0; \
93 (pr_reg)[23] = 0; \
94 (pr_reg)[24] = 0; \
95 (pr_reg)[25] = 0; \
96 (pr_reg)[26] = 0;
97
98#define task_pt_regs(t) (&(t)->thread.regs)
99
100struct task_struct;
101
102extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu);
103
104#define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu)
105
106#ifdef TIF_IA32 /* XXX */
107#error XXX, indeed
108 clear_thread_flag(TIF_IA32);
109#endif
110
111#define ELF_EXEC_PAGESIZE 4096
112
113#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
114
115extern long elf_aux_hwcap;
116#define ELF_HWCAP (elf_aux_hwcap)
117
118#define ELF_PLATFORM "x86_64"
119
120#define SET_PERSONALITY(ex) do ; while(0)
121
122#define __HAVE_ARCH_GATE_AREA 1
123#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
124struct linux_binprm;
125extern int arch_setup_additional_pages(struct linux_binprm *bprm,
126 int uses_interp);
127
128extern unsigned long um_vdso_addr;
129#define AT_SYSINFO_EHDR 33
130#define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)
131
132#endif
diff --git a/arch/um/sys-x86_64/asm/module.h b/arch/um/sys-x86_64/asm/module.h
deleted file mode 100644
index 8eb79c2d07d5..000000000000
--- a/arch/um/sys-x86_64/asm/module.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __UM_MODULE_X86_64_H
8#define __UM_MODULE_X86_64_H
9
10/* UML is simple */
11struct mod_arch_specific
12{
13};
14
15#define Elf_Shdr Elf64_Shdr
16#define Elf_Sym Elf64_Sym
17#define Elf_Ehdr Elf64_Ehdr
18
19#endif
20
diff --git a/arch/um/sys-x86_64/asm/processor.h b/arch/um/sys-x86_64/asm/processor.h
deleted file mode 100644
index 875a26a62614..000000000000
--- a/arch/um/sys-x86_64/asm/processor.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __UM_PROCESSOR_X86_64_H
8#define __UM_PROCESSOR_X86_64_H
9
10/* include faultinfo structure */
11#include "sysdep/faultinfo.h"
12
13struct arch_thread {
14 unsigned long debugregs[8];
15 int debugregs_seq;
16 unsigned long fs;
17 struct faultinfo faultinfo;
18};
19
20/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
21static inline void rep_nop(void)
22{
23 __asm__ __volatile__("rep;nop": : :"memory");
24}
25
26#define cpu_relax() rep_nop()
27
28#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \
29 .debugregs_seq = 0, \
30 .fs = 0, \
31 .faultinfo = { 0, 0, 0 } }
32
33static inline void arch_flush_thread(struct arch_thread *thread)
34{
35}
36
37static inline void arch_copy_thread(struct arch_thread *from,
38 struct arch_thread *to)
39{
40 to->fs = from->fs;
41}
42
43#include <asm/user.h>
44
45#define current_text_addr() \
46 ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
47
48#define ARCH_IS_STACKGROW(address) \
49 (address + 128 >= UPT_SP(&current->thread.regs.regs))
50
51#define KSTK_EIP(tsk) KSTK_REG(tsk, RIP)
52#define KSTK_ESP(tsk) KSTK_REG(tsk, RSP)
53
54#include "asm/processor-generic.h"
55
56#endif
diff --git a/arch/um/sys-x86_64/asm/ptrace.h b/arch/um/sys-x86_64/asm/ptrace.h
deleted file mode 100644
index 83d8c473b905..000000000000
--- a/arch/um/sys-x86_64/asm/ptrace.h
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __UM_PTRACE_X86_64_H
8#define __UM_PTRACE_X86_64_H
9
10#include "linux/compiler.h"
11#include "asm/errno.h"
12
13#define __FRAME_OFFSETS /* Needed to get the R* macros */
14#include "asm/ptrace-generic.h"
15
16#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
17
18#define PT_REGS_RBX(r) UPT_RBX(&(r)->regs)
19#define PT_REGS_RCX(r) UPT_RCX(&(r)->regs)
20#define PT_REGS_RDX(r) UPT_RDX(&(r)->regs)
21#define PT_REGS_RSI(r) UPT_RSI(&(r)->regs)
22#define PT_REGS_RDI(r) UPT_RDI(&(r)->regs)
23#define PT_REGS_RBP(r) UPT_RBP(&(r)->regs)
24#define PT_REGS_RAX(r) UPT_RAX(&(r)->regs)
25#define PT_REGS_R8(r) UPT_R8(&(r)->regs)
26#define PT_REGS_R9(r) UPT_R9(&(r)->regs)
27#define PT_REGS_R10(r) UPT_R10(&(r)->regs)
28#define PT_REGS_R11(r) UPT_R11(&(r)->regs)
29#define PT_REGS_R12(r) UPT_R12(&(r)->regs)
30#define PT_REGS_R13(r) UPT_R13(&(r)->regs)
31#define PT_REGS_R14(r) UPT_R14(&(r)->regs)
32#define PT_REGS_R15(r) UPT_R15(&(r)->regs)
33
34#define PT_REGS_FS(r) UPT_FS(&(r)->regs)
35#define PT_REGS_GS(r) UPT_GS(&(r)->regs)
36#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
37#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
38#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
39#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
40
41#define PT_REGS_ORIG_RAX(r) UPT_ORIG_RAX(&(r)->regs)
42#define PT_REGS_RIP(r) UPT_IP(&(r)->regs)
43#define PT_REGS_RSP(r) UPT_SP(&(r)->regs)
44
45#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
46
47/* XXX */
48#define user_mode(r) UPT_IS_USER(&(r)->regs)
49#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_RAX(r)
50#define PT_REGS_SYSCALL_RET(r) PT_REGS_RAX(r)
51
52#define PT_FIX_EXEC_STACK(sp) do ; while(0)
53
54#define profile_pc(regs) PT_REGS_IP(regs)
55
56struct user_desc;
57
58static inline int ptrace_get_thread_area(struct task_struct *child, int idx,
59 struct user_desc __user *user_desc)
60{
61 return -ENOSYS;
62}
63
64static inline int ptrace_set_thread_area(struct task_struct *child, int idx,
65 struct user_desc __user *user_desc)
66{
67 return -ENOSYS;
68}
69
70extern long arch_prctl(struct task_struct *task, int code,
71 unsigned long __user *addr);
72#endif
diff --git a/arch/um/sys-x86_64/bug.c b/arch/um/sys-x86_64/bug.c
deleted file mode 100644
index e8034e363d83..000000000000
--- a/arch/um/sys-x86_64/bug.c
+++ /dev/null
@@ -1,21 +0,0 @@
1/*
2 * Copyright (C) 2006 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL V2
4 */
5
6#include <linux/uaccess.h>
7
8/*
9 * Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
10 * that's not relevant in skas mode.
11 */
12
13int is_valid_bugaddr(unsigned long eip)
14{
15 unsigned short ud2;
16
17 if (probe_kernel_address((unsigned short __user *)eip, ud2))
18 return 0;
19
20 return ud2 == 0x0b0f;
21}
diff --git a/arch/um/sys-x86_64/bugs.c b/arch/um/sys-x86_64/bugs.c
deleted file mode 100644
index 44e02ba2a265..000000000000
--- a/arch/um/sys-x86_64/bugs.c
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#include "sysdep/ptrace.h"
8
9void arch_check_bugs(void)
10{
11}
12
13void arch_examine_signal(int sig, struct uml_pt_regs *regs)
14{
15}
diff --git a/arch/um/sys-x86_64/delay.c b/arch/um/sys-x86_64/delay.c
deleted file mode 100644
index f3fe1a688f7e..000000000000
--- a/arch/um/sys-x86_64/delay.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
3 * Mostly copied from arch/x86/lib/delay.c
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/delay.h>
13#include <asm/param.h>
14
15void __delay(unsigned long loops)
16{
17 asm volatile(
18 "test %0,%0\n"
19 "jz 3f\n"
20 "jmp 1f\n"
21
22 ".align 16\n"
23 "1: jmp 2f\n"
24
25 ".align 16\n"
26 "2: dec %0\n"
27 " jnz 2b\n"
28 "3: dec %0\n"
29
30 : /* we don't need output */
31 : "a" (loops)
32 );
33}
34EXPORT_SYMBOL(__delay);
35
36inline void __const_udelay(unsigned long xloops)
37{
38 int d0;
39
40 xloops *= 4;
41 asm("mull %%edx"
42 : "=d" (xloops), "=&a" (d0)
43 : "1" (xloops), "0"
44 (loops_per_jiffy * (HZ/4)));
45
46 __delay(++xloops);
47}
48EXPORT_SYMBOL(__const_udelay);
49
50void __udelay(unsigned long usecs)
51{
52 __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
53}
54EXPORT_SYMBOL(__udelay);
55
56void __ndelay(unsigned long nsecs)
57{
58 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
59}
60EXPORT_SYMBOL(__ndelay);
diff --git a/arch/um/sys-x86_64/fault.c b/arch/um/sys-x86_64/fault.c
deleted file mode 100644
index ce85117fc64e..000000000000
--- a/arch/um/sys-x86_64/fault.c
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#include "sysdep/ptrace.h"
8
9/* These two are from asm-um/uaccess.h and linux/module.h, check them. */
10struct exception_table_entry
11{
12 unsigned long insn;
13 unsigned long fixup;
14};
15
16const struct exception_table_entry *search_exception_tables(unsigned long add);
17
18int arch_fixup(unsigned long address, struct uml_pt_regs *regs)
19{
20 const struct exception_table_entry *fixup;
21
22 fixup = search_exception_tables(address);
23 if (fixup != 0) {
24 UPT_IP(regs) = fixup->fixup;
25 return 1;
26 }
27 return 0;
28}
diff --git a/arch/um/sys-x86_64/ksyms.c b/arch/um/sys-x86_64/ksyms.c
deleted file mode 100644
index 1db2fce00948..000000000000
--- a/arch/um/sys-x86_64/ksyms.c
+++ /dev/null
@@ -1,11 +0,0 @@
1#include <linux/module.h>
2#include <asm/string.h>
3#include <asm/checksum.h>
4
5/*XXX: we need them because they would be exported by x86_64 */
6#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
7EXPORT_SYMBOL(memcpy);
8#else
9EXPORT_SYMBOL(__memcpy);
10#endif
11EXPORT_SYMBOL(csum_partial);
diff --git a/arch/um/sys-x86_64/mem.c b/arch/um/sys-x86_64/mem.c
deleted file mode 100644
index 546518727a73..000000000000
--- a/arch/um/sys-x86_64/mem.c
+++ /dev/null
@@ -1,26 +0,0 @@
1#include "linux/mm.h"
2#include "asm/page.h"
3#include "asm/mman.h"
4
5const char *arch_vma_name(struct vm_area_struct *vma)
6{
7 if (vma->vm_mm && vma->vm_start == um_vdso_addr)
8 return "[vdso]";
9
10 return NULL;
11}
12
13struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
14{
15 return NULL;
16}
17
18int in_gate_area(struct mm_struct *mm, unsigned long addr)
19{
20 return 0;
21}
22
23int in_gate_area_no_mm(unsigned long addr)
24{
25 return 0;
26}
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
deleted file mode 100644
index 4005506834fd..000000000000
--- a/arch/um/sys-x86_64/ptrace.c
+++ /dev/null
@@ -1,198 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 *
5 * Licensed under the GPL
6 */
7
8#include <linux/mm.h>
9#include <linux/sched.h>
10#include <linux/errno.h>
11#define __FRAME_OFFSETS
12#include <asm/ptrace.h>
13#include <asm/uaccess.h>
14
15/*
16 * determines which flags the user has access to.
17 * 1 = access 0 = no access
18 */
19#define FLAG_MASK 0x44dd5UL
20
21int putreg(struct task_struct *child, int regno, unsigned long value)
22{
23 unsigned long tmp;
24
25#ifdef TIF_IA32
26 /*
27 * Some code in the 64bit emulation may not be 64bit clean.
28 * Don't take any chances.
29 */
30 if (test_tsk_thread_flag(child, TIF_IA32))
31 value &= 0xffffffff;
32#endif
33 switch (regno) {
34 case FS:
35 case GS:
36 case DS:
37 case ES:
38 case SS:
39 case CS:
40 if (value && (value & 3) != 3)
41 return -EIO;
42 value &= 0xffff;
43 break;
44
45 case FS_BASE:
46 case GS_BASE:
47 if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
48 return -EIO;
49 break;
50
51 case EFLAGS:
52 value &= FLAG_MASK;
53 tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK;
54 value |= tmp;
55 break;
56 }
57
58 PT_REGS_SET(&child->thread.regs, regno, value);
59 return 0;
60}
61
62int poke_user(struct task_struct *child, long addr, long data)
63{
64 if ((addr & 3) || addr < 0)
65 return -EIO;
66
67 if (addr < MAX_REG_OFFSET)
68 return putreg(child, addr, data);
69 else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
70 (addr <= offsetof(struct user, u_debugreg[7]))) {
71 addr -= offsetof(struct user, u_debugreg[0]);
72 addr = addr >> 2;
73 if ((addr == 4) || (addr == 5))
74 return -EIO;
75 child->thread.arch.debugregs[addr] = data;
76 return 0;
77 }
78 return -EIO;
79}
80
81unsigned long getreg(struct task_struct *child, int regno)
82{
83 unsigned long retval = ~0UL;
84 switch (regno) {
85 case FS:
86 case GS:
87 case DS:
88 case ES:
89 case SS:
90 case CS:
91 retval = 0xffff;
92 /* fall through */
93 default:
94 retval &= PT_REG(&child->thread.regs, regno);
95#ifdef TIF_IA32
96 if (test_tsk_thread_flag(child, TIF_IA32))
97 retval &= 0xffffffff;
98#endif
99 }
100 return retval;
101}
102
103int peek_user(struct task_struct *child, long addr, long data)
104{
105 /* read the word at location addr in the USER area. */
106 unsigned long tmp;
107
108 if ((addr & 3) || addr < 0)
109 return -EIO;
110
111 tmp = 0; /* Default return condition */
112 if (addr < MAX_REG_OFFSET)
113 tmp = getreg(child, addr);
114 else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
115 (addr <= offsetof(struct user, u_debugreg[7]))) {
116 addr -= offsetof(struct user, u_debugreg[0]);
117 addr = addr >> 2;
118 tmp = child->thread.arch.debugregs[addr];
119 }
120 return put_user(tmp, (unsigned long *) data);
121}
122
123/* XXX Mostly copied from sys-i386 */
124int is_syscall(unsigned long addr)
125{
126 unsigned short instr;
127 int n;
128
129 n = copy_from_user(&instr, (void __user *) addr, sizeof(instr));
130 if (n) {
131 /*
132 * access_process_vm() grants access to vsyscall and stub,
133 * while copy_from_user doesn't. Maybe access_process_vm is
134 * slow, but that doesn't matter, since it will be called only
135 * in case of singlestepping, if copy_from_user failed.
136 */
137 n = access_process_vm(current, addr, &instr, sizeof(instr), 0);
138 if (n != sizeof(instr)) {
139 printk("is_syscall : failed to read instruction from "
140 "0x%lx\n", addr);
141 return 1;
142 }
143 }
144 /* sysenter */
145 return instr == 0x050f;
146}
147
148static int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
149{
150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
151 long fpregs[HOST_FP_SIZE];
152
153 BUG_ON(sizeof(*buf) != sizeof(fpregs));
154 err = save_fp_registers(userspace_pid[cpu], fpregs);
155 if (err)
156 return err;
157
158 n = copy_to_user(buf, fpregs, sizeof(fpregs));
159 if (n > 0)
160 return -EFAULT;
161
162 return n;
163}
164
165static int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
166{
167 int n, cpu = ((struct thread_info *) child->stack)->cpu;
168 long fpregs[HOST_FP_SIZE];
169
170 BUG_ON(sizeof(*buf) != sizeof(fpregs));
171 n = copy_from_user(fpregs, buf, sizeof(fpregs));
172 if (n > 0)
173 return -EFAULT;
174
175 return restore_fp_registers(userspace_pid[cpu], fpregs);
176}
177
178long subarch_ptrace(struct task_struct *child, long request,
179 unsigned long addr, unsigned long data)
180{
181 int ret = -EIO;
182 void __user *datap = (void __user *) data;
183
184 switch (request) {
185 case PTRACE_GETFPREGS: /* Get the child FPU state. */
186 ret = get_fpregs(datap, child);
187 break;
188 case PTRACE_SETFPREGS: /* Set the child FPU state. */
189 ret = set_fpregs(datap, child);
190 break;
191 case PTRACE_ARCH_PRCTL:
192 /* XXX Calls ptrace on the host - needs some SMP thinking */
193 ret = arch_prctl(child, data, (void __user *) addr);
194 break;
195 }
196
197 return ret;
198}
diff --git a/arch/um/sys-x86_64/ptrace_user.c b/arch/um/sys-x86_64/ptrace_user.c
deleted file mode 100644
index c57a496d3f5b..000000000000
--- a/arch/um/sys-x86_64/ptrace_user.c
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#include <errno.h>
8#include "ptrace_user.h"
9
10int ptrace_getregs(long pid, unsigned long *regs_out)
11{
12 if (ptrace(PTRACE_GETREGS, pid, 0, regs_out) < 0)
13 return -errno;
14 return(0);
15}
16
17int ptrace_setregs(long pid, unsigned long *regs_out)
18{
19 if (ptrace(PTRACE_SETREGS, pid, 0, regs_out) < 0)
20 return -errno;
21 return(0);
22}
diff --git a/arch/um/sys-x86_64/setjmp.S b/arch/um/sys-x86_64/setjmp.S
deleted file mode 100644
index 45f547b4043e..000000000000
--- a/arch/um/sys-x86_64/setjmp.S
+++ /dev/null
@@ -1,54 +0,0 @@
1#
2# arch/x86_64/setjmp.S
3#
4# setjmp/longjmp for the x86-64 architecture
5#
6
7#
8# The jmp_buf is assumed to contain the following, in order:
9# %rbx
10# %rsp (post-return)
11# %rbp
12# %r12
13# %r13
14# %r14
15# %r15
16# <return address>
17#
18
19 .text
20 .align 4
21 .globl setjmp
22 .type setjmp, @function
23setjmp:
24 pop %rsi # Return address, and adjust the stack
25 xorl %eax,%eax # Return value
26 movq %rbx,(%rdi)
27 movq %rsp,8(%rdi) # Post-return %rsp!
28 push %rsi # Make the call/return stack happy
29 movq %rbp,16(%rdi)
30 movq %r12,24(%rdi)
31 movq %r13,32(%rdi)
32 movq %r14,40(%rdi)
33 movq %r15,48(%rdi)
34 movq %rsi,56(%rdi) # Return address
35 ret
36
37 .size setjmp,.-setjmp
38
39 .text
40 .align 4
41 .globl longjmp
42 .type longjmp, @function
43longjmp:
44 movl %esi,%eax # Return value (int)
45 movq (%rdi),%rbx
46 movq 8(%rdi),%rsp
47 movq 16(%rdi),%rbp
48 movq 24(%rdi),%r12
49 movq 32(%rdi),%r13
50 movq 40(%rdi),%r14
51 movq 48(%rdi),%r15
52 jmp *56(%rdi)
53
54 .size longjmp,.-longjmp
diff --git a/arch/um/sys-x86_64/shared/sysdep/archsetjmp.h b/arch/um/sys-x86_64/shared/sysdep/archsetjmp.h
deleted file mode 100644
index 2af8f12ca161..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/archsetjmp.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * arch/um/include/sysdep-x86_64/archsetjmp.h
3 */
4
5#ifndef _KLIBC_ARCHSETJMP_H
6#define _KLIBC_ARCHSETJMP_H
7
8struct __jmp_buf {
9 unsigned long __rbx;
10 unsigned long __rsp;
11 unsigned long __rbp;
12 unsigned long __r12;
13 unsigned long __r13;
14 unsigned long __r14;
15 unsigned long __r15;
16 unsigned long __rip;
17};
18
19typedef struct __jmp_buf jmp_buf[1];
20
21#define JB_IP __rip
22#define JB_SP __rsp
23
24#endif /* _SETJMP_H */
diff --git a/arch/um/sys-x86_64/shared/sysdep/barrier.h b/arch/um/sys-x86_64/shared/sysdep/barrier.h
deleted file mode 100644
index 7b610befdc8f..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/barrier.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __SYSDEP_X86_64_BARRIER_H
2#define __SYSDEP_X86_64_BARRIER_H
3
4/* Copied from include/asm-x86_64 for use by userspace. */
5#define mb() asm volatile("mfence":::"memory")
6
7#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 a5be9031ea85..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/checksum.h
+++ /dev/null
@@ -1,144 +0,0 @@
1/*
2 * Licensed under the GPL
3 */
4
5#ifndef __UM_SYSDEP_CHECKSUM_H
6#define __UM_SYSDEP_CHECKSUM_H
7
8#include "linux/string.h"
9#include "linux/in6.h"
10#include "asm/uaccess.h"
11
12extern __wsum csum_partial(const void *buff, int len, __wsum sum);
13
14/*
15 * Note: when you get a NULL pointer exception here this means someone
16 * passed in an incorrect kernel address to one of these functions.
17 *
18 * If you use these functions directly please don't forget the
19 * access_ok().
20 */
21
22static __inline__
23__wsum csum_partial_copy_nocheck(const void *src, void *dst,
24 int len, __wsum sum)
25{
26 memcpy(dst, src, len);
27 return(csum_partial(dst, len, sum));
28}
29
30static __inline__
31__wsum csum_partial_copy_from_user(const void __user *src,
32 void *dst, int len, __wsum sum,
33 int *err_ptr)
34{
35 if (copy_from_user(dst, src, len)) {
36 *err_ptr = -EFAULT;
37 return (__force __wsum)-1;
38 }
39 return csum_partial(dst, len, sum);
40}
41
42/**
43 * csum_fold - Fold and invert a 32bit checksum.
44 * sum: 32bit unfolded sum
45 *
46 * Fold a 32bit running checksum to 16bit and invert it. This is usually
47 * the last step before putting a checksum into a packet.
48 * Make sure not to mix with 64bit checksums.
49 */
50static inline __sum16 csum_fold(__wsum sum)
51{
52 __asm__(
53 " addl %1,%0\n"
54 " adcl $0xffff,%0"
55 : "=r" (sum)
56 : "r" ((__force u32)sum << 16),
57 "0" ((__force u32)sum & 0xffff0000)
58 );
59 return (__force __sum16)(~(__force u32)sum >> 16);
60}
61
62/**
63 * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum.
64 * @saddr: source address
65 * @daddr: destination address
66 * @len: length of packet
67 * @proto: ip protocol of packet
68 * @sum: initial sum to be added in (32bit unfolded)
69 *
70 * Returns the pseudo header checksum the input data. Result is
71 * 32bit unfolded.
72 */
73static inline __wsum
74csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
75 unsigned short proto, __wsum sum)
76{
77 asm(" addl %1, %0\n"
78 " adcl %2, %0\n"
79 " adcl %3, %0\n"
80 " adcl $0, %0\n"
81 : "=r" (sum)
82 : "g" (daddr), "g" (saddr), "g" ((len + proto) << 8), "0" (sum));
83 return sum;
84}
85
86/*
87 * computes the checksum of the TCP/UDP pseudo-header
88 * returns a 16-bit checksum, already complemented
89 */
90static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
91 unsigned short len,
92 unsigned short proto,
93 __wsum sum)
94{
95 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
96}
97
98/**
99 * ip_fast_csum - Compute the IPv4 header checksum efficiently.
100 * iph: ipv4 header
101 * ihl: length of header / 4
102 */
103static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
104{
105 unsigned int sum;
106
107 asm( " movl (%1), %0\n"
108 " subl $4, %2\n"
109 " jbe 2f\n"
110 " addl 4(%1), %0\n"
111 " adcl 8(%1), %0\n"
112 " adcl 12(%1), %0\n"
113 "1: adcl 16(%1), %0\n"
114 " lea 4(%1), %1\n"
115 " decl %2\n"
116 " jne 1b\n"
117 " adcl $0, %0\n"
118 " movl %0, %2\n"
119 " shrl $16, %0\n"
120 " addw %w2, %w0\n"
121 " adcl $0, %0\n"
122 " notl %0\n"
123 "2:"
124 /* Since the input registers which are loaded with iph and ipl
125 are modified, we must also specify them as outputs, or gcc
126 will assume they contain their original values. */
127 : "=r" (sum), "=r" (iph), "=r" (ihl)
128 : "1" (iph), "2" (ihl)
129 : "memory");
130 return (__force __sum16)sum;
131}
132
133static inline unsigned add32_with_carry(unsigned a, unsigned b)
134{
135 asm("addl %2,%0\n\t"
136 "adcl $0,%0"
137 : "=r" (a)
138 : "0" (a), "r" (b));
139 return a;
140}
141
142extern __sum16 ip_compute_csum(const void *buff, int len);
143
144#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/faultinfo.h b/arch/um/sys-x86_64/shared/sysdep/faultinfo.h
deleted file mode 100644
index cb917b0d5660..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/faultinfo.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
4 * Licensed under the GPL
5 */
6
7#ifndef __FAULTINFO_X86_64_H
8#define __FAULTINFO_X86_64_H
9
10/* this structure contains the full arch-specific faultinfo
11 * from the traps.
12 * On i386, ptrace_faultinfo unfortunately doesn't provide
13 * all the info, since trap_no is missing.
14 * All common elements are defined at the same position in
15 * both structures, thus making it easy to copy the
16 * contents without knowledge about the structure elements.
17 */
18struct faultinfo {
19 int error_code; /* in ptrace_faultinfo misleadingly called is_write */
20 unsigned long cr2; /* in ptrace_faultinfo called addr */
21 int trap_no; /* missing in ptrace_faultinfo */
22};
23
24#define FAULT_WRITE(fi) ((fi).error_code & 2)
25#define FAULT_ADDRESS(fi) ((fi).cr2)
26
27#define PTRACE_FULL_FAULTINFO 1
28
29#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/host_ldt.h b/arch/um/sys-x86_64/shared/sysdep/host_ldt.h
deleted file mode 100644
index e8b1be1e154f..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/host_ldt.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef __ASM_HOST_LDT_X86_64_H
2#define __ASM_HOST_LDT_X86_64_H
3
4#include <asm/ldt.h>
5
6/*
7 * macros stolen from include/asm-x86_64/desc.h
8 */
9#define LDT_entry_a(info) \
10 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
11
12/* Don't allow setting of the lm bit. It is useless anyways because
13 * 64bit system calls require __USER_CS. */
14#define LDT_entry_b(info) \
15 (((info)->base_addr & 0xff000000) | \
16 (((info)->base_addr & 0x00ff0000) >> 16) | \
17 ((info)->limit & 0xf0000) | \
18 (((info)->read_exec_only ^ 1) << 9) | \
19 ((info)->contents << 10) | \
20 (((info)->seg_not_present ^ 1) << 15) | \
21 ((info)->seg_32bit << 22) | \
22 ((info)->limit_in_pages << 23) | \
23 ((info)->useable << 20) | \
24 /* ((info)->lm << 21) | */ \
25 0x7000)
26
27#define LDT_empty(info) (\
28 (info)->base_addr == 0 && \
29 (info)->limit == 0 && \
30 (info)->contents == 0 && \
31 (info)->read_exec_only == 1 && \
32 (info)->seg_32bit == 0 && \
33 (info)->limit_in_pages == 0 && \
34 (info)->seg_not_present == 1 && \
35 (info)->useable == 0 && \
36 (info)->lm == 0)
37
38#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h b/arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h
deleted file mode 100644
index a307237b7964..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#include <linux/stddef.h>
2#include <linux/sched.h>
3#include <linux/time.h>
4#include <linux/elf.h>
5#include <linux/crypto.h>
6#include <asm/page.h>
7#include <asm/mman.h>
8
9#define DEFINE(sym, val) \
10 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
11
12#define DEFINE_STR1(x) #x
13#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : )
14
15#define BLANK() asm volatile("\n->" : : )
16
17#define OFFSET(sym, str, mem) \
18 DEFINE(sym, offsetof(struct str, mem));
19
20void foo(void)
21{
22#include <common-offsets.h>
23}
diff --git a/arch/um/sys-x86_64/shared/sysdep/ptrace.h b/arch/um/sys-x86_64/shared/sysdep/ptrace.h
deleted file mode 100644
index 8ee8f8e12af1..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/ptrace.h
+++ /dev/null
@@ -1,240 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 *
5 * Licensed under the GPL
6 */
7
8#ifndef __SYSDEP_X86_64_PTRACE_H
9#define __SYSDEP_X86_64_PTRACE_H
10
11#include "user_constants.h"
12#include "sysdep/faultinfo.h"
13
14#define MAX_REG_OFFSET (UM_FRAME_SIZE)
15#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
16
17#include "skas_ptregs.h"
18
19#define REGS_IP(r) ((r)[HOST_IP])
20#define REGS_SP(r) ((r)[HOST_SP])
21
22#define REGS_RBX(r) ((r)[HOST_RBX])
23#define REGS_RCX(r) ((r)[HOST_RCX])
24#define REGS_RDX(r) ((r)[HOST_RDX])
25#define REGS_RSI(r) ((r)[HOST_RSI])
26#define REGS_RDI(r) ((r)[HOST_RDI])
27#define REGS_RBP(r) ((r)[HOST_RBP])
28#define REGS_RAX(r) ((r)[HOST_RAX])
29#define REGS_R8(r) ((r)[HOST_R8])
30#define REGS_R9(r) ((r)[HOST_R9])
31#define REGS_R10(r) ((r)[HOST_R10])
32#define REGS_R11(r) ((r)[HOST_R11])
33#define REGS_R12(r) ((r)[HOST_R12])
34#define REGS_R13(r) ((r)[HOST_R13])
35#define REGS_R14(r) ((r)[HOST_R14])
36#define REGS_R15(r) ((r)[HOST_R15])
37#define REGS_CS(r) ((r)[HOST_CS])
38#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
39#define REGS_SS(r) ((r)[HOST_SS])
40
41#define HOST_FS_BASE 21
42#define HOST_GS_BASE 22
43#define HOST_DS 23
44#define HOST_ES 24
45#define HOST_FS 25
46#define HOST_GS 26
47
48/* Also defined in asm/ptrace-x86_64.h, but not in libc headers. So, these
49 * are already defined for kernel code, but not for userspace code.
50 */
51#ifndef FS_BASE
52/* These aren't defined in ptrace.h, but exist in struct user_regs_struct,
53 * which is what x86_64 ptrace actually uses.
54 */
55#define FS_BASE (HOST_FS_BASE * sizeof(long))
56#define GS_BASE (HOST_GS_BASE * sizeof(long))
57#define DS (HOST_DS * sizeof(long))
58#define ES (HOST_ES * sizeof(long))
59#define FS (HOST_FS * sizeof(long))
60#define GS (HOST_GS * sizeof(long))
61#endif
62
63#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
64#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
65#define REGS_DS(r) ((r)[HOST_DS])
66#define REGS_ES(r) ((r)[HOST_ES])
67#define REGS_FS(r) ((r)[HOST_FS])
68#define REGS_GS(r) ((r)[HOST_GS])
69
70#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_RAX])
71
72#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
73
74#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
75
76#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
77
78#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
79
80#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
81
82#define REGS_TRAP(r) ((r)->trap_type)
83
84#define REGS_ERR(r) ((r)->fault_type)
85
86struct uml_pt_regs {
87 unsigned long gp[MAX_REG_NR];
88 unsigned long fp[HOST_FP_SIZE];
89 struct faultinfo faultinfo;
90 long syscall;
91 int is_user;
92};
93
94#define EMPTY_UML_PT_REGS { }
95
96#define UPT_RBX(r) REGS_RBX((r)->gp)
97#define UPT_RCX(r) REGS_RCX((r)->gp)
98#define UPT_RDX(r) REGS_RDX((r)->gp)
99#define UPT_RSI(r) REGS_RSI((r)->gp)
100#define UPT_RDI(r) REGS_RDI((r)->gp)
101#define UPT_RBP(r) REGS_RBP((r)->gp)
102#define UPT_RAX(r) REGS_RAX((r)->gp)
103#define UPT_R8(r) REGS_R8((r)->gp)
104#define UPT_R9(r) REGS_R9((r)->gp)
105#define UPT_R10(r) REGS_R10((r)->gp)
106#define UPT_R11(r) REGS_R11((r)->gp)
107#define UPT_R12(r) REGS_R12((r)->gp)
108#define UPT_R13(r) REGS_R13((r)->gp)
109#define UPT_R14(r) REGS_R14((r)->gp)
110#define UPT_R15(r) REGS_R15((r)->gp)
111#define UPT_CS(r) REGS_CS((r)->gp)
112#define UPT_FS_BASE(r) REGS_FS_BASE((r)->gp)
113#define UPT_FS(r) REGS_FS((r)->gp)
114#define UPT_GS_BASE(r) REGS_GS_BASE((r)->gp)
115#define UPT_GS(r) REGS_GS((r)->gp)
116#define UPT_DS(r) REGS_DS((r)->gp)
117#define UPT_ES(r) REGS_ES((r)->gp)
118#define UPT_CS(r) REGS_CS((r)->gp)
119#define UPT_SS(r) REGS_SS((r)->gp)
120#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->gp)
121
122#define UPT_IP(r) REGS_IP((r)->gp)
123#define UPT_SP(r) REGS_SP((r)->gp)
124
125#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
126#define UPT_SYSCALL_NR(r) ((r)->syscall)
127#define UPT_SYSCALL_RET(r) UPT_RAX(r)
128
129extern int user_context(unsigned long sp);
130
131#define UPT_IS_USER(r) ((r)->is_user)
132
133#define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
134#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
135#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
136#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
137#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
138#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
139
140struct syscall_args {
141 unsigned long args[6];
142};
143
144#define SYSCALL_ARGS(r) ((struct syscall_args) \
145 { .args = { UPT_SYSCALL_ARG1(r), \
146 UPT_SYSCALL_ARG2(r), \
147 UPT_SYSCALL_ARG3(r), \
148 UPT_SYSCALL_ARG4(r), \
149 UPT_SYSCALL_ARG5(r), \
150 UPT_SYSCALL_ARG6(r) } } )
151
152#define UPT_REG(regs, reg) \
153 ({ unsigned long val; \
154 switch(reg){ \
155 case R8: val = UPT_R8(regs); break; \
156 case R9: val = UPT_R9(regs); break; \
157 case R10: val = UPT_R10(regs); break; \
158 case R11: val = UPT_R11(regs); break; \
159 case R12: val = UPT_R12(regs); break; \
160 case R13: val = UPT_R13(regs); break; \
161 case R14: val = UPT_R14(regs); break; \
162 case R15: val = UPT_R15(regs); break; \
163 case RIP: val = UPT_IP(regs); break; \
164 case RSP: val = UPT_SP(regs); break; \
165 case RAX: val = UPT_RAX(regs); break; \
166 case RBX: val = UPT_RBX(regs); break; \
167 case RCX: val = UPT_RCX(regs); break; \
168 case RDX: val = UPT_RDX(regs); break; \
169 case RSI: val = UPT_RSI(regs); break; \
170 case RDI: val = UPT_RDI(regs); break; \
171 case RBP: val = UPT_RBP(regs); break; \
172 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
173 case CS: val = UPT_CS(regs); break; \
174 case SS: val = UPT_SS(regs); break; \
175 case FS_BASE: val = UPT_FS_BASE(regs); break; \
176 case GS_BASE: val = UPT_GS_BASE(regs); break; \
177 case DS: val = UPT_DS(regs); break; \
178 case ES: val = UPT_ES(regs); break; \
179 case FS : val = UPT_FS (regs); break; \
180 case GS: val = UPT_GS(regs); break; \
181 case EFLAGS: val = UPT_EFLAGS(regs); break; \
182 default : \
183 panic("Bad register in UPT_REG : %d\n", reg); \
184 val = -1; \
185 } \
186 val; \
187 })
188
189
190#define UPT_SET(regs, reg, val) \
191 ({ unsigned long __upt_val = val; \
192 switch(reg){ \
193 case R8: UPT_R8(regs) = __upt_val; break; \
194 case R9: UPT_R9(regs) = __upt_val; break; \
195 case R10: UPT_R10(regs) = __upt_val; break; \
196 case R11: UPT_R11(regs) = __upt_val; break; \
197 case R12: UPT_R12(regs) = __upt_val; break; \
198 case R13: UPT_R13(regs) = __upt_val; break; \
199 case R14: UPT_R14(regs) = __upt_val; break; \
200 case R15: UPT_R15(regs) = __upt_val; break; \
201 case RIP: UPT_IP(regs) = __upt_val; break; \
202 case RSP: UPT_SP(regs) = __upt_val; break; \
203 case RAX: UPT_RAX(regs) = __upt_val; break; \
204 case RBX: UPT_RBX(regs) = __upt_val; break; \
205 case RCX: UPT_RCX(regs) = __upt_val; break; \
206 case RDX: UPT_RDX(regs) = __upt_val; break; \
207 case RSI: UPT_RSI(regs) = __upt_val; break; \
208 case RDI: UPT_RDI(regs) = __upt_val; break; \
209 case RBP: UPT_RBP(regs) = __upt_val; break; \
210 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
211 case CS: UPT_CS(regs) = __upt_val; break; \
212 case SS: UPT_SS(regs) = __upt_val; break; \
213 case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \
214 case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \
215 case DS: UPT_DS(regs) = __upt_val; break; \
216 case ES: UPT_ES(regs) = __upt_val; break; \
217 case FS: UPT_FS(regs) = __upt_val; break; \
218 case GS: UPT_GS(regs) = __upt_val; break; \
219 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
220 default : \
221 panic("Bad register in UPT_SET : %d\n", reg); \
222 break; \
223 } \
224 __upt_val; \
225 })
226
227#define UPT_SET_SYSCALL_RETURN(r, res) \
228 REGS_SET_SYSCALL_RETURN((r)->regs, (res))
229
230#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
231
232#define UPT_SEGV_IS_FIXABLE(r) REGS_SEGV_IS_FIXABLE(&r->skas)
233
234#define UPT_FAULTINFO(r) (&(r)->faultinfo)
235
236static inline void arch_init_registers(int pid)
237{
238}
239
240#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/ptrace_user.h b/arch/um/sys-x86_64/shared/sysdep/ptrace_user.h
deleted file mode 100644
index 4dbccdb58f48..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/ptrace_user.h
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_PTRACE_USER_H__
8#define __SYSDEP_X86_64_PTRACE_USER_H__
9
10#define __FRAME_OFFSETS
11#include <sys/ptrace.h>
12#include <linux/ptrace.h>
13#include <asm/ptrace.h>
14#undef __FRAME_OFFSETS
15#include "user_constants.h"
16
17#define PT_INDEX(off) ((off) / sizeof(unsigned long))
18
19#define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)])
20#define PT_SYSCALL_NR_OFFSET (ORIG_RAX)
21
22#define PT_SYSCALL_ARG1(regs) (((unsigned long *) (regs))[PT_INDEX(RDI)])
23#define PT_SYSCALL_ARG1_OFFSET (RDI)
24
25#define PT_SYSCALL_ARG2(regs) (((unsigned long *) (regs))[PT_INDEX(RSI)])
26#define PT_SYSCALL_ARG2_OFFSET (RSI)
27
28#define PT_SYSCALL_ARG3(regs) (((unsigned long *) (regs))[PT_INDEX(RDX)])
29#define PT_SYSCALL_ARG3_OFFSET (RDX)
30
31#define PT_SYSCALL_ARG4(regs) (((unsigned long *) (regs))[PT_INDEX(RCX)])
32#define PT_SYSCALL_ARG4_OFFSET (RCX)
33
34#define PT_SYSCALL_ARG5(regs) (((unsigned long *) (regs))[PT_INDEX(R8)])
35#define PT_SYSCALL_ARG5_OFFSET (R8)
36
37#define PT_SYSCALL_ARG6(regs) (((unsigned long *) (regs))[PT_INDEX(R9)])
38#define PT_SYSCALL_ARG6_OFFSET (R9)
39
40#define PT_SYSCALL_RET_OFFSET (RAX)
41
42#define PT_IP_OFFSET (RIP)
43#define PT_IP(regs) ((regs)[PT_INDEX(RIP)])
44
45#define PT_SP_OFFSET (RSP)
46#define PT_SP(regs) ((regs)[PT_INDEX(RSP)])
47
48#define PT_ORIG_RAX_OFFSET (ORIG_RAX)
49#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)])
50
51/*
52 * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
53 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
54 * 2.4 name and value for 2.4 host compatibility.
55 */
56#ifndef PTRACE_OLDSETOPTIONS
57#define PTRACE_OLDSETOPTIONS 21
58#endif
59
60/*
61 * These are before the system call, so the system call number is RAX
62 * rather than ORIG_RAX, and arg4 is R10 rather than RCX
63 */
64#define REGS_SYSCALL_NR PT_INDEX(RAX)
65#define REGS_SYSCALL_ARG1 PT_INDEX(RDI)
66#define REGS_SYSCALL_ARG2 PT_INDEX(RSI)
67#define REGS_SYSCALL_ARG3 PT_INDEX(RDX)
68#define REGS_SYSCALL_ARG4 PT_INDEX(R10)
69#define REGS_SYSCALL_ARG5 PT_INDEX(R8)
70#define REGS_SYSCALL_ARG6 PT_INDEX(R9)
71
72#define REGS_IP_INDEX PT_INDEX(RIP)
73#define REGS_SP_INDEX PT_INDEX(RSP)
74
75#define FP_SIZE (HOST_FP_SIZE)
76
77#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/sc.h b/arch/um/sys-x86_64/shared/sysdep/sc.h
deleted file mode 100644
index 8aee45b07434..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/sc.h
+++ /dev/null
@@ -1,45 +0,0 @@
1#ifndef __SYSDEP_X86_64_SC_H
2#define __SYSDEP_X86_64_SC_H
3
4/* Copyright (C) 2003 - 2004 PathScale, Inc
5 * Released under the GPL
6 */
7
8#include <user_constants.h>
9
10#define SC_OFFSET(sc, field) \
11 *((unsigned long *) &(((char *) (sc))[HOST_##field]))
12
13#define SC_RBX(sc) SC_OFFSET(sc, SC_RBX)
14#define SC_RCX(sc) SC_OFFSET(sc, SC_RCX)
15#define SC_RDX(sc) SC_OFFSET(sc, SC_RDX)
16#define SC_RSI(sc) SC_OFFSET(sc, SC_RSI)
17#define SC_RDI(sc) SC_OFFSET(sc, SC_RDI)
18#define SC_RBP(sc) SC_OFFSET(sc, SC_RBP)
19#define SC_RAX(sc) SC_OFFSET(sc, SC_RAX)
20#define SC_R8(sc) SC_OFFSET(sc, SC_R8)
21#define SC_R9(sc) SC_OFFSET(sc, SC_R9)
22#define SC_R10(sc) SC_OFFSET(sc, SC_R10)
23#define SC_R11(sc) SC_OFFSET(sc, SC_R11)
24#define SC_R12(sc) SC_OFFSET(sc, SC_R12)
25#define SC_R13(sc) SC_OFFSET(sc, SC_R13)
26#define SC_R14(sc) SC_OFFSET(sc, SC_R14)
27#define SC_R15(sc) SC_OFFSET(sc, SC_R15)
28#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
29#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
30#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
31#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
32#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
33#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
34#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
35#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
36#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
37#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
38#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
39#if 0
40#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX)
41#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
42#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
43#endif
44
45#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/sigcontext.h b/arch/um/sys-x86_64/shared/sysdep/sigcontext.h
deleted file mode 100644
index 0155133b1458..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/sigcontext.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_SIGCONTEXT_H
8#define __SYSDEP_X86_64_SIGCONTEXT_H
9
10#include <sysdep/sc.h>
11
12#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
13
14#define GET_FAULTINFO_FROM_SC(fi, sc) \
15 { \
16 (fi).cr2 = SC_CR2(sc); \
17 (fi).error_code = SC_ERR(sc); \
18 (fi).trap_no = SC_TRAPNO(sc); \
19 }
20
21/* This is Page Fault */
22#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
23
24/* No broken SKAS API, which doesn't pass trap_no, here. */
25#define SEGV_MAYBE_FIXABLE(fi) 0
26
27#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h b/arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h
deleted file mode 100644
index 95db4be786e4..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_X86_64_SKAS_PTRACE_H
7#define __SYSDEP_X86_64_SKAS_PTRACE_H
8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_LDT 54
21
22#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/stub.h b/arch/um/sys-x86_64/shared/sysdep/stub.h
deleted file mode 100644
index 3432aa249970..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/stub.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_STUB_H
7#define __SYSDEP_STUB_H
8
9#include <sys/mman.h>
10#include <asm/unistd.h>
11#include <sysdep/ptrace_user.h>
12#include "as-layout.h"
13#include "stub-data.h"
14#include "kern_constants.h"
15
16extern void stub_segv_handler(int sig);
17extern void stub_clone_handler(void);
18
19#define STUB_SYSCALL_RET PT_INDEX(RAX)
20#define STUB_MMAP_NR __NR_mmap
21#define MMAP_OFFSET(o) (o)
22
23#define __syscall_clobber "r11","rcx","memory"
24#define __syscall "syscall"
25
26static inline long stub_syscall0(long syscall)
27{
28 long ret;
29
30 __asm__ volatile (__syscall
31 : "=a" (ret)
32 : "0" (syscall) : __syscall_clobber );
33
34 return ret;
35}
36
37static inline long stub_syscall2(long syscall, long arg1, long arg2)
38{
39 long ret;
40
41 __asm__ volatile (__syscall
42 : "=a" (ret)
43 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
44
45 return ret;
46}
47
48static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
49{
50 long ret;
51
52 __asm__ volatile (__syscall
53 : "=a" (ret)
54 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
55 : __syscall_clobber );
56
57 return ret;
58}
59
60static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
61 long arg4)
62{
63 long ret;
64
65 __asm__ volatile ("movq %5,%%r10 ; " __syscall
66 : "=a" (ret)
67 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
68 "g" (arg4)
69 : __syscall_clobber, "r10" );
70
71 return ret;
72}
73
74static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
75 long arg4, long arg5)
76{
77 long ret;
78
79 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
80 : "=a" (ret)
81 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
82 "g" (arg4), "g" (arg5)
83 : __syscall_clobber, "r10", "r8" );
84
85 return ret;
86}
87
88static inline void trap_myself(void)
89{
90 __asm("int3");
91}
92
93static inline void remap_stack(long fd, unsigned long offset)
94{
95 __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
96 "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
97 "movq %%rax, (%%rbx)":
98 : "a" (STUB_MMAP_NR), "D" (STUB_DATA),
99 "S" (UM_KERN_PAGE_SIZE),
100 "d" (PROT_READ | PROT_WRITE),
101 "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
102 "g" (offset),
103 "i" (&((struct stub_data *) STUB_DATA)->err)
104 : __syscall_clobber, "r10", "r8", "r9" );
105}
106
107#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/syscalls.h b/arch/um/sys-x86_64/shared/sysdep/syscalls.h
deleted file mode 100644
index 7cfb0b085655..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/syscalls.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_SYSCALLS_H__
8#define __SYSDEP_X86_64_SYSCALLS_H__
9
10#include <linux/msg.h>
11#include <linux/shm.h>
12#include <kern_constants.h>
13
14typedef long syscall_handler_t(void);
15
16extern syscall_handler_t *sys_call_table[];
17
18#define EXECUTE_SYSCALL(syscall, regs) \
19 (((long (*)(long, long, long, long, long, long)) \
20 (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(&regs->regs), \
21 UPT_SYSCALL_ARG2(&regs->regs), \
22 UPT_SYSCALL_ARG3(&regs->regs), \
23 UPT_SYSCALL_ARG4(&regs->regs), \
24 UPT_SYSCALL_ARG5(&regs->regs), \
25 UPT_SYSCALL_ARG6(&regs->regs)))
26
27extern long old_mmap(unsigned long addr, unsigned long len,
28 unsigned long prot, unsigned long flags,
29 unsigned long fd, unsigned long pgoff);
30extern syscall_handler_t sys_modify_ldt;
31extern syscall_handler_t sys_arch_prctl;
32
33#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/system.h b/arch/um/sys-x86_64/shared/sysdep/system.h
deleted file mode 100644
index d1b93c436200..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/system.h
+++ /dev/null
@@ -1,132 +0,0 @@
1#ifndef _ASM_X86_SYSTEM_H_
2#define _ASM_X86_SYSTEM_H_
3
4#include <asm/asm.h>
5#include <asm/segment.h>
6#include <asm/cpufeature.h>
7#include <asm/cmpxchg.h>
8#include <asm/nops.h>
9
10#include <linux/kernel.h>
11#include <linux/irqflags.h>
12
13/* entries in ARCH_DLINFO: */
14#ifdef CONFIG_IA32_EMULATION
15# define AT_VECTOR_SIZE_ARCH 2
16#else
17# define AT_VECTOR_SIZE_ARCH 1
18#endif
19
20extern unsigned long arch_align_stack(unsigned long sp);
21
22void default_idle(void);
23
24/*
25 * Force strict CPU ordering.
26 * And yes, this is required on UP too when we're talking
27 * to devices.
28 */
29#ifdef CONFIG_X86_32
30/*
31 * Some non-Intel clones support out of order store. wmb() ceases to be a
32 * nop for these.
33 */
34#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
35#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
36#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
37#else
38#define mb() asm volatile("mfence":::"memory")
39#define rmb() asm volatile("lfence":::"memory")
40#define wmb() asm volatile("sfence" ::: "memory")
41#endif
42
43/**
44 * read_barrier_depends - Flush all pending reads that subsequents reads
45 * depend on.
46 *
47 * No data-dependent reads from memory-like regions are ever reordered
48 * over this barrier. All reads preceding this primitive are guaranteed
49 * to access memory (but not necessarily other CPUs' caches) before any
50 * reads following this primitive that depend on the data return by
51 * any of the preceding reads. This primitive is much lighter weight than
52 * rmb() on most CPUs, and is never heavier weight than is
53 * rmb().
54 *
55 * These ordering constraints are respected by both the local CPU
56 * and the compiler.
57 *
58 * Ordering is not guaranteed by anything other than these primitives,
59 * not even by data dependencies. See the documentation for
60 * memory_barrier() for examples and URLs to more information.
61 *
62 * For example, the following code would force ordering (the initial
63 * value of "a" is zero, "b" is one, and "p" is "&a"):
64 *
65 * <programlisting>
66 * CPU 0 CPU 1
67 *
68 * b = 2;
69 * memory_barrier();
70 * p = &b; q = p;
71 * read_barrier_depends();
72 * d = *q;
73 * </programlisting>
74 *
75 * because the read of "*q" depends on the read of "p" and these
76 * two reads are separated by a read_barrier_depends(). However,
77 * the following code, with the same initial values for "a" and "b":
78 *
79 * <programlisting>
80 * CPU 0 CPU 1
81 *
82 * a = 2;
83 * memory_barrier();
84 * b = 3; y = b;
85 * read_barrier_depends();
86 * x = a;
87 * </programlisting>
88 *
89 * does not enforce ordering, since there is no data dependency between
90 * the read of "a" and the read of "b". Therefore, on some CPUs, such
91 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
92 * in cases like this where there are no data dependencies.
93 **/
94
95#define read_barrier_depends() do { } while (0)
96
97#ifdef CONFIG_SMP
98#define smp_mb() mb()
99#ifdef CONFIG_X86_PPRO_FENCE
100# define smp_rmb() rmb()
101#else
102# define smp_rmb() barrier()
103#endif
104#ifdef CONFIG_X86_OOSTORE
105# define smp_wmb() wmb()
106#else
107# define smp_wmb() barrier()
108#endif
109#define smp_read_barrier_depends() read_barrier_depends()
110#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
111#else
112#define smp_mb() barrier()
113#define smp_rmb() barrier()
114#define smp_wmb() barrier()
115#define smp_read_barrier_depends() do { } while (0)
116#define set_mb(var, value) do { var = value; barrier(); } while (0)
117#endif
118
119/*
120 * Stop RDTSC speculation. This is needed when you need to use RDTSC
121 * (or get_cycles or vread that possibly accesses the TSC) in a defined
122 * code region.
123 *
124 * (Could use an alternative three way for this if there was one.)
125 */
126static inline void rdtsc_barrier(void)
127{
128 alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC);
129 alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC);
130}
131
132#endif
diff --git a/arch/um/sys-x86_64/shared/sysdep/tls.h b/arch/um/sys-x86_64/shared/sysdep/tls.h
deleted file mode 100644
index 18c000d0357a..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/tls.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef _SYSDEP_TLS_H
2#define _SYSDEP_TLS_H
3
4# ifndef __KERNEL__
5
6/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
7 * may be named user_desc (but in 2.4 and in header matching its API was named
8 * modify_ldt_ldt_s). */
9
10typedef struct um_dup_user_desc {
11 unsigned int entry_number;
12 unsigned int base_addr;
13 unsigned int limit;
14 unsigned int seg_32bit:1;
15 unsigned int contents:2;
16 unsigned int read_exec_only:1;
17 unsigned int limit_in_pages:1;
18 unsigned int seg_not_present:1;
19 unsigned int useable:1;
20 unsigned int lm:1;
21} user_desc_t;
22
23# else /* __KERNEL__ */
24
25# include <ldt.h>
26typedef struct user_desc user_desc_t;
27
28# endif /* __KERNEL__ */
29#endif /* _SYSDEP_TLS_H */
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 3978e55132d2..000000000000
--- a/arch/um/sys-x86_64/shared/sysdep/vm-flags.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
5 */
6
7#ifndef __VM_FLAGS_X86_64_H
8#define __VM_FLAGS_X86_64_H
9
10#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
11 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
12#define VM_STACK_DEFAULT_FLAGS (VM_GROWSDOWN | VM_READ | VM_WRITE | \
13 VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
14
15#endif
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
deleted file mode 100644
index b6b65c7c7a7d..000000000000
--- a/arch/um/sys-x86_64/signal.c
+++ /dev/null
@@ -1,290 +0,0 @@
1/*
2 * Copyright (C) 2003 PathScale, Inc.
3 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 * Licensed under the GPL
5 */
6
7#include <linux/personality.h>
8#include <linux/ptrace.h>
9#include <linux/kernel.h>
10#include <asm/unistd.h>
11#include <asm/uaccess.h>
12#include <asm/ucontext.h>
13#include "frame_kern.h"
14#include "skas.h"
15
16void copy_sc(struct uml_pt_regs *regs, void *from)
17{
18 struct sigcontext *sc = from;
19
20#define GETREG(regs, regno, sc, regname) \
21 (regs)->gp[(regno) / sizeof(unsigned long)] = (sc)->regname
22
23 GETREG(regs, R8, sc, r8);
24 GETREG(regs, R9, sc, r9);
25 GETREG(regs, R10, sc, r10);
26 GETREG(regs, R11, sc, r11);
27 GETREG(regs, R12, sc, r12);
28 GETREG(regs, R13, sc, r13);
29 GETREG(regs, R14, sc, r14);
30 GETREG(regs, R15, sc, r15);
31 GETREG(regs, RDI, sc, di);
32 GETREG(regs, RSI, sc, si);
33 GETREG(regs, RBP, sc, bp);
34 GETREG(regs, RBX, sc, bx);
35 GETREG(regs, RDX, sc, dx);
36 GETREG(regs, RAX, sc, ax);
37 GETREG(regs, RCX, sc, cx);
38 GETREG(regs, RSP, sc, sp);
39 GETREG(regs, RIP, sc, ip);
40 GETREG(regs, EFLAGS, sc, flags);
41 GETREG(regs, CS, sc, cs);
42
43#undef GETREG
44}
45
46static int copy_sc_from_user(struct pt_regs *regs,
47 struct sigcontext __user *from,
48 struct _fpstate __user *fpp)
49{
50 struct user_i387_struct fp;
51 int err = 0;
52
53#define GETREG(regs, regno, sc, regname) \
54 __get_user((regs)->regs.gp[(regno) / sizeof(unsigned long)], \
55 &(sc)->regname)
56
57 err |= GETREG(regs, R8, from, r8);
58 err |= GETREG(regs, R9, from, r9);
59 err |= GETREG(regs, R10, from, r10);
60 err |= GETREG(regs, R11, from, r11);
61 err |= GETREG(regs, R12, from, r12);
62 err |= GETREG(regs, R13, from, r13);
63 err |= GETREG(regs, R14, from, r14);
64 err |= GETREG(regs, R15, from, r15);
65 err |= GETREG(regs, RDI, from, di);
66 err |= GETREG(regs, RSI, from, si);
67 err |= GETREG(regs, RBP, from, bp);
68 err |= GETREG(regs, RBX, from, bx);
69 err |= GETREG(regs, RDX, from, dx);
70 err |= GETREG(regs, RAX, from, ax);
71 err |= GETREG(regs, RCX, from, cx);
72 err |= GETREG(regs, RSP, from, sp);
73 err |= GETREG(regs, RIP, from, ip);
74 err |= GETREG(regs, EFLAGS, from, flags);
75 err |= GETREG(regs, CS, from, cs);
76 if (err)
77 return 1;
78
79#undef GETREG
80
81 err = copy_from_user(&fp, fpp, sizeof(struct user_i387_struct));
82 if (err)
83 return 1;
84
85 err = restore_fp_registers(userspace_pid[current_thread_info()->cpu],
86 (unsigned long *) &fp);
87 if (err < 0) {
88 printk(KERN_ERR "copy_sc_from_user - "
89 "restore_fp_registers failed, errno = %d\n",
90 -err);
91 return 1;
92 }
93
94 return 0;
95}
96
97static int copy_sc_to_user(struct sigcontext __user *to,
98 struct _fpstate __user *to_fp, struct pt_regs *regs,
99 unsigned long mask, unsigned long sp)
100{
101 struct faultinfo * fi = &current->thread.arch.faultinfo;
102 struct user_i387_struct fp;
103 int err = 0;
104
105 err |= __put_user(0, &to->gs);
106 err |= __put_user(0, &to->fs);
107
108#define PUTREG(regs, regno, sc, regname) \
109 __put_user((regs)->regs.gp[(regno) / sizeof(unsigned long)], \
110 &(sc)->regname)
111
112 err |= PUTREG(regs, RDI, to, di);
113 err |= PUTREG(regs, RSI, to, si);
114 err |= PUTREG(regs, RBP, to, bp);
115 /*
116 * Must use original RSP, which is passed in, rather than what's in
117 * the pt_regs, because that's already been updated to point at the
118 * signal frame.
119 */
120 err |= __put_user(sp, &to->sp);
121 err |= PUTREG(regs, RBX, to, bx);
122 err |= PUTREG(regs, RDX, to, dx);
123 err |= PUTREG(regs, RCX, to, cx);
124 err |= PUTREG(regs, RAX, to, ax);
125 err |= PUTREG(regs, R8, to, r8);
126 err |= PUTREG(regs, R9, to, r9);
127 err |= PUTREG(regs, R10, to, r10);
128 err |= PUTREG(regs, R11, to, r11);
129 err |= PUTREG(regs, R12, to, r12);
130 err |= PUTREG(regs, R13, to, r13);
131 err |= PUTREG(regs, R14, to, r14);
132 err |= PUTREG(regs, R15, to, r15);
133 err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */
134
135 err |= __put_user(fi->cr2, &to->cr2);
136 err |= __put_user(fi->error_code, &to->err);
137 err |= __put_user(fi->trap_no, &to->trapno);
138
139 err |= PUTREG(regs, RIP, to, ip);
140 err |= PUTREG(regs, EFLAGS, to, flags);
141#undef PUTREG
142
143 err |= __put_user(mask, &to->oldmask);
144 if (err)
145 return 1;
146
147 err = save_fp_registers(userspace_pid[current_thread_info()->cpu],
148 (unsigned long *) &fp);
149 if (err < 0) {
150 printk(KERN_ERR "copy_sc_from_user - restore_fp_registers "
151 "failed, errno = %d\n", -err);
152 return 1;
153 }
154
155 if (copy_to_user(to_fp, &fp, sizeof(struct user_i387_struct)))
156 return 1;
157
158 return err;
159}
160
161struct rt_sigframe
162{
163 char __user *pretcode;
164 struct ucontext uc;
165 struct siginfo info;
166 struct _fpstate fpstate;
167};
168
169int setup_signal_stack_si(unsigned long stack_top, int sig,
170 struct k_sigaction *ka, struct pt_regs * regs,
171 siginfo_t *info, sigset_t *set)
172{
173 struct rt_sigframe __user *frame;
174 unsigned long save_sp = PT_REGS_RSP(regs);
175 int err = 0;
176 struct task_struct *me = current;
177
178 frame = (struct rt_sigframe __user *)
179 round_down(stack_top - sizeof(struct rt_sigframe), 16);
180 /* Subtract 128 for a red zone and 8 for proper alignment */
181 frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8);
182
183 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
184 goto out;
185
186 if (ka->sa.sa_flags & SA_SIGINFO) {
187 err |= copy_siginfo_to_user(&frame->info, info);
188 if (err)
189 goto out;
190 }
191
192 /*
193 * Update SP now because the page fault handler refuses to extend
194 * the stack if the faulting address is too far below the current
195 * SP, which frame now certainly is. If there's an error, the original
196 * value is restored on the way out.
197 * When writing the sigcontext to the stack, we have to write the
198 * original value, so that's passed to copy_sc_to_user, which does
199 * the right thing with it.
200 */
201 PT_REGS_RSP(regs) = (unsigned long) frame;
202
203 /* Create the ucontext. */
204 err |= __put_user(0, &frame->uc.uc_flags);
205 err |= __put_user(0, &frame->uc.uc_link);
206 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
207 err |= __put_user(sas_ss_flags(save_sp),
208 &frame->uc.uc_stack.ss_flags);
209 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
210 err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs,
211 set->sig[0], save_sp);
212 err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);
213 if (sizeof(*set) == 16) {
214 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
215 __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]);
216 }
217 else
218 err |= __copy_to_user(&frame->uc.uc_sigmask, set,
219 sizeof(*set));
220
221 /*
222 * Set up to return from userspace. If provided, use a stub
223 * already in userspace.
224 */
225 /* x86-64 should always use SA_RESTORER. */
226 if (ka->sa.sa_flags & SA_RESTORER)
227 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);
228 else
229 /* could use a vstub here */
230 goto restore_sp;
231
232 if (err)
233 goto restore_sp;
234
235 /* Set up registers for signal handler */
236 {
237 struct exec_domain *ed = current_thread_info()->exec_domain;
238 if (unlikely(ed && ed->signal_invmap && sig < 32))
239 sig = ed->signal_invmap[sig];
240 }
241
242 PT_REGS_RDI(regs) = sig;
243 /* In case the signal handler was declared without prototypes */
244 PT_REGS_RAX(regs) = 0;
245
246 /*
247 * This also works for non SA_SIGINFO handlers because they expect the
248 * next argument after the signal number on the stack.
249 */
250 PT_REGS_RSI(regs) = (unsigned long) &frame->info;
251 PT_REGS_RDX(regs) = (unsigned long) &frame->uc;
252 PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler;
253 out:
254 return err;
255
256restore_sp:
257 PT_REGS_RSP(regs) = save_sp;
258 return err;
259}
260
261long sys_rt_sigreturn(struct pt_regs *regs)
262{
263 unsigned long sp = PT_REGS_SP(&current->thread.regs);
264 struct rt_sigframe __user *frame =
265 (struct rt_sigframe __user *)(sp - 8);
266 struct ucontext __user *uc = &frame->uc;
267 sigset_t set;
268
269 if (copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
270 goto segfault;
271
272 sigdelsetmask(&set, ~_BLOCKABLE);
273
274 spin_lock_irq(&current->sighand->siglock);
275 current->blocked = set;
276 recalc_sigpending();
277 spin_unlock_irq(&current->sighand->siglock);
278
279 if (copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext,
280 &frame->fpstate))
281 goto segfault;
282
283 /* Avoid ERESTART handling */
284 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1;
285 return PT_REGS_SYSCALL_RET(&current->thread.regs);
286
287 segfault:
288 force_sig(SIGSEGV, current);
289 return 0;
290}
diff --git a/arch/um/sys-x86_64/stub.S b/arch/um/sys-x86_64/stub.S
deleted file mode 100644
index 20e4a96a6dcb..000000000000
--- a/arch/um/sys-x86_64/stub.S
+++ /dev/null
@@ -1,66 +0,0 @@
1#include "as-layout.h"
2
3 .globl syscall_stub
4.section .__syscall_stub, "ax"
5syscall_stub:
6 syscall
7 /* We don't have 64-bit constants, so this constructs the address
8 * we need.
9 */
10 movq $(STUB_DATA >> 32), %rbx
11 salq $32, %rbx
12 movq $(STUB_DATA & 0xffffffff), %rcx
13 or %rcx, %rbx
14 movq %rax, (%rbx)
15 int3
16
17 .globl batch_syscall_stub
18batch_syscall_stub:
19 mov $(STUB_DATA >> 32), %rbx
20 sal $32, %rbx
21 mov $(STUB_DATA & 0xffffffff), %rax
22 or %rax, %rbx
23 /* load pointer to first operation */
24 mov %rbx, %rsp
25 add $0x10, %rsp
26again:
27 /* load length of additional data */
28 mov 0x0(%rsp), %rax
29
30 /* if(length == 0) : end of list */
31 /* write possible 0 to header */
32 mov %rax, 8(%rbx)
33 cmp $0, %rax
34 jz done
35
36 /* save current pointer */
37 mov %rsp, 8(%rbx)
38
39 /* skip additional data */
40 add %rax, %rsp
41
42 /* load syscall-# */
43 pop %rax
44
45 /* load syscall params */
46 pop %rdi
47 pop %rsi
48 pop %rdx
49 pop %r10
50 pop %r8
51 pop %r9
52
53 /* execute syscall */
54 syscall
55
56 /* check return value */
57 pop %rcx
58 cmp %rcx, %rax
59 je again
60
61done:
62 /* save return value */
63 mov %rax, (%rbx)
64
65 /* stop */
66 int3
diff --git a/arch/um/sys-x86_64/stub_segv.c b/arch/um/sys-x86_64/stub_segv.c
deleted file mode 100644
index ced051afc705..000000000000
--- a/arch/um/sys-x86_64/stub_segv.c
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#include <signal.h>
7#include "as-layout.h"
8#include "sysdep/stub.h"
9#include "sysdep/faultinfo.h"
10#include "sysdep/sigcontext.h"
11
12void __attribute__ ((__section__ (".__syscall_stub")))
13stub_segv_handler(int sig)
14{
15 struct ucontext *uc;
16
17 __asm__ __volatile__("movq %%rdx, %0" : "=g" (uc) :);
18 GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA),
19 &uc->uc_mcontext);
20 trap_myself();
21}
22
diff --git a/arch/um/sys-x86_64/syscall_table.c b/arch/um/sys-x86_64/syscall_table.c
deleted file mode 100644
index 47d469e7e7ce..000000000000
--- a/arch/um/sys-x86_64/syscall_table.c
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * System call table for UML/x86-64, copied from arch/x86_64/kernel/syscall.c
3 * with some changes for UML.
4 */
5
6#include <linux/linkage.h>
7#include <linux/sys.h>
8#include <linux/cache.h>
9#include <kern_constants.h>
10
11#define __NO_STUBS
12
13/*
14 * Below you can see, in terms of #define's, the differences between the x86-64
15 * and the UML syscall table.
16 */
17
18/* Not going to be implemented by UML, since we have no hardware. */
19#define stub_iopl sys_ni_syscall
20#define sys_ioperm sys_ni_syscall
21
22/*
23 * The UML TLS problem. Note that x86_64 does not implement this, so the below
24 * is needed only for the ia32 compatibility.
25 */
26
27/* On UML we call it this way ("old" means it's not mmap2) */
28#define sys_mmap old_mmap
29
30#define stub_clone sys_clone
31#define stub_fork sys_fork
32#define stub_vfork sys_vfork
33#define stub_execve sys_execve
34#define stub_rt_sigsuspend sys_rt_sigsuspend
35#define stub_sigaltstack sys_sigaltstack
36#define stub_rt_sigreturn sys_rt_sigreturn
37
38#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
39#undef _ASM_X86_UNISTD_64_H
40#include "../../x86/include/asm/unistd_64.h"
41
42#undef __SYSCALL
43#define __SYSCALL(nr, sym) [ nr ] = sym,
44#undef _ASM_X86_UNISTD_64_H
45
46typedef void (*sys_call_ptr_t)(void);
47
48extern void sys_ni_syscall(void);
49
50/*
51 * We used to have a trick here which made sure that holes in the
52 * x86_64 table were filled in with sys_ni_syscall, but a comment in
53 * unistd_64.h says that holes aren't allowed, so the trick was
54 * removed.
55 * The trick looked like this
56 * [0 ... UM_NR_syscall_max] = &sys_ni_syscall
57 * before including unistd_64.h - the later initializations overwrote
58 * the sys_ni_syscall filler.
59 */
60
61sys_call_ptr_t sys_call_table[] __cacheline_aligned = {
62#include "../../x86/include/asm/unistd_64.h"
63};
64
65int syscall_table_size = sizeof(sys_call_table);
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c
deleted file mode 100644
index f3d82bb6e15a..000000000000
--- a/arch/um/sys-x86_64/syscalls.c
+++ /dev/null
@@ -1,102 +0,0 @@
1/*
2 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Copyright 2003 PathScale, Inc.
4 *
5 * Licensed under the GPL
6 */
7
8#include "linux/linkage.h"
9#include "linux/personality.h"
10#include "linux/utsname.h"
11#include "asm/prctl.h" /* XXX This should get the constants from libc */
12#include "asm/uaccess.h"
13#include "os.h"
14
15long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
16{
17 unsigned long *ptr = addr, tmp;
18 long ret;
19 int pid = task->mm->context.id.u.pid;
20
21 /*
22 * With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to
23 * be safe), we need to call arch_prctl on the host because
24 * setting %fs may result in something else happening (like a
25 * GDT or thread.fs being set instead). So, we let the host
26 * fiddle the registers and thread struct and restore the
27 * registers afterwards.
28 *
29 * So, the saved registers are stored to the process (this
30 * needed because a stub may have been the last thing to run),
31 * arch_prctl is run on the host, then the registers are read
32 * back.
33 */
34 switch (code) {
35 case ARCH_SET_FS:
36 case ARCH_SET_GS:
37 ret = restore_registers(pid, &current->thread.regs.regs);
38 if (ret)
39 return ret;
40 break;
41 case ARCH_GET_FS:
42 case ARCH_GET_GS:
43 /*
44 * With these two, we read to a local pointer and
45 * put_user it to the userspace pointer that we were
46 * given. If addr isn't valid (because it hasn't been
47 * faulted in or is just bogus), we want put_user to
48 * fault it in (or return -EFAULT) instead of having
49 * the host return -EFAULT.
50 */
51 ptr = &tmp;
52 }
53
54 ret = os_arch_prctl(pid, code, ptr);
55 if (ret)
56 return ret;
57
58 switch (code) {
59 case ARCH_SET_FS:
60 current->thread.arch.fs = (unsigned long) ptr;
61 ret = save_registers(pid, &current->thread.regs.regs);
62 break;
63 case ARCH_SET_GS:
64 ret = save_registers(pid, &current->thread.regs.regs);
65 break;
66 case ARCH_GET_FS:
67 ret = put_user(tmp, addr);
68 break;
69 case ARCH_GET_GS:
70 ret = put_user(tmp, addr);
71 break;
72 }
73
74 return ret;
75}
76
77long sys_arch_prctl(int code, unsigned long addr)
78{
79 return arch_prctl(current, code, (unsigned long __user *) addr);
80}
81
82long sys_clone(unsigned long clone_flags, unsigned long newsp,
83 void __user *parent_tid, void __user *child_tid)
84{
85 long ret;
86
87 if (!newsp)
88 newsp = UPT_SP(&current->thread.regs.regs);
89 current->thread.forking = 1;
90 ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
91 child_tid);
92 current->thread.forking = 0;
93 return ret;
94}
95
96void arch_switch_to(struct task_struct *to)
97{
98 if ((to->thread.arch.fs == 0) || (to->mm == NULL))
99 return;
100
101 arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
102}
diff --git a/arch/um/sys-x86_64/sysrq.c b/arch/um/sys-x86_64/sysrq.c
deleted file mode 100644
index f4f82beb3508..000000000000
--- a/arch/um/sys-x86_64/sysrq.c
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/sched.h>
10#include <linux/utsname.h>
11#include <asm/current.h>
12#include <asm/ptrace.h>
13#include "sysrq.h"
14
15void __show_regs(struct pt_regs *regs)
16{
17 printk("\n");
18 print_modules();
19 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current),
20 current->comm, print_tainted(), init_utsname()->release);
21 printk(KERN_INFO "RIP: %04lx:[<%016lx>]\n", PT_REGS_CS(regs) & 0xffff,
22 PT_REGS_RIP(regs));
23 printk(KERN_INFO "RSP: %016lx EFLAGS: %08lx\n", PT_REGS_RSP(regs),
24 PT_REGS_EFLAGS(regs));
25 printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n",
26 PT_REGS_RAX(regs), PT_REGS_RBX(regs), PT_REGS_RCX(regs));
27 printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n",
28 PT_REGS_RDX(regs), PT_REGS_RSI(regs), PT_REGS_RDI(regs));
29 printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n",
30 PT_REGS_RBP(regs), PT_REGS_R8(regs), PT_REGS_R9(regs));
31 printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n",
32 PT_REGS_R10(regs), PT_REGS_R11(regs), PT_REGS_R12(regs));
33 printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n",
34 PT_REGS_R13(regs), PT_REGS_R14(regs), PT_REGS_R15(regs));
35}
36
37void show_regs(struct pt_regs *regs)
38{
39 __show_regs(regs);
40 show_trace(current, (unsigned long *) &regs);
41}
diff --git a/arch/um/sys-x86_64/tls.c b/arch/um/sys-x86_64/tls.c
deleted file mode 100644
index f7ba46200ecd..000000000000
--- a/arch/um/sys-x86_64/tls.c
+++ /dev/null
@@ -1,17 +0,0 @@
1#include "linux/sched.h"
2
3void clear_flushed_tls(struct task_struct *task)
4{
5}
6
7int arch_copy_tls(struct task_struct *t)
8{
9 /*
10 * If CLONE_SETTLS is set, we need to save the thread id
11 * (which is argument 5, child_tid, of clone) so it can be set
12 * during context switches.
13 */
14 t->thread.arch.fs = t->thread.regs.regs.gp[R8 / sizeof(long)];
15
16 return 0;
17}
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
deleted file mode 100644
index 973585414a66..000000000000
--- a/arch/um/sys-x86_64/user-offsets.c
+++ /dev/null
@@ -1,65 +0,0 @@
1#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
4#include <sys/poll.h>
5#include <sys/mman.h>
6#include <sys/user.h>
7#define __FRAME_OFFSETS
8#include <asm/ptrace.h>
9#include <asm/types.h>
10
11#define DEFINE(sym, val) \
12 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
13
14#define DEFINE_LONGS(sym, val) \
15 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
16
17#define OFFSET(sym, str, mem) \
18 DEFINE(sym, offsetof(struct str, mem));
19
20void foo(void)
21{
22 OFFSET(HOST_SC_CR2, sigcontext, cr2);
23 OFFSET(HOST_SC_ERR, sigcontext, err);
24 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
25
26 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
27 DEFINE_LONGS(HOST_RBX, RBX);
28 DEFINE_LONGS(HOST_RCX, RCX);
29 DEFINE_LONGS(HOST_RDI, RDI);
30 DEFINE_LONGS(HOST_RSI, RSI);
31 DEFINE_LONGS(HOST_RDX, RDX);
32 DEFINE_LONGS(HOST_RBP, RBP);
33 DEFINE_LONGS(HOST_RAX, RAX);
34 DEFINE_LONGS(HOST_R8, R8);
35 DEFINE_LONGS(HOST_R9, R9);
36 DEFINE_LONGS(HOST_R10, R10);
37 DEFINE_LONGS(HOST_R11, R11);
38 DEFINE_LONGS(HOST_R12, R12);
39 DEFINE_LONGS(HOST_R13, R13);
40 DEFINE_LONGS(HOST_R14, R14);
41 DEFINE_LONGS(HOST_R15, R15);
42 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
43 DEFINE_LONGS(HOST_CS, CS);
44 DEFINE_LONGS(HOST_SS, SS);
45 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
46#if 0
47 DEFINE_LONGS(HOST_FS, FS);
48 DEFINE_LONGS(HOST_GS, GS);
49 DEFINE_LONGS(HOST_DS, DS);
50 DEFINE_LONGS(HOST_ES, ES);
51#endif
52
53 DEFINE_LONGS(HOST_IP, RIP);
54 DEFINE_LONGS(HOST_SP, RSP);
55 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
56
57 /* XXX Duplicated between i386 and x86_64 */
58 DEFINE(UM_POLLIN, POLLIN);
59 DEFINE(UM_POLLPRI, POLLPRI);
60 DEFINE(UM_POLLOUT, POLLOUT);
61
62 DEFINE(UM_PROT_READ, PROT_READ);
63 DEFINE(UM_PROT_WRITE, PROT_WRITE);
64 DEFINE(UM_PROT_EXEC, PROT_EXEC);
65}
diff --git a/arch/um/sys-x86_64/vdso/Makefile b/arch/um/sys-x86_64/vdso/Makefile
deleted file mode 100644
index 5dffe6d46686..000000000000
--- a/arch/um/sys-x86_64/vdso/Makefile
+++ /dev/null
@@ -1,90 +0,0 @@
1#
2# Building vDSO images for x86.
3#
4
5VDSO64-y := y
6
7vdso-install-$(VDSO64-y) += vdso.so
8
9
10# files to link into the vdso
11vobjs-y := vdso-note.o um_vdso.o
12
13# files to link into kernel
14obj-$(VDSO64-y) += vdso.o vma.o
15
16vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
17
18$(obj)/vdso.o: $(obj)/vdso.so
19
20targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
21
22export CPPFLAGS_vdso.lds += -P -C
23
24VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
25 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
26
27$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
28
29$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
30 $(call if_changed,vdso)
31
32$(obj)/%.so: OBJCOPYFLAGS := -S
33$(obj)/%.so: $(obj)/%.so.dbg FORCE
34 $(call if_changed,objcopy)
35
36#
37# Don't omit frame pointers for ease of userspace debugging, but do
38# optimize sibling calls.
39#
40CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
41 $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
42 -fno-omit-frame-pointer -foptimize-sibling-calls
43
44$(vobjs): KBUILD_CFLAGS += $(CFL)
45
46#
47# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
48#
49CFLAGS_REMOVE_vdso-note.o = -pg
50CFLAGS_REMOVE_um_vdso.o = -pg
51
52targets += vdso-syms.lds
53obj-$(VDSO64-y) += vdso-syms.lds
54
55#
56# Match symbols in the DSO that look like VDSO*; produce a file of constants.
57#
58sed-vdsosym := -e 's/^00*/0/' \
59 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
60quiet_cmd_vdsosym = VDSOSYM $@
61define cmd_vdsosym
62 $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
63endef
64
65$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
66 $(call if_changed,vdsosym)
67
68#
69# The DSO images are built using a special linker script.
70#
71quiet_cmd_vdso = VDSO $@
72 cmd_vdso = $(CC) -nostdlib -o $@ \
73 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
74 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
75 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
76
77VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
78GCOV_PROFILE := n
79
80#
81# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
82#
83quiet_cmd_vdso_install = INSTALL $@
84 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
85$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
86 @mkdir -p $(MODLIB)/vdso
87 $(call cmd,vdso_install)
88
89PHONY += vdso_install $(vdso-install-y)
90vdso_install: $(vdso-install-y)
diff --git a/arch/um/sys-x86_64/vdso/checkundef.sh b/arch/um/sys-x86_64/vdso/checkundef.sh
deleted file mode 100644
index 7ee90a9b549d..000000000000
--- a/arch/um/sys-x86_64/vdso/checkundef.sh
+++ /dev/null
@@ -1,10 +0,0 @@
1#!/bin/sh
2nm="$1"
3file="$2"
4$nm "$file" | grep '^ *U' > /dev/null 2>&1
5if [ $? -eq 1 ]; then
6 exit 0
7else
8 echo "$file: undefined symbols found" >&2
9 exit 1
10fi
diff --git a/arch/um/sys-x86_64/vdso/um_vdso.c b/arch/um/sys-x86_64/vdso/um_vdso.c
deleted file mode 100644
index 7c441b59d375..000000000000
--- a/arch/um/sys-x86_64/vdso/um_vdso.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This vDSO turns all calls into a syscall so that UML can trap them.
9 */
10
11
12/* Disable profiling for userspace code */
13#define DISABLE_BRANCH_PROFILING
14
15#include <linux/time.h>
16#include <linux/getcpu.h>
17#include <asm/unistd.h>
18
19int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
20{
21 long ret;
22
23 asm("syscall" : "=a" (ret) :
24 "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
25
26 return ret;
27}
28int clock_gettime(clockid_t, struct timespec *)
29 __attribute__((weak, alias("__vdso_clock_gettime")));
30
31int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
32{
33 long ret;
34
35 asm("syscall" : "=a" (ret) :
36 "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
37
38 return ret;
39}
40int gettimeofday(struct timeval *, struct timezone *)
41 __attribute__((weak, alias("__vdso_gettimeofday")));
42
43time_t __vdso_time(time_t *t)
44{
45 long secs;
46
47 asm volatile("syscall"
48 : "=a" (secs)
49 : "0" (__NR_time), "D" (t) : "cc", "r11", "cx", "memory");
50
51 return secs;
52}
53int time(time_t *t) __attribute__((weak, alias("__vdso_time")));
54
55long
56__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
57{
58 /*
59 * UML does not support SMP, we can cheat here. :)
60 */
61
62 if (cpu)
63 *cpu = 0;
64 if (node)
65 *node = 0;
66
67 return 0;
68}
69
70long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
71 __attribute__((weak, alias("__vdso_getcpu")));
diff --git a/arch/um/sys-x86_64/vdso/vdso-layout.lds.S b/arch/um/sys-x86_64/vdso/vdso-layout.lds.S
deleted file mode 100644
index 634a2cf62046..000000000000
--- a/arch/um/sys-x86_64/vdso/vdso-layout.lds.S
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * Linker script for vDSO. This is an ELF shared object prelinked to
3 * its virtual address, and with only one read-only segment.
4 * This script controls its layout.
5 */
6
7SECTIONS
8{
9 . = VDSO_PRELINK + SIZEOF_HEADERS;
10
11 .hash : { *(.hash) } :text
12 .gnu.hash : { *(.gnu.hash) }
13 .dynsym : { *(.dynsym) }
14 .dynstr : { *(.dynstr) }
15 .gnu.version : { *(.gnu.version) }
16 .gnu.version_d : { *(.gnu.version_d) }
17 .gnu.version_r : { *(.gnu.version_r) }
18
19 .note : { *(.note.*) } :text :note
20
21 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
22 .eh_frame : { KEEP (*(.eh_frame)) } :text
23
24 .dynamic : { *(.dynamic) } :text :dynamic
25
26 .rodata : { *(.rodata*) } :text
27 .data : {
28 *(.data*)
29 *(.sdata*)
30 *(.got.plt) *(.got)
31 *(.gnu.linkonce.d.*)
32 *(.bss*)
33 *(.dynbss*)
34 *(.gnu.linkonce.b.*)
35 }
36
37 .altinstructions : { *(.altinstructions) }
38 .altinstr_replacement : { *(.altinstr_replacement) }
39
40 /*
41 * Align the actual code well away from the non-instruction data.
42 * This is the best thing for the I-cache.
43 */
44 . = ALIGN(0x100);
45
46 .text : { *(.text*) } :text =0x90909090
47}
48
49/*
50 * Very old versions of ld do not recognize this name token; use the constant.
51 */
52#define PT_GNU_EH_FRAME 0x6474e550
53
54/*
55 * We must supply the ELF program headers explicitly to get just one
56 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
57 */
58PHDRS
59{
60 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
61 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
62 note PT_NOTE FLAGS(4); /* PF_R */
63 eh_frame_hdr PT_GNU_EH_FRAME;
64}
diff --git a/arch/um/sys-x86_64/vdso/vdso-note.S b/arch/um/sys-x86_64/vdso/vdso-note.S
deleted file mode 100644
index 79a071e4357e..000000000000
--- a/arch/um/sys-x86_64/vdso/vdso-note.S
+++ /dev/null
@@ -1,12 +0,0 @@
1/*
2 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
3 * Here we can supply some information useful to userland.
4 */
5
6#include <linux/uts.h>
7#include <linux/version.h>
8#include <linux/elfnote.h>
9
10ELFNOTE_START(Linux, 0, "a")
11 .long LINUX_VERSION_CODE
12ELFNOTE_END
diff --git a/arch/um/sys-x86_64/vdso/vdso.S b/arch/um/sys-x86_64/vdso/vdso.S
deleted file mode 100644
index ec82c1686bd6..000000000000
--- a/arch/um/sys-x86_64/vdso/vdso.S
+++ /dev/null
@@ -1,10 +0,0 @@
1#include <linux/init.h>
2
3__INITDATA
4
5 .globl vdso_start, vdso_end
6vdso_start:
7 .incbin "arch/um/sys-x86_64/vdso/vdso.so"
8vdso_end:
9
10__FINIT
diff --git a/arch/um/sys-x86_64/vdso/vdso.lds.S b/arch/um/sys-x86_64/vdso/vdso.lds.S
deleted file mode 100644
index b96b2677cad8..000000000000
--- a/arch/um/sys-x86_64/vdso/vdso.lds.S
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Linker script for 64-bit vDSO.
3 * We #include the file to define the layout details.
4 * Here we only choose the prelinked virtual address.
5 *
6 * This file defines the version script giving the user-exported symbols in
7 * the DSO. We can define local symbols here called VDSO* to make their
8 * values visible using the asm-x86/vdso.h macros from the kernel proper.
9 */
10
11#define VDSO_PRELINK 0xffffffffff700000
12#include "vdso-layout.lds.S"
13
14/*
15 * This controls what userland symbols we export from the vDSO.
16 */
17VERSION {
18 LINUX_2.6 {
19 global:
20 clock_gettime;
21 __vdso_clock_gettime;
22 gettimeofday;
23 __vdso_gettimeofday;
24 getcpu;
25 __vdso_getcpu;
26 time;
27 __vdso_time;
28 local: *;
29 };
30}
31
32VDSO64_PRELINK = VDSO_PRELINK;
diff --git a/arch/um/sys-x86_64/vdso/vma.c b/arch/um/sys-x86_64/vdso/vma.c
deleted file mode 100644
index 9495c8d0ce37..000000000000
--- a/arch/um/sys-x86_64/vdso/vma.c
+++ /dev/null
@@ -1,74 +0,0 @@
1/*
2 * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/slab.h>
10#include <linux/sched.h>
11#include <linux/mm.h>
12#include <asm/page.h>
13#include <linux/init.h>
14
15unsigned int __read_mostly vdso_enabled = 1;
16unsigned long um_vdso_addr;
17
18extern unsigned long task_size;
19extern char vdso_start[], vdso_end[];
20
21static struct page **vdsop;
22
23static int __init init_vdso(void)
24{
25 struct page *um_vdso;
26
27 BUG_ON(vdso_end - vdso_start > PAGE_SIZE);
28
29 um_vdso_addr = task_size - PAGE_SIZE;
30
31 vdsop = kmalloc(GFP_KERNEL, sizeof(struct page *));
32 if (!vdsop)
33 goto oom;
34
35 um_vdso = alloc_page(GFP_KERNEL);
36 if (!um_vdso) {
37 kfree(vdsop);
38
39 goto oom;
40 }
41
42 copy_page(page_address(um_vdso), vdso_start);
43 *vdsop = um_vdso;
44
45 return 0;
46
47oom:
48 printk(KERN_ERR "Cannot allocate vdso\n");
49 vdso_enabled = 0;
50
51 return -ENOMEM;
52}
53subsys_initcall(init_vdso);
54
55int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
56{
57 int err;
58 struct mm_struct *mm = current->mm;
59
60 if (!vdso_enabled)
61 return 0;
62
63 down_write(&mm->mmap_sem);
64
65 err = install_special_mapping(mm, um_vdso_addr, PAGE_SIZE,
66 VM_READ|VM_EXEC|
67 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
68 VM_ALWAYSDUMP,
69 vdsop);
70
71 up_write(&mm->mmap_sem);
72
73 return err;
74}