2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-09-17 10:39:46 -05:00
|
|
|
#ifndef _ASM_POWERPC_SECTIONS_H
|
|
|
|
|
#define _ASM_POWERPC_SECTIONS_H
|
2005-12-16 22:43:46 +01:00
|
|
|
#ifdef __KERNEL__
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-09-09 14:04:18 +00:00
|
|
|
#include <linux/elf.h>
|
|
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm-generic/sections.h>
|
|
|
|
|
|
2017-04-19 20:59:51 +05:30
|
|
|
extern char __head_end[];
|
|
|
|
|
|
2005-09-17 10:39:46 -05:00
|
|
|
#ifdef __powerpc64__
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2014-01-31 00:31:04 +05:30
|
|
|
extern char __start_interrupts[];
|
2011-11-14 12:54:47 +00:00
|
|
|
extern char __end_interrupts[];
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-11-26 17:39:03 +00:00
|
|
|
extern char __prom_init_toc_start[];
|
|
|
|
|
extern char __prom_init_toc_end[];
|
|
|
|
|
|
2005-04-16 15:20:36 -07: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 15:26:53 +11: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-31 00:31:04 +05:30
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-30 11:43:47 +10: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 12:17:26 +02: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
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-06 22:26:10 +05:30
|
|
|
#ifdef PPC64_ELF_ABI_v1
|
2017-11-10 08:48:27 +09:00
|
|
|
|
|
|
|
|
#define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1
|
|
|
|
|
|
2008-09-03 20:43:36 -05: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;
|
|
|
|
|
}
|
2017-11-10 08:48:27 +09:00
|
|
|
|
|
|
|
|
#undef dereference_kernel_function_descriptor
|
|
|
|
|
static inline void *dereference_kernel_function_descriptor(void *ptr)
|
|
|
|
|
{
|
|
|
|
|
if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd)
|
|
|
|
|
return ptr;
|
|
|
|
|
|
|
|
|
|
return dereference_function_descriptor(ptr);
|
|
|
|
|
}
|
2016-06-06 22:26:10 +05:30
|
|
|
#endif /* PPC64_ELF_ABI_v1 */
|
2008-09-03 20:43:36 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|
2005-09-17 10:39:46 -05:00
|
|
|
|
2005-12-16 22:43:46 +01:00
|
|
|
#endif /* __KERNEL__ */
|
2005-09-17 10:39:46 -05:00
|
|
|
#endif /* _ASM_POWERPC_SECTIONS_H */
|