cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

elf.h (6294B)


      1/*
      2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
      3 * Licensed under the GPL
      4 */
      5#ifndef __UM_ELF_X86_H
      6#define __UM_ELF_X86_H
      7
      8#include <asm/user.h>
      9#include <skas.h>
     10
     11#ifdef CONFIG_X86_32
     12
     13#define R_386_NONE	0
     14#define R_386_32	1
     15#define R_386_PC32	2
     16#define R_386_GOT32	3
     17#define R_386_PLT32	4
     18#define R_386_COPY	5
     19#define R_386_GLOB_DAT	6
     20#define R_386_JMP_SLOT	7
     21#define R_386_RELATIVE	8
     22#define R_386_GOTOFF	9
     23#define R_386_GOTPC	10
     24#define R_386_NUM	11
     25
     26/*
     27 * This is used to ensure we don't load something for the wrong architecture.
     28 */
     29#define elf_check_arch(x) \
     30	(((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
     31
     32#define ELF_CLASS	ELFCLASS32
     33#define ELF_DATA        ELFDATA2LSB
     34#define ELF_ARCH        EM_386
     35
     36#define ELF_PLAT_INIT(regs, load_addr) do { \
     37	PT_REGS_BX(regs) = 0; \
     38	PT_REGS_CX(regs) = 0; \
     39	PT_REGS_DX(regs) = 0; \
     40	PT_REGS_SI(regs) = 0; \
     41	PT_REGS_DI(regs) = 0; \
     42	PT_REGS_BP(regs) = 0; \
     43	PT_REGS_AX(regs) = 0; \
     44} while (0)
     45
     46/* Shamelessly stolen from include/asm-i386/elf.h */
     47
     48#define ELF_CORE_COPY_REGS(pr_reg, regs) do {	\
     49	pr_reg[0] = PT_REGS_BX(regs);		\
     50	pr_reg[1] = PT_REGS_CX(regs);		\
     51	pr_reg[2] = PT_REGS_DX(regs);		\
     52	pr_reg[3] = PT_REGS_SI(regs);		\
     53	pr_reg[4] = PT_REGS_DI(regs);		\
     54	pr_reg[5] = PT_REGS_BP(regs);		\
     55	pr_reg[6] = PT_REGS_AX(regs);		\
     56	pr_reg[7] = PT_REGS_DS(regs);		\
     57	pr_reg[8] = PT_REGS_ES(regs);		\
     58	/* fake once used fs and gs selectors? */	\
     59	pr_reg[9] = PT_REGS_DS(regs);		\
     60	pr_reg[10] = PT_REGS_DS(regs);		\
     61	pr_reg[11] = PT_REGS_SYSCALL_NR(regs);	\
     62	pr_reg[12] = PT_REGS_IP(regs);		\
     63	pr_reg[13] = PT_REGS_CS(regs);		\
     64	pr_reg[14] = PT_REGS_EFLAGS(regs);	\
     65	pr_reg[15] = PT_REGS_SP(regs);		\
     66	pr_reg[16] = PT_REGS_SS(regs);		\
     67} while (0);
     68
     69extern char * elf_aux_platform;
     70#define ELF_PLATFORM (elf_aux_platform)
     71
     72extern unsigned long vsyscall_ehdr;
     73extern unsigned long vsyscall_end;
     74extern unsigned long __kernel_vsyscall;
     75
     76/*
     77 * This is the range that is readable by user mode, and things
     78 * acting like user mode such as get_user_pages.
     79 */
     80#define FIXADDR_USER_START      vsyscall_ehdr
     81#define FIXADDR_USER_END        vsyscall_end
     82
     83
     84/*
     85 * Architecture-neutral AT_ values in 0-17, leave some room
     86 * for more of them, start the x86-specific ones at 32.
     87 */
     88#define AT_SYSINFO		32
     89#define AT_SYSINFO_EHDR		33
     90
     91#define ARCH_DLINFO						\
     92do {								\
     93	if ( vsyscall_ehdr ) {					\
     94		NEW_AUX_ENT(AT_SYSINFO,	__kernel_vsyscall);	\
     95		NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr);	\
     96	}							\
     97} while (0)
     98
     99#else
    100
    101/* x86-64 relocation types, taken from asm-x86_64/elf.h */
    102#define R_X86_64_NONE		0	/* No reloc */
    103#define R_X86_64_64		1	/* Direct 64 bit  */
    104#define R_X86_64_PC32		2	/* PC relative 32 bit signed */
    105#define R_X86_64_GOT32		3	/* 32 bit GOT entry */
    106#define R_X86_64_PLT32		4	/* 32 bit PLT address */
    107#define R_X86_64_COPY		5	/* Copy symbol at runtime */
    108#define R_X86_64_GLOB_DAT	6	/* Create GOT entry */
    109#define R_X86_64_JUMP_SLOT	7	/* Create PLT entry */
    110#define R_X86_64_RELATIVE	8	/* Adjust by program base */
    111#define R_X86_64_GOTPCREL	9	/* 32 bit signed pc relative
    112					   offset to GOT */
    113#define R_X86_64_32		10	/* Direct 32 bit zero extended */
    114#define R_X86_64_32S		11	/* Direct 32 bit sign extended */
    115#define R_X86_64_16		12	/* Direct 16 bit zero extended */
    116#define R_X86_64_PC16		13	/* 16 bit sign extended pc relative */
    117#define R_X86_64_8		14	/* Direct 8 bit sign extended  */
    118#define R_X86_64_PC8		15	/* 8 bit sign extended pc relative */
    119#define R_X86_64_PC64		24	/* Place relative 64-bit signed */
    120
    121/*
    122 * This is used to ensure we don't load something for the wrong architecture.
    123 */
    124#define elf_check_arch(x) \
    125	((x)->e_machine == EM_X86_64)
    126
    127#define ELF_CLASS	ELFCLASS64
    128#define ELF_DATA        ELFDATA2LSB
    129#define ELF_ARCH        EM_X86_64
    130
    131#define ELF_PLAT_INIT(regs, load_addr)    do { \
    132	PT_REGS_BX(regs) = 0; \
    133	PT_REGS_CX(regs) = 0; \
    134	PT_REGS_DX(regs) = 0; \
    135	PT_REGS_SI(regs) = 0; \
    136	PT_REGS_DI(regs) = 0; \
    137	PT_REGS_BP(regs) = 0; \
    138	PT_REGS_AX(regs) = 0; \
    139	PT_REGS_R8(regs) = 0; \
    140	PT_REGS_R9(regs) = 0; \
    141	PT_REGS_R10(regs) = 0; \
    142	PT_REGS_R11(regs) = 0; \
    143	PT_REGS_R12(regs) = 0; \
    144	PT_REGS_R13(regs) = 0; \
    145	PT_REGS_R14(regs) = 0; \
    146	PT_REGS_R15(regs) = 0; \
    147} while (0)
    148
    149#define ELF_CORE_COPY_REGS(pr_reg, _regs)		\
    150	(pr_reg)[0] = (_regs)->regs.gp[0];			\
    151	(pr_reg)[1] = (_regs)->regs.gp[1];			\
    152	(pr_reg)[2] = (_regs)->regs.gp[2];			\
    153	(pr_reg)[3] = (_regs)->regs.gp[3];			\
    154	(pr_reg)[4] = (_regs)->regs.gp[4];			\
    155	(pr_reg)[5] = (_regs)->regs.gp[5];			\
    156	(pr_reg)[6] = (_regs)->regs.gp[6];			\
    157	(pr_reg)[7] = (_regs)->regs.gp[7];			\
    158	(pr_reg)[8] = (_regs)->regs.gp[8];			\
    159	(pr_reg)[9] = (_regs)->regs.gp[9];			\
    160	(pr_reg)[10] = (_regs)->regs.gp[10];			\
    161	(pr_reg)[11] = (_regs)->regs.gp[11];			\
    162	(pr_reg)[12] = (_regs)->regs.gp[12];			\
    163	(pr_reg)[13] = (_regs)->regs.gp[13];			\
    164	(pr_reg)[14] = (_regs)->regs.gp[14];			\
    165	(pr_reg)[15] = (_regs)->regs.gp[15];			\
    166	(pr_reg)[16] = (_regs)->regs.gp[16];			\
    167	(pr_reg)[17] = (_regs)->regs.gp[17];			\
    168	(pr_reg)[18] = (_regs)->regs.gp[18];			\
    169	(pr_reg)[19] = (_regs)->regs.gp[19];			\
    170	(pr_reg)[20] = (_regs)->regs.gp[20];			\
    171	(pr_reg)[21] = current->thread.arch.fs;			\
    172	(pr_reg)[22] = 0;					\
    173	(pr_reg)[23] = 0;					\
    174	(pr_reg)[24] = 0;					\
    175	(pr_reg)[25] = 0;					\
    176	(pr_reg)[26] = 0;
    177
    178#define ELF_PLATFORM "x86_64"
    179
    180/* No user-accessible fixmap addresses, i.e. vsyscall */
    181#define FIXADDR_USER_START      0
    182#define FIXADDR_USER_END        0
    183
    184#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
    185struct linux_binprm;
    186extern int arch_setup_additional_pages(struct linux_binprm *bprm,
    187	int uses_interp);
    188
    189extern unsigned long um_vdso_addr;
    190#define AT_SYSINFO_EHDR 33
    191#define ARCH_DLINFO	NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)
    192
    193#endif
    194
    195typedef unsigned long elf_greg_t;
    196
    197#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
    198typedef elf_greg_t elf_gregset_t[ELF_NGREG];
    199
    200typedef struct user_i387_struct elf_fpregset_t;
    201
    202struct task_struct;
    203
    204extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu);
    205
    206#define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu)
    207
    208#define ELF_EXEC_PAGESIZE 4096
    209
    210#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
    211
    212extern long elf_aux_hwcap;
    213#define ELF_HWCAP (elf_aux_hwcap)
    214
    215#define SET_PERSONALITY(ex) do {} while(0)
    216
    217#endif