1#ifndef _ASM_POWERPC_SECTIONS_H
2#define _ASM_POWERPC_SECTIONS_H
3#ifdef __KERNEL__
4
5#include <linux/elf.h>
6#include <linux/uaccess.h>
7#include <asm-generic/sections.h>
8
9#ifdef __powerpc64__
10
11extern char __start_interrupts[];
12extern char __end_interrupts[];
13
14extern char __prom_init_toc_start[];
15extern char __prom_init_toc_end[];
16
17static inline int in_kernel_text(unsigned long addr)
18{
19 if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
20 return 1;
21
22 return 0;
23}
24
25static inline unsigned long kernel_toc_addr(void)
26{
27
28 extern unsigned long __toc_start;
29
30
31
32
33
34 return (unsigned long)(&__toc_start) + 0x8000UL;
35}
36
37static inline int overlaps_interrupt_vector_text(unsigned long start,
38 unsigned long end)
39{
40 unsigned long real_start, real_end;
41 real_start = __start_interrupts - _stext;
42 real_end = __end_interrupts - _stext;
43
44 return start < (unsigned long)__va(real_end) &&
45 (unsigned long)__va(real_start) < end;
46}
47
48static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
49{
50 return start < (unsigned long)__init_end &&
51 (unsigned long)_stext < end;
52}
53
54static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
55{
56#ifdef CONFIG_KVM_GUEST
57 extern char kvm_tmp[];
58 return start < (unsigned long)kvm_tmp &&
59 (unsigned long)&kvm_tmp[1024 * 1024] < end;
60#else
61 return 0;
62#endif
63}
64
65#ifdef PPC64_ELF_ABI_v1
66#undef dereference_function_descriptor
67static inline void *dereference_function_descriptor(void *ptr)
68{
69 struct ppc64_opd_entry *desc = ptr;
70 void *p;
71
72 if (!probe_kernel_address(&desc->funcaddr, p))
73 ptr = p;
74 return ptr;
75}
76#endif
77
78#endif
79
80#endif
81#endif
82