Skip to contentSkip to conversation

configure: Support QEMU cross-compiling for ARM64 host

PATCH Superseded Anup Patel 3 participants 6 messages Jan 8, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH 1/1 configure: Support QEMU cross-compiling for ARM64 host

We should be able to cross compile QEMU for ARM64 host.

This is required for trying out ARM 32-bit guest on ARM64 host using QEMU + KVM ARM64.

---
 configure |    5 +++++
 1 file changed, 5 insertions(+)
configure +5 -0
index fe18ed2..0bfb8bb 100755
@@ -366,6 +366,8 @@ elif check_define __s390__ ; then
   fi
 elif check_define __arm__ ; then
   cpu="arm"
+elif check_define __aarch64__ ; then
+  cpu="arm64"
 elif check_define __hppa__ ; then
   cpu="hppa"
 else
@@ -388,6 +390,9 @@ case "$cpu" in
   armv*b|armv*l|arm)
     cpu="arm"
   ;;
+  arm64|aarch64)
+    cpu="arm64"
+  ;;
   hppa|parisc|parisc64)
     cpu="hppa"
   ;;
Signature · 1 line
1.7.9.5
#1 lore raw

configure elif check_define __s390__ ; then · line 370

Quoted 10 lines · Anup Patel
configure +2 -0
index fe18ed2..0bfb8bb 100755
@@ -366,6 +366,8 @@ elif check_define __s390__ ; then
   fi
 elif check_define __arm__ ; then
   cpu="arm"
+elif check_define __aarch64__ ; then
+  cpu="arm64"

This should be "aarch64"...

configure case "$cpu" in · line 395

Quoted 10 lines
configure +3 -0
 elif check_define __hppa__ ; then
   cpu="hppa"
 else
@@ -388,6 +390,9 @@ case "$cpu" in
   armv*b|armv*l|arm)
     cpu="arm"
   ;;
+  arm64|aarch64)
+    cpu="arm64"
+  ;;

...and this should just be

      aarch64)
          cpu="aarch64"
     ;;

Here's the rationale for that naming...

So, to start off with, the official ARM terminology goes:
* ARMv8 is the new version of the architecture, covering both 32 and 64 bit systems. (v7 is the most recent public arch version and is 32 bit only.) There may well be a v9 in future.
* AArch64 is the 64 bit operating mode of a 64-bit aware v8 core. (AArch32 is the corresponding 32 bit operating mode.) The core can transition between these at exception boundaries.
* A64 is the instruction set visible in AArch64. A32 and T32 are the 'classic' ARM and Thumb(2) instruction sets visible in AArch32. NB that v8 includes some new stuff even in A32/T32 (eg crypto extensions, some extensions to Neon, etc).
* arm64 is what the kernel port is called, since Linus doesn't much like any of the above :-) Note that 'uname -m' still says "aarch64", and the gcc triplet uses "aarch64". Only kernel devs looking at source filenames see 'arm64'.

So, QEMU names:
For the target architecture name (ie what comes out in the qemu-foo and qemu-system-foo binary names) we generally use the same name that 'uname -m' produces on those machines. In this case that would be "aarch64", hence my suggested changes.

The translator sources (as and when we implement a
TCG QEMU target for this) should live under the existing target-arm. We will probably want to put the A64 decoder in its own file, ie target-arm/translate-a64.c.

[Big-endian would be aarch64_be, but let's not go there.]

Also, I suspect this isn't the only thing that will be required. Presumably for an aarch64 build of QEMU we want to use the 64 bit kernel KVM headers, which means we need to import them. Since neither ARM 32 or 64 bit KVM has landed upstream yet those parts are definitely not going to be ready for upstream qemu just yet. Similarly the configure check for whether we can set CONFIG_KVM needs to accept "target cpu is arm and host cpu is aarch64", otherwise we won't enable KVM at all.

-- PMM

author
#2 lore raw
Quoted 48 lines · Peter Maydell

configure elif check_define __s390__ ; then · line 370

Quoted 10 lines · Anup Patel
configure +2 -0
index fe18ed2..0bfb8bb 100755
@@ -366,6 +366,8 @@ elif check_define __s390__ ; then
   fi
 elif check_define __arm__ ; then
   cpu="arm"
+elif check_define __aarch64__ ; then
+  cpu="arm64"

This should be "aarch64"...

configure case "$cpu" in · line 395

Quoted 10 lines
configure +3 -0
 elif check_define __hppa__ ; then
   cpu="hppa"
 else
@@ -388,6 +390,9 @@ case "$cpu" in
   armv*b|armv*l|arm)
     cpu="arm"
   ;;
