cputlb: atomically update tlb fields used by tlb_reset_dirty

The main use case for tlb_reset_dirty is to set the TLB_NOTDIRTY flags
in TLB entries to force the slow-path on writes. This is used to mark
page ranges containing code which has been translated so it can be
invalidated if written to. To do this safely we need to ensure the TLB
entries in question for all vCPUs are updated before we attempt to run
the code otherwise a race could be introduced.

To achieve this we atomically set the flag in tlb_reset_dirty_range and
take care when setting it when the TLB entry is filled.

On 32 bit systems attempting to emulate 64 bit guests we don't even
bother as we might not have the atomic primitives available. MTTCG is
disabled in this case and can't be forced on. The copy_tlb_helper
function helps keep the atomic semantics in one place to avoid
confusion.

The dirty helper function is made static as it isn't used outside of
cputlb.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2 files changed
tree: 662569f4cf78e18605e5f5ee5f1824bcf2a1dda3
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. chardev/
  6. contrib/
  7. crypto/
  8. default-configs/
  9. disas/
  10. docs/
  11. fpu/
  12. fsdev/
  13. gdb-xml/
  14. hw/
  15. include/
  16. io/
  17. libdecnumber/
  18. linux-headers/
  19. linux-user/
  20. migration/
  21. nbd/
  22. net/
  23. pc-bios/
  24. po/
  25. qapi/
  26. qga/
  27. qobject/
  28. qom/
  29. replay/
  30. roms/
  31. scripts/
  32. slirp/
  33. stubs/
  34. target/
  35. tcg/
  36. tests/
  37. trace/
  38. ui/
  39. util/
  40. .dir-locals.el
  41. .exrc
  42. .gitignore
  43. .gitmodules
  44. .mailmap
  45. .travis.yml
  46. accel.c
  47. arch_init.c
  48. atomic_template.h
  49. balloon.c
  50. block.c
  51. blockdev-nbd.c
  52. blockdev.c
  53. blockjob.c
  54. bootdevice.c
  55. bt-host.c
  56. bt-vhci.c
  57. Changelog
  58. CODING_STYLE
  59. configure
  60. COPYING
  61. COPYING.LIB
  62. cpu-exec-common.c
  63. cpu-exec.c
  64. cpus-common.c
  65. cpus.c
  66. cputlb.c
  67. device-hotplug.c
  68. device_tree.c
  69. disas.c
  70. dma-helpers.c
  71. dump.c
  72. exec.c
  73. gdbstub.c
  74. HACKING
  75. hax-stub.c
  76. hmp-commands-info.hx
  77. hmp-commands.hx
  78. hmp.c
  79. hmp.h
  80. ioport.c
  81. iothread.c
  82. kvm-all.c
  83. kvm-stub.c
  84. LICENSE
  85. MAINTAINERS
  86. Makefile
  87. Makefile.objs
  88. Makefile.target
  89. memory.c
  90. memory_ldst.inc.c
  91. memory_mapping.c
  92. module-common.c
  93. monitor.c
  94. numa.c
  95. os-posix.c
  96. os-win32.c
  97. page_cache.c
  98. qapi-schema.json
  99. qdev-monitor.c
  100. qdict-test-data.txt
  101. qemu-bridge-helper.c
  102. qemu-doc.texi
  103. qemu-ga.texi
  104. qemu-img-cmds.hx
  105. qemu-img.c
  106. qemu-img.texi
  107. qemu-io-cmds.c
  108. qemu-io.c
  109. qemu-nbd.c
  110. qemu-nbd.texi
  111. qemu-option-trace.texi
  112. qemu-options-wrapper.h
  113. qemu-options.h
  114. qemu-options.hx
  115. qemu-seccomp.c
  116. qemu-tech.texi
  117. qemu.nsi
  118. qemu.sasl
  119. qmp.c
  120. qtest.c
  121. README
  122. replication.c
  123. replication.h
  124. rules.mak
  125. softmmu_template.h
  126. spice-qemu-char.c
  127. tcg-runtime.c
  128. tci.c
  129. thunk.c
  130. tpm.c
  131. trace-events
  132. translate-all.c
  133. translate-all.h
  134. translate-common.c
  135. user-exec-stub.c
  136. user-exec.c
  137. VERSION
  138. version.rc
  139. vl.c
  140. xen-common-stub.c
  141. xen-common.c
  142. xen-hvm-stub.c
  143. xen-hvm.c
  144. xen-mapcache.c