book3s_emulate.c 13.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Copyright SUSE Linux Products GmbH 2009
 *
 * Authors: Alexander Graf <agraf@suse.de>
 */

#include <asm/kvm_ppc.h>
#include <asm/disassemble.h>
#include <asm/kvm_book3s.h>
#include <asm/reg.h>

#define OP_19_XOP_RFID		18
#define OP_19_XOP_RFI		50

#define OP_31_XOP_MFMSR		83
#define OP_31_XOP_MTMSR		146
#define OP_31_XOP_MTMSRD	178
31
#define OP_31_XOP_MTSR		210
32 33 34 35 36 37
#define OP_31_XOP_MTSRIN	242
#define OP_31_XOP_TLBIEL	274
#define OP_31_XOP_TLBIE		306
#define OP_31_XOP_SLBMTE	402
#define OP_31_XOP_SLBIE		434
#define OP_31_XOP_SLBIA		498
38
#define OP_31_XOP_MFSR		595
39
#define OP_31_XOP_MFSRIN	659
40
#define OP_31_XOP_DCBA		758
41 42 43 44 45 46 47
#define OP_31_XOP_SLBMFEV	851
#define OP_31_XOP_EIOIO		854
#define OP_31_XOP_SLBMFEE	915

/* DCBZ is actually 1014, but we patch it to 1010 so we get a trap */
#define OP_31_XOP_DCBZ		1010

48 49 50 51 52
#define OP_LFS			48
#define OP_LFD			50
#define OP_STFS			52
#define OP_STFD			54

A
Alexander Graf 已提交
53 54 55 56 57 58 59 60 61
#define SPRN_GQR0		912
#define SPRN_GQR1		913
#define SPRN_GQR2		914
#define SPRN_GQR3		915
#define SPRN_GQR4		916
#define SPRN_GQR5		917
#define SPRN_GQR6		918
#define SPRN_GQR7		919

62 63 64 65
/* Book3S_32 defines mfsrin(v) - but that messes up our abstract
 * function pointers, so let's just disable the define. */
#undef mfsrin

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
enum priv_level {
	PRIV_PROBLEM = 0,
	PRIV_SUPER = 1,
	PRIV_HYPER = 2,
};

static bool spr_allowed(struct kvm_vcpu *vcpu, enum priv_level level)
{
	/* PAPR VMs only access supervisor SPRs */
	if (vcpu->arch.papr_enabled && (level > PRIV_SUPER))
		return false;

	/* Limit user space to its own small SPR set */
	if ((vcpu->arch.shared->msr & MSR_PR) && level > PRIV_PROBLEM)
		return false;

	return true;
}

