From patchwork Thu Jan 31 19:20:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 217245 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 6C8002C008E for ; Fri, 1 Feb 2013 06:20:52 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753401Ab3AaTUv (ORCPT ); Thu, 31 Jan 2013 14:20:51 -0500 Received: from cantor2.suse.de ([195.135.220.15]:52390 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753858Ab3AaTUu convert rfc822-to-8bit (ORCPT ); Thu, 31 Jan 2013 14:20:50 -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 8A06EA3A49; Thu, 31 Jan 2013 20:20:49 +0100 (CET) Subject: Re: [PATCH 8/8] KVM:PPC:booke: Allow debug interrupt injection to guest Mime-Version: 1.0 (Apple Message framework v1278) From: Alexander Graf In-Reply-To: <3BC09F64-2F11-4494-85CA-25D5FFC0D959@suse.de> Date: Thu, 31 Jan 2013 20:20:39 +0100 Cc: Bhushan Bharat-R65777 , "kvm-ppc@vger.kernel.org" , "kvm@vger.kernel.org" Message-Id: <16DEE4DC-E963-49FB-B211-810D1068E6C4@suse.de> References: <1359657795.31540.5@snotra> <1A30DCCA-FCBA-4D0A-918E-12B529028DA4@suse.de> <1359658473.31540.8@snotra> <3BC09F64-2F11-4494-85CA-25D5FFC0D959@suse.de> To: Scott Wood X-Mailer: Apple Mail (2.1278) Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org On 31.01.2013, at 20:05, Alexander Graf wrote: > > On 31.01.2013, at 19:54, Scott Wood wrote: > >> On 01/31/2013 12:52:41 PM, Alexander Graf wrote: >>> On 31.01.2013, at 19:43, Scott Wood wrote: >>>> On 01/31/2013 12:21:07 PM, Alexander Graf wrote: >>>>> How about something like this? Then both targets at least suck as much :). >>>> >>>> I'm not sure that should be the goal... >>>> >>>>> Thanks to e500mc's awful hardware design, we don't know who sets the MSR_DE bit. Once we forced it onto the guest, we have no change to know whether the guest also set it or not. We could only guess. >>>> >>>> MSRP[DEP] can prevent the guest from modifying MSR[DE] -- but we still need to set it in the first place. >>>> >>>> According to ISA V2.06B, the hypervisor should set DBCR0[EDM] to let the guest know that the debug resources are not available, and that "the value of MSR[DE] is not specified and not modifiable". >>> So what would the guest do then to tell the hypervisor that it actually wants to know about debug events? >> >> The guest is out of luck, just as if a JTAG were in use. > > Hrm. > > Can we somehow generalize this "out of luck" behavior? > > Every time we would set or clear an MSR bit in shadow_msr on e500v2, we would instead set or clear it in the real MSR. That way only e500mc is out of luck, but the code would still be shared. Something like this. We could also define a SHADOW_MSR(vcpu) macro to hide the glorious details, but I think this way it's easier to understand what's going on. Alex To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 38a62ef..9bdb845 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -133,6 +133,29 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu *vcpu) #endif } +static void kvmppc_vcpu_sync_debug(struct kvm_vcpu *vcpu) +{ + u32 is_debug = vcpu->arch.shared->msr & MSR_DE; + + /* Force debug to on in guest space when user space wants to debug */ + if (vcpu->guest_debug) + is_debug = MSR_DE; + +#ifdef CONFIG_KVM_BOOKE_HV + /* + * Since there is no shadow MSR, sync MSR_DE into the guest + * visible MSR. + */ + vcpu->arch.shared->msr &= ~MSR_DE; + vcpu->arch.shared->msr |= is_debug; +#endif + +#ifndef CONFIG_KVM_BOOKE_HV + vcpu->arch.shadow_msr &= ~MSR_DE; + vcpu->arch.shadow_msr |= is_debug; +#endif +} + /* * Helper function for "full" MSR writes. No need to call this if only * EE/CE/ME/DE/RI are changing. @@ -150,6 +173,7 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) kvmppc_mmu_msr_notify(vcpu, old_msr); kvmppc_vcpu_sync_spe(vcpu); kvmppc_vcpu_sync_fpu(vcpu); + kvmppc_vcpu_sync_debug(vcpu); } static void kvmppc_booke_queue_irqprio(struct kvm_vcpu *vcpu,--