xref: /linux/arch/powerpc/include/asm/sections.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
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 
11 extern char __start_interrupts[];
12 extern char __end_interrupts[];
13 
14 extern char __prom_init_toc_start[];
15 extern char __prom_init_toc_end[];
16 
17 static 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 
25 static inline int overlaps_interrupt_vector_text(unsigned long start,
26 							unsigned long end)
27 {
28 	unsigned long real_start, real_end;
29 	real_start = __start_interrupts - _stext;
30 	real_end = __end_interrupts - _stext;
31 
32 	return start < (unsigned long)__va(real_end) &&
33 		(unsigned long)__va(real_start) < end;
34 }
35 
36 static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
37 {
38 	return start < (unsigned long)__init_end &&
39 		(unsigned long)_stext < end;
40 }
41 
42 static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
43 {
44 #ifdef CONFIG_KVM_GUEST
45 	extern char kvm_tmp[];
46 	return start < (unsigned long)kvm_tmp &&
47 		(unsigned long)&kvm_tmp[1024 * 1024] < end;
48 #else
49 	return 0;
50 #endif
51 }
52 
53 #if !defined(_CALL_ELF) || _CALL_ELF != 2
54 #undef dereference_function_descriptor
55 static inline void *dereference_function_descriptor(void *ptr)
56 {
57 	struct ppc64_opd_entry *desc = ptr;
58 	void *p;
59 
60 	if (!probe_kernel_address(&desc->funcaddr, p))
61 		ptr = p;
62 	return ptr;
63 }
64 #endif
65 
66 #endif
67 
68 #endif /* __KERNEL__ */
69 #endif	/* _ASM_POWERPC_SECTIONS_H */
70