1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_SECTIONS_H
3 #define _ASM_POWERPC_SECTIONS_H
7 #include <linux/uaccess.h>
8 #include <asm-generic/sections.h>
10 extern char __head_end[];
14 extern char __start_interrupts[];
15 extern char __end_interrupts[];
17 extern char __prom_init_toc_start[];
18 extern char __prom_init_toc_end[];
20 #ifdef CONFIG_PPC_POWERNV
21 extern char start_real_trampolines[];
22 extern char end_real_trampolines[];
23 extern char start_virt_trampolines[];
24 extern char end_virt_trampolines[];
27 static inline int in_kernel_text(unsigned long addr)
29 if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
35 static inline unsigned long kernel_toc_addr(void)
37 /* Defined by the linker, see vmlinux.lds.S */
38 extern unsigned long __toc_start;
41 * The TOC register (r2) points 32kB into the TOC, so that 64kB of
42 * the TOC can be addressed using a single machine instruction.
44 return (unsigned long)(&__toc_start) + 0x8000UL;
47 static inline int overlaps_interrupt_vector_text(unsigned long start,
50 unsigned long real_start, real_end;
51 real_start = __start_interrupts - _stext;
52 real_end = __end_interrupts - _stext;
54 return start < (unsigned long)__va(real_end) &&
55 (unsigned long)__va(real_start) < end;
58 static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
60 return start < (unsigned long)__init_end &&
61 (unsigned long)_stext < end;
64 static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
66 #ifdef CONFIG_KVM_GUEST
67 extern char kvm_tmp[];
68 return start < (unsigned long)kvm_tmp &&
69 (unsigned long)&kvm_tmp[1024 * 1024] < end;
75 #ifdef PPC64_ELF_ABI_v1
77 #define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1
79 #undef dereference_function_descriptor
80 static inline void *dereference_function_descriptor(void *ptr)
82 struct ppc64_opd_entry *desc = ptr;
85 if (!probe_kernel_address(&desc->funcaddr, p))
90 #undef dereference_kernel_function_descriptor
91 static inline void *dereference_kernel_function_descriptor(void *ptr)
93 if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd)
96 return dereference_function_descriptor(ptr);
98 #endif /* PPC64_ELF_ABI_v1 */
102 #endif /* __KERNEL__ */
103 #endif /* _ASM_POWERPC_SECTIONS_H */