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 <linux/config.h>
  7. #include <asm/asi.h>
  8. #include <asm/pgtable.h>
  9. #include <asm/page.h>
  10. #include <asm/spitfire.h>
  11. #include <asm/mmu_context.h>
  12. #include <asm/mmu.h>
  13. #include <asm/pil.h>
  14. #include <asm/head.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/hypervisor.h>
  18. /* Basically, most of the Spitfire vs. Cheetah madness
  19. * has to do with the fact that Cheetah does not support
  20. * IMMU flushes out of the secondary context. Someone needs
  21. * to throw a south lake birthday party for the folks
  22. * in Microelectronics who refused to fix this shit.
  23. */
  24. /* This file is meant to be read efficiently by the CPU, not humans.
  25. * Staraj sie tego nikomu nie pierdolnac...
  26. */
  27. .text
  28. .align 32
  29. .globl __flush_tlb_mm
  30. __flush_tlb_mm: /* 18 insns */
  31. /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */
  32. ldxa [%o1] ASI_DMMU, %g2
  33. cmp %g2, %o0
  34. bne,pn %icc, __spitfire_flush_tlb_mm_slow
  35. mov 0x50, %g3
  36. stxa %g0, [%g3] ASI_DMMU_DEMAP
  37. stxa %g0, [%g3] ASI_IMMU_DEMAP
  38. sethi %hi(KERNBASE), %g3
  39. flush %g3
  40. retl
  41. nop
  42. nop
  43. nop
  44. nop
  45. nop
  46. nop
  47. nop
  48. nop
  49. nop
  50. nop
  51. .align 32
  52. .globl __flush_tlb_pending
  53. __flush_tlb_pending: /* 26 insns */
  54. /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
  55. rdpr %pstate, %g7
  56. sllx %o1, 3, %o1
  57. andn %g7, PSTATE_IE, %g2
  58. wrpr %g2, %pstate
  59. mov SECONDARY_CONTEXT, %o4
  60. ldxa [%o4] ASI_DMMU, %g2
  61. stxa %o0, [%o4] ASI_DMMU
  62. 1: sub %o1, (1 << 3), %o1
  63. ldx [%o2 + %o1], %o3
  64. andcc %o3, 1, %g0
  65. andn %o3, 1, %o3
  66. be,pn %icc, 2f
  67. or %o3, 0x10, %o3
  68. stxa %g0, [%o3] ASI_IMMU_DEMAP
  69. 2: stxa %g0, [%o3] ASI_DMMU_DEMAP
  70. membar #Sync
  71. brnz,pt %o1, 1b
  72. nop
  73. stxa %g2, [%o4] ASI_DMMU
  74. sethi %hi(KERNBASE), %o4
  75. flush %o4
  76. retl
  77. wrpr %g7, 0x0, %pstate
  78. nop
  79. nop
  80. nop
  81. nop
  82. .align 32
  83. .globl __flush_tlb_kernel_range
  84. __flush_tlb_kernel_range: /* 16 insns */
  85. /* %o0=start, %o1=end */
  86. cmp %o0, %o1
  87. be,pn %xcc, 2f
  88. sethi %hi(PAGE_SIZE), %o4
  89. sub %o1, %o0, %o3
  90. sub %o3, %o4, %o3
  91. or %o0, 0x20, %o0 ! Nucleus
  92. 1: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP
  93. stxa %g0, [%o0 + %o3] ASI_IMMU_DEMAP
  94. membar #Sync
  95. brnz,pt %o3, 1b
  96. sub %o3, %o4, %o3
  97. 2: sethi %hi(KERNBASE), %o3
  98. flush %o3
  99. retl
  100. nop
  101. nop
  102. __spitfire_flush_tlb_mm_slow:
  103. rdpr %pstate, %g1
  104. wrpr %g1, PSTATE_IE, %pstate
  105. stxa %o0, [%o1] ASI_DMMU
  106. stxa %g0, [%g3] ASI_DMMU_DEMAP
  107. stxa %g0, [%g3] ASI_IMMU_DEMAP
  108. flush %g6
  109. stxa %g2, [%o1] ASI_DMMU
  110. sethi %hi(KERNBASE), %o1
  111. flush %o1
  112. retl
  113. wrpr %g1, 0, %pstate
  114. /*
  115. * The following code flushes one page_size worth.
  116. */
  117. #if (PAGE_SHIFT == 13)
  118. #define ITAG_MASK 0xfe
  119. #elif (PAGE_SHIFT == 16)
  120. #define ITAG_MASK 0x7fe
  121. #else
  122. #error unsupported PAGE_SIZE
  123. #endif
  124. .section .kprobes.text, "ax"
  125. .align 32
  126. .globl __flush_icache_page
  127. __flush_icache_page: /* %o0 = phys_page */
  128. membar #StoreStore
  129. srlx %o0, PAGE_SHIFT, %o0
  130. sethi %uhi(PAGE_OFFSET), %g1
  131. sllx %o0, PAGE_SHIFT, %o0
  132. sethi %hi(PAGE_SIZE), %g2
  133. sllx %g1, 32, %g1
  134. add %o0, %g1, %o0
  135. 1: subcc %g2, 32, %g2
  136. bne,pt %icc, 1b
  137. flush %o0 + %g2
  138. retl
  139. nop
  140. #ifdef DCACHE_ALIASING_POSSIBLE
  141. #if (PAGE_SHIFT != 13)
  142. #error only page shift of 13 is supported by dcache flush
  143. #endif
  144. #define DTAG_MASK 0x3
  145. /* This routine is Spitfire specific so the hardcoded
  146. * D-cache size and line-size are OK.
  147. */
  148. .align 64
  149. .globl __flush_dcache_page
  150. __flush_dcache_page: /* %o0=kaddr, %o1=flush_icache */
  151. sethi %uhi(PAGE_OFFSET), %g1
  152. sllx %g1, 32, %g1
  153. sub %o0, %g1, %o0 ! physical address
  154. srlx %o0, 11, %o0 ! make D-cache TAG
  155. sethi %hi(1 << 14), %o2 ! D-cache size
  156. sub %o2, (1 << 5), %o2 ! D-cache line size
  157. 1: ldxa [%o2] ASI_DCACHE_TAG, %o3 ! load D-cache TAG
  158. andcc %o3, DTAG_MASK, %g0 ! Valid?
  159. be,pn %xcc, 2f ! Nope, branch
  160. andn %o3, DTAG_MASK, %o3 ! Clear valid bits
  161. cmp %o3, %o0 ! TAG match?
  162. bne,pt %xcc, 2f ! Nope, branch
  163. nop
  164. stxa %g0, [%o2] ASI_DCACHE_TAG ! Invalidate TAG
  165. membar #Sync
  166. 2: brnz,pt %o2, 1b
  167. sub %o2, (1 << 5), %o2 ! D-cache line size
  168. /* The I-cache does not snoop local stores so we
  169. * better flush that too when necessary.
  170. */
  171. brnz,pt %o1, __flush_icache_page
  172. sllx %o0, 11, %o0
  173. retl
  174. nop
  175. #endif /* DCACHE_ALIASING_POSSIBLE */
  176. .previous
  177. /* Cheetah specific versions, patched at boot time. */
  178. __cheetah_flush_tlb_mm: /* 19 insns */
  179. rdpr %pstate, %g7
  180. andn %g7, PSTATE_IE, %g2
  181. wrpr %g2, 0x0, %pstate
  182. wrpr %g0, 1, %tl
  183. mov PRIMARY_CONTEXT, %o2
  184. mov 0x40, %g3
  185. ldxa [%o2] ASI_DMMU, %g2
  186. srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o1
  187. sllx %o1, CTX_PGSZ1_NUC_SHIFT, %o1
  188. or %o0, %o1, %o0 /* Preserve nucleus page size fields */
  189. stxa %o0, [%o2] ASI_DMMU
  190. stxa %g0, [%g3] ASI_DMMU_DEMAP
  191. stxa %g0, [%g3] ASI_IMMU_DEMAP
  192. stxa %g2, [%o2] ASI_DMMU
  193. sethi %hi(KERNBASE), %o2
  194. flush %o2
  195. wrpr %g0, 0, %tl
  196. retl
  197. wrpr %g7, 0x0, %pstate
  198. __cheetah_flush_tlb_pending: /* 27 insns */
  199. /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
  200. rdpr %pstate, %g7
  201. sllx %o1, 3, %o1
  202. andn %g7, PSTATE_IE, %g2
  203. wrpr %g2, 0x0, %pstate
  204. wrpr %g0, 1, %tl
  205. mov PRIMARY_CONTEXT, %o4
  206. ldxa [%o4] ASI_DMMU, %g2
  207. srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o3
  208. sllx %o3, CTX_PGSZ1_NUC_SHIFT, %o3
  209. or %o0, %o3, %o0 /* Preserve nucleus page size fields */
  210. stxa %o0, [%o4] ASI_DMMU
  211. 1: sub %o1, (1 << 3), %o1
  212. ldx [%o2 + %o1], %o3
  213. andcc %o3, 1, %g0
  214. be,pn %icc, 2f
  215. andn %o3, 1, %o3
  216. stxa %g0, [%o3] ASI_IMMU_DEMAP
  217. 2: stxa %g0, [%o3] ASI_DMMU_DEMAP
  218. membar #Sync
  219. brnz,pt %o1, 1b
  220. nop
  221. stxa %g2, [%o4] ASI_DMMU
  222. sethi %hi(KERNBASE), %o4
  223. flush %o4
  224. wrpr %g0, 0, %tl
  225. retl
  226. wrpr %g7, 0x0, %pstate
  227. #ifdef DCACHE_ALIASING_POSSIBLE
  228. __cheetah_flush_dcache_page: /* 11 insns */
  229. sethi %uhi(PAGE_OFFSET), %g1
  230. sllx %g1, 32, %g1
  231. sub %o0, %g1, %o0
  232. sethi %hi(PAGE_SIZE), %o4
  233. 1: subcc %o4, (1 << 5), %o4
  234. stxa %g0, [%o0 + %o4] ASI_DCACHE_INVALIDATE
  235. membar #Sync
  236. bne,pt %icc, 1b
  237. nop
  238. retl /* I-cache flush never needed on Cheetah, see callers. */
  239. nop
  240. #endif /* DCACHE_ALIASING_POSSIBLE */
  241. /* Hypervisor specific versions, patched at boot time. */
  242. __hypervisor_tlb_tl0_error:
  243. save %sp, -192, %sp
  244. mov %i0, %o0
  245. call hypervisor_tlbop_error
  246. mov %i1, %o1
  247. ret
  248. restore
  249. __hypervisor_flush_tlb_mm: /* 10 insns */
  250. mov %o0, %o2 /* ARG2: mmu context */
  251. mov 0, %o0 /* ARG0: CPU lists unimplemented */
  252. mov 0, %o1 /* ARG1: CPU lists unimplemented */
  253. mov HV_MMU_ALL, %o3 /* ARG3: flags */
  254. mov HV_FAST_MMU_DEMAP_CTX, %o5
  255. ta HV_FAST_TRAP
  256. brnz,pn %o0, __hypervisor_tlb_tl0_error
  257. mov HV_FAST_MMU_DEMAP_CTX, %o1
  258. retl
  259. nop
  260. __hypervisor_flush_tlb_pending: /* 16 insns */
  261. /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
  262. sllx %o1, 3, %g1
  263. mov %o2, %g2
  264. mov %o0, %g3
  265. 1: sub %g1, (1 << 3), %g1
  266. ldx [%g2 + %g1], %o0 /* ARG0: vaddr + IMMU-bit */
  267. mov %g3, %o1 /* ARG1: mmu context */
  268. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  269. srlx %o0, PAGE_SHIFT, %o0
  270. sllx %o0, PAGE_SHIFT, %o0
  271. ta HV_MMU_UNMAP_ADDR_TRAP
  272. brnz,pn %o0, __hypervisor_tlb_tl0_error
  273. mov HV_MMU_UNMAP_ADDR_TRAP, %o1
  274. brnz,pt %g1, 1b
  275. nop
  276. retl
  277. nop
  278. __hypervisor_flush_tlb_kernel_range: /* 16 insns */
  279. /* %o0=start, %o1=end */
  280. cmp %o0, %o1
  281. be,pn %xcc, 2f
  282. sethi %hi(PAGE_SIZE), %g3
  283. mov %o0, %g1
  284. sub %o1, %g1, %g2
  285. sub %g2, %g3, %g2
  286. 1: add %g1, %g2, %o0 /* ARG0: virtual address */
  287. mov 0, %o1 /* ARG1: mmu context */
  288. mov HV_MMU_ALL, %o2 /* ARG2: flags */
  289. ta HV_MMU_UNMAP_ADDR_TRAP
  290. brnz,pn %o0, __hypervisor_tlb_tl0_error
  291. mov HV_MMU_UNMAP_ADDR_TRAP, %o1
  292. brnz,pt %g2, 1b
  293. sub %g2, %g3, %g2
  294. 2: retl
  295. nop
  296. #ifdef DCACHE_ALIASING_POSSIBLE
  297. /* XXX Niagara and friends have an 8K cache, so no aliasing is
  298. * XXX possible, but nothing explicit in the Hypervisor API
  299. * XXX guarantees this.
  300. */
  301. __hypervisor_flush_dcache_page: /* 2 insns */
  302. retl
  303. nop
  304. #endif
  305. tlb_patch_one:
  306. 1: lduw [%o1], %g1
  307. stw %g1, [%o0]
  308. flush %o0
  309. subcc %o2, 1, %o2
  310. add %o1, 4, %o1
  311. bne,pt %icc, 1b
  312. add %o0, 4, %o0
  313. retl
  314. nop
  315. .globl cheetah_patch_cachetlbops
  316. cheetah_patch_cachetlbops:
  317. save %sp, -128, %sp
  318. sethi %hi(__flush_tlb_mm), %o0
  319. or %o0, %lo(__flush_tlb_mm), %o0
  320. sethi %hi(__cheetah_flush_tlb_mm), %o1
  321. or %o1, %lo(__cheetah_flush_tlb_mm), %o1
  322. call tlb_patch_one
  323. mov 19, %o2
  324. sethi %hi(__flush_tlb_pending), %o0
  325. or %o0, %lo(__flush_tlb_pending), %o0
  326. sethi %hi(__cheetah_flush_tlb_pending), %o1
  327. or %o1, %lo(__cheetah_flush_tlb_pending), %o1
  328. call tlb_patch_one
  329. mov 27, %o2
  330. #ifdef DCACHE_ALIASING_POSSIBLE
  331. sethi %hi(__flush_dcache_page), %o0
  332. or %o0, %lo(__flush_dcache_page), %o0
  333. sethi %hi(__cheetah_flush_dcache_page), %o1
  334. or %o1, %lo(__cheetah_flush_dcache_page), %o1
  335. call tlb_patch_one
  336. mov 11, %o2
  337. #endif /* DCACHE_ALIASING_POSSIBLE */
  338. ret
  339. restore
  340. #ifdef CONFIG_SMP
  341. /* These are all called by the slaves of a cross call, at
  342. * trap level 1, with interrupts fully disabled.
  343. *
  344. * Register usage:
  345. * %g5 mm->context (all tlb flushes)
  346. * %g1 address arg 1 (tlb page and range flushes)
  347. * %g7 address arg 2 (tlb range flush only)
  348. *
  349. * %g6 scratch 1
  350. * %g2 scratch 2
  351. * %g3 scratch 3
  352. * %g4 scratch 4
  353. */
  354. .align 32
  355. .globl xcall_flush_tlb_mm
  356. xcall_flush_tlb_mm: /* 21 insns */
  357. mov PRIMARY_CONTEXT, %g2
  358. ldxa [%g2] ASI_DMMU, %g3
  359. srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4
  360. sllx %g4, CTX_PGSZ1_NUC_SHIFT, %g4
  361. or %g5, %g4, %g5 /* Preserve nucleus page size fields */
  362. stxa %g5, [%g2] ASI_DMMU
  363. mov 0x40, %g4
  364. stxa %g0, [%g4] ASI_DMMU_DEMAP
  365. stxa %g0, [%g4] ASI_IMMU_DEMAP
  366. stxa %g3, [%g2] ASI_DMMU
  367. retry
  368. nop
  369. nop
  370. nop
  371. nop
  372. nop
  373. nop
  374. nop
  375. nop
  376. nop
  377. nop
  378. .globl xcall_flush_tlb_pending
  379. xcall_flush_tlb_pending: /* 21 insns */
  380. /* %g5=context, %g1=nr, %g7=vaddrs[] */
  381. sllx %g1, 3, %g1
  382. mov PRIMARY_CONTEXT, %g4
  383. ldxa [%g4] ASI_DMMU, %g2
  384. srlx %g2, CTX_PGSZ1_NUC_SHIFT, %g4
  385. sllx %g4, CTX_PGSZ1_NUC_SHIFT, %g4
  386. or %g5, %g4, %g5
  387. mov PRIMARY_CONTEXT, %g4
  388. stxa %g5, [%g4] ASI_DMMU
  389. 1: sub %g1, (1 << 3), %g1
  390. ldx [%g7 + %g1], %g5
  391. andcc %g5, 0x1, %g0
  392. be,pn %icc, 2f
  393. andn %g5, 0x1, %g5
  394. stxa %g0, [%g5] ASI_IMMU_DEMAP
  395. 2: stxa %g0, [%g5] ASI_DMMU_DEMAP
  396. membar #Sync
  397. brnz,pt %g1, 1b
  398. nop
  399. stxa %g2, [%g4] ASI_DMMU
  400. retry
  401. nop
  402. .globl xcall_flush_tlb_kernel_range
  403. xcall_flush_tlb_kernel_range: /* 25 insns */
  404. sethi %hi(PAGE_SIZE - 1), %g2
  405. or %g2, %lo(PAGE_SIZE - 1), %g2
  406. andn %g1, %g2, %g1
  407. andn %g7, %g2, %g7
  408. sub %g7, %g1, %g3
  409. add %g2, 1, %g2
  410. sub %g3, %g2, %g3
  411. or %g1, 0x20, %g1 ! Nucleus
  412. 1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
  413. stxa %g0, [%g1 + %g3] ASI_IMMU_DEMAP
  414. membar #Sync
  415. brnz,pt %g3, 1b
  416. sub %g3, %g2, %g3
  417. retry
  418. nop
  419. nop
  420. nop
  421. nop
  422. nop
  423. nop
  424. nop
  425. nop
  426. nop
  427. nop
  428. nop
  429. /* This runs in a very controlled environment, so we do
  430. * not need to worry about BH races etc.
  431. */
  432. .globl xcall_sync_tick
  433. xcall_sync_tick:
  434. 661: rdpr %pstate, %g2
  435. wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
  436. .section .sun4v_2insn_patch, "ax"
  437. .word 661b
  438. nop
  439. nop
  440. .previous
  441. rdpr %pil, %g2
  442. wrpr %g0, 15, %pil
  443. sethi %hi(109f), %g7
  444. b,pt %xcc, etrap_irq
  445. 109: or %g7, %lo(109b), %g7
  446. call smp_synchronize_tick_client
  447. nop
  448. clr %l6
  449. b rtrap_xcall
  450. ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
  451. /* NOTE: This is SPECIAL!! We do etrap/rtrap however
  452. * we choose to deal with the "BH's run with
  453. * %pil==15" problem (described in asm/pil.h)
  454. * by just invoking rtrap directly past where
  455. * BH's are checked for.
  456. *
  457. * We do it like this because we do not want %pil==15
  458. * lockups to prevent regs being reported.
  459. */
  460. .globl xcall_report_regs
  461. xcall_report_regs:
  462. 661: rdpr %pstate, %g2
  463. wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
  464. .section .sun4v_2insn_patch, "ax"
  465. .word 661b
  466. nop
  467. nop
  468. .previous
  469. rdpr %pil, %g2
  470. wrpr %g0, 15, %pil
  471. sethi %hi(109f), %g7
  472. b,pt %xcc, etrap_irq
  473. 109: or %g7, %lo(109b), %g7
  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