2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-18 23:54:26 +08:00
linux-next/include/math-emu
Mikael Pettersson f8324e20f8 math-emu: correct test for downshifting fraction in _FP_FROM_INT()
The kernel's math-emu code contains a macro _FP_FROM_INT() which is
used to convert an integer to a raw normalized floating-point value.
It does this basically in three steps:

1. Compute the exponent from the number of leading zero bits.
2. Downshift large fractions to put the MSB in the right position
   for normalized fractions.
3. Upshift small fractions to put the MSB in the right position.

There is an boundary error in step 2, causing a fraction with its
MSB exactly one bit above the normalized MSB position to not be
downshifted.  This results in a non-normalized raw float, which when
packed becomes a massively inaccurate representation for that input.

The impact of this depends on a number of arch-specific factors,
but it is known to have broken emulation of FXTOD instructions
on UltraSPARC III, which was originally reported as GCC bug 44631
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44631>.

Any arch which uses math-emu to emulate conversions from integers to
same-size floats may be affected.

The fix is simple: the exponent comparison used to determine if the
fraction should be downshifted must be "<=" not "<".

I'm sending a kernel module to test this as a reply to this message.
There are also SPARC user-space test cases in the GCC bug entry.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-07-20 18:45:14 -07:00
..
double.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
op-1.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
op-2.h math-emu: Fix compiler warnings 2008-09-16 10:01:37 -05:00
op-4.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
op-8.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
op-common.h math-emu: correct test for downshifting fraction in _FP_FROM_INT() 2010-07-20 18:45:14 -07:00
quad.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
single.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
soft-fp.h math-emu: Add support for reporting exact invalid exception 2008-09-16 10:01:37 -05:00