Difference between revisions of "AArch64 QEMU User Space Emulation"

From CDOT Wiki
Jump to: navigation, search
(Created page with '== QEMU linux-user == There is a [http://wiki.qemu.org/Main_Page QEMU] userspace emulator available to execute AArch64 applications on a x86_64 machine and kernel. This program …')
 
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[Category:SPO600]]
 +
{{Admon/obsolete|[[AArch64 Emulation]]}}
 
== QEMU linux-user ==
 
== QEMU linux-user ==
  
There is a [http://wiki.qemu.org/Main_Page QEMU] userspace emulator available to execute AArch64 applications on a x86_64 machine and kernel. This program interprets aarch64 binaries and translate operating system calls to the underlying x86_64 kernel, enabling many aarch64 binaries to be executed with good performance. However, because it does not emulate the full system, some capabilities are not available: in particular, debugging software such as gdb and strace will not work.
+
There is a [http://wiki.qemu.org/Main_Page QEMU] userspace emulator available to execute AArch64 applications on an x86_64 machine and kernel. This program interprets aarch64 binaries and translates operating system calls to the underlying x86_64 kernel, enabling many aarch64 binaries to be executed with good performance. However, because it does not emulate the full system, some capabilities are not available: in particular, debugging software such as gdb and strace will not work.
 +
 
 +
This system works by installing a binfmt (binary format) handler for aarch64 binaries. When the kernel attempts to execute a binary, it will analyze the binary's signature data, and if it matches the aarch64 elf signature, the qemu userspace system is invoked as an interpreter for the binary.
 +
 
 +
This approach works best when a directory tree of a complete aarch64 system is installed, and then chroot is used to make that the root of a new process; this allows the aarch64 binaries to easily use aarch64 shared object libraries (.so). The qemu binfmt handler/interpreter can be installed inside the aarch64 directory tree.
 +
 
 +
Therefore, the two pieces that need to be installed are the directory tree, containing the aarch64 userspace files and interpreter, and the binfmt configuration file.
  
 
== Special Mounts ==
 
== Special Mounts ==
Line 7: Line 15:
 
In the arm64 chroot, some commands such as ''mount'' and ''top'' will not work correctly because special filesystems such as <code>/proc</code> and <code>/sys</code> are not mounted. If you need those filesystems, explicitly mount them within your chroot environment, remembering to unmount them when you're done.
 
In the arm64 chroot, some commands such as ''mount'' and ''top'' will not work correctly because special filesystems such as <code>/proc</code> and <code>/sys</code> are not mounted. If you need those filesystems, explicitly mount them within your chroot environment, remembering to unmount them when you're done.
  
{{Admon/caution|Superuser access - Danger!|While in the chroot environment, you are a superuser. Although the chroot provides partial protection, it is still possible to cause '''major damage'''. Take care not to delete entries in the special mounts or perform other actions that would affect the host or other users.}}
+
{{Admon/caution|Superuser access - Danger!|While in the chroot environment, you are a superuser. Although the chroot provides partial protection, it is still possible to cause '''major damage'''. Take care not to delete entries in the special mounts or perform other actions that would affect the host or other users.<br/><br />If you create a regular user within the chroot environment for safety, you can change to that user using the command <code>su ''username''</code>}}
  
 
== Setting Up Qemu User Space Emulation ==
 
== Setting Up Qemu User Space Emulation ==
  
On your home system:
+
{{Admon/important|Fedora 19|The tarball mentioned here contains the preliminary aarch64 version of Fedora 19. The library versions, etc. are very old -- some of the earliest Aarch64 ports. Please feel free to update the image and contribute an updated tarball!}}
 +
 
 +
=== On Xerxes ===
  
1. Obtain the files in the <code>/public/qemu-linux-user-aarch64</code> directory on Australia: <code>arm64.qemu-userspace.tgz</code> and <code>qemu-arm64.conf</code>
+
1. Unpack the archive in your home directory:
 +
 
 +
cd ; sudo tar xvf /public/qemu-linux-user-aarch64
 +
 
 +
2. To switch to arm64/aarch64 mode, type:
 +
 
 +
sudo chroot ~/arm64
 +
 
 +
{{Admon/tip|Alias Recommended|It's a good idea to create an alias (and additional sudoers entry) to simplify the transition to the arm64 chroot. Doing so is left as an exercise for the reader.}}
 +
 
 +
=== On your home system ===
 +
 
 +
1. Obtain the files in the <code>/public/qemu-linux-user-aarch64</code> directory on Xerxes: <code>arm64.qemu-userspace.tgz</code> and <code>qemu-arm64.conf</code>
  
 
2. Copy those files your machine.
 
2. Copy those files your machine.
Line 28: Line 50:
  
 
  sudo chroot ~/arm64 # or wherever you put your arm64 directory
 
  sudo chroot ~/arm64 # or wherever you put your arm64 directory
 
On Australia:
 
 
1. Unpack the archive in your home directory:
 
 
cd ; tar xvf /public/qemu-linux-user-aarch64
 
 
2. To switch to arm64/aarch64 mode, type:
 
 
sudo chroot ~/arm64
 

Latest revision as of 10:32, 13 October 2023

Important.png
This page may be obsolete.
It contains historical information. For current information, please see AArch64 Emulation.

QEMU linux-user

There is a QEMU userspace emulator available to execute AArch64 applications on an x86_64 machine and kernel. This program interprets aarch64 binaries and translates operating system calls to the underlying x86_64 kernel, enabling many aarch64 binaries to be executed with good performance. However, because it does not emulate the full system, some capabilities are not available: in particular, debugging software such as gdb and strace will not work.

This system works by installing a binfmt (binary format) handler for aarch64 binaries. When the kernel attempts to execute a binary, it will analyze the binary's signature data, and if it matches the aarch64 elf signature, the qemu userspace system is invoked as an interpreter for the binary.

This approach works best when a directory tree of a complete aarch64 system is installed, and then chroot is used to make that the root of a new process; this allows the aarch64 binaries to easily use aarch64 shared object libraries (.so). The qemu binfmt handler/interpreter can be installed inside the aarch64 directory tree.

Therefore, the two pieces that need to be installed are the directory tree, containing the aarch64 userspace files and interpreter, and the binfmt configuration file.

Special Mounts

In the arm64 chroot, some commands such as mount and top will not work correctly because special filesystems such as /proc and /sys are not mounted. If you need those filesystems, explicitly mount them within your chroot environment, remembering to unmount them when you're done.

Stop (medium size).png
Superuser access - Danger!
While in the chroot environment, you are a superuser. Although the chroot provides partial protection, it is still possible to cause major damage. Take care not to delete entries in the special mounts or perform other actions that would affect the host or other users.

If you create a regular user within the chroot environment for safety, you can change to that user using the command su username

Setting Up Qemu User Space Emulation

Important.png
Fedora 19
The tarball mentioned here contains the preliminary aarch64 version of Fedora 19. The library versions, etc. are very old -- some of the earliest Aarch64 ports. Please feel free to update the image and contribute an updated tarball!

On Xerxes

1. Unpack the archive in your home directory:

cd ; sudo tar xvf /public/qemu-linux-user-aarch64

2. To switch to arm64/aarch64 mode, type:

sudo chroot ~/arm64
Idea.png
Alias Recommended
It's a good idea to create an alias (and additional sudoers entry) to simplify the transition to the arm64 chroot. Doing so is left as an exercise for the reader.

On your home system

1. Obtain the files in the /public/qemu-linux-user-aarch64 directory on Xerxes: arm64.qemu-userspace.tgz and qemu-arm64.conf

2. Copy those files your machine.

3. In a suitable location with at least 1.1GB of storage available, unpack the arm64.qemu-userspace.tgz archive as root (use -p to preserve permissions and timestamps).

4. Put the qemu-arm64.conf file into /etc/binfmt.d/qemu-arm64.conf on your local machine.

4. Activate the new qemu-arm64 binformat configuration:

sudo systemctl restart systemd-binfmt

5. To switch to arm64/aarch64 mode, type:

sudo chroot ~/arm64 # or wherever you put your arm64 directory