Open jim-wilson opened 5 years ago
There is a closely related bug here. If one of the input values to a single float instruction is not NaN boxed, then the result must be a canonical NaN. Qemu gets this wrong also. Found while trying to debug a different gdb bug.
Hi is this still open im new to this project but would like to help out
Just submitted a PR for this
In translate.c, there is explicit code to NaN box the result of FLW. However, there is no equivalent code for any of the FP arithmetic instructions, add, sub, mul, div, etc. They all should produce NaN boxed results also. Likewise the conversion instructions that produce single float results. This was noticed while testing linux kernel ptrace support for FP registers in gdb running on system qemu. I can see that the raw FP values are wrong after an operation. This is probably hard to notice otherwise, you would have to have broken code that performs single float operations and then tries to read the results as double float.
(gdb) 0x0000000000010462 6 return a + b; 1: x/i $pc => 0x10462 <sub+22>: fadd.s fa5,fa4,fa5 (gdb) print $fa4 $1 = -nan(0xfffff3fc00000) (gdb) print $fa5 $2 = -nan(0xfffff40200000) (gdb) stepi 7 } 1: x/i $pc => 0x10466 <sub+26>: fmv.s fa0,fa5 (gdb) print $fa5 $3 = 5.3464347077054713e-315 (gdb)
info all-registers shows fa4 -nan(0xfffff3fc00000) (raw 0xffffffff3fc00000) fa5 5.3464347077054713e-315 (raw 0x0000000040800000)