Difference between revisions of "AArch64 Emulation"

From CDOT Wiki
Jump to: navigation, search
(Full Processor Emulation with qemu-aarch64)
(Partial Processor Emulation with qemu-aarch64)
Line 18: Line 18:
 
On an aarch64 machine, qemu-aarch64 may be used to provide unsupported system features.
 
On an aarch64 machine, qemu-aarch64 may be used to provide unsupported system features.
  
For example, the system [[SPO600 Servers|israel.cdot.systems]] is an [[Armv8]] system that does not have SVE or [[SVE2]] support. Using qemu-aarch64, you can emulate this capability. Armv8 aarch64 instructions that can be executed on the CPU will be, and additional instructions such as the SVE2 instructions will be executed in software by the emulator.
+
For example, the system [[SPO600 Servers|israel.cdot.systems]] is an [[ARMv8|Armv8]] system that does not have SVE or [[SVE2]] support. Using qemu-aarch64, you can emulate this capability. Armv8 aarch64 instructions that can be executed on the CPU will be, and additional instructions such as the SVE2 instructions will be executed in software by the emulator.
  
 
To use qemu-aarch64 in this way, run the emulator (optionally with additional arguments) on an aarch64 system (such as israel.cdot.systems) followed by the name of the executable you with to run:
 
To use qemu-aarch64 in this way, run the emulator (optionally with additional arguments) on an aarch64 system (such as israel.cdot.systems) followed by the name of the executable you with to run:

Revision as of 09:26, 13 October 2023

Processor emulation is the use of software to emulate (act like) hardware which is not present. It may be used in two different ways:

1. Full processor emulation - If the target architecture (the architecture for which the code was compiled) is completely different from the host architecture (the architecture of the machine on which the code will be executed), then full processor emulation is required. In this case, registers are represented by variables, and the operation of every machine language instruction is handled in software. This is very slow, typically running at less than 3% of the speed of native code (code compiled for the host architecture), but it is very flexible.

2. Partial processor emulation - If the target architecture is a newer or more advanced version of the host architecture, it is possible to execute most instructions directly on the host processor. An instruction which is not supported by the host will cause an exception (like a software interrupt) which would normally cause the process to be aborted. In partial processor emulation, the emulator handles the exception, processing the unsupported instruction using software emulation, and then returning control to the CPU. This is much faster than full processor emulation, because the majority of instructions are handled directly by the CPU. The performance varies according to the ratio of instructions which may be directly executed to instructions which must be handled in emulation.

Both of these techniques may be used in a virtual machine (VM), which simulates a full standalone computer, or for userspace emulation, which supports one processes (and possibly child processes) which a system which is otherwise natively running on the host system.

The QEMU project provides a range of high-quality emulators and virtualizers based on these two technologies.

qemu-aarch64 Userspace Emulation

The qemu-aarch64 emulator handles both full and partial processor emulation.

Partial Processor Emulation with qemu-aarch64

On an aarch64 machine, qemu-aarch64 may be used to provide unsupported system features.

For example, the system israel.cdot.systems is an Armv8 system that does not have SVE or SVE2 support. Using qemu-aarch64, you can emulate this capability. Armv8 aarch64 instructions that can be executed on the CPU will be, and additional instructions such as the SVE2 instructions will be executed in software by the emulator.

To use qemu-aarch64 in this way, run the emulator (optionally with additional arguments) on an aarch64 system (such as israel.cdot.systems) followed by the name of the executable you with to run:

$ qemu-aarch64 testprogram

See the Arm System Emulator] documentation on the QEMU web site for details on optional arguments which can be used to specify machine type, SVE/SVE2 vector length, and so forth. Note that qemu-aarch64 does not differentiate between SVE and SVE2 (at the time of writing, it is not possible to enable SVE without enabling SVE2).

Full Processor Emulation with qemu-aarch64

On non-aarch64 systems, you can use qemu-aarch64 for full processor emulation. However, this requires not only the qemu-aarch64 binary and the aarch64 test program you wish to execute, but all of the related pieces of userspace software. For dynamically-linked software, this will include the linker itself and all of the shared libraries.

In order to simplify the setup of such an environment, a fully-configured root filesystem has been built. It is available from the /public directory on israel.cdot.systems and portugal.cdot.systems:

/public/aarch64-f38-root.README       # README file with usage instructions
/public/aarch64-f38-root.tar.xz       # root filesystem

You will need an x86_64 host system running Linux to use this software (it has been tested on Fedora 38; it should work on other systems, but this is not guaranteed!).

Please download and read the *README file before downloading and attempting to use the root filesystem.