kvmppc: rewrite guest code - mfmsr
Subsystems (2)
PATCH 5/6 kvmppc: rewrite guest code - mfmsr
From: Christian Ehrhardt <[email protected]>
This adds another guest code rewrite support replacing the mfmsr instructions using the magic page mechanism.
Signed-off-by Christian Ehrhardt <[email protected]>
---
[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]
arch/powerpc/kvm/emulate.c +19 -1
@@ -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 */
include/asm-powerpc/kvm_para.h +1 -0
@@ -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 0x20static inline int kvm_para_available (void ) {
include/asm-powerpc/kvm_ppc.h +3 -0
@@ -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);