From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRcSU-0004wk-AA for qemu-devel@nongnu.org; Mon, 25 Jul 2016 05:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRcSS-0004Da-7i for qemu-devel@nongnu.org; Mon, 25 Jul 2016 05:45:57 -0400 Message-ID: <1469439886.5978.31.camel@kernel.crashing.org> From: Benjamin Herrenschmidt Date: Mon, 25 Jul 2016 19:44:46 +1000 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] ppc: TCG and FP exceptions, is it right ? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: David Gibson , Paul Mackerras , Anton Blanchard , Fabien Chouteau , Tristan Gingold , Richard Henderson Hi folks ! I could use a bit of help determining if something is quite right in TCG emulation of FP ops. Fabien, Tristan, you submitted a patch back in 2013: db72c9f256ae70b30c5d5985234f085df4226c55 "powerpc: correctly handle fpu exceptions" which effectively makes any of the exceptions generated for underflow, overflow and inexact fire right away (helper_raise_exception_err will exit the cpu loop with a setjmp). This makes them effectively do the same thing as=C2=A0float_zero_divide_excp(). However I *think* it might not be what we want, according to the comment in=C2=A0helper_float_check_status() that says =C2=A0/* Differred floating-point exception after target FPR update */ And according to the architecture definition for those exceptions, where we indeed want the target FPR updated before we take the interrupts. The code as writte will take the exception before the FPR is updated, I *think*, or am I missing something here =C2=A0? I think the intent was to return to the translated code so the FPRons update happen, though we ideally would need to also set some state so the translated code itself can then check for an exception and fire it. However as you noticed, that doesn't work well either. What do you think is the most appropriate implementation here? I'm thinking it's almost worth bringing FE0/FE1 into the hflags so that we know at translation time whether to be precise, imprecise, or ignore FP exceptions. Then we could do something along the lines of: =C2=A0 =C2=A0 - In the helpers, when checking status, set an env flag if an exception should occur. =C2=A0 - In all the translate call sites, if FE0/1 is non-0 (at translate time), generate call to check that flag and shoot the exception =C2=A0 - Optionally, we could even implement some smarts to defer this to the end of a TB in imprecise mode. An additional note is that if FE0/FE1 are 0, we still in some case leave an exception behind in cs->exception_index. Now, I *think* that's ok, it will just be silently dropped at some point, but I am not 100% certain as that's a part of TCG I'm an not super familiar with yet. What do you guys reckon ? I am missing something here ? Cheers, Ben.