Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / powerpc / include / asm / sections.h
blobe335a8f846afdd0d8388e782b02c5dba563bf206
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_SECTIONS_H
3 #define _ASM_POWERPC_SECTIONS_H
4 #ifdef __KERNEL__
6 #include <linux/elf.h>
7 #include <linux/uaccess.h>
8 #include <asm-generic/sections.h>
10 extern char __head_end[];
12 #ifdef __powerpc64__
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 static inline int in_kernel_text(unsigned long addr)
22 if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
23 return 1;
25 return 0;
28 static inline unsigned long kernel_toc_addr(void)
30 /* Defined by the linker, see vmlinux.lds.S */
31 extern unsigned long __toc_start;
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.
37 return (unsigned long)(&__toc_start) + 0x8000UL;
40 static inline int overlaps_interrupt_vector_text(unsigned long start,
41 unsigned long end)
43 unsigned long real_start, real_end;
44 real_start = __start_interrupts - _stext;
45 real_end = __end_interrupts - _stext;
47 return start < (unsigned long)__va(real_end) &&
48 (unsigned long)__va(real_start) < end;
51 static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
53 return start < (unsigned long)__init_end &&
54 (unsigned long)_stext < end;
57 static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
59 #ifdef CONFIG_KVM_GUEST
60 extern char kvm_tmp[];
61 return start < (unsigned long)kvm_tmp &&
62 (unsigned long)&kvm_tmp[1024 * 1024] < end;
63 #else
64 return 0;
65 #endif
68 #ifdef PPC64_ELF_ABI_v1
70 #define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1
72 #undef dereference_function_descriptor
73 static inline void *dereference_function_descriptor(void *ptr)
75 struct ppc64_opd_entry *desc = ptr;
76 void *p;
78 if (!probe_kernel_address(&desc->funcaddr, p))
79 ptr = p;
80 return ptr;
83 #undef dereference_kernel_function_descriptor
84 static inline void *dereference_kernel_function_descriptor(void *ptr)
86 if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd)
87 return ptr;
89 return dereference_function_descriptor(ptr);
91 #endif /* PPC64_ELF_ABI_v1 */
93 #endif
95 #endif /* __KERNEL__ */
96 #endif /* _ASM_POWERPC_SECTIONS_H */