* [PATCH 5/6] kvmppc: rewrite guest code - mfmsr
@ 2008-09-16 6:27 ehrhardt
0 siblings, 0 replies; only message in thread
From: ehrhardt @ 2008-09-16 6:27 UTC (permalink / raw)
To: kvm-ppc
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-09-16 6:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-16 6:27 [PATCH 5/6] kvmppc: rewrite guest code - mfmsr ehrhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox