linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Mihai Caraman <mihai.caraman@freescale.com>
To: <kvm-ppc@vger.kernel.org>
Cc: Mihai Caraman <mihai.caraman@freescale.com>,
	linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org
Subject: [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation
Date: Thu, 11 Oct 2012 19:13:27 +0300	[thread overview]
Message-ID: <1349972009-23027-11-git-send-email-mihai.caraman@freescale.com> (raw)
In-Reply-To: <1349972009-23027-1-git-send-email-mihai.caraman@freescale.com>

Add EPCR support in booke mtspr/mfspr emulation. EPCR register is defined only
for 64-bit and HV categories, we will expose it at this point only to 64-bit
virtual processors running on 64-bit HV hosts.
Define a reusable setter function for vcpu's EPCR.

Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
v1: extended guard defines with CONFIG_KVM_BOOKE_HV required by arch's epcr and
shadow_epcr fields.

 arch/powerpc/kvm/booke.c         |   10 ++++++++++
 arch/powerpc/kvm/booke.h         |    1 +
 arch/powerpc/kvm/booke_emulate.c |   12 +++++++++++-
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 86f0d0d..e6159f5 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1473,6 +1473,16 @@ void kvmppc_core_flush_memslot(struct kvm *kvm, struct kvm_memory_slot *memslot)
 {
 }
 
+void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr)
+{
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+	vcpu->arch.epcr = new_epcr;
+	vcpu->arch.shadow_epcr &= ~SPRN_EPCR_GICM;
+	if (vcpu->arch.epcr  & SPRN_EPCR_ICM)
+		vcpu->arch.shadow_epcr |= SPRN_EPCR_GICM;
+#endif
+}
+
 void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr)
 {
 	vcpu->arch.tcr = new_tcr;
diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
index ba61974..e9b88e4 100644
--- a/arch/powerpc/kvm/booke.h
+++ b/arch/powerpc/kvm/booke.h
@@ -69,6 +69,7 @@ extern unsigned long kvmppc_booke_handlers;
 void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
 void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
 
+void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
 void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
 void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
 void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 514790f..8d9d8f9 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -240,7 +240,12 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
 	case SPRN_MCSR:
 		vcpu->arch.mcsr &= ~spr_val;
 		break;
-
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+	case SPRN_EPCR:
+		kvmppc_set_epcr(vcpu, spr_val);
+		mtspr(SPRN_EPCR, vcpu->arch.shadow_epcr);
+		break;
+#endif
 	default:
 		emulated = EMULATE_FAIL;
 	}
@@ -335,6 +340,11 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
 	case SPRN_MCSR:
 		*spr_val = vcpu->arch.mcsr;
 		break;
+#if defined(CONFIG_64BIT) && defined(CONFIG_KVM_BOOKE_HV)
+	case SPRN_EPCR:
+		*spr_val = vcpu->arch.epcr;
+		break;
+#endif
 
 	default:
 		emulated = EMULATE_FAIL;
-- 
1.7.4.1

  parent reply	other threads:[~2012-10-11 16:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-11 16:13 [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Mihai Caraman
2012-10-11 16:13 ` [PATCH 01/12] KVM: PPC: e500: Silence bogus GCC warning in tlb code Mihai Caraman
2012-10-11 16:13 ` [PATCH 02/12] KVM: PPC: booke: Fix get_tb() compile error on 64-bit Mihai Caraman
2012-10-11 16:13 ` [PATCH 03/12] KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler Mihai Caraman
2012-10-11 16:13 ` [PATCH 04/12] KVM: PPC64: bookehv: Add support for interrupt handling Mihai Caraman
2012-10-11 16:13 ` [PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea Mihai Caraman
2012-12-01 13:28   ` Alexander Graf
2012-12-01 13:32     ` Alexander Graf
2012-10-11 16:13 ` [PATCH 06/12] KVM: PPC: Mask ea's high 32-bits in 32/64 instr emulation Mihai Caraman
2012-10-11 16:13 ` [PATCH 07/12] KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation Mihai Caraman
2012-10-11 16:13 ` [PATCH 08/12] KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit Mihai Caraman
2012-10-11 16:13 ` [PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery Mihai Caraman
2012-12-01 13:42   ` Alexander Graf
2012-10-11 16:13 ` Mihai Caraman [this message]
2012-12-01 13:59   ` [PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation Alexander Graf
2012-10-11 16:13 ` [PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs Mihai Caraman
2012-12-01 14:02   ` Alexander Graf
2012-10-11 16:13 ` [PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface Mihai Caraman
2012-12-01 14:15   ` Alexander Graf
2012-12-01 15:06 ` [PATCH 00/12] KVM: PPC: 64-bit Book3E arch support Alexander Graf

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=1349972009-23027-11-git-send-email-mihai.caraman@freescale.com \
    --to=mihai.caraman@freescale.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).