unicorn/qemu/include/exec
Pavel Dovgalyuk b4bf3c776b
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.

Backports commit afd46fcad2dceffda35c0586f5723c127b6e09d8 from qemu
2018-04-11 20:05:40 -04:00
..
address-spaces.h Clean up header guards that don't match their file name 2018-02-25 04:18:42 -05:00
cpu_ldst_template.h
cpu_ldst.h cpu_ldst.h: use correct guest address parameter 2018-03-01 08:56:37 -05:00
cpu-all.h target-*: Don't redefine cpu_exec() 2018-03-20 07:02:47 -04:00
cpu-common.h cpu: Introduce a wrapper for tlb_flush() that can be used in common code 2018-03-03 21:24:55 -05:00
cpu-defs.h tcg: add CONFIG_TCG guards in headers 2018-03-03 21:37:52 -05:00
cputlb.h exec: Drop unnecessary code for unicorn 2018-03-12 10:11:46 -04:00
exec-all.h icount: fix cpu_restore_state_from_tb for non-tb-exit cases 2018-04-11 20:05:40 -04:00
gen-icount.h tcg: Dynamically allocate TCGOps 2018-03-05 16:34:40 -05:00
helper-gen.h tcg: Allow 6 arguments to TCG helpers 2018-03-17 18:29:04 -04:00
helper-head.h tcg: Allow 6 arguments to TCG helpers 2018-03-17 18:29:04 -04:00
helper-proto.h tcg: Allow 6 arguments to TCG helpers 2018-03-17 18:29:04 -04:00
helper-tcg.h tcg: Allow 6 arguments to TCG helpers 2018-03-17 18:29:04 -04:00
hwaddr.h qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
ioport.h hw: remove pio_addr_t 2018-02-24 02:43:16 -05:00
memattrs.h memory.h: Move MemTxResult type to memattrs.h 2018-03-04 13:10:47 -05:00
memory-internal.h memory: Rename mem_begin/mem_commit/mem_add helpers 2018-03-11 21:36:50 -04:00
memory.h memory: Share special empty FlatView 2018-03-11 22:34:28 -04:00
ram_addr.h exec: Drop unnecessary code for unicorn 2018-03-12 10:11:46 -04:00
ramlist.h
semihost.h
tb-context.h tcg: allocate TB structs before the corresponding translated code 2018-03-03 17:05:49 -05:00
tb-hash-xx.h Clean up ill-advised or unusual header guards 2018-02-25 04:22:46 -05:00
tb-hash.h tb-hash: improve tb_jmp_cache hash function in user mode 2018-03-03 14:11:29 -05:00
tb-lookup.h exec-all: bring tb->invalid into tb->cflags 2018-03-05 02:46:21 -05:00
translator.h tcg: Add generic translation framework 2018-03-04 14:31:16 -05:00