processor.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * arch/arm/include/asm/processor.h
  3. *
  4. * Copyright (C) 1995-1999 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __ASM_ARM_PROCESSOR_H
  11. #define __ASM_ARM_PROCESSOR_H
  12. #ifdef __KERNEL__
  13. #include <asm/hw_breakpoint.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/types.h>
  16. #include <asm/unified.h>
  17. #ifdef __KERNEL__
  18. #define STACK_TOP ((current->personality & ADDR_LIMIT_32BIT) ? \
  19. TASK_SIZE : TASK_SIZE_26)
  20. #define STACK_TOP_MAX TASK_SIZE
  21. #endif
  22. struct debug_info {
  23. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  24. struct perf_event *hbp[ARM_MAX_HBP_SLOTS];
  25. #endif
  26. };
  27. struct thread_struct {
  28. /* fault info */
  29. unsigned long address;
  30. unsigned long trap_no;
  31. unsigned long error_code;
  32. /* debugging */
  33. struct debug_info debug;
  34. };
  35. /*
  36. * Everything usercopied to/from thread_struct is statically-sized, so
  37. * no hardened usercopy whitelist is needed.
  38. */
  39. static inline void arch_thread_struct_whitelist(unsigned long *offset,
  40. unsigned long *size)
  41. {
  42. *offset = *size = 0;
  43. }
  44. #define INIT_THREAD { }
  45. #define start_thread(regs,pc,sp) \
  46. ({ \
  47. unsigned long r7, r8, r9; \
  48. \
  49. if (IS_ENABLED(CONFIG_BINFMT_ELF_FDPIC)) { \
  50. r7 = regs->ARM_r7; \
  51. r8 = regs->ARM_r8; \
  52. r9 = regs->ARM_r9; \
  53. } \
  54. memset(regs->uregs, 0, sizeof(regs->uregs)); \
  55. if (IS_ENABLED(CONFIG_BINFMT_ELF_FDPIC) && \
  56. current->personality & FDPIC_FUNCPTRS) { \
  57. regs->ARM_r7 = r7; \
  58. regs->ARM_r8 = r8; \
  59. regs->ARM_r9 = r9; \
  60. regs->ARM_r10 = current->mm->start_data; \
  61. } else if (!IS_ENABLED(CONFIG_MMU)) \
  62. regs->ARM_r10 = current->mm->start_data; \
  63. if (current->personality & ADDR_LIMIT_32BIT) \
  64. regs->ARM_cpsr = USR_MODE; \
  65. else \
  66. regs->ARM_cpsr = USR26_MODE; \
  67. if (elf_hwcap & HWCAP_THUMB && pc & 1) \
  68. regs->ARM_cpsr |= PSR_T_BIT; \
  69. regs->ARM_cpsr |= PSR_ENDSTATE; \
  70. regs->ARM_pc = pc & ~1; /* pc */ \
  71. regs->ARM_sp = sp; /* sp */ \
  72. })
  73. /* Forward declaration, a strange C thing */
  74. struct task_struct;
  75. /* Free all resources held by a thread. */
  76. extern void release_thread(struct task_struct *);
  77. unsigned long get_wchan(struct task_struct *p);
  78. #if __LINUX_ARM_ARCH__ == 6 || defined(CONFIG_ARM_ERRATA_754327)
  79. #define cpu_relax() smp_mb()
  80. #else
  81. #define cpu_relax() barrier()
  82. #endif
  83. #define task_pt_regs(p) \
  84. ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
  85. #define KSTK_EIP(tsk) task_pt_regs(tsk)->ARM_pc
  86. #define KSTK_ESP(tsk) task_pt_regs(tsk)->ARM_sp
  87. #ifdef CONFIG_SMP
  88. #define __ALT_SMP_ASM(smp, up) \
  89. "9998: " smp "\n" \
  90. " .pushsection \".alt.smp.init\", \"a\"\n" \
  91. " .long 9998b\n" \
  92. " " up "\n" \
  93. " .popsection\n"
  94. #else
  95. #define __ALT_SMP_ASM(smp, up) up
  96. #endif
  97. /*
  98. * Prefetching support - only ARMv5.
  99. */
  100. #if __LINUX_ARM_ARCH__ >= 5
  101. #define ARCH_HAS_PREFETCH
  102. static inline void prefetch(const void *ptr)
  103. {
  104. __asm__ __volatile__(
  105. "pld\t%a0"
  106. :: "p" (ptr));
  107. }
  108. #if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
  109. #define ARCH_HAS_PREFETCHW
  110. static inline void prefetchw(const void *ptr)
  111. {
  112. __asm__ __volatile__(
  113. ".arch_extension mp\n"
  114. __ALT_SMP_ASM(
  115. WASM(pldw) "\t%a0",
  116. WASM(pld) "\t%a0"
  117. )
  118. :: "p" (ptr));
  119. }
  120. #endif
  121. #endif
  122. #define HAVE_ARCH_PICK_MMAP_LAYOUT
  123. #endif
  124. #endif /* __ASM_ARM_PROCESSOR_H */