Linux 4.13.16
[linux/fpc-iii.git] / arch / powerpc / include / asm / sections.h
blob7902d63588548a0cca22e7875d21f75264df49e3
1 #ifndef _ASM_POWERPC_SECTIONS_H
2 #define _ASM_POWERPC_SECTIONS_H
3 #ifdef __KERNEL__
5 #include <linux/elf.h>
6 #include <linux/uaccess.h>
7 #include <asm-generic/sections.h>
9 extern char __head_end[];
11 #ifdef __powerpc64__
13 extern char __start_interrupts[];
14 extern char __end_interrupts[];
16 extern char __prom_init_toc_start[];
17 extern char __prom_init_toc_end[];
19 static inline int in_kernel_text(unsigned long addr)
21 if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
22 return 1;
24 return 0;
27 static inline unsigned long kernel_toc_addr(void)
29 /* Defined by the linker, see vmlinux.lds.S */
30 extern unsigned long __toc_start;
33 * The TOC register (r2) points 32kB into the TOC, so that 64kB of
34 * the TOC can be addressed using a single machine instruction.
36 return (unsigned long)(&__toc_start) + 0x8000UL;
39 static inline int overlaps_interrupt_vector_text(unsigned long start,
40 unsigned long end)
42 unsigned long real_start, real_end;
43 real_start = __start_interrupts - _stext;
44 real_end = __end_interrupts - _stext;
46 return start < (unsigned long)__va(real_end) &&
47 (unsigned long)__va(real_start) < end;
50 static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
52 return start < (unsigned long)__init_end &&
53 (unsigned long)_stext < end;
56 static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
58 #ifdef CONFIG_KVM_GUEST
59 extern char kvm_tmp[];
60 return start < (unsigned long)kvm_tmp &&
61 (unsigned long)&kvm_tmp[1024 * 1024] < end;
62 #else
63 return 0;
64 #endif
67 #ifdef PPC64_ELF_ABI_v1
68 #undef dereference_function_descriptor
69 static inline void *dereference_function_descriptor(void *ptr)
71 struct ppc64_opd_entry *desc = ptr;
72 void *p;
74 if (!probe_kernel_address(&desc->funcaddr, p))
75 ptr = p;
76 return ptr;
78 #endif /* PPC64_ELF_ABI_v1 */
80 #endif
82 #endif /* __KERNEL__ */
83 #endif /* _ASM_POWERPC_SECTIONS_H */