From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LeOnk-0006YL-UT for qemu-devel@nongnu.org; Tue, 03 Mar 2009 02:12:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LeOnj-0006Xi-Bm for qemu-devel@nongnu.org; Tue, 03 Mar 2009 02:12:28 -0500 Received: from [199.232.76.173] (port=45787 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LeOnj-0006Xf-4q for qemu-devel@nongnu.org; Tue, 03 Mar 2009 02:12:27 -0500 Received: from soufre.accelance.net ([213.162.48.15]:52579) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LeOni-0004Xi-O5 for qemu-devel@nongnu.org; Tue, 03 Mar 2009 02:12:26 -0500 Subject: Re: [Qemu-devel] [PATCH] SH4: Fixed last UTLB unused From: Lionel Landwerlin In-Reply-To: <20090303061525.GC5159@volta.aurel32.net> References: <1234824063.8648.6.camel@cocoduo.atr> <1235229695.8648.17.camel@cocoduo.atr> <1235261137.8648.18.camel@cocoduo.atr> <20090303061525.GC5159@volta.aurel32.net> Content-Type: text/plain; charset=UTF-8 Date: Tue, 03 Mar 2009 08:12:57 +0100 Message-Id: <1236064377.4975.26.camel@coalu.atr> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Aurelien Jarno Le mardi 03 mars 2009 =C3=A0 07:15 +0100, Aurelien Jarno a =C3=A9crit : > On Sun, Feb 22, 2009 at 01:05:37AM +0100, Lionel Landwerlin wrote: > > Still not happy with the fix ... > >=20 > > Signed-off-by: Lionel Landwerlin > > --- > > target-sh4/helper.c | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) >=20 > Sorry I missed this one when committing the first patch. I have applied > it on top of it. >=20 > > diff --git a/target-sh4/helper.c b/target-sh4/helper.c > > index cd0f392..8498d3f 100644 > > --- a/target-sh4/helper.c > > +++ b/target-sh4/helper.c > > @@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) > > urb =3D ((env->mmucr) >> 18) & 0x3f; > > urc =3D ((env->mmucr) >> 10) & 0x3f; > > urc++; > > - if (urc =3D=3D urb || urc =3D=3D UTLB_SIZE - 1) > > + if (urc > urb || urc > (UTLB_SIZE - 1)) > > urc =3D 0; > > env->mmucr =3D (env->mmucr & 0xffff03ff) | (urc << 10); > > } > > --=20 > > 1.5.6.5 Hi Aurelien, Thanks for applying my patches, but even with this version, I was still missing the real condition (according to SH4 datasheet) : Random counter for indicating the UTLB entry for which replacement is to be performed with an LDTLB instruction. URC is incremented each time the UTLB is accessed. When URB > 0, URC is reset to 0 when the condition URC =3D URB occurs. Also note that, if a value is written to URC by software which results in the condition URC > URB, incrementing is first performed in excess of URB until URC =3D 0x3F. URC is not incremented by an LDTLB instruction. =20 So the final version is : [PATCH] SH4: Fixed last UTLB unused and URB/URC management Signed-off-by: Lionel Landwerlin --- target-sh4/helper.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target-sh4/helper.c b/target-sh4/helper.c index cd0f392..54a3f1f 100644 --- a/target-sh4/helper.c +++ b/target-sh4/helper.c @@ -297,7 +297,7 @@ static int same_tlb_entry_exists(const tlb_t * haystack, uint8_t nbtlb, return 0; } =20 static void increment_urc(CPUState * env) { uint8_t urb, urc; =20 @@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb =3D ((env->mmucr) >> 18) & 0x3f; urc =3D ((env->mmucr) >> 10) & 0x3f; urc++; - if (urc =3D=3D urb || urc =3D=3D UTLB_SIZE - 1) + if ((urb > 0 && urc > urb) || urc > (UTLB_SIZE - 1)) urc =3D 0; env->mmucr =3D (env->mmucr & 0xffff03ff) | (urc << 10); } --=20 1.5.6.5 Sorry for that mistake. --=20 Lionel Landwerlin