2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
14 * This routine is a helper for migrating the home of a set of pages to
15 * a new cpu. See the documentation in homecache.c for more information.
18 #include <linux/linkage.h>
19 #include <linux/threads.h>
21 #include <asm/thread_info.h>
22 #include <asm/types.h>
23 #include <asm/asm-offsets.h>
24 #include <hv/hypervisor.h>
29 * First, some definitions that apply to all the code in the file.
32 /* Locals (caller-save) */
36 /* What we save where in the stack frame; must include all callee-saves. */
51 * r0 low word of the new context PA to install (moved to r_context_lo)
52 * r1 high word of the new context PA to install (moved to r_context_hi)
53 * r2 low word of PTE to use for context access (moved to r_access_lo)
54 * r3 high word of PTE to use for context access (moved to r_access_lo)
55 * r4 ASID to use for new context (moved to r_asid)
56 * r5 pointer to cpumask with just this cpu set in it (r_my_cpumask)
59 /* Arguments (caller-save) */
60 #define r_context_lo_in r0
61 #define r_context_hi_in r1
62 #define r_access_lo_in r2
63 #define r_access_hi_in r3
65 #define r_my_cpumask r5
67 /* Locals (callee-save); must not be more than FRAME_xxx above. */
68 #define r_context_lo r30
69 #define r_context_hi r31
70 #define r_access_lo r32
71 #define r_access_hi r33
74 STD_ENTRY(flush_and_install_context)
76 * Create a stack frame; we can't touch it once we flush the
77 * cache until we install the new page table and flush the TLB.
82 addi sp, sp, -FRAME_SIZE
84 addi r_tmp, sp, FRAME_SP
87 addi r_tmp, sp, FRAME_R30
91 addi r_tmp, sp, FRAME_R31
95 addi r_tmp, sp, FRAME_R32
99 addi r_tmp, sp, FRAME_R33
103 addi r_tmp, sp, FRAME_R34
107 /* Move some arguments to callee-save registers. */
109 move r_context_lo, r_context_lo_in
110 move r_context_hi, r_context_hi_in
113 move r_access_lo, r_access_lo_in
114 move r_access_hi, r_access_hi_in
116 move r_asid, r_asid_in
118 /* First, flush our L2 cache. */
120 move r0, zero /* cache_pa */
124 auli r2, zero, ha16(HV_FLUSH_EVICT_L2) /* cache_control */
125 move r3, r_my_cpumask /* cache_cpumask */
128 move r4, zero /* tlb_va */
129 move r5, zero /* tlb_length */
132 move r6, zero /* tlb_pgsize */
133 move r7, zero /* tlb_cpumask */
136 move r8, zero /* asids */
137 move r9, zero /* asidcount */
142 /* Now install the new page table. */
144 move r0, r_context_lo
145 move r1, r_context_hi
153 moveli r5, HV_CTX_DIRECTIO | CTX_PAGE_FLAG
155 jal hv_install_context
158 /* Finally, flush the TLB. */
160 movei r0, 0 /* preserve_global */
165 /* Restore the callee-saved registers and return. */
166 addli lr, sp, FRAME_SIZE
169 addli r_tmp, sp, FRAME_R30
173 addli r_tmp, sp, FRAME_R31
177 addli r_tmp, sp, FRAME_R32
181 addli r_tmp, sp, FRAME_R33
185 addli r_tmp, sp, FRAME_R34
189 addi sp, sp, FRAME_SIZE
192 STD_ENDPROC(flush_and_install_context)