Kernel KVM-PPC virtualization development
 help / color / mirror / Atom feed
From: ehrhardt@linux.vnet.ibm.com
To: kvm-ppc@vger.kernel.org
Subject: [PATCH 5/6] kvmppc: rewrite guest code - mfmsr
Date: Tue, 16 Sep 2008 06:27:54 +0000	[thread overview]
Message-ID: <1221546475-15818-6-git-send-email-ehrhardt@linux.vnet.ibm.com> (raw)

From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

This adds another guest code rewrite support replacing the mfmsr instructions
using the magic page mechanism.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---

[diffstat]
 arch/powerpc/kvm/emulate.c     |   20 +++++++++++++++++++-
 include/asm-powerpc/kvm_para.h |    1 +
 include/asm-powerpc/kvm_ppc.h  |    3 +++
 3 files changed, 23 insertions(+), 1 deletion(-)

[diff]

diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -279,6 +279,8 @@
 					vcpu->arch.dear);
 		kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_ESR,
 					vcpu->arch.esr);
+		kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_MSR,
+					vcpu->arch.msr);
 		break;
 	default:
 		printk(KERN_ERR "unknown hypercall %d\n", vcpu->arch.gpr[11]);
@@ -304,6 +306,10 @@
 	switch (get_op(inst)) {
 	case 31:
 		switch (get_xop(inst)) {
+		case 83:                                       /* mfmsr */
+			rw = KVM_PPCPV_PVMEM_READ;
+			offset = KVM_PPCPV_OFFSET_MSR;
+			break;
 		case 339:                                       /* mfspr */
 			sprn = get_sprn(inst);
 			rw = KVM_PPCPV_PVMEM_READ;
@@ -445,6 +451,11 @@
 	switch (get_op(inst)) {
 	case 31:
 		switch (get_xop(inst)) {
+		case 83:                                        /* mfmsr */
+			rt = get_rt(inst);
+			vcpu->arch.gpr[rt] = kvmppc_get_pvreg(vcpu,
+						KVM_PPCPV_OFFSET_MSR);
+			break;
 		case 339:                                       /* mfspr */
 			sprn = get_sprn(inst);
 			rt = get_rt(inst);
@@ -602,6 +613,7 @@
 		case 83:                                        /* mfmsr */
 			rt = get_rt(inst);
 			vcpu->arch.gpr[rt] = vcpu->arch.msr;
+			rewritable = 1;
 			break;
 
 		case 87:                                        /* lbzx */
@@ -613,6 +625,9 @@
 			rs = get_rs(inst);
 			vcpu->arch.msr = (vcpu->arch.msr & ~MSR_EE)
 			                 | (vcpu->arch.gpr[rs] & MSR_EE);
+			if (kvmppc_has_pvmem(vcpu))
+				kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_MSR,
+							vcpu->arch.msr);
 			break;
 
 		case 146:                                       /* mtmsr */
@@ -629,7 +644,10 @@
 
 		case 163:                                       /* wrteei */
 			vcpu->arch.msr = (vcpu->arch.msr & ~MSR_EE)
-			                 | (inst & MSR_EE);
+					| (inst & MSR_EE);
+			if (kvmppc_has_pvmem(vcpu))
+				kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_MSR,
+							vcpu->arch.msr);
 			break;
 
 		case 215:                                       /* stbx */
diff --git a/include/asm-powerpc/kvm_para.h b/include/asm-powerpc/kvm_para.h
--- a/include/asm-powerpc/kvm_para.h
+++ b/include/asm-powerpc/kvm_para.h
@@ -48,6 +48,7 @@
 #define KVM_PPCPV_OFFSET_SRR1	0x14
 #define KVM_PPCPV_OFFSET_DEAR	0x18
 #define KVM_PPCPV_OFFSET_ESR	0x1C
+#define KVM_PPCPV_OFFSET_MSR	0x20
 
 static inline int kvm_para_available(void)
 {
diff --git a/include/asm-powerpc/kvm_ppc.h b/include/asm-powerpc/kvm_ppc.h
--- a/include/asm-powerpc/kvm_ppc.h
+++ b/include/asm-powerpc/kvm_ppc.h
@@ -28,6 +28,7 @@
 #include <linux/types.h>
 #include <linux/kvm_types.h>
 #include <linux/kvm_host.h>
+#include <linux/kvm_para.h>
 
 struct kvm_tlb {
 	struct tlbe guest_tlb[PPC44x_TLB_SIZE];
@@ -88,6 +89,8 @@
 		kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR);
 
 	vcpu->arch.msr = new_msr;
+	if (kvmppc_has_pvmem(vcpu))
+		kvmppc_set_pvreg(vcpu, KVM_PPCPV_OFFSET_MSR, vcpu->arch.msr);
 
 	if (vcpu->arch.msr & MSR_WE)
 		kvm_vcpu_block(vcpu);

                 reply	other threads:[~2008-09-16  6:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1221546475-15818-6-git-send-email-ehrhardt@linux.vnet.ibm.com \
    --to=ehrhardt@linux.vnet.ibm.com \
    --cc=kvm-ppc@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