qemu.inc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. SUMMARY = "Fast open source processor emulator"
  2. DESCRIPTION = "QEMU is a hosted virtual machine monitor: it emulates the \
  3. machine's processor through dynamic binary translation and provides a set \
  4. of different hardware and device models for the machine, enabling it to run \
  5. a variety of guest operating systems"
  6. HOMEPAGE = "http://qemu.org"
  7. LICENSE = "GPLv2 & LGPLv2.1"
  8. RDEPENDS_${PN}-ptest = "bash"
  9. require qemu-targets.inc
  10. inherit pkgconfig ptest
  11. LIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \
  12. file://COPYING.LIB;endline=24;md5=8c5efda6cf1e1b03dcfd0e6c0d271c7f"
  13. SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
  14. file://powerpc_rom.bin \
  15. file://run-ptest \
  16. file://0001-qemu-Add-missing-wacom-HID-descriptor.patch \
  17. file://0003-qemu-Add-addition-environment-space-to-boot-loader-q.patch \
  18. file://0004-qemu-disable-Valgrind.patch \
  19. file://0006-chardev-connect-socket-to-a-spawned-command.patch \
  20. file://0007-apic-fixup-fallthrough-to-PIC.patch \
  21. file://0010-configure-Add-pkg-config-handling-for-libgcrypt.patch \
  22. file://0001-Add-enable-disable-udev.patch \
  23. file://0001-qemu-Do-not-include-file-if-not-exists.patch \
  24. file://mmap2.patch \
  25. file://determinism.patch \
  26. file://0001-tests-meson.build-use-relative-path-to-refer-to-file.patch \
  27. file://0001-configure-fix-detection-of-gdbus-codegen.patch \
  28. file://0001-vhost-user-gpu-fix-memory-disclosure-in-virgl_cmd_ge.patch \
  29. file://0002-vhost-user-gpu-fix-resource-leak-in-vg_resource_crea.patch \
  30. file://0003-vhost-user-gpu-fix-memory-leak-in-vg_resource_attach.patch \
  31. file://0004-vhost-user-gpu-fix-memory-leak-while-calling-vg_reso.patch \
  32. file://0005-vhost-user-gpu-fix-memory-leak-in-virgl_cmd_resource.patch \
  33. file://0006-vhost-user-gpu-fix-memory-leak-in-virgl_resource_att.patch \
  34. file://0007-vhost-user-gpu-fix-OOB-write-in-virgl_cmd_get_capset.patch \
  35. file://0001-linux-user-Tag-vsx-with-ieee128-fpbits.patch \
  36. file://CVE-2021-3527-1.patch \
  37. file://CVE-2021-3527-2.patch \
  38. file://0001-softfloat-add-APIs-to-handle-alternative-sNaN-propag.patch \
  39. file://0002-target-riscv-change-the-api-for-single-double-fmin-f.patch \
  40. file://0003-target-riscv-support-x-Zfh-in-cpu-option.patch \
  41. file://0004-target-riscv-Implement-zfh-extension.patch \
  42. file://0005-target-riscv-fix-TB_FLAGS-bits-overlapping-bug-for-r.patch \
  43. file://0006-fpu-softfloat-set-invalid-excp-flag-for-RISC-V-mulad.patch \
  44. file://0007-target-riscv-Fixup-saturate-subtract-function.patch \
  45. file://0008-target-riscv-fix-vrgather-macro-index-variable-type-.patch \
  46. file://0009-target-riscv-drop-vector-0.7.1-and-add-1.0-support.patch \
  47. file://0010-target-riscv-Use-FIELD_EX32-to-extract-wd-field.patch \
  48. file://0011-target-riscv-rvv-1.0-add-mstatus-VS-field.patch \
  49. file://0012-target-riscv-rvv-1.0-add-sstatus-VS-field.patch \
  50. file://0013-target-riscv-rvv-1.0-introduce-writable-misa.v-field.patch \
  51. file://0014-target-riscv-rvv-1.0-add-translation-time-vector-con.patch \
  52. file://0015-target-riscv-rvv-1.0-remove-rvv-related-codes-from-f.patch \
  53. file://0016-target-riscv-rvv-1.0-add-vcsr-register.patch \
  54. file://0017-target-riscv-rvv-1.0-add-vlenb-register.patch \
  55. file://0018-target-riscv-rvv-1.0-check-MSTATUS_VS-when-accessing.patch \
  56. file://0019-target-riscv-rvv-1.0-remove-MLEN-calculations.patch \
  57. file://0020-target-riscv-rvv-1.0-add-fractional-LMUL.patch \
  58. file://0021-target-riscv-rvv-1.0-add-VMA-and-VTA.patch \
  59. file://0022-target-riscv-rvv-1.0-update-check-functions.patch \
  60. file://0023-target-riscv-introduce-more-imm-value-modes-in-trans.patch \
  61. file://0024-target-riscv-rvv-1.0-add-translation-time-nan-box-he.patch \
  62. file://0025-target-riscv-rvv-1.0-configure-instructions.patch \
  63. file://0026-target-riscv-rvv-1.0-stride-load-and-store-instructi.patch \
  64. file://0027-target-riscv-rvv-1.0-index-load-and-store-instructio.patch \
  65. file://0028-target-riscv-rvv-1.0-fix-address-index-overflow-bug-.patch \
  66. file://0029-target-riscv-rvv-1.0-fault-only-first-unit-stride-lo.patch \
  67. file://0030-target-riscv-rvv-1.0-amo-operations.patch \
  68. file://0031-target-riscv-rvv-1.0-load-store-whole-register-instr.patch \
  69. file://0032-target-riscv-rvv-1.0-update-vext_max_elems-for-load-.patch \
  70. file://0033-target-riscv-rvv-1.0-take-fractional-LMUL-into-vecto.patch \
  71. file://0034-target-riscv-rvv-1.0-floating-point-square-root-inst.patch \
  72. file://0035-target-riscv-rvv-1.0-floating-point-classify-instruc.patch \
  73. file://0036-target-riscv-rvv-1.0-mask-population-count-instructi.patch \
  74. file://0037-target-riscv-rvv-1.0-find-first-set-mask-bit-instruc.patch \
  75. file://0038-target-riscv-rvv-1.0-set-X-first-mask-bit-instructio.patch \
  76. file://0039-target-riscv-rvv-1.0-iota-instruction.patch \
  77. file://0040-target-riscv-rvv-1.0-element-index-instruction.patch \
  78. file://0041-target-riscv-rvv-1.0-allow-load-element-with-sign-ex.patch \
  79. file://0042-target-riscv-rvv-1.0-register-gather-instructions.patch \
  80. file://0043-target-riscv-rvv-1.0-integer-scalar-move-instruction.patch \
  81. file://0044-target-riscv-rvv-1.0-floating-point-move-instruction.patch \
  82. file://0045-target-riscv-rvv-1.0-floating-point-scalar-move-inst.patch \
  83. file://0046-target-riscv-rvv-1.0-whole-register-move-instruction.patch \
  84. file://0047-target-riscv-rvv-1.0-integer-extension-instructions.patch \
  85. file://0048-target-riscv-rvv-1.0-single-width-averaging-add-and-.patch \
  86. file://0049-target-riscv-rvv-1.0-single-width-bit-shift-instruct.patch \
  87. file://0050-target-riscv-rvv-1.0-integer-add-with-carry-subtract.patch \
  88. file://0051-target-riscv-rvv-1.0-narrowing-integer-right-shift-i.patch \
  89. file://0052-target-riscv-rvv-1.0-widening-integer-multiply-add-i.patch \
  90. file://0053-target-riscv-rvv-1.0-single-width-saturating-add-and.patch \
  91. file://0054-target-riscv-rvv-1.0-integer-comparison-instructions.patch \
  92. file://0055-target-riscv-rvv-1.0-floating-point-compare-instruct.patch \
  93. file://0056-target-riscv-rvv-1.0-mask-register-logical-instructi.patch \
  94. file://0057-target-riscv-rvv-1.0-slide-instructions.patch \
  95. file://0058-target-riscv-rvv-1.0-floating-point-slide-instructio.patch \
  96. file://0059-target-riscv-rvv-1.0-narrowing-fixed-point-clip-inst.patch \
  97. file://0060-target-riscv-rvv-1.0-single-width-floating-point-red.patch \
  98. file://0061-target-riscv-rvv-1.0-widening-floating-point-reducti.patch \
  99. file://0062-target-riscv-rvv-1.0-single-width-scaling-shift-inst.patch \
  100. file://0063-target-riscv-rvv-1.0-remove-widening-saturating-scal.patch \
  101. file://0064-target-riscv-rvv-1.0-remove-vmford.vv-and-vmford.vf.patch \
  102. file://0065-target-riscv-rvv-1.0-remove-integer-extract-instruct.patch \
  103. file://0066-target-riscv-rvv-1.0-floating-point-min-max-instruct.patch \
  104. file://0067-target-riscv-introduce-floating-point-rounding-mode-.patch \
  105. file://0068-target-riscv-rvv-1.0-floating-point-integer-type-con.patch \
  106. file://0069-target-riscv-rvv-1.0-widening-floating-point-integer.patch \
  107. file://0070-target-riscv-add-set-round-to-odd-rounding-mode-help.patch \
  108. file://0071-target-riscv-rvv-1.0-narrowing-floating-point-intege.patch \
  109. file://0072-target-riscv-rvv-1.0-relax-RV_VLEN_MAX-to-1024-bits.patch \
  110. file://0073-target-riscv-rvv-1.0-implement-vstart-CSR.patch \
  111. file://0074-target-riscv-rvv-1.0-trigger-illegal-instruction-exc.patch \
  112. file://0075-target-riscv-rvv-1.0-set-mstatus.SD-bit-when-writing.patch \
  113. file://0076-target-riscv-gdb-support-vector-registers-for-rv64-r.patch \
  114. file://0077-target-riscv-rvv-1.0-floating-point-reciprocal-squar.patch \
  115. file://0078-target-riscv-rvv-1.0-floating-point-reciprocal-estim.patch \
  116. file://0079-target-riscv-set-mstatus.SD-bit-when-writing-fp-CSRs.patch \
  117. file://0080-target-riscv-rvv-1.0-rename-r2_zimm-to-r2_zimm11.patch \
  118. file://0081-target-riscv-rvv-1.0-add-vsetivli-instruction.patch \
  119. file://0082-target-riscv-rvv-1.0-add-evl-parameter-to-vext_ldst_.patch \
  120. file://0083-target-riscv-rvv-1.0-add-vector-unit-stride-mask-loa.patch \
  121. file://0084-target-riscv-rvv-1.0-patch-floating-point-reduction-.patch \
  122. file://0085-target-riscv-reformat-sh-format-encoding-for-B-exten.patch \
  123. file://0086-target-riscv-rvb-count-leading-trailing-zeros.patch \
  124. file://0087-target-riscv-rvb-count-bits-set.patch \
  125. file://0088-target-riscv-rvb-logic-with-negate.patch \
  126. file://0089-target-riscv-rvb-pack-two-words-into-one-register.patch \
  127. file://0090-target-riscv-rvb-min-max-instructions.patch \
  128. file://0091-target-riscv-rvb-sign-extend-instructions.patch \
  129. file://0092-target-riscv-add-gen_shifti-and-gen_shiftiw-helper-f.patch \
  130. file://0093-target-riscv-rvb-single-bit-instructions.patch \
  131. file://0094-target-riscv-rvb-shift-ones.patch \
  132. file://0095-target-riscv-rvb-rotate-left-right.patch \
  133. file://0096-target-riscv-rvb-generalized-reverse.patch \
  134. file://0097-target-riscv-rvb-generalized-or-combine.patch \
  135. file://0098-target-riscv-rvb-address-calculation.patch \
  136. file://0099-target-riscv-rvb-add-shift-with-prefix-zero-extend.patch \
  137. file://0100-target-riscv-rvb-support-and-turn-on-B-extension-fro.patch \
  138. file://0101-target-riscv-rvb-add-b-ext-version-cpu-option.patch \
  139. file://0102-target-riscv-fix-REQUIRE_ZFH-macro-bug.patch \
  140. file://0103-linux-user-elfload-Implement-ELF_HWCAP-for-RISC-V.patch \
  141. file://0104-target-riscv-Pass-the-same-value-to-oprsz-and-maxsz.patch \
  142. file://0105-target-riscv-Backup-restore-mstatus.SD-bit-when-virt.patch \
  143. file://0106-target-riscv-Force-to-set-mstatus_hs.-SD-FS-bits-in-.patch \
  144. file://0107-target-riscv-Force-to-set-mstatus_hs.-SD-VS-bits-in-.patch \
  145. file://0001-merge-riscv-bitmapip-b0p94-version.patch \
  146. file://0002-Add-four-cache-csr-instruction.patch \
  147. "
  148. UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
  149. SRC_URI[sha256sum] = "87bc1a471ca24b97e7005711066007d443423d19aacda3d442558ae032fa30b9"
  150. SRC_URI_append_class-target = " file://cross.patch"
  151. SRC_URI_append_class-nativesdk = " file://cross.patch"
  152. # Applies against virglrender < 0.6.0 and not qemu itself
  153. CVE_CHECK_WHITELIST += "CVE-2017-5957"
  154. # The VNC server can expose host files uder some circumstances. We don't
  155. # enable it by default.
  156. CVE_CHECK_WHITELIST += "CVE-2007-0998"
  157. # 'The issues identified by this CVE were determined to not constitute a vulnerability.'
  158. # https://bugzilla.redhat.com/show_bug.cgi?id=1609015#c11
  159. CVE_CHECK_WHITELIST += "CVE-2018-18438"
  160. COMPATIBLE_HOST_mipsarchn32 = "null"
  161. COMPATIBLE_HOST_mipsarchn64 = "null"
  162. # Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
  163. # upstream states qemu doesn't work without optimization
  164. DEBUG_BUILD = "0"
  165. do_install_append() {
  166. # Prevent QA warnings about installed ${localstatedir}/run
  167. if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
  168. }
  169. do_install_ptest() {
  170. cp -rL ${B}/tests ${D}${PTEST_PATH}
  171. find ${D}${PTEST_PATH}/tests -type f -name "*.[Sshcodp]" | xargs -i rm -rf {}
  172. # Don't check the file genreated by configure
  173. sed -i -e "1s,#!/usr/bin/bash,#!${base_bindir}/bash," ${D}${PTEST_PATH}/tests/data/acpi/disassemle-aml.sh
  174. # Strip the paths from the QEMU variable, we can use PATH
  175. sed -i -e "s#^QEMU=.*/qemu-#QEMU=qemu-#g" ${D}${PTEST_PATH}/tests/tcg/*.mak
  176. }
  177. # QEMU_TARGETS is overridable variable
  178. QEMU_TARGETS ?= "arm aarch64 i386 mips mipsel mips64 mips64el ppc ppc64 ppc64le riscv32 riscv64 sh4 x86_64"
  179. EXTRA_OECONF = " \
  180. --prefix=${prefix} \
  181. --bindir=${bindir} \
  182. --includedir=${includedir} \
  183. --libdir=${libdir} \
  184. --mandir=${mandir} \
  185. --datadir=${datadir} \
  186. --docdir=${docdir}/${BPN} \
  187. --sysconfdir=${sysconfdir} \
  188. --libexecdir=${libexecdir} \
  189. --localstatedir=${localstatedir} \
  190. --with-suffix=${BPN} \
  191. --disable-strip \
  192. --disable-werror \
  193. --extra-cflags='${CFLAGS}' \
  194. --extra-ldflags='${LDFLAGS}' \
  195. --with-git=/bin/false \
  196. --with-git-submodules=ignore \
  197. --meson=meson \
  198. ${PACKAGECONFIG_CONFARGS} \
  199. "
  200. export LIBTOOL="${HOST_SYS}-libtool"
  201. B = "${WORKDIR}/build"
  202. #EXTRA_OECONF_append = " --python=${HOSTTOOLS_DIR}/python3"
  203. do_configure_prepend_class-native() {
  204. # Append build host pkg-config paths for native target since the host may provide sdl
  205. BHOST_PKGCONFIG_PATH=$(PATH=/usr/bin:/bin pkg-config --variable pc_path pkg-config || echo "")
  206. if [ ! -z "$BHOST_PKGCONFIG_PATH" ]; then
  207. export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$BHOST_PKGCONFIG_PATH
  208. fi
  209. }
  210. do_configure() {
  211. ${S}/configure ${EXTRA_OECONF}
  212. }
  213. do_configure[cleandirs] += "${B}"
  214. do_install () {
  215. export STRIP=""
  216. oe_runmake 'DESTDIR=${D}' install
  217. }
  218. # The following fragment will create a wrapper for qemu-mips user emulation
  219. # binary in order to work around a segmentation fault issue. Basically, by
  220. # default, the reserved virtual address space for 32-on-64 bit is set to 4GB.
  221. # This will trigger a MMU access fault in the virtual CPU. With this change,
  222. # the qemu-mips works fine.
  223. # IMPORTANT: This piece needs to be removed once the root cause is fixed!
  224. do_install_append() {
  225. if [ -e "${D}/${bindir}/qemu-mips" ]; then
  226. create_wrapper ${D}/${bindir}/qemu-mips \
  227. QEMU_RESERVED_VA=0x0
  228. fi
  229. }
  230. # END of qemu-mips workaround
  231. make_qemu_wrapper() {
  232. gdk_pixbuf_module_file=`pkg-config --variable=gdk_pixbuf_cache_file gdk-pixbuf-2.0`
  233. for tool in `ls ${D}${bindir}/qemu-system-*`; do
  234. create_wrapper $tool \
  235. GDK_PIXBUF_MODULE_FILE=$gdk_pixbuf_module_file \
  236. FONTCONFIG_PATH=/etc/fonts \
  237. GTK_THEME=Adwaita
  238. done
  239. }
  240. # Disable kvm/virgl/mesa on targets that do not support it
  241. PACKAGECONFIG_remove_darwin = "kvm virglrenderer glx gtk+"
  242. PACKAGECONFIG_remove_mingw32 = "kvm virglrenderer glx gtk+"
  243. PACKAGECONFIG[sdl] = "--enable-sdl,--disable-sdl,libsdl2"
  244. PACKAGECONFIG[virtfs] = "--enable-virtfs --enable-attr --enable-cap-ng,--disable-virtfs,libcap-ng attr,"
  245. PACKAGECONFIG[aio] = "--enable-linux-aio,--disable-linux-aio,libaio,"
  246. PACKAGECONFIG[xfs] = "--enable-xfsctl,--disable-xfsctl,xfsprogs,"
  247. PACKAGECONFIG[xen] = "--enable-xen,--disable-xen,xen-tools,xen-tools-libxenstore xen-tools-libxenctrl xen-tools-libxenguest"
  248. PACKAGECONFIG[vnc-sasl] = "--enable-vnc --enable-vnc-sasl,--disable-vnc-sasl,cyrus-sasl,"
  249. PACKAGECONFIG[vnc-jpeg] = "--enable-vnc --enable-vnc-jpeg,--disable-vnc-jpeg,jpeg,"
  250. PACKAGECONFIG[vnc-png] = "--enable-vnc --enable-vnc-png,--disable-vnc-png,libpng,"
  251. PACKAGECONFIG[libcurl] = "--enable-curl,--disable-curl,curl,"
  252. PACKAGECONFIG[nss] = "--enable-smartcard,--disable-smartcard,nss,"
  253. PACKAGECONFIG[curses] = "--enable-curses,--disable-curses,ncurses,"
  254. PACKAGECONFIG[gtk+] = "--enable-gtk,--disable-gtk,gtk+3 gettext-native"
  255. PACKAGECONFIG[vte] = "--enable-vte,--disable-vte,vte gettext-native"
  256. PACKAGECONFIG[libcap-ng] = "--enable-cap-ng,--disable-cap-ng,libcap-ng,"
  257. PACKAGECONFIG[ssh] = "--enable-libssh,--disable-libssh,libssh,"
  258. PACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt,"
  259. PACKAGECONFIG[nettle] = "--enable-nettle,--disable-nettle,nettle"
  260. PACKAGECONFIG[libusb] = "--enable-libusb,--disable-libusb,libusb1"
  261. PACKAGECONFIG[fdt] = "--enable-fdt,--disable-fdt,dtc"
  262. PACKAGECONFIG[alsa] = "--audio-drv-list='oss alsa',,alsa-lib"
  263. PACKAGECONFIG[glx] = "--enable-opengl,--disable-opengl,virtual/libgl"
  264. PACKAGECONFIG[lzo] = "--enable-lzo,--disable-lzo,lzo"
  265. PACKAGECONFIG[numa] = "--enable-numa,--disable-numa,numactl"
  266. PACKAGECONFIG[gnutls] = "--enable-gnutls,--disable-gnutls,gnutls"
  267. PACKAGECONFIG[bzip2] = "--enable-bzip2,--disable-bzip2,bzip2"
  268. PACKAGECONFIG[libiscsi] = "--enable-libiscsi,--disable-libiscsi"
  269. PACKAGECONFIG[kvm] = "--enable-kvm,--disable-kvm"
  270. PACKAGECONFIG[virglrenderer] = "--enable-virglrenderer,--disable-virglrenderer,virglrenderer"
  271. # spice will be in meta-networking layer
  272. PACKAGECONFIG[spice] = "--enable-spice,--disable-spice,spice"
  273. # usbredir will be in meta-networking layer
  274. PACKAGECONFIG[usb-redir] = "--enable-usb-redir,--disable-usb-redir,usbredir"
  275. PACKAGECONFIG[snappy] = "--enable-snappy,--disable-snappy,snappy"
  276. PACKAGECONFIG[glusterfs] = "--enable-glusterfs,--disable-glusterfs,glusterfs"
  277. PACKAGECONFIG[xkbcommon] = "--enable-xkbcommon,--disable-xkbcommon,libxkbcommon"
  278. PACKAGECONFIG[libudev] = "--enable-libudev,--disable-libudev,eudev"
  279. PACKAGECONFIG[libxml2] = "--enable-libxml2,--disable-libxml2,libxml2"
  280. PACKAGECONFIG[attr] = "--enable-attr,--disable-attr,attr,"
  281. PACKAGECONFIG[rbd] = "--enable-rbd,--disable-rbd,ceph,ceph"
  282. PACKAGECONFIG[vhost] = "--enable-vhost-net,--disable-vhost-net,,"
  283. PACKAGECONFIG[ust] = "--enable-trace-backend=ust,--enable-trace-backend=nop,lttng-ust,"
  284. PACKAGECONFIG[pie] = "--enable-pie,--disable-pie,,"
  285. PACKAGECONFIG[seccomp] = "--enable-seccomp,--disable-seccomp,libseccomp"
  286. INSANE_SKIP_${PN} = "arch"
  287. FILES_${PN} += "${datadir}/icons"