85 86 87 88 89 90 91 92 93 94
int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
                           unsigned int inst, int *advance)
{
	int emulated = EMULATE_DONE;

	switch (get_op(inst)) {
	case 19:
		switch (get_xop(inst)) {
		case OP_19_XOP_RFID:
		case OP_19_XOP_RFI:
95 96
			kvmppc_set_pc(vcpu, vcpu->arch.shared->srr0);
			kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1);
97 98 99 100 101 102 103 104 105 106 107
			*advance = 0;
			break;

		default:
			emulated = EMULATE_FAIL;
			break;
		}
		break;
	case 31:
		switch (get_xop(inst)) {
		case OP_31_XOP_MFMSR:
108 109
			kvmppc_set_gpr(vcpu, get_rt(inst),
				       vcpu->arch.shared->msr);
110 111 112
			break;
		case OP_31_XOP_MTMSRD:
		{
113
			ulong rs = kvmppc_get_gpr(vcpu, get_rs(inst));
114
			if (inst & 0x10000) {
115 116
				vcpu->arch.shared->msr &= ~(MSR_RI | MSR_EE);
				vcpu->arch.shared->msr |= rs & (MSR_RI | MSR_EE);
117 118 119 120 121
			} else
				kvmppc_set_msr(vcpu, rs);
			break;
		}
		case OP_31_XOP_MTMSR:
122
			kvmppc_set_msr(vcpu, kvmppc_get_gpr(vcpu, get_rs(inst)));
123
			break;
124 125 126 127 128 129 130 131 132 133 134 135
		case OP_31_XOP_MFSR:
		{
			int srnum;

			srnum = kvmppc_get_field(inst, 12 + 32, 15 + 32);
			if (vcpu->arch.mmu.mfsrin) {
				u32 sr;
				sr = vcpu->arch.mmu.mfsrin(vcpu, srnum);
				kvmppc_set_gpr(vcpu, get_rt(inst), sr);
			}
			break;
		}
136 137 138 139
		case OP_31_XOP_MFSRIN:
		{
			int srnum;

140
			srnum = (kvmppc_get_gpr(vcpu, get_rb(inst)) >> 28) & 0xf;
141 142 143
			if (vcpu->arch.mmu.mfsrin) {
				u32 sr;
				sr = vcpu->arch.mmu.mfsrin(vcpu, srnum);
144
				kvmppc_set_gpr(vcpu, get_rt(inst), sr);
145 146 147
			}
			break;
		}
148 149 150 151 152
		case OP_31_XOP_MTSR:
			vcpu->arch.mmu.mtsrin(vcpu,
				(inst >> 16) & 0xf,
				kvmppc_get_gpr(vcpu, get_rs(inst)));
			break;
153 154
		case OP_31_XOP_MTSRIN:
			vcpu->arch.mmu.mtsrin(vcpu,
155 156
				(kvmppc_get_gpr(vcpu, get_rb(inst)) >> 28) & 0xf,
				kvmppc_get_gpr(vcpu, get_rs(inst)));
157 158 159 160 161
			break;
		case OP_31_XOP_TLBIE:
		case OP_31_XOP_TLBIEL:
		{
			bool large = (inst & 0x00200000) ? true : false;
162
			ulong addr = kvmppc_get_gpr(vcpu, get_rb(inst));
163 164 165 166 167 168 169 170 171
			vcpu->arch.mmu.tlbie(vcpu, addr, large);
			break;
		}
		case OP_31_XOP_EIOIO:
			break;
		case OP_31_XOP_SLBMTE:
			if (!vcpu->arch.mmu.slbmte)
				return EMULATE_FAIL;

172 173 174
			vcpu->arch.mmu.slbmte(vcpu,
					kvmppc_get_gpr(vcpu, get_rs(inst)),
					kvmppc_get_gpr(vcpu, get_rb(inst)));
175 176 177 178 179
			break;
		case OP_31_XOP_SLBIE:
			if (!vcpu->arch.mmu.slbie)
				return EMULATE_FAIL;

180 181
			vcpu->arch.mmu.slbie(vcpu,
					kvmppc_get_gpr(vcpu, get_rb(inst)));
182 183 184 185 186 187 188 189 190 191 192 193 194
			break;
		case OP_31_XOP_SLBIA:
			if (!vcpu->arch.mmu.slbia)
				return EMULATE_FAIL;

			vcpu->arch.mmu.slbia(vcpu);
			break;
		case OP_31_XOP_SLBMFEE:
			if (!vcpu->arch.mmu.slbmfee) {
				emulated = EMULATE_FAIL;
			} else {
				ulong t, rb;

195
				rb = kvmppc_get_gpr(vcpu, get_rb(inst));
196
				t = vcpu->arch.mmu.slbmfee(vcpu, rb);
197
				kvmppc_set_gpr(vcpu, get_rt(inst), t);
198 199 200 201 202 203 204 205
			}
			break;
		case OP_31_XOP_SLBMFEV:
			if (!vcpu->arch.mmu.slbmfev) {
				emulated = EMULATE_FAIL;
			} else {
				ulong t, rb;

206
				rb = kvmppc_get_gpr(vcpu, get_rb(inst));
207
				t = vcpu->arch.mmu.slbmfev(vcpu, rb);
208
				kvmppc_set_gpr(vcpu, get_rt(inst), t);
209 210
			}
			break;
211 212 213
		case OP_31_XOP_DCBA:
			/* Gets treated as NOP */
			break;
214 215
		case OP_31_XOP_DCBZ:
		{
216
			ulong rb = kvmppc_get_gpr(vcpu, get_rb(inst));
217
			ulong ra = 0;
218
			ulong addr, vaddr;
219
			u32 zeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
A
Alexander Graf 已提交
220 221
			u32 dsisr;
			int r;
222 223

			if (get_ra(inst))
224
				ra = kvmppc_get_gpr(vcpu, get_ra(inst));
225 226

			addr = (ra + rb) & ~31ULL;
227
			if (!(vcpu->arch.shared->msr & MSR_SF))
228
				addr &= 0xffffffff;
229
			vaddr = addr;
230

A
Alexander Graf 已提交
231 232
			r = kvmppc_st(vcpu, &addr, 32, zeros, true);
			if ((r == -ENOENT) || (r == -EPERM)) {
233 234 235
				struct kvmppc_book3s_shadow_vcpu *svcpu;

				svcpu = svcpu_get(vcpu);
A
Alexander Graf 已提交
236
				*advance = 0;
237
				vcpu->arch.shared->dar = vaddr;
238
				svcpu->fault_dar = vaddr;
A
Alexander Graf 已提交
239 240 241 242 243 244 245

				dsisr = DSISR_ISSTORE;
				if (r == -ENOENT)
					dsisr |= DSISR_NOHPTE;
				else if (r == -EPERM)
					dsisr |= DSISR_PROTFAULT;

246
				vcpu->arch.shared->dsisr = dsisr;
247 248
				svcpu->fault_dsisr = dsisr;
				svcpu_put(svcpu);
A
Alexander Graf 已提交
249

250 251 252 253 254 255 256 257 258 259 260 261 262 263
				kvmppc_book3s_queue_irqprio(vcpu,
					BOOK3S_INTERRUPT_DATA_STORAGE);
			}

			break;
		}
		default:
			emulated = EMULATE_FAIL;
		}
		break;
	default:
		emulated = EMULATE_FAIL;
	}

