asm-offsets.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*
  2. * Copyright (C) 2012 Regents of the University of California
  3. * Copyright (C) 2017 SiFive
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation, version 2.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #define GENERATING_ASM_OFFSETS
  15. #include <linux/kbuild.h>
  16. #include <linux/sched.h>
  17. #include <asm/thread_info.h>
  18. #include <asm/ptrace.h>
  19. void asm_offsets(void)
  20. {
  21. OFFSET(TASK_THREAD_RA, task_struct, thread.ra);
  22. OFFSET(TASK_THREAD_SP, task_struct, thread.sp);
  23. OFFSET(TASK_THREAD_S0, task_struct, thread.s[0]);
  24. OFFSET(TASK_THREAD_S1, task_struct, thread.s[1]);
  25. OFFSET(TASK_THREAD_S2, task_struct, thread.s[2]);
  26. OFFSET(TASK_THREAD_S3, task_struct, thread.s[3]);
  27. OFFSET(TASK_THREAD_S4, task_struct, thread.s[4]);
  28. OFFSET(TASK_THREAD_S5, task_struct, thread.s[5]);
  29. OFFSET(TASK_THREAD_S6, task_struct, thread.s[6]);
  30. OFFSET(TASK_THREAD_S7, task_struct, thread.s[7]);
  31. OFFSET(TASK_THREAD_S8, task_struct, thread.s[8]);
  32. OFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);
  33. OFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);
  34. OFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);
  35. OFFSET(TASK_THREAD_SP, task_struct, thread.sp);
  36. OFFSET(TASK_STACK, task_struct, stack);
  37. OFFSET(TASK_TI, task_struct, thread_info);
  38. OFFSET(TASK_TI_FLAGS, task_struct, thread_info.flags);
  39. OFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp);
  40. OFFSET(TASK_TI_USER_SP, task_struct, thread_info.user_sp);
  41. OFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);
  42. OFFSET(TASK_THREAD_F0, task_struct, thread.fstate.f[0]);
  43. OFFSET(TASK_THREAD_F1, task_struct, thread.fstate.f[1]);
  44. OFFSET(TASK_THREAD_F2, task_struct, thread.fstate.f[2]);
  45. OFFSET(TASK_THREAD_F3, task_struct, thread.fstate.f[3]);
  46. OFFSET(TASK_THREAD_F4, task_struct, thread.fstate.f[4]);
  47. OFFSET(TASK_THREAD_F5, task_struct, thread.fstate.f[5]);
  48. OFFSET(TASK_THREAD_F6, task_struct, thread.fstate.f[6]);
  49. OFFSET(TASK_THREAD_F7, task_struct, thread.fstate.f[7]);
  50. OFFSET(TASK_THREAD_F8, task_struct, thread.fstate.f[8]);
  51. OFFSET(TASK_THREAD_F9, task_struct, thread.fstate.f[9]);
  52. OFFSET(TASK_THREAD_F10, task_struct, thread.fstate.f[10]);
  53. OFFSET(TASK_THREAD_F11, task_struct, thread.fstate.f[11]);
  54. OFFSET(TASK_THREAD_F12, task_struct, thread.fstate.f[12]);
  55. OFFSET(TASK_THREAD_F13, task_struct, thread.fstate.f[13]);
  56. OFFSET(TASK_THREAD_F14, task_struct, thread.fstate.f[14]);
  57. OFFSET(TASK_THREAD_F15, task_struct, thread.fstate.f[15]);
  58. OFFSET(TASK_THREAD_F16, task_struct, thread.fstate.f[16]);
  59. OFFSET(TASK_THREAD_F17, task_struct, thread.fstate.f[17]);
  60. OFFSET(TASK_THREAD_F18, task_struct, thread.fstate.f[18]);
  61. OFFSET(TASK_THREAD_F19, task_struct, thread.fstate.f[19]);
  62. OFFSET(TASK_THREAD_F20, task_struct, thread.fstate.f[20]);
  63. OFFSET(TASK_THREAD_F21, task_struct, thread.fstate.f[21]);
  64. OFFSET(TASK_THREAD_F22, task_struct, thread.fstate.f[22]);
  65. OFFSET(TASK_THREAD_F23, task_struct, thread.fstate.f[23]);
  66. OFFSET(TASK_THREAD_F24, task_struct, thread.fstate.f[24]);
  67. OFFSET(TASK_THREAD_F25, task_struct, thread.fstate.f[25]);
  68. OFFSET(TASK_THREAD_F26, task_struct, thread.fstate.f[26]);
  69. OFFSET(TASK_THREAD_F27, task_struct, thread.fstate.f[27]);
  70. OFFSET(TASK_THREAD_F28, task_struct, thread.fstate.f[28]);
  71. OFFSET(TASK_THREAD_F29, task_struct, thread.fstate.f[29]);
  72. OFFSET(TASK_THREAD_F30, task_struct, thread.fstate.f[30]);
  73. OFFSET(TASK_THREAD_F31, task_struct, thread.fstate.f[31]);
  74. OFFSET(TASK_THREAD_FCSR, task_struct, thread.fstate.fcsr);
  75. DEFINE(PT_SIZE, sizeof(struct pt_regs));
  76. OFFSET(PT_SEPC, pt_regs, sepc);
  77. OFFSET(PT_RA, pt_regs, ra);
  78. OFFSET(PT_FP, pt_regs, s0);
  79. OFFSET(PT_S0, pt_regs, s0);
  80. OFFSET(PT_S1, pt_regs, s1);
  81. OFFSET(PT_S2, pt_regs, s2);
  82. OFFSET(PT_S3, pt_regs, s3);
  83. OFFSET(PT_S4, pt_regs, s4);
  84. OFFSET(PT_S5, pt_regs, s5);
  85. OFFSET(PT_S6, pt_regs, s6);
  86. OFFSET(PT_S7, pt_regs, s7);
  87. OFFSET(PT_S8, pt_regs, s8);
  88. OFFSET(PT_S9, pt_regs, s9);
  89. OFFSET(PT_S10, pt_regs, s10);
  90. OFFSET(PT_S11, pt_regs, s11);
  91. OFFSET(PT_SP, pt_regs, sp);
  92. OFFSET(PT_TP, pt_regs, tp);
  93. OFFSET(PT_A0, pt_regs, a0);
  94. OFFSET(PT_A1, pt_regs, a1);
  95. OFFSET(PT_A2, pt_regs, a2);
  96. OFFSET(PT_A3, pt_regs, a3);
  97. OFFSET(PT_A4, pt_regs, a4);
  98. OFFSET(PT_A5, pt_regs, a5);
  99. OFFSET(PT_A6, pt_regs, a6);
  100. OFFSET(PT_A7, pt_regs, a7);
  101. OFFSET(PT_T0, pt_regs, t0);
  102. OFFSET(PT_T1, pt_regs, t1);
  103. OFFSET(PT_T2, pt_regs, t2);
  104. OFFSET(PT_T3, pt_regs, t3);
  105. OFFSET(PT_T4, pt_regs, t4);
  106. OFFSET(PT_T5, pt_regs, t5);
  107. OFFSET(PT_T6, pt_regs, t6);
  108. OFFSET(PT_GP, pt_regs, gp);
  109. OFFSET(PT_ORIG_A0, pt_regs, orig_a0);
  110. OFFSET(PT_SSTATUS, pt_regs, sstatus);
  111. OFFSET(PT_SBADADDR, pt_regs, sbadaddr);
  112. OFFSET(PT_SCAUSE, pt_regs, scause);
  113. /*
  114. * THREAD_{F,X}* might be larger than a S-type offset can handle, but
  115. * these are used in performance-sensitive assembly so we can't resort
  116. * to loading the long immediate every time.
  117. */
  118. DEFINE(TASK_THREAD_RA_RA,
  119. offsetof(struct task_struct, thread.ra)
  120. - offsetof(struct task_struct, thread.ra)
  121. );
  122. DEFINE(TASK_THREAD_SP_RA,
  123. offsetof(struct task_struct, thread.sp)
  124. - offsetof(struct task_struct, thread.ra)
  125. );
  126. DEFINE(TASK_THREAD_S0_RA,
  127. offsetof(struct task_struct, thread.s[0])
  128. - offsetof(struct task_struct, thread.ra)
  129. );
  130. DEFINE(TASK_THREAD_S1_RA,
  131. offsetof(struct task_struct, thread.s[1])
  132. - offsetof(struct task_struct, thread.ra)
  133. );
  134. DEFINE(TASK_THREAD_S2_RA,
  135. offsetof(struct task_struct, thread.s[2])
  136. - offsetof(struct task_struct, thread.ra)
  137. );
  138. DEFINE(TASK_THREAD_S3_RA,
  139. offsetof(struct task_struct, thread.s[3])
  140. - offsetof(struct task_struct, thread.ra)
  141. );
  142. DEFINE(TASK_THREAD_S4_RA,
  143. offsetof(struct task_struct, thread.s[4])
  144. - offsetof(struct task_struct, thread.ra)
  145. );
  146. DEFINE(TASK_THREAD_S5_RA,
  147. offsetof(struct task_struct, thread.s[5])
  148. - offsetof(struct task_struct, thread.ra)
  149. );
  150. DEFINE(TASK_THREAD_S6_RA,
  151. offsetof(struct task_struct, thread.s[6])
  152. - offsetof(struct task_struct, thread.ra)
  153. );
  154. DEFINE(TASK_THREAD_S7_RA,
  155. offsetof(struct task_struct, thread.s[7])
  156. - offsetof(struct task_struct, thread.ra)
  157. );
  158. DEFINE(TASK_THREAD_S8_RA,
  159. offsetof(struct task_struct, thread.s[8])
  160. - offsetof(struct task_struct, thread.ra)
  161. );
  162. DEFINE(TASK_THREAD_S9_RA,
  163. offsetof(struct task_struct, thread.s[9])
  164. - offsetof(struct task_struct, thread.ra)
  165. );
  166. DEFINE(TASK_THREAD_S10_RA,
  167. offsetof(struct task_struct, thread.s[10])
  168. - offsetof(struct task_struct, thread.ra)
  169. );
  170. DEFINE(TASK_THREAD_S11_RA,
  171. offsetof(struct task_struct, thread.s[11])
  172. - offsetof(struct task_struct, thread.ra)
  173. );
  174. DEFINE(TASK_THREAD_F0_F0,
  175. offsetof(struct task_struct, thread.fstate.f[0])
  176. - offsetof(struct task_struct, thread.fstate.f[0])
  177. );
  178. DEFINE(TASK_THREAD_F1_F0,
  179. offsetof(struct task_struct, thread.fstate.f[1])
  180. - offsetof(struct task_struct, thread.fstate.f[0])
  181. );
  182. DEFINE(TASK_THREAD_F2_F0,
  183. offsetof(struct task_struct, thread.fstate.f[2])
  184. - offsetof(struct task_struct, thread.fstate.f[0])
  185. );
  186. DEFINE(TASK_THREAD_F3_F0,
  187. offsetof(struct task_struct, thread.fstate.f[3])
  188. - offsetof(struct task_struct, thread.fstate.f[0])
  189. );
  190. DEFINE(TASK_THREAD_F4_F0,
  191. offsetof(struct task_struct, thread.fstate.f[4])
  192. - offsetof(struct task_struct, thread.fstate.f[0])
  193. );
  194. DEFINE(TASK_THREAD_F5_F0,
  195. offsetof(struct task_struct, thread.fstate.f[5])
  196. - offsetof(struct task_struct, thread.fstate.f[0])
  197. );
  198. DEFINE(TASK_THREAD_F6_F0,
  199. offsetof(struct task_struct, thread.fstate.f[6])
  200. - offsetof(struct task_struct, thread.fstate.f[0])
  201. );
  202. DEFINE(TASK_THREAD_F7_F0,
  203. offsetof(struct task_struct, thread.fstate.f[7])
  204. - offsetof(struct task_struct, thread.fstate.f[0])
  205. );
  206. DEFINE(TASK_THREAD_F8_F0,
  207. offsetof(struct task_struct, thread.fstate.f[8])
  208. - offsetof(struct task_struct, thread.fstate.f[0])
  209. );
  210. DEFINE(TASK_THREAD_F9_F0,
  211. offsetof(struct task_struct, thread.fstate.f[9])
  212. - offsetof(struct task_struct, thread.fstate.f[0])
  213. );
  214. DEFINE(TASK_THREAD_F10_F0,
  215. offsetof(struct task_struct, thread.fstate.f[10])
  216. - offsetof(struct task_struct, thread.fstate.f[0])
  217. );
  218. DEFINE(TASK_THREAD_F11_F0,
  219. offsetof(struct task_struct, thread.fstate.f[11])
  220. - offsetof(struct task_struct, thread.fstate.f[0])
  221. );
  222. DEFINE(TASK_THREAD_F12_F0,
  223. offsetof(struct task_struct, thread.fstate.f[12])
  224. - offsetof(struct task_struct, thread.fstate.f[0])
  225. );
  226. DEFINE(TASK_THREAD_F13_F0,
  227. offsetof(struct task_struct, thread.fstate.f[13])
  228. - offsetof(struct task_struct, thread.fstate.f[0])
  229. );
  230. DEFINE(TASK_THREAD_F14_F0,
  231. offsetof(struct task_struct, thread.fstate.f[14])
  232. - offsetof(struct task_struct, thread.fstate.f[0])
  233. );
  234. DEFINE(TASK_THREAD_F15_F0,
  235. offsetof(struct task_struct, thread.fstate.f[15])
  236. - offsetof(struct task_struct, thread.fstate.f[0])
  237. );
  238. DEFINE(TASK_THREAD_F16_F0,
  239. offsetof(struct task_struct, thread.fstate.f[16])
  240. - offsetof(struct task_struct, thread.fstate.f[0])
  241. );
  242. DEFINE(TASK_THREAD_F17_F0,
  243. offsetof(struct task_struct, thread.fstate.f[17])
  244. - offsetof(struct task_struct, thread.fstate.f[0])
  245. );
  246. DEFINE(TASK_THREAD_F18_F0,
  247. offsetof(struct task_struct, thread.fstate.f[18])
  248. - offsetof(struct task_struct, thread.fstate.f[0])
  249. );
  250. DEFINE(TASK_THREAD_F19_F0,
  251. offsetof(struct task_struct, thread.fstate.f[19])
  252. - offsetof(struct task_struct, thread.fstate.f[0])
  253. );
  254. DEFINE(TASK_THREAD_F20_F0,
  255. offsetof(struct task_struct, thread.fstate.f[20])
  256. - offsetof(struct task_struct, thread.fstate.f[0])
  257. );
  258. DEFINE(TASK_THREAD_F21_F0,
  259. offsetof(struct task_struct, thread.fstate.f[21])
  260. - offsetof(struct task_struct, thread.fstate.f[0])
  261. );
  262. DEFINE(TASK_THREAD_F22_F0,
  263. offsetof(struct task_struct, thread.fstate.f[22])
  264. - offsetof(struct task_struct, thread.fstate.f[0])
  265. );
  266. DEFINE(TASK_THREAD_F23_F0,
  267. offsetof(struct task_struct, thread.fstate.f[23])
  268. - offsetof(struct task_struct, thread.fstate.f[0])
  269. );
  270. DEFINE(TASK_THREAD_F24_F0,
  271. offsetof(struct task_struct, thread.fstate.f[24])
  272. - offsetof(struct task_struct, thread.fstate.f[0])
  273. );
  274. DEFINE(TASK_THREAD_F25_F0,
  275. offsetof(struct task_struct, thread.fstate.f[25])
  276. - offsetof(struct task_struct, thread.fstate.f[0])
  277. );
  278. DEFINE(TASK_THREAD_F26_F0,
  279. offsetof(struct task_struct, thread.fstate.f[26])
  280. - offsetof(struct task_struct, thread.fstate.f[0])
  281. );
  282. DEFINE(TASK_THREAD_F27_F0,
  283. offsetof(struct task_struct, thread.fstate.f[27])
  284. - offsetof(struct task_struct, thread.fstate.f[0])
  285. );
  286. DEFINE(TASK_THREAD_F28_F0,
  287. offsetof(struct task_struct, thread.fstate.f[28])
  288. - offsetof(struct task_struct, thread.fstate.f[0])
  289. );
  290. DEFINE(TASK_THREAD_F29_F0,
  291. offsetof(struct task_struct, thread.fstate.f[29])
  292. - offsetof(struct task_struct, thread.fstate.f[0])
  293. );
  294. DEFINE(TASK_THREAD_F30_F0,
  295. offsetof(struct task_struct, thread.fstate.f[30])
  296. - offsetof(struct task_struct, thread.fstate.f[0])
  297. );
  298. DEFINE(TASK_THREAD_F31_F0,
  299. offsetof(struct task_struct, thread.fstate.f[31])
  300. - offsetof(struct task_struct, thread.fstate.f[0])
  301. );
  302. DEFINE(TASK_THREAD_FCSR_F0,
  303. offsetof(struct task_struct, thread.fstate.fcsr)
  304. - offsetof(struct task_struct, thread.fstate.f[0])
  305. );
  306. /* The assembler needs access to THREAD_SIZE as well. */
  307. DEFINE(ASM_THREAD_SIZE, THREAD_SIZE);
  308. /*
  309. * We allocate a pt_regs on the stack when entering the kernel. This
  310. * ensures the alignment is sane.
  311. */
  312. DEFINE(PT_SIZE_ON_STACK, ALIGN(sizeof(struct pt_regs), STACK_ALIGN));
  313. }