Package: qemu-user-static
Version: 1:3.1+dfsg-4
Severity: normal

Dear Maintainer,

Trying to build gitlab-runner on an ThunderX arm64 box it tries to run a
docker image with armhf binaries which fails:

  standard_init_linux.go:207: exec user process caused "exec format error"

You can replicate by running:

  14:30:41 [root@qemu-test:/v/l/d/info] 1 # uname -a
  Linux qemu-test 4.20.0 #5 SMP Tue Jan 8 10:57:44 UTC 2019 aarch64 aarch64 
aarch64 GNU/Linux
  14:30:46 [root@qemu-test:/v/l/d/info] # arch-test -n armhf
  armhf: not supported on this machine/kernel

The underlying reason is because binfmt_misc isn't set up for armhf
binaries because qemu-user-static.postinst does:

  # find which fmts needs to be filtered out, which is arch-dependent.
  # Drop support for emulating amd64 on i386, http://bugs.debian.org/604712
  case "$DPKG_MAINTSCRIPT_ARCH" in
    amd64 | i386) omit="i386|x86_64" ;;
    arm | armel | armhf | arm64) omit="arm|aarch64" ;;
    mips | mipsel) omit="$DPKG_MAINTSCRIPT_ARCH" ;;
    ppc64 | powerpc) omit="ppc|ppc64|ppc64abi32" ;;
    ppc64el) omit="ppc64le" ;;
    s390x) omit="s390x" ;;
    sparc | sparc64) omit="sparc|sparc32plus|sparc64" ;;
    *) omit="$DPKG_MAINTSCRIPT_ARCH" ;;
  esac

Which is certainly not true for all aarch64 CPUs. Some do not support
aarch32. The following change makes it work but requires arch-test as a
dependency:

  # find which fmts needs to be filtered out, which is arch-dependent.
  # Drop support for emulating amd64 on i386, http://bugs.debian.org/604712
  case "$DPKG_MAINTSCRIPT_ARCH" in
    amd64 | i386) omit="i386|x86_64" ;;
    arm | armel | armhf) omit="arm" ;;
    arm64 )
        if arch-test -n armhf > /dev/null; then
            omit="arm|aarch64"
        else
            omit="aarch64"
        fi
        ;;
    mips | mipsel) omit="$DPKG_MAINTSCRIPT_ARCH" ;;
    ppc64 | powerpc) omit="ppc|ppc64|ppc64abi32" ;;
    ppc64el) omit="ppc64le" ;;
    s390x) omit="s390x" ;;
    sparc | sparc64) omit="sparc|sparc32plus|sparc64" ;;
    *) omit="$DPKG_MAINTSCRIPT_ARCH" ;;
  esac

This logic is repeated in the prerm script so there is probably some
scope in cleaning up and sharing the logic.

-- System Information:
Ubuntu Release: bionic
Debian Release: buster/sid
Architecture: arm64

I found this on bionic but the bug exists upstream as well:

binfmt-support/bionic,now 2.1.8-2 arm64 [installed,automatic]
qemu-user-static/bionic-updates,now 1:2.11+dfsg-1ubuntu7.10 arm64 [installed]

-- no debconf information

--
Alex Bennée

Reply via email to