Linux Audio

Check our new training course

Loading...
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * ELF register definitions..
 
 
 
 
 
  4 */
  5#ifndef _ASM_POWERPC_ELF_H
  6#define _ASM_POWERPC_ELF_H
  7
  8#include <linux/sched.h>	/* for task_struct */
  9#include <asm/page.h>
 10#include <asm/string.h>
 11#include <uapi/asm/elf.h>
 12
 13/*
 14 * This is used to ensure we don't load something for the wrong architecture.
 15 */
 16#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
 17#define compat_elf_check_arch(x)	((x)->e_machine == EM_PPC)
 18
 19#define CORE_DUMP_USE_REGSET
 20#define ELF_EXEC_PAGESIZE	PAGE_SIZE
 21
 22/*
 23 * This is the base location for PIE (ET_DYN with INTERP) loads. On
 24 * 64-bit, this is raised to 4GB to leave the entire 32-bit address
 25 * space open for things that want to use the area for 32-bit pointers.
 26 */
 27#define ELF_ET_DYN_BASE		(is_32bit_task() ? 0x000400000UL : \
 28						   0x100000000UL)
 29
 30#define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
 31
 32/*
 33 * Our registers are always unsigned longs, whether we're a 32 bit
 34 * process or 64 bit, on either a 64 bit or 32 bit kernel.
 35 *
 36 * This macro relies on elf_regs[i] having the right type to truncate to,
 37 * either u32 or u64.  It defines the body of the elf_core_copy_regs
 38 * function, either the native one with elf_gregset_t elf_regs or
 39 * the 32-bit one with elf_gregset_t32 elf_regs.
 40 */
 41#define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \
 42	int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \
 43			   (size_t)ELF_NGREG);			  \
 44	for (i = 0; i < nregs; i++) \
 45		elf_regs[i] = ((unsigned long *) regs)[i]; \
 46	memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0]))
 47
 48/* Common routine for both 32-bit and 64-bit native processes */
 49static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
 50					  struct pt_regs *regs)
 51{
 52	PPC_ELF_CORE_COPY_REGS(elf_regs, regs);
 53}
 54#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
 55
 
 
 56/* ELF_HWCAP yields a mask that user programs can use to figure out what
 57   instruction set this cpu supports.  This could be done in userspace,
 58   but it's not easy, and we've already done it here.  */
 59# define ELF_HWCAP	(cur_cpu_spec->cpu_user_features)
 60# define ELF_HWCAP2	(cur_cpu_spec->cpu_user_features2)
 61
 62/* This yields a string that ld.so will use to load implementation
 63   specific libraries for optimization.  This is more specific in
 64   intent than poking at uname or /proc/cpuinfo.  */
 65
 66#define ELF_PLATFORM	(cur_cpu_spec->platform)
 67
 68/* While ELF_PLATFORM indicates the ISA supported by the platform, it
 69 * may not accurately reflect the underlying behavior of the hardware
 70 * (as in the case of running in Power5+ compatibility mode on a
 71 * Power6 machine).  ELF_BASE_PLATFORM allows ld.so to load libraries
 72 * that are tuned for the real hardware.
 73 */
 74#define ELF_BASE_PLATFORM (powerpc_base_platform)
 75
 76#ifdef __powerpc64__
 77# define ELF_PLAT_INIT(_r, load_addr)	do {	\
 78	_r->gpr[2] = load_addr; 		\
 79} while (0)
 80#endif /* __powerpc64__ */
 81
 82#ifdef __powerpc64__
 83# define SET_PERSONALITY(ex)					\
 84do {								\
 85	if (((ex).e_flags & 0x3) == 2)				\
 86		set_thread_flag(TIF_ELF2ABI);			\
 87	else							\
 88		clear_thread_flag(TIF_ELF2ABI);			\
 89	if ((ex).e_ident[EI_CLASS] == ELFCLASS32)		\
 90		set_thread_flag(TIF_32BIT);			\
 91	else							\
 92		clear_thread_flag(TIF_32BIT);			\
 93	if (personality(current->personality) != PER_LINUX32)	\
 94		set_personality(PER_LINUX |			\
 95			(current->personality & (~PER_MASK)));	\
 96} while (0)
 97/*
 98 * An executable for which elf_read_implies_exec() returns TRUE will
 99 * have the READ_IMPLIES_EXEC personality flag set automatically. This
100 * is only required to work around bugs in old 32bit toolchains. Since
101 * the 64bit ABI has never had these issues dont enable the workaround
102 * even if we have an executable stack.
103 */
104# define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \
105		(exec_stk == EXSTACK_DEFAULT) : 0)
106#else 
107# define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT)
108#endif /* __powerpc64__ */
109
110extern int dcache_bsize;
111extern int icache_bsize;
112extern int ucache_bsize;
113
114/* vDSO has arch_setup_additional_pages */
115#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
116struct linux_binprm;
117extern int arch_setup_additional_pages(struct linux_binprm *bprm,
118				       int uses_interp);
119#define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b)
120
121/* 1GB for 64bit, 8MB for 32bit */
122#define STACK_RND_MASK (is_32bit_task() ? \
123	(0x7ff >> (PAGE_SHIFT - 12)) : \
124	(0x3ffff >> (PAGE_SHIFT - 12)))
125
126#ifdef CONFIG_SPU_BASE
127/* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
128#define NT_SPU		1
129
130#define ARCH_HAVE_EXTRA_ELF_NOTES
131
132#endif /* CONFIG_SPU_BASE */
133
134#ifdef CONFIG_PPC64
135
136#define get_cache_geometry(level) \
137	(ppc64_caches.level.assoc << 16 | ppc64_caches.level.line_size)
138
139#define ARCH_DLINFO_CACHE_GEOMETRY					\
140	NEW_AUX_ENT(AT_L1I_CACHESIZE, ppc64_caches.l1i.size);		\
141	NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, get_cache_geometry(l1i));	\
142	NEW_AUX_ENT(AT_L1D_CACHESIZE, ppc64_caches.l1d.size);		\
143	NEW_AUX_ENT(AT_L1D_CACHEGEOMETRY, get_cache_geometry(l1d));	\
144	NEW_AUX_ENT(AT_L2_CACHESIZE, ppc64_caches.l2.size);		\
145	NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, get_cache_geometry(l2));	\
146	NEW_AUX_ENT(AT_L3_CACHESIZE, ppc64_caches.l3.size);		\
147	NEW_AUX_ENT(AT_L3_CACHEGEOMETRY, get_cache_geometry(l3))
148
149#else
150#define ARCH_DLINFO_CACHE_GEOMETRY
151#endif
152
153/*
154 * The requirements here are:
155 * - keep the final alignment of sp (sp & 0xf)
156 * - make sure the 32-bit value at the first 16 byte aligned position of
157 *   AUXV is greater than 16 for glibc compatibility.
158 *   AT_IGNOREPPC is used for that.
159 * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC,
160 *   even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
161 * update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes
162 */
163#define COMMON_ARCH_DLINFO						\
164do {									\
165	/* Handle glibc compatibility. */				\
166	NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC);			\
167	NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC);			\
168	/* Cache size items */						\
169	NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize);			\
170	NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize);			\
171	NEW_AUX_ENT(AT_UCACHEBSIZE, 0);					\
172	VDSO_AUX_ENT(AT_SYSINFO_EHDR, (unsigned long)current->mm->context.vdso);\
173	ARCH_DLINFO_CACHE_GEOMETRY;					\
174} while (0)
175
176#define ARCH_DLINFO							\
177do {									\
178	COMMON_ARCH_DLINFO;						\
179	NEW_AUX_ENT(AT_MINSIGSTKSZ, get_min_sigframe_size());		\
180} while (0)
181
182#define COMPAT_ARCH_DLINFO						\
183do {									\
184	COMMON_ARCH_DLINFO;						\
185	NEW_AUX_ENT(AT_MINSIGSTKSZ, get_min_sigframe_size_compat());	\
186} while (0)
187
188/* Relocate the kernel image to @final_address */
189void relocate(unsigned long final_address);
190
191struct func_desc {
192	unsigned long addr;
193	unsigned long toc;
194	unsigned long env;
195};
196
197#endif /* _ASM_POWERPC_ELF_H */
v4.10.11
 
  1/*
  2 * ELF register definitions..
  3 *
  4 * This program is free software; you can redistribute it and/or
  5 * modify it under the terms of the GNU General Public License
  6 * as published by the Free Software Foundation; either version
  7 * 2 of the License, or (at your option) any later version.
  8 */
  9#ifndef _ASM_POWERPC_ELF_H
 10#define _ASM_POWERPC_ELF_H
 11
 12#include <linux/sched.h>	/* for task_struct */
 13#include <asm/page.h>
 14#include <asm/string.h>
 15#include <uapi/asm/elf.h>
 16
 17/*
 18 * This is used to ensure we don't load something for the wrong architecture.
 19 */
 20#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
 21#define compat_elf_check_arch(x)	((x)->e_machine == EM_PPC)
 22
 23#define CORE_DUMP_USE_REGSET
 24#define ELF_EXEC_PAGESIZE	PAGE_SIZE
 25
 26/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
 27   use of this is to invoke "./ld.so someprog" to test out a new version of
 28   the loader.  We need to make sure that it is out of the way of the program
 29   that it will "exec", and that there is sufficient room for the brk.  */
 30
 31#define ELF_ET_DYN_BASE	0x20000000
 
 32
 33#define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
 34
 35/*
 36 * Our registers are always unsigned longs, whether we're a 32 bit
 37 * process or 64 bit, on either a 64 bit or 32 bit kernel.
 38 *
 39 * This macro relies on elf_regs[i] having the right type to truncate to,
 40 * either u32 or u64.  It defines the body of the elf_core_copy_regs
 41 * function, either the native one with elf_gregset_t elf_regs or
 42 * the 32-bit one with elf_gregset_t32 elf_regs.
 43 */
 44#define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \
 45	int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \
 46			   (size_t)ELF_NGREG);			  \
 47	for (i = 0; i < nregs; i++) \
 48		elf_regs[i] = ((unsigned long *) regs)[i]; \
 49	memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0]))
 50
 51/* Common routine for both 32-bit and 64-bit native processes */
 52static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
 53					  struct pt_regs *regs)
 54{
 55	PPC_ELF_CORE_COPY_REGS(elf_regs, regs);
 56}
 57#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
 58
 59typedef elf_vrregset_t elf_fpxregset_t;
 60
 61/* ELF_HWCAP yields a mask that user programs can use to figure out what
 62   instruction set this cpu supports.  This could be done in userspace,
 63   but it's not easy, and we've already done it here.  */
 64# define ELF_HWCAP	(cur_cpu_spec->cpu_user_features)
 65# define ELF_HWCAP2	(cur_cpu_spec->cpu_user_features2)
 66
 67/* This yields a string that ld.so will use to load implementation
 68   specific libraries for optimization.  This is more specific in
 69   intent than poking at uname or /proc/cpuinfo.  */
 70
 71#define ELF_PLATFORM	(cur_cpu_spec->platform)
 72
 73/* While ELF_PLATFORM indicates the ISA supported by the platform, it
 74 * may not accurately reflect the underlying behavior of the hardware
 75 * (as in the case of running in Power5+ compatibility mode on a
 76 * Power6 machine).  ELF_BASE_PLATFORM allows ld.so to load libraries
 77 * that are tuned for the real hardware.
 78 */
 79#define ELF_BASE_PLATFORM (powerpc_base_platform)
 80
 81#ifdef __powerpc64__
 82# define ELF_PLAT_INIT(_r, load_addr)	do {	\
 83	_r->gpr[2] = load_addr; 		\
 84} while (0)
 85#endif /* __powerpc64__ */
 86
 87#ifdef __powerpc64__
 88# define SET_PERSONALITY(ex)					\
 89do {								\
 90	if (((ex).e_flags & 0x3) == 2)				\
 91		set_thread_flag(TIF_ELF2ABI);			\
 92	else							\
 93		clear_thread_flag(TIF_ELF2ABI);			\
 94	if ((ex).e_ident[EI_CLASS] == ELFCLASS32)		\
 95		set_thread_flag(TIF_32BIT);			\
 96	else							\
 97		clear_thread_flag(TIF_32BIT);			\
 98	if (personality(current->personality) != PER_LINUX32)	\
 99		set_personality(PER_LINUX |			\
100			(current->personality & (~PER_MASK)));	\
101} while (0)
102/*
103 * An executable for which elf_read_implies_exec() returns TRUE will
104 * have the READ_IMPLIES_EXEC personality flag set automatically. This
105 * is only required to work around bugs in old 32bit toolchains. Since
106 * the 64bit ABI has never had these issues dont enable the workaround
107 * even if we have an executable stack.
108 */
109# define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \
110		(exec_stk == EXSTACK_DEFAULT) : 0)
111#else 
112# define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT)
113#endif /* __powerpc64__ */
114
115extern int dcache_bsize;
116extern int icache_bsize;
117extern int ucache_bsize;
118
119/* vDSO has arch_setup_additional_pages */
120#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
121struct linux_binprm;
122extern int arch_setup_additional_pages(struct linux_binprm *bprm,
123				       int uses_interp);
124#define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b)
125
126/* 1GB for 64bit, 8MB for 32bit */
127#define STACK_RND_MASK (is_32bit_task() ? \
128	(0x7ff >> (PAGE_SHIFT - 12)) : \
129	(0x3ffff >> (PAGE_SHIFT - 12)))
130
131#ifdef CONFIG_SPU_BASE
132/* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
133#define NT_SPU		1
134
135#define ARCH_HAVE_EXTRA_ELF_NOTES
136
137#endif /* CONFIG_SPU_BASE */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
139#endif /* _ASM_POWERPC_ELF_H */