fsys.S 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * This file contains the light-weight system call handlers (fsyscall-handlers).
  4. *
  5. * Copyright (C) 2003 Hewlett-Packard Co
  6. * David Mosberger-Tang <davidm@hpl.hp.com>
  7. *
  8. * 25-Sep-03 davidm Implement fsys_rt_sigprocmask().
  9. * 18-Feb-03 louisk Implement fsys_gettimeofday().
  10. * 28-Feb-03 davidm Fixed several bugs in fsys_gettimeofday(). Tuned it some more,
  11. * probably broke it along the way... ;-)
  12. * 13-Jul-04 clameter Implement fsys_clock_gettime and revise fsys_gettimeofday to make
  13. * it capable of using memory based clocks without falling back to C code.
  14. * 08-Feb-07 Fenghua Yu Implement fsys_getcpu.
  15. *
  16. */
  17. #include <asm/asmmacro.h>
  18. #include <asm/errno.h>
  19. #include <asm/asm-offsets.h>
  20. #include <asm/percpu.h>
  21. #include <asm/thread_info.h>
  22. #include <asm/sal.h>
  23. #include <asm/signal.h>
  24. #include <asm/unistd.h>
  25. #include "entry.h"
  26. #include <asm/native/inst.h>
  27. /*
  28. * See Documentation/ia64/fsys.txt for details on fsyscalls.
  29. *
  30. * On entry to an fsyscall handler:
  31. * r10 = 0 (i.e., defaults to "successful syscall return")
  32. * r11 = saved ar.pfs (a user-level value)
  33. * r15 = system call number
  34. * r16 = "current" task pointer (in normal kernel-mode, this is in r13)
  35. * r32-r39 = system call arguments
  36. * b6 = return address (a user-level value)
  37. * ar.pfs = previous frame-state (a user-level value)
  38. * PSR.be = cleared to zero (i.e., little-endian byte order is in effect)
  39. * all other registers may contain values passed in from user-mode
  40. *
  41. * On return from an fsyscall handler:
  42. * r11 = saved ar.pfs (as passed into the fsyscall handler)
  43. * r15 = system call number (as passed into the fsyscall handler)
  44. * r32-r39 = system call arguments (as passed into the fsyscall handler)
  45. * b6 = return address (as passed into the fsyscall handler)
  46. * ar.pfs = previous frame-state (as passed into the fsyscall handler)
  47. */
  48. ENTRY(fsys_ni_syscall)
  49. .prologue
  50. .altrp b6
  51. .body
  52. mov r8=ENOSYS
  53. mov r10=-1
  54. FSYS_RETURN
  55. END(fsys_ni_syscall)
  56. ENTRY(fsys_getpid)
  57. .prologue
  58. .altrp b6
  59. .body
  60. add r17=IA64_TASK_SIGNAL_OFFSET,r16
  61. ;;
  62. ld8 r17=[r17] // r17 = current->signal
  63. add r9=TI_FLAGS+IA64_TASK_SIZE,r16
  64. ;;
  65. ld4 r9=[r9]
  66. add r17=IA64_SIGNAL_PIDS_TGID_OFFSET,r17
  67. ;;
  68. and r9=TIF_ALLWORK_MASK,r9
  69. ld8 r17=[r17] // r17 = current->signal->pids[PIDTYPE_TGID]
  70. ;;
  71. add r8=IA64_PID_LEVEL_OFFSET,r17
  72. ;;
  73. ld4 r8=[r8] // r8 = pid->level
  74. add r17=IA64_PID_UPID_OFFSET,r17 // r17 = &pid->numbers[0]
  75. ;;
  76. shl r8=r8,IA64_UPID_SHIFT
  77. ;;
  78. add r17=r17,r8 // r17 = &pid->numbers[pid->level]
  79. ;;
  80. ld4 r8=[r17] // r8 = pid->numbers[pid->level].nr
  81. ;;
  82. mov r17=0
  83. ;;
  84. cmp.ne p8,p0=0,r9
  85. (p8) br.spnt.many fsys_fallback_syscall
  86. FSYS_RETURN
  87. END(fsys_getpid)
  88. ENTRY(fsys_set_tid_address)
  89. .prologue
  90. .altrp b6
  91. .body
  92. add r9=TI_FLAGS+IA64_TASK_SIZE,r16
  93. add r17=IA64_TASK_THREAD_PID_OFFSET,r16
  94. ;;
  95. ld4 r9=[r9]
  96. tnat.z p6,p7=r32 // check argument register for being NaT
  97. ld8 r17=[r17] // r17 = current->thread_pid
  98. ;;
  99. and r9=TIF_ALLWORK_MASK,r9
  100. add r8=IA64_PID_LEVEL_OFFSET,r17
  101. add r18=IA64_TASK_CLEAR_CHILD_TID_OFFSET,r16
  102. ;;
  103. ld4 r8=[r8] // r8 = pid->level
  104. add r17=IA64_PID_UPID_OFFSET,r17 // r17 = &pid->numbers[0]
  105. ;;
  106. shl r8=r8,IA64_UPID_SHIFT
  107. ;;
  108. add r17=r17,r8 // r17 = &pid->numbers[pid->level]
  109. ;;
  110. ld4 r8=[r17] // r8 = pid->numbers[pid->level].nr
  111. ;;
  112. cmp.ne p8,p0=0,r9
  113. mov r17=-1
  114. ;;
  115. (p6) st8 [r18]=r32
  116. (p7) st8 [r18]=r17
  117. (p8) br.spnt.many fsys_fallback_syscall
  118. ;;
  119. mov r17=0 // i must not leak kernel bits...
  120. mov r18=0 // i must not leak kernel bits...
  121. FSYS_RETURN
  122. END(fsys_set_tid_address)
  123. #if IA64_GTOD_SEQ_OFFSET !=0
  124. #error fsys_gettimeofday incompatible with changes to struct fsyscall_gtod_data_t
  125. #endif
  126. #if IA64_ITC_JITTER_OFFSET !=0
  127. #error fsys_gettimeofday incompatible with changes to struct itc_jitter_data_t
  128. #endif
  129. #define CLOCK_REALTIME 0
  130. #define CLOCK_MONOTONIC 1
  131. #define CLOCK_DIVIDE_BY_1000 0x4000
  132. #define CLOCK_ADD_MONOTONIC 0x8000
  133. ENTRY(fsys_gettimeofday)
  134. .prologue
  135. .altrp b6
  136. .body
  137. mov r31 = r32
  138. tnat.nz p6,p0 = r33 // guard against NaT argument
  139. (p6) br.cond.spnt.few .fail_einval
  140. mov r30 = CLOCK_DIVIDE_BY_1000
  141. ;;
  142. .gettime:
  143. // Register map
  144. // Incoming r31 = pointer to address where to place result
  145. // r30 = flags determining how time is processed
  146. // r2,r3 = temp r4-r7 preserved
  147. // r8 = result nanoseconds
  148. // r9 = result seconds
  149. // r10 = temporary storage for clock difference
  150. // r11 = preserved: saved ar.pfs
  151. // r12 = preserved: memory stack
  152. // r13 = preserved: thread pointer
  153. // r14 = address of mask / mask value
  154. // r15 = preserved: system call number
  155. // r16 = preserved: current task pointer
  156. // r17 = (not used)
  157. // r18 = (not used)
  158. // r19 = address of itc_lastcycle
  159. // r20 = struct fsyscall_gtod_data (= address of gtod_lock.sequence)
  160. // r21 = address of mmio_ptr
  161. // r22 = address of wall_time or monotonic_time
  162. // r23 = address of shift / value
  163. // r24 = address mult factor / cycle_last value
  164. // r25 = itc_lastcycle value
  165. // r26 = address clocksource cycle_last
  166. // r27 = (not used)
  167. // r28 = sequence number at the beginning of critcal section
  168. // r29 = address of itc_jitter
  169. // r30 = time processing flags / memory address
  170. // r31 = pointer to result
  171. // Predicates
  172. // p6,p7 short term use
  173. // p8 = timesource ar.itc
  174. // p9 = timesource mmio64
  175. // p10 = timesource mmio32 - not used
  176. // p11 = timesource not to be handled by asm code
  177. // p12 = memory time source ( = p9 | p10) - not used
  178. // p13 = do cmpxchg with itc_lastcycle
  179. // p14 = Divide by 1000
  180. // p15 = Add monotonic
  181. //
  182. // Note that instructions are optimized for McKinley. McKinley can
  183. // process two bundles simultaneously and therefore we continuously
  184. // try to feed the CPU two bundles and then a stop.
  185. add r2 = TI_FLAGS+IA64_TASK_SIZE,r16
  186. tnat.nz p6,p0 = r31 // guard against Nat argument
  187. (p6) br.cond.spnt.few .fail_einval
  188. movl r20 = fsyscall_gtod_data // load fsyscall gettimeofday data address
  189. ;;
  190. ld4 r2 = [r2] // process work pending flags
  191. movl r29 = itc_jitter_data // itc_jitter
  192. add r22 = IA64_GTOD_WALL_TIME_OFFSET,r20 // wall_time
  193. add r21 = IA64_CLKSRC_MMIO_OFFSET,r20
  194. mov pr = r30,0xc000 // Set predicates according to function
  195. ;;
  196. and r2 = TIF_ALLWORK_MASK,r2
  197. add r19 = IA64_ITC_LASTCYCLE_OFFSET,r29
  198. (p15) add r22 = IA64_GTOD_MONO_TIME_OFFSET,r20 // monotonic_time
  199. ;;
  200. add r26 = IA64_CLKSRC_CYCLE_LAST_OFFSET,r20 // clksrc_cycle_last
  201. cmp.ne p6, p0 = 0, r2 // Fallback if work is scheduled
  202. (p6) br.cond.spnt.many fsys_fallback_syscall
  203. ;;
  204. // Begin critical section
  205. .time_redo:
  206. ld4.acq r28 = [r20] // gtod_lock.sequence, Must take first
  207. ;;
  208. and r28 = ~1,r28 // And make sequence even to force retry if odd
  209. ;;
  210. ld8 r30 = [r21] // clocksource->mmio_ptr
  211. add r24 = IA64_CLKSRC_MULT_OFFSET,r20
  212. ld4 r2 = [r29] // itc_jitter value
  213. add r23 = IA64_CLKSRC_SHIFT_OFFSET,r20
  214. add r14 = IA64_CLKSRC_MASK_OFFSET,r20
  215. ;;
  216. ld4 r3 = [r24] // clocksource mult value
  217. ld8 r14 = [r14] // clocksource mask value
  218. cmp.eq p8,p9 = 0,r30 // use cpu timer if no mmio_ptr
  219. ;;
  220. setf.sig f7 = r3 // Setup for mult scaling of counter
  221. (p8) cmp.ne p13,p0 = r2,r0 // need itc_jitter compensation, set p13
  222. ld4 r23 = [r23] // clocksource shift value
  223. ld8 r24 = [r26] // get clksrc_cycle_last value
  224. (p9) cmp.eq p13,p0 = 0,r30 // if mmio_ptr, clear p13 jitter control
  225. ;;
  226. .pred.rel.mutex p8,p9
  227. MOV_FROM_ITC(p8, p6, r2, r10) // CPU_TIMER. 36 clocks latency!!!
  228. (p9) ld8 r2 = [r30] // MMIO_TIMER. Could also have latency issues..
  229. (p13) ld8 r25 = [r19] // get itc_lastcycle value
  230. ld8 r9 = [r22],IA64_TIME_SN_SPEC_SNSEC_OFFSET // sec
  231. ;;
  232. ld8 r8 = [r22],-IA64_TIME_SN_SPEC_SNSEC_OFFSET // snsec
  233. (p13) sub r3 = r25,r2 // Diff needed before comparison (thanks davidm)
  234. ;;
  235. (p13) cmp.gt.unc p6,p7 = r3,r0 // check if it is less than last. p6,p7 cleared
  236. sub r10 = r2,r24 // current_cycle - last_cycle
  237. ;;
  238. (p6) sub r10 = r25,r24 // time we got was less than last_cycle
  239. (p7) mov ar.ccv = r25 // more than last_cycle. Prep for cmpxchg
  240. ;;
  241. (p7) cmpxchg8.rel r3 = [r19],r2,ar.ccv
  242. ;;
  243. (p7) cmp.ne p7,p0 = r25,r3 // if cmpxchg not successful
  244. ;;
  245. (p7) sub r10 = r3,r24 // then use new last_cycle instead
  246. ;;
  247. and r10 = r10,r14 // Apply mask
  248. ;;
  249. setf.sig f8 = r10
  250. nop.i 123
  251. ;;
  252. // fault check takes 5 cycles and we have spare time
  253. EX(.fail_efault, probe.w.fault r31, 3)
  254. xmpy.l f8 = f8,f7 // nsec_per_cyc*(counter-last_counter)
  255. ;;
  256. getf.sig r2 = f8
  257. mf
  258. ;;
  259. ld4 r10 = [r20] // gtod_lock.sequence
  260. add r8 = r8,r2 // Add xtime.nsecs
  261. ;;
  262. shr.u r8 = r8,r23 // shift by factor
  263. cmp4.ne p7,p0 = r28,r10
  264. (p7) br.cond.dpnt.few .time_redo // sequence number changed, redo
  265. // End critical section.
  266. // Now r8=tv->tv_nsec and r9=tv->tv_sec
  267. mov r10 = r0
  268. movl r2 = 1000000000
  269. add r23 = IA64_TIMESPEC_TV_NSEC_OFFSET, r31
  270. (p14) movl r3 = 2361183241434822607 // Prep for / 1000 hack
  271. ;;
  272. .time_normalize:
  273. mov r21 = r8
  274. cmp.ge p6,p0 = r8,r2
  275. (p14) shr.u r20 = r8, 3 // We can repeat this if necessary just wasting time
  276. ;;
  277. (p14) setf.sig f8 = r20
  278. (p6) sub r8 = r8,r2
  279. (p6) add r9 = 1,r9 // two nops before the branch.
  280. (p14) setf.sig f7 = r3 // Chances for repeats are 1 in 10000 for gettod
  281. (p6) br.cond.dpnt.few .time_normalize
  282. ;;
  283. // Divided by 8 though shift. Now divide by 125
  284. // The compiler was able to do that with a multiply
  285. // and a shift and we do the same
  286. EX(.fail_efault, probe.w.fault r23, 3) // This also costs 5 cycles
  287. (p14) xmpy.hu f8 = f8, f7 // xmpy has 5 cycles latency so use it
  288. ;;
  289. (p14) getf.sig r2 = f8
  290. ;;
  291. mov r8 = r0
  292. (p14) shr.u r21 = r2, 4
  293. ;;
  294. EX(.fail_efault, st8 [r31] = r9)
  295. EX(.fail_efault, st8 [r23] = r21)
  296. FSYS_RETURN
  297. .fail_einval:
  298. mov r8 = EINVAL
  299. mov r10 = -1
  300. FSYS_RETURN
  301. .fail_efault:
  302. mov r8 = EFAULT
  303. mov r10 = -1
  304. FSYS_RETURN
  305. END(fsys_gettimeofday)
  306. ENTRY(fsys_clock_gettime)
  307. .prologue
  308. .altrp b6
  309. .body
  310. cmp4.ltu p6, p0 = CLOCK_MONOTONIC, r32
  311. // Fallback if this is not CLOCK_REALTIME or CLOCK_MONOTONIC
  312. (p6) br.spnt.few fsys_fallback_syscall
  313. mov r31 = r33
  314. shl r30 = r32,15
  315. br.many .gettime
  316. END(fsys_clock_gettime)
  317. /*
  318. * fsys_getcpu doesn't use the third parameter in this implementation. It reads
  319. * current_thread_info()->cpu and corresponding node in cpu_to_node_map.
  320. */
  321. ENTRY(fsys_getcpu)
  322. .prologue
  323. .altrp b6
  324. .body
  325. ;;
  326. add r2=TI_FLAGS+IA64_TASK_SIZE,r16
  327. tnat.nz p6,p0 = r32 // guard against NaT argument
  328. add r3=TI_CPU+IA64_TASK_SIZE,r16
  329. ;;
  330. ld4 r3=[r3] // M r3 = thread_info->cpu
  331. ld4 r2=[r2] // M r2 = thread_info->flags
  332. (p6) br.cond.spnt.few .fail_einval // B
  333. ;;
  334. tnat.nz p7,p0 = r33 // I guard against NaT argument
  335. (p7) br.cond.spnt.few .fail_einval // B
  336. ;;
  337. cmp.ne p6,p0=r32,r0
  338. cmp.ne p7,p0=r33,r0
  339. ;;
  340. #ifdef CONFIG_NUMA
  341. movl r17=cpu_to_node_map
  342. ;;
  343. EX(.fail_efault, (p6) probe.w.fault r32, 3) // M This takes 5 cycles
  344. EX(.fail_efault, (p7) probe.w.fault r33, 3) // M This takes 5 cycles
  345. shladd r18=r3,1,r17
  346. ;;
  347. ld2 r20=[r18] // r20 = cpu_to_node_map[cpu]
  348. and r2 = TIF_ALLWORK_MASK,r2
  349. ;;
  350. cmp.ne p8,p0=0,r2
  351. (p8) br.spnt.many fsys_fallback_syscall
  352. ;;
  353. ;;
  354. EX(.fail_efault, (p6) st4 [r32] = r3)
  355. EX(.fail_efault, (p7) st2 [r33] = r20)
  356. mov r8=0
  357. ;;
  358. #else
  359. EX(.fail_efault, (p6) probe.w.fault r32, 3) // M This takes 5 cycles
  360. EX(.fail_efault, (p7) probe.w.fault r33, 3) // M This takes 5 cycles
  361. and r2 = TIF_ALLWORK_MASK,r2
  362. ;;
  363. cmp.ne p8,p0=0,r2
  364. (p8) br.spnt.many fsys_fallback_syscall
  365. ;;
  366. EX(.fail_efault, (p6) st4 [r32] = r3)
  367. EX(.fail_efault, (p7) st2 [r33] = r0)
  368. mov r8=0
  369. ;;
  370. #endif
  371. FSYS_RETURN
  372. END(fsys_getcpu)
  373. ENTRY(fsys_fallback_syscall)
  374. .prologue
  375. .altrp b6
  376. .body
  377. /*
  378. * We only get here from light-weight syscall handlers. Thus, we already
  379. * know that r15 contains a valid syscall number. No need to re-check.
  380. */
  381. adds r17=-1024,r15
  382. movl r14=sys_call_table
  383. ;;
  384. RSM_PSR_I(p0, r26, r27)
  385. shladd r18=r17,3,r14
  386. ;;
  387. ld8 r18=[r18] // load normal (heavy-weight) syscall entry-point
  388. MOV_FROM_PSR(p0, r29, r26) // read psr (12 cyc load latency)
  389. mov r27=ar.rsc
  390. mov r21=ar.fpsr
  391. mov r26=ar.pfs
  392. END(fsys_fallback_syscall)
  393. /* FALL THROUGH */
  394. GLOBAL_ENTRY(fsys_bubble_down)
  395. .prologue
  396. .altrp b6
  397. .body
  398. /*
  399. * We get here for syscalls that don't have a lightweight
  400. * handler. For those, we need to bubble down into the kernel
  401. * and that requires setting up a minimal pt_regs structure,
  402. * and initializing the CPU state more or less as if an
  403. * interruption had occurred. To make syscall-restarts work,
  404. * we setup pt_regs such that cr_iip points to the second
  405. * instruction in syscall_via_break. Decrementing the IP
  406. * hence will restart the syscall via break and not
  407. * decrementing IP will return us to the caller, as usual.
  408. * Note that we preserve the value of psr.pp rather than
  409. * initializing it from dcr.pp. This makes it possible to
  410. * distinguish fsyscall execution from other privileged
  411. * execution.
  412. *
  413. * On entry:
  414. * - normal fsyscall handler register usage, except
  415. * that we also have:
  416. * - r18: address of syscall entry point
  417. * - r21: ar.fpsr
  418. * - r26: ar.pfs
  419. * - r27: ar.rsc
  420. * - r29: psr
  421. *
  422. * We used to clear some PSR bits here but that requires slow
  423. * serialization. Fortuntely, that isn't really necessary.
  424. * The rationale is as follows: we used to clear bits
  425. * ~PSR_PRESERVED_BITS in PSR.L. Since
  426. * PSR_PRESERVED_BITS==PSR.{UP,MFL,MFH,PK,DT,PP,SP,RT,IC}, we
  427. * ended up clearing PSR.{BE,AC,I,DFL,DFH,DI,DB,SI,TB}.
  428. * However,
  429. *
  430. * PSR.BE : already is turned off in __kernel_syscall_via_epc()
  431. * PSR.AC : don't care (kernel normally turns PSR.AC on)
  432. * PSR.I : already turned off by the time fsys_bubble_down gets
  433. * invoked
  434. * PSR.DFL: always 0 (kernel never turns it on)
  435. * PSR.DFH: don't care --- kernel never touches f32-f127 on its own
  436. * initiative
  437. * PSR.DI : always 0 (kernel never turns it on)
  438. * PSR.SI : always 0 (kernel never turns it on)
  439. * PSR.DB : don't care --- kernel never enables kernel-level
  440. * breakpoints
  441. * PSR.TB : must be 0 already; if it wasn't zero on entry to
  442. * __kernel_syscall_via_epc, the branch to fsys_bubble_down
  443. * will trigger a taken branch; the taken-trap-handler then
  444. * converts the syscall into a break-based system-call.
  445. */
  446. /*
  447. * Reading psr.l gives us only bits 0-31, psr.it, and psr.mc.
  448. * The rest we have to synthesize.
  449. */
  450. # define PSR_ONE_BITS ((3 << IA64_PSR_CPL0_BIT) \
  451. | (0x1 << IA64_PSR_RI_BIT) \
  452. | IA64_PSR_BN | IA64_PSR_I)
  453. invala // M0|1
  454. movl r14=ia64_ret_from_syscall // X
  455. nop.m 0
  456. movl r28=__kernel_syscall_via_break // X create cr.iip
  457. ;;
  458. mov r2=r16 // A get task addr to addl-addressable register
  459. adds r16=IA64_TASK_THREAD_ON_USTACK_OFFSET,r16 // A
  460. mov r31=pr // I0 save pr (2 cyc)
  461. ;;
  462. st1 [r16]=r0 // M2|3 clear current->thread.on_ustack flag
  463. addl r22=IA64_RBS_OFFSET,r2 // A compute base of RBS
  464. add r3=TI_FLAGS+IA64_TASK_SIZE,r2 // A
  465. ;;
  466. ld4 r3=[r3] // M0|1 r3 = current_thread_info()->flags
  467. lfetch.fault.excl.nt1 [r22] // M0|1 prefetch register backing-store
  468. nop.i 0
  469. ;;
  470. mov ar.rsc=0 // M2 set enforced lazy mode, pl 0, LE, loadrs=0
  471. #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
  472. MOV_FROM_ITC(p0, p6, r30, r23) // M get cycle for accounting
  473. #else
  474. nop.m 0
  475. #endif
  476. nop.i 0
  477. ;;
  478. mov r23=ar.bspstore // M2 (12 cyc) save ar.bspstore
  479. mov.m r24=ar.rnat // M2 (5 cyc) read ar.rnat (dual-issues!)
  480. nop.i 0
  481. ;;
  482. mov ar.bspstore=r22 // M2 (6 cyc) switch to kernel RBS
  483. movl r8=PSR_ONE_BITS // X
  484. ;;
  485. mov r25=ar.unat // M2 (5 cyc) save ar.unat
  486. mov r19=b6 // I0 save b6 (2 cyc)
  487. mov r20=r1 // A save caller's gp in r20
  488. ;;
  489. or r29=r8,r29 // A construct cr.ipsr value to save
  490. mov b6=r18 // I0 copy syscall entry-point to b6 (7 cyc)
  491. addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r2 // A compute base of memory stack
  492. mov r18=ar.bsp // M2 save (kernel) ar.bsp (12 cyc)
  493. cmp.ne pKStk,pUStk=r0,r0 // A set pKStk <- 0, pUStk <- 1
  494. br.call.sptk.many b7=ia64_syscall_setup // B
  495. ;;
  496. #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
  497. // mov.m r30=ar.itc is called in advance
  498. add r16=TI_AC_STAMP+IA64_TASK_SIZE,r2
  499. add r17=TI_AC_LEAVE+IA64_TASK_SIZE,r2
  500. ;;
  501. ld8 r18=[r16],TI_AC_STIME-TI_AC_STAMP // time at last check in kernel
  502. ld8 r19=[r17],TI_AC_UTIME-TI_AC_LEAVE // time at leave kernel
  503. ;;
  504. ld8 r20=[r16],TI_AC_STAMP-TI_AC_STIME // cumulated stime
  505. ld8 r21=[r17] // cumulated utime
  506. sub r22=r19,r18 // stime before leave kernel
  507. ;;
  508. st8 [r16]=r30,TI_AC_STIME-TI_AC_STAMP // update stamp
  509. sub r18=r30,r19 // elapsed time in user mode
  510. ;;
  511. add r20=r20,r22 // sum stime
  512. add r21=r21,r18 // sum utime
  513. ;;
  514. st8 [r16]=r20 // update stime
  515. st8 [r17]=r21 // update utime
  516. ;;
  517. #endif
  518. mov ar.rsc=0x3 // M2 set eager mode, pl 0, LE, loadrs=0
  519. mov rp=r14 // I0 set the real return addr
  520. and r3=_TIF_SYSCALL_TRACEAUDIT,r3 // A
  521. ;;
  522. SSM_PSR_I(p0, p6, r22) // M2 we're on kernel stacks now, reenable irqs
  523. cmp.eq p8,p0=r3,r0 // A
  524. (p10) br.cond.spnt.many ia64_ret_from_syscall // B return if bad call-frame or r15 is a NaT
  525. nop.m 0
  526. (p8) br.call.sptk.many b6=b6 // B (ignore return address)
  527. br.cond.spnt ia64_trace_syscall // B
  528. END(fsys_bubble_down)
  529. .rodata
  530. .align 8
  531. .globl fsyscall_table
  532. data8 fsys_bubble_down
  533. fsyscall_table:
  534. data8 fsys_ni_syscall
  535. data8 0 // exit // 1025
  536. data8 0 // read
  537. data8 0 // write
  538. data8 0 // open
  539. data8 0 // close
  540. data8 0 // creat // 1030
  541. data8 0 // link
  542. data8 0 // unlink
  543. data8 0 // execve
  544. data8 0 // chdir
  545. data8 0 // fchdir // 1035
  546. data8 0 // utimes
  547. data8 0 // mknod
  548. data8 0 // chmod
  549. data8 0 // chown
  550. data8 0 // lseek // 1040
  551. data8 fsys_getpid // getpid
  552. data8 0 // getppid
  553. data8 0 // mount
  554. data8 0 // umount
  555. data8 0 // setuid // 1045
  556. data8 0 // getuid
  557. data8 0 // geteuid
  558. data8 0 // ptrace
  559. data8 0 // access
  560. data8 0 // sync // 1050
  561. data8 0 // fsync
  562. data8 0 // fdatasync
  563. data8 0 // kill
  564. data8 0 // rename
  565. data8 0 // mkdir // 1055
  566. data8 0 // rmdir
  567. data8 0 // dup
  568. data8 0 // pipe
  569. data8 0 // times
  570. data8 0 // brk // 1060
  571. data8 0 // setgid
  572. data8 0 // getgid
  573. data8 0 // getegid
  574. data8 0 // acct
  575. data8 0 // ioctl // 1065
  576. data8 0 // fcntl
  577. data8 0 // umask
  578. data8 0 // chroot
  579. data8 0 // ustat
  580. data8 0 // dup2 // 1070
  581. data8 0 // setreuid
  582. data8 0 // setregid
  583. data8 0 // getresuid
  584. data8 0 // setresuid
  585. data8 0 // getresgid // 1075
  586. data8 0 // setresgid
  587. data8 0 // getgroups
  588. data8 0 // setgroups
  589. data8 0 // getpgid
  590. data8 0 // setpgid // 1080
  591. data8 0 // setsid
  592. data8 0 // getsid
  593. data8 0 // sethostname
  594. data8 0 // setrlimit
  595. data8 0 // getrlimit // 1085
  596. data8 0 // getrusage
  597. data8 fsys_gettimeofday // gettimeofday
  598. data8 0 // settimeofday
  599. data8 0 // select
  600. data8 0 // poll // 1090
  601. data8 0 // symlink
  602. data8 0 // readlink
  603. data8 0 // uselib
  604. data8 0 // swapon
  605. data8 0 // swapoff // 1095
  606. data8 0 // reboot
  607. data8 0 // truncate
  608. data8 0 // ftruncate
  609. data8 0 // fchmod
  610. data8 0 // fchown // 1100
  611. data8 0 // getpriority
  612. data8 0 // setpriority
  613. data8 0 // statfs
  614. data8 0 // fstatfs
  615. data8 0 // gettid // 1105
  616. data8 0 // semget
  617. data8 0 // semop
  618. data8 0 // semctl
  619. data8 0 // msgget
  620. data8 0 // msgsnd // 1110
  621. data8 0 // msgrcv
  622. data8 0 // msgctl
  623. data8 0 // shmget
  624. data8 0 // shmat
  625. data8 0 // shmdt // 1115
  626. data8 0 // shmctl
  627. data8 0 // syslog
  628. data8 0 // setitimer
  629. data8 0 // getitimer
  630. data8 0 // 1120
  631. data8 0
  632. data8 0
  633. data8 0 // vhangup
  634. data8 0 // lchown
  635. data8 0 // remap_file_pages // 1125
  636. data8 0 // wait4
  637. data8 0 // sysinfo
  638. data8 0 // clone
  639. data8 0 // setdomainname
  640. data8 0 // newuname // 1130
  641. data8 0 // adjtimex
  642. data8 0
  643. data8 0 // init_module
  644. data8 0 // delete_module
  645. data8 0 // 1135
  646. data8 0
  647. data8 0 // quotactl
  648. data8 0 // bdflush
  649. data8 0 // sysfs
  650. data8 0 // personality // 1140
  651. data8 0 // afs_syscall
  652. data8 0 // setfsuid
  653. data8 0 // setfsgid
  654. data8 0 // getdents
  655. data8 0 // flock // 1145
  656. data8 0 // readv
  657. data8 0 // writev
  658. data8 0 // pread64
  659. data8 0 // pwrite64
  660. data8 0 // sysctl // 1150
  661. data8 0 // mmap
  662. data8 0 // munmap
  663. data8 0 // mlock
  664. data8 0 // mlockall
  665. data8 0 // mprotect // 1155
  666. data8 0 // mremap
  667. data8 0 // msync
  668. data8 0 // munlock
  669. data8 0 // munlockall
  670. data8 0 // sched_getparam // 1160
  671. data8 0 // sched_setparam
  672. data8 0 // sched_getscheduler
  673. data8 0 // sched_setscheduler
  674. data8 0 // sched_yield
  675. data8 0 // sched_get_priority_max // 1165
  676. data8 0 // sched_get_priority_min
  677. data8 0 // sched_rr_get_interval
  678. data8 0 // nanosleep
  679. data8 0 // nfsservctl
  680. data8 0 // prctl // 1170
  681. data8 0 // getpagesize
  682. data8 0 // mmap2
  683. data8 0 // pciconfig_read
  684. data8 0 // pciconfig_write
  685. data8 0 // perfmonctl // 1175
  686. data8 0 // sigaltstack
  687. data8 0 // rt_sigaction
  688. data8 0 // rt_sigpending
  689. data8 0 // rt_sigprocmask
  690. data8 0 // rt_sigqueueinfo // 1180
  691. data8 0 // rt_sigreturn
  692. data8 0 // rt_sigsuspend
  693. data8 0 // rt_sigtimedwait
  694. data8 0 // getcwd
  695. data8 0 // capget // 1185
  696. data8 0 // capset
  697. data8 0 // sendfile
  698. data8 0
  699. data8 0
  700. data8 0 // socket // 1190
  701. data8 0 // bind
  702. data8 0 // connect
  703. data8 0 // listen
  704. data8 0 // accept
  705. data8 0 // getsockname // 1195
  706. data8 0 // getpeername
  707. data8 0 // socketpair
  708. data8 0 // send
  709. data8 0 // sendto
  710. data8 0 // recv // 1200
  711. data8 0 // recvfrom
  712. data8 0 // shutdown
  713. data8 0 // setsockopt
  714. data8 0 // getsockopt
  715. data8 0 // sendmsg // 1205
  716. data8 0 // recvmsg
  717. data8 0 // pivot_root
  718. data8 0 // mincore
  719. data8 0 // madvise
  720. data8 0 // newstat // 1210
  721. data8 0 // newlstat
  722. data8 0 // newfstat
  723. data8 0 // clone2
  724. data8 0 // getdents64
  725. data8 0 // getunwind // 1215
  726. data8 0 // readahead
  727. data8 0 // setxattr
  728. data8 0 // lsetxattr
  729. data8 0 // fsetxattr
  730. data8 0 // getxattr // 1220
  731. data8 0 // lgetxattr
  732. data8 0 // fgetxattr
  733. data8 0 // listxattr
  734. data8 0 // llistxattr
  735. data8 0 // flistxattr // 1225
  736. data8 0 // removexattr
  737. data8 0 // lremovexattr
  738. data8 0 // fremovexattr
  739. data8 0 // tkill
  740. data8 0 // futex // 1230
  741. data8 0 // sched_setaffinity
  742. data8 0 // sched_getaffinity
  743. data8 fsys_set_tid_address // set_tid_address
  744. data8 0 // fadvise64_64
  745. data8 0 // tgkill // 1235
  746. data8 0 // exit_group
  747. data8 0 // lookup_dcookie
  748. data8 0 // io_setup
  749. data8 0 // io_destroy
  750. data8 0 // io_getevents // 1240
  751. data8 0 // io_submit
  752. data8 0 // io_cancel
  753. data8 0 // epoll_create
  754. data8 0 // epoll_ctl
  755. data8 0 // epoll_wait // 1245
  756. data8 0 // restart_syscall
  757. data8 0 // semtimedop
  758. data8 0 // timer_create
  759. data8 0 // timer_settime
  760. data8 0 // timer_gettime // 1250
  761. data8 0 // timer_getoverrun
  762. data8 0 // timer_delete
  763. data8 0 // clock_settime
  764. data8 fsys_clock_gettime // clock_gettime
  765. data8 0 // clock_getres // 1255
  766. data8 0 // clock_nanosleep
  767. data8 0 // fstatfs64
  768. data8 0 // statfs64
  769. data8 0 // mbind
  770. data8 0 // get_mempolicy // 1260
  771. data8 0 // set_mempolicy
  772. data8 0 // mq_open
  773. data8 0 // mq_unlink
  774. data8 0 // mq_timedsend
  775. data8 0 // mq_timedreceive // 1265
  776. data8 0 // mq_notify
  777. data8 0 // mq_getsetattr
  778. data8 0 // kexec_load
  779. data8 0 // vserver
  780. data8 0 // waitid // 1270
  781. data8 0 // add_key
  782. data8 0 // request_key
  783. data8 0 // keyctl
  784. data8 0 // ioprio_set
  785. data8 0 // ioprio_get // 1275
  786. data8 0 // move_pages
  787. data8 0 // inotify_init
  788. data8 0 // inotify_add_watch
  789. data8 0 // inotify_rm_watch
  790. data8 0 // migrate_pages // 1280
  791. data8 0 // openat
  792. data8 0 // mkdirat
  793. data8 0 // mknodat
  794. data8 0 // fchownat
  795. data8 0 // futimesat // 1285
  796. data8 0 // newfstatat
  797. data8 0 // unlinkat
  798. data8 0 // renameat
  799. data8 0 // linkat
  800. data8 0 // symlinkat // 1290
  801. data8 0 // readlinkat
  802. data8 0 // fchmodat
  803. data8 0 // faccessat
  804. data8 0
  805. data8 0 // 1295
  806. data8 0 // unshare
  807. data8 0 // splice
  808. data8 0 // set_robust_list
  809. data8 0 // get_robust_list
  810. data8 0 // sync_file_range // 1300
  811. data8 0 // tee
  812. data8 0 // vmsplice
  813. data8 0
  814. data8 fsys_getcpu // getcpu // 1304
  815. // fill in zeros for the remaining entries
  816. .zero:
  817. .space fsyscall_table + 8*NR_syscalls - .zero, 0