Received: from [140.186.70.92] (port=57450 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkEhA-0008Mc-R3 for qemu-devel@nongnu.org; Tue, 01 Feb 2011 06:47:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PkEh6-0008Gl-8y for qemu-devel@nongnu.org; Tue, 01 Feb 2011 06:46:52 -0500 Received: from cantor.suse.de ([195.135.220.2]:34137 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PkEh5-0008FA-VO for qemu-devel@nongnu.org; Tue, 01 Feb 2011 06:46:48 -0500 Subject: Re: [Qemu-devel] [PATCH 0/4] new Blackfin QEMU port Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: Date: Tue, 1 Feb 2011 12:46:44 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <6ADF7310-2588-4FD5-BA21-2A31456B3E2B@suse.de> References: <1295864581-13494-1-git-send-email-vapier@gentoo.org> <20110131140054.GA24608@edde.se.axis.com> <929A8BC2-BC8C-459D-96C0-FF8E9C1BF5FD@suse.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "Edgar E. Iglesias" , Mike Frysinger , toolchain-devel@blackfin.uclinux.org, qemu-devel@nongnu.org On 01.02.2011, at 11:31, Peter Maydell wrote: > On 1 February 2011 09:38, Alexander Graf wrote: >> On 01.02.2011, at 05:19, Mike Frysinger wrote: >>> On Mon, Jan 31, 2011 at 09:00, Edgar E. Iglesias wrote: >>>> * cpu_get_tb_cpu_state() doesn't define any tb flags? >>>=20 >>> no idea what this func is supposed to do >>=20 >> Qemu uses the tb flags as identifier for a translation block. >> So a tb is only reused, when the physical address, flags and >> code segment (x86 thing) are equal. >=20 > Put another way, when you are generating code, if the code > you generate will change based on the contents of something > in the CPUState struct, then the bit of CPUState you are > looking at has to be one of: > (1) encoded in the TB flags > (as Alexander says, "is CPU in privileged mode" > is a popular choice) > (2) always constant for the life of the simulation > (eg env->features if you have some sort of > "target feature support" flags) > (3) specially handled so that when it changes then > all TBs or at least all affected TBs are flushed > (env->breakpoints is in this category) >=20 > ...because the CPUState you're passed in is not guaranteed > to be the state of the CPU at the PC which you are starting > translation from. >=20 > Otherwise you have case > (4) a very hard to track down bug (qemu will in some > cases ask you to retranslate a block and if you don't > generate binary-identical output the second time around > things will go badly wrong) >=20 > So for instance here: >=20 > +static void gen_hwloop_check(DisasContext *dc) > +{ > + bool loop1, loop0; > + int endl; > + > + loop1 =3D (dc->pc =3D=3D dc->env->lbreg[1]); > + loop0 =3D (dc->pc =3D=3D dc->env->lbreg[0]); >=20 > I suspect that this check of pc against the lbreg[] > values should be being done in the generated code, > not at translate time. Ouch. Yes. General rule: never access env from translate.c :). If you = need to check for anything, go through the tb flags. Or generate inline = code that does the checks. Thanks for the nice explanation Peter :) Alex