1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_SECTIONS_H
3 #define _ASM_POWERPC_SECTIONS_H
4 #ifdef __KERNEL__
5 
6 #include <linux/elf.h>
7 #include <linux/uaccess.h>
8 
9 #ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
10 typedef struct func_desc func_desc_t;
11 #endif
12 
13 #include <asm-generic/sections.h>
14 
15 extern char __head_end[];
16 extern char __srwx_boundary[];
17 
18 /* Patch sites */
19 extern s32 patch__call_flush_branch_caches1;
20 extern s32 patch__call_flush_branch_caches2;
21 extern s32 patch__call_flush_branch_caches3;
22 extern s32 patch__flush_count_cache_return;
23 extern s32 patch__flush_link_stack_return;
24 extern s32 patch__call_kvm_flush_link_stack;
25 extern s32 patch__call_kvm_flush_link_stack_p9;
26 extern s32 patch__memset_nocache, patch__memcpy_nocache;
27 
28 extern long flush_branch_caches;
29 extern long kvm_flush_link_stack;
30 
31 #ifdef __powerpc64__
32 
33 extern char __start_interrupts[];
34 extern char __end_interrupts[];
35 
36 #ifdef CONFIG_PPC_POWERNV
37 extern char start_real_trampolines[];
38 extern char end_real_trampolines[];
39 extern char start_virt_trampolines[];
40 extern char end_virt_trampolines[];
41 #endif
42 
43 /*
44  * This assumes the kernel is never compiled -mcmodel=small or
45  * the total .toc is always less than 64k.
46  */
kernel_toc_addr(void)47 static inline unsigned long kernel_toc_addr(void)
48 {
49 	unsigned long toc_ptr;
50 
51 	asm volatile("mr %0, 2" : "=r" (toc_ptr));
52 	return toc_ptr;
53 }
54 
overlaps_interrupt_vector_text(unsigned long start,unsigned long end)55 static inline int overlaps_interrupt_vector_text(unsigned long start,
56 							unsigned long end)
57 {
58 	unsigned long real_start, real_end;
59 	real_start = __start_interrupts - _stext;
60 	real_end = __end_interrupts - _stext;
61 
62 	return start < (unsigned long)__va(real_end) &&
63 		(unsigned long)__va(real_start) < end;
64 }
65 
overlaps_kernel_text(unsigned long start,unsigned long end)66 static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
67 {
68 	return start < (unsigned long)__init_end &&
69 		(unsigned long)_stext < end;
70 }
71 
72 #endif
73 
74 #endif /* __KERNEL__ */
75 #endif	/* _ASM_POWERPC_SECTIONS_H */
76