264 265 266
	if (emulated == EMULATE_FAIL)
		emulated = kvmppc_emulate_paired_single(run, vcpu);

267 268 269
	return emulated;
}

270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, bool upper,
                    u32 val)
{
	if (upper) {
		/* Upper BAT */
		u32 bl = (val >> 2) & 0x7ff;
		bat->bepi_mask = (~bl << 17);
		bat->bepi = val & 0xfffe0000;
		bat->vs = (val & 2) ? 1 : 0;
		bat->vp = (val & 1) ? 1 : 0;
		bat->raw = (bat->raw & 0xffffffff00000000ULL) | val;
	} else {
		/* Lower BAT */
		bat->brpn = val & 0xfffe0000;
		bat->wimg = (val >> 3) & 0xf;
		bat->pp = val & 3;
		bat->raw = (bat->raw & 0x00000000ffffffffULL) | ((u64)val << 32);
	}
}

290
static struct kvmppc_bat *kvmppc_find_bat(struct kvm_vcpu *vcpu, int sprn)
A
Alexander Graf 已提交
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
{
	struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
	struct kvmppc_bat *bat;

	switch (sprn) {
	case SPRN_IBAT0U ... SPRN_IBAT3L:
		bat = &vcpu_book3s->ibat[(sprn - SPRN_IBAT0U) / 2];
		break;
	case SPRN_IBAT4U ... SPRN_IBAT7L:
		bat = &vcpu_book3s->ibat[4 + ((sprn - SPRN_IBAT4U) / 2)];
		break;
	case SPRN_DBAT0U ... SPRN_DBAT3L:
		bat = &vcpu_book3s->dbat[(sprn - SPRN_DBAT0U) / 2];
		break;
	case SPRN_DBAT4U ... SPRN_DBAT7L:
		bat = &vcpu_book3s->dbat[4 + ((sprn - SPRN_DBAT4U) / 2)];
		break;
	default:
		BUG();
	}

312
	return bat;
313 314 315 316 317
}

