blob: 689ff5f90e9ef9f725395e1434cd69e32e5c0347 [file] [log] [blame]
Thomas Gleixnerd94d71c2019-05-29 07:12:40 -07001// SPDX-License-Identifier: GPL-2.0-only
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -06002/*
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -06003 *
4 * Copyright IBM Corp. 2008
Scott Wooddfd4d472011-11-17 12:39:59 +00005 * Copyright 2011 Freescale Semiconductor, Inc.
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -06006 *
7 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
8 */
9
10#include <linux/kvm_host.h>
11#include <asm/disassemble.h>
12
13#include "booke.h"
14
15#define OP_19_XOP_RFI 50
Bharat Bhushan0c1fc3c2012-06-27 19:37:31 +000016#define OP_19_XOP_RFCI 51
Bharat Bhushanc8ca97c2014-08-06 12:08:52 +053017#define OP_19_XOP_RFDI 39
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060018
19#define OP_31_XOP_MFMSR 83
20#define OP_31_XOP_WRTEE 131
21#define OP_31_XOP_MTMSR 146
22#define OP_31_XOP_WRTEEI 163
23
24static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)
25{
Simon Guo173c5202018-05-07 14:20:08 +080026 vcpu->arch.regs.nip = vcpu->arch.shared->srr0;
Alexander Grafde7906c2010-07-29 14:47:46 +020027 kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1);
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060028}
29
Bharat Bhushanc8ca97c2014-08-06 12:08:52 +053030static void kvmppc_emul_rfdi(struct kvm_vcpu *vcpu)
31{
Simon Guo173c5202018-05-07 14:20:08 +080032 vcpu->arch.regs.nip = vcpu->arch.dsrr0;
Bharat Bhushanc8ca97c2014-08-06 12:08:52 +053033 kvmppc_set_msr(vcpu, vcpu->arch.dsrr1);
34}
35
Bharat Bhushan0c1fc3c2012-06-27 19:37:31 +000036static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)
37{
Simon Guo173c5202018-05-07 14:20:08 +080038 vcpu->arch.regs.nip = vcpu->arch.csrr0;
Bharat Bhushan0c1fc3c2012-06-27 19:37:31 +000039 kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
40}
41
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060042int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
43 unsigned int inst, int *advance)
44{
45 int emulated = EMULATE_DONE;
Alexander Grafc46dc9a2012-05-04 14:01:33 +020046 int rs = get_rs(inst);
47 int rt = get_rt(inst);
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060048
49 switch (get_op(inst)) {
50 case 19:
51 switch (get_xop(inst)) {
52 case OP_19_XOP_RFI:
53 kvmppc_emul_rfi(vcpu);
54 kvmppc_set_exit_type(vcpu, EMULATED_RFI_EXITS);
55 *advance = 0;
56 break;
57
Bharat Bhushan0c1fc3c2012-06-27 19:37:31 +000058 case OP_19_XOP_RFCI:
59 kvmppc_emul_rfci(vcpu);
60 kvmppc_set_exit_type(vcpu, EMULATED_RFCI_EXITS);
61 *advance = 0;
62 break;
63
Bharat Bhushanc8ca97c2014-08-06 12:08:52 +053064 case OP_19_XOP_RFDI:
65 kvmppc_emul_rfdi(vcpu);
66 kvmppc_set_exit_type(vcpu, EMULATED_RFDI_EXITS);
67 *advance = 0;
68 break;
69
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060070 default:
71 emulated = EMULATE_FAIL;
72 break;
73 }
74 break;
75
76 case 31:
77 switch (get_xop(inst)) {
78
79 case OP_31_XOP_MFMSR:
Alexander Graf666e7252010-07-29 14:47:43 +020080 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->msr);
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060081 kvmppc_set_exit_type(vcpu, EMULATED_MFMSR_EXITS);
82 break;
83
84 case OP_31_XOP_MTMSR:
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060085 kvmppc_set_exit_type(vcpu, EMULATED_MTMSR_EXITS);
Alexander Graf8e5b26b2010-01-08 02:58:01 +010086 kvmppc_set_msr(vcpu, kvmppc_get_gpr(vcpu, rs));
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060087 break;
88
89 case OP_31_XOP_WRTEE:
Alexander Graf666e7252010-07-29 14:47:43 +020090 vcpu->arch.shared->msr = (vcpu->arch.shared->msr & ~MSR_EE)
Alexander Graf8e5b26b2010-01-08 02:58:01 +010091 | (kvmppc_get_gpr(vcpu, rs) & MSR_EE);
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060092 kvmppc_set_exit_type(vcpu, EMULATED_WRTEE_EXITS);
93 break;
94
95 case OP_31_XOP_WRTEEI:
Alexander Graf666e7252010-07-29 14:47:43 +020096 vcpu->arch.shared->msr = (vcpu->arch.shared->msr & ~MSR_EE)
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060097 | (inst & MSR_EE);
98 kvmppc_set_exit_type(vcpu, EMULATED_WRTEE_EXITS);
99 break;
100
101 default:
102 emulated = EMULATE_FAIL;
103 }
104
105 break;
106
107 default:
108 emulated = EMULATE_FAIL;
109 }
110
111 return emulated;
112}
113
Scott Woodd30f6e42011-12-20 15:34:43 +0000114/*
115 * NOTE: some of these registers are not emulated on BOOKE_HV (GS-mode).
116 * Their backing store is in real registers, and these functions
117 * will return the wrong result if called for them in another context
118 * (such as debugging).
119 */
Alexander Graf54771e62012-05-04 14:55:12 +0200120int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600121{
122 int emulated = EMULATE_DONE;
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530123 bool debug_inst = false;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600124
125 switch (sprn) {
126 case SPRN_DEAR:
Alexander Graf54771e62012-05-04 14:55:12 +0200127 vcpu->arch.shared->dar = spr_val;
128 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600129 case SPRN_ESR:
Alexander Graf54771e62012-05-04 14:55:12 +0200130 vcpu->arch.shared->esr = spr_val;
131 break;
Bharat Bhushan0c1fc3c2012-06-27 19:37:31 +0000132 case SPRN_CSRR0:
133 vcpu->arch.csrr0 = spr_val;
134 break;
135 case SPRN_CSRR1:
136 vcpu->arch.csrr1 = spr_val;
137 break;
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530138 case SPRN_DSRR0:
139 vcpu->arch.dsrr0 = spr_val;
140 break;
141 case SPRN_DSRR1:
142 vcpu->arch.dsrr1 = spr_val;
143 break;
144 case SPRN_IAC1:
145 /*
146 * If userspace is debugging guest then guest
147 * can not access debug registers.
148 */
149 if (vcpu->guest_debug)
150 break;
151
152 debug_inst = true;
153 vcpu->arch.dbg_reg.iac1 = spr_val;
154 break;
155 case SPRN_IAC2:
156 /*
157 * If userspace is debugging guest then guest
158 * can not access debug registers.
159 */
160 if (vcpu->guest_debug)
161 break;
162
163 debug_inst = true;
164 vcpu->arch.dbg_reg.iac2 = spr_val;
165 break;
166#if CONFIG_PPC_ADV_DEBUG_IACS > 2
167 case SPRN_IAC3:
168 /*
169 * If userspace is debugging guest then guest
170 * can not access debug registers.
171 */
172 if (vcpu->guest_debug)
173 break;
174
175 debug_inst = true;
176 vcpu->arch.dbg_reg.iac3 = spr_val;
177 break;
178 case SPRN_IAC4:
179 /*
180 * If userspace is debugging guest then guest
181 * can not access debug registers.
182 */
183 if (vcpu->guest_debug)
184 break;
185
186 debug_inst = true;
187 vcpu->arch.dbg_reg.iac4 = spr_val;
188 break;
189#endif
190 case SPRN_DAC1:
191 /*
192 * If userspace is debugging guest then guest
193 * can not access debug registers.
194 */
195 if (vcpu->guest_debug)
196 break;
197
198 debug_inst = true;
199 vcpu->arch.dbg_reg.dac1 = spr_val;
200 break;
201 case SPRN_DAC2:
202 /*
203 * If userspace is debugging guest then guest
204 * can not access debug registers.
205 */
206 if (vcpu->guest_debug)
207 break;
208
209 debug_inst = true;
210 vcpu->arch.dbg_reg.dac2 = spr_val;
211 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600212 case SPRN_DBCR0:
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530213 /*
214 * If userspace is debugging guest then guest
215 * can not access debug registers.
216 */
217 if (vcpu->guest_debug)
218 break;
219
220 debug_inst = true;
221 spr_val &= (DBCR0_IDM | DBCR0_IC | DBCR0_BT | DBCR0_TIE |
222 DBCR0_IAC1 | DBCR0_IAC2 | DBCR0_IAC3 | DBCR0_IAC4 |
223 DBCR0_DAC1R | DBCR0_DAC1W | DBCR0_DAC2R | DBCR0_DAC2W);
224
Bharat Bhushan6df8d3f2012-08-08 21:17:55 +0000225 vcpu->arch.dbg_reg.dbcr0 = spr_val;
Alexander Graf54771e62012-05-04 14:55:12 +0200226 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600227 case SPRN_DBCR1:
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530228 /*
229 * If userspace is debugging guest then guest
230 * can not access debug registers.
231 */
232 if (vcpu->guest_debug)
233 break;
234
235 debug_inst = true;
Bharat Bhushan6df8d3f2012-08-08 21:17:55 +0000236 vcpu->arch.dbg_reg.dbcr1 = spr_val;
Alexander Graf54771e62012-05-04 14:55:12 +0200237 break;
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530238 case SPRN_DBCR2:
239 /*
240 * If userspace is debugging guest then guest
241 * can not access debug registers.
242 */
243 if (vcpu->guest_debug)
244 break;
245
246 debug_inst = true;
247 vcpu->arch.dbg_reg.dbcr2 = spr_val;
248 break;
Hollis Blanchardf7b200a2009-01-03 16:23:07 -0600249 case SPRN_DBSR:
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530250 /*
251 * If userspace is debugging guest then guest
252 * can not access debug registers.
253 */
254 if (vcpu->guest_debug)
255 break;
256
Alexander Graf54771e62012-05-04 14:55:12 +0200257 vcpu->arch.dbsr &= ~spr_val;
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530258 if (!(vcpu->arch.dbsr & ~DBSR_IDE))
259 kvmppc_core_dequeue_debug(vcpu);
Alexander Graf54771e62012-05-04 14:55:12 +0200260 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600261 case SPRN_TSR:
Scott Wooddfd4d472011-11-17 12:39:59 +0000262 kvmppc_clr_tsr_bits(vcpu, spr_val);
263 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600264 case SPRN_TCR:
Bharat Bhushanf61c94b2012-08-08 20:38:19 +0000265 /*
266 * WRC is a 2-bit field that is supposed to preserve its
267 * value once written to non-zero.
268 */
269 if (vcpu->arch.tcr & TCR_WRC_MASK) {
270 spr_val &= ~TCR_WRC_MASK;
271 spr_val |= vcpu->arch.tcr & TCR_WRC_MASK;
272 }
Scott Wooddfd4d472011-11-17 12:39:59 +0000273 kvmppc_set_tcr(vcpu, spr_val);
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600274 break;
275
Bharat Bhushan21bd0002012-05-20 23:21:23 +0000276 case SPRN_DECAR:
277 vcpu->arch.decar = spr_val;
278 break;
Scott Woodd30f6e42011-12-20 15:34:43 +0000279 /*
280 * Note: SPRG4-7 are user-readable.
281 * These values are loaded into the real SPRGs when resuming the
282 * guest (PR-mode only).
283 */
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600284 case SPRN_SPRG4:
Bharat Bhushanc1b8a012014-07-17 17:01:39 +0530285 kvmppc_set_sprg4(vcpu, spr_val);
Alexander Graf54771e62012-05-04 14:55:12 +0200286 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600287 case SPRN_SPRG5:
Bharat Bhushanc1b8a012014-07-17 17:01:39 +0530288 kvmppc_set_sprg5(vcpu, spr_val);
Alexander Graf54771e62012-05-04 14:55:12 +0200289 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600290 case SPRN_SPRG6:
Bharat Bhushanc1b8a012014-07-17 17:01:39 +0530291 kvmppc_set_sprg6(vcpu, spr_val);
Alexander Graf54771e62012-05-04 14:55:12 +0200292 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600293 case SPRN_SPRG7:
Bharat Bhushanc1b8a012014-07-17 17:01:39 +0530294 kvmppc_set_sprg7(vcpu, spr_val);
Alexander Graf54771e62012-05-04 14:55:12 +0200295 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600296
297 case SPRN_IVPR:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100298 vcpu->arch.ivpr = spr_val;
Scott Woodd30f6e42011-12-20 15:34:43 +0000299#ifdef CONFIG_KVM_BOOKE_HV
300 mtspr(SPRN_GIVPR, spr_val);
301#endif
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600302 break;
303 case SPRN_IVOR0:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100304 vcpu->arch.ivor[BOOKE_IRQPRIO_CRITICAL] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600305 break;
306 case SPRN_IVOR1:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100307 vcpu->arch.ivor[BOOKE_IRQPRIO_MACHINE_CHECK] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600308 break;
309 case SPRN_IVOR2:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100310 vcpu->arch.ivor[BOOKE_IRQPRIO_DATA_STORAGE] = spr_val;
Scott Woodd30f6e42011-12-20 15:34:43 +0000311#ifdef CONFIG_KVM_BOOKE_HV
312 mtspr(SPRN_GIVOR2, spr_val);
313#endif
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600314 break;
315 case SPRN_IVOR3:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100316 vcpu->arch.ivor[BOOKE_IRQPRIO_INST_STORAGE] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600317 break;
318 case SPRN_IVOR4:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100319 vcpu->arch.ivor[BOOKE_IRQPRIO_EXTERNAL] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600320 break;
321 case SPRN_IVOR5:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100322 vcpu->arch.ivor[BOOKE_IRQPRIO_ALIGNMENT] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600323 break;
324 case SPRN_IVOR6:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100325 vcpu->arch.ivor[BOOKE_IRQPRIO_PROGRAM] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600326 break;
327 case SPRN_IVOR7:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100328 vcpu->arch.ivor[BOOKE_IRQPRIO_FP_UNAVAIL] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600329 break;
330 case SPRN_IVOR8:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100331 vcpu->arch.ivor[BOOKE_IRQPRIO_SYSCALL] = spr_val;
Scott Woodd30f6e42011-12-20 15:34:43 +0000332#ifdef CONFIG_KVM_BOOKE_HV
333 mtspr(SPRN_GIVOR8, spr_val);
334#endif
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600335 break;
336 case SPRN_IVOR9:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100337 vcpu->arch.ivor[BOOKE_IRQPRIO_AP_UNAVAIL] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600338 break;
339 case SPRN_IVOR10:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100340 vcpu->arch.ivor[BOOKE_IRQPRIO_DECREMENTER] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600341 break;
342 case SPRN_IVOR11:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100343 vcpu->arch.ivor[BOOKE_IRQPRIO_FIT] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600344 break;
345 case SPRN_IVOR12:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100346 vcpu->arch.ivor[BOOKE_IRQPRIO_WATCHDOG] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600347 break;
348 case SPRN_IVOR13:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100349 vcpu->arch.ivor[BOOKE_IRQPRIO_DTLB_MISS] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600350 break;
351 case SPRN_IVOR14:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100352 vcpu->arch.ivor[BOOKE_IRQPRIO_ITLB_MISS] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600353 break;
354 case SPRN_IVOR15:
Alexander Graf8e5b26b2010-01-08 02:58:01 +0100355 vcpu->arch.ivor[BOOKE_IRQPRIO_DEBUG] = spr_val;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600356 break;
Alexander Graf50c871e2012-08-13 14:50:54 +0200357 case SPRN_MCSR:
358 vcpu->arch.mcsr &= ~spr_val;
359 break;
Mihai Caraman38f98822012-10-11 06:13:27 +0000360#if defined(CONFIG_64BIT)
361 case SPRN_EPCR:
362 kvmppc_set_epcr(vcpu, spr_val);
363#ifdef CONFIG_KVM_BOOKE_HV
364 mtspr(SPRN_EPCR, vcpu->arch.shadow_epcr);
365#endif
366 break;
367#endif
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600368 default:
369 emulated = EMULATE_FAIL;
370 }
371
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530372 if (debug_inst) {
373 current->thread.debug = vcpu->arch.dbg_reg;
374 switch_booke_debug_regs(&vcpu->arch.dbg_reg);
375 }
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600376 return emulated;
377}
378
Alexander Graf54771e62012-05-04 14:55:12 +0200379int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600380{
381 int emulated = EMULATE_DONE;
382
383 switch (sprn) {
384 case SPRN_IVPR:
Alexander Graf54771e62012-05-04 14:55:12 +0200385 *spr_val = vcpu->arch.ivpr;
386 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600387 case SPRN_DEAR:
Alexander Graf54771e62012-05-04 14:55:12 +0200388 *spr_val = vcpu->arch.shared->dar;
389 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600390 case SPRN_ESR:
Alexander Graf54771e62012-05-04 14:55:12 +0200391 *spr_val = vcpu->arch.shared->esr;
392 break;
Alexander Graf37ecb252013-01-04 18:02:14 +0100393 case SPRN_EPR:
394 *spr_val = vcpu->arch.epr;
395 break;
Bharat Bhushan0c1fc3c2012-06-27 19:37:31 +0000396 case SPRN_CSRR0:
397 *spr_val = vcpu->arch.csrr0;
398 break;
399 case SPRN_CSRR1:
400 *spr_val = vcpu->arch.csrr1;
401 break;
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530402 case SPRN_DSRR0:
403 *spr_val = vcpu->arch.dsrr0;
404 break;
405 case SPRN_DSRR1:
406 *spr_val = vcpu->arch.dsrr1;
407 break;
408 case SPRN_IAC1:
409 *spr_val = vcpu->arch.dbg_reg.iac1;
410 break;
411 case SPRN_IAC2:
412 *spr_val = vcpu->arch.dbg_reg.iac2;
413 break;
414#if CONFIG_PPC_ADV_DEBUG_IACS > 2
415 case SPRN_IAC3:
416 *spr_val = vcpu->arch.dbg_reg.iac3;
417 break;
418 case SPRN_IAC4:
419 *spr_val = vcpu->arch.dbg_reg.iac4;
420 break;
421#endif
422 case SPRN_DAC1:
423 *spr_val = vcpu->arch.dbg_reg.dac1;
424 break;
425 case SPRN_DAC2:
426 *spr_val = vcpu->arch.dbg_reg.dac2;
427 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600428 case SPRN_DBCR0:
Bharat Bhushan6df8d3f2012-08-08 21:17:55 +0000429 *spr_val = vcpu->arch.dbg_reg.dbcr0;
Bharat Bhushan348ba712014-08-06 12:08:55 +0530430 if (vcpu->guest_debug)
431 *spr_val = *spr_val | DBCR0_EDM;
Alexander Graf54771e62012-05-04 14:55:12 +0200432 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600433 case SPRN_DBCR1:
Bharat Bhushan6df8d3f2012-08-08 21:17:55 +0000434 *spr_val = vcpu->arch.dbg_reg.dbcr1;
Alexander Graf54771e62012-05-04 14:55:12 +0200435 break;
Bharat Bhushan2f699a52014-08-13 14:39:44 +0530436 case SPRN_DBCR2:
437 *spr_val = vcpu->arch.dbg_reg.dbcr2;
438 break;
Hollis Blanchardf7b200a2009-01-03 16:23:07 -0600439 case SPRN_DBSR:
Alexander Graf54771e62012-05-04 14:55:12 +0200440 *spr_val = vcpu->arch.dbsr;
441 break;
Scott Wooddfd4d472011-11-17 12:39:59 +0000442 case SPRN_TSR:
Alexander Graf54771e62012-05-04 14:55:12 +0200443 *spr_val = vcpu->arch.tsr;
444 break;
Scott Wooddfd4d472011-11-17 12:39:59 +0000445 case SPRN_TCR:
Alexander Graf54771e62012-05-04 14:55:12 +0200446 *spr_val = vcpu->arch.tcr;
447 break;
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600448
449 case SPRN_IVOR0:
Alexander Graf54771e62012-05-04 14:55:12 +0200450 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_CRITICAL];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600451 break;
452 case SPRN_IVOR1:
Alexander Graf54771e62012-05-04 14:55:12 +0200453 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_MACHINE_CHECK];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600454 break;
455 case SPRN_IVOR2:
Alexander Graf54771e62012-05-04 14:55:12 +0200456 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_DATA_STORAGE];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600457 break;
458 case SPRN_IVOR3:
Alexander Graf54771e62012-05-04 14:55:12 +0200459 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_INST_STORAGE];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600460 break;
461 case SPRN_IVOR4:
Alexander Graf54771e62012-05-04 14:55:12 +0200462 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_EXTERNAL];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600463 break;
464 case SPRN_IVOR5:
Alexander Graf54771e62012-05-04 14:55:12 +0200465 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_ALIGNMENT];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600466 break;
467 case SPRN_IVOR6:
Alexander Graf54771e62012-05-04 14:55:12 +0200468 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_PROGRAM];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600469 break;
470 case SPRN_IVOR7:
Alexander Graf54771e62012-05-04 14:55:12 +0200471 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_FP_UNAVAIL];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600472 break;
473 case SPRN_IVOR8:
Alexander Graf54771e62012-05-04 14:55:12 +0200474 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_SYSCALL];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600475 break;
476 case SPRN_IVOR9:
Alexander Graf54771e62012-05-04 14:55:12 +0200477 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_AP_UNAVAIL];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600478 break;
479 case SPRN_IVOR10:
Alexander Graf54771e62012-05-04 14:55:12 +0200480 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_DECREMENTER];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600481 break;
482 case SPRN_IVOR11:
Alexander Graf54771e62012-05-04 14:55:12 +0200483 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_FIT];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600484 break;
485 case SPRN_IVOR12:
Alexander Graf54771e62012-05-04 14:55:12 +0200486 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_WATCHDOG];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600487 break;
488 case SPRN_IVOR13:
Alexander Graf54771e62012-05-04 14:55:12 +0200489 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_DTLB_MISS];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600490 break;
491 case SPRN_IVOR14:
Alexander Graf54771e62012-05-04 14:55:12 +0200492 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_ITLB_MISS];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600493 break;
494 case SPRN_IVOR15:
Alexander Graf54771e62012-05-04 14:55:12 +0200495 *spr_val = vcpu->arch.ivor[BOOKE_IRQPRIO_DEBUG];
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600496 break;
Alexander Graf50c871e2012-08-13 14:50:54 +0200497 case SPRN_MCSR:
498 *spr_val = vcpu->arch.mcsr;
499 break;
Mihai Caraman38f98822012-10-11 06:13:27 +0000500#if defined(CONFIG_64BIT)
501 case SPRN_EPCR:
502 *spr_val = vcpu->arch.epcr;
503 break;
504#endif
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -0600505
506 default:
507 emulated = EMULATE_FAIL;
508 }
509
510 return emulated;
511}