diff options
Diffstat (limited to 'arch/mips/include')
-rw-r--r-- | arch/mips/include/asm/kvm_host.h | 417 |
1 files changed, 211 insertions, 206 deletions
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index a995fce87791..060aaa6348d7 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h | |||
@@ -30,16 +30,16 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | /* Special address that contains the comm page, used for reducing # of traps */ | 32 | /* Special address that contains the comm page, used for reducing # of traps */ |
33 | #define KVM_GUEST_COMMPAGE_ADDR 0x0 | 33 | #define KVM_GUEST_COMMPAGE_ADDR 0x0 |
34 | 34 | ||
35 | #define KVM_GUEST_KERNEL_MODE(vcpu) ((kvm_read_c0_guest_status(vcpu->arch.cop0) & (ST0_EXL | ST0_ERL)) || \ | 35 | #define KVM_GUEST_KERNEL_MODE(vcpu) ((kvm_read_c0_guest_status(vcpu->arch.cop0) & (ST0_EXL | ST0_ERL)) || \ |
36 | ((kvm_read_c0_guest_status(vcpu->arch.cop0) & KSU_USER) == 0)) | 36 | ((kvm_read_c0_guest_status(vcpu->arch.cop0) & KSU_USER) == 0)) |
37 | 37 | ||
38 | #define KVM_GUEST_KUSEG 0x00000000UL | 38 | #define KVM_GUEST_KUSEG 0x00000000UL |
39 | #define KVM_GUEST_KSEG0 0x40000000UL | 39 | #define KVM_GUEST_KSEG0 0x40000000UL |
40 | #define KVM_GUEST_KSEG23 0x60000000UL | 40 | #define KVM_GUEST_KSEG23 0x60000000UL |
41 | #define KVM_GUEST_KSEGX(a) ((_ACAST32_(a)) & 0x60000000) | 41 | #define KVM_GUEST_KSEGX(a) ((_ACAST32_(a)) & 0x60000000) |
42 | #define KVM_GUEST_CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff) | 42 | #define KVM_GUEST_CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff) |
43 | 43 | ||
44 | #define KVM_GUEST_CKSEG0ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG0) | 44 | #define KVM_GUEST_CKSEG0ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG0) |
45 | #define KVM_GUEST_CKSEG1ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG1) | 45 | #define KVM_GUEST_CKSEG1ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG1) |
@@ -52,17 +52,17 @@ | |||
52 | #define KVM_GUEST_KSEG1ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG1) | 52 | #define KVM_GUEST_KSEG1ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG1) |
53 | #define KVM_GUEST_KSEG23ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG23) | 53 | #define KVM_GUEST_KSEG23ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG23) |
54 | 54 | ||
55 | #define KVM_INVALID_PAGE 0xdeadbeef | 55 | #define KVM_INVALID_PAGE 0xdeadbeef |
56 | #define KVM_INVALID_INST 0xdeadbeef | 56 | #define KVM_INVALID_INST 0xdeadbeef |
57 | #define KVM_INVALID_ADDR 0xdeadbeef | 57 | #define KVM_INVALID_ADDR 0xdeadbeef |
58 | 58 | ||
59 | #define KVM_MALTA_GUEST_RTC_ADDR 0xb8000070UL | 59 | #define KVM_MALTA_GUEST_RTC_ADDR 0xb8000070UL |
60 | 60 | ||
61 | #define GUEST_TICKS_PER_JIFFY (40000000/HZ) | 61 | #define GUEST_TICKS_PER_JIFFY (40000000/HZ) |
62 | #define MS_TO_NS(x) (x * 1E6L) | 62 | #define MS_TO_NS(x) (x * 1E6L) |
63 | 63 | ||
64 | #define CAUSEB_DC 27 | 64 | #define CAUSEB_DC 27 |
65 | #define CAUSEF_DC (_ULCAST_(1) << 27) | 65 | #define CAUSEF_DC (_ULCAST_(1) << 27) |
66 | 66 | ||
67 | struct kvm; | 67 | struct kvm; |
68 | struct kvm_run; | 68 | struct kvm_run; |
@@ -126,8 +126,8 @@ struct kvm_arch { | |||
126 | int commpage_tlb; | 126 | int commpage_tlb; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | #define N_MIPS_COPROC_REGS 32 | 129 | #define N_MIPS_COPROC_REGS 32 |
130 | #define N_MIPS_COPROC_SEL 8 | 130 | #define N_MIPS_COPROC_SEL 8 |
131 | 131 | ||
132 | struct mips_coproc { | 132 | struct mips_coproc { |
133 | unsigned long reg[N_MIPS_COPROC_REGS][N_MIPS_COPROC_SEL]; | 133 | unsigned long reg[N_MIPS_COPROC_REGS][N_MIPS_COPROC_SEL]; |
@@ -139,124 +139,124 @@ struct mips_coproc { | |||
139 | /* | 139 | /* |
140 | * Coprocessor 0 register names | 140 | * Coprocessor 0 register names |
141 | */ | 141 | */ |
142 | #define MIPS_CP0_TLB_INDEX 0 | 142 | #define MIPS_CP0_TLB_INDEX 0 |
143 | #define MIPS_CP0_TLB_RANDOM 1 | 143 | #define MIPS_CP0_TLB_RANDOM 1 |
144 | #define MIPS_CP0_TLB_LOW 2 | 144 | #define MIPS_CP0_TLB_LOW 2 |
145 | #define MIPS_CP0_TLB_LO0 2 | 145 | #define MIPS_CP0_TLB_LO0 2 |
146 | #define MIPS_CP0_TLB_LO1 3 | 146 | #define MIPS_CP0_TLB_LO1 3 |
147 | #define MIPS_CP0_TLB_CONTEXT 4 | 147 | #define MIPS_CP0_TLB_CONTEXT 4 |
148 | #define MIPS_CP0_TLB_PG_MASK 5 | 148 | #define MIPS_CP0_TLB_PG_MASK 5 |
149 | #define MIPS_CP0_TLB_WIRED 6 | 149 | #define MIPS_CP0_TLB_WIRED 6 |
150 | #define MIPS_CP0_HWRENA 7 | 150 | #define MIPS_CP0_HWRENA 7 |
151 | #define MIPS_CP0_BAD_VADDR 8 | 151 | #define MIPS_CP0_BAD_VADDR 8 |
152 | #define MIPS_CP0_COUNT 9 | 152 | #define MIPS_CP0_COUNT 9 |
153 | #define MIPS_CP0_TLB_HI 10 | 153 | #define MIPS_CP0_TLB_HI 10 |
154 | #define MIPS_CP0_COMPARE 11 | 154 | #define MIPS_CP0_COMPARE 11 |
155 | #define MIPS_CP0_STATUS 12 | 155 | #define MIPS_CP0_STATUS 12 |
156 | #define MIPS_CP0_CAUSE 13 | 156 | #define MIPS_CP0_CAUSE 13 |
157 | #define MIPS_CP0_EXC_PC 14 | 157 | #define MIPS_CP0_EXC_PC 14 |
158 | #define MIPS_CP0_PRID 15 | 158 | #define MIPS_CP0_PRID 15 |
159 | #define MIPS_CP0_CONFIG 16 | 159 | #define MIPS_CP0_CONFIG 16 |
160 | #define MIPS_CP0_LLADDR 17 | 160 | #define MIPS_CP0_LLADDR 17 |
161 | #define MIPS_CP0_WATCH_LO 18 | 161 | #define MIPS_CP0_WATCH_LO 18 |
162 | #define MIPS_CP0_WATCH_HI 19 | 162 | #define MIPS_CP0_WATCH_HI 19 |
163 | #define MIPS_CP0_TLB_XCONTEXT 20 | 163 | #define MIPS_CP0_TLB_XCONTEXT 20 |
164 | #define MIPS_CP0_ECC 26 | 164 | #define MIPS_CP0_ECC 26 |
165 | #define MIPS_CP0_CACHE_ERR 27 | 165 | #define MIPS_CP0_CACHE_ERR 27 |
166 | #define MIPS_CP0_TAG_LO 28 | 166 | #define MIPS_CP0_TAG_LO 28 |
167 | #define MIPS_CP0_TAG_HI 29 | 167 | #define MIPS_CP0_TAG_HI 29 |
168 | #define MIPS_CP0_ERROR_PC 30 | 168 | #define MIPS_CP0_ERROR_PC 30 |
169 | #define MIPS_CP0_DEBUG 23 | 169 | #define MIPS_CP0_DEBUG 23 |
170 | #define MIPS_CP0_DEPC 24 | 170 | #define MIPS_CP0_DEPC 24 |
171 | #define MIPS_CP0_PERFCNT 25 | 171 | #define MIPS_CP0_PERFCNT 25 |
172 | #define MIPS_CP0_ERRCTL 26 | 172 | #define MIPS_CP0_ERRCTL 26 |
173 | #define MIPS_CP0_DATA_LO 28 | 173 | #define MIPS_CP0_DATA_LO 28 |
174 | #define MIPS_CP0_DATA_HI 29 | 174 | #define MIPS_CP0_DATA_HI 29 |
175 | #define MIPS_CP0_DESAVE 31 | 175 | #define MIPS_CP0_DESAVE 31 |
176 | 176 | ||
177 | #define MIPS_CP0_CONFIG_SEL 0 | 177 | #define MIPS_CP0_CONFIG_SEL 0 |
178 | #define MIPS_CP0_CONFIG1_SEL 1 | 178 | #define MIPS_CP0_CONFIG1_SEL 1 |
179 | #define MIPS_CP0_CONFIG2_SEL 2 | 179 | #define MIPS_CP0_CONFIG2_SEL 2 |
180 | #define MIPS_CP0_CONFIG3_SEL 3 | 180 | #define MIPS_CP0_CONFIG3_SEL 3 |
181 | 181 | ||
182 | /* Config0 register bits */ | 182 | /* Config0 register bits */ |
183 | #define CP0C0_M 31 | 183 | #define CP0C0_M 31 |
184 | #define CP0C0_K23 28 | 184 | #define CP0C0_K23 28 |
185 | #define CP0C0_KU 25 | 185 | #define CP0C0_KU 25 |
186 | #define CP0C0_MDU 20 | 186 | #define CP0C0_MDU 20 |
187 | #define CP0C0_MM 17 | 187 | #define CP0C0_MM 17 |
188 | #define CP0C0_BM 16 | 188 | #define CP0C0_BM 16 |
189 | #define CP0C0_BE 15 | 189 | #define CP0C0_BE 15 |
190 | #define CP0C0_AT 13 | 190 | #define CP0C0_AT 13 |
191 | #define CP0C0_AR 10 | 191 | #define CP0C0_AR 10 |
192 | #define CP0C0_MT 7 | 192 | #define CP0C0_MT 7 |
193 | #define CP0C0_VI 3 | 193 | #define CP0C0_VI 3 |
194 | #define CP0C0_K0 0 | 194 | #define CP0C0_K0 0 |
195 | 195 | ||
196 | /* Config1 register bits */ | 196 | /* Config1 register bits */ |
197 | #define CP0C1_M 31 | 197 | #define CP0C1_M 31 |
198 | #define CP0C1_MMU 25 | 198 | #define CP0C1_MMU 25 |
199 | #define CP0C1_IS 22 | 199 | #define CP0C1_IS 22 |
200 | #define CP0C1_IL 19 | 200 | #define CP0C1_IL 19 |
201 | #define CP0C1_IA 16 | 201 | #define CP0C1_IA 16 |
202 | #define CP0C1_DS 13 | 202 | #define CP0C1_DS 13 |
203 | #define CP0C1_DL 10 | 203 | #define CP0C1_DL 10 |
204 | #define CP0C1_DA 7 | 204 | #define CP0C1_DA 7 |
205 | #define CP0C1_C2 6 | 205 | #define CP0C1_C2 6 |
206 | #define CP0C1_MD 5 | 206 | #define CP0C1_MD 5 |
207 | #define CP0C1_PC 4 | 207 | #define CP0C1_PC 4 |
208 | #define CP0C1_WR 3 | 208 | #define CP0C1_WR 3 |
209 | #define CP0C1_CA 2 | 209 | #define CP0C1_CA 2 |
210 | #define CP0C1_EP 1 | 210 | #define CP0C1_EP 1 |
211 | #define CP0C1_FP 0 | 211 | #define CP0C1_FP 0 |
212 | 212 | ||
213 | /* Config2 Register bits */ | 213 | /* Config2 Register bits */ |
214 | #define CP0C2_M 31 | 214 | #define CP0C2_M 31 |
215 | #define CP0C2_TU 28 | 215 | #define CP0C2_TU 28 |
216 | #define CP0C2_TS 24 | 216 | #define CP0C2_TS 24 |
217 | #define CP0C2_TL 20 | 217 | #define CP0C2_TL 20 |
218 | #define CP0C2_TA 16 | 218 | #define CP0C2_TA 16 |
219 | #define CP0C2_SU 12 | 219 | #define CP0C2_SU 12 |
220 | #define CP0C2_SS 8 | 220 | #define CP0C2_SS 8 |
221 | #define CP0C2_SL 4 | 221 | #define CP0C2_SL 4 |
222 | #define CP0C2_SA 0 | 222 | #define CP0C2_SA 0 |
223 | 223 | ||
224 | /* Config3 Register bits */ | 224 | /* Config3 Register bits */ |
225 | #define CP0C3_M 31 | 225 | #define CP0C3_M 31 |
226 | #define CP0C3_ISA_ON_EXC 16 | 226 | #define CP0C3_ISA_ON_EXC 16 |
227 | #define CP0C3_ULRI 13 | 227 | #define CP0C3_ULRI 13 |
228 | #define CP0C3_DSPP 10 | 228 | #define CP0C3_DSPP 10 |
229 | #define CP0C3_LPA 7 | 229 | #define CP0C3_LPA 7 |
230 | #define CP0C3_VEIC 6 | 230 | #define CP0C3_VEIC 6 |
231 | #define CP0C3_VInt 5 | 231 | #define CP0C3_VInt 5 |
232 | #define CP0C3_SP 4 | 232 | #define CP0C3_SP 4 |
233 | #define CP0C3_MT 2 | 233 | #define CP0C3_MT 2 |
234 | #define CP0C3_SM 1 | 234 | #define CP0C3_SM 1 |
235 | #define CP0C3_TL 0 | 235 | #define CP0C3_TL 0 |
236 | 236 | ||
237 | /* Have config1, Cacheable, noncoherent, write-back, write allocate*/ | 237 | /* Have config1, Cacheable, noncoherent, write-back, write allocate*/ |
238 | #define MIPS_CONFIG0 \ | 238 | #define MIPS_CONFIG0 \ |
239 | ((1 << CP0C0_M) | (0x3 << CP0C0_K0)) | 239 | ((1 << CP0C0_M) | (0x3 << CP0C0_K0)) |
240 | 240 | ||
241 | /* Have config2, no coprocessor2 attached, no MDMX support attached, | 241 | /* Have config2, no coprocessor2 attached, no MDMX support attached, |
242 | no performance counters, watch registers present, | 242 | no performance counters, watch registers present, |
243 | no code compression, EJTAG present, no FPU, no watch registers */ | 243 | no code compression, EJTAG present, no FPU, no watch registers */ |
244 | #define MIPS_CONFIG1 \ | 244 | #define MIPS_CONFIG1 \ |
245 | ((1 << CP0C1_M) | \ | 245 | ((1 << CP0C1_M) | \ |
246 | (0 << CP0C1_C2) | (0 << CP0C1_MD) | (0 << CP0C1_PC) | \ | 246 | (0 << CP0C1_C2) | (0 << CP0C1_MD) | (0 << CP0C1_PC) | \ |
247 | (0 << CP0C1_WR) | (0 << CP0C1_CA) | (1 << CP0C1_EP) | \ | 247 | (0 << CP0C1_WR) | (0 << CP0C1_CA) | (1 << CP0C1_EP) | \ |
248 | (0 << CP0C1_FP)) | 248 | (0 << CP0C1_FP)) |
249 | 249 | ||
250 | /* Have config3, no tertiary/secondary caches implemented */ | 250 | /* Have config3, no tertiary/secondary caches implemented */ |
251 | #define MIPS_CONFIG2 \ | 251 | #define MIPS_CONFIG2 \ |
252 | ((1 << CP0C2_M)) | 252 | ((1 << CP0C2_M)) |
253 | 253 | ||
254 | /* No config4, no DSP ASE, no large physaddr (PABITS), | 254 | /* No config4, no DSP ASE, no large physaddr (PABITS), |
255 | no external interrupt controller, no vectored interrupts, | 255 | no external interrupt controller, no vectored interrupts, |
256 | no 1kb pages, no SmartMIPS ASE, no trace logic */ | 256 | no 1kb pages, no SmartMIPS ASE, no trace logic */ |
257 | #define MIPS_CONFIG3 \ | 257 | #define MIPS_CONFIG3 \ |
258 | ((0 << CP0C3_M) | (0 << CP0C3_DSPP) | (0 << CP0C3_LPA) | \ | 258 | ((0 << CP0C3_M) | (0 << CP0C3_DSPP) | (0 << CP0C3_LPA) | \ |
259 | (0 << CP0C3_VEIC) | (0 << CP0C3_VInt) | (0 << CP0C3_SP) | \ | 259 | (0 << CP0C3_VEIC) | (0 << CP0C3_VInt) | (0 << CP0C3_SP) | \ |
260 | (0 << CP0C3_SM) | (0 << CP0C3_TL)) | 260 | (0 << CP0C3_SM) | (0 << CP0C3_TL)) |
261 | 261 | ||
262 | /* MMU types, the first four entries have the same layout as the | 262 | /* MMU types, the first four entries have the same layout as the |
@@ -274,36 +274,36 @@ enum mips_mmu_types { | |||
274 | /* | 274 | /* |
275 | * Trap codes | 275 | * Trap codes |
276 | */ | 276 | */ |
277 | #define T_INT 0 /* Interrupt pending */ | 277 | #define T_INT 0 /* Interrupt pending */ |
278 | #define T_TLB_MOD 1 /* TLB modified fault */ | 278 | #define T_TLB_MOD 1 /* TLB modified fault */ |
279 | #define T_TLB_LD_MISS 2 /* TLB miss on load or ifetch */ | 279 | #define T_TLB_LD_MISS 2 /* TLB miss on load or ifetch */ |
280 | #define T_TLB_ST_MISS 3 /* TLB miss on a store */ | 280 | #define T_TLB_ST_MISS 3 /* TLB miss on a store */ |
281 | #define T_ADDR_ERR_LD 4 /* Address error on a load or ifetch */ | 281 | #define T_ADDR_ERR_LD 4 /* Address error on a load or ifetch */ |
282 | #define T_ADDR_ERR_ST 5 /* Address error on a store */ | 282 | #define T_ADDR_ERR_ST 5 /* Address error on a store */ |
283 | #define T_BUS_ERR_IFETCH 6 /* Bus error on an ifetch */ | 283 | #define T_BUS_ERR_IFETCH 6 /* Bus error on an ifetch */ |
284 | #define T_BUS_ERR_LD_ST 7 /* Bus error on a load or store */ | 284 | #define T_BUS_ERR_LD_ST 7 /* Bus error on a load or store */ |
285 | #define T_SYSCALL 8 /* System call */ | 285 | #define T_SYSCALL 8 /* System call */ |
286 | #define T_BREAK 9 /* Breakpoint */ | 286 | #define T_BREAK 9 /* Breakpoint */ |
287 | #define T_RES_INST 10 /* Reserved instruction exception */ | 287 | #define T_RES_INST 10 /* Reserved instruction exception */ |
288 | #define T_COP_UNUSABLE 11 /* Coprocessor unusable */ | 288 | #define T_COP_UNUSABLE 11 /* Coprocessor unusable */ |
289 | #define T_OVFLOW 12 /* Arithmetic overflow */ | 289 | #define T_OVFLOW 12 /* Arithmetic overflow */ |
290 | 290 | ||
291 | /* | 291 | /* |
292 | * Trap definitions added for r4000 port. | 292 | * Trap definitions added for r4000 port. |
293 | */ | 293 | */ |
294 | #define T_TRAP 13 /* Trap instruction */ | 294 | #define T_TRAP 13 /* Trap instruction */ |
295 | #define T_VCEI 14 /* Virtual coherency exception */ | 295 | #define T_VCEI 14 /* Virtual coherency exception */ |
296 | #define T_FPE 15 /* Floating point exception */ | 296 | #define T_FPE 15 /* Floating point exception */ |
297 | #define T_WATCH 23 /* Watch address reference */ | 297 | #define T_WATCH 23 /* Watch address reference */ |
298 | #define T_VCED 31 /* Virtual coherency data */ | 298 | #define T_VCED 31 /* Virtual coherency data */ |
299 | 299 | ||
300 | /* Resume Flags */ | 300 | /* Resume Flags */ |
301 | #define RESUME_FLAG_DR (1<<0) /* Reload guest nonvolatile state? */ | 301 | #define RESUME_FLAG_DR (1<<0) /* Reload guest nonvolatile state? */ |
302 | #define RESUME_FLAG_HOST (1<<1) /* Resume host? */ | 302 | #define RESUME_FLAG_HOST (1<<1) /* Resume host? */ |
303 | 303 | ||
304 | #define RESUME_GUEST 0 | 304 | #define RESUME_GUEST 0 |
305 | #define RESUME_GUEST_DR RESUME_FLAG_DR | 305 | #define RESUME_GUEST_DR RESUME_FLAG_DR |
306 | #define RESUME_HOST RESUME_FLAG_HOST | 306 | #define RESUME_HOST RESUME_FLAG_HOST |
307 | 307 | ||
308 | enum emulation_result { | 308 | enum emulation_result { |
309 | EMULATE_DONE, /* no further processing */ | 309 | EMULATE_DONE, /* no further processing */ |
@@ -313,24 +313,27 @@ enum emulation_result { | |||
313 | EMULATE_PRIV_FAIL, | 313 | EMULATE_PRIV_FAIL, |
314 | }; | 314 | }; |
315 | 315 | ||
316 | #define MIPS3_PG_G 0x00000001 /* Global; ignore ASID if in lo0 & lo1 */ | 316 | #define MIPS3_PG_G 0x00000001 /* Global; ignore ASID if in lo0 & lo1 */ |
317 | #define MIPS3_PG_V 0x00000002 /* Valid */ | 317 | #define MIPS3_PG_V 0x00000002 /* Valid */ |
318 | #define MIPS3_PG_NV 0x00000000 | 318 | #define MIPS3_PG_NV 0x00000000 |
319 | #define MIPS3_PG_D 0x00000004 /* Dirty */ | 319 | #define MIPS3_PG_D 0x00000004 /* Dirty */ |
320 | 320 | ||
321 | #define mips3_paddr_to_tlbpfn(x) \ | 321 | #define mips3_paddr_to_tlbpfn(x) \ |
322 | (((unsigned long)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME) | 322 | (((unsigned long)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME) |
323 | #define mips3_tlbpfn_to_paddr(x) \ | 323 | #define mips3_tlbpfn_to_paddr(x) \ |
324 | ((unsigned long)((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT) | 324 | ((unsigned long)((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT) |
325 | 325 | ||
326 | #define MIPS3_PG_SHIFT 6 | 326 | #define MIPS3_PG_SHIFT 6 |
327 | #define MIPS3_PG_FRAME 0x3fffffc0 | 327 | #define MIPS3_PG_FRAME 0x3fffffc0 |
328 | 328 | ||
329 | #define VPN2_MASK 0xffffe000 | 329 | #define VPN2_MASK 0xffffe000 |
330 | #define TLB_IS_GLOBAL(x) (((x).tlb_lo0 & MIPS3_PG_G) && ((x).tlb_lo1 & MIPS3_PG_G)) | 330 | #define TLB_IS_GLOBAL(x) (((x).tlb_lo0 & MIPS3_PG_G) && \ |
331 | #define TLB_VPN2(x) ((x).tlb_hi & VPN2_MASK) | 331 | ((x).tlb_lo1 & MIPS3_PG_G)) |
332 | #define TLB_ASID(x) ((x).tlb_hi & ASID_MASK) | 332 | #define TLB_VPN2(x) ((x).tlb_hi & VPN2_MASK) |
333 | #define TLB_IS_VALID(x, va) (((va) & (1 << PAGE_SHIFT)) ? ((x).tlb_lo1 & MIPS3_PG_V) : ((x).tlb_lo0 & MIPS3_PG_V)) | 333 | #define TLB_ASID(x) ((x).tlb_hi & ASID_MASK) |
334 | #define TLB_IS_VALID(x, va) (((va) & (1 << PAGE_SHIFT)) \ | ||
335 | ? ((x).tlb_lo1 & MIPS3_PG_V) \ | ||
336 | : ((x).tlb_lo0 & MIPS3_PG_V)) | ||
334 | 337 | ||
335 | struct kvm_mips_tlb { | 338 | struct kvm_mips_tlb { |
336 | long tlb_mask; | 339 | long tlb_mask; |
@@ -339,7 +342,7 @@ struct kvm_mips_tlb { | |||
339 | long tlb_lo1; | 342 | long tlb_lo1; |
340 | }; | 343 | }; |
341 | 344 | ||
342 | #define KVM_MIPS_GUEST_TLB_SIZE 64 | 345 | #define KVM_MIPS_GUEST_TLB_SIZE 64 |
343 | struct kvm_vcpu_arch { | 346 | struct kvm_vcpu_arch { |
344 | void *host_ebase, *guest_ebase; | 347 | void *host_ebase, *guest_ebase; |
345 | unsigned long host_stack; | 348 | unsigned long host_stack; |
@@ -400,65 +403,67 @@ struct kvm_vcpu_arch { | |||
400 | }; | 403 | }; |
401 | 404 | ||
402 | 405 | ||
403 | #define kvm_read_c0_guest_index(cop0) (cop0->reg[MIPS_CP0_TLB_INDEX][0]) | 406 | #define kvm_read_c0_guest_index(cop0) (cop0->reg[MIPS_CP0_TLB_INDEX][0]) |
404 | #define kvm_write_c0_guest_index(cop0, val) (cop0->reg[MIPS_CP0_TLB_INDEX][0] = val) | 407 | #define kvm_write_c0_guest_index(cop0, val) (cop0->reg[MIPS_CP0_TLB_INDEX][0] = val) |
405 | #define kvm_read_c0_guest_entrylo0(cop0) (cop0->reg[MIPS_CP0_TLB_LO0][0]) | 408 | #define kvm_read_c0_guest_entrylo0(cop0) (cop0->reg[MIPS_CP0_TLB_LO0][0]) |
406 | #define kvm_read_c0_guest_entrylo1(cop0) (cop0->reg[MIPS_CP0_TLB_LO1][0]) | 409 | #define kvm_read_c0_guest_entrylo1(cop0) (cop0->reg[MIPS_CP0_TLB_LO1][0]) |
407 | #define kvm_read_c0_guest_context(cop0) (cop0->reg[MIPS_CP0_TLB_CONTEXT][0]) | 410 | #define kvm_read_c0_guest_context(cop0) (cop0->reg[MIPS_CP0_TLB_CONTEXT][0]) |
408 | #define kvm_write_c0_guest_context(cop0, val) (cop0->reg[MIPS_CP0_TLB_CONTEXT][0] = (val)) | 411 | #define kvm_write_c0_guest_context(cop0, val) (cop0->reg[MIPS_CP0_TLB_CONTEXT][0] = (val)) |
409 | #define kvm_read_c0_guest_userlocal(cop0) (cop0->reg[MIPS_CP0_TLB_CONTEXT][2]) | 412 | #define kvm_read_c0_guest_userlocal(cop0) (cop0->reg[MIPS_CP0_TLB_CONTEXT][2]) |
410 | #define kvm_read_c0_guest_pagemask(cop0) (cop0->reg[MIPS_CP0_TLB_PG_MASK][0]) | 413 | #define kvm_read_c0_guest_pagemask(cop0) (cop0->reg[MIPS_CP0_TLB_PG_MASK][0]) |
411 | #define kvm_write_c0_guest_pagemask(cop0, val) (cop0->reg[MIPS_CP0_TLB_PG_MASK][0] = (val)) | 414 | #define kvm_write_c0_guest_pagemask(cop0, val) (cop0->reg[MIPS_CP0_TLB_PG_MASK][0] = (val)) |
412 | #define kvm_read_c0_guest_wired(cop0) (cop0->reg[MIPS_CP0_TLB_WIRED][0]) | 415 | #define kvm_read_c0_guest_wired(cop0) (cop0->reg[MIPS_CP0_TLB_WIRED][0]) |
413 | #define kvm_write_c0_guest_wired(cop0, val) (cop0->reg[MIPS_CP0_TLB_WIRED][0] = (val)) | 416 | #define kvm_write_c0_guest_wired(cop0, val) (cop0->reg[MIPS_CP0_TLB_WIRED][0] = (val)) |
414 | #define kvm_read_c0_guest_badvaddr(cop0) (cop0->reg[MIPS_CP0_BAD_VADDR][0]) | 417 | #define kvm_read_c0_guest_hwrena(cop0) (cop0->reg[MIPS_CP0_HWRENA][0]) |
415 | #define kvm_write_c0_guest_badvaddr(cop0, val) (cop0->reg[MIPS_CP0_BAD_VADDR][0] = (val)) | 418 | #define kvm_write_c0_guest_hwrena(cop0, val) (cop0->reg[MIPS_CP0_HWRENA][0] = (val)) |
416 | #define kvm_read_c0_guest_count(cop0) (cop0->reg[MIPS_CP0_COUNT][0]) | 419 | #define kvm_read_c0_guest_badvaddr(cop0) (cop0->reg[MIPS_CP0_BAD_VADDR][0]) |
417 | #define kvm_write_c0_guest_count(cop0, val) (cop0->reg[MIPS_CP0_COUNT][0] = (val)) | 420 | #define kvm_write_c0_guest_badvaddr(cop0, val) (cop0->reg[MIPS_CP0_BAD_VADDR][0] = (val)) |
418 | #define kvm_read_c0_guest_entryhi(cop0) (cop0->reg[MIPS_CP0_TLB_HI][0]) | 421 | #define kvm_read_c0_guest_count(cop0) (cop0->reg[MIPS_CP0_COUNT][0]) |
419 | #define kvm_write_c0_guest_entryhi(cop0, val) (cop0->reg[MIPS_CP0_TLB_HI][0] = (val)) | 422 | #define kvm_write_c0_guest_count(cop0, val) (cop0->reg[MIPS_CP0_COUNT][0] = (val)) |
420 | #define kvm_read_c0_guest_compare(cop0) (cop0->reg[MIPS_CP0_COMPARE][0]) | 423 | #define kvm_read_c0_guest_entryhi(cop0) (cop0->reg[MIPS_CP0_TLB_HI][0]) |
421 | #define kvm_write_c0_guest_compare(cop0, val) (cop0->reg[MIPS_CP0_COMPARE][0] = (val)) | 424 | #define kvm_write_c0_guest_entryhi(cop0, val) (cop0->reg[MIPS_CP0_TLB_HI][0] = (val)) |
422 | #define kvm_read_c0_guest_status(cop0) (cop0->reg[MIPS_CP0_STATUS][0]) | 425 | #define kvm_read_c0_guest_compare(cop0) (cop0->reg[MIPS_CP0_COMPARE][0]) |
423 | #define kvm_write_c0_guest_status(cop0, val) (cop0->reg[MIPS_CP0_STATUS][0] = (val)) | 426 | #define kvm_write_c0_guest_compare(cop0, val) (cop0->reg[MIPS_CP0_COMPARE][0] = (val)) |
424 | #define kvm_read_c0_guest_intctl(cop0) (cop0->reg[MIPS_CP0_STATUS][1]) | 427 | #define kvm_read_c0_guest_status(cop0) (cop0->reg[MIPS_CP0_STATUS][0]) |
425 | #define kvm_write_c0_guest_intctl(cop0, val) (cop0->reg[MIPS_CP0_STATUS][1] = (val)) | 428 | #define kvm_write_c0_guest_status(cop0, val) (cop0->reg[MIPS_CP0_STATUS][0] = (val)) |
426 | #define kvm_read_c0_guest_cause(cop0) (cop0->reg[MIPS_CP0_CAUSE][0]) | 429 | #define kvm_read_c0_guest_intctl(cop0) (cop0->reg[MIPS_CP0_STATUS][1]) |
427 | #define kvm_write_c0_guest_cause(cop0, val) (cop0->reg[MIPS_CP0_CAUSE][0] = (val)) | 430 | #define kvm_write_c0_guest_intctl(cop0, val) (cop0->reg[MIPS_CP0_STATUS][1] = (val)) |
428 | #define kvm_read_c0_guest_epc(cop0) (cop0->reg[MIPS_CP0_EXC_PC][0]) | 431 | #define kvm_read_c0_guest_cause(cop0) (cop0->reg[MIPS_CP0_CAUSE][0]) |
429 | #define kvm_write_c0_guest_epc(cop0, val) (cop0->reg[MIPS_CP0_EXC_PC][0] = (val)) | 432 | #define kvm_write_c0_guest_cause(cop0, val) (cop0->reg[MIPS_CP0_CAUSE][0] = (val)) |
430 | #define kvm_read_c0_guest_prid(cop0) (cop0->reg[MIPS_CP0_PRID][0]) | 433 | #define kvm_read_c0_guest_epc(cop0) (cop0->reg[MIPS_CP0_EXC_PC][0]) |
431 | #define kvm_write_c0_guest_prid(cop0, val) (cop0->reg[MIPS_CP0_PRID][0] = (val)) | 434 | #define kvm_write_c0_guest_epc(cop0, val) (cop0->reg[MIPS_CP0_EXC_PC][0] = (val)) |
432 | #define kvm_read_c0_guest_ebase(cop0) (cop0->reg[MIPS_CP0_PRID][1]) | 435 | #define kvm_read_c0_guest_prid(cop0) (cop0->reg[MIPS_CP0_PRID][0]) |
433 | #define kvm_write_c0_guest_ebase(cop0, val) (cop0->reg[MIPS_CP0_PRID][1] = (val)) | 436 | #define kvm_write_c0_guest_prid(cop0, val) (cop0->reg[MIPS_CP0_PRID][0] = (val)) |
434 | #define kvm_read_c0_guest_config(cop0) (cop0->reg[MIPS_CP0_CONFIG][0]) | 437 | #define kvm_read_c0_guest_ebase(cop0) (cop0->reg[MIPS_CP0_PRID][1]) |
435 | #define kvm_read_c0_guest_config1(cop0) (cop0->reg[MIPS_CP0_CONFIG][1]) | 438 | #define kvm_write_c0_guest_ebase(cop0, val) (cop0->reg[MIPS_CP0_PRID][1] = (val)) |
436 | #define kvm_read_c0_guest_config2(cop0) (cop0->reg[MIPS_CP0_CONFIG][2]) | 439 | #define kvm_read_c0_guest_config(cop0) (cop0->reg[MIPS_CP0_CONFIG][0]) |
437 | #define kvm_read_c0_guest_config3(cop0) (cop0->reg[MIPS_CP0_CONFIG][3]) | 440 | #define kvm_read_c0_guest_config1(cop0) (cop0->reg[MIPS_CP0_CONFIG][1]) |
438 | #define kvm_read_c0_guest_config7(cop0) (cop0->reg[MIPS_CP0_CONFIG][7]) | 441 | #define kvm_read_c0_guest_config2(cop0) (cop0->reg[MIPS_CP0_CONFIG][2]) |
439 | #define kvm_write_c0_guest_config(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][0] = (val)) | 442 | #define kvm_read_c0_guest_config3(cop0) (cop0->reg[MIPS_CP0_CONFIG][3]) |
440 | #define kvm_write_c0_guest_config1(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][1] = (val)) | 443 | #define kvm_read_c0_guest_config7(cop0) (cop0->reg[MIPS_CP0_CONFIG][7]) |
441 | #define kvm_write_c0_guest_config2(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][2] = (val)) | 444 | #define kvm_write_c0_guest_config(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][0] = (val)) |
442 | #define kvm_write_c0_guest_config3(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][3] = (val)) | 445 | #define kvm_write_c0_guest_config1(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][1] = (val)) |
443 | #define kvm_write_c0_guest_config7(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][7] = (val)) | 446 | #define kvm_write_c0_guest_config2(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][2] = (val)) |
444 | #define kvm_read_c0_guest_errorepc(cop0) (cop0->reg[MIPS_CP0_ERROR_PC][0]) | 447 | #define kvm_write_c0_guest_config3(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][3] = (val)) |
445 | #define kvm_write_c0_guest_errorepc(cop0, val) (cop0->reg[MIPS_CP0_ERROR_PC][0] = (val)) | 448 | #define kvm_write_c0_guest_config7(cop0, val) (cop0->reg[MIPS_CP0_CONFIG][7] = (val)) |
446 | 449 | #define kvm_read_c0_guest_errorepc(cop0) (cop0->reg[MIPS_CP0_ERROR_PC][0]) | |
447 | #define kvm_set_c0_guest_status(cop0, val) (cop0->reg[MIPS_CP0_STATUS][0] |= (val)) | 450 | #define kvm_write_c0_guest_errorepc(cop0, val) (cop0->reg[MIPS_CP0_ERROR_PC][0] = (val)) |
448 | #define kvm_clear_c0_guest_status(cop0, val) (cop0->reg[MIPS_CP0_STATUS][0] &= ~(val)) | 451 | |
449 | #define kvm_set_c0_guest_cause(cop0, val) (cop0->reg[MIPS_CP0_CAUSE][0] |= (val)) | 452 | #define kvm_set_c0_guest_status(cop0, val) (cop0->reg[MIPS_CP0_STATUS][0] |= (val)) |
450 | #define kvm_clear_c0_guest_cause(cop0, val) (cop0->reg[MIPS_CP0_CAUSE][0] &= ~(val)) | 453 | #define kvm_clear_c0_guest_status(cop0, val) (cop0->reg[MIPS_CP0_STATUS][0] &= ~(val)) |
451 | #define kvm_change_c0_guest_cause(cop0, change, val) \ | 454 | #define kvm_set_c0_guest_cause(cop0, val) (cop0->reg[MIPS_CP0_CAUSE][0] |= (val)) |
452 | { \ | 455 | #define kvm_clear_c0_guest_cause(cop0, val) (cop0->reg[MIPS_CP0_CAUSE][0] &= ~(val)) |
453 | kvm_clear_c0_guest_cause(cop0, change); \ | 456 | #define kvm_change_c0_guest_cause(cop0, change, val) \ |
454 | kvm_set_c0_guest_cause(cop0, ((val) & (change))); \ | 457 | { \ |
458 | kvm_clear_c0_guest_cause(cop0, change); \ | ||
459 | kvm_set_c0_guest_cause(cop0, ((val) & (change))); \ | ||
455 | } | 460 | } |
456 | #define kvm_set_c0_guest_ebase(cop0, val) (cop0->reg[MIPS_CP0_PRID][1] |= (val)) | 461 | #define kvm_set_c0_guest_ebase(cop0, val) (cop0->reg[MIPS_CP0_PRID][1] |= (val)) |
457 | #define kvm_clear_c0_guest_ebase(cop0, val) (cop0->reg[MIPS_CP0_PRID][1] &= ~(val)) | 462 | #define kvm_clear_c0_guest_ebase(cop0, val) (cop0->reg[MIPS_CP0_PRID][1] &= ~(val)) |
458 | #define kvm_change_c0_guest_ebase(cop0, change, val) \ | 463 | #define kvm_change_c0_guest_ebase(cop0, change, val) \ |
459 | { \ | 464 | { \ |
460 | kvm_clear_c0_guest_ebase(cop0, change); \ | 465 | kvm_clear_c0_guest_ebase(cop0, change); \ |
461 | kvm_set_c0_guest_ebase(cop0, ((val) & (change))); \ | 466 | kvm_set_c0_guest_ebase(cop0, ((val) & (change))); \ |
462 | } | 467 | } |
463 | 468 | ||
464 | 469 | ||