Patchwork [3/3] KVM: PPC: BookE: Forward DBCR0 to user space

login
register
mail settings
Submitter Alexander Graf
Date Oct. 6, 2012, 11:41 p.m.
Message ID <1349566882-10948-4-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/189761/
State New
Headers show

Comments

Alexander Graf - Oct. 6, 2012, 11:41 p.m.
When the guest wants to access DBCR0 and we support user space SPR handling,
let's expose it to user space.

DBCR0 is used for system reset trigger. Since user space as control over the
machine, not KVM, we need to let this register be handled by user space.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/kvm/booke_emulate.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

Patch

diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 514790f..62cf27f 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -133,7 +133,11 @@  int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
 		vcpu->arch.csrr1 = spr_val;
 		break;
 	case SPRN_DBCR0:
-		vcpu->arch.dbg_reg.dbcr0 = spr_val;
+		if (vcpu->arch.spr_exit_enabled)
+			/* Forward to user space, as it triggers reset */
+			emulated = EMULATE_FAIL;
+		else
+			vcpu->arch.dbg_reg.dbcr0 = spr_val;
 		break;
 	case SPRN_DBCR1:
 		vcpu->arch.dbg_reg.dbcr1 = spr_val;
@@ -269,7 +273,11 @@  int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
 		*spr_val = vcpu->arch.csrr1;
 		break;
 	case SPRN_DBCR0:
-		*spr_val = vcpu->arch.dbg_reg.dbcr0;
+		if (vcpu->arch.spr_exit_enabled)
+			/* Forward to user space, as it triggers reset */
+			emulated = EMULATE_FAIL;
+		else
+			*spr_val = vcpu->arch.dbg_reg.dbcr0;
 		break;
 	case SPRN_DBCR1:
 		*spr_val = vcpu->arch.dbg_reg.dbcr1;