kvm: fix unaligned slots

kvm_set_phys_mem() may be passed sections that are not aligned to a page
boundary.  The current code simply brute-forces the alignment which leads
to an inconsistency and an abort().

Fix by aligning the start and the end of the section correctly, discarding
and unaligned head or tail.

This was triggered by a guest sizing a 64-bit BAR that is smaller than a page
with PCI_COMMAND_MEMORY enabled and the upper dword clear.

Signed-off-by: Avi Kivity <avi@redhat.com>
1 file changed
tree: 50fbaaf123d39f77b46c94becfed8a50eb4febe0
  1. .gitignore
  2. .gitmodules
  3. .mailmap
  4. CODING_STYLE
  5. COPYING
  6. COPYING.LIB
  7. Changelog
  8. HACKING
  9. LICENSE
  10. MAINTAINERS
  11. Makefile
  12. Makefile.dis
  13. Makefile.hw
  14. Makefile.objs
  15. Makefile.target
  16. Makefile.user
  17. QMP/
  18. README
  19. TODO
  20. VERSION
  21. a.out.h
  22. acl.c
  23. acl.h
  24. aes.c
  25. aes.h
  26. aio.c
  27. alpha-dis.c
  28. alpha.ld
  29. arch_init.c
  30. arch_init.h
  31. arm-dis.c
  32. arm-semi.c
  33. arm.ld
  34. async.c
  35. audio/
  36. balloon.c
  37. balloon.h
  38. bitmap.c
  39. bitmap.h
  40. bitops.c
  41. bitops.h
  42. block-migration.c
  43. block-migration.h
  44. block.c
  45. block.h
  46. block/
  47. block_int.h
  48. blockdev.c
  49. blockdev.h
  50. bsd-user/
  51. bswap.h
  52. bt-host.c
  53. bt-host.h
  54. bt-vhci.c
  55. buffered_file.c
  56. buffered_file.h
  57. cache-utils.c
  58. cache-utils.h
  59. check-qdict.c
  60. check-qfloat.c
  61. check-qint.c
  62. check-qjson.c
  63. check-qlist.c
  64. check-qstring.c
  65. cmd.c
  66. cmd.h
  67. compatfd.c
  68. compatfd.h
  69. compiler.h
  70. config.h
  71. configure
  72. console.c
  73. console.h
  74. coroutine-gthread.c
  75. coroutine-ucontext.c
  76. coroutine-win32.c
  77. cpu-all.h
  78. cpu-common.h
  79. cpu-defs.h
  80. cpu-exec.c
  81. cpus.c
  82. cpus.h
  83. cris-dis.c
  84. cursor.c
  85. cursor_hidden.xpm
  86. cursor_left_ptr.xpm
  87. cutils.c
  88. darwin-user/
  89. def-helper.h
  90. default-configs/
  91. device_tree.c
  92. device_tree.h
  93. dis-asm.h
  94. disas.c
  95. disas.h
  96. dma-helpers.c
  97. dma.h
  98. docs/
  99. dyngen-exec.h
  100. elf.h
  101. envlist.c
  102. envlist.h
  103. error.c
  104. error.h
  105. error_int.h
  106. event_notifier.c
  107. event_notifier.h
  108. exec-all.h
  109. exec-memory.h
  110. exec-obsolete.h
  111. exec.c
  112. fpu/
  113. fsdev/
  114. gdb-xml/
  115. gdbstub.c
  116. gdbstub.h
  117. gen-icount.h
  118. hmp-commands.hx
  119. hmp.c
  120. hmp.h
  121. host-utils.c
  122. host-utils.h
  123. hppa-dis.c
  124. hppa.ld
  125. hw/
  126. i386-dis.c
  127. i386.ld
  128. ia64-dis.c
  129. ia64.ld
  130. include/
  131. input.c
  132. int128.h
  133. iohandler.c
  134. ioport-user.c
  135. ioport.c
  136. ioport.h
  137. iorange.h
  138. iov.c
  139. iov.h
  140. json-lexer.c
  141. json-lexer.h
  142. json-parser.c
  143. json-parser.h
  144. json-streamer.c
  145. json-streamer.h
  146. kvm-all.c
  147. kvm-stub.c
  148. kvm.h
  149. libcacard/
  150. libfdt_env.h
  151. linux-aio.c
  152. linux-headers/
  153. linux-user/
  154. m68k-dis.c
  155. m68k-semi.c
  156. m68k.ld
  157. main-loop.c
  158. main-loop.h
  159. memory.c
  160. memory.h
  161. microblaze-dis.c
  162. migration-exec.c
  163. migration-fd.c
  164. migration-tcp.c
  165. migration-unix.c
  166. migration.c
  167. migration.h
  168. mips-dis.c
  169. mips.ld
  170. module.c
  171. module.h
  172. monitor.c
  173. monitor.h
  174. nbd.c
  175. nbd.h
  176. net.c
  177. net.h
  178. net/
  179. notify.c
  180. notify.h
  181. os-posix.c
  182. os-win32.c
  183. osdep.c
  184. osdep.h
  185. oslib-posix.c
  186. oslib-win32.c
  187. path.c
  188. pc-bios/
  189. pci-ids.txt
  190. pflib.c
  191. pflib.h
  192. poison.h
  193. posix-aio-compat.c
  194. ppc-dis.c
  195. ppc.ld
  196. ppc64.ld
  197. qapi-schema-guest.json
  198. qapi-schema-test.json
  199. qapi-schema.json
  200. qapi/
  201. qbool.c
  202. qbool.h
  203. qdict-test-data.txt
  204. qdict.c
  205. qdict.h
  206. qemu-aio.h
  207. qemu-barrier.h
  208. qemu-bridge-helper.c
  209. qemu-char.c
  210. qemu-char.h
  211. qemu-common.h
  212. qemu-config.c
  213. qemu-config.h
  214. qemu-coroutine-int.h
  215. qemu-coroutine-io.c
  216. qemu-coroutine-lock.c
  217. qemu-coroutine-sleep.c
  218. qemu-coroutine.c
  219. qemu-coroutine.h
  220. qemu-doc.texi
  221. qemu-error.c
  222. qemu-error.h
  223. qemu-file.h
  224. qemu-ga.c
  225. qemu-img-cmds.hx
  226. qemu-img.c
  227. qemu-img.texi
  228. qemu-io.c
  229. qemu-lock.h
  230. qemu-log.h
  231. qemu-nbd.c
  232. qemu-nbd.texi
  233. qemu-objects.h
  234. qemu-option.c
  235. qemu-option.h
  236. qemu-options-wrapper.h
  237. qemu-options.h
  238. qemu-options.hx
  239. qemu-os-posix.h
  240. qemu-os-win32.h
  241. qemu-progress.c
  242. qemu-queue.h
  243. qemu-sockets.c
  244. qemu-tech.texi
  245. qemu-thread-posix.c
  246. qemu-thread-posix.h
  247. qemu-thread-win32.c
  248. qemu-thread-win32.h
  249. qemu-thread.h
  250. qemu-timer-common.c
  251. qemu-timer.c
  252. qemu-timer.h
  253. qemu-tls.h
  254. qemu-tool.c
  255. qemu-x509.h
  256. qemu-xattr.h
  257. qemu.sasl
  258. qemu_socket.h
  259. qerror.c
  260. qerror.h
  261. qfloat.c
  262. qfloat.h
  263. qga/
  264. qint.c
  265. qint.h
  266. qjson.c
  267. qjson.h
  268. qlist.c
  269. qlist.h
  270. qmp-commands.hx
  271. qmp.c
  272. qobject.h
  273. qom/
  274. qstring.c
  275. qstring.h
  276. range.h
  277. readline.c
  278. readline.h
  279. roms/
  280. rules.mak
  281. s390-dis.c
  282. s390.ld
  283. savevm.c
  284. scripts/
  285. sh4-dis.c
  286. slirp/
  287. softmmu-semi.h
  288. softmmu_defs.h
  289. softmmu_exec.h
  290. softmmu_header.h
  291. softmmu_template.h
  292. sparc-dis.c
  293. sparc.ld
  294. sparc64.ld
  295. spice-qemu-char.c
  296. sysconfigs/
  297. sysemu.h
  298. target-alpha/
  299. target-arm/
  300. target-cris/
  301. target-i386/
  302. target-lm32/
  303. target-m68k/
  304. target-microblaze/
  305. target-mips/
  306. target-ppc/
  307. target-s390x/
  308. target-sh4/
  309. target-sparc/
  310. target-unicore32/
  311. target-xtensa/
  312. targphys.h
  313. tcg-runtime.c
  314. tcg/
  315. tci-dis.c
  316. tci.c
  317. test-coroutine.c
  318. test-qmp-commands.c
  319. test-qmp-input-visitor.c
  320. test-qmp-output-visitor.c
  321. tests/
  322. thunk.c
  323. thunk.h
  324. trace-events
  325. trace/
  326. translate-all.c
  327. uboot_image.h
  328. ui/
  329. usb-bsd.c
  330. usb-linux.c
  331. usb-redir.c
  332. usb-stub.c
  333. user-exec.c
  334. version.rc
  335. vgafont.h
  336. vl.c
  337. vmstate.h
  338. x86_64.ld
  339. xen-all.c
  340. xen-mapcache.c
  341. xen-mapcache.h
  342. xen-stub.c
  343. xtensa-semi.c