mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
target/riscv: Check nanboxed inputs to fp helpers
If a 32-bit input is not properly nanboxed, then the input is replaced with the default qnan. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com> Message-Id: <20200724002807.441147-5-richard.henderson@linaro.org> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
40eaa47361
commit
00e925c560
2 changed files with 57 additions and 18 deletions
|
@ -43,4 +43,15 @@ static inline uint64_t nanbox_s(float32 f)
|
|||
return f | MAKE_64BIT_MASK(32, 32);
|
||||
}
|
||||
|
||||
static inline float32 check_nanbox_s(uint64_t f)
|
||||
{
|
||||
uint64_t mask = MAKE_64BIT_MASK(32, 32);
|
||||
|
||||
if (likely((f & mask) == mask)) {
|
||||
return (uint32_t)f;
|
||||
} else {
|
||||
return 0x7fc00000u; /* default qnan */
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue