2005-09-17 15:39:46 +00:00
|
|
|
#ifndef _ASM_POWERPC_SECTIONS_H
|
|
|
|
#define _ASM_POWERPC_SECTIONS_H
|
2005-12-16 21:43:46 +00:00
|
|
|
#ifdef __KERNEL__
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-09-09 14:04:18 +00:00
|
|
|
#include <linux/elf.h>
|
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm-generic/sections.h>
|
|
|
|
|
2005-09-17 15:39:46 +00:00
|
|
|
#ifdef __powerpc64__
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-01-30 19:01:04 +00:00
|
|
|
extern char __start_interrupts[];
|
2011-11-14 12:54:47 +00:00
|
|
|
extern char __end_interrupts[];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-11-26 17:39:03 +00:00
|
|
|
extern char __prom_init_toc_start[];
|
|
|
|
extern char __prom_init_toc_end[];
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline int in_kernel_text(unsigned long addr)
|
|
|
|
{
|
|
|
|
if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-03 04:26:53 +00:00
|
|
|
static inline unsigned long kernel_toc_addr(void)
|
|
|
|
{
|
|
|
|
/* Defined by the linker, see vmlinux.lds.S */
|
|
|
|
extern unsigned long __toc_start;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The TOC register (r2) points 32kB into the TOC, so that 64kB of
|
|
|
|
* the TOC can be addressed using a single machine instruction.
|
|
|
|
*/
|
|
|
|
return (unsigned long)(&__toc_start) + 0x8000UL;
|
|
|
|
}
|
|
|
|
|
2014-01-30 19:01:04 +00:00
|
|
|
static inline int overlaps_interrupt_vector_text(unsigned long start,
|
|
|
|
unsigned long end)
|
|
|
|
{
|
|
|
|
unsigned long real_start, real_end;
|
|
|
|
real_start = __start_interrupts - _stext;
|
|
|
|
real_end = __end_interrupts - _stext;
|
|
|
|
|
|
|
|
return start < (unsigned long)__va(real_end) &&
|
|
|
|
(unsigned long)__va(real_start) < end;
|
|
|
|
}
|
|
|
|
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 01:43:47 +00:00
|
|
|
static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
return start < (unsigned long)__init_end &&
|
|
|
|
(unsigned long)_stext < end;
|
|
|
|
}
|
|
|
|
|
2014-04-29 10:17:26 +00:00
|
|
|
static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_KVM_GUEST
|
|
|
|
extern char kvm_tmp[];
|
|
|
|
return start < (unsigned long)kvm_tmp &&
|
|
|
|
(unsigned long)&kvm_tmp[1024 * 1024] < end;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-11 01:15:27 +00:00
|
|
|
#if !defined(_CALL_ELF) || _CALL_ELF != 2
|
2008-09-04 01:43:36 +00:00
|
|
|
#undef dereference_function_descriptor
|
2008-09-09 14:04:18 +00:00
|
|
|
static inline void *dereference_function_descriptor(void *ptr)
|
|
|
|
{
|
|
|
|
struct ppc64_opd_entry *desc = ptr;
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
if (!probe_kernel_address(&desc->funcaddr, p))
|
|
|
|
ptr = p;
|
|
|
|
return ptr;
|
|
|
|
}
|
2014-03-11 01:15:27 +00:00
|
|
|
#endif
|
2008-09-04 01:43:36 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2005-09-17 15:39:46 +00:00
|
|
|
|
2005-12-16 21:43:46 +00:00
|
|
|
#endif /* __KERNEL__ */
|
2005-09-17 15:39:46 +00:00
|
|
|
#endif /* _ASM_POWERPC_SECTIONS_H */
|