From patchwork Fri Feb 24 14:26:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 142856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 09DFFB6FE9 for ; Sat, 25 Feb 2012 01:26:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755890Ab2BXO0q (ORCPT ); Fri, 24 Feb 2012 09:26:46 -0500 Received: from cantor2.suse.de ([195.135.220.15]:42513 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755598Ab2BXO0j (ORCPT ); Fri, 24 Feb 2012 09:26:39 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 36F4293E50; Fri, 24 Feb 2012 15:26:33 +0100 (CET) From: Alexander Graf To: kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Scott Wood Subject: [PATCH 36/37] KVM: PPC: booke: expose guest registers on irq reinject Date: Fri, 24 Feb 2012 15:26:30 +0100 Message-Id: <1330093591-19523-37-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1330093591-19523-1-git-send-email-agraf@suse.de> References: <1330093591-19523-1-git-send-email-agraf@suse.de> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org When reinjecting an interrupt into the host interrupt handler after we're back in host kernel land, let's tell the kernel about all the guest state that the interrupt happened at. This helps getting reasonable numbers out of perf. Signed-off-by: Alexander Graf --- arch/powerpc/kvm/booke.c | 54 +++++++++++++++++++++++++++++++++------------ 1 files changed, 39 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 423701b..709fd45 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -593,37 +593,61 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu) } } -/** - * kvmppc_handle_exit - * - * Return value is in the form (errcode<<2 | RESUME_FLAG_HOST | RESUME_FLAG_NV) - */ -int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, - unsigned int exit_nr) +static void kvmppc_fill_pt_regs(struct kvm_vcpu *vcpu, struct pt_regs *regs) { - int r = RESUME_HOST; + int i; - /* update before a new last_exit_type is rewritten */ - kvmppc_update_timing_stats(vcpu); + for (i = 0; i < 32; i++) + regs->gpr[i] = kvmppc_get_gpr(vcpu, i); + regs->nip = vcpu->arch.pc; + regs->msr = vcpu->arch.shared->msr; + regs->ctr = vcpu->arch.ctr; + regs->link = vcpu->arch.lr; + regs->xer = kvmppc_get_xer(vcpu); + regs->ccr = kvmppc_get_cr(vcpu); + regs->dar = get_guest_dear(vcpu); + regs->dsisr = get_guest_esr(vcpu); +} + +static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, + unsigned int exit_nr) +{ + struct pt_regs regs = *current->thread.regs; + kvmppc_fill_pt_regs(vcpu, ®s); switch (exit_nr) { case BOOKE_INTERRUPT_EXTERNAL: - do_IRQ(current->thread.regs); + do_IRQ(®s); break; - case BOOKE_INTERRUPT_DECREMENTER: - timer_interrupt(current->thread.regs); + timer_interrupt(®s); break; - #if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3E_64) case BOOKE_INTERRUPT_DOORBELL: - doorbell_exception(current->thread.regs); + doorbell_exception(®s); break; #endif case BOOKE_INTERRUPT_MACHINE_CHECK: /* FIXME */ break; } +} + +/** + * kvmppc_handle_exit + * + * Return value is in the form (errcode<<2 | RESUME_FLAG_HOST | RESUME_FLAG_NV) + */ +int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, + unsigned int exit_nr) +{ + int r = RESUME_HOST; + + /* update before a new last_exit_type is rewritten */ + kvmppc_update_timing_stats(vcpu); + + /* restart interrupts if they were meant for the host */ + kvmppc_restart_interrupt(vcpu, exit_nr); local_irq_enable();