From patchwork Wed Jan 16 08:24:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 1986971 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0F6EF3FDD1 for ; Wed, 16 Jan 2013 08:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758743Ab3APIdF (ORCPT ); Wed, 16 Jan 2013 03:33:05 -0500 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:18402 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758739Ab3APIdD (ORCPT ); Wed, 16 Jan 2013 03:33:03 -0500 Received: from mail152-tx2-R.bigfish.com (10.9.14.254) by TX2EHSOBE012.bigfish.com (10.9.40.32) with Microsoft SMTP Server id 14.1.225.23; Wed, 16 Jan 2013 08:33:02 +0000 Received: from mail152-tx2 (localhost [127.0.0.1]) by mail152-tx2-R.bigfish.com (Postfix) with ESMTP id 589CF3800E1; Wed, 16 Jan 2013 08:33:02 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1ee6h1de0h1202h1e76h1d1ah1d2ah1082kzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h1155h) Received: from mail152-tx2 (localhost.localdomain [127.0.0.1]) by mail152-tx2 (MessageSwitch) id 1358325180179500_20044; Wed, 16 Jan 2013 08:33:00 +0000 (UTC) Received: from TX2EHSMHS033.bigfish.com (unknown [10.9.14.240]) by mail152-tx2.bigfish.com (Postfix) with ESMTP id 27999200046; Wed, 16 Jan 2013 08:33:00 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS033.bigfish.com (10.9.99.133) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 16 Jan 2013 08:32:59 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.318.3; Wed, 16 Jan 2013 08:32:59 +0000 Received: from freescale.com ([10.232.15.72]) by az84smr01.freescale.net (8.14.3/8.14.0) with SMTP id r0G8WtYS024110; Wed, 16 Jan 2013 01:32:56 -0700 Received: by freescale.com (sSMTP sendmail emulation); Wed, 16 Jan 2013 13:55:25 +0530 From: Bharat Bhushan To: , , CC: Bharat Bhushan Subject: [PATCH 8/8] KVM:PPC:booke: Allow debug interrupt injection to guest Date: Wed, 16 Jan 2013 13:54:45 +0530 Message-ID: <1358324685-30225-7-git-send-email-bharat.bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1358324685-30225-1-git-send-email-bharat.bhushan@freescale.com> References: <1358324685-30225-1-git-send-email-bharat.bhushan@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Allow userspace to inject debug interrupt to guest. QEMU can inject the debug interrupt to guest if it is not able to handle the debug interrupt. Signed-off-by: Bharat Bhushan --- arch/powerpc/kvm/booke.c | 32 +++++++++++++++++++++++++++++++- arch/powerpc/kvm/e500mc.c | 10 +++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index faa0a0b..547797f 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -133,6 +133,13 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu *vcpu) #endif } +#ifdef CONFIG_KVM_BOOKE_HV +static int kvmppc_core_pending_debug(struct kvm_vcpu *vcpu) +{ + return test_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions); +} +#endif + /* * Helper function for "full" MSR writes. No need to call this if only * EE/CE/ME/DE/RI are changing. @@ -144,7 +151,11 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) #ifdef CONFIG_KVM_BOOKE_HV new_msr |= MSR_GS; - if (vcpu->guest_debug) + /* + * Set MSR_DE if the hardware debug resources are owned by user-space + * and there is no debug interrupt pending for guest to handle. + */ + if (vcpu->guest_debug && !kvmppc_core_pending_debug(vcpu)) new_msr |= MSR_DE; #endif @@ -234,6 +245,16 @@ static void kvmppc_core_dequeue_watchdog(struct kvm_vcpu *vcpu) clear_bit(BOOKE_IRQPRIO_WATCHDOG, &vcpu->arch.pending_exceptions); } +static void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu) +{ + kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DEBUG); +} + +static void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu) +{ + clear_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions); +} + static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1) { #ifdef CONFIG_KVM_BOOKE_HV @@ -1278,6 +1299,7 @@ static void get_sregs_base(struct kvm_vcpu *vcpu, sregs->u.e.dec = kvmppc_get_dec(vcpu, tb); sregs->u.e.tb = tb; sregs->u.e.vrsave = vcpu->arch.vrsave; + sregs->u.e.dbsr = vcpu->arch.dbsr; } static int set_sregs_base(struct kvm_vcpu *vcpu, @@ -1310,6 +1332,14 @@ static int set_sregs_base(struct kvm_vcpu *vcpu, update_timer_ints(vcpu); } + if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_DBSR) { + vcpu->arch.dbsr = sregs->u.e.dbsr; + if (vcpu->arch.dbsr) + kvmppc_core_queue_debug(vcpu); + else + kvmppc_core_dequeue_debug(vcpu); + } + return 0; } diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c index 81abe92..7d90622 100644 --- a/arch/powerpc/kvm/e500mc.c +++ b/arch/powerpc/kvm/e500mc.c @@ -208,7 +208,7 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); sregs->u.e.features |= KVM_SREGS_E_ARCH206_MMU | KVM_SREGS_E_PM | - KVM_SREGS_E_PC; + KVM_SREGS_E_PC | KVM_SREGS_E_ED; sregs->u.e.impl_id = KVM_SREGS_E_IMPL_FSL; sregs->u.e.impl.fsl.features = 0; @@ -216,6 +216,9 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) sregs->u.e.impl.fsl.hid0 = vcpu_e500->hid0; sregs->u.e.impl.fsl.mcar = vcpu_e500->mcar; + sregs->u.e.dsrr0 = vcpu->arch.dsrr0; + sregs->u.e.dsrr1 = vcpu->arch.dsrr1; + kvmppc_get_sregs_e500_tlb(vcpu, sregs); sregs->u.e.ivor_high[3] = @@ -256,6 +259,11 @@ int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) sregs->u.e.ivor_high[5]; } + if (sregs->u.e.features & KVM_SREGS_E_ED) { + vcpu->arch.dsrr0 = sregs->u.e.dsrr0; + vcpu->arch.dsrr1 = sregs->u.e.dsrr1; + } + return kvmppc_set_sregs_ivor(vcpu, sregs); }