ultra.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. /* $Id: ultra.S,v 1.72 2002/02/09 19:49:31 davem Exp $
  2. * ultra.S: Don't expand these all over the place...
  3. *
  4. * Copyright (C) 1997, 2000 David S. Miller (davem@redhat.com)
  5. */
  6. #include <asm/asi.h>
  7. #include <asm/pgtable.h>
  8. #include <asm/page.h>
  9. #include <asm/spitfire.h>
  10. #include <asm/mmu_context.h>
  11. #include <asm/mmu.h>
  12. #include <asm/pil.h>
  13. #include <asm/head.h>
  14. #include <asm/thread_info.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/hypervisor.h>
  17. /* Basically, most of the Spitfire vs. Cheetah madness
  18. * has to do with the fact that Cheetah does not support
  19. * IMMU flushes out of the secondary context. Someone needs
  20. * to throw a south lake birthday party for the folks
  21. * in Microelectronics who refused to fix this shit.
  22. */
  23. /* This file is meant to be read efficiently by the CPU, not humans.
  24. * Staraj sie tego nikomu nie pierdolnac...
  25. */
  26. .text
  27. .align 32
  28. .globl __flush_tlb_mm
  29. __flush_tlb_mm: /* 18 insns */
  30. /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */
  31. ldxa [%o1] ASI_DMMU, %g2
  32. cmp %g2, %o0
  33. bne,pn %icc, __spitfire_flush_tlb_mm_slow
  34. mov 0x50, %g3
  35. stxa %g0, [%g3] ASI_DMMU_DEMAP
  36. stxa %g0, [%g3] ASI_IMMU_DEMAP
  37. sethi %hi(KERNBASE), %g3
  38. flush %g3
  39. retl
  40. nop
  41. nop
  42. nop
  43. nop
  44. nop
  45. nop
  46. nop
  47. nop
  48. nop
  49. nop
  50. .align 32
  51. .globl __flush_tlb_pending
  52. __flush_tlb_pending: /* 26 insns */
  53. /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
  54. rdpr %pstate, %g7
  55. sllx %o1, 3, %o1
  56. andn %g7, PSTATE_IE, %g2
  57. wrpr %g2, %pstate
  58. mov SECONDARY_CONTEXT, %o4
  59. ldxa [%o4] ASI_DMMU, %g2
  60. stxa %o0, [%o4] ASI_DMMU
  61. 1: sub %o1, (1 << 3), %o1
  62. ldx [%o2 + %o1], %o3
  63. andcc %o3, 1, %g0
  64. andn %o3, 1, %o3
  65. be,pn %icc, 2f
  66. or %o3, 0x10, %o3
  67. stxa %g0, [%o3] ASI_IMMU_DEMAP
  68. 2: stxa %g0, [%o3] ASI_DMMU_DEMAP
  69. membar #Sync
  70. brnz,pt %o1, 1b
  71. nop
  72. stxa %g2, [%o4] ASI_DMMU
  73. sethi %hi(KERNBASE), %o4
  74. flush %o4
  75. retl
  76. wrpr %g7, 0x0, %pstate
  77. nop
  78. nop
  79. nop
  80. nop
  81. .align 32
  82. .globl __flush_tlb_kernel_range
  83. __flush_tlb_kernel_range: /* 16 insns */
  84. /* %o0=start, %o1=end */
  85. cmp %o0, %o1
  86. be,pn %xcc, 2f
  87. sethi %hi(PAGE_SIZE), %o4
  88. sub %o1, %o0, %o3
  89. sub %o3, %o4, %o3
  90. or %o0, 0x20, %o0 ! Nucleus
  91. 1: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP
  92. stxa %g0, [%o0 + %o3] ASI_IMMU_DEMAP
  93. membar #Sync
  94. brnz,pt %o3, 1b
  95. sub %o3, %o4, %o3
  96. 2: sethi %hi(KERNBASE), %o3
  97. flush %o3
  98. retl
  99. nop
  100. nop
  101. __spitfire_flush_tlb_mm_slow:
  102. rdpr %pstate, %g1
  103. wrpr %g1, PSTATE_IE, %pstate
  104. stxa %o0, [%o1] ASI_DMMU
  105. stxa %g0, [%g3] ASI_DMMU_DEMAP
  106. stxa %g0, [%g3] ASI_IMMU_DEMAP
  107. flush %g6
  108. stxa %g2, [%o1] ASI_DMMU
  109. sethi %hi(KERNBASE), %o1
  110. flush %o1
  111. retl
  112. wrpr %g1, 0, %pstate
  113. /*
  114. * The following code flushes one page_size worth.
  115. */
  116. .section .kprobes.text, "ax"
  117. .align 32
  118. .globl __flush_icache_page
  119. __flush_icache_page: /* %o0 = phys_page */
  120. membar #StoreStore
  121. srlx %o0, PAGE_SHIFT, %o0
  122. sethi %uhi(PAGE_OFFSET), %g1
  123. sllx %o0, PAGE_SHIFT, %o0
  124. sethi %hi(PAGE_SIZE), %g2
  125. sllx %g1, 32, %g1
  126. add %o0, %g1, %o0
  127. 1: subcc %g2, 32, %g2
  128. bne,pt %icc, 1b
  129. flush %o0 + %g2
  130. retl
  131. nop
  132. #ifdef DCACHE_ALIASING_POSSIBLE
  133. #if (PAGE_SHIFT != 13)
  134. #error only page shift of 13 is supported by dcache flush
  135. #endif
  136. #define DTAG_MASK 0x3
  137. /* This routine is Spitfire specific so the hardcoded
  138. * D-cache size and line-size are OK.
  139. */
  140. .align 64
  141. .globl __flush_dcache_page
  142. __flush_dcache_page: /* %o0=kaddr, %o1=flush_icache */
  143. sethi %uhi(PAGE_OFFSET), %g1
  144. sllx %g1, 32, %g1
  145. sub %o0, %g1, %o0 ! physical address
  146. srlx %o0, 11, %o0 ! make D-cache TAG
  147. sethi %hi(1 << 14), %o2 ! D-cache size
  148. sub %o2, (1 << 5), %o2 ! D-cache line size
  149. 1: ldxa [%o2] ASI_DCACHE_TAG, %o3 ! load D-cache TAG
  150. andcc %o3, DTAG_MASK, %g0 ! Valid?
  151. be,pn %xcc, 2f ! Nope, branch
  152. andn %o3, DTAG_MASK, %o3 ! Clear valid bits
  153. cmp %o3, %o0 ! TAG match?
  154. bne,pt %xcc, 2f ! Nope, branch
  155. nop
  156. stxa %g0, [%o2] ASI_DCACHE_TAG ! Invalidate TAG
  157. membar #Sync
  158. 2: brnz,pt %o2, 1b
  159. sub %o2, (1 << 5), %o2 ! D-cache line size
  160. /* The I-cache does not snoop local stores so we
  161. * better flush that too when necessary.
  162. */
  163. brnz,pt %o1, __flush_icache_page
  164. sllx %o0, 11, %o0
  165. retl
  166. nop
  167. #endif /* DCACHE_ALIASING_POSSIBLE */
  168. .previous
  169. /* Cheetah specific versions, patched at boot time. */
  170. __cheetah_flush_tlb_mm: /* 19 insns */
  171. rdpr %pstate, %g7
  172. andn %g7, PSTATE_IE, %g2
  173. wrpr %g2, 0x0, %pstate
  174. wrpr %g0, 1, %tl
  175. mov PRIMARY_CONTEXT, %o2
  176. mov 0x40, %g3
  177. ldxa [%o2] ASI_DMMU, %g2
  178. srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o1
  179. sllx %o1, CTX_PGSZ1_NUC_SHIFT, %o1
  180. or %o0, %o1, %o0 /* Preserve nucleus page size fields */
  181. stxa %o0, [%o2] ASI_DMMU
  182. stxa %g0, [%g3] ASI_DMMU_DEMAP
  183. stxa %g0, [%g3] ASI_IMMU_DEMAP
  184. stxa %g2, [%o2] ASI_DMMU
  185. sethi %hi(KERNBASE), %o2
  186. flush %o2
  187. wrpr %g0, 0, %tl
  188. retl
  189. wrpr %g7, 0x0, %pstate
  190. __cheetah_flush_tlb_pending: /* 27 insns */
  191. /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
  192. rdpr %pstate, %g7
  193. sllx %o1, 3, %o1
  194. andn %g7, PSTATE_IE, %g2
  195. wrpr %g2, 0x0, %pstate
  196. wrpr %g0, 1, %tl
  197. mov PRIMARY_CONTEXT, %o4
  198. ldxa [%o4] ASI_DMMU, %g2
  199. srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o3
  200. sllx %o3, CTX_PGSZ1_NUC_SHIFT, %o3
  201. or %o0, %o3, %o0 /* Preserve nucleus page size fields */
  202. stxa %o0, [%o4] ASI_DMMU
  203. 1: sub %o1, (1 << 3), %o1
  204. ldx [%o2 + %o1], %o3
  205. andcc %o3, 1, %g0
  206. be,pn %icc, 2f
  207. andn %o3, 1, %o3
  208. stxa %g0, [%o3] ASI_IMMU_DEMAP
  209. 2: stxa %g0, [%o3] ASI_DMMU_DEMAP
  210. membar #Sync
  211. brnz,pt %o1, 1b
  212. nop
  213. stxa %g2, [%o4] ASI_DMMU
  214. sethi %hi(KERNBASE), %o4
  215. flush %o4
  216. wrpr %g0, 0, %tl
  217. retl
  218. wrpr %g7, 0x0, %pstate
  219. #ifdef DCACHE_ALIASING_POSSIBLE
  220. __cheetah_flush_dcache_page: /* 11 insns */
  221. sethi %uhi(PAGE_OFFSET), %g1
  222. sllx %g1, 32, %g1
  223. sub %o0, %g1, %o0
  224. sethi %hi(PAGE_SIZE), %o4
  225. 1: subcc %o4, (1 << 5), %o4
  226. stxa %g0, [%o0 + %o4] ASI_DCACHE_INVALIDATE
  227. membar #Sync
  228. bne,pt %icc, 1b
  229. nop
  230. retl /* I-cache flush never needed on Cheetah, see callers. */
  231. nop
  232. #endif /* DCACHE_ALIASING_POSSIBLE */
  233. /* Hypervisor specific versions, patched at boot time. */
  234. __hypervisor_tlb_tl0_error:
  235. save %sp, -192, %sp
  236. mov %i0, %o0
  237. call hypervisor_tlbop_error
  238. mov %i1, %o1
  239. ret
  240. restore
  241. __hypervisor_flush_tlb_mm: /* 10 insns */
  242. mov %o0, %o2 /* ARG2: mmu context */
  243. mov 0, %o0 /* ARG0: CPU lists unimplemented */
  244. mov 0, %o1 /* ARG1: CPU lists unimplemented */
  245. mov HV_MMU_ALL, %o3 /* ARG3: flags */
  246. mov HV_FAST_MMU_DEMAP_CTX, %o5
  247. ta HV_FAST_TRAP
  248. brnz,pn %o0, __hypervisor_tlb_tl0_error
  249. mov HV_FAST_MMU_DEMAP_CTX, %o1
  250. retl
  251. nop
  252. __hypervisor_flush_tlb_pending: /* 16 insns */
  253. /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
  254. sllx %o1, 3, %g1
  255. mov %o2, %g2
  256. mov %o0, %g3
  257. 1: sub %g1, (1 << 3), %g1
  258. ldx [%g2 + %g1], %o0 /* ARG0: vaddr + IMMU-bit */
  259. mov %g3, %o1 /* ARG1: mmu context */
  260. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  261. srlx %o0, PAGE_SHIFT, %o0
  262. sllx %o0, PAGE_SHIFT, %o0
  263. ta HV_MMU_UNMAP_ADDR_TRAP
  264. brnz,pn %o0, __hypervisor_tlb_tl0_error
  265. mov HV_MMU_UNMAP_ADDR_TRAP, %o1
  266. brnz,pt %g1, 1b
  267. nop
  268. retl
  269. nop
  270. __hypervisor_flush_tlb_kernel_range: /* 16 insns */
  271. /* %o0=start, %o1=end */
  272. cmp %o0, %o1
  273. be,pn %xcc, 2f
  274. sethi %hi(PAGE_SIZE), %g3
  275. mov %o0, %g1
  276. sub %o1, %g1, %g2
  277. sub %g2, %g3, %g2
  278. 1: add %g1, %g2, %o0 /* ARG0: virtual address */
  279. mov 0, %o1 /* ARG1: mmu context */
  280. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  281. ta HV_MMU_UNMAP_ADDR_TRAP
  282. brnz,pn %o0, __hypervisor_tlb_tl0_error
  283. mov HV_MMU_UNMAP_ADDR_TRAP, %o1
  284. brnz,pt %g2, 1b
  285. sub %g2, %g3, %g2
  286. 2: retl
  287. nop
  288. #ifdef DCACHE_ALIASING_POSSIBLE
  289. /* XXX Niagara and friends have an 8K cache, so no aliasing is
  290. * XXX possible, but nothing explicit in the Hypervisor API
  291. * XXX guarantees this.
  292. */
  293. __hypervisor_flush_dcache_page: /* 2 insns */
  294. retl
  295. nop
  296. #endif
  297. tlb_patch_one:
  298. 1: lduw [%o1], %g1
  299. stw %g1, [%o0]
  300. flush %o0
  301. subcc %o2, 1, %o2
  302. add %o1, 4, %o1
  303. bne,pt %icc, 1b
  304. add %o0, 4, %o0
  305. retl
  306. nop
  307. .globl cheetah_patch_cachetlbops
  308. cheetah_patch_cachetlbops:
  309. save %sp, -128, %sp
  310. sethi %hi(__flush_tlb_mm), %o0
  311. or %o0, %lo(__flush_tlb_mm), %o0
  312. sethi %hi(__cheetah_flush_tlb_mm), %o1
  313. or %o1, %lo(__cheetah_flush_tlb_mm), %o1
  314. call tlb_patch_one
  315. mov 19, %o2
  316. sethi %hi(__flush_tlb_pending), %o0
  317. or %o0, %lo(__flush_tlb_pending), %o0
  318. sethi %hi(__cheetah_flush_tlb_pending), %o1
  319. or %o1, %lo(__cheetah_flush_tlb_pending), %o1
  320. call tlb_patch_one
  321. mov 27, %o2
  322. #ifdef DCACHE_ALIASING_POSSIBLE
  323. sethi %hi(__flush_dcache_page), %o0
  324. or %o0, %lo(__flush_dcache_page), %o0
  325. sethi %hi(__cheetah_flush_dcache_page), %o1
  326. or %o1, %lo(__cheetah_flush_dcache_page), %o1
  327. call tlb_patch_one
  328. mov 11, %o2
  329. #endif /* DCACHE_ALIASING_POSSIBLE */
  330. ret
  331. restore
  332. #ifdef CONFIG_SMP
  333. /* These are all called by the slaves of a cross call, at
  334. * trap level 1, with interrupts fully disabled.
  335. *
  336. * Register usage:
  337. * %g5 mm->context (all tlb flushes)
  338. * %g1 address arg 1 (tlb page and range flushes)
  339. * %g7 address arg 2 (tlb range flush only)
  340. *
  341. * %g6 scratch 1
  342. * %g2 scratch 2
  343. * %g3 scratch 3
  344. * %g4 scratch 4
  345. */
  346. .align 32
  347. .globl xcall_flush_tlb_mm
  348. xcall_flush_tlb_mm: /* 21 insns */
  349. mov PRIMARY_CONTEXT, %g2
  350. ldxa [%g2] ASI_DMMU, %g3
  351. srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4
  352. sllx %g4, CTX_PGSZ1_NUC_SHIFT, %g4
  353. or %g5, %g4, %g5 /* Preserve nucleus page size fields */
  354. stxa %g5, [%g2] ASI_DMMU
  355. mov 0x40, %g4
  356. stxa %g0, [%g4] ASI_DMMU_DEMAP
  357. stxa %g0, [%g4] ASI_IMMU_DEMAP
  358. stxa %g3, [%g2] ASI_DMMU
  359. retry
  360. nop
  361. nop
  362. nop
  363. nop
  364. nop
  365. nop
  366. nop
  367. nop
  368. nop
  369. nop
  370. .globl xcall_flush_tlb_pending
  371. xcall_flush_tlb_pending: /* 21 insns */
  372. /* %g5=context, %g1=nr, %g7=vaddrs[] */
  373. sllx %g1, 3, %g1
  374. mov PRIMARY_CONTEXT, %g4
  375. ldxa [%g4] ASI_DMMU, %g2
  376. srlx %g2, CTX_PGSZ1_NUC_SHIFT, %g4
  377. sllx %g4, CTX_PGSZ1_NUC_SHIFT, %g4
  378. or %g5, %g4, %g5
  379. mov PRIMARY_CONTEXT, %g4
  380. stxa %g5, [%g4] ASI_DMMU
  381. 1: sub %g1, (1 << 3), %g1
  382. ldx [%g7 + %g1], %g5
  383. andcc %g5, 0x1, %g0
  384. be,pn %icc, 2f
  385. andn %g5, 0x1, %g5
  386. stxa %g0, [%g5] ASI_IMMU_DEMAP
  387. 2: stxa %g0, [%g5] ASI_DMMU_DEMAP
  388. membar #Sync
  389. brnz,pt %g1, 1b
  390. nop
  391. stxa %g2, [%g4] ASI_DMMU
  392. retry
  393. nop
  394. .globl xcall_flush_tlb_kernel_range
  395. xcall_flush_tlb_kernel_range: /* 25 insns */
  396. sethi %hi(PAGE_SIZE - 1), %g2
  397. or %g2, %lo(PAGE_SIZE - 1), %g2
  398. andn %g1, %g2, %g1
  399. andn %g7, %g2, %g7
  400. sub %g7, %g1, %g3
  401. add %g2, 1, %g2
  402. sub %g3, %g2, %g3
  403. or %g1, 0x20, %g1 ! Nucleus
  404. 1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
  405. stxa %g0, [%g1 + %g3] ASI_IMMU_DEMAP
  406. membar #Sync
  407. brnz,pt %g3, 1b
  408. sub %g3, %g2, %g3
  409. retry
  410. nop
  411. nop
  412. nop
  413. nop
  414. nop
  415. nop
  416. nop
  417. nop
  418. nop
  419. nop
  420. nop
  421. /* This runs in a very controlled environment, so we do
  422. * not need to worry about BH races etc.
  423. */
  424. .globl xcall_sync_tick
  425. xcall_sync_tick:
  426. 661: rdpr %pstate, %g2
  427. wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
  428. .section .sun4v_2insn_patch, "ax"
  429. .word 661b
  430. nop
  431. nop
  432. .previous
  433. rdpr %pil, %g2
  434. wrpr %g0, 15, %pil
  435. sethi %hi(109f), %g7
  436. b,pt %xcc, etrap_irq
  437. 109: or %g7, %lo(109b), %g7
  438. #ifdef CONFIG_TRACE_IRQFLAGS
  439. call trace_hardirqs_off
  440. nop
  441. #endif
  442. call smp_synchronize_tick_client
  443. nop
  444. b rtrap_xcall
  445. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
  446. /* NOTE: This is SPECIAL!! We do etrap/rtrap however
  447. * we choose to deal with the "BH's run with
  448. * %pil==15" problem (described in asm/pil.h)
  449. * by just invoking rtrap directly past where
  450. * BH's are checked for.
  451. *
  452. * We do it like this because we do not want %pil==15
  453. * lockups to prevent regs being reported.
  454. */
  455. .globl xcall_report_regs
  456. xcall_report_regs:
  457. 661: rdpr %pstate, %g2
  458. wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
  459. .section .sun4v_2insn_patch, "ax"
  460. .word 661b
  461. nop
  462. nop
  463. .previous
  464. rdpr %pil, %g2
  465. wrpr %g0, 15, %pil
  466. sethi %hi(109f), %g7
  467. b,pt %xcc, etrap_irq
  468. 109: or %g7, %lo(109b), %g7
  469. #ifdef CONFIG_TRACE_IRQFLAGS
  470. call trace_hardirqs_off
  471. nop
  472. #endif
  473. call __show_regs
  474. add %sp, PTREGS_OFF, %o0
  475. /* Has to be a non-v9 branch due to the large distance. */
  476. b rtrap_xcall
  477. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
  478. #ifdef DCACHE_ALIASING_POSSIBLE
  479. .align 32
  480. .globl xcall_flush_dcache_page_cheetah
  481. xcall_flush_dcache_page_cheetah: /* %g1 == physical page address */
  482. sethi %hi(PAGE_SIZE), %g3
  483. 1: subcc %g3, (1 << 5), %g3
  484. stxa %g0, [%g1 + %g3] ASI_DCACHE_INVALIDATE
  485. membar #Sync
  486. bne,pt %icc, 1b
  487. nop
  488. retry
  489. nop
  490. #endif /* DCACHE_ALIASING_POSSIBLE */
  491. .globl xcall_flush_dcache_page_spitfire
  492. xcall_flush_dcache_page_spitfire: /* %g1 == physical page address
  493. %g7 == kernel page virtual address
  494. %g5 == (page->mapping != NULL) */
  495. #ifdef DCACHE_ALIASING_POSSIBLE
  496. srlx %g1, (13 - 2), %g1 ! Form tag comparitor
  497. sethi %hi(L1DCACHE_SIZE), %g3 ! D$ size == 16K
  498. sub %g3, (1 << 5), %g3 ! D$ linesize == 32
  499. 1: ldxa [%g3] ASI_DCACHE_TAG, %g2
  500. andcc %g2, 0x3, %g0
  501. be,pn %xcc, 2f
  502. andn %g2, 0x3, %g2
  503. cmp %g2, %g1
  504. bne,pt %xcc, 2f
  505. nop
  506. stxa %g0, [%g3] ASI_DCACHE_TAG
  507. membar #Sync
  508. 2: cmp %g3, 0
  509. bne,pt %xcc, 1b
  510. sub %g3, (1 << 5), %g3
  511. brz,pn %g5, 2f
  512. #endif /* DCACHE_ALIASING_POSSIBLE */
  513. sethi %hi(PAGE_SIZE), %g3
  514. 1: flush %g7
  515. subcc %g3, (1 << 5), %g3
  516. bne,pt %icc, 1b
  517. add %g7, (1 << 5), %g7
  518. 2: retry
  519. nop
  520. nop
  521. /* %g5: error
  522. * %g6: tlb op
  523. */
  524. __hypervisor_tlb_xcall_error:
  525. mov %g5, %g4
  526. mov %g6, %g5
  527. ba,pt %xcc, etrap
  528. rd %pc, %g7
  529. mov %l4, %o0
  530. call hypervisor_tlbop_error_xcall
  531. mov %l5, %o1
  532. ba,a,pt %xcc, rtrap
  533. .globl __hypervisor_xcall_flush_tlb_mm
  534. __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
  535. /* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */
  536. mov %o0, %g2
  537. mov %o1, %g3
  538. mov %o2, %g4
  539. mov %o3, %g1
  540. mov %o5, %g7
  541. clr %o0 /* ARG0: CPU lists unimplemented */
  542. clr %o1 /* ARG1: CPU lists unimplemented */
  543. mov %g5, %o2 /* ARG2: mmu context */
  544. mov HV_MMU_ALL, %o3 /* ARG3: flags */
  545. mov HV_FAST_MMU_DEMAP_CTX, %o5
  546. ta HV_FAST_TRAP
  547. mov HV_FAST_MMU_DEMAP_CTX, %g6
  548. brnz,pn %o0, __hypervisor_tlb_xcall_error
  549. mov %o0, %g5
  550. mov %g2, %o0
  551. mov %g3, %o1
  552. mov %g4, %o2
  553. mov %g1, %o3
  554. mov %g7, %o5
  555. membar #Sync
  556. retry
  557. .globl __hypervisor_xcall_flush_tlb_pending
  558. __hypervisor_xcall_flush_tlb_pending: /* 21 insns */
  559. /* %g5=ctx, %g1=nr, %g7=vaddrs[], %g2,%g3,%g4,g6=scratch */
  560. sllx %g1, 3, %g1
  561. mov %o0, %g2
  562. mov %o1, %g3
  563. mov %o2, %g4
  564. 1: sub %g1, (1 << 3), %g1
  565. ldx [%g7 + %g1], %o0 /* ARG0: virtual address */
  566. mov %g5, %o1 /* ARG1: mmu context */
  567. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  568. srlx %o0, PAGE_SHIFT, %o0
  569. sllx %o0, PAGE_SHIFT, %o0
  570. ta HV_MMU_UNMAP_ADDR_TRAP
  571. mov HV_MMU_UNMAP_ADDR_TRAP, %g6
  572. brnz,a,pn %o0, __hypervisor_tlb_xcall_error
  573. mov %o0, %g5
  574. brnz,pt %g1, 1b
  575. nop
  576. mov %g2, %o0
  577. mov %g3, %o1
  578. mov %g4, %o2
  579. membar #Sync
  580. retry
  581. .globl __hypervisor_xcall_flush_tlb_kernel_range
  582. __hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */
  583. /* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */
  584. sethi %hi(PAGE_SIZE - 1), %g2
  585. or %g2, %lo(PAGE_SIZE - 1), %g2
  586. andn %g1, %g2, %g1
  587. andn %g7, %g2, %g7
  588. sub %g7, %g1, %g3
  589. add %g2, 1, %g2
  590. sub %g3, %g2, %g3
  591. mov %o0, %g2
  592. mov %o1, %g4
  593. mov %o2, %g7
  594. 1: add %g1, %g3, %o0 /* ARG0: virtual address */
  595. mov 0, %o1 /* ARG1: mmu context */
  596. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  597. ta HV_MMU_UNMAP_ADDR_TRAP
  598. mov HV_MMU_UNMAP_ADDR_TRAP, %g6
  599. brnz,pn %o0, __hypervisor_tlb_xcall_error
  600. mov %o0, %g5
  601. sethi %hi(PAGE_SIZE), %o2
  602. brnz,pt %g3, 1b
  603. sub %g3, %o2, %g3
  604. mov %g2, %o0
  605. mov %g4, %o1
  606. mov %g7, %o2
  607. membar #Sync
  608. retry
  609. /* These just get rescheduled to PIL vectors. */
  610. .globl xcall_call_function
  611. xcall_call_function:
  612. wr %g0, (1 << PIL_SMP_CALL_FUNC), %set_softint
  613. retry
  614. .globl xcall_receive_signal
  615. xcall_receive_signal:
  616. wr %g0, (1 << PIL_SMP_RECEIVE_SIGNAL), %set_softint
  617. retry
  618. .globl xcall_capture
  619. xcall_capture:
  620. wr %g0, (1 << PIL_SMP_CAPTURE), %set_softint
  621. retry
  622. .globl xcall_new_mmu_context_version
  623. xcall_new_mmu_context_version:
  624. wr %g0, (1 << PIL_SMP_CTX_NEW_VERSION), %set_softint
  625. retry
  626. #endif /* CONFIG_SMP */
  627. .globl hypervisor_patch_cachetlbops
  628. hypervisor_patch_cachetlbops:
  629. save %sp, -128, %sp
  630. sethi %hi(__flush_tlb_mm), %o0
  631. or %o0, %lo(__flush_tlb_mm), %o0
  632. sethi %hi(__hypervisor_flush_tlb_mm), %o1
  633. or %o1, %lo(__hypervisor_flush_tlb_mm), %o1
  634. call tlb_patch_one
  635. mov 10, %o2
  636. sethi %hi(__flush_tlb_pending), %o0
  637. or %o0, %lo(__flush_tlb_pending), %o0
  638. sethi %hi(__hypervisor_flush_tlb_pending), %o1
  639. or %o1, %lo(__hypervisor_flush_tlb_pending), %o1
  640. call tlb_patch_one
  641. mov 16, %o2
  642. sethi %hi(__flush_tlb_kernel_range), %o0
  643. or %o0, %lo(__flush_tlb_kernel_range), %o0
  644. sethi %hi(__hypervisor_flush_tlb_kernel_range), %o1
  645. or %o1, %lo(__hypervisor_flush_tlb_kernel_range), %o1
  646. call tlb_patch_one
  647. mov 16, %o2
  648. #ifdef DCACHE_ALIASING_POSSIBLE
  649. sethi %hi(__flush_dcache_page), %o0
  650. or %o0, %lo(__flush_dcache_page), %o0
  651. sethi %hi(__hypervisor_flush_dcache_page), %o1
  652. or %o1, %lo(__hypervisor_flush_dcache_page), %o1
  653. call tlb_patch_one
  654. mov 2, %o2
  655. #endif /* DCACHE_ALIASING_POSSIBLE */
  656. #ifdef CONFIG_SMP
  657. sethi %hi(xcall_flush_tlb_mm), %o0
  658. or %o0, %lo(xcall_flush_tlb_mm), %o0
  659. sethi %hi(__hypervisor_xcall_flush_tlb_mm), %o1
  660. or %o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1
  661. call tlb_patch_one
  662. mov 21, %o2
  663. sethi %hi(xcall_flush_tlb_pending), %o0
  664. or %o0, %lo(xcall_flush_tlb_pending), %o0
  665. sethi %hi(__hypervisor_xcall_flush_tlb_pending), %o1
  666. or %o1, %lo(__hypervisor_xcall_flush_tlb_pending), %o1
  667. call tlb_patch_one
  668. mov 21, %o2
  669. sethi %hi(xcall_flush_tlb_kernel_range), %o0
  670. or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
  671. sethi %hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1
  672. or %o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1
  673. call tlb_patch_one
  674. mov 25, %o2
  675. #endif /* CONFIG_SMP */
  676. ret
  677. restore