coproc_defs.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /*
  2. * Linux 2.6.32 and later Kernel module for VMware MVP Hypervisor Support
  3. *
  4. * Copyright (C) 2010-2013 VMware, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; see the file COPYING. If not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #line 5
  20. /**
  21. * @file
  22. *
  23. * @brief Constant definitions for ARM CP15 coprocessor registers.
  24. *
  25. * Derived from tweety hypervisor/src/armv6/trango_macros.inc file
  26. */
  27. #ifndef _COPROC_DEFS_H_
  28. #define _COPROC_DEFS_H_
  29. #define INCLUDE_ALLOW_MVPD
  30. #define INCLUDE_ALLOW_VMX
  31. #define INCLUDE_ALLOW_MODULE
  32. #define INCLUDE_ALLOW_MONITOR
  33. #define INCLUDE_ALLOW_PV
  34. #define INCLUDE_ALLOW_GPL
  35. #include "include_check.h"
  36. /**
  37. * @name CP10 registers.
  38. *
  39. * MCR/MRC format:
  40. * @code #define <name> <opcode_1>, <CRn>, <CRm>, <opcode_2> @endcode
  41. * @{
  42. */
  43. #define VFP_FPSID 7, c0, c0, 0
  44. #define VFP_MVFR0 7, c7, c0, 0
  45. #define VFP_MVFR1 7, c6, c0, 0
  46. #define VFP_FPEXC 7, c8, c0, 0
  47. #define VFP_FPSCR 7, c1, c0, 0
  48. #define VFP_FPINST 7, c9, c0, 0
  49. #define VFP_FPINST2 7, c10, c0, 0
  50. /*@}*/
  51. /**
  52. * @name CP15 registers.
  53. *
  54. * MCR/MRC format:
  55. * @code #define <name> <opcode_1>, <CRn>, <CRm>, <opcode_2> @endcode
  56. * MCRR format:
  57. * @code #define <name> <opcode>, <CRm>@endcode
  58. * @{
  59. */
  60. #define ID_CODE 0, c0, c0, 0
  61. #define CACHE_TYPE 0, c0, c0, 1
  62. #define MPIDR 0, c0, c0, 5
  63. #define CACHE_SIZE_ID 1, c0, c0, 0
  64. #define CACHE_LEVEL_ID 1, c0, c0, 1
  65. #define CACHE_SIZE_SELECTION 2, c0, c0, 0
  66. #define PROC_FEATURE_0 0, c0, c1, 0
  67. #define MEM_MODEL_FEATURE_0 0, c0, c1, 4
  68. #define CONTROL_REGISTER 0, c1, c0, 0
  69. #define TTBASE0_POINTER 0, c2, c0, 0
  70. #define TTBASE1_POINTER 0, c2, c0, 1
  71. #define TTCONTROL 0, c2, c0, 2
  72. #define DOMAIN_CONTROL 0, c3, c0, 0
  73. #define DATA_FAULT_STATUS 0, c5, c0, 0
  74. #define INST_FAULT_STATUS 0, c5, c0, 1
  75. #define AUX_DATA_FAULT_STATUS 0, c5, c1, 0
  76. #define AUX_INST_FAULT_STATUS 0, c5, c1, 1
  77. #define DATA_FAULT_ADDRESS 0, c6, c0, 0
  78. #define INST_FAULT_ADDRESS 0, c6, c0, 2
  79. #define WAIT_FOR_INTERRUPT 0, c7, c0, 4
  80. #define PHYSICAL_ADDRESS 0, c7, c4, 0
  81. #define ICACHE_INVALIDATE_POU 0, c7, c5, 0
  82. #define ICACHE_INVALIDATE_MVA_POU 0, c7, c5, 1
  83. #define ICACHE_INVALIDATE_INDEX 0, c7, c5, 2
  84. #define BTAC_INVALIDATE 0, c7, c5, 6
  85. #define BTAC_INVALIDATE_MVA 0, c7, c5, 7
  86. #define DCACHE_INVALIDATE 0, c7, c6, 0
  87. #define DCACHE_INVALIDATE_MVA_POC 0, c7, c6, 1
  88. #define DCACHE_INVALIDATE_INDEX 0, c7, c6, 2
  89. #define UCACHE_INVALIDATE 0, c7, c7, 0
  90. #define V2P_CURRENT_PRIV_READ 0, c7, c8, 0
  91. #define V2P_CURRENT_PRIV_WRITE 0, c7, c8, 1
  92. #define V2P_CURRENT_USER_READ 0, c7, c8, 2
  93. #define V2P_CURRENT_USER_WRITE 0, c7, c8, 3
  94. #define V2P_OTHER_PRIV_READ 0, c7, c8, 4
  95. #define V2P_OTHER_PRIV_WRITE 0, c7, c8, 5
  96. #define V2P_OTHER_USER_READ 0, c7, c8, 6
  97. #define V2P_OTHER_USER_WRITE 0, c7, c8, 7
  98. #define DCACHE_CLEAN 0, c7, c10, 0
  99. #define DCACHE_CLEAN_MVA_POC 0, c7, c10, 1
  100. #define DCACHE_CLEAN_INDEX 0, c7, c10, 2
  101. #define DCACHE_CLEAN_MVA_POU 0, c7, c11, 1
  102. #define DCACHE_CLEAN_INVALIDATE 0, c7, c14, 0
  103. #define DCACHE_CLEAN_INVALIDATE_MVA_POC 0, c7, c14, 1
  104. #define DCACHE_CLEAN_INVALIDATE_INDEX 0, c7, c14, 2
  105. #define ITLB_INVALIDATE_ALL 0, c8, c5, 0
  106. #define ITLB_INVALIDATE_SINGLE 0, c8, c5, 1
  107. #define ITLB_INVALIDATE_ASID 0, c8, c5, 2
  108. #define DTLB_INVALIDATE_ALL 0, c8, c6, 0
  109. #define DTLB_INVALIDATE_SINGLE 0, c8, c6, 1
  110. #define DTLB_INVALIDATE_ASID 0, c8, c6, 2
  111. #define UTLB_INVALIDATE_ALL 0, c8, c7, 0
  112. #define UTLB_INVALIDATE_SINGLE 0, c8, c7, 1
  113. #define UTLB_INVALIDATE_ASID 0, c8, c7, 2
  114. #define TLB_LOCKDOWN 0, c10, c0, 0
  115. #define PRIMARY_REGION_REMAP 0, c10, c2, 0
  116. #define MAIR0 PRIMARY_REGION_REMAP
  117. #define NORMAL_MEMORY_REMAP 0, c10, c2, 1
  118. #define MAIR1 NORMAL_MEMORY_REMAP
  119. #define VECTOR_BASE 0, c12, c0, 0
  120. #define INTERRUPT_STATUS 0, c12, c1, 0
  121. #define CONTEXT_ID 0, c13, c0, 1
  122. #define TID_USER_RW 0, c13, c0, 2
  123. #define TID_USER_RO 0, c13, c0, 3
  124. #define TID_PRIV_RW 0, c13, c0, 4
  125. #define CLEAR_FAULT_IN_EFSR 7, c15, c0, 1
  126. #define VBAR 0, c12, c0, 0
  127. /*
  128. * ARMv7 performance counters' registers (MVP related)
  129. * - ARM Architecture Reference Manual v7-A and v7-R: DDI0406B
  130. * - Cortex-A8 TRM, rev.r1p1: DDI0344B
  131. */
  132. #define PERF_MON_CONTROL_REGISTER 0, c9, c12, 0
  133. #define CYCLE_COUNT 0, c9, c13, 0
  134. #define PERF_MON_COUNT_SET 0, c9, c12, 1
  135. #define PERF_MON_COUNT_CLR 0, c9, c12, 2
  136. #define PERF_MON_FLAG_RDCLR 0, c9, c12, 3
  137. #define PERF_MON_EVENT_SELECT 0, c9, c12, 5
  138. #define PERF_MON_EVENT_TYPE 0, c9, c13, 1
  139. #define PERF_MON_EVENT_COUNT 0, c9, c13, 2
  140. #define PERF_MON_USER_ENR 0, c9, c14, 0
  141. #define PERF_MON_INTEN_SET 0, c9, c14, 1
  142. #define PERF_MON_INTEN_CLR 0, c9, c14, 2
  143. #define COPROC_ACCESS_CONTROL 0, c1, c0, 2
  144. #define NON_SECURE_ACCESS_CONTROL 0, c1, c1, 2
  145. #define HYP_CFG 4, c1, c1, 0
  146. #define HYP_DEBUG_CONTROL 4, c1, c1, 1
  147. #define HYP_COPROC_TRAP 4, c1, c1, 2
  148. #define HYP_SYS_TRAP 4, c1, c1, 3
  149. #define VIRT_TCR 4, c2, c1, 2
  150. #define HYP_SYNDROME 4, c5, c2, 0
  151. #define HYP_DATA_FAULT_ADDRESS 4, c6, c0, 0
  152. #define HYP_INST_FAULT_ADDRESS 4, c6, c0, 2
  153. #define HYP_IPA_FAULT_ADDRESS 4, c6, c0, 4
  154. #define UTLB_INVALIDATE_ALL_HYP 4, c8, c7, 0
  155. #define UTLB_INVALIDATE_SINGLE_HYP 4, c8, c7, 1
  156. #define UTLB_INVALIDATE_ALL_NS_NON_HYP 4, c8, c7, 4
  157. #define EXT_TTBR0 0, c2
  158. #define EXT_TTBR1 1, c2
  159. #define HYP_TTBR 4, c2
  160. #define VIRT_TTBR 6, c2
  161. #define EXT_PHYSICAL_ADDRESS 0, c7
  162. /*@}*/
  163. /**
  164. * @name CP15 configuration control register bits.
  165. * @{
  166. */
  167. #define ARM_CP15_CNTL_M (1 << 0)
  168. #define ARM_CP15_CNTL_A (1 << 1)
  169. #define ARM_CP15_CNTL_C (1 << 2)
  170. #define ARM_CP15_CNTL_B (1 << 7)
  171. #define ARM_CP15_CNTL_Z (1 << 11)
  172. #define ARM_CP15_CNTL_I (1 << 12)
  173. #define ARM_CP15_CNTL_V (1 << 13)
  174. #define ARM_CP15_CNTL_U (1 << 22)
  175. #define ARM_CP15_CNTL_VE (1 << 24)
  176. #define ARM_CP15_CNTL_EE (1 << 25)
  177. #define ARM_CP15_CNTL_TRE (1 << 28)
  178. #define ARM_CP15_CNTL_AFE (1 << 29)
  179. #define ARM_CP15_CNTL_TE (1 << 30)
  180. /*@}*/
  181. /**
  182. * @brief Initial System Control Register (SCTLR) value.
  183. *
  184. * Magic described on B3-97 ARM DDI 0406B, it's the power-on
  185. * value, e.g. caches/MMU/alignment checking/TEX remap etc. disabled.
  186. */
  187. #define ARM_CP15_CNTL_INIT 0x00c50078
  188. /**
  189. * @name System control coprocessor primary registers.
  190. * Each primary register is backed by potentially multiple
  191. * physical registers in the vCPU CP15 register file.
  192. * @{
  193. */
  194. #define ARM_CP15_CRN_ID 0 /**< Processor ID, cache, TCM and TLB type */
  195. #define ARM_CP15_CRN_CNTL 1 /**< System configuration bits */
  196. #define ARM_CP15_CRN_PT 2 /**< Page table control */
  197. #define ARM_CP15_CRN_DACR 3 /**< Domain access control */
  198. #define ARM_CP15_CRN_F_STATUS 5 /**< Fault status */
  199. #define ARM_CP15_CRN_F_ADDR 6 /**< Fault address */
  200. #define ARM_CP15_CRN_CACHE 7 /**< Cache/write buffer control */
  201. #define ARM_CP15_CRN_TLB 8 /**< TLB control */
  202. #define ARM_CP15_CRN_REMAP 10 /**< Memory Remap registers */
  203. #define ARM_CP15_CRN_SER 12 /**< Security Extension registers */
  204. #define ARM_CP15_CRN_PID 13 /**< Process ID */
  205. #define ARM_CP15_CRN_TIMER 14 /**< Architecture timers */
  206. #define ARM_CP15_CRM_INVALIDATE_D_CACHE_RANGE 6
  207. #define ARM_CP15_CRM_CLEAN_AND_INVALIDATE_D_CACHE_RANGE 14
  208. /*@}*/
  209. /**
  210. * @name ARMv7 performance counter control/status register bits (MVP related)
  211. * INTEN: counters overflow interrupt enable
  212. * CNTEN: counters enable
  213. * @{
  214. */
  215. #define ARMV7_PMNC_E (1 << 0)
  216. #define ARMV7_PMNC_INTEN_P0 (1 << 0)
  217. #define ARMV7_PMNC_INTEN_P1 (1 << 1)
  218. #define ARMV7_PMNC_INTEN_P2 (1 << 2)
  219. #define ARMV7_PMNC_INTEN_P3 (1 << 3)
  220. #define ARMV7_PMNC_INTEN_C (1 << 31)
  221. #define ARMV7_PMNC_INTEN_MASK 0x8000000f
  222. #define ARMV7_PMNC_CNTEN_P0 (1 << 0)
  223. #define ARMV7_PMNC_CNTEN_P1 (1 << 1)
  224. #define ARMV7_PMNC_CNTEN_P2 (1 << 2)
  225. #define ARMV7_PMNC_CNTEN_P3 (1 << 3)
  226. #define ARMV7_PMNC_CNTEN_C (1 << 31)
  227. #define ARMV7_PMNC_FLAG_P0 (1 << 0)
  228. #define ARMV7_PMNC_FLAG_P1 (1 << 1)
  229. #define ARMV7_PMNC_FLAG_P2 (1 << 2)
  230. #define ARMV7_PMNC_FLAG_P3 (1 << 3)
  231. #define ARMV7_PMNC_FLAG_C (1 << 31)
  232. /*@}*/
  233. /**
  234. * @name TTBR masks.
  235. * See B4.9.2 ARM DDI 0100I and B3.12.24 ARM DDI 0406A.
  236. * @{
  237. */
  238. #define ARM_CP15_TTBASE_MASK MVP_MASK(14, 18)
  239. #define ARM_CP15_TTBASE_SPLIT_MASK(ttbcrn) MVP_MASK(14-ttbcrn, 18+ttbcrn)
  240. #define ARM_CP15_TTATTRIB_MASK MVP_MASK(0, 6)
  241. /*@}*/
  242. /**
  243. * @name ARM fault status register encoding/decoding.
  244. * See B4.6 and B4.9.6 in ARM DDI 0100I.
  245. * @{
  246. */
  247. #define ARM_CP15_FSR_STATUS_POS 0
  248. #define ARM_CP15_FSR_STATUS_POS2 10
  249. #define ARM_CP15_FSR_DOMAIN_POS 4
  250. #define ARM_CP15_FSR_WR_POS 11
  251. #define ARM_CP15_FSR_STATUS_LEN 4
  252. #define ARM_CP15_FSR_DOMAIN_LEN 4
  253. #define ARM_CP15_FSR_STATUS_DEBUG_EVENT 0x2
  254. #define ARM_CP15_FSR_STATUS_ALIGNMENT 0x1
  255. #define ARM_CP15_FSR_STATUS_ICACHE_MAINT 0x4
  256. #define ARM_CP15_FSR_STATUS_TRANSLATION_SECT 0x5
  257. #define ARM_CP15_FSR_STATUS_TRANSLATION_PAGE 0x7
  258. #define ARM_CP15_FSR_STATUS_DOMAIN_SECT 0x9
  259. #define ARM_CP15_FSR_STATUS_DOMAIN_PAGE 0xb
  260. #define ARM_CP15_FSR_STATUS_PERMISSION_SECT 0xd
  261. #define ARM_CP15_FSR_STATUS_PERMISSION_PAGE 0xf
  262. #define ARM_CP15_FSR_STATUS_ACCESS_FLAG_SECT 0x3
  263. #define ARM_CP15_FSR_STATUS_ACCESS_FLAG_PAGE 0x6
  264. #define ARM_CP15_FSR_STATUS_SYNC_EXT_ABORT 0x8
  265. #define ARM_CP15_FSR_STATUS_ASYNC_EXT_ABORT 0x16
  266. /*@}*/
  267. /**
  268. * @brief Generate ARM fault status register value.
  269. *
  270. * @param fs status from Table B4-1. Only implemented for fs <= 0xf.
  271. * @param domain domain accessed when abort occurred.
  272. * @param write write access caused abort.
  273. */
  274. #define ARM_CP15_FSR(fs, domain, write) \
  275. (((fs) << ARM_CP15_FSR_STATUS_POS) | \
  276. ((domain) << ARM_CP15_FSR_DOMAIN_POS) | \
  277. ((write) ? (1 << ARM_CP15_FSR_WR_POS) : 0))
  278. #define ARM_CP15_FSR_STATUS(r) \
  279. (MVP_EXTRACT_FIELD((r), ARM_CP15_FSR_STATUS_POS, \
  280. ARM_CP15_FSR_STATUS_LEN) | \
  281. (MVP_BIT((r), ARM_CP15_FSR_STATUS_POS2) << ARM_CP15_FSR_STATUS_LEN))
  282. #define ARM_CP15_FSR_DOMAIN(r) \
  283. MVP_EXTRACT_FIELD((r), ARM_CP15_FSR_DOMAIN_POS, ARM_CP15_FSR_DOMAIN_LEN)
  284. #define ARM_CP15_FSR_WR(r) \
  285. MVP_BIT((r), ARM_CP15_FSR_WR_POS)
  286. /*@}*/
  287. /*
  288. * This should mask out the major and minor revision numbers.
  289. * As per http://infocenter.arm.com/help/topic/com.arm.doc.ddi0211k/I65012.html
  290. */
  291. #define ARM_CP15_MAIN_ID_NOREVISION_MASK 0xFF0FFFF0
  292. /* 2-8 ARM DDI 0151C */
  293. #define ARM_CP15_MAIN_ID_920_T 0x41129200
  294. /* 3-18 ARM DDI 0211H */
  295. #define ARM_CP15_MAIN_ID_1136J_S 0x4107B362
  296. /* Coprocessor Access Control Register */
  297. #define CPACR_ASEDIS (1 << 31)
  298. #define CPACR_D32DIS (1 << 30)
  299. #define CPACR_CP10_MASK (0x3 << (10*2))
  300. #define CPACR_CP10_CP11_MASK ((0x3 << (10*2)) | (0x3 << (11*2)))
  301. #define CPACR_CP10_CP11_PRIV_ONLY ((0x1 << (10*2)) | (0x1 << (11*2)))
  302. /* 2-bit access permission per Co-Proc */
  303. /**
  304. * @name ARM VFP/Adv. SIMD Extension System Registers
  305. * @{
  306. */
  307. #define ARM_VFP_SYSTEM_REG_FPSID 0x0
  308. #define ARM_VFP_SYSTEM_REG_FPSCR 0x1
  309. #define ARM_VFP_SYSTEM_REG_MVFR1 0x6
  310. #define ARM_VFP_SYSTEM_REG_MVFR0 0x7
  311. #define ARM_VFP_SYSTEM_REG_FPEXC 0x8
  312. #define ARM_VFP_SYSTEM_REG_FPINST 0x9
  313. #define ARM_VFP_SYSTEM_REG_FPINST2 0xa
  314. #define ARM_VFP_SYSTEM_REG_FPEXC_EX (1 << 31)
  315. #define ARM_VFP_SYSTEM_REG_FPEXC_EN (1 << 30)
  316. #define ARM_VFP_SYSTEM_REG_FPEXC_FP2V (1 << 28)
  317. #define ARM_VFP_SYSTEM_REG_MVFR0_A_SIMD_BIT (0)
  318. #define ARM_VFP_SYSTEM_REG_MVFR0_A_SIMD_MASK \
  319. (0xf << ARM_VFP_SYSTEM_REG_MVFR0_A_SIMD_BIT)
  320. /*@}*/
  321. /**
  322. * @name ARM Multi Processor ID Register (MPIDR) decoding
  323. * @{
  324. */
  325. #define ARM_CP15_MPIDR_MP (0x1 << 31)
  326. #define ARM_CP15_MPIDR_U (0x1 << 30)
  327. /*@}*/
  328. #endif /* ifndef _COPROC_DEFS_H_ */