Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
fbcd54b1 JL |
2 | #ifndef _ASM_POWERPC_SECTIONS_H |
3 | #define _ASM_POWERPC_SECTIONS_H | |
88ced031 | 4 | #ifdef __KERNEL__ |
1da177e4 | 5 | |
2d291e90 JB |
6 | #include <linux/elf.h> |
7 | #include <linux/uaccess.h> | |
6f07048c | 8 | |
1da177e4 LT |
9 | #include <asm-generic/sections.h> |
10 | ||
7aa5b018 NR |
11 | extern char __head_end[]; |
12 | ||
fbcd54b1 | 13 | #ifdef __powerpc64__ |
1da177e4 | 14 | |
429d2e83 | 15 | extern char __start_interrupts[]; |
d715e433 | 16 | extern char __end_interrupts[]; |
1da177e4 | 17 | |
5ac47f7a AB |
18 | extern char __prom_init_toc_start[]; |
19 | extern char __prom_init_toc_end[]; | |
20 | ||
bd3524fe NP |
21 | #ifdef CONFIG_PPC_POWERNV |
22 | extern char start_real_trampolines[]; | |
23 | extern char end_real_trampolines[]; | |
24 | extern char start_virt_trampolines[]; | |
25 | extern char end_virt_trampolines[]; | |
26 | #endif | |
27 | ||
a5cab83c ME |
28 | static inline unsigned long kernel_toc_addr(void) |
29 | { | |
30 | /* Defined by the linker, see vmlinux.lds.S */ | |
31 | extern unsigned long __toc_start; | |
32 | ||
33 | /* | |
34 | * The TOC register (r2) points 32kB into the TOC, so that 64kB of | |
35 | * the TOC can be addressed using a single machine instruction. | |
36 | */ | |
37 | return (unsigned long)(&__toc_start) + 0x8000UL; | |
38 | } | |
39 | ||
429d2e83 MS |
40 | static inline int overlaps_interrupt_vector_text(unsigned long start, |
41 | unsigned long end) | |
42 | { | |
43 | unsigned long real_start, real_end; | |
44 | real_start = __start_interrupts - _stext; | |
45 | real_end = __end_interrupts - _stext; | |
46 | ||
47 | return start < (unsigned long)__va(real_end) && | |
48 | (unsigned long)__va(real_start) < end; | |
49 | } | |
50 | ||
549e8152 PM |
51 | static inline int overlaps_kernel_text(unsigned long start, unsigned long end) |
52 | { | |
53 | return start < (unsigned long)__init_end && | |
54 | (unsigned long)_stext < end; | |
55 | } | |
56 | ||
f55d9665 | 57 | #ifdef PPC64_ELF_ABI_v1 |
5633e85b SS |
58 | |
59 | #define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1 | |
60 | ||
deac93df | 61 | #undef dereference_function_descriptor |
2d291e90 JB |
62 | static inline void *dereference_function_descriptor(void *ptr) |
63 | { | |
64 | struct ppc64_opd_entry *desc = ptr; | |
65 | void *p; | |
66 | ||
0c389d89 | 67 | if (!get_kernel_nofault(p, (void *)&desc->funcaddr)) |
2d291e90 JB |
68 | ptr = p; |
69 | return ptr; | |
70 | } | |
5633e85b SS |
71 | |
72 | #undef dereference_kernel_function_descriptor | |
73 | static inline void *dereference_kernel_function_descriptor(void *ptr) | |
74 | { | |
75 | if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd) | |
76 | return ptr; | |
77 | ||
78 | return dereference_function_descriptor(ptr); | |
79 | } | |
f55d9665 | 80 | #endif /* PPC64_ELF_ABI_v1 */ |
deac93df | 81 | |
1da177e4 | 82 | #endif |
fbcd54b1 | 83 | |
88ced031 | 84 | #endif /* __KERNEL__ */ |
fbcd54b1 | 85 | #endif /* _ASM_POWERPC_SECTIONS_H */ |