Fix upstream ARM emulation bug that broke singlestep mode.

This fixes a really bad bug in the Thumb/Thumb2 ARM emulation related to
conditional instructions execution. The issue was that the previous
implementation did break badly if a page fault occured during the conditional
instruction's emulation. Giving an example if probably the best way to demonstrate
this. Consider the following two instructions:

    itt eq
    streq r0,[r4, #0]

These two instructions mean, respectively:
  - If the Z flag is set, execute the next instruction. Otherwise ignore it
  - Store the value of r0 at the address pointed to by r4

In single-step mode (used when debugging the emulator), each instruction is
separately JIT-ed and executed in a different pass. The 'condexec_bits' field
of the CPU state if used to store flags corresponding to the conditional
execution of up to 4 next instructions.

When the first instruction is executed, it simply sets 'condexec_bits' to a
specific value (4).

When the second instruction is executed, things get slightly bit more funky
because what happened was the following:

 - the JIT-ed code started by clearing the 'condexec_bits' right at the
   start of its sequence (a comment says "to avoid complications trying to
   do it at the end of the block", famous last words...)

 - a conditional test, based on the current value of the Z flag was added
   to skip over the rest of the instruction sequence

 - the store itself is implemented through a call to the __stl_mmu helper
   function.

The thing is that __stl_mmu may implement a *page fault* (i.e. when the
address in r4 hasn't been commited to memory yet) which requires a switch
to kernel mode (to populate the page), then going back to the instruction's
execution.

This is done in the current implementation by re-running the JIT-er for the
same instruction, however, since 'condexec_bits' was already cleared to 0,
the new JIT-ed code sequence doesn't have the conditional test to skip over
the store. The conditional instruction has been transformed into a
non-conditional one due to the page fault ! This results in either bad behaviour
or, even a crash in the emulator.

The patch fixes the clearing of condexec_bits to happen as it should, i.e.
only when execution has really cleared it.

This is preliminary work to fix the -trace option.

Also, disable the IO Thread when running the standalone emulator. This makes
debugging much easier since everything happens in a single thread.
2 files changed
tree: 15710dea9719cc49d7607e8f726c39e940d08900
  1. android/
  2. audio/
  3. block/
  4. distrib/
  5. docs/
  6. fpu/
  7. gdb-xml/
  8. hw/
  9. images/
  10. proxy/
  11. slirp/
  12. slirp-android/
  13. target-arm/
  14. tcg/
  15. telephony/
  16. .gitignore
  17. a.out.h
  18. acl.c
  19. acl.h
  20. aes.c
  21. aes.h
  22. aio-android.c
  23. aio.c
  24. alpha.ld
  25. android-configure.sh
  26. android-rebuild.sh
  27. Android.mk
  28. arm-dis.c
  29. arm-semi.c
  30. arm.ld
  31. balloon.h
  32. block.c
  33. block.h
  34. block_int.h
  35. bswap.h
  36. bt-host.c
  37. bt-host.h
  38. bt-vhci.c
  39. buffered_file.c
  40. buffered_file.h
  41. cache-utils.c
  42. cache-utils.h
  43. cbuffer.c
  44. cbuffer.h
  45. Changelog
  46. CHANGES.TXT
  47. charpipe.c
  48. charpipe.h
  49. compatfd.c
  50. compatfd.h
  51. console.c
  52. console.h
  53. COPYING
  54. COPYING.LIB
  55. cpu-all.h
  56. cpu-common.h
  57. cpu-defs.h
  58. cpu-exec.c
  59. curses.c
  60. curses_keys.h
  61. cutils.c
  62. d3des.c
  63. d3des.h
  64. dcache.c
  65. dcache.h
  66. def-helper.h
  67. device_tree.c
  68. device_tree.h
  69. dis-asm.h
  70. disas.c
  71. disas.h
  72. dma-helpers.c
  73. dma.h
  74. dyngen-exec.h
  75. dynlink.h
  76. elf.h
  77. elf_ops.h
  78. exec-all.h
  79. exec.c
  80. feature_to_c.sh
  81. framebuffer.c
  82. framebuffer.h
  83. gdbstub.c
  84. gdbstub.h
  85. gen-charmap.py
  86. gen-icount.h
  87. gen-skin.py
  88. host-defs.h
  89. host-utils.c
  90. host-utils.h
  91. hostregs_helper.h
  92. hpet.h
  93. hxtool
  94. i386-dis.c
  95. i386-vl.ld
  96. i386.ld
  97. ia64.ld
  98. INSTALL
  99. iolooper-select.c
  100. iolooper.h
  101. keymaps.c
  102. keymaps.h
  103. kqemu.c
  104. kqemu.h
  105. kvm.h
  106. LICENSE
  107. linux_keycodes.h
  108. loader.c
  109. loadpng.c
  110. m68k.ld
  111. Makefile
  112. Makefile.android
  113. migration-dummy-android.c
  114. migration-exec.c
  115. migration-tcp-android.c
  116. migration-tcp.c
  117. migration.c
  118. migration.h
  119. module.c
  120. module.h
  121. MODULE_LICENSE_GPL
  122. monitor.c
  123. monitor.h
  124. net-android.c
  125. net-checksum.c
  126. net.c
  127. net.h
  128. NOTICE
  129. offset_layout.py
  130. osdep.c
  131. osdep.h
  132. ppc-dis.c
  133. ppc.ld
  134. qemu-aio.h
  135. qemu-char-android.c
  136. qemu-char.c
  137. qemu-char.h
  138. qemu-common.h
  139. qemu-io.c
  140. qemu-lock.h
  141. qemu-log.h
  142. qemu-malloc.c
  143. qemu-monitor.hx
  144. qemu-option.c
  145. qemu-option.h
  146. qemu-options.hx
  147. qemu-sockets-android.c
  148. qemu-sockets.c
  149. qemu-thread.c
  150. qemu-thread.h
  151. qemu-timer.h
  152. qemu_debug.h
  153. qemu_file.h
  154. qemu_socket.h
  155. qemu_timers.h
  156. readline.c
  157. readline.h
  158. README
  159. savevm.c
  160. sdl_keysym.h
  161. shaper.c
  162. shaper.h
  163. sockets.c
  164. sockets.h
  165. softmmu-semi.h
  166. softmmu_defs.h
  167. softmmu_exec.h
  168. softmmu_header.h
  169. softmmu_template.h
  170. sparc.ld
  171. sys-queue.h
  172. sysemu.h
  173. tap-win32.c
  174. targphys.h
  175. tcpdump.c
  176. tcpdump.h
  177. thunk.c
  178. thunk.h
  179. trace.c
  180. trace.h
  181. trace_common.h
  182. translate-all.c
  183. translate-op.c
  184. translate.make
  185. uboot_image.h
  186. usb-dummy-android.c
  187. usb-linux.c
  188. varint.c
  189. varint.h
  190. vgafont.h
  191. vl-android.c
  192. vl.c
  193. vnc-android.c
  194. vnc-tls.h
  195. vnc.c
  196. vnc.h
  197. vnc_keysym.h
  198. vnchextile.h
  199. x86_64.ld