sections.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _ASM_POWERPC_SECTIONS_H
  2. #define _ASM_POWERPC_SECTIONS_H
  3. #ifdef __KERNEL__
  4. #include <linux/elf.h>
  5. #include <linux/uaccess.h>
  6. #include <asm-generic/sections.h>
  7. #ifdef __powerpc64__
  8. extern char __start_interrupts[];
  9. extern char __end_interrupts[];
  10. extern char __prom_init_toc_start[];
  11. extern char __prom_init_toc_end[];
  12. static inline int in_kernel_text(unsigned long addr)
  13. {
  14. if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
  15. return 1;
  16. return 0;
  17. }
  18. static inline unsigned long kernel_toc_addr(void)
  19. {
  20. /* Defined by the linker, see vmlinux.lds.S */
  21. extern unsigned long __toc_start;
  22. /*
  23. * The TOC register (r2) points 32kB into the TOC, so that 64kB of
  24. * the TOC can be addressed using a single machine instruction.
  25. */
  26. return (unsigned long)(&__toc_start) + 0x8000UL;
  27. }
  28. static inline int overlaps_interrupt_vector_text(unsigned long start,
  29. unsigned long end)
  30. {
  31. unsigned long real_start, real_end;
  32. real_start = __start_interrupts - _stext;
  33. real_end = __end_interrupts - _stext;
  34. return start < (unsigned long)__va(real_end) &&
  35. (unsigned long)__va(real_start) < end;
  36. }
  37. static inline int overlaps_kernel_text(unsigned long start, unsigned long end)
  38. {
  39. return start < (unsigned long)__init_end &&
  40. (unsigned long)_stext < end;
  41. }
  42. static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end)
  43. {
  44. #ifdef CONFIG_KVM_GUEST
  45. extern char kvm_tmp[];
  46. return start < (unsigned long)kvm_tmp &&
  47. (unsigned long)&kvm_tmp[1024 * 1024] < end;
  48. #else
  49. return 0;
  50. #endif
  51. }
  52. #ifdef PPC64_ELF_ABI_v1
  53. #undef dereference_function_descriptor
  54. static inline void *dereference_function_descriptor(void *ptr)
  55. {
  56. struct ppc64_opd_entry *desc = ptr;
  57. void *p;
  58. if (!probe_kernel_address(&desc->funcaddr, p))
  59. ptr = p;
  60. return ptr;
  61. }
  62. #endif /* PPC64_ELF_ABI_v1 */
  63. #endif
  64. #endif /* __KERNEL__ */
  65. #endif /* _ASM_POWERPC_SECTIONS_H */