From 5fed6ef4ba36f621ad6ff0ab01a32e718641a4f2 Mon Sep 17 00:00:00 2001 From: Andreas Grapentin Date: Mon, 12 Mar 2018 22:59:09 +0100 Subject: pcr/qemu-riscv-* superseded by qemu-git et al. --- pcr/qemu-git/65-kvm.rules | 2 + pcr/qemu-git/PKGBUILD | 240 ++++++++++++++++++++ pcr/qemu-git/qemu-ga.service | 8 + pcr/qemu-git/qemu.install | 8 + pcr/qemu-riscv-git/65-kvm.rules | 2 - pcr/qemu-riscv-git/PKGBUILD | 247 --------------------- pcr/qemu-riscv-git/qemu-ga.service | 8 - pcr/qemu-riscv-git/qemu.install | 8 - ...Use-if-to-only-call-validate_guest_space-.patch | 81 +++++++ ...Rename-validate_guest_space-init_guest_co.patch | 54 +++++ ...init_guest_space-Clean-up-if-we-can-t-ini.patch | 29 +++ ...init_guest_space-Correctly-handle-guest_s.patch | 47 ++++ ...init_guest_space-Clarify-page-alignment-l.patch | 120 ++++++++++ ...init_guest_commpage-Add-a-comment-about-s.patch | 30 +++ ...init_guest_space-Clean-up-control-flow-a-.patch | 94 ++++++++ ...init_guest_space-Don-t-try-to-align-if-we.patch | 50 +++++ ...init_guest_space-Add-a-comment-about-sear.patch | 29 +++ ...init_guest_space-Try-to-make-ARM-space-co.patch | 99 +++++++++ pcr/qemu-user-static-git/PKGBUILD | 173 +++++++++++++++ pcr/qemu-user-static-git/out | 81 +++++++ ...Use-if-to-only-call-validate_guest_space-.patch | 81 ------- ...Rename-validate_guest_space-init_guest_co.patch | 54 ----- ...init_guest_space-Clean-up-if-we-can-t-ini.patch | 29 --- ...init_guest_space-Correctly-handle-guest_s.patch | 47 ---- ...init_guest_space-Clarify-page-alignment-l.patch | 120 ---------- ...init_guest_commpage-Add-a-comment-about-s.patch | 30 --- ...init_guest_space-Clean-up-control-flow-a-.patch | 94 -------- ...init_guest_space-Don-t-try-to-align-if-we.patch | 50 ----- ...init_guest_space-Add-a-comment-about-sear.patch | 29 --- ...init_guest_space-Try-to-make-ARM-space-co.patch | 99 --------- pcr/qemu-user-static-riscv-git/PKGBUILD | 182 --------------- pcr/qemu-user-static-riscv-git/allow_elf64.patch | 27 --- 32 files changed, 1145 insertions(+), 1107 deletions(-) create mode 100644 pcr/qemu-git/65-kvm.rules create mode 100644 pcr/qemu-git/PKGBUILD create mode 100644 pcr/qemu-git/qemu-ga.service create mode 100644 pcr/qemu-git/qemu.install delete mode 100644 pcr/qemu-riscv-git/65-kvm.rules delete mode 100644 pcr/qemu-riscv-git/PKGBUILD delete mode 100644 pcr/qemu-riscv-git/qemu-ga.service delete mode 100644 pcr/qemu-riscv-git/qemu.install create mode 100644 pcr/qemu-user-static-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch create mode 100644 pcr/qemu-user-static-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch create mode 100644 pcr/qemu-user-static-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch create mode 100644 pcr/qemu-user-static-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch create mode 100644 pcr/qemu-user-static-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch create mode 100644 pcr/qemu-user-static-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch create mode 100644 pcr/qemu-user-static-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch create mode 100644 pcr/qemu-user-static-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch create mode 100644 pcr/qemu-user-static-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch create mode 100644 pcr/qemu-user-static-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch create mode 100644 pcr/qemu-user-static-git/PKGBUILD create mode 100644 pcr/qemu-user-static-git/out delete mode 100644 pcr/qemu-user-static-riscv-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch delete mode 100644 pcr/qemu-user-static-riscv-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch delete mode 100644 pcr/qemu-user-static-riscv-git/PKGBUILD delete mode 100644 pcr/qemu-user-static-riscv-git/allow_elf64.patch diff --git a/pcr/qemu-git/65-kvm.rules b/pcr/qemu-git/65-kvm.rules new file mode 100644 index 000000000..569ded9f9 --- /dev/null +++ b/pcr/qemu-git/65-kvm.rules @@ -0,0 +1,2 @@ +KERNEL=="kvm", GROUP="kvm", MODE="0660" +KERNEL=="vhost-net", GROUP="kvm", MODE="0660", TAG+="uaccess", OPTIONS+="static_node=vhost-net" diff --git a/pcr/qemu-git/PKGBUILD b/pcr/qemu-git/PKGBUILD new file mode 100644 index 000000000..c42869a37 --- /dev/null +++ b/pcr/qemu-git/PKGBUILD @@ -0,0 +1,240 @@ +# Maintainer: Frederic Bezies +# Contributor: ajs124 < aur at ajs124 dot de> +# Contributor: Devin Cofer +# Contributor: Tobias Powalowski +# Contributor: Sébastien "Seblu" Luttringer + +pkgbase=qemu-git +_gitname=qemu +pkgname=(qemu-git qemu-headless-git qemu-arch-extra-git qemu-headless-arch-extra-git qemu-block-{iscsi-git,rbd-git,gluster-git} qemu-guest-agent-git) +pkgdesc="A generic and open source machine emulator and virtualizer. Git version." +pkgver=v2.11.0.r2282.gfb5fff1588 +pkgrel=1 +epoch=3 +arch=(x86_64) +license=(GPL2 LGPL2.1) +url="http://wiki.qemu.org/" +_headlessdeps=(seabios gnutls libpng libaio numactl jemalloc xfsprogs libnfs lzo snappy curl vde2 libcap-ng spice libcacard usbredir) +depends=(dtc virglrenderer sdl2 vte3 libpulse "${_headlessdeps[@]}") +makedepends=(spice-protocol python2 ceph libiscsi glusterfs git) +source=(git://git.qemu.org/qemu.git + qemu-ga.service + 65-kvm.rules) +sha256sums=('SKIP' + '0b4f3283973bb3bc876735f051d8eaab68f0065502a3a5012141fad193538ea1' + '60dcde5002c7c0b983952746e6fb2cf06d6c5b425d64f340f819356e561e7fc7') + +case $CARCH in + i?86) _corearch=i386 ;; + x86_64) _corearch=x86_64 ;; +esac + +pkgver() { + cd "${srcdir}/${_gitname}" + git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g' +} + +prepare() { + cd "${srcdir}/${_gitname}" + mkdir build-{full,headless} + mkdir -p extra-arch-{full,headless}/usr/{bin,share/qemu} + + scripts/git-submodule.sh update ui/keycodemapdb capstone + + #cd "${srcdir}/${_gitname}" + sed -i 's/vte-2\.90/vte-2.91/g' configure +} + +build() { + _build full \ + --audio-drv-list="pa alsa sdl" + + _build headless \ + --audio-drv-list= \ + --disable-bluez \ + --disable-sdl \ + --disable-gtk \ + --disable-vte \ + --disable-opengl \ + --disable-virglrenderer +} + +_build() ( + cd ${srcdir}/${_gitname}/build-$1 + + # qemu vs. make 4 == bad + export ARFLAGS=rv + + # http://permalink.gmane.org/gmane.comp.emulators.qemu/238740 + export CFLAGS+=" -fPIC" + + ../configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --libexecdir=/usr/lib/qemu \ + --python=/usr/bin/python2 \ + --smbd=/usr/bin/smbd \ + --with-gtkabi=3.0 \ + --with-sdlabi=2.0 \ + --enable-modules \ + --enable-jemalloc \ + --disable-werror \ + "${@:2}" + + make +) + +package_qemu-git() { + optdepends=('qemu-arch-extra-git: extra architectures support') + conflicts=('qemu-headless' 'qemu' 'kvm' 'kvm-git' 'qemu-spice') + provides=('qemu-headless' 'qemu' 'qemu-kvm' 'qemu-spice') + replaces=(qemu-kvm) + + _package full +} + +package_qemu-headless-git() { + pkgdesc="QEMU without GUI. Git version." + depends=("${_headlessdeps[@]}") + optdepends=('qemu-headless-arch-extra-git: extra architectures support') + conflicts=('qemu-headless') + + _package headless +} + +_package() { + optdepends+=('ovmf: Tianocore UEFI firmware for qemu' + 'samba: SMB/CIFS server support' + 'qemu-block-iscsi-git: iSCSI block support' + 'qemu-block-rbd-git: RBD block support' + 'qemu-block-gluster-git: glusterfs block support') + install=qemu.install + options=(!strip) + + make -C ${srcdir}/${_gitname}/build-$1 DESTDIR="$pkgdir" install "${@:2}" + + # systemd stuff + install -Dm644 65-kvm.rules "$pkgdir/usr/lib/udev/rules.d/65-kvm.rules" + + # remove conflicting /var/run directory + cd "$pkgdir" + rm -r var + + cd usr/lib + tidy_strip + + # bridge_helper needs suid + # https://bugs.archlinux.org/task/32565 + chmod u+s qemu/qemu-bridge-helper + + # remove split block modules + rm -f qemu/block-{iscsi,rbd,gluster}.so + + cd ../bin + tidy_strip + + # remove extra arch + for _bin in qemu-*; do + [[ -f $_bin ]] || continue + + case ${_bin#qemu-} in + # guest agent + ga) rm "$_bin"; continue ;; + + # tools + img|io|nbd) continue ;; + + # core emu + system-${_corearch}) continue ;; + esac + + mv "$_bin" "$srcdir/$_gitname/extra-arch-$1/usr/bin" + done + + cd ../share/qemu + for _blob in *; do + [[ -f $_blob ]] || continue + + case $_blob in + # provided by seabios package + bios.bin|acpi-dsdt.aml|bios-256k.bin|vgabios-cirrus.bin|vgabios-qxl.bin|\ + vgabios-stdvga.bin|vgabios-vmware.bin) rm "$_blob"; continue ;; + + + # iPXE ROMs + efi-*|pxe-*) continue ;; + + # core blobs + kvmvapic.bin|linuxboot*|multiboot.bin|sgabios.bin|vgabios*) continue ;; + + # Trace events definitions + trace-events*) continue ;; + + # Logos + *.bmp|*.svg) continue ;; + esac + + mv "$_blob" "$srcdir/$_gitname/extra-arch-$1/usr/share/qemu" + done +} + +package_qemu-arch-extra-git() { + pkgdesc="QEMU for foreign architectures. Git version." + depends=(qemu) + provides=(qemu-arch-extra) + conflicts=(qemu-arch-extra) + options=(!strip) + + mv $srcdir/$_gitname/extra-arch-full/usr "$pkgdir" +} + +package_qemu-headless-arch-extra-git() { + pkgdesc="QEMU without GUI, for foreign architectures. Git version." + depends=(qemu-headless) + options=(!strip) + conflicts=(qemu-headless-arch-extra) + provides=(qemu-headless-arch-extra) + + mv $srcdir/$_gitname/extra-arch-headless/usr "$pkgdir" +} + +package_qemu-block-iscsi-git() { + pkgdesc="QEMU iSCSI block module. Git version." + depends=(glib2 libiscsi jemalloc) + conflicts=(qemu-block-iscsi) + provides=(qemu-block-iscsi) + + install -D $srcdir/$_gitname/build-full/block-iscsi.so "$pkgdir/usr/lib/qemu/block-iscsi.so" +} + +package_qemu-block-rbd-git() { + pkgdesc="QEMU RBD block module. Git version." + depends=(glib2 ceph) + conflicts=(qemu-block-rbd) + provides=(qemu-block-rbd) + + install -D $srcdir/$_gitname/build-full/block-rbd.so "$pkgdir/usr/lib/qemu/block-rbd.so" +} + +package_qemu-block-gluster-git() { + pkgdesc="QEMU GlusterFS block module. Git version." + depends=(glib2 glusterfs) + conflicts=(qemu-block-gluster) + provides=(qemu-block-gluster) + + install -D $srcdir/$_gitname/build-full/block-gluster.so "$pkgdir/usr/lib/qemu/block-gluster.so" +} + +package_qemu-guest-agent-git() { + pkgdesc="QEMU Guest Agent. Git version." + depends=(gcc-libs glib2) + conflicts=(qemu-guest-agent) + provides=(qemu-guest-agent) + + install -D $srcdir/$_gitname/build-full/qemu-ga "$pkgdir/usr/bin/qemu-ga" + install -Dm644 $srcdir/qemu-ga.service "$pkgdir/usr/lib/systemd/system/qemu-ga.service" + install -Dm755 "$srcdir/$_gitname/scripts/qemu-guest-agent/fsfreeze-hook" "$pkgdir/etc/qemu/fsfreeze-hook" +} + +# vim:set ts=2 sw=2 et: diff --git a/pcr/qemu-git/qemu-ga.service b/pcr/qemu-git/qemu-ga.service new file mode 100644 index 000000000..e5eb469f9 --- /dev/null +++ b/pcr/qemu-git/qemu-ga.service @@ -0,0 +1,8 @@ +[Unit] +Description=QEMU Guest Agent + +[Service] +ExecStart=/usr/bin/qemu-ga + +[Install] +WantedBy=multi-user.target diff --git a/pcr/qemu-git/qemu.install b/pcr/qemu-git/qemu.install new file mode 100644 index 000000000..9fe850d4e --- /dev/null +++ b/pcr/qemu-git/qemu.install @@ -0,0 +1,8 @@ +# Arg 1: the new package version +post_install() { + # trigger events on modules files when already loaded + for _f in /sys/devices/virtual/misc/{kvm,vhost-net}; do + [[ -e "$_f" ]] && udevadm trigger "$_f" + done + : +} diff --git a/pcr/qemu-riscv-git/65-kvm.rules b/pcr/qemu-riscv-git/65-kvm.rules deleted file mode 100644 index 569ded9f9..000000000 --- a/pcr/qemu-riscv-git/65-kvm.rules +++ /dev/null @@ -1,2 +0,0 @@ -KERNEL=="kvm", GROUP="kvm", MODE="0660" -KERNEL=="vhost-net", GROUP="kvm", MODE="0660", TAG+="uaccess", OPTIONS+="static_node=vhost-net" diff --git a/pcr/qemu-riscv-git/PKGBUILD b/pcr/qemu-riscv-git/PKGBUILD deleted file mode 100644 index db62ff60d..000000000 --- a/pcr/qemu-riscv-git/PKGBUILD +++ /dev/null @@ -1,247 +0,0 @@ -# Maintainer (AUR): Frederic Bezies -# Contributor (AUR): ajs124 < aur at ajs124 dot de> -# Contributor (AUR): Devin Cofer -# Contributor (AUR): Tobias Powalowski -# Contributor (AUR): Sébastien "Seblu" Luttringer - -# parabola changes and rationale: -# - apdapted from qemu-git on the AUR -# - changed to build riscv/riscv-qemu on github -# - checking out submodules in prepare - -pkgbase=qemu-riscv-git -_gitname=riscv-qemu -pkgname=(qemu-riscv-git qemu-riscv-headless-git qemu-riscv-arch-extra-git qemu-riscv-headless-arch-extra-git qemu-riscv-block-{iscsi-git,rbd-git,gluster-git} qemu-riscv-guest-agent-git) -pkgdesc="A generic and open source machine emulator and virtualizer. Git version with riscv support." -pkgver=2.11.50.r59354.b6e0a38a92 -pkgrel=1 -arch=(x86_64) -license=(GPL2 LGPL2.1) -url="https://github.com/riscv/riscv-qemu" -_headlessdeps=(seabios gnutls libpng libaio numactl jemalloc xfsprogs libnfs lzo snappy curl vde2 libcap-ng spice libcacard usbredir) -depends=(dtc virglrenderer sdl2 vte3 libpulse "${_headlessdeps[@]}") -makedepends=(spice-protocol python2 ceph libiscsi glusterfs git) -source=(git+https://github.com/riscv/riscv-qemu.git#tag=riscv-qemu-upstream-v8 - qemu-ga.service - 65-kvm.rules) -sha256sums=('SKIP' - '0b4f3283973bb3bc876735f051d8eaab68f0065502a3a5012141fad193538ea1' - '60dcde5002c7c0b983952746e6fb2cf06d6c5b425d64f340f819356e561e7fc7') - -case $CARCH in - i?86) _corearch=i386 ;; - x86_64) _corearch=x86_64 ;; -esac - -pkgver() { - cd "${srcdir}/${_gitname}" - - printf "%s.r%s.%s" "$(cat VERSION)" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" -} - -prepare() { - cd "${srcdir}/${_gitname}" - mkdir build-{full,headless} - mkdir -p extra-arch-{full,headless}/usr/{bin,share/qemu} - - #cd "${srcdir}/${_gitname}" - sed -i 's/vte-2\.90/vte-2.91/g' configure - - # update git submodules - scripts/git-submodule.sh update ui/keycodemapdb -} - -build() { - _build full \ - --audio-drv-list="pa alsa sdl" - - _build headless \ - --audio-drv-list= \ - --disable-bluez \ - --disable-sdl \ - --disable-gtk \ - --disable-vte \ - --disable-opengl \ - --disable-virglrenderer -} - -_build() ( - cd ${srcdir}/${_gitname}/build-$1 - - # qemu vs. make 4 == bad - export ARFLAGS=rv - - # http://permalink.gmane.org/gmane.comp.emulators.qemu/238740 - export CFLAGS+=" -fPIC" - - ../configure \ - --prefix=/usr \ - --sysconfdir=/etc \ - --localstatedir=/var \ - --libexecdir=/usr/lib/qemu \ - --python=/usr/bin/python2 \ - --smbd=/usr/bin/smbd \ - --with-gtkabi=3.0 \ - --with-sdlabi=2.0 \ - --enable-modules \ - --enable-jemalloc \ - --disable-werror \ - --disable-git-update \ - "${@:2}" - - make -) - -package_qemu-riscv-git() { - optdepends=('qemu-arch-extra-git: extra architectures support') - conflicts=('qemu-headless' 'qemu' 'kvm' 'kvm-git' 'qemu-spice') - provides=('qemu-headless' 'qemu' 'qemu-kvm' 'qemu-spice') - replaces=(qemu-kvm) - - _package full -} - -package_qemu-riscv-headless-git() { - pkgdesc="QEMU without GUI. Git version." - depends=("${_headlessdeps[@]}") - optdepends=('qemu-headless-arch-extra-git: extra architectures support') - conflicts=('qemu-headless') - - _package headless -} - -_package() { - optdepends+=('ovmf: Tianocore UEFI firmware for qemu' - 'samba: SMB/CIFS server support' - 'qemu-block-iscsi-git: iSCSI block support' - 'qemu-block-rbd-git: RBD block support' - 'qemu-block-gluster-git: glusterfs block support') - install=qemu.install - options=(!strip) - - make -C ${srcdir}/${_gitname}/build-$1 DESTDIR="$pkgdir" install "${@:2}" - - # systemd stuff - install -Dm644 65-kvm.rules "$pkgdir/usr/lib/udev/rules.d/65-kvm.rules" - - # remove conflicting /var/run directory - cd "$pkgdir" - rm -r var - - cd usr/lib - tidy_strip - - # bridge_helper needs suid - # https://bugs.archlinux.org/task/32565 - chmod u+s qemu/qemu-bridge-helper - - # remove split block modules - rm qemu/block-{iscsi,rbd,gluster}.so - - cd ../bin - tidy_strip - - # remove extra arch - for _bin in qemu-*; do - [[ -f $_bin ]] || continue - - case ${_bin#qemu-} in - # guest agent - ga) rm "$_bin"; continue ;; - - # tools - img|io|nbd) continue ;; - - # core emu - system-${_corearch}) continue ;; - esac - - mv "$_bin" "$srcdir/$_gitname/extra-arch-$1/usr/bin" - done - - cd ../share/qemu - for _blob in *; do - [[ -f $_blob ]] || continue - - case $_blob in - # provided by seabios package - bios.bin|acpi-dsdt.aml|bios-256k.bin|vgabios-cirrus.bin|vgabios-qxl.bin|\ - vgabios-stdvga.bin|vgabios-vmware.bin) rm "$_blob"; continue ;; - - - # iPXE ROMs - efi-*|pxe-*) continue ;; - - # core blobs - kvmvapic.bin|linuxboot*|multiboot.bin|sgabios.bin|vgabios*) continue ;; - - # Trace events definitions - trace-events*) continue ;; - - # Logos - *.bmp|*.svg) continue ;; - esac - - mv "$_blob" "$srcdir/$_gitname/extra-arch-$1/usr/share/qemu" - done -} - -package_qemu-riscv-arch-extra-git() { - pkgdesc="QEMU for foreign architectures. Git version." - depends=(qemu) - provides=(qemu-arch-extra) - conflicts=(qemu-arch-extra) - options=(!strip) - - mv $srcdir/$_gitname/extra-arch-full/usr "$pkgdir" -} - -package_qemu-riscv-headless-arch-extra-git() { - pkgdesc="QEMU without GUI, for foreign architectures. Git version." - depends=(qemu-headless) - options=(!strip) - conflicts=(qemu-headless-arch-extra) - provides=(qemu-headless-arch-extra) - - mv $srcdir/$_gitname/extra-arch-headless/usr "$pkgdir" -} - -package_qemu-riscv-block-iscsi-git() { - pkgdesc="QEMU iSCSI block module. Git version." - depends=(glib2 libiscsi jemalloc) - conflicts=(qemu-block-iscsi) - provides=(qemu-block-iscsi) - - install -D $srcdir/$_gitname/build-full/block-iscsi.so "$pkgdir/usr/lib/qemu/block-iscsi.so" -} - -package_qemu-riscv-block-rbd-git() { - pkgdesc="QEMU RBD block module. Git version." - depends=(glib2 ceph) - conflicts=(qemu-block-rbd) - provides=(qemu-block-rbd) - - install -D $srcdir/$_gitname/build-full/block-rbd.so "$pkgdir/usr/lib/qemu/block-rbd.so" -} - -package_qemu-riscv-block-gluster-git() { - pkgdesc="QEMU GlusterFS block module. Git version." - depends=(glib2 glusterfs) - conflicts=(qemu-block-gluster) - provides=(qemu-block-gluster) - - install -D $srcdir/$_gitname/build-full/block-gluster.so "$pkgdir/usr/lib/qemu/block-gluster.so" -} - -package_qemu-riscv-guest-agent-git() { - pkgdesc="QEMU Guest Agent. Git version." - depends=(gcc-libs glib2) - conflicts=(qemu-guest-agent) - provides=(qemu-guest-agent) - - install -D $srcdir/$_gitname/build-full/qemu-ga "$pkgdir/usr/bin/qemu-ga" - install -Dm644 $srcdir/qemu-ga.service "$pkgdir/usr/lib/systemd/system/qemu-ga.service" - install -Dm755 "$srcdir/$_gitname/scripts/qemu-guest-agent/fsfreeze-hook" "$pkgdir/etc/qemu/fsfreeze-hook" -} - -# vim:set ts=2 sw=2 et: diff --git a/pcr/qemu-riscv-git/qemu-ga.service b/pcr/qemu-riscv-git/qemu-ga.service deleted file mode 100644 index e5eb469f9..000000000 --- a/pcr/qemu-riscv-git/qemu-ga.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=QEMU Guest Agent - -[Service] -ExecStart=/usr/bin/qemu-ga - -[Install] -WantedBy=multi-user.target diff --git a/pcr/qemu-riscv-git/qemu.install b/pcr/qemu-riscv-git/qemu.install deleted file mode 100644 index 9fe850d4e..000000000 --- a/pcr/qemu-riscv-git/qemu.install +++ /dev/null @@ -1,8 +0,0 @@ -# Arg 1: the new package version -post_install() { - # trigger events on modules files when already loaded - for _f in /sys/devices/virtual/misc/{kvm,vhost-net}; do - [[ -e "$_f" ]] && udevadm trigger "$_f" - done - : -} diff --git a/pcr/qemu-user-static-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch b/pcr/qemu-user-static-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch new file mode 100644 index 000000000..bbc3840fe --- /dev/null +++ b/pcr/qemu-user-static-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch @@ -0,0 +1,81 @@ +From 0c5afb7a15b6bb0e3fe276e377ad3702427e85d1 Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Wed, 27 Dec 2017 03:33:21 -0500 +Subject: [PATCH 01/10] linux-user: Use #if to only call validate_guest_space + for 32-bit ARM target + +Instead of defining a bogus validate_guest_space that always returns 1 on +targets other than 32-bit ARM, use #if blocks to only call it on 32-bit ARM +targets. This makes the "normal" flow control clearer. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 20f3d8c2c3..cac991159c 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -354,7 +354,6 @@ enum { + + /* The commpage only exists for 32 bit kernels */ + +-#define TARGET_HAS_VALIDATE_GUEST_SPACE + /* Return 1 if the proposed guest space is suitable for the guest. + * Return 0 if the proposed guest space isn't suitable, but another + * address space should be tried. +@@ -1823,15 +1822,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, + return sp; + } + +-#ifndef TARGET_HAS_VALIDATE_GUEST_SPACE +-/* If the guest doesn't have a validation function just agree */ +-static int validate_guest_space(unsigned long guest_base, +- unsigned long guest_size) +-{ +- return 1; +-} +-#endif +- + unsigned long init_guest_space(unsigned long host_start, + unsigned long host_size, + unsigned long guest_start, +@@ -1845,11 +1835,12 @@ unsigned long init_guest_space(unsigned long host_start, + /* If just a starting address is given, then just verify that + * address. */ + if (host_start && !host_size) { ++#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) + if (validate_guest_space(host_start, host_size) == 1) { +- return host_start; +- } else { + return (unsigned long)-1; + } ++#endif ++ return host_start; + } + + /* Setup the initial flags and start address. */ +@@ -1888,6 +1879,8 @@ unsigned long init_guest_space(unsigned long host_start, + + /* Check to see if the address is valid. */ + if (!host_start || real_start == current_start) { ++#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) ++ /* On 32-bit ARM, we need to also be able to map the commpage. */ + int valid = validate_guest_space(real_start - guest_start, + real_size); + if (valid == 1) { +@@ -1896,6 +1889,10 @@ unsigned long init_guest_space(unsigned long host_start, + return (unsigned long)-1; + } + /* valid == 0, so try again. */ ++#else ++ /* On other architectures, whatever we have here is fine. */ ++ break; ++#endif + } + + /* That address didn't work. Unmap and try a different one. +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch b/pcr/qemu-user-static-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch new file mode 100644 index 000000000..06e508219 --- /dev/null +++ b/pcr/qemu-user-static-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch @@ -0,0 +1,54 @@ +From b5b929b0423e5db333c9d5dfc104bb3598ff4182 Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Thu, 28 Dec 2017 08:03:26 -0500 +Subject: [PATCH 02/10] linux-user: Rename validate_guest_space => + init_guest_commpage + +init_guest_commpage is a much more honest description of what the function +does. validate_guest_space not only suggests that the function has no +side-effects, but also introduces confusion as to why it is only needed on +32-bit ARM targets. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index cac991159c..453394239c 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -362,8 +362,8 @@ enum { + * The guest code may leave a page mapped and populate it if the + * address is suitable. + */ +-static int validate_guest_space(unsigned long guest_base, +- unsigned long guest_size) ++static int init_guest_commpage(unsigned long guest_base, ++ unsigned long guest_size) + { + unsigned long real_start, test_page_addr; + +@@ -1836,7 +1836,7 @@ unsigned long init_guest_space(unsigned long host_start, + * address. */ + if (host_start && !host_size) { + #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) +- if (validate_guest_space(host_start, host_size) == 1) { ++ if (init_guest_commpage(host_start, host_size) != 1) { + return (unsigned long)-1; + } + #endif +@@ -1881,8 +1881,8 @@ unsigned long init_guest_space(unsigned long host_start, + if (!host_start || real_start == current_start) { + #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) + /* On 32-bit ARM, we need to also be able to map the commpage. */ +- int valid = validate_guest_space(real_start - guest_start, +- real_size); ++ int valid = init_guest_commpage(real_start - guest_start, ++ real_size); + if (valid == 1) { + break; + } else if (valid == -1) { +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch b/pcr/qemu-user-static-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch new file mode 100644 index 000000000..ea9eff138 --- /dev/null +++ b/pcr/qemu-user-static-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch @@ -0,0 +1,29 @@ +From c03d2cc51c5fa496f894b641c035b12e49fd637b Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Wed, 27 Dec 2017 14:40:39 -0500 +Subject: [PATCH 03/10] linux-user: init_guest_space: Clean up if we can't + initialize the commpage + +We'll just exit with an error anyway, so it doesn't really matter, but it +is cleaned up in all of the other places were we error out. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 453394239c..1a6b660b25 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1886,6 +1886,7 @@ unsigned long init_guest_space(unsigned long host_start, + if (valid == 1) { + break; + } else if (valid == -1) { ++ munmap((void *)real_start, host_size); + return (unsigned long)-1; + } + /* valid == 0, so try again. */ +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch b/pcr/qemu-user-static-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch new file mode 100644 index 000000000..7f9cfc7a8 --- /dev/null +++ b/pcr/qemu-user-static-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch @@ -0,0 +1,47 @@ +From bc26025ccc64a2a63fc58776c93e2e4392445abe Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Wed, 27 Dec 2017 19:44:00 -0500 +Subject: [PATCH 04/10] linux-user: init_guest_space: Correctly handle + guest_start in commpage initialization + +init_guest_commpage needs to check if the mapped space, which ends at +real_start+real_size overlaps with where it needs to put the commpage, +which is (assuming sane qemu_host_page_size) guest_base + 0xffff000, where +guest_base is real_start - guest_start. + + [guest_base][ 0xffff0000 ][commpage] + [guest_base][guest_start][real_size] [commpage] + [ real_start ][real_size] [commpage] + ^ + fail if this gap < 0 + +Since init_guest_commpage wants to do everything relative to guest_base +(rather than real_start), it obviously needs to be comparing 0xffff0000 +against guest_start+real_size, not just real_size. + +This bug has been present since 806d102141b99d4f1e55a97d68b7ea8c8ba3129f in +2012, but guest_start is usually 0, and prior to v2.11 real_size was +usually much smaller than 0xffff0000, so it was uncommon for it to have +made a difference. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 1a6b660b25..f41cecc3cb 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1882,7 +1882,7 @@ unsigned long init_guest_space(unsigned long host_start, + #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) + /* On 32-bit ARM, we need to also be able to map the commpage. */ + int valid = init_guest_commpage(real_start - guest_start, +- real_size); ++ real_size + guest_start); + if (valid == 1) { + break; + } else if (valid == -1) { +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch b/pcr/qemu-user-static-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch new file mode 100644 index 000000000..1570774ee --- /dev/null +++ b/pcr/qemu-user-static-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch @@ -0,0 +1,120 @@ +From b2432d1b415143a55083782712f11241f194c0ba Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Wed, 27 Dec 2017 20:05:52 -0500 +Subject: [PATCH 05/10] linux-user: init_guest_space: Clarify page alignment + logic + +There are 3 parts to this change: + - Add a comment showing the relative sizes and positions of the blocks of + memory + - introduce and use new aligned_{start,size} instead of adjusting + real_{start_size} + - When we clean up (on failure), munmap(real_start, real_size) instead of + munmap(aligned_start, aligned_size). It *shouldn't* make any + difference, but I will admit that this does mean we are making the + syscall with different values, so this isn't quite a no-op patch. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 43 +++++++++++++++++++++++++++++++++---------- + 1 file changed, 33 insertions(+), 10 deletions(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index f41cecc3cb..22f2632dfa 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1827,7 +1827,7 @@ unsigned long init_guest_space(unsigned long host_start, + unsigned long guest_start, + bool fixed) + { +- unsigned long current_start, real_start; ++ unsigned long current_start, aligned_start; + int flags; + + assert(host_start || host_size); +@@ -1853,7 +1853,8 @@ unsigned long init_guest_space(unsigned long host_start, + /* Otherwise, a non-zero size region of memory needs to be mapped + * and validated. */ + while (1) { +- unsigned long real_size = host_size; ++ unsigned long real_start, real_size, aligned_size; ++ aligned_size = real_size = host_size; + + /* Do not use mmap_find_vma here because that is limited to the + * guest address space. We are going to make the +@@ -1867,26 +1868,48 @@ unsigned long init_guest_space(unsigned long host_start, + + /* Ensure the address is properly aligned. */ + if (real_start & ~qemu_host_page_mask) { ++ /* Ideally, we adjust like ++ * ++ * pages: [ ][ ][ ][ ][ ] ++ * old: [ real ] ++ * [ aligned ] ++ * new: [ real ] ++ * [ aligned ] ++ * ++ * But if there is something else mapped right after it, ++ * then obviously it won't have room to grow, and the ++ * kernel will put the new larger real someplace else with ++ * unknown alignment (if we made it to here, then ++ * fixed=false). Which is why we grow real by a full page ++ * size, instead of by part of one; so that even if we get ++ * moved, we can still guarantee alignment. But this does ++ * mean that there is a padding of < 1 page both before ++ * and after the aligned range; the "after" could could ++ * cause problems for ARM emulation where it could butt in ++ * to where we need to put the commpage. ++ */ + munmap((void *)real_start, host_size); +- real_size = host_size + qemu_host_page_size; ++ real_size = aligned_size + qemu_host_page_size; + real_start = (unsigned long) + mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0); + if (real_start == (unsigned long)-1) { + return (unsigned long)-1; + } +- real_start = HOST_PAGE_ALIGN(real_start); ++ aligned_start = HOST_PAGE_ALIGN(real_start); ++ } else { ++ aligned_start = real_start; + } + + /* Check to see if the address is valid. */ +- if (!host_start || real_start == current_start) { ++ if (!host_start || aligned_start == current_start) { + #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) + /* On 32-bit ARM, we need to also be able to map the commpage. */ +- int valid = init_guest_commpage(real_start - guest_start, +- real_size + guest_start); ++ int valid = init_guest_commpage(aligned_start - guest_start, ++ aligned_size + guest_start); + if (valid == 1) { + break; + } else if (valid == -1) { +- munmap((void *)real_start, host_size); ++ munmap((void *)real_start, real_size); + return (unsigned long)-1; + } + /* valid == 0, so try again. */ +@@ -1905,7 +1928,7 @@ unsigned long init_guest_space(unsigned long host_start, + * address space randomization put a shared library somewhere + * inconvenient. + */ +- munmap((void *)real_start, host_size); ++ munmap((void *)real_start, real_size); + current_start += qemu_host_page_size; + if (host_start == current_start) { + /* Theoretically possible if host doesn't have any suitably +@@ -1917,7 +1940,7 @@ unsigned long init_guest_space(unsigned long host_start, + + qemu_log_mask(CPU_LOG_PAGE, "Reserved 0x%lx bytes of guest address space\n", host_size); + +- return real_start; ++ return aligned_start; + } + + static void probe_guest_base(const char *image_name, +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch b/pcr/qemu-user-static-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch new file mode 100644 index 000000000..4436b7817 --- /dev/null +++ b/pcr/qemu-user-static-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch @@ -0,0 +1,30 @@ +From ca873a81cc020df0ee0ec072a60678bb83dce9e2 Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Wed, 27 Dec 2017 21:05:29 -0500 +Subject: [PATCH 06/10] linux-user: init_guest_commpage: Add a comment about + size check + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 22f2632dfa..b560f5d6fe 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -374,6 +374,11 @@ static int init_guest_commpage(unsigned long guest_base, + + /* If the commpage lies within the already allocated guest space, + * then there is no way we can allocate it. ++ * ++ * You may be thinking that that this check is redundant because ++ * we already validated the guest size against MAX_RESERVED_VA; ++ * but if qemu_host_page_mask is unusually large, then ++ * test_page_addr may be lower. + */ + if (test_page_addr >= guest_base + && test_page_addr < (guest_base + guest_size)) { +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch b/pcr/qemu-user-static-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch new file mode 100644 index 000000000..59be04cf9 --- /dev/null +++ b/pcr/qemu-user-static-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch @@ -0,0 +1,94 @@ +From dbbba45fa37da85ac213fbbe1f7eab3e1de74b41 Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Wed, 27 Dec 2017 21:17:52 -0500 +Subject: [PATCH 07/10] linux-user: init_guest_space: Clean up control flow a + bit + +Instead of doing + + if (check1) { + if (check2) { + success; + } + } + + retry; + +Do a clearer + + if (!check1) { + goto try_again; + } + + if (!check2) { + goto try_again; + } + + success; + + try_again: + retry; + +Besides being clearer, this makes it easier to insert more checks that +need to trigger a retry on check failure, or rearrange them, or anything +like that. + +Because some indentation is changing, "ignore space change" may be useful +for viewing this patch. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 34 +++++++++++++++++++--------------- + 1 file changed, 19 insertions(+), 15 deletions(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index b560f5d6fe..5c0ad65611 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1906,24 +1906,28 @@ unsigned long init_guest_space(unsigned long host_start, + } + + /* Check to see if the address is valid. */ +- if (!host_start || aligned_start == current_start) { ++ if (host_start && aligned_start != current_start) { ++ goto try_again; ++ } ++ + #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) +- /* On 32-bit ARM, we need to also be able to map the commpage. */ +- int valid = init_guest_commpage(aligned_start - guest_start, +- aligned_size + guest_start); +- if (valid == 1) { +- break; +- } else if (valid == -1) { +- munmap((void *)real_start, real_size); +- return (unsigned long)-1; +- } +- /* valid == 0, so try again. */ +-#else +- /* On other architectures, whatever we have here is fine. */ +- break; +-#endif ++ /* On 32-bit ARM, we need to also be able to map the commpage. */ ++ int valid = init_guest_commpage(aligned_start - guest_start, ++ aligned_size + guest_start); ++ if (valid == -1) { ++ munmap((void *)real_start, real_size); ++ return (unsigned long)-1; ++ } else if (valid == -1) { ++ goto try_again; + } ++#endif ++ ++ /* If nothing has said `return -1` or `goto try_again` yet, ++ * then the address we have is good. ++ */ ++ break; + ++ try_again: + /* That address didn't work. Unmap and try a different one. + * The address the host picked because is typically right at + * the top of the host address space and leaves the guest with +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch b/pcr/qemu-user-static-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch new file mode 100644 index 000000000..9f434e116 --- /dev/null +++ b/pcr/qemu-user-static-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch @@ -0,0 +1,50 @@ +From 8f38106de8d023be8b3b28955df3615637c65dd9 Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Thu, 28 Dec 2017 06:42:12 -0500 +Subject: [PATCH 08/10] linux-user: init_guest_space: Don't try to align if + we'll reject it + +If the ensure-alignment code gets triggered, then the +"if (host_start && real_start != current_start)" check will always trigger, +so save 2 syscalls and put that check first. + +Note that we can't just switch to using MAP_FIXED for that check, because +then we couldn't differentiate between a failure because "there isn't +enough space" and "there isn't enough space *here*". + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 5c0ad65611..1b7583d659 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1871,6 +1871,11 @@ unsigned long init_guest_space(unsigned long host_start, + return (unsigned long)-1; + } + ++ /* Check to see if the address is valid. */ ++ if (host_start && real_start != current_start) { ++ goto try_again; ++ } ++ + /* Ensure the address is properly aligned. */ + if (real_start & ~qemu_host_page_mask) { + /* Ideally, we adjust like +@@ -1905,11 +1910,6 @@ unsigned long init_guest_space(unsigned long host_start, + aligned_start = real_start; + } + +- /* Check to see if the address is valid. */ +- if (host_start && aligned_start != current_start) { +- goto try_again; +- } +- + #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) + /* On 32-bit ARM, we need to also be able to map the commpage. */ + int valid = init_guest_commpage(aligned_start - guest_start, +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch b/pcr/qemu-user-static-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch new file mode 100644 index 000000000..e91fdefd8 --- /dev/null +++ b/pcr/qemu-user-static-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch @@ -0,0 +1,29 @@ +From 81033c66738a2e3b713c414e8e07e6ef8e59d8d7 Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Thu, 28 Dec 2017 07:22:29 -0500 +Subject: [PATCH 09/10] linux-user: init_guest_space: Add a comment about + search strategy + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 1b7583d659..7736ea2c3a 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1936,6 +1936,10 @@ unsigned long init_guest_space(unsigned long host_start, + * happen often. Probably means we got unlucky and host + * address space randomization put a shared library somewhere + * inconvenient. ++ * ++ * This is probably a good strategy if host_start, but is ++ * probably a bad strategy if not, which means we got here ++ * because of trouble with ARM commpage setup. + */ + munmap((void *)real_start, real_size); + current_start += qemu_host_page_size; +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch b/pcr/qemu-user-static-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch new file mode 100644 index 000000000..587293564 --- /dev/null +++ b/pcr/qemu-user-static-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch @@ -0,0 +1,99 @@ +From f8ccd5e7353937e0a48ccd8bfbc07202dc85afac Mon Sep 17 00:00:00 2001 +From: Luke Shumaker +Date: Thu, 28 Dec 2017 07:27:20 -0500 +Cc: paul@codesourcery.com +Subject: [PATCH 10/10] linux-user: init_guest_space: Try to make ARM + space+commpage continuous + +At a fixed distance after the usable memory that init_guest_space maps, for +32-bit ARM targets we also need to map a commpage. The normal +init_guest_space logic doesn't keep this in mind when searching for an +address range. + +If !host_start, then try to find a big continuous segment where we can put +both the usable memory and the commpage; we then munmap that segment and +set current_start to that address; and let the normal code mmap the usable +memory and the commpage separately. That is: if we don't have hint of +where to start looking for memory, come up with one that is better than +NULL. Depending on host_size and guest_start, there may or may not be a +gap between the usable memory and the commpage, so this is slightly more +restrictive than it needs to be; but it's only a hint, so that's OK. + +We only do that for !host start, because if host_start, then either: + - we got an address passed in with -B, in which case we don't want to + interfere with what the user said; + - or host_start is based off of the ELF image's loaddr. The check "if + (host_start && real_start != current_start)" suggests that we really + want lowest available address that is >= loaddr. I don't know why that + is, but I'm trusting that Paul Brook knew what he was doing when he + wrote the original version of that check in + c581deda322080e8beb88b2e468d4af54454e4b3 way back in 2010. + +Signed-off-by: Luke Shumaker +--- + linux-user/elfload.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 49 insertions(+) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 7736ea2c3a..cd3a7d877d 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1857,6 +1857,55 @@ unsigned long init_guest_space(unsigned long host_start, + + /* Otherwise, a non-zero size region of memory needs to be mapped + * and validated. */ ++ ++#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) ++ /* On 32-bit ARM, we need to map not just the usable memory, but ++ * also the commpage. Try to find a suitable place by allocating ++ * a big chunk for all of it. If host_start, then the naive ++ * strategy probably does good enough. ++ */ ++ if (!host_start) { ++ unsigned long guest_full_size, host_full_size, real_start; ++ ++ guest_full_size = ++ (0xffff0f00 & qemu_host_page_mask) + qemu_host_page_size; ++ host_full_size = guest_full_size - guest_start; ++ real_start = (unsigned long) ++ mmap(NULL, host_full_size, PROT_NONE, flags, -1, 0); ++ if (real_start == (unsigned long)-1) { ++ if (host_size < host_full_size - qemu_host_page_size) { ++ /* We failed to map a continous segment, but we're ++ * allowed to have a gap between the usable memory and ++ * the commpage where other things can be mapped. ++ * This sparseness gives us more flexibility to find ++ * an address range. ++ */ ++ goto naive; ++ } ++ return (unsigned long)-1; ++ } ++ munmap((void *)real_start, host_full_size); ++ if (real_start & ~qemu_host_page_mask) { ++ /* The same thing again, but with an extra qemu_host_page_size ++ * so that we can shift around alignment. ++ */ ++ unsigned long real_size = host_full_size + qemu_host_page_size; ++ real_start = (unsigned long) ++ mmap(NULL, real_size, PROT_NONE, flags, -1, 0); ++ if (real_start == (unsigned long)-1) { ++ if (host_size < host_full_size - qemu_host_page_size) { ++ goto naive; ++ } ++ return (unsigned long)-1; ++ } ++ munmap((void *)real_start, real_size); ++ real_start = HOST_PAGE_ALIGN(real_start); ++ } ++ current_start = real_start; ++ } ++ naive: ++#endif ++ + while (1) { + unsigned long real_start, real_size, aligned_size; + aligned_size = real_size = host_size; +-- +2.15.1 + diff --git a/pcr/qemu-user-static-git/PKGBUILD b/pcr/qemu-user-static-git/PKGBUILD new file mode 100644 index 000000000..a16fa8ebc --- /dev/null +++ b/pcr/qemu-user-static-git/PKGBUILD @@ -0,0 +1,173 @@ +# Maintainer (Arch:qemu): Tobias Powalowski +# Contributor (Arch:qemu): Sébastien "Seblu" Luttringer +# Maintainer: Luke Shumaker +# Contributor: Márcio Silva + +_pkgbase=qemu-git +_gitname=qemu +pkgname=(qemu-user-static-git qemu-user-static-binfmt-git) +pkgdesc="A generic and open source machine emulator and virtualizer. Git version." +pkgver=2.11.50.r59752.fb5fff1588 +pkgrel=1 +arch=(x86_64) +license=(GPL2 LGPL2.1) +url="http://wiki.qemu.org/" +makedepends=(git pixman-static glib2-static pcre-static python2) +source=(git://git.qemu.org/qemu.git + 0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch + 0002-linux-user-Rename-validate_guest_space-init_guest_co.patch + 0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch + 0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch + 0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch + 0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch + 0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch + 0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch + 0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch + 0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch) +sha256sums=('SKIP' + '9953a8debd9456adb4f5968817fa89da4d4542e44980a5533ccf86371d819845' + 'a977e9295daa14a9c73258cf16399eb5af66382217f8a4e69951ec044131a7ce' + 'dba2cfeb24841d45936091319957ee6f65e481da3c761791d410d3b8e6799998' + '75b3bda6752c4bf17488489f898767b6772b10ecc5d1f0a5bc1bd831e99a31e3' + '731895a8ed6f6d322bb60764b01cf09e0ea762d7d53fc01e91c2d2aecfdc8844' + '69b37040f52ef86b86c7c2952eb3f85f3c67d7adf289c43fdac8c71827c6e5b9' + '76f88850b0f52450eecb80029ffe16db6f418cec3b58231aca354cc20bbfb16a' + '76944d84990cc76e47c381849c683a346c5234bcebbe4c24334d0fd8368482db' + '7845867348fd380def28c7fe023e54cee8ff88cd6754aae3ab3472149cfbde51' + '1953e7cac58c23526d007d8559410e0042d4a7c1b8cbd5f4c0543f7f876436dd') +validpgpkeys=('CEACC9E15534EBABB82D3FA03353C9CEF108B584') + +case $CARCH in + i?86) _corearch=i386 ;; + x86_64) _corearch=x86_64 ;; +esac + +pkgver() { + cd "${srcdir}/${_gitname}" + + printf "%s.r%s.%s" "$(cat VERSION)" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +prepare() { + mkdir build-static + mkdir -p extra-arch-static/usr/{bin,share/qemu} + + cd "${srcdir}/${_gitname}" + sed -i 's/vte-2\.90/vte-2.91/g' configure + + # https://bugs.launchpad.net/qemu/+bug/1740219 + # https://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg05237.html + local patchfile + for patchfile in ../????-linux-user-*.patch; do + patch -p1 < "$patchfile" + done + + # update git submodules + scripts/git-submodule.sh update ui/keycodemapdb dtc +} + +build() { + local flags=( + --static + --disable-system # disable building qemu-system-$CPU, we only want qemu-$CPU + --disable-guest-agent # disable building qemu-ga + --disable-tools # disable building the qemu-{io,nbd,img} tools + --disable-blobs # disable installing firmware files used by system + --disable-docs + --disable-modules # modules imply dynamic linking + + # jemalloc-static isn't packaged + --disable-jemalloc + + # These libraries are only used for system or tools, but even + # though that's disabled, libqemuutil.a still tries to link + # against them unless we specifically tell it not to (the linkage + # would be removed at the final linker's tree-shaking). + --disable-gcrypt + --disable-nettle + ) + _build static "${flags[@]}" \ + --audio-drv-list= \ + --disable-bluez \ + --disable-sdl \ + --disable-gtk \ + --disable-vte \ + --disable-opengl \ + --disable-virglrenderer +} + +_build() ( + cd build-$1 + + # qemu vs. make 4 == bad + export ARFLAGS=rv + + # http://permalink.gmane.org/gmane.comp.emulators.qemu/238740 + export CFLAGS+=" -fPIC" + + ../${_gitname}/configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --libexecdir=/usr/lib/qemu \ + --python=/usr/bin/python2 \ + --smbd=/usr/bin/smbd \ + --with-gtkabi=3.0 \ + --with-sdlabi=2.0 \ + --enable-modules \ + --enable-jemalloc \ + --disable-git-update \ + "${@:2}" + + make +) + +package_qemu-user-static-git() { + pkgdesc="QEMU user-mode emulation (static binaries) - Git version." + + provides=("qemu-static=$pkgver") + conflicts=(qemu-static qemu-user-static) + + _package static + + rm -vr -- \ + "$pkgdir"/usr/lib/ \ + "$pkgdir"/usr/share/ + + local prog + for prog in "$pkgdir"/usr/bin/*; do + mv -nT -- "$prog" "${prog%-static}-static" + done +} + +_package() { + options=(!strip) + + make -C build-$1 DESTDIR="$pkgdir" install "${@:2}" + + cd "$pkgdir"/usr/bin + tidy_strip +} + +package_qemu-user-static-binfmt-git() { + pkgdesc="binfmt registration for QEMU user-mode emulation - Git version." + depends=("qemu-user-static-git=$pkgver") + + provides=("binfmt-qemu-static=$pkgver") + conflicts=('binfmt-qemu-static' 'qemu-user-static-binfmt') + + cd ${_gitname} + + install -d "$pkgdir"/usr/lib/binfmt.d + + < scripts/qemu-binfmt-conf.sh \ + sed -e 's/^CHECK=.*/CHECK=qemu_check_systemd/' \ + -e 's/^BINFMT_SET=.*/BINFMT_SET=qemu_generate_systemd/' \ + | sh /dev/stdin \ + --qemu-path /usr/bin \ + --exportdir "$pkgdir"/usr/lib/binfmt.d \ + --credential yes + + # add the "-static" suffix + sed -i 's/:[^:]*$/-static&/' -- "$pkgdir"/usr/lib/binfmt.d/*.conf +} diff --git a/pcr/qemu-user-static-git/out b/pcr/qemu-user-static-git/out new file mode 100644 index 000000000..b53c479cc --- /dev/null +++ b/pcr/qemu-user-static-git/out @@ -0,0 +1,81 @@ +ID State Output E-Level Times(r/u/s) Command [run=0/1] +114 finished /tmp/ts-out.jKXd3b 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/qtcreator +115 finished /tmp/ts-out.bLshXK 0 2.07/0.50/0.14 [114]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +116 finished /tmp/ts-out.4clmJN 0 3477.55/6939.77/472.28 [115]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +117 finished /tmp/ts-out.LesP6K 0 46.29/19.98/4.79 [116]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +118 finished /tmp/ts-out.FsJBTB 0 3549.12/7215.64/361.63 [117]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +119 finished /tmp/ts-out.1966dR 0 92.37/60.61/6.76 [118]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +120 finished /tmp/ts-out.xSySZl 1 121.93/16.85/2.16 [119]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +121 skipped (no output) [120]&& librestage +122 finished /tmp/ts-out.KQQ5SR 0 0.01/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/khotkeys +123 finished /tmp/ts-out.nS62vV 0 2.23/0.34/0.09 [122]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +124 finished /tmp/ts-out.iUm6cj 0 128.67/166.64/22.83 [123]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +125 finished /tmp/ts-out.RnwqqV 0 3.43/0.44/0.17 [124]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +126 finished /tmp/ts-out.fRfmqC 1 145.69/3.35/1.28 [125]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +127 skipped (no output) [126]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +128 skipped (no output) [127]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +129 skipped (no output) [128]&& librestage +130 finished /tmp/ts-out.qRKrxc 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/kinfocenter +131 finished /tmp/ts-out.cYMQmc 0 2.05/0.48/0.08 [130]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +132 finished /tmp/ts-out.62n1qk 0 89.65/136.29/18.21 [131]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +133 finished /tmp/ts-out.CtuGTQ 0 1.92/0.36/0.08 [132]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +134 finished /tmp/ts-out.SERXL1 1 26.15/4.06/0.65 [133]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +135 skipped (no output) [134]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +136 skipped (no output) [135]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +137 skipped (no output) [136]&& librestage +138 finished /tmp/ts-out.ZnBjor 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/kio-extras +139 finished /tmp/ts-out.8E8wer 0 2.03/0.44/0.11 [138]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +140 finished /tmp/ts-out.uBqekA 0 149.69/239.85/30.41 [139]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +141 finished /tmp/ts-out.YWHWJx 0 1.99/0.36/0.09 [140]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +142 finished /tmp/ts-out.RNe9ZD 1 68.01/6.23/0.77 [141]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +143 skipped (no output) [142]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +144 skipped (no output) [143]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +145 skipped (no output) [144]&& librestage +146 finished /tmp/ts-out.Qzqk7l 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/kio +147 finished /tmp/ts-out.zcsBam 0 2.05/0.46/0.09 [146]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +148 finished /tmp/ts-out.WqzjOy 2 11.73/9.36/1.55 [147]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +149 skipped (no output) [148]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +150 skipped (no output) [149]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +151 skipped (no output) [150]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +152 skipped (no output) [151]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +153 skipped (no output) [152]&& librestage +154 finished /tmp/ts-out.qPBy1S 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/ark +155 finished /tmp/ts-out.hq0gZS 0 2.01/0.46/0.10 [154]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +156 finished /tmp/ts-out.QWdn0Y 0 85.41/168.05/18.15 [155]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +157 finished /tmp/ts-out.R2kOmY 0 1.93/0.35/0.10 [156]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +158 finished /tmp/ts-out.ByXyGZ 1 11.01/7.78/1.82 [157]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +159 skipped (no output) [158]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +160 skipped (no output) [159]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +161 skipped (no output) [160]&& librestage +162 finished /tmp/ts-out.ZAcxSz 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/konqueror +163 finished /tmp/ts-out.24ch0z 0 2.01/0.44/0.11 [162]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +164 finished /tmp/ts-out.nY510G 2 19.05/15.45/3.71 [163]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +165 skipped (no output) [164]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +166 skipped (no output) [165]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +167 skipped (no output) [166]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +168 skipped (no output) [167]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +169 skipped (no output) [168]&& librestage +170 finished /tmp/ts-out.DFQFUN 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/okular +171 finished /tmp/ts-out.GYxJIN 0 2.02/0.45/0.11 [170]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +172 finished /tmp/ts-out.fRbbXX 0 217.58/461.79/47.29 [171]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +173 finished /tmp/ts-out.xV2Q2q 0 1.92/0.36/0.09 [172]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +174 finished /tmp/ts-out.rFR91u 1 105.93/8.18/1.11 [173]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +175 skipped (no output) [174]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +176 skipped (no output) [175]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +177 skipped (no output) [176]&& librestage +178 finished /tmp/ts-out.vvrtXa 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/libre/linux-libre-armv7 +179 finished /tmp/ts-out.weaBTb 0 2.74/1.20/0.12 [178]&& script --return --quiet --command sudo /usr/bin/librechroot -A armv7h -n default-armv7h update /dev/null +180 finished /tmp/ts-out.8A2Bm1 1 41.80/31.36/3.75 [179]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-armv7h /dev/null +181 skipped (no output) [180]&& librestage +182 finished /tmp/ts-out.pnAfO4 0 0.00/0.00/0.00 echo /home/andi/parabola/tree/abslibre/pcr/qemu-git +183 finished /tmp/ts-out.MO6WN4 0 2.29/0.45/0.09 [182]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +184 finished /tmp/ts-out.TJcZHx 0 2323.03/6351.91/490.83 [183]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +185 finished /tmp/ts-out.jbHsL1 0 3.66/0.45/0.18 [184]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +186 finished /tmp/ts-out.E56QbQ 1 58.06/16.16/3.95 [185]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +187 skipped (no output) [186]&& librestage +188 finished /tmp/ts-out.yj25w6 0 0.02/0.00/0.00 echo /home/andi/parabola/tree/abslibre/pcr/qemu-user-static-git +189 finished /tmp/ts-out.O6yyo5 0 2.44/0.50/0.16 [188]&& script --return --quiet --command sudo /usr/bin/librechroot -A x86_64 -n default-x86_64 update /dev/null +190 finished /tmp/ts-out.DbDqGL 2 14.80/5.27/3.26 [189]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-x86_64 /dev/null +191 skipped (no output) [190]&& script --return --quiet --command sudo /usr/bin/librechroot -A i686 -n default-i686 update /dev/null +192 skipped (no output) [191]&& script --return --quiet --command sudo /usr/bin/libremakepkg -n default-i686 /dev/null +193 skipped (no output) [192]&& librestage diff --git a/pcr/qemu-user-static-riscv-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch b/pcr/qemu-user-static-riscv-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch deleted file mode 100644 index bbc3840fe..000000000 --- a/pcr/qemu-user-static-riscv-git/0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 0c5afb7a15b6bb0e3fe276e377ad3702427e85d1 Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Wed, 27 Dec 2017 03:33:21 -0500 -Subject: [PATCH 01/10] linux-user: Use #if to only call validate_guest_space - for 32-bit ARM target - -Instead of defining a bogus validate_guest_space that always returns 1 on -targets other than 32-bit ARM, use #if blocks to only call it on 32-bit ARM -targets. This makes the "normal" flow control clearer. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 21 +++++++++------------ - 1 file changed, 9 insertions(+), 12 deletions(-) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 20f3d8c2c3..cac991159c 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -354,7 +354,6 @@ enum { - - /* The commpage only exists for 32 bit kernels */ - --#define TARGET_HAS_VALIDATE_GUEST_SPACE - /* Return 1 if the proposed guest space is suitable for the guest. - * Return 0 if the proposed guest space isn't suitable, but another - * address space should be tried. -@@ -1823,15 +1822,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, - return sp; - } - --#ifndef TARGET_HAS_VALIDATE_GUEST_SPACE --/* If the guest doesn't have a validation function just agree */ --static int validate_guest_space(unsigned long guest_base, -- unsigned long guest_size) --{ -- return 1; --} --#endif -- - unsigned long init_guest_space(unsigned long host_start, - unsigned long host_size, - unsigned long guest_start, -@@ -1845,11 +1835,12 @@ unsigned long init_guest_space(unsigned long host_start, - /* If just a starting address is given, then just verify that - * address. */ - if (host_start && !host_size) { -+#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - if (validate_guest_space(host_start, host_size) == 1) { -- return host_start; -- } else { - return (unsigned long)-1; - } -+#endif -+ return host_start; - } - - /* Setup the initial flags and start address. */ -@@ -1888,6 +1879,8 @@ unsigned long init_guest_space(unsigned long host_start, - - /* Check to see if the address is valid. */ - if (!host_start || real_start == current_start) { -+#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) -+ /* On 32-bit ARM, we need to also be able to map the commpage. */ - int valid = validate_guest_space(real_start - guest_start, - real_size); - if (valid == 1) { -@@ -1896,6 +1889,10 @@ unsigned long init_guest_space(unsigned long host_start, - return (unsigned long)-1; - } - /* valid == 0, so try again. */ -+#else -+ /* On other architectures, whatever we have here is fine. */ -+ break; -+#endif - } - - /* That address didn't work. Unmap and try a different one. --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch b/pcr/qemu-user-static-riscv-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch deleted file mode 100644 index 06e508219..000000000 --- a/pcr/qemu-user-static-riscv-git/0002-linux-user-Rename-validate_guest_space-init_guest_co.patch +++ /dev/null @@ -1,54 +0,0 @@ -From b5b929b0423e5db333c9d5dfc104bb3598ff4182 Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Thu, 28 Dec 2017 08:03:26 -0500 -Subject: [PATCH 02/10] linux-user: Rename validate_guest_space => - init_guest_commpage - -init_guest_commpage is a much more honest description of what the function -does. validate_guest_space not only suggests that the function has no -side-effects, but also introduces confusion as to why it is only needed on -32-bit ARM targets. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index cac991159c..453394239c 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -362,8 +362,8 @@ enum { - * The guest code may leave a page mapped and populate it if the - * address is suitable. - */ --static int validate_guest_space(unsigned long guest_base, -- unsigned long guest_size) -+static int init_guest_commpage(unsigned long guest_base, -+ unsigned long guest_size) - { - unsigned long real_start, test_page_addr; - -@@ -1836,7 +1836,7 @@ unsigned long init_guest_space(unsigned long host_start, - * address. */ - if (host_start && !host_size) { - #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) -- if (validate_guest_space(host_start, host_size) == 1) { -+ if (init_guest_commpage(host_start, host_size) != 1) { - return (unsigned long)-1; - } - #endif -@@ -1881,8 +1881,8 @@ unsigned long init_guest_space(unsigned long host_start, - if (!host_start || real_start == current_start) { - #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to also be able to map the commpage. */ -- int valid = validate_guest_space(real_start - guest_start, -- real_size); -+ int valid = init_guest_commpage(real_start - guest_start, -+ real_size); - if (valid == 1) { - break; - } else if (valid == -1) { --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch b/pcr/qemu-user-static-riscv-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch deleted file mode 100644 index ea9eff138..000000000 --- a/pcr/qemu-user-static-riscv-git/0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch +++ /dev/null @@ -1,29 +0,0 @@ -From c03d2cc51c5fa496f894b641c035b12e49fd637b Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Wed, 27 Dec 2017 14:40:39 -0500 -Subject: [PATCH 03/10] linux-user: init_guest_space: Clean up if we can't - initialize the commpage - -We'll just exit with an error anyway, so it doesn't really matter, but it -is cleaned up in all of the other places were we error out. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 453394239c..1a6b660b25 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1886,6 +1886,7 @@ unsigned long init_guest_space(unsigned long host_start, - if (valid == 1) { - break; - } else if (valid == -1) { -+ munmap((void *)real_start, host_size); - return (unsigned long)-1; - } - /* valid == 0, so try again. */ --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch b/pcr/qemu-user-static-riscv-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch deleted file mode 100644 index 7f9cfc7a8..000000000 --- a/pcr/qemu-user-static-riscv-git/0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch +++ /dev/null @@ -1,47 +0,0 @@ -From bc26025ccc64a2a63fc58776c93e2e4392445abe Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Wed, 27 Dec 2017 19:44:00 -0500 -Subject: [PATCH 04/10] linux-user: init_guest_space: Correctly handle - guest_start in commpage initialization - -init_guest_commpage needs to check if the mapped space, which ends at -real_start+real_size overlaps with where it needs to put the commpage, -which is (assuming sane qemu_host_page_size) guest_base + 0xffff000, where -guest_base is real_start - guest_start. - - [guest_base][ 0xffff0000 ][commpage] - [guest_base][guest_start][real_size] [commpage] - [ real_start ][real_size] [commpage] - ^ - fail if this gap < 0 - -Since init_guest_commpage wants to do everything relative to guest_base -(rather than real_start), it obviously needs to be comparing 0xffff0000 -against guest_start+real_size, not just real_size. - -This bug has been present since 806d102141b99d4f1e55a97d68b7ea8c8ba3129f in -2012, but guest_start is usually 0, and prior to v2.11 real_size was -usually much smaller than 0xffff0000, so it was uncommon for it to have -made a difference. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 1a6b660b25..f41cecc3cb 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1882,7 +1882,7 @@ unsigned long init_guest_space(unsigned long host_start, - #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to also be able to map the commpage. */ - int valid = init_guest_commpage(real_start - guest_start, -- real_size); -+ real_size + guest_start); - if (valid == 1) { - break; - } else if (valid == -1) { --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch b/pcr/qemu-user-static-riscv-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch deleted file mode 100644 index 1570774ee..000000000 --- a/pcr/qemu-user-static-riscv-git/0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch +++ /dev/null @@ -1,120 +0,0 @@ -From b2432d1b415143a55083782712f11241f194c0ba Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Wed, 27 Dec 2017 20:05:52 -0500 -Subject: [PATCH 05/10] linux-user: init_guest_space: Clarify page alignment - logic - -There are 3 parts to this change: - - Add a comment showing the relative sizes and positions of the blocks of - memory - - introduce and use new aligned_{start,size} instead of adjusting - real_{start_size} - - When we clean up (on failure), munmap(real_start, real_size) instead of - munmap(aligned_start, aligned_size). It *shouldn't* make any - difference, but I will admit that this does mean we are making the - syscall with different values, so this isn't quite a no-op patch. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 43 +++++++++++++++++++++++++++++++++---------- - 1 file changed, 33 insertions(+), 10 deletions(-) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index f41cecc3cb..22f2632dfa 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1827,7 +1827,7 @@ unsigned long init_guest_space(unsigned long host_start, - unsigned long guest_start, - bool fixed) - { -- unsigned long current_start, real_start; -+ unsigned long current_start, aligned_start; - int flags; - - assert(host_start || host_size); -@@ -1853,7 +1853,8 @@ unsigned long init_guest_space(unsigned long host_start, - /* Otherwise, a non-zero size region of memory needs to be mapped - * and validated. */ - while (1) { -- unsigned long real_size = host_size; -+ unsigned long real_start, real_size, aligned_size; -+ aligned_size = real_size = host_size; - - /* Do not use mmap_find_vma here because that is limited to the - * guest address space. We are going to make the -@@ -1867,26 +1868,48 @@ unsigned long init_guest_space(unsigned long host_start, - - /* Ensure the address is properly aligned. */ - if (real_start & ~qemu_host_page_mask) { -+ /* Ideally, we adjust like -+ * -+ * pages: [ ][ ][ ][ ][ ] -+ * old: [ real ] -+ * [ aligned ] -+ * new: [ real ] -+ * [ aligned ] -+ * -+ * But if there is something else mapped right after it, -+ * then obviously it won't have room to grow, and the -+ * kernel will put the new larger real someplace else with -+ * unknown alignment (if we made it to here, then -+ * fixed=false). Which is why we grow real by a full page -+ * size, instead of by part of one; so that even if we get -+ * moved, we can still guarantee alignment. But this does -+ * mean that there is a padding of < 1 page both before -+ * and after the aligned range; the "after" could could -+ * cause problems for ARM emulation where it could butt in -+ * to where we need to put the commpage. -+ */ - munmap((void *)real_start, host_size); -- real_size = host_size + qemu_host_page_size; -+ real_size = aligned_size + qemu_host_page_size; - real_start = (unsigned long) - mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0); - if (real_start == (unsigned long)-1) { - return (unsigned long)-1; - } -- real_start = HOST_PAGE_ALIGN(real_start); -+ aligned_start = HOST_PAGE_ALIGN(real_start); -+ } else { -+ aligned_start = real_start; - } - - /* Check to see if the address is valid. */ -- if (!host_start || real_start == current_start) { -+ if (!host_start || aligned_start == current_start) { - #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to also be able to map the commpage. */ -- int valid = init_guest_commpage(real_start - guest_start, -- real_size + guest_start); -+ int valid = init_guest_commpage(aligned_start - guest_start, -+ aligned_size + guest_start); - if (valid == 1) { - break; - } else if (valid == -1) { -- munmap((void *)real_start, host_size); -+ munmap((void *)real_start, real_size); - return (unsigned long)-1; - } - /* valid == 0, so try again. */ -@@ -1905,7 +1928,7 @@ unsigned long init_guest_space(unsigned long host_start, - * address space randomization put a shared library somewhere - * inconvenient. - */ -- munmap((void *)real_start, host_size); -+ munmap((void *)real_start, real_size); - current_start += qemu_host_page_size; - if (host_start == current_start) { - /* Theoretically possible if host doesn't have any suitably -@@ -1917,7 +1940,7 @@ unsigned long init_guest_space(unsigned long host_start, - - qemu_log_mask(CPU_LOG_PAGE, "Reserved 0x%lx bytes of guest address space\n", host_size); - -- return real_start; -+ return aligned_start; - } - - static void probe_guest_base(const char *image_name, --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch b/pcr/qemu-user-static-riscv-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch deleted file mode 100644 index 4436b7817..000000000 --- a/pcr/qemu-user-static-riscv-git/0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch +++ /dev/null @@ -1,30 +0,0 @@ -From ca873a81cc020df0ee0ec072a60678bb83dce9e2 Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Wed, 27 Dec 2017 21:05:29 -0500 -Subject: [PATCH 06/10] linux-user: init_guest_commpage: Add a comment about - size check - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 22f2632dfa..b560f5d6fe 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -374,6 +374,11 @@ static int init_guest_commpage(unsigned long guest_base, - - /* If the commpage lies within the already allocated guest space, - * then there is no way we can allocate it. -+ * -+ * You may be thinking that that this check is redundant because -+ * we already validated the guest size against MAX_RESERVED_VA; -+ * but if qemu_host_page_mask is unusually large, then -+ * test_page_addr may be lower. - */ - if (test_page_addr >= guest_base - && test_page_addr < (guest_base + guest_size)) { --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch b/pcr/qemu-user-static-riscv-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch deleted file mode 100644 index 59be04cf9..000000000 --- a/pcr/qemu-user-static-riscv-git/0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch +++ /dev/null @@ -1,94 +0,0 @@ -From dbbba45fa37da85ac213fbbe1f7eab3e1de74b41 Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Wed, 27 Dec 2017 21:17:52 -0500 -Subject: [PATCH 07/10] linux-user: init_guest_space: Clean up control flow a - bit - -Instead of doing - - if (check1) { - if (check2) { - success; - } - } - - retry; - -Do a clearer - - if (!check1) { - goto try_again; - } - - if (!check2) { - goto try_again; - } - - success; - - try_again: - retry; - -Besides being clearer, this makes it easier to insert more checks that -need to trigger a retry on check failure, or rearrange them, or anything -like that. - -Because some indentation is changing, "ignore space change" may be useful -for viewing this patch. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 34 +++++++++++++++++++--------------- - 1 file changed, 19 insertions(+), 15 deletions(-) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index b560f5d6fe..5c0ad65611 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1906,24 +1906,28 @@ unsigned long init_guest_space(unsigned long host_start, - } - - /* Check to see if the address is valid. */ -- if (!host_start || aligned_start == current_start) { -+ if (host_start && aligned_start != current_start) { -+ goto try_again; -+ } -+ - #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) -- /* On 32-bit ARM, we need to also be able to map the commpage. */ -- int valid = init_guest_commpage(aligned_start - guest_start, -- aligned_size + guest_start); -- if (valid == 1) { -- break; -- } else if (valid == -1) { -- munmap((void *)real_start, real_size); -- return (unsigned long)-1; -- } -- /* valid == 0, so try again. */ --#else -- /* On other architectures, whatever we have here is fine. */ -- break; --#endif -+ /* On 32-bit ARM, we need to also be able to map the commpage. */ -+ int valid = init_guest_commpage(aligned_start - guest_start, -+ aligned_size + guest_start); -+ if (valid == -1) { -+ munmap((void *)real_start, real_size); -+ return (unsigned long)-1; -+ } else if (valid == -1) { -+ goto try_again; - } -+#endif -+ -+ /* If nothing has said `return -1` or `goto try_again` yet, -+ * then the address we have is good. -+ */ -+ break; - -+ try_again: - /* That address didn't work. Unmap and try a different one. - * The address the host picked because is typically right at - * the top of the host address space and leaves the guest with --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch b/pcr/qemu-user-static-riscv-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch deleted file mode 100644 index 9f434e116..000000000 --- a/pcr/qemu-user-static-riscv-git/0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 8f38106de8d023be8b3b28955df3615637c65dd9 Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Thu, 28 Dec 2017 06:42:12 -0500 -Subject: [PATCH 08/10] linux-user: init_guest_space: Don't try to align if - we'll reject it - -If the ensure-alignment code gets triggered, then the -"if (host_start && real_start != current_start)" check will always trigger, -so save 2 syscalls and put that check first. - -Note that we can't just switch to using MAP_FIXED for that check, because -then we couldn't differentiate between a failure because "there isn't -enough space" and "there isn't enough space *here*". - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 5c0ad65611..1b7583d659 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1871,6 +1871,11 @@ unsigned long init_guest_space(unsigned long host_start, - return (unsigned long)-1; - } - -+ /* Check to see if the address is valid. */ -+ if (host_start && real_start != current_start) { -+ goto try_again; -+ } -+ - /* Ensure the address is properly aligned. */ - if (real_start & ~qemu_host_page_mask) { - /* Ideally, we adjust like -@@ -1905,11 +1910,6 @@ unsigned long init_guest_space(unsigned long host_start, - aligned_start = real_start; - } - -- /* Check to see if the address is valid. */ -- if (host_start && aligned_start != current_start) { -- goto try_again; -- } -- - #if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to also be able to map the commpage. */ - int valid = init_guest_commpage(aligned_start - guest_start, --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch b/pcr/qemu-user-static-riscv-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch deleted file mode 100644 index e91fdefd8..000000000 --- a/pcr/qemu-user-static-riscv-git/0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 81033c66738a2e3b713c414e8e07e6ef8e59d8d7 Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Thu, 28 Dec 2017 07:22:29 -0500 -Subject: [PATCH 09/10] linux-user: init_guest_space: Add a comment about - search strategy - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 1b7583d659..7736ea2c3a 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1936,6 +1936,10 @@ unsigned long init_guest_space(unsigned long host_start, - * happen often. Probably means we got unlucky and host - * address space randomization put a shared library somewhere - * inconvenient. -+ * -+ * This is probably a good strategy if host_start, but is -+ * probably a bad strategy if not, which means we got here -+ * because of trouble with ARM commpage setup. - */ - munmap((void *)real_start, real_size); - current_start += qemu_host_page_size; --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch b/pcr/qemu-user-static-riscv-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch deleted file mode 100644 index 587293564..000000000 --- a/pcr/qemu-user-static-riscv-git/0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch +++ /dev/null @@ -1,99 +0,0 @@ -From f8ccd5e7353937e0a48ccd8bfbc07202dc85afac Mon Sep 17 00:00:00 2001 -From: Luke Shumaker -Date: Thu, 28 Dec 2017 07:27:20 -0500 -Cc: paul@codesourcery.com -Subject: [PATCH 10/10] linux-user: init_guest_space: Try to make ARM - space+commpage continuous - -At a fixed distance after the usable memory that init_guest_space maps, for -32-bit ARM targets we also need to map a commpage. The normal -init_guest_space logic doesn't keep this in mind when searching for an -address range. - -If !host_start, then try to find a big continuous segment where we can put -both the usable memory and the commpage; we then munmap that segment and -set current_start to that address; and let the normal code mmap the usable -memory and the commpage separately. That is: if we don't have hint of -where to start looking for memory, come up with one that is better than -NULL. Depending on host_size and guest_start, there may or may not be a -gap between the usable memory and the commpage, so this is slightly more -restrictive than it needs to be; but it's only a hint, so that's OK. - -We only do that for !host start, because if host_start, then either: - - we got an address passed in with -B, in which case we don't want to - interfere with what the user said; - - or host_start is based off of the ELF image's loaddr. The check "if - (host_start && real_start != current_start)" suggests that we really - want lowest available address that is >= loaddr. I don't know why that - is, but I'm trusting that Paul Brook knew what he was doing when he - wrote the original version of that check in - c581deda322080e8beb88b2e468d4af54454e4b3 way back in 2010. - -Signed-off-by: Luke Shumaker ---- - linux-user/elfload.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 49 insertions(+) - -diff --git a/linux-user/elfload.c b/linux-user/elfload.c -index 7736ea2c3a..cd3a7d877d 100644 ---- a/linux-user/elfload.c -+++ b/linux-user/elfload.c -@@ -1857,6 +1857,55 @@ unsigned long init_guest_space(unsigned long host_start, - - /* Otherwise, a non-zero size region of memory needs to be mapped - * and validated. */ -+ -+#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) -+ /* On 32-bit ARM, we need to map not just the usable memory, but -+ * also the commpage. Try to find a suitable place by allocating -+ * a big chunk for all of it. If host_start, then the naive -+ * strategy probably does good enough. -+ */ -+ if (!host_start) { -+ unsigned long guest_full_size, host_full_size, real_start; -+ -+ guest_full_size = -+ (0xffff0f00 & qemu_host_page_mask) + qemu_host_page_size; -+ host_full_size = guest_full_size - guest_start; -+ real_start = (unsigned long) -+ mmap(NULL, host_full_size, PROT_NONE, flags, -1, 0); -+ if (real_start == (unsigned long)-1) { -+ if (host_size < host_full_size - qemu_host_page_size) { -+ /* We failed to map a continous segment, but we're -+ * allowed to have a gap between the usable memory and -+ * the commpage where other things can be mapped. -+ * This sparseness gives us more flexibility to find -+ * an address range. -+ */ -+ goto naive; -+ } -+ return (unsigned long)-1; -+ } -+ munmap((void *)real_start, host_full_size); -+ if (real_start & ~qemu_host_page_mask) { -+ /* The same thing again, but with an extra qemu_host_page_size -+ * so that we can shift around alignment. -+ */ -+ unsigned long real_size = host_full_size + qemu_host_page_size; -+ real_start = (unsigned long) -+ mmap(NULL, real_size, PROT_NONE, flags, -1, 0); -+ if (real_start == (unsigned long)-1) { -+ if (host_size < host_full_size - qemu_host_page_size) { -+ goto naive; -+ } -+ return (unsigned long)-1; -+ } -+ munmap((void *)real_start, real_size); -+ real_start = HOST_PAGE_ALIGN(real_start); -+ } -+ current_start = real_start; -+ } -+ naive: -+#endif -+ - while (1) { - unsigned long real_start, real_size, aligned_size; - aligned_size = real_size = host_size; --- -2.15.1 - diff --git a/pcr/qemu-user-static-riscv-git/PKGBUILD b/pcr/qemu-user-static-riscv-git/PKGBUILD deleted file mode 100644 index 89b83a008..000000000 --- a/pcr/qemu-user-static-riscv-git/PKGBUILD +++ /dev/null @@ -1,182 +0,0 @@ -# Maintainer (Arch:qemu): Tobias Powalowski -# Contributor (Arch:qemu): Sébastien "Seblu" Luttringer -# Maintainer: Luke Shumaker -# Contributor: Márcio Silva - -# parabola changes and rationale: -# - apdapted from ribre/qemu-user-static -# - changed to build riscv/riscv-qemu on github -# - checking out submodules in prepare - -_pkgbase=qemu -_gitname=riscv-qemu -pkgname=(qemu-user-static-riscv-git qemu-user-static-binfmt-riscv-git) -pkgdesc="A generic and open source machine emulator and virtualizer. Git version with riscv support." -pkgver=2.11.50.r59354.b6e0a38a92 -pkgrel=1 -arch=(x86_64) -license=(GPL2 LGPL2.1) -url="https://github.com/riscv/riscv-qemu" -makedepends=(git pixman-static glib2-static pcre-static python2) -source=("git+https://github.com/riscv/riscv-qemu.git#tag=riscv-qemu-upstream-v8" - 0001-linux-user-Use-if-to-only-call-validate_guest_space-.patch - 0002-linux-user-Rename-validate_guest_space-init_guest_co.patch - 0003-linux-user-init_guest_space-Clean-up-if-we-can-t-ini.patch - 0004-linux-user-init_guest_space-Correctly-handle-guest_s.patch - 0005-linux-user-init_guest_space-Clarify-page-alignment-l.patch - 0006-linux-user-init_guest_commpage-Add-a-comment-about-s.patch - 0007-linux-user-init_guest_space-Clean-up-control-flow-a-.patch - 0008-linux-user-init_guest_space-Don-t-try-to-align-if-we.patch - 0009-linux-user-init_guest_space-Add-a-comment-about-sear.patch - 0010-linux-user-init_guest_space-Try-to-make-ARM-space-co.patch - allow_elf64.patch) -sha256sums=('SKIP' - '9953a8debd9456adb4f5968817fa89da4d4542e44980a5533ccf86371d819845' - 'a977e9295daa14a9c73258cf16399eb5af66382217f8a4e69951ec044131a7ce' - 'dba2cfeb24841d45936091319957ee6f65e481da3c761791d410d3b8e6799998' - '75b3bda6752c4bf17488489f898767b6772b10ecc5d1f0a5bc1bd831e99a31e3' - '731895a8ed6f6d322bb60764b01cf09e0ea762d7d53fc01e91c2d2aecfdc8844' - '69b37040f52ef86b86c7c2952eb3f85f3c67d7adf289c43fdac8c71827c6e5b9' - '76f88850b0f52450eecb80029ffe16db6f418cec3b58231aca354cc20bbfb16a' - '76944d84990cc76e47c381849c683a346c5234bcebbe4c24334d0fd8368482db' - '7845867348fd380def28c7fe023e54cee8ff88cd6754aae3ab3472149cfbde51' - '1953e7cac58c23526d007d8559410e0042d4a7c1b8cbd5f4c0543f7f876436dd' - '13a6d9e678bdc9e1f051006cfd0555f5a80582368f54c8a1bb5a78ece3832ac4') -validpgpkeys=('CEACC9E15534EBABB82D3FA03353C9CEF108B584') - -case $CARCH in - i?86) _corearch=i386 ;; - x86_64) _corearch=x86_64 ;; -esac - -pkgver() { - cd "${srcdir}/${_gitname}" - - printf "%s.r%s.%s" "$(cat VERSION)" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" -} - -prepare() { - mkdir build-static - mkdir -p extra-arch-static/usr/{bin,share/qemu} - - cd "${srcdir}/${_gitname}" - sed -i 's/vte-2\.90/vte-2.91/g' configure - - # https://bugs.launchpad.net/qemu/+bug/1740219 - # https://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg05237.html - local patchfile - for patchfile in ../????-linux-user-*.patch; do - patch -p1 < "$patchfile" - done - - patch -p1 < ../allow_elf64.patch - - # update git submodules - scripts/git-submodule.sh update ui/keycodemapdb dtc -} - -build() { - local flags=( - --static - --disable-system # disable building qemu-system-$CPU, we only want qemu-$CPU - --disable-guest-agent # disable building qemu-ga - --disable-tools # disable building the qemu-{io,nbd,img} tools - --disable-blobs # disable installing firmware files used by system - --disable-docs - --disable-modules # modules imply dynamic linking - - # jemalloc-static isn't packaged - --disable-jemalloc - - # These libraries are only used for system or tools, but even - # though that's disabled, libqemuutil.a still tries to link - # against them unless we specifically tell it not to (the linkage - # would be removed at the final linker's tree-shaking). - --disable-gcrypt - --disable-nettle - ) - _build static "${flags[@]}" \ - --audio-drv-list= \ - --disable-bluez \ - --disable-sdl \ - --disable-gtk \ - --disable-vte \ - --disable-opengl \ - --disable-virglrenderer -} - -_build() ( - cd build-$1 - - # qemu vs. make 4 == bad - export ARFLAGS=rv - - # http://permalink.gmane.org/gmane.comp.emulators.qemu/238740 - export CFLAGS+=" -fPIC" - - ../${_gitname}/configure \ - --prefix=/usr \ - --sysconfdir=/etc \ - --localstatedir=/var \ - --libexecdir=/usr/lib/qemu \ - --python=/usr/bin/python2 \ - --smbd=/usr/bin/smbd \ - --with-gtkabi=3.0 \ - --with-sdlabi=2.0 \ - --enable-modules \ - --enable-jemalloc \ - --disable-git-update \ - "${@:2}" - - make -) - -package_qemu-user-static-riscv-git() { - pkgdesc="QEMU user-mode emulation (static binaries) - Git version with riscv support." - - provides=("qemu-static=$pkgver") - conflicts=(qemu-static qemu-user-static) - - _package static - - rm -vr -- \ - "$pkgdir"/usr/lib/ \ - "$pkgdir"/usr/share/ - - local prog - for prog in "$pkgdir"/usr/bin/*; do - mv -nT -- "$prog" "${prog%-static}-static" - done -} - -_package() { - options=(!strip) - - make -C build-$1 DESTDIR="$pkgdir" install "${@:2}" - - cd "$pkgdir"/usr/bin - tidy_strip -} - -package_qemu-user-static-binfmt-riscv-git() { - pkgdesc="binfmt registration for QEMU user-mode emulation - Git version with riscv support." - depends=("qemu-user-static-riscv-git=$pkgver") - - provides=("binfmt-qemu-static=$pkgver") - conflicts=('binfmt-qemu-static' 'qemu-user-static-binfmt') - - cd ${_gitname} - - install -d "$pkgdir"/usr/lib/binfmt.d - - < scripts/qemu-binfmt-conf.sh \ - sed -e 's/^CHECK=.*/CHECK=qemu_check_systemd/' \ - -e 's/^BINFMT_SET=.*/BINFMT_SET=qemu_generate_systemd/' \ - | sh /dev/stdin \ - --qemu-path /usr/bin \ - --exportdir "$pkgdir"/usr/lib/binfmt.d \ - --credential yes - - # add the "-static" suffix - sed -i 's/:[^:]*$/-static&/' -- "$pkgdir"/usr/lib/binfmt.d/*.conf -} diff --git a/pcr/qemu-user-static-riscv-git/allow_elf64.patch b/pcr/qemu-user-static-riscv-git/allow_elf64.patch deleted file mode 100644 index 07f27a038..000000000 --- a/pcr/qemu-user-static-riscv-git/allow_elf64.patch +++ /dev/null @@ -1,27 +0,0 @@ -commit 3c72765ec760a51f0e879dc792be82c93141e318 -Author: Anatol Pomozov -Date: Tue Jun 6 20:07:03 2017 -0700 - - Remove restriction that prevents bootimg elf64 images - - It is possible to create a 64 bit elf image that has valid multiboot header. - qemu should be able to boot such images. - - Signed-off-by: Anatol Pomozov - -diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c -index 663f35a658..cf1b4f5fb3 100644 ---- a/hw/i386/multiboot.c -+++ b/hw/i386/multiboot.c -@@ -192,11 +192,6 @@ int load_multiboot(FWCfgState *fw_cfg, - int kernel_size; - fclose(f); - -- if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) { -- fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n"); -- exit(1); -- } -- - kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, - &elf_low, &elf_high, 0, I386_ELF_MACHINE, - 0, 0); -- cgit v1.2.3