int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
{
	int emulated = EMULATE_DONE;
318
	ulong spr_val = kvmppc_get_gpr(vcpu, rs);
319 320 321

	switch (sprn) {
	case SPRN_SDR1:
322 323
		if (!spr_allowed(vcpu, PRIV_HYPER))
			goto unprivileged;
324
		to_book3s(vcpu)->sdr1 = spr_val;
325 326
		break;
	case SPRN_DSISR:
327
		vcpu->arch.shared->dsisr = spr_val;
328 329
		break;
	case SPRN_DAR:
330
		vcpu->arch.shared->dar = spr_val;
331 332
		break;
	case SPRN_HIOR:
333
		to_book3s(vcpu)->hior = spr_val;
334 335 336 337 338
		break;
	case SPRN_IBAT0U ... SPRN_IBAT3L:
	case SPRN_IBAT4U ... SPRN_IBAT7L:
	case SPRN_DBAT0U ... SPRN_DBAT3L:
	case SPRN_DBAT4U ... SPRN_DBAT7L:
339 340 341 342
	{
		struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn);

		kvmppc_set_bat(vcpu, bat, !(sprn % 2), (u32)spr_val);
343 344 345
		/* BAT writes happen so rarely that we're ok to flush
		 * everything here */
		kvmppc_mmu_pte_flush(vcpu, 0, 0);
A
Alexander Graf 已提交
346
		kvmppc_mmu_flush_segments(vcpu);
347
		break;
348
	}
349
	case SPRN_HID0:
350
		to_book3s(vcpu)->hid[0] = spr_val;
351 352
		break;
	case SPRN_HID1:
353
		to_book3s(vcpu)->hid[1] = spr_val;
354 355
		break;
	case SPRN_HID2:
356
		to_book3s(vcpu)->hid[2] = spr_val;
357
		break;
A
Alexander Graf 已提交
358 359 360 361 362 363 364 365 366 367 368 369
	case SPRN_HID2_GEKKO:
		to_book3s(vcpu)->hid[2] = spr_val;
		/* HID2.PSE controls paired single on gekko */
		switch (vcpu->arch.pvr) {
		case 0x00080200:	/* lonestar 2.0 */
		case 0x00088202:	/* lonestar 2.2 */
		case 0x70000100:	/* gekko 1.0 */
		case 0x00080100:	/* gekko 2.0 */
		case 0x00083203:	/* gekko 2.3a */
		case 0x00083213:	/* gekko 2.3b */
		case 0x00083204:	/* gekko 2.4 */
		case 0x00083214:	/* gekko 2.4e (8SE) - retail HW2 */
370 371 372 373
		case 0x00087200:	/* broadway */
			if (vcpu->arch.hflags & BOOK3S_HFLAG_NATIVE_PS) {
				/* Native paired singles */
			} else if (spr_val & (1 << 29)) { /* HID2.PSE */
A
Alexander Graf 已提交
374 375 376 377 378 379 380 381
				vcpu->arch.hflags |= BOOK3S_HFLAG_PAIRED_SINGLE;
				kvmppc_giveup_ext(vcpu, MSR_FP);
			} else {
				vcpu->arch.hflags &= ~BOOK3S_HFLAG_PAIRED_SINGLE;
			}
			break;
		}
		break;
382
	case SPRN_HID4:
A
Alexander Graf 已提交
383
	case SPRN_HID4_GEKKO:
384
		to_book3s(vcpu)->hid[4] = spr_val;
385 386
		break;
	case SPRN_HID5:
387
		to_book3s(vcpu)->hid[5] = spr_val;
388 389 390 391 392
		/* guest HID5 set can change is_dcbz32 */
		if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
		    (mfmsr() & MSR_HV))
			vcpu->arch.hflags |= BOOK3S_HFLAG_DCBZ32;
		break;
A
Alexander Graf 已提交
393 394 395 396 397 398 399 400 401 402
	case SPRN_GQR0:
	case SPRN_GQR1:
	case SPRN_GQR2:
	case SPRN_GQR3:
	case SPRN_GQR4:
	case SPRN_GQR5:
	case SPRN_GQR6:
	case SPRN_GQR7:
		to_book3s(vcpu)->gqr[sprn - SPRN_GQR0] = spr_val;
		break;
403 404 405 406 407 408
	case SPRN_ICTC:
	case SPRN_THRM1:
	case SPRN_THRM2:
	case SPRN_THRM3:
	case SPRN_CTRLF:
	case SPRN_CTRLT:
A
Alexander Graf 已提交
409 410 411 412 413 414 415 416
	case SPRN_L2CR:
	case SPRN_MMCR0_GEKKO:
	case SPRN_MMCR1_GEKKO:
	case SPRN_PMC1_GEKKO:
	case SPRN_PMC2_GEKKO:
	case SPRN_PMC3_GEKKO:
	case SPRN_PMC4_GEKKO:
	case SPRN_WPAR_GEKKO:
417
		break;
418
unprivileged:
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
	default:
		printk(KERN_INFO "KVM: invalid SPR write: %d\n", sprn);
#ifndef DEBUG_SPR
		emulated = EMULATE_FAIL;
#endif
		break;
	}

	return emulated;
}

int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
{
	int emulated = EMULATE_DONE;

	switch (sprn) {
A
Alexander Graf 已提交
435 436 437 438
	case SPRN_IBAT0U ... SPRN_IBAT3L:
	case SPRN_IBAT4U ... SPRN_IBAT7L:
	case SPRN_DBAT0U ... SPRN_DBAT3L:
	case SPRN_DBAT4U ... SPRN_DBAT7L:
439 440 441 442 443 444 445 446
	{
		struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn);

		if (sprn % 2)
			kvmppc_set_gpr(vcpu, rt, bat->raw >> 32);
		else
			kvmppc_set_gpr(vcpu, rt, bat->raw);

A
Alexander Graf 已提交
447
		break;
448
	}
449
	case SPRN_SDR1:
450 451
		if (!spr_allowed(vcpu, PRIV_HYPER))
			goto unprivileged;
452
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->sdr1);
453 454
		break;
	case SPRN_DSISR:
455
		kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dsisr);