+  arm64|aarch64)
+    cpu="arm64"
+  ;;

...and this should just be

      aarch64)
          cpu="aarch64"
     ;;

Here's the rationale for that naming...

So, to start off with, the official ARM terminology goes:
* ARMv8 is the new version of the architecture, covering both 32 and 64 bit systems. (v7 is the most recent public arch version and is 32 bit only.) There may well be a v9 in future.
* AArch64 is the 64 bit operating mode of a 64-bit aware v8 core. (AArch32 is the corresponding 32 bit operating mode.) The core can transition between these at exception boundaries.
* A64 is the instruction set visible in AArch64. A32 and T32 are the 'classic' ARM and Thumb(2) instruction sets visible in AArch32. NB that v8 includes some new stuff even in A32/T32 (eg crypto extensions, some extensions to Neon, etc).
* arm64 is what the kernel port is called, since Linus doesn't much like any of the above :-) Note that 'uname -m' still says "aarch64", and the gcc triplet uses "aarch64". Only kernel devs looking at source filenames see 'arm64'.

Quoted 6 lines

So, QEMU names:
For the target architecture name (ie what comes out in the qemu-foo and qemu-system-foo binary names) we generally use the same name that 'uname -m' produces on those machines. In this case that would be "aarch64", hence my suggested changes.

Agree with your suggestion. I will update the patch accordingly.

Quoted 9 lines

The translator sources (as and when we implement a
TCG QEMU target for this) should live under the existing target-arm. We will probably want to put the A64 decoder in its own file, ie target-arm/translate-a64.c.

[Big-endian would be aarch64_be, but let's not go there.]

Quoted 9 lines

Also, I suspect this isn't the only thing that will be required. Presumably for an aarch64 build of QEMU we want to use the 64 bit kernel KVM headers, which means we need to import them. Since neither ARM 32 or 64 bit KVM has landed upstream yet those parts are definitely not going to be ready for upstream qemu just yet. Similarly the configure check for whether we can set CONFIG_KVM needs to accept "target cpu is arm and host cpu is aarch64", otherwise we won't enable KVM at all.

Yes. This patch only tries to make sure that the configure step falls through and
at-least QEMU cross-compilation starts.
(assuming we have provided the QEMU dependencies such as zlib, glib-2.0, etc.)

Quoted 3 lines

-- PMM

--Anup

#3 lore raw
Quoted 5 lines · Anup Patel
Quoted 1 line · Peter Maydell

Also, I suspect this isn't the only thing that will be required.

Yes. This patch only tries to make sure that the configure step falls through and at-least QEMU cross-compilation starts.

It's generally considered polite to mention if the patch you're posting is still in the "this doesn't actually work yet" state :-) Tagging it [RFC] rather than [PATCH] is probably also a good idea.

thanks
-- PMM

#4 lore raw
In reply to Peter Maydell
Quoted 2 lines · Peter Maydell

The translator sources (as and when we implement a
TCG QEMU target for this) should live under the existing target-arm.

Of this I'm not certain, given that A64 is different enough from A32 to warrant a brand new gcc backend. I havn't tried to reverse engineer the encodings from the binutils sources to understand the details; I'm happy to wait until proper documentation is finally released.

r~

#5 lore raw
Quoted 8 lines · Richard Henderson
Quoted 2 lines · Peter Maydell

The translator sources (as and when we implement a
TCG QEMU target for this) should live under the existing target-arm.

Of this I'm not certain, given that A64 is different enough from A32 to warrant a brand new gcc backend. I havn't tried to reverse engineer the encodings from the binutils sources to understand the details; I'm happy to wait until proper documentation is finally released.

Since an ARMv8 64 bit CPU can run both 32 bit and 64 bit binaries, a QEMU TCG system level emulator would need the existing 32 bit code as well as new 64 bit code, so putting them both in the same directory seems to make sense to me. GCC backends don't need to emit code for both modes at once (since you can only change mode on an exception boundary) so they don't have the same requirements.

(Also, all our other "we have a 32 and a 64 bit version" tcg targets live in a shared target-foo/ directory.)

-- PMM