Fix signal handling for GS_RESTORE hack

Currently we hack QEMU's signal handler because of the GS_BASE MSR KVM bug.
The reason of the hack is, when signal happens during KVM_RUN ioctl, the
GS_BASE is broken, we have to restore the correct gs before run the signal
handler.
However, currently we take signal even when signal is set as SIG_DFL/SIG_IGN,
or the signal is set with SIG_SIGINFO. Currently "kill -13" to emulator causes
emulator crash.

This patch fixed it as:
1) If the signal handler is set as SIG_DFL or SIG_IGN, we don't take the signal
2) If the signal handler is set with SIG_SIGINFO, we will use sa_sigaction
3) Cover all potential signals

One thing left is, if the signal handler is setup dynamically, this method may
still have issue because currently the signal handlers are taken statically
when first KVM_RUN ioctl. Luckily this does not happen now.

Change-Id: Icfbe43db665a11f2b6eaf9593075b3e643783ee7
Signed-off-by: Jiang Yunhong <yunhong.jiang@intel.com>
1 file changed
tree: 2d99fcaf4c75746bd68247efab92e4946775a291
  1. android/
  2. audio/
  3. block/
  4. distrib/
  5. docs/
  6. elff/
  7. fpu/
  8. gdb-xml/
  9. hw/
  10. images/
  11. memcheck/
  12. pc-bios/
  13. proxy/
  14. slirp/
  15. slirp-android/
  16. target-arm/
  17. target-i386/
  18. tcg/
  19. telephony/
  20. .gitignore
  21. a.out.h
  22. acl.c
  23. acl.h
  24. aes.c
  25. aes.h
  26. aio-android.c
  27. aio.c
  28. alpha.ld
  29. android-configure.sh
  30. android-rebuild.sh
  31. android-trace.h
  32. android-trace_common.h
  33. Android.mk
  34. arch_init.c
  35. arch_init.h
  36. arm-dis.c
  37. arm-semi.c
  38. arm.ld
  39. async.c
  40. balloon.h
  41. block.c
  42. block.h
  43. block_int.h
  44. blockdev.c
  45. blockdev.h
  46. bswap.h
  47. bt-host.c
  48. bt-host.h
  49. bt-vhci.c
  50. buffered_file.c
  51. buffered_file.h
  52. cache-utils.c
  53. cache-utils.h
  54. cbuffer.c
  55. cbuffer.h
  56. Changelog
  57. CHANGES.TXT
  58. charpipe.c
  59. charpipe.h
  60. CleanSpec.mk
  61. compatfd.c
  62. compatfd.h
  63. console.c
  64. console.h
  65. COPYING
  66. COPYING.LIB
  67. cpu-all.h
  68. cpu-common.h
  69. cpu-defs.h
  70. cpu-exec.c
  71. cpus.c
  72. cpus.h
  73. curses.c
  74. curses_keys.h
  75. cutils.c
  76. d3des.c
  77. d3des.h
  78. def-helper.h
  79. device_tree.c
  80. device_tree.h
  81. dis-asm.h
  82. disas.c
  83. disas.h
  84. dma-helpers.c
  85. dma.h
  86. dyngen-exec.h
  87. dynlink-static.c
  88. dynlink.h
  89. elf.h
  90. elf_ops.h
  91. envlist.c
  92. envlist.h
  93. exec-all.h
  94. exec.c
  95. feature_to_c.sh
  96. gdbstub.c
  97. gdbstub.h
  98. gen-charmap.py
  99. gen-icount.h
  100. gen-skin.py
  101. host-defs.h
  102. host-utils.c
  103. host-utils.h
  104. hostregs_helper.h
  105. hpet.h
  106. hxtool
  107. i386-dis.c
  108. i386-vl.ld
  109. i386.ld
  110. ia64.ld
  111. input.c
  112. INSTALL
  113. iohandler.c
  114. iolooper-select.c
  115. iolooper.h
  116. ioport-user.c
  117. ioport.c
  118. ioport.h
  119. json-lexer.c
  120. json-lexer.h
  121. json-parser.c
  122. json-parser.h
  123. json-streamer.c
  124. json-streamer.h
  125. keymaps.c
  126. keymaps.h
  127. kqemu.c
  128. kqemu.h
  129. kvm-all.c
  130. kvm-android.c
  131. kvm-android.h
  132. kvm.h
  133. LICENSE
  134. linux_keycodes.h
  135. loader.c
  136. loadpng.c
  137. m68k.ld
  138. Makefile
  139. Makefile.android
  140. Makefile.common
  141. Makefile.target
  142. migration-dummy-android.c
  143. migration-exec.c
  144. migration-tcp-android.c
  145. migration-tcp.c
  146. migration.c
  147. migration.h
  148. module.c
  149. module.h
  150. MODULE_LICENSE_GPL
  151. monitor-android.h
  152. monitor.c
  153. monitor.h
  154. net-android.c
  155. net-checksum.c
  156. net.c
  157. net.h
  158. NOTICE
  159. notify.c
  160. notify.h
  161. offset_layout.py
  162. os-posix.c
  163. os-win32.c
  164. osdep.c
  165. osdep.h
  166. oslib-posix.c
  167. oslib-win32.c
  168. path.c
  169. poison.h
  170. posix-aio-compat.c
  171. ppc-dis.c
  172. ppc.ld
  173. qbool.c
  174. qbool.h
  175. qdict.c
  176. qdict.h
  177. qemu-aio.h
  178. qemu-barrier.h
  179. qemu-char.c
  180. qemu-char.h
  181. qemu-common.h
  182. qemu-config.c
  183. qemu-config.h
  184. qemu-error.c
  185. qemu-error.h
  186. qemu-io.c
  187. qemu-lock.h
  188. qemu-log.h
  189. qemu-malloc.c
  190. qemu-monitor.hx
  191. qemu-objects.h
  192. qemu-option.c
  193. qemu-option.h
  194. qemu-options.h
  195. qemu-options.hx
  196. qemu-os-posix.h
  197. qemu-os-win32.h
  198. qemu-queue.h
  199. qemu-sockets-android.c
  200. qemu-sockets.c
  201. qemu-thread.c
  202. qemu-thread.h
  203. qemu-timer-common.c
  204. qemu-timer.c
  205. qemu-timer.h
  206. qemu_debug.h
  207. qemu_file.h
  208. qemu_socket.h
  209. qemu_timers.h
  210. qerror.c
  211. qerror.h
  212. qfloat.c
  213. qfloat.h
  214. qint.c
  215. qint.h
  216. qjson.c
  217. qjson.h
  218. qlist.c
  219. qlist.h
  220. qobject.h
  221. qstring.c
  222. qstring.h
  223. readline.c
  224. readline.h
  225. README
  226. savevm.c
  227. sdl_keysym.h
  228. shaper.c
  229. shaper.h
  230. sockets.c
  231. sockets.h
  232. softmmu-semi.h
  233. softmmu_defs.h
  234. softmmu_exec.h
  235. softmmu_header.h
  236. softmmu_outside_jit.c
  237. softmmu_outside_jit.h
  238. softmmu_template.h
  239. sparc.ld
  240. sys-tree.h
  241. sysemu.h
  242. tap-win32.c
  243. targphys.h
  244. tcpdump.c
  245. tcpdump.h
  246. thunk.c
  247. thunk.h
  248. trace.c
  249. trace.h
  250. trace_common.h
  251. translate-all.c
  252. translate-op.c
  253. translate.make
  254. uboot_image.h
  255. usb-dummy-android.c
  256. usb-linux.c
  257. user-events-qemu.c
  258. user-events.h
  259. varint.c
  260. varint.h
  261. vgafont.h
  262. vl-android-ui.c
  263. vl-android.c
  264. vl.c
  265. vnc-android.c
  266. vnc-tls.h
  267. vnc.c
  268. vnc.h
  269. vnc_keysym.h
  270. vnchextile.h
  271. x86_64.ld