From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Herrenschmidt Date: Sat, 10 Oct 2009 23:14:17 +0000 Subject: Re: [PATCH 16/27] Add desktop PowerPC specific emulation Message-Id: <1255216457.2192.16.camel@pasglop> List-Id: References: <1254212303-8737-17-git-send-email-agraf@suse.de> In-Reply-To: <1254212303-8737-17-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-ppc@vger.kernel.org On Fri, 2009-10-09 at 13:57 -0700, Hollis Blanchard wrote: > > +#ifdef CONFIG_PPC64 > > +#ifdef DEBUG_EMUL > > + printk(KERN_INFO "mtDEC: %x\n", vcpu->arch.dec); > > +#endif > > + /* POWER4+ triggers a dec interrupt if the value is < 0 */ > > + if (vcpu->arch.dec & 0x80000000) { > > + del_timer(&vcpu->arch.dec_timer); > > + kvmppc_core_queue_dec(vcpu); > > + } > > + else if (true) { > > +#else > > if (vcpu->arch.tcr & TCR_DIE) { > > +#endif > > /* The decrementer ticks at the same rate as the timebase, so > > * that's how we convert the guest DEC value to the number of > > * host ticks. */ > > Ifdefs through the middle of control syntax makes my head hurt. :) Note that your original BookE DEC emulation looks fishy :-) I may have missed something in your code... but I don't think it emulates the expected HW behaviour: Basically, when the BookE DEC hits the 1 -> 0 transition it latches an event in TSE:DIS always, whether TCR:DIE is set or not. If DIE is not set, the interrupt is sent. It will then stop counting if auto-reload isn't enabled. That means that if TSR:DIS is set from a previous event while TCR:DIE is clear, then setting TCR:DIE (with MSR:EE enabled of course) will trigger a DEC interrupt on BookE. The BookE DEC interrupt is basically a level sensitive thing sourced from to (TSR:DIS && TCR:DIE), and TSR:DIS remains set until explicitely cleared. Cheers, Ben.