2
* Copyright 2011 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. */
50
* r0 the new context PA to install (moved to r_context)
51
* r1 PTE to use for context access (moved to r_access)
52
* r2 ASID to use for new context (moved to r_asid)
53
* r3 pointer to cpumask with just this cpu set in it (r_my_cpumask)
56
/* Arguments (caller-save) */
57
#define r_context_in r0
58
#define r_access_in r1
60
#define r_my_cpumask r3
62
/* Locals (callee-save); must not be more than FRAME_xxx above. */
63
#define r_save_ics r30
69
* Caller-save locals and frame constants are the same as
70
* for homecache_migrate_stack_and_flush.
73
STD_ENTRY(flush_and_install_context)
75
* Create a stack frame; we can't touch it once we flush the
76
* cache until we install the new page table and flush the TLB.
81
addi sp, sp, -FRAME_SIZE
83
addi r_tmp, sp, FRAME_SP
86
addi r_tmp, sp, FRAME_R30
90
addi r_tmp, sp, FRAME_R31
94
addi r_tmp, sp, FRAME_R32
98
addi r_tmp, sp, FRAME_R33
102
/* Move some arguments to callee-save registers. */
104
move r_context, r_context_in
105
move r_access, r_access_in
107
move r_asid, r_asid_in
109
/* Disable interrupts, since we can't use our stack. */
111
mfspr r_save_ics, INTERRUPT_CRITICAL_SECTION
114
mtspr INTERRUPT_CRITICAL_SECTION, r_tmp
116
/* First, flush our L2 cache. */
118
move r0, zero /* cache_pa */
119
moveli r1, hw2_last(HV_FLUSH_EVICT_L2) /* cache_control */
122
shl16insli r1, r1, hw1(HV_FLUSH_EVICT_L2)
123
move r2, r_my_cpumask /* cache_cpumask */
126
shl16insli r1, r1, hw0(HV_FLUSH_EVICT_L2)
127
move r3, zero /* tlb_va */
130
move r4, zero /* tlb_length */
131
move r5, zero /* tlb_pgsize */
134
move r6, zero /* tlb_cpumask */
135
move r7, zero /* asids */
138
move r8, zero /* asidcount */
143
/* Now install the new page table. */
150
movei r3, HV_CTX_DIRECTIO
152
jal hv_install_context
155
/* Finally, flush the TLB. */
157
movei r0, 0 /* preserve_global */
161
1: /* Reset interrupts back how they were before. */
162
mtspr INTERRUPT_CRITICAL_SECTION, r_save_ics
164
/* Restore the callee-saved registers and return. */
165
addli lr, sp, FRAME_SIZE
168
addli r_tmp, sp, FRAME_R30
172
addli r_tmp, sp, FRAME_R31
176
addli r_tmp, sp, FRAME_R32
180
addli r_tmp, sp, FRAME_R33
184
addi sp, sp, FRAME_SIZE
187
STD_ENDPROC(flush_and_install_context)