1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_SECTIONS_H
3 #define _ASM_POWERPC_SECTIONS_H
7 #include <linux/uaccess.h>
9 #define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed
11 #include <asm-generic/sections.h>
13 extern bool init_mem_is_free
;
15 static inline int arch_is_kernel_initmem_freed(unsigned long addr
)
17 if (!init_mem_is_free
)
20 return addr
>= (unsigned long)__init_begin
&&
21 addr
< (unsigned long)__init_end
;
24 extern char __head_end
[];
28 extern char __start_interrupts
[];
29 extern char __end_interrupts
[];
31 extern char __prom_init_toc_start
[];
32 extern char __prom_init_toc_end
[];
34 #ifdef CONFIG_PPC_POWERNV
35 extern char start_real_trampolines
[];
36 extern char end_real_trampolines
[];
37 extern char start_virt_trampolines
[];
38 extern char end_virt_trampolines
[];
41 static inline int in_kernel_text(unsigned long addr
)
43 if (addr
>= (unsigned long)_stext
&& addr
< (unsigned long)__init_end
)
49 static inline unsigned long kernel_toc_addr(void)
51 /* Defined by the linker, see vmlinux.lds.S */
52 extern unsigned long __toc_start
;
55 * The TOC register (r2) points 32kB into the TOC, so that 64kB of
56 * the TOC can be addressed using a single machine instruction.
58 return (unsigned long)(&__toc_start
) + 0x8000UL
;
61 static inline int overlaps_interrupt_vector_text(unsigned long start
,
64 unsigned long real_start
, real_end
;
65 real_start
= __start_interrupts
- _stext
;
66 real_end
= __end_interrupts
- _stext
;
68 return start
< (unsigned long)__va(real_end
) &&
69 (unsigned long)__va(real_start
) < end
;
72 static inline int overlaps_kernel_text(unsigned long start
, unsigned long end
)
74 return start
< (unsigned long)__init_end
&&
75 (unsigned long)_stext
< end
;
78 #ifdef PPC64_ELF_ABI_v1
80 #define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1
82 #undef dereference_function_descriptor
83 static inline void *dereference_function_descriptor(void *ptr
)
85 struct ppc64_opd_entry
*desc
= ptr
;
88 if (!probe_kernel_address(&desc
->funcaddr
, p
))
93 #undef dereference_kernel_function_descriptor
94 static inline void *dereference_kernel_function_descriptor(void *ptr
)
96 if (ptr
< (void *)__start_opd
|| ptr
>= (void *)__end_opd
)
99 return dereference_function_descriptor(ptr
);
101 #endif /* PPC64_ELF_ABI_v1 */
105 #endif /* __KERNEL__ */
106 #endif /* _ASM_POWERPC_SECTIONS_H */