2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* ELF register definitions..
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
2012-10-09 15:47:26 +07:00
|
|
|
#ifndef _ASM_POWERPC_ELF_H
|
|
|
|
#define _ASM_POWERPC_ELF_H
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-10-09 15:47:26 +07:00
|
|
|
#include <linux/sched.h> /* for task_struct */
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/string.h>
|
|
|
|
#include <uapi/asm/elf.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is used to ensure we don't load something for the wrong architecture.
|
|
|
|
*/
|
|
|
|
#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
|
2008-01-03 08:03:11 +07:00
|
|
|
#define compat_elf_check_arch(x) ((x)->e_machine == EM_PPC)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-20 18:58:12 +07:00
|
|
|
#define CORE_DUMP_USE_REGSET
|
2005-09-20 10:47:41 +07:00
|
|
|
#define ELF_EXEC_PAGESIZE PAGE_SIZE
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-07-11 05:52:47 +07:00
|
|
|
/*
|
|
|
|
* This is the base location for PIE (ET_DYN with INTERP) loads. On
|
|
|
|
* 64-bit, this is raised to 4GB to leave the entire 32-bit address
|
|
|
|
* space open for things that want to use the area for 32-bit pointers.
|
|
|
|
*/
|
|
|
|
#define ELF_ET_DYN_BASE (is_32bit_task() ? 0x000400000UL : \
|
|
|
|
0x100000000UL)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-11-20 18:15:01 +07:00
|
|
|
#define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
|
|
|
|
|
2007-10-17 13:26:55 +07:00
|
|
|
/*
|
|
|
|
* Our registers are always unsigned longs, whether we're a 32 bit
|
|
|
|
* process or 64 bit, on either a 64 bit or 32 bit kernel.
|
|
|
|
*
|
|
|
|
* This macro relies on elf_regs[i] having the right type to truncate to,
|
|
|
|
* either u32 or u64. It defines the body of the elf_core_copy_regs
|
|
|
|
* function, either the native one with elf_gregset_t elf_regs or
|
|
|
|
* the 32-bit one with elf_gregset_t32 elf_regs.
|
|
|
|
*/
|
|
|
|
#define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \
|
|
|
|
int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \
|
|
|
|
(size_t)ELF_NGREG); \
|
|
|
|
for (i = 0; i < nregs; i++) \
|
|
|
|
elf_regs[i] = ((unsigned long *) regs)[i]; \
|
|
|
|
memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0]))
|
|
|
|
|
|
|
|
/* Common routine for both 32-bit and 64-bit native processes */
|
2005-09-20 07:17:27 +07:00
|
|
|
static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
|
2007-10-17 13:26:55 +07:00
|
|
|
struct pt_regs *regs)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-10-17 13:26:55 +07:00
|
|
|
PPC_ELF_CORE_COPY_REGS(elf_regs, regs);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2005-09-20 07:17:27 +07:00
|
|
|
#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-10-17 13:25:40 +07:00
|
|
|
typedef elf_vrregset_t elf_fpxregset_t;
|
|
|
|
|
2005-09-20 07:17:27 +07:00
|
|
|
/* ELF_HWCAP yields a mask that user programs can use to figure out what
|
2005-04-17 05:20:36 +07:00
|
|
|
instruction set this cpu supports. This could be done in userspace,
|
|
|
|
but it's not easy, and we've already done it here. */
|
2005-09-20 07:17:27 +07:00
|
|
|
# define ELF_HWCAP (cur_cpu_spec->cpu_user_features)
|
2013-04-18 00:33:11 +07:00
|
|
|
# define ELF_HWCAP2 (cur_cpu_spec->cpu_user_features2)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* This yields a string that ld.so will use to load implementation
|
|
|
|
specific libraries for optimization. This is more specific in
|
2006-01-14 06:11:39 +07:00
|
|
|
intent than poking at uname or /proc/cpuinfo. */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-14 06:11:39 +07:00
|
|
|
#define ELF_PLATFORM (cur_cpu_spec->platform)
|
2008-07-16 06:58:51 +07:00
|
|
|
|
|
|
|
/* While ELF_PLATFORM indicates the ISA supported by the platform, it
|
|
|
|
* may not accurately reflect the underlying behavior of the hardware
|
|
|
|
* (as in the case of running in Power5+ compatibility mode on a
|
|
|
|
* Power6 machine). ELF_BASE_PLATFORM allows ld.so to load libraries
|
|
|
|
* that are tuned for the real hardware.
|
|
|
|
*/
|
|
|
|
#define ELF_BASE_PLATFORM (powerpc_base_platform)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-14 06:11:39 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
# define ELF_PLAT_INIT(_r, load_addr) do { \
|
|
|
|
_r->gpr[2] = load_addr; \
|
|
|
|
} while (0)
|
|
|
|
#endif /* __powerpc64__ */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-20 07:17:27 +07:00
|
|
|
#ifdef __powerpc64__
|
2008-10-16 20:39:57 +07:00
|
|
|
# define SET_PERSONALITY(ex) \
|
2005-04-17 05:20:36 +07:00
|
|
|
do { \
|
2013-11-20 18:15:00 +07:00
|
|
|
if (((ex).e_flags & 0x3) == 2) \
|
|
|
|
set_thread_flag(TIF_ELF2ABI); \
|
2014-05-17 22:05:43 +07:00
|
|
|
else \
|
|
|
|
clear_thread_flag(TIF_ELF2ABI); \
|
2005-04-17 05:20:36 +07:00
|
|
|
if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
|
2010-01-30 17:20:59 +07:00
|
|
|
set_thread_flag(TIF_32BIT); \
|
2005-04-17 05:20:36 +07:00
|
|
|
else \
|
2010-01-30 17:20:59 +07:00
|
|
|
clear_thread_flag(TIF_32BIT); \
|
2005-06-08 18:59:15 +07:00
|
|
|
if (personality(current->personality) != PER_LINUX32) \
|
2008-06-30 23:12:13 +07:00
|
|
|
set_personality(PER_LINUX | \
|
|
|
|
(current->personality & (~PER_MASK))); \
|
2005-04-17 05:20:36 +07:00
|
|
|
} while (0)
|
|
|
|
/*
|
|
|
|
* An executable for which elf_read_implies_exec() returns TRUE will
|
2005-05-01 22:58:45 +07:00
|
|
|
* have the READ_IMPLIES_EXEC personality flag set automatically. This
|
|
|
|
* is only required to work around bugs in old 32bit toolchains. Since
|
|
|
|
* the 64bit ABI has never had these issues dont enable the workaround
|
|
|
|
* even if we have an executable stack.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2010-08-27 10:49:11 +07:00
|
|
|
# define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \
|
2009-04-28 10:32:36 +07:00
|
|
|
(exec_stk == EXSTACK_DEFAULT) : 0)
|
2005-09-20 07:17:27 +07:00
|
|
|
#else
|
2009-04-28 10:32:36 +07:00
|
|
|
# define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT)
|
2005-09-20 07:17:27 +07:00
|
|
|
#endif /* __powerpc64__ */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
extern int dcache_bsize;
|
|
|
|
extern int icache_bsize;
|
|
|
|
extern int ucache_bsize;
|
|
|
|
|
2005-11-11 17:15:21 +07:00
|
|
|
/* vDSO has arch_setup_additional_pages */
|
|
|
|
#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
|
2005-04-17 05:20:36 +07:00
|
|
|
struct linux_binprm;
|
2005-11-11 17:15:21 +07:00
|
|
|
extern int arch_setup_additional_pages(struct linux_binprm *bprm,
|
2008-12-25 19:38:35 +07:00
|
|
|
int uses_interp);
|
2011-07-14 19:07:13 +07:00
|
|
|
#define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-02-22 08:50:02 +07:00
|
|
|
/* 1GB for 64bit, 8MB for 32bit */
|
|
|
|
#define STACK_RND_MASK (is_32bit_task() ? \
|
|
|
|
(0x7ff >> (PAGE_SHIFT - 12)) : \
|
|
|
|
(0x3ffff >> (PAGE_SHIFT - 12)))
|
|
|
|
|
2006-11-28 01:18:55 +07:00
|
|
|
#ifdef CONFIG_SPU_BASE
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 06:46:37 +07:00
|
|
|
/* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
|
|
|
|
#define NT_SPU 1
|
|
|
|
|
|
|
|
#define ARCH_HAVE_EXTRA_ELF_NOTES
|
[POWERPC] spufs: Cleanup ELF coredump extra notes logic
To start with, arch_notes_size() etc. is a little too ambiguous a name for
my liking, so change the function names to be more explicit.
Calling through macros is ugly, especially with hidden parameters, so don't
do that, call the routines directly.
Use ARCH_HAVE_EXTRA_ELF_NOTES as the only flag, and based on it decide
whether we want the extern declarations or the empty versions.
Since we have empty routines, actually use them in the coredump code to
save a few #ifdefs.
We want to change the handling of foffset so that the write routine updates
foffset as it goes, instead of using file->f_pos (so that writing to a pipe
works). So pass foffset to the write routine, and for now just set it to
file->f_pos at the end of writing.
It should also be possible for the write routine to fail, so change it to
return int and treat a non-zero return as failure.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-09-19 11:38:12 +07:00
|
|
|
|
|
|
|
#endif /* CONFIG_SPU_BASE */
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 06:46:37 +07:00
|
|
|
|
2017-02-03 13:20:07 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
|
|
|
|
#define get_cache_geometry(level) \
|
|
|
|
(ppc64_caches.level.assoc << 16 | ppc64_caches.level.line_size)
|
|
|
|
|
|
|
|
#define ARCH_DLINFO_CACHE_GEOMETRY \
|
|
|
|
NEW_AUX_ENT(AT_L1I_CACHESIZE, ppc64_caches.l1i.size); \
|
|
|
|
NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, get_cache_geometry(l1i)); \
|
2017-03-06 17:51:32 +07:00
|
|
|
NEW_AUX_ENT(AT_L1D_CACHESIZE, ppc64_caches.l1d.size); \
|
|
|
|
NEW_AUX_ENT(AT_L1D_CACHEGEOMETRY, get_cache_geometry(l1d)); \
|
2017-02-03 13:20:07 +07:00
|
|
|
NEW_AUX_ENT(AT_L2_CACHESIZE, ppc64_caches.l2.size); \
|
|
|
|
NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, get_cache_geometry(l2)); \
|
|
|
|
NEW_AUX_ENT(AT_L3_CACHESIZE, ppc64_caches.l3.size); \
|
|
|
|
NEW_AUX_ENT(AT_L3_CACHEGEOMETRY, get_cache_geometry(l3))
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define ARCH_DLINFO_CACHE_GEOMETRY
|
|
|
|
#endif
|
|
|
|
|
2017-01-09 06:31:42 +07:00
|
|
|
/*
|
|
|
|
* The requirements here are:
|
|
|
|
* - keep the final alignment of sp (sp & 0xf)
|
|
|
|
* - make sure the 32-bit value at the first 16 byte aligned position of
|
|
|
|
* AUXV is greater than 16 for glibc compatibility.
|
|
|
|
* AT_IGNOREPPC is used for that.
|
|
|
|
* - for compatibility with glibc ARCH_DLINFO must always be defined on PPC,
|
|
|
|
* even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
|
|
|
|
* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes
|
|
|
|
*/
|
|
|
|
#define ARCH_DLINFO \
|
|
|
|
do { \
|
|
|
|
/* Handle glibc compatibility. */ \
|
|
|
|
NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
|
|
|
|
NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
|
|
|
|
/* Cache size items */ \
|
|
|
|
NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize); \
|
|
|
|
NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize); \
|
|
|
|
NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize); \
|
|
|
|
VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base); \
|
2017-02-03 13:20:07 +07:00
|
|
|
ARCH_DLINFO_CACHE_GEOMETRY; \
|
2017-01-09 06:31:42 +07:00
|
|
|
} while (0)
|
|
|
|
|
2005-09-20 07:17:27 +07:00
|
|
|
#endif /* _ASM_POWERPC_ELF_H */
|