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 extern char __head_end[]; 10 11 #ifdef __powerpc64__ 12 13 extern char __start_interrupts[]; 14 extern char __end_interrupts[]; 15 16 extern char __prom_init_toc_start[]; 17 extern char __prom_init_toc_end[]; 18 19 static inline int in_kernel_text(unsigned long addr) 20 { 21 if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end) 22 return 1; 23 24 return 0; 25 } 26 27 static inline unsigned long kernel_toc_addr(void) 28 { 29 /* Defined by the linker, see vmlinux.lds.S */ 30 extern unsigned long __toc_start; 31 32 /* 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. 35 */ 36 return (unsigned long)(&__toc_start) + 0x8000UL; 37 } 38 39 static inline int overlaps_interrupt_vector_text(unsigned long start, 40 unsigned long end) 41 { 42 unsigned long real_start, real_end; 43 real_start = __start_interrupts - _stext; 44 real_end = __end_interrupts - _stext; 45 46 return start < (unsigned long)__va(real_end) && 47 (unsigned long)__va(real_start) < end; 48 } 49 50 static inline int overlaps_kernel_text(unsigned long start, unsigned long end) 51 { 52 return start < (unsigned long)__init_end && 53 (unsigned long)_stext < end; 54 } 55 56 static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end) 57 { 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 65 } 66 67 #ifdef PPC64_ELF_ABI_v1 68 #undef dereference_function_descriptor 69 static inline void *dereference_function_descriptor(void *ptr) 70 { 71 struct ppc64_opd_entry *desc = ptr; 72 void *p; 73 74 if (!probe_kernel_address(&desc->funcaddr, p)) 75 ptr = p; 76 return ptr; 77 } 78 #endif /* PPC64_ELF_ABI_v1 */ 79 80 #endif 81 82 #endif /* __KERNEL__ */ 83 #endif /* _ASM_POWERPC_SECTIONS_H */ 84