456 457
		break;
	case SPRN_DAR:
458
		kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dar);
459 460
		break;
	case SPRN_HIOR:
461
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hior);
462 463
		break;
	case SPRN_HID0:
464
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hid[0]);
465 466
		break;
	case SPRN_HID1:
467
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hid[1]);
468 469
		break;
	case SPRN_HID2:
A
Alexander Graf 已提交
470
	case SPRN_HID2_GEKKO:
471
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hid[2]);
472 473
		break;
	case SPRN_HID4:
A
Alexander Graf 已提交
474
	case SPRN_HID4_GEKKO:
475
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hid[4]);
476 477
		break;
	case SPRN_HID5:
478
		kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hid[5]);
479
		break;
480 481 482 483
	case SPRN_CFAR:
	case SPRN_PURR:
		kvmppc_set_gpr(vcpu, rt, 0);
		break;
A
Alexander Graf 已提交
484 485 486 487 488 489 490 491 492 493 494
	case SPRN_GQR0:
	case SPRN_GQR1:
	case SPRN_GQR2:
	case SPRN_GQR3:
	case SPRN_GQR4:
	case SPRN_GQR5:
	case SPRN_GQR6:
	case SPRN_GQR7:
		kvmppc_set_gpr(vcpu, rt,
			       to_book3s(vcpu)->gqr[sprn - SPRN_GQR0]);
		break;
495 496 497 498 499
	case SPRN_THRM1:
	case SPRN_THRM2:
	case SPRN_THRM3:
	case SPRN_CTRLF:
	case SPRN_CTRLT:
A
Alexander Graf 已提交
500 501 502 503 504 505 506 507
	case SPRN_L2CR:
	case SPRN_MMCR0_GEKKO:
	case SPRN_MMCR1_GEKKO:
	case SPRN_PMC1_GEKKO:
	case SPRN_PMC2_GEKKO:
	case SPRN_PMC3_GEKKO:
	case SPRN_PMC4_GEKKO:
	case SPRN_WPAR_GEKKO:
508
		kvmppc_set_gpr(vcpu, rt, 0);
509 510
		break;
	default:
511
unprivileged:
512 513 514 515 516 517 518 519 520 521
		printk(KERN_INFO "KVM: invalid SPR read: %d\n", sprn);
#ifndef DEBUG_SPR
		emulated = EMULATE_FAIL;
#endif
		break;
	}

	return emulated;
}

522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
{
	u32 dsisr = 0;

	/*
	 * This is what the spec says about DSISR bits (not mentioned = 0):
	 *
	 * 12:13		[DS]	Set to bits 30:31
	 * 15:16		[X]	Set to bits 29:30
	 * 17			[X]	Set to bit 25
	 *			[D/DS]	Set to bit 5
	 * 18:21		[X]	Set to bits 21:24
	 *			[D/DS]	Set to bits 1:4
	 * 22:26			Set to bits 6:10 (RT/RS/FRT/FRS)
	 * 27:31			Set to bits 11:15 (RA)
	 */

	switch (get_op(inst)) {
	/* D-form */
	case OP_LFS:
	case OP_LFD:
	case OP_STFD:
	case OP_STFS:
		dsisr |= (inst >> 12) & 0x4000;	/* bit 17 */
		dsisr |= (inst >> 17) & 0x3c00; /* bits 18:21 */
		break;
	/* X-form */
	case 31:
		dsisr |= (inst << 14) & 0x18000; /* bits 15:16 */
		dsisr |= (inst << 8)  & 0x04000; /* bit 17 */
		dsisr |= (inst << 3)  & 0x03c00; /* bits 18:21 */
		break;
	default:
		printk(KERN_INFO "KVM: Unaligned instruction 0x%x\n", inst);
		break;
	}

	dsisr |= (inst >> 16) & 0x03ff; /* bits 22:31 */

	return dsisr;
}

ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
{
	ulong dar = 0;
	ulong ra;

	switch (get_op(inst)) {
	case OP_LFS:
	case OP_LFD:
	case OP_STFD:
	case OP_STFS:
		ra = get_ra(inst);
		if (ra)
			dar = kvmppc_get_gpr(vcpu, ra);
		dar += (s32)((s16)inst);
		break;
	case 31:
		ra = get_ra(inst);
		if (ra)
			dar = kvmppc_get_gpr(vcpu, ra);
		dar += kvmppc_get_gpr(vcpu, get_rb(inst));
		break;
	default:
		printk(KERN_INFO "KVM: Unaligned instruction 0x%x\n", inst);
		break;
	}

	return dar;
}