qemu/target/i386
Joseph Myers 975af797f1 target/i386: fix IEEE x87 floating-point exception raising
Most x87 instruction implementations fail to raise the expected IEEE
floating-point exceptions because they do nothing to convert the
exception state from the softfloat machinery into the exception flags
in the x87 status word.  There is special-case handling of division to
raise the divide-by-zero exception, but that handling is itself buggy:
it raises the exception in inappropriate cases (inf / 0 and nan / 0,
which should not raise any exceptions, and 0 / 0, which should raise
"invalid" instead).

Fix this by converting the floating-point exceptions raised during an
operation by the softfloat machinery into exceptions in the x87 status
word (passing through the existing fpu_set_exception function for
handling related to trapping exceptions).  There are special cases
where some functions convert to integer internally but exceptions from
that conversion are not always correct exceptions for the instruction
to raise.

There might be scope for some simplification if the softfloat
exception state either could always be assumed to be in sync with the
state in the status word, or could always be ignored at the start of
each instruction and just set to 0 then; I haven't looked into that in
detail, and it might run into interactions with the various ways the
emulation does not yet handle trapping exceptions properly.  I think
the approach taken here, of saving the softfloat state, setting
exceptions there to 0 and then merging the old exceptions back in
after carrying out the operation, is conservatively safe.

Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Message-Id: <alpine.DEB.2.21.2005152120280.3469@digraph.polyomino.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-06-10 12:10:51 -04:00
..
hvf i386: Remove unused define's from hax and hvf 2020-06-10 12:10:47 -04:00
arch_dump.c
arch_memory_mapping.c
bpt_helper.c
cc_helper_template.h
cc_helper.c
cpu-param.h
cpu-qom.h cpu: Use DeviceClass reset instead of a special CPUClass reset 2020-03-17 19:48:10 -04:00
cpu.c target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES 2020-06-10 12:10:47 -04:00
cpu.h target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES 2020-06-10 12:10:47 -04:00
excp_helper.c
fpu_helper.c target/i386: fix IEEE x87 floating-point exception raising 2020-06-10 12:10:51 -04:00
gdbstub.c gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb 2020-04-15 11:38:23 +01:00
hax-all.c hax: Dynamic allocate vcpu state structure 2020-06-10 12:09:59 -04:00
hax-i386.h i386: Remove unused define's from hax and hvf 2020-06-10 12:10:47 -04:00
hax-interface.h
hax-mem.c
hax-posix.c i386: Fix GCC warning with snprintf when HAX is enabled 2020-03-16 23:02:24 +01:00
hax-posix.h
hax-windows.c hax: Windows doesn't like posix device names 2020-04-14 10:37:42 -04:00
hax-windows.h
helper.c
helper.h
hyperv-proto.h
hyperv-stub.c
hyperv.c
hyperv.h
int_helper.c
kvm_i386.h target/i386: kvm: initialize feature MSRs very early 2020-01-24 20:59:09 +01:00
kvm-stub.c
kvm.c target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES 2020-06-10 12:10:47 -04:00
machine.c Fix some comment spelling errors. 2019-12-18 02:34:11 +01:00
Makefile.objs
mem_helper.c tcg: Search includes from the project root source directory 2020-01-15 15:13:10 -10:00
misc_helper.c target/i386: Fix OUTL debug output 2020-06-10 12:09:35 -04:00
monitor.c hw: replace hw/i386/pc.h with a header just for the i8259 2019-12-17 19:33:49 +01:00
mpx_helper.c
ops_sse_header.h
ops_sse.h target/i386: fix phadd* with identical destination and source register 2020-06-10 12:09:42 -04:00
seg_helper.c target/i386: Use cpu_*_mmuidx_ra instead of templates 2020-01-15 15:13:10 -10:00
sev_i386.h
sev-stub.c
sev.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
shift_helper_template.h
smm_helper.c
svm_helper.c
svm.h
TODO
trace-events
translate.c linux-user/i386: Emulate x86_64 vsyscalls 2020-03-26 08:08:54 +01:00
whp-dispatch.h WHPX: TSC get and set should be dependent on VM state 2020-03-16 23:02:21 +01:00
whpx-all.c WHPX: Use proper synchronization primitives while processing 2020-03-16 23:02:24 +01:00
xsave_helper.c