aboutsummaryrefslogtreecommitdiff
path: root/target/i386/fpu_helper.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2020-05-13 23:50:19 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-10 12:10:24 -0400
commit34b9cc076ff423023a779a04a9f7cd7c17372cbf (patch)
treeda8938f804746da92052eebfe180c67b473d885a /target/i386/fpu_helper.c
parent80b4008c805ebcfd4c0d302ac31c1689e34571e0 (diff)
downloadqemu-34b9cc076ff423023a779a04a9f7cd7c17372cbf.zip
qemu-34b9cc076ff423023a779a04a9f7cd7c17372cbf.tar.gz
qemu-34b9cc076ff423023a779a04a9f7cd7c17372cbf.tar.bz2
target/i386: fix fxam handling of invalid encodings
The fxam implementation does not check for invalid encodings, instead treating them like NaN or normal numbers depending on the exponent. Fix it to check that the high bit of the significand is set before treating an encoding as NaN or normal, thus resulting in correct handling (all of C0, C2 and C3 cleared) for invalid encodings. Signed-off-by: Joseph Myers <joseph@codesourcery.com> Message-Id: <alpine.DEB.2.21.2005132349311.11687@digraph.polyomino.org.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/fpu_helper.c')
-rw-r--r--target/i386/fpu_helper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c
index f0b9cb5..185493d 100644
--- a/target/i386/fpu_helper.c
+++ b/target/i386/fpu_helper.c
@@ -1099,7 +1099,7 @@ void helper_fxam_ST0(CPUX86State *env)
if (expdif == MAXEXPD) {
if (MANTD(temp) == 0x8000000000000000ULL) {
env->fpus |= 0x500; /* Infinity */
- } else {
+ } else if (MANTD(temp) & 0x8000000000000000ULL) {
env->fpus |= 0x100; /* NaN */
}
} else if (expdif == 0) {
@@ -1108,7 +1108,7 @@ void helper_fxam_ST0(CPUX86State *env)
} else {
env->fpus |= 0x4400; /* Denormal */
}
- } else {
+ } else if (MANTD(temp) & 0x8000000000000000ULL) {
env->fpus |= 0x400;
}
}