kvmppc: rewrite guest code - dear, esr, srr0, srr1
Subsystems (2)
PATCH 4/6 kvmppc: rewrite guest code - dear, esr, srr0, srr1
From: Christian Ehrhardt <[email protected]>
Interrupt delivery is usually followed by several exits to fetch e.g. dear, esr, srr0, srr1. To easen that this patch adds guest code rewriting using the magic page mechanism for these four special purpose registers. This patch rewrites reads and writes to this registers and also the kvm code in the interrupt delivery/ rfi path that writes/reads those. Since this patch is touching the dump_tlb and dump_vcpu functions it is fixing all the missing printk KERN_* levels avoiding checkpatch noise.
Signed-off-by Christian Ehrhardt <[email protected]>
---
[diffstat]
arch/powerpc/kvm/booke_guest.c | 43 ++++++++++++---- arch/powerpc/kvm/emulate.c | 107 +++++++++++++++++++++++++++++++++++++---- include/asm-powerpc/kvm_para.h | 4 + 3 files changed, 134 insertions(+), 20 deletions(-)
[diff]
arch/powerpc/kvm/booke_guest.c +33 -10
@@ -120,14 +120,14 @@struct tlbe *tlbe;int i; -printk ("vcpu %d TLB dump:\n" , vcpu->vcpu_id); -printk ("| %2s | %3s | %8s | %8s | %8s |\n" , +printk (KERN_ERR "vcpu %d TLB dump:\n" , vcpu->vcpu_id); +printk (KERN_ERR "| %2s | %3s | %8s | %8s | %8s |\n" ,"nr" ,"tid" ,"word0" ,"word1" ,"word2" );for (i =0 ; i < PPC44x_TLB_SIZE; i++) { tlbe = &vcpu->arch.guest_tlb[i];if (tlbe->word0 & PPC44x_TLB_VALID) -printk (" G%2d | %02X | %08X | %08X | %08X |\n" , +printk (KERN_ERR " G%2d | %02X | %08X | %08X | %08X |\n" , i, tlbe->tid, tlbe->word0, tlbe->word1, tlbe->word2); }
@@ -135,7 +135,7 @@for (i =0 ; i < PPC44x_TLB_SIZE; i++) { tlbe = &vcpu->arch.shadow_tlb[i];if (tlbe->word0 & PPC44x_TLB_VALID) -printk (" S%2d | %02X | %08X | %08X | %08X |\n" , +printk (KERN_ERR " S%2d | %02X | %08X | %08X | %08X |\n" , i, tlbe->tid, tlbe->word0, tlbe->word1, tlbe->word2); }
@@ -146,18 +146,28 @@ {int i; -printk ("pc: %08x msr: %08x\n" , vcpu->arch.pc, vcpu->arch.msr); -printk ("lr: %08x ctr: %08x\n" , vcpu->arch.lr, vcpu->arch.ctr); -printk ("srr0: %08x srr1: %08x\n" , vcpu->arch.srr0, vcpu->arch.srr1); +printk (KERN_ERR "pc: %08x msr: %08x\n" , + vcpu->arch.pc, vcpu->arch.msr); +printk (KERN_ERR "lr: %08x ctr: %08x\n" , + vcpu->arch.lr, vcpu->arch.ctr); +printk (KERN_ERR "srr0: %08x srr1: %08x\n" , + vcpu->arch.srr0, vcpu->arch.srr1);printk ("exceptions: %08lx\n" , vcpu->arch.pending_exceptions);for (i =0 ; i <32 ; i +=4 ) { -printk ("gpr%02d: %08x %08x %08x %08x\n" , i, +printk (KERN_ERR "gpr%02d: %08x %08x %08x %08x\n" , i, vcpu->arch.gpr[i], vcpu->arch.gpr[i+1 ], vcpu->arch.gpr[i+2 ], vcpu->arch.gpr[i+3 ]); + } + +if (kvmppc_has_pvmem (vcpu)) { +printk (KERN_ERR "vcpu has pvmem enabled\n" ); +printk (KERN_ERR "srr0: %08x srr1: %08x (PVMEM)\n" , +kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR0 ), +kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR1 )); } }
@@ -203,8 +213,17 @@break ; } - vcpu->arch.srr0 = vcpu->arch.pc; - vcpu->arch.srr1 = vcpu->arch.msr; +if (kvmppc_has_pvmem (vcpu)) { +kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR0 , vcpu->arch.pc); +kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR1 , vcpu->arch.msr); +/* only modified on interrupt delivery path */ +kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_DEAR , vcpu->arch.dear); +kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_ESR , vcpu->arch.esr); + }else { + vcpu->arch.srr0 = vcpu->arch.pc; + vcpu->arch.srr1 = vcpu->arch.msr; + } + vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[interrupt];kvmppc_set_msr (vcpu, vcpu->arch.msr & interrupt_msr_mask[interrupt]); }
@@ -549,6 +568,8 @@ regs->sprg1 =kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SPRG1 ); regs->sprg2 =kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SPRG2 ); regs->sprg3 =kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SPRG3 ); + regs->srr0 =kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR0 ); + regs->srr1 =kvmppc_get_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR1 ); }return 0 ;
@@ -582,6 +603,8 @@kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SPRG1 , regs->sprg1);kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SPRG2 , regs->sprg2);kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SPRG3 , regs->sprg3); +kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR0 , regs->srr0); +kvmppc_set_pvreg (vcpu,KVM_PPCPV_OFFSET_SRR1 , regs->srr1); }return 0 ;
arch/powerpc/kvm/emulate.c +97 -10
171 lines not on this page · raw message
include/asm-powerpc/kvm_para.h +4 -0
@@ -44,6 +44,10 @@#define KVM_PPCPV_OFFSET_SPRG1 0x04#define KVM_PPCPV_OFFSET_SPRG2 0x08#define KVM_PPCPV_OFFSET_SPRG3 0x0C +#define KVM_PPCPV_OFFSET_SRR0 0x10 +#define KVM_PPCPV_OFFSET_SRR1 0x14 +#define KVM_PPCPV_OFFSET_DEAR 0x18 +#define KVM_PPCPV_OFFSET_ESR 0x1Cstatic inline int kvm_para_available (void ) {