public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 3/3] KVM: PPC: BookE: Forward DBCR0 to user space
Date: Sun,  7 Oct 2012 01:41:22 +0200	[thread overview]
Message-ID: <1349566882-10948-4-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1349566882-10948-1-git-send-email-agraf@suse.de>

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


      parent reply	other threads:[~2012-10-06 23:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-06 23:41 [PATCH 0/3] KVM: PPC: Enable user space handled SPRs Alexander Graf
2012-10-06 23:41 ` [PATCH 1/3] KVM: PPC: Move mtspr/mfspr emulation into own functions Alexander Graf
2012-10-06 23:41 ` [PATCH 2/3] KVM: PPC: Add SPR emulation exits Alexander Graf
2012-10-07 13:13   ` Avi Kivity
2012-10-07 13:19     ` Alexander Graf
2012-10-07 13:26       ` Avi Kivity
2012-10-07 13:30         ` Alexander Graf
2012-10-07 13:34           ` Avi Kivity
2012-10-07 13:37             ` Alexander Graf
2012-10-08 20:45           ` Scott Wood
2012-10-08 21:01             ` Alexander Graf
2012-10-08 21:07               ` Scott Wood
2012-10-07 13:26       ` Alexander Graf
2012-10-07 13:30         ` Avi Kivity
2012-10-07 13:33           ` Alexander Graf
2012-10-06 23:41 ` Alexander Graf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349566882-10948-4-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox