[PATCH 5/6] kvmppc: rewrite guest code - mfmsr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christian Ehrhardt <ehrhardt@xxxxxxxxxxxxxxxxxx>

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

Signed-off-by: Christian Ehrhardt <ehrhardt@xxxxxxxxxxxxxxxxxx>
---

[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);
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux