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 17 #ifdef __powerpc64__ 18 19 extern char __start_interrupts[]; 20 extern char __end_interrupts[]; 21 22 extern char __prom_init_toc_start[]; 23 extern char __prom_init_toc_end[]; 24 25 #ifdef CONFIG_PPC_POWERNV 26 extern char start_real_trampolines[]; 27 extern char end_real_trampolines[]; 28 extern char start_virt_trampolines[]; 29 extern char end_virt_trampolines[]; 30 #endif 31 32 /* 33 * This assumes the kernel is never compiled -mcmodel=small or 34 * the total .toc is always less than 64k. 35 */ 36 static inline unsigned long kernel_toc_addr(void) 37 { 38 unsigned long toc_ptr; 39 40 asm volatile("mr %0, 2" : "=r" (toc_ptr)); 41 return toc_ptr; 42 } 43 44 static inline int overlaps_interrupt_vector_text(unsigned long start, 45 unsigned long end) 46 { 47 unsigned long real_start, real_end; 48 real_start = __start_interrupts - _stext; 49 real_end = __end_interrupts - _stext; 50 51 return start < (unsigned long)__va(real_end) && 52 (unsigned long)__va(real_start) < end; 53 } 54 55 static inline int overlaps_kernel_text(unsigned long start, unsigned long end) 56 { 57 return start < (unsigned long)__init_end && 58 (unsigned long)_stext < end; 59 } 60 61 #endif 62 63 #endif /* __KERNEL__ */ 64 #endif /* _ASM_POWERPC_SECTIONS_H */ 65