pvchk_inst.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #ifndef _ASM_NATIVE_PVCHK_INST_H
  2. #define _ASM_NATIVE_PVCHK_INST_H
  3. /******************************************************************************
  4. * arch/ia64/include/asm/native/pvchk_inst.h
  5. * Checker for paravirtualizations of privileged operations.
  6. *
  7. * Copyright (C) 2005 Hewlett-Packard Co
  8. * Dan Magenheimer <dan.magenheimer@hp.com>
  9. *
  10. * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
  11. * VA Linux Systems Japan K.K.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. *
  27. */
  28. /**********************************************
  29. * Instructions paravirtualized for correctness
  30. **********************************************/
  31. /* "fc" and "thash" are privilege-sensitive instructions, meaning they
  32. * may have different semantics depending on whether they are executed
  33. * at PL0 vs PL!=0. When paravirtualized, these instructions mustn't
  34. * be allowed to execute directly, lest incorrect semantics result.
  35. */
  36. #define fc .error "fc should not be used directly."
  37. #define thash .error "thash should not be used directly."
  38. /* Note that "ttag" and "cover" are also privilege-sensitive; "ttag"
  39. * is not currently used (though it may be in a long-format VHPT system!)
  40. * and the semantics of cover only change if psr.ic is off which is very
  41. * rare (and currently non-existent outside of assembly code
  42. */
  43. #define ttag .error "ttag should not be used directly."
  44. #define cover .error "cover should not be used directly."
  45. /* There are also privilege-sensitive registers. These registers are
  46. * readable at any privilege level but only writable at PL0.
  47. */
  48. #define cpuid .error "cpuid should not be used directly."
  49. #define pmd .error "pmd should not be used directly."
  50. /*
  51. * mov ar.eflag =
  52. * mov = ar.eflag
  53. */
  54. /**********************************************
  55. * Instructions paravirtualized for performance
  56. **********************************************/
  57. /*
  58. * Those instructions include '.' which can't be handled by cpp.
  59. * or can't be handled by cpp easily.
  60. * They are handled by sed instead of cpp.
  61. */
  62. /* for .S
  63. * itc.i
  64. * itc.d
  65. *
  66. * bsw.0
  67. * bsw.1
  68. *
  69. * ssm psr.ic | PSR_DEFAULT_BITS
  70. * ssm psr.ic
  71. * rsm psr.ic
  72. * ssm psr.i
  73. * rsm psr.i
  74. * rsm psr.i | psr.ic
  75. * rsm psr.dt
  76. * ssm psr.dt
  77. *
  78. * mov = cr.ifa
  79. * mov = cr.itir
  80. * mov = cr.isr
  81. * mov = cr.iha
  82. * mov = cr.ipsr
  83. * mov = cr.iim
  84. * mov = cr.iip
  85. * mov = cr.ivr
  86. * mov = psr
  87. *
  88. * mov cr.ifa =
  89. * mov cr.itir =
  90. * mov cr.iha =
  91. * mov cr.ipsr =
  92. * mov cr.ifs =
  93. * mov cr.iip =
  94. * mov cr.kr =
  95. */
  96. /* for intrinsics
  97. * ssm psr.i
  98. * rsm psr.i
  99. * mov = psr
  100. * mov = ivr
  101. * mov = tpr
  102. * mov cr.itm =
  103. * mov eoi =
  104. * mov rr[] =
  105. * mov = rr[]
  106. * mov = kr
  107. * mov kr =
  108. * ptc.ga
  109. */
  110. /*************************************************************
  111. * define paravirtualized instrcution macros as nop to ingore.
  112. * and check whether arguments are appropriate.
  113. *************************************************************/
  114. /* check whether reg is a regular register */
  115. .macro is_rreg_in reg
  116. .ifc "\reg", "r0"
  117. nop 0
  118. .exitm
  119. .endif
  120. ;;
  121. mov \reg = r0
  122. ;;
  123. .endm
  124. #define IS_RREG_IN(reg) is_rreg_in reg ;
  125. #define IS_RREG_OUT(reg) \
  126. ;; \
  127. mov reg = r0 \
  128. ;;
  129. #define IS_RREG_CLOB(reg) IS_RREG_OUT(reg)
  130. /* check whether pred is a predicate register */
  131. #define IS_PRED_IN(pred) \
  132. ;; \
  133. (pred) nop 0 \
  134. ;;
  135. #define IS_PRED_OUT(pred) \
  136. ;; \
  137. cmp.eq pred, p0 = r0, r0 \
  138. ;;
  139. #define IS_PRED_CLOB(pred) IS_PRED_OUT(pred)
  140. #define DO_SAVE_MIN(__COVER, SAVE_IFS, EXTRA, WORKAROUND) \
  141. nop 0
  142. #define MOV_FROM_IFA(reg) \
  143. IS_RREG_OUT(reg)
  144. #define MOV_FROM_ITIR(reg) \
  145. IS_RREG_OUT(reg)
  146. #define MOV_FROM_ISR(reg) \
  147. IS_RREG_OUT(reg)
  148. #define MOV_FROM_IHA(reg) \
  149. IS_RREG_OUT(reg)
  150. #define MOV_FROM_IPSR(pred, reg) \
  151. IS_PRED_IN(pred) \
  152. IS_RREG_OUT(reg)
  153. #define MOV_FROM_IIM(reg) \
  154. IS_RREG_OUT(reg)
  155. #define MOV_FROM_IIP(reg) \
  156. IS_RREG_OUT(reg)
  157. #define MOV_FROM_IVR(reg, clob) \
  158. IS_RREG_OUT(reg) \
  159. IS_RREG_CLOB(clob)
  160. #define MOV_FROM_PSR(pred, reg, clob) \
  161. IS_PRED_IN(pred) \
  162. IS_RREG_OUT(reg) \
  163. IS_RREG_CLOB(clob)
  164. #define MOV_FROM_ITC(pred, pred_clob, reg, clob) \
  165. IS_PRED_IN(pred) \
  166. IS_PRED_CLOB(pred_clob) \
  167. IS_RREG_OUT(reg) \
  168. IS_RREG_CLOB(clob)
  169. #define MOV_TO_IFA(reg, clob) \
  170. IS_RREG_IN(reg) \
  171. IS_RREG_CLOB(clob)
  172. #define MOV_TO_ITIR(pred, reg, clob) \
  173. IS_PRED_IN(pred) \
  174. IS_RREG_IN(reg) \
  175. IS_RREG_CLOB(clob)
  176. #define MOV_TO_IHA(pred, reg, clob) \
  177. IS_PRED_IN(pred) \
  178. IS_RREG_IN(reg) \
  179. IS_RREG_CLOB(clob)
  180. #define MOV_TO_IPSR(pred, reg, clob) \
  181. IS_PRED_IN(pred) \
  182. IS_RREG_IN(reg) \
  183. IS_RREG_CLOB(clob)
  184. #define MOV_TO_IFS(pred, reg, clob) \
  185. IS_PRED_IN(pred) \
  186. IS_RREG_IN(reg) \
  187. IS_RREG_CLOB(clob)
  188. #define MOV_TO_IIP(reg, clob) \
  189. IS_RREG_IN(reg) \
  190. IS_RREG_CLOB(clob)
  191. #define MOV_TO_KR(kr, reg, clob0, clob1) \
  192. IS_RREG_IN(reg) \
  193. IS_RREG_CLOB(clob0) \
  194. IS_RREG_CLOB(clob1)
  195. #define ITC_I(pred, reg, clob) \
  196. IS_PRED_IN(pred) \
  197. IS_RREG_IN(reg) \
  198. IS_RREG_CLOB(clob)
  199. #define ITC_D(pred, reg, clob) \
  200. IS_PRED_IN(pred) \
  201. IS_RREG_IN(reg) \
  202. IS_RREG_CLOB(clob)
  203. #define ITC_I_AND_D(pred_i, pred_d, reg, clob) \
  204. IS_PRED_IN(pred_i) \
  205. IS_PRED_IN(pred_d) \
  206. IS_RREG_IN(reg) \
  207. IS_RREG_CLOB(clob)
  208. #define THASH(pred, reg0, reg1, clob) \
  209. IS_PRED_IN(pred) \
  210. IS_RREG_OUT(reg0) \
  211. IS_RREG_IN(reg1) \
  212. IS_RREG_CLOB(clob)
  213. #define SSM_PSR_IC_AND_DEFAULT_BITS_AND_SRLZ_I(clob0, clob1) \
  214. IS_RREG_CLOB(clob0) \
  215. IS_RREG_CLOB(clob1)
  216. #define SSM_PSR_IC_AND_SRLZ_D(clob0, clob1) \
  217. IS_RREG_CLOB(clob0) \
  218. IS_RREG_CLOB(clob1)
  219. #define RSM_PSR_IC(clob) \
  220. IS_RREG_CLOB(clob)
  221. #define SSM_PSR_I(pred, pred_clob, clob) \
  222. IS_PRED_IN(pred) \
  223. IS_PRED_CLOB(pred_clob) \
  224. IS_RREG_CLOB(clob)
  225. #define RSM_PSR_I(pred, clob0, clob1) \
  226. IS_PRED_IN(pred) \
  227. IS_RREG_CLOB(clob0) \
  228. IS_RREG_CLOB(clob1)
  229. #define RSM_PSR_I_IC(clob0, clob1, clob2) \
  230. IS_RREG_CLOB(clob0) \
  231. IS_RREG_CLOB(clob1) \
  232. IS_RREG_CLOB(clob2)
  233. #define RSM_PSR_DT \
  234. nop 0
  235. #define RSM_PSR_BE_I(clob0, clob1) \
  236. IS_RREG_CLOB(clob0) \
  237. IS_RREG_CLOB(clob1)
  238. #define SSM_PSR_DT_AND_SRLZ_I \
  239. nop 0
  240. #define BSW_0(clob0, clob1, clob2) \
  241. IS_RREG_CLOB(clob0) \
  242. IS_RREG_CLOB(clob1) \
  243. IS_RREG_CLOB(clob2)
  244. #define BSW_1(clob0, clob1) \
  245. IS_RREG_CLOB(clob0) \
  246. IS_RREG_CLOB(clob1)
  247. #define COVER \
  248. nop 0
  249. #define RFI \
  250. br.ret.sptk.many rp /* defining nop causes dependency error */
  251. #endif /* _ASM_NATIVE_PVCHK_INST_H */