exception-64s.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_POWERPC_EXCEPTION_H
  3. #define _ASM_POWERPC_EXCEPTION_H
  4. /*
  5. * Extracted from head_64.S
  6. *
  7. * PowerPC version
  8. * Copyright (C) 1995-1996 Gary Thomas ([email protected])
  9. *
  10. * Rewritten by Cort Dougan ([email protected]) for PReP
  11. * Copyright (C) 1996 Cort Dougan <[email protected]>
  12. * Adapted for Power Macintosh by Paul Mackerras.
  13. * Low-level exception handlers and MMU support
  14. * rewritten by Paul Mackerras.
  15. * Copyright (C) 1996 Paul Mackerras.
  16. *
  17. * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
  18. * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
  19. *
  20. * This file contains the low-level support and setup for the
  21. * PowerPC-64 platform, including trap and interrupt dispatch.
  22. */
  23. /*
  24. * The following macros define the code that appears as
  25. * the prologue to each of the exception handlers. They
  26. * are split into two parts to allow a single kernel binary
  27. * to be used for pSeries and iSeries.
  28. *
  29. * We make as much of the exception code common between native
  30. * exception handlers (including pSeries LPAR) and iSeries LPAR
  31. * implementations as possible.
  32. */
  33. #include <asm/feature-fixups.h>
  34. /* PACA save area size in u64 units (exgen, exmc, etc) */
  35. #define EX_SIZE 10
  36. /* PACA save area offsets */
  37. #define EX_R9 0
  38. #define EX_R10 8
  39. #define EX_R11 16
  40. #define EX_R12 24
  41. #define EX_R13 32
  42. #define EX_DAR 40
  43. #define EX_DSISR 48
  44. #define EX_CCR 52
  45. #define EX_CFAR 56
  46. #define EX_PPR 64
  47. #define EX_CTR 72
  48. /*
  49. * maximum recursive depth of MCE exceptions
  50. */
  51. #define MAX_MCE_DEPTH 4
  52. #ifdef __ASSEMBLY__
  53. #define STF_ENTRY_BARRIER_SLOT \
  54. STF_ENTRY_BARRIER_FIXUP_SECTION; \
  55. nop; \
  56. nop; \
  57. nop
  58. #define STF_EXIT_BARRIER_SLOT \
  59. STF_EXIT_BARRIER_FIXUP_SECTION; \
  60. nop; \
  61. nop; \
  62. nop; \
  63. nop; \
  64. nop; \
  65. nop
  66. #define ENTRY_FLUSH_SLOT \
  67. ENTRY_FLUSH_FIXUP_SECTION; \
  68. nop; \
  69. nop; \
  70. nop;
  71. #define SCV_ENTRY_FLUSH_SLOT \
  72. SCV_ENTRY_FLUSH_FIXUP_SECTION; \
  73. nop; \
  74. nop; \
  75. nop;
  76. /*
  77. * r10 must be free to use, r13 must be paca
  78. */
  79. #define INTERRUPT_TO_KERNEL \
  80. STF_ENTRY_BARRIER_SLOT; \
  81. ENTRY_FLUSH_SLOT
  82. /*
  83. * r10, ctr must be free to use, r13 must be paca
  84. */
  85. #define SCV_INTERRUPT_TO_KERNEL \
  86. STF_ENTRY_BARRIER_SLOT; \
  87. SCV_ENTRY_FLUSH_SLOT
  88. /*
  89. * Macros for annotating the expected destination of (h)rfid
  90. *
  91. * The nop instructions allow us to insert one or more instructions to flush the
  92. * L1-D cache when returning to userspace or a guest.
  93. *
  94. * powerpc relies on return from interrupt/syscall being context synchronising
  95. * (which hrfid, rfid, and rfscv are) to support ARCH_HAS_MEMBARRIER_SYNC_CORE
  96. * without additional synchronisation instructions.
  97. *
  98. * soft-masked interrupt replay does not include a context-synchronising rfid,
  99. * but those always return to kernel, the sync is only required when returning
  100. * to user.
  101. */
  102. #define RFI_FLUSH_SLOT \
  103. RFI_FLUSH_FIXUP_SECTION; \
  104. nop; \
  105. nop; \
  106. nop
  107. #define RFI_TO_KERNEL \
  108. rfid
  109. #define RFI_TO_USER \
  110. STF_EXIT_BARRIER_SLOT; \
  111. RFI_FLUSH_SLOT; \
  112. rfid; \
  113. b rfi_flush_fallback
  114. #define RFI_TO_USER_OR_KERNEL \
  115. STF_EXIT_BARRIER_SLOT; \
  116. RFI_FLUSH_SLOT; \
  117. rfid; \
  118. b rfi_flush_fallback
  119. #define RFI_TO_GUEST \
  120. STF_EXIT_BARRIER_SLOT; \
  121. RFI_FLUSH_SLOT; \
  122. rfid; \
  123. b rfi_flush_fallback
  124. #define HRFI_TO_KERNEL \
  125. hrfid
  126. #define HRFI_TO_USER \
  127. STF_EXIT_BARRIER_SLOT; \
  128. RFI_FLUSH_SLOT; \
  129. hrfid; \
  130. b hrfi_flush_fallback
  131. #define HRFI_TO_USER_OR_KERNEL \
  132. STF_EXIT_BARRIER_SLOT; \
  133. RFI_FLUSH_SLOT; \
  134. hrfid; \
  135. b hrfi_flush_fallback
  136. #define HRFI_TO_GUEST \
  137. STF_EXIT_BARRIER_SLOT; \
  138. RFI_FLUSH_SLOT; \
  139. hrfid; \
  140. b hrfi_flush_fallback
  141. #define HRFI_TO_UNKNOWN \
  142. STF_EXIT_BARRIER_SLOT; \
  143. RFI_FLUSH_SLOT; \
  144. hrfid; \
  145. b hrfi_flush_fallback
  146. #define RFSCV_TO_USER \
  147. STF_EXIT_BARRIER_SLOT; \
  148. RFI_FLUSH_SLOT; \
  149. RFSCV; \
  150. b rfscv_flush_fallback
  151. #else /* __ASSEMBLY__ */
  152. /* Prototype for function defined in exceptions-64s.S */
  153. void do_uaccess_flush(void);
  154. #endif /* __ASSEMBLY__ */
  155. #endif /* _ASM_POWERPC_EXCEPTION_H */