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

Alexander Graf
2012-10-06T23:41:27Z

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(-)

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;
--
1.6.0.2