qemu/target/xtensa
Pavel Dovgalyuk afd46fcad2 icount: fix cpu_restore_state_from_tb for non-tb-exit cases
In icount mode, instructions that access io memory spaces in the middle
of the translation block invoke TB recompilation.  After recompilation,
such instructions become last in the TB and are allowed to access io
memory spaces.

When the code includes instruction like i386 'xchg eax, 0xffffd080'
which accesses APIC, QEMU goes into an infinite loop of the recompilation.

This instruction includes two memory accesses - one read and one write.
After the first access, APIC calls cpu_report_tpr_access, which restores
the CPU state to get the current eip.  But cpu_restore_state_from_tb
resets the cpu->can_do_io flag which makes the second memory access invalid.
Therefore the second memory access causes a recompilation of the block.
Then these operations repeat again and again.

This patch moves resetting cpu->can_do_io flag from
cpu_restore_state_from_tb to cpu_loop_exit* functions.

It also adds a parameter for cpu_restore_state which controls restoring
icount.  There is no need to restore icount when we only query CPU state
without breaking the TB.  Restoring it in such cases leads to the
incorrect flow of the virtual time.

In most cases new parameter is true (icount should be recalculated).
But there are two cases in i386 and openrisc when the CPU state is only
queried without the need to break the TB.  This patch fixes both of
these cases.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Message-Id: <20180409091320.12504.35329.stgit@pasha-VirtualBox>
[rth: Make can_do_io setting unconditional; move from cpu_exec;
make cpu_loop_exit_{noexc,restore} call cpu_loop_exit.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2018-04-11 09:05:22 +10:00
..
core-dc232b target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-dc233c target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-de212 target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-fsf target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-sample_controller target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
Makefile.objs target/xtensa: add linux-user support 2018-03-16 09:40:34 -07:00
core-dc232b.c target/xtensa: fix timers test 2018-03-26 14:17:04 -07:00
core-dc233c.c target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-de212.c target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-fsf.c target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
core-sample_controller.c target/xtensa: add .inc. to non-top level source file names 2018-03-26 14:17:03 -07:00
cpu-qom.h Move target-* CPU file into a target/ folder 2016-12-20 21:52:12 +01:00
cpu.c target/xtensa: add linux-user support 2018-03-16 09:40:34 -07:00
cpu.h cpu: get rid of unused cpu_init() defines 2018-03-19 14:10:36 -03:00
gdbstub.c target/xtensa: use correct number of registers in gdbstub 2018-03-13 11:30:22 -07:00
helper.c target/xtensa: add linux-user support 2018-03-16 09:40:34 -07:00
helper.h target/xtensa: add linux-user support 2018-03-16 09:40:34 -07:00
import_core.sh target/xtensa/import_core.sh: fix #include <xtensa-isa.h> 2018-03-26 14:17:03 -07:00
monitor.c monitor: Fix crashes when using HMP commands without CPU 2017-02-21 18:29:01 +00:00
op_helper.c icount: fix cpu_restore_state_from_tb for non-tb-exit cases 2018-04-11 09:05:22 +10:00
overlay_tool.h target/xtensa: use correct number of registers in gdbstub 2018-03-13 11:30:22 -07:00
translate.c target/xtensa: add linux-user support 2018-03-16 09:40:34 -07:00
xtensa-isa-internal.h target/xtensa: import libisa source 2017-12-18 21:26:19 -08:00
xtensa-isa.c Clean up includes 2018-02-09 05:05:11 +01:00
xtensa-isa.h Use #include "..." for our own headers, <...> for others 2018-02-09 05:05:11 +01:00
xtensa-semi.c char: add backend hotswap handler 2017-07-14 11:04:33 +02:00