diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/um/sys-x86_64/asm | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'arch/um/sys-x86_64/asm')
| -rw-r--r-- | arch/um/sys-x86_64/asm/archparam.h | 16 | ||||
| -rw-r--r-- | arch/um/sys-x86_64/asm/elf.h | 132 | ||||
| -rw-r--r-- | arch/um/sys-x86_64/asm/module.h | 20 | ||||
| -rw-r--r-- | arch/um/sys-x86_64/asm/processor.h | 56 | ||||
| -rw-r--r-- | arch/um/sys-x86_64/asm/ptrace.h | 72 |
5 files changed, 296 insertions, 0 deletions
diff --git a/arch/um/sys-x86_64/asm/archparam.h b/arch/um/sys-x86_64/asm/archparam.h new file mode 100644 index 00000000000..6c083663b8d --- /dev/null +++ b/arch/um/sys-x86_64/asm/archparam.h | |||
| @@ -0,0 +1,16 @@ | |||
| 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 new file mode 100644 index 00000000000..11a2bfb3885 --- /dev/null +++ b/arch/um/sys-x86_64/asm/elf.h | |||
| @@ -0,0 +1,132 @@ | |||
| 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 | |||
| 34 | typedef unsigned long elf_greg_t; | ||
| 35 | |||
| 36 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) | ||
| 37 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | ||
| 38 | |||
| 39 | typedef 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 | |||
| 100 | struct task_struct; | ||
| 101 | |||
| 102 | extern 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 | |||
| 115 | extern 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 | ||
| 124 | struct linux_binprm; | ||
| 125 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, | ||
| 126 | int uses_interp); | ||
| 127 | |||
| 128 | extern 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 new file mode 100644 index 00000000000..8eb79c2d07d --- /dev/null +++ b/arch/um/sys-x86_64/asm/module.h | |||
| @@ -0,0 +1,20 @@ | |||
| 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 */ | ||
| 11 | struct 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 new file mode 100644 index 00000000000..875a26a6261 --- /dev/null +++ b/arch/um/sys-x86_64/asm/processor.h | |||
| @@ -0,0 +1,56 @@ | |||
| 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 | |||
| 13 | struct 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. */ | ||
| 21 | static 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 | |||
| 33 | static inline void arch_flush_thread(struct arch_thread *thread) | ||
| 34 | { | ||
| 35 | } | ||
| 36 | |||
| 37 | static 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(¤t->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 new file mode 100644 index 00000000000..83d8c473b90 --- /dev/null +++ b/arch/um/sys-x86_64/asm/ptrace.h | |||
| @@ -0,0 +1,72 @@ | |||
| 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 | |||
| 56 | struct user_desc; | ||
| 57 | |||
| 58 | static 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 | |||
| 64 | static 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 | |||
| 70 | extern long arch_prctl(struct task_struct *task, int code, | ||
| 71 | unsigned long __user *addr); | ||
| 72 | #endif | ||
