If we use qemu-arm64-system directly, it will cost too much time on IO and systemcalls.So I try to use SuSE’s userpsace mode qemu, which only reinterprets the arm64 instructions to x86_64 but processes all systemcalls to local host.
This installation manual for user-mode qemu-arm64 has tested on debian-7.7.0

Step 1, make directory for chroot.

mkdir ~/myarm

Step 2, build qemu of SuSE:

cd ~/
git clone https://github.com/susematz/qemu/tree/aarch64-1.6 qemu-arm64
cd ~/qemu-arm64
apt-get build-dep qemu
./configure --target-list=arm64-linux-user  --static --disable-werror

Add this patch to SuSE’s qemu before make it:

--- config-host.mak~    2013-10-30 16:09:57.440144183 +0000
+++ config-host.mak     2013-10-30 16:36:42.656104017 +0000
@@ -120,7 +120,7 @@
 LDFLAGS=-Wl,--warn-common -m64 -static -g 
 LIBTOOLFLAGS= -Wc,-fstack-protector-all
 LIBS+=-lrt -pthread -lgthread-2.0 -lglib-2.0 -lrt -lpcre    -liscsi
-LIBS_TOOLS+=-Wl,-z,relro -lssh2 -lgcrypt   -lvdeplug -luuid  -laio
+LIBS_TOOLS+=-Wl,-z,relro -lssh2 -lgcrypt   -lvdeplug -luuid  -laio -lgpg-error
 LIBS_QGA+=-lrt -pthread -lgthread-2.0 -lglib-2.0 -lrt -lpcre   
 POD2MAN=pod2man --utf8

Make the qemu and install it:

make -j8

Step 3, download arm64 disk image of Fedora 19, and extract it.

cd ~/
wget "http://dmarlin.fedorapeople.org/fedora-arm/aarch64/F19-aarch64-efi.tar.xz"
xd -d F19-aarch64-efi.tar.xz
tar xf F19-aarch64-efi.tar
virt-tar-out -a ../F19-aarch64-efi/aarch64-efi.img / - | sudo tar xf -

Copy the qemu-arm64

cd ~/qemu-arm64
cp arm64-linux-user/qemu-arm64 ~/myarm/usr/bin/qemu-arm64-static

Step 4, configure the binfmts-misc

sudo apt-get install binfmt-support qemu

and put the content below into /usr/share/binfmts/qemu-arm64 in normal system(not the chroot)

package qemu-user-static
interpreter /usr/bin/qemu-arm64-static
flags: OC
offset 0
magic \x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7
mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff

Then run

sudo update-binfmts --import qemu-arm64

Step 5, you could chroot into the user mode qemu now:

cd ~/myarm
sudo mount -o bind /dev ./dev
sudo mount -o bind /dev/pts ./dev/pts
sudo mount -o bind /proc ./proc
sudo mount -o bind /sys ./sys
sudo chroot .

Now, If you typein “arch”, it will report “aarch64”
Addtionally, add below contents into “aarch64” environtment’s /etc/yum.repos.d/stage4.repo:

name=Fedora fc19-stage4 - aarch64

You could use yum to install rpm of aarch64 now. If it report DNS unavailable, you could append  dmarlin.fedorapeople.org  arm.koji.fedoraproject.org

into /etc/hosts

I use this user-mode of arm64 Qemu to build linux kernel, but the speed of compiling is not very perfrect. After all, the user-mode Qemu only accelerate the speed of systemcall, not the reinterpreter of instructions. But in my opinion, it is still very useful because it could use host’s resource of network and storage efficiently (Don’t you think it looks like linux-container or lxc/docker ?). If this news is true, I think facebook could use cheap x86_64 machines to test their IOS apps instead of costly Mac minis 🙂

How to run aarch64 binaries on an x86-64 host using qemu userspace emulation