virtio-pci: Fix endianness of virtio config

The virtio config area in PIO space is a bit special. The initial
header is little endian but the rest (device specific) is guest
native endian.

The PIO accessors for PCI on machines that don't have native IO ports
assume that all PIO is little endian, which works fine for everything
except the above.

A complicated way to fix it would be to split the BAR into two memory
regions with different endianess settings, but this isn't practical
to do, besides, the PIO code doesn't honor region endianness anyway
(I have a patch for that too but it isn't necessary at this stage).

So I decided to go for the quick fix instead which consists of
reverting the swap in virtio-pci in selected places, hoping that when
we eventually do a "v2" of the virtio protocols, we sort that out once
and for all using a fixed endian setting for everything.

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