ultra.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  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. clr %l6
  445. b rtrap_xcall
  446. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
  447. /* NOTE: This is SPECIAL!! We do etrap/rtrap however
  448. * we choose to deal with the "BH's run with
  449. * %pil==15" problem (described in asm/pil.h)
  450. * by just invoking rtrap directly past where
  451. * BH's are checked for.
  452. *
  453. * We do it like this because we do not want %pil==15
  454. * lockups to prevent regs being reported.
  455. */
  456. .globl xcall_report_regs
  457. xcall_report_regs:
  458. 661: rdpr %pstate, %g2
  459. wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
  460. .section .sun4v_2insn_patch, "ax"
  461. .word 661b
  462. nop
  463. nop
  464. .previous
  465. rdpr %pil, %g2
  466. wrpr %g0, 15, %pil
  467. sethi %hi(109f), %g7
  468. b,pt %xcc, etrap_irq
  469. 109: or %g7, %lo(109b), %g7
  470. #ifdef CONFIG_TRACE_IRQFLAGS
  471. call trace_hardirqs_off
  472. nop
  473. #endif
  474. call __show_regs
  475. add %sp, PTREGS_OFF, %o0
  476. clr %l6
  477. /* Has to be a non-v9 branch due to the large distance. */
  478. b rtrap_xcall
  479. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
  480. #ifdef DCACHE_ALIASING_POSSIBLE
  481. .align 32
  482. .globl xcall_flush_dcache_page_cheetah
  483. xcall_flush_dcache_page_cheetah: /* %g1 == physical page address */
  484. sethi %hi(PAGE_SIZE), %g3
  485. 1: subcc %g3, (1 << 5), %g3
  486. stxa %g0, [%g1 + %g3] ASI_DCACHE_INVALIDATE
  487. membar #Sync
  488. bne,pt %icc, 1b
  489. nop
  490. retry
  491. nop
  492. #endif /* DCACHE_ALIASING_POSSIBLE */
  493. .globl xcall_flush_dcache_page_spitfire
  494. xcall_flush_dcache_page_spitfire: /* %g1 == physical page address
  495. %g7 == kernel page virtual address
  496. %g5 == (page->mapping != NULL) */
  497. #ifdef DCACHE_ALIASING_POSSIBLE
  498. srlx %g1, (13 - 2), %g1 ! Form tag comparitor
  499. sethi %hi(L1DCACHE_SIZE), %g3 ! D$ size == 16K
  500. sub %g3, (1 << 5), %g3 ! D$ linesize == 32
  501. 1: ldxa [%g3] ASI_DCACHE_TAG, %g2
  502. andcc %g2, 0x3, %g0
  503. be,pn %xcc, 2f
  504. andn %g2, 0x3, %g2
  505. cmp %g2, %g1
  506. bne,pt %xcc, 2f
  507. nop
  508. stxa %g0, [%g3] ASI_DCACHE_TAG
  509. membar #Sync
  510. 2: cmp %g3, 0
  511. bne,pt %xcc, 1b
  512. sub %g3, (1 << 5), %g3
  513. brz,pn %g5, 2f
  514. #endif /* DCACHE_ALIASING_POSSIBLE */
  515. sethi %hi(PAGE_SIZE), %g3
  516. 1: flush %g7
  517. subcc %g3, (1 << 5), %g3
  518. bne,pt %icc, 1b
  519. add %g7, (1 << 5), %g7
  520. 2: retry
  521. nop
  522. nop
  523. /* %g5: error
  524. * %g6: tlb op
  525. */
  526. __hypervisor_tlb_xcall_error:
  527. mov %g5, %g4
  528. mov %g6, %g5
  529. ba,pt %xcc, etrap
  530. rd %pc, %g7
  531. mov %l4, %o0
  532. call hypervisor_tlbop_error_xcall
  533. mov %l5, %o1
  534. ba,a,pt %xcc, rtrap_clr_l6
  535. .globl __hypervisor_xcall_flush_tlb_mm
  536. __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
  537. /* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */
  538. mov %o0, %g2
  539. mov %o1, %g3
  540. mov %o2, %g4
  541. mov %o3, %g1
  542. mov %o5, %g7
  543. clr %o0 /* ARG0: CPU lists unimplemented */
  544. clr %o1 /* ARG1: CPU lists unimplemented */
  545. mov %g5, %o2 /* ARG2: mmu context */
  546. mov HV_MMU_ALL, %o3 /* ARG3: flags */
  547. mov HV_FAST_MMU_DEMAP_CTX, %o5
  548. ta HV_FAST_TRAP
  549. mov HV_FAST_MMU_DEMAP_CTX, %g6
  550. brnz,pn %o0, __hypervisor_tlb_xcall_error
  551. mov %o0, %g5
  552. mov %g2, %o0
  553. mov %g3, %o1
  554. mov %g4, %o2
  555. mov %g1, %o3
  556. mov %g7, %o5
  557. membar #Sync
  558. retry
  559. .globl __hypervisor_xcall_flush_tlb_pending
  560. __hypervisor_xcall_flush_tlb_pending: /* 21 insns */
  561. /* %g5=ctx, %g1=nr, %g7=vaddrs[], %g2,%g3,%g4,g6=scratch */
  562. sllx %g1, 3, %g1
  563. mov %o0, %g2
  564. mov %o1, %g3
  565. mov %o2, %g4
  566. 1: sub %g1, (1 << 3), %g1
  567. ldx [%g7 + %g1], %o0 /* ARG0: virtual address */
  568. mov %g5, %o1 /* ARG1: mmu context */
  569. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  570. srlx %o0, PAGE_SHIFT, %o0
  571. sllx %o0, PAGE_SHIFT, %o0
  572. ta HV_MMU_UNMAP_ADDR_TRAP
  573. mov HV_MMU_UNMAP_ADDR_TRAP, %g6
  574. brnz,a,pn %o0, __hypervisor_tlb_xcall_error
  575. mov %o0, %g5
  576. brnz,pt %g1, 1b
  577. nop
  578. mov %g2, %o0
  579. mov %g3, %o1
  580. mov %g4, %o2
  581. membar #Sync
  582. retry
  583. .globl __hypervisor_xcall_flush_tlb_kernel_range
  584. __hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */
  585. /* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */
  586. sethi %hi(PAGE_SIZE - 1), %g2
  587. or %g2, %lo(PAGE_SIZE - 1), %g2
  588. andn %g1, %g2, %g1
  589. andn %g7, %g2, %g7
  590. sub %g7, %g1, %g3
  591. add %g2, 1, %g2
  592. sub %g3, %g2, %g3
  593. mov %o0, %g2
  594. mov %o1, %g4
  595. mov %o2, %g7
  596. 1: add %g1, %g3, %o0 /* ARG0: virtual address */
  597. mov 0, %o1 /* ARG1: mmu context */
  598. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  599. ta HV_MMU_UNMAP_ADDR_TRAP
  600. mov HV_MMU_UNMAP_ADDR_TRAP, %g6
  601. brnz,pn %o0, __hypervisor_tlb_xcall_error
  602. mov %o0, %g5
  603. sethi %hi(PAGE_SIZE), %o2
  604. brnz,pt %g3, 1b
  605. sub %g3, %o2, %g3
  606. mov %g2, %o0
  607. mov %g4, %o1
  608. mov %g7, %o2
  609. membar #Sync
  610. retry
  611. /* These just get rescheduled to PIL vectors. */
  612. .globl xcall_call_function
  613. xcall_call_function:
  614. wr %g0, (1 << PIL_SMP_CALL_FUNC), %set_softint
  615. retry
  616. .globl xcall_receive_signal
  617. xcall_receive_signal:
  618. wr %g0, (1 << PIL_SMP_RECEIVE_SIGNAL), %set_softint
  619. retry
  620. .globl xcall_capture
  621. xcall_capture:
  622. wr %g0, (1 << PIL_SMP_CAPTURE), %set_softint
  623. retry
  624. .globl xcall_new_mmu_context_version
  625. xcall_new_mmu_context_version:
  626. wr %g0, (1 << PIL_SMP_CTX_NEW_VERSION), %set_softint
  627. retry
  628. #endif /* CONFIG_SMP */
  629. .globl hypervisor_patch_cachetlbops
  630. hypervisor_patch_cachetlbops:
  631. save %sp, -128, %sp
  632. sethi %hi(__flush_tlb_mm), %o0
  633. or %o0, %lo(__flush_tlb_mm), %o0
  634. sethi %hi(__hypervisor_flush_tlb_mm), %o1
  635. or %o1, %lo(__hypervisor_flush_tlb_mm), %o1
  636. call tlb_patch_one
  637. mov 10, %o2
  638. sethi %hi(__flush_tlb_pending), %o0
  639. or %o0, %lo(__flush_tlb_pending), %o0
  640. sethi %hi(__hypervisor_flush_tlb_pending), %o1
  641. or %o1, %lo(__hypervisor_flush_tlb_pending), %o1
  642. call tlb_patch_one
  643. mov 16, %o2
  644. sethi %hi(__flush_tlb_kernel_range), %o0
  645. or %o0, %lo(__flush_tlb_kernel_range), %o0
  646. sethi %hi(__hypervisor_flush_tlb_kernel_range), %o1
  647. or %o1, %lo(__hypervisor_flush_tlb_kernel_range), %o1
  648. call tlb_patch_one
  649. mov 16, %o2
  650. #ifdef DCACHE_ALIASING_POSSIBLE
  651. sethi %hi(__flush_dcache_page), %o0
  652. or %o0, %lo(__flush_dcache_page), %o0
  653. sethi %hi(__hypervisor_flush_dcache_page), %o1
  654. or %o1, %lo(__hypervisor_flush_dcache_page), %o1
  655. call tlb_patch_one
  656. mov 2, %o2
  657. #endif /* DCACHE_ALIASING_POSSIBLE */
  658. #ifdef CONFIG_SMP
  659. sethi %hi(xcall_flush_tlb_mm), %o0
  660. or %o0, %lo(xcall_flush_tlb_mm), %o0
  661. sethi %hi(__hypervisor_xcall_flush_tlb_mm), %o1
  662. or %o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1
  663. call tlb_patch_one
  664. mov 21, %o2
  665. sethi %hi(xcall_flush_tlb_pending), %o0
  666. or %o0, %lo(xcall_flush_tlb_pending), %o0
  667. sethi %hi(__hypervisor_xcall_flush_tlb_pending), %o1
  668. or %o1, %lo(__hypervisor_xcall_flush_tlb_pending), %o1
  669. call tlb_patch_one
  670. mov 21, %o2
  671. sethi %hi(xcall_flush_tlb_kernel_range), %o0
  672. or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
  673. sethi %hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1
  674. or %o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1
  675. call tlb_patch_one
  676. mov 25, %o2
  677. #endif /* CONFIG_SMP */
  678. ret
  679. restore