Skip to contentSkip to conversation

arm: tools: build for arm64 and enable cross-compiling for both arm32 and arm64

PATCH Applied Ian Campbell 4 participants 23 messages Mar 15, 2013 – Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

cover arm: tools: build for arm64 and enable cross-compiling for both arm32 and arm64

The following patches shave some rough edges off the tools build system to allow cross compiling for at least arm32 and arm64 based on the Debian/Ubuntu multiarch infrastructure. They also add the necessary fixes to build for arm64 (which I have only tried cross, not native).

I have posted some instructions on how to compile with these patches on the wiki:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/CrossCompiling

Thanks are due to Wookey who gave lots of good advice in the hackrooms at LinaroConnect last week.

I consider it an outstanding bug that you need to essentially pass CROSS_COMPILE and XEN_TARGET_ARCH to both configure and make. This is hardly the only remaining annoyance in our build system though...

Ian.

#1 lore raw

PATCH 1/9 tools: Use AC_SYS_LARGEFILE instead of calling getconf(1)

getconf is not cross-compile friendly since it reports the features of the host and not the target. There doesn't appear to be a $triplet-getconf.

AC_SYS_LARGEFILE arranges for #defines to appear in config.h however Xen's build system expects these to be part of C{PP}FLAGS. Since I'm not confident that everything in Xen includes config.h I instead arrange for the result of running AC_SYS_LARGERFILE to end up in CFLAGS.

---
 config/Tools.mk.in |    2 +
 tools/Rules.mk     |    5 +-
 tools/config.h.in  |    6 +
 tools/configure    | 1292 +++++++++++++++++++++++++++++++++++++++++-----------
 tools/configure.ac |   10 +
 5 files changed, 1042 insertions(+), 273 deletions(-)
config/Tools.mk.in +2 -0
index c69c7d2..5e2c6d8 100644
@@ -60,3 +60,5 @@ CONFIG_LIBICONV     := @libiconv@
 CONFIG_GCRYPT       := @libgcrypt@
 EXTFS_LIBS          := @EXTFS_LIBS@
 CURSES_LIBS         := @CURSES_LIBS@
+
+FILE_OFFSET_BITS    := @FILE_OFFSET_BITS@
tools/Rules.mk +3 -2
index 8d55e03..3f03a31 100644
@@ -65,11 +65,12 @@ CFLAGS += -D__XEN_TOOLS__
 CFLAGS += -MMD -MF .$(@F).d
 DEPS = .*.d
 
+ifneq ($(FILE_OFFSET_BITS),)
+CFLAGS  += -D_FILE_OFFSET_BITS=$(FILE_OFFSET_BITS)
+endif
 ifneq ($(XEN_OS),NetBSD)
 # Enable implicit LFS support *and* explicit LFS names.
-CFLAGS  += $(shell getconf LFS_CFLAGS)
 CFLAGS  += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-LDFLAGS += $(shell getconf LFS_LDFLAGS)
 endif
 
 # 32-bit x86 does not perform well with -ve segment accesses on Xen.
tools/config.h.in +6 -0
index 6d67503..08e337a 100644
@@ -68,3 +68,9 @@
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
tools/configure +1021 -271

1,358 lines not on this page · raw message

tools/configure.ac +10 -0
index 0d38408..f6e2fec 100644
@@ -21,6 +21,16 @@ APPEND_INCLUDES and APPEND_LIB instead when possible.])
 
 AC_CANONICAL_HOST
 
+AC_SYS_LARGEFILE
+
+case $ac_cv_sys_file_offset_bits in #(
+  no | unknown) ;;
+  *)
+  FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits
+;;
+esac
+AC_SUBST(FILE_OFFSET_BITS)
+
 # M4 Macro includes
 m4_include([../m4/savevar.m4])
 m4_include([../m4/features.m4])
Signature · 1 line
1.7.2.5
Acked-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] tools: Use AC_SYS_LARGEFILE instead of calling getconf(1)

Ian Campbell writes ("[PATCH 1/9] tools: Use AC_SYS_LARGEFILE instead of calling getconf(1)"):

Quoted 7 lines

getconf is not cross-compile friendly since it reports the features of the host and not the target. There doesn't appear to be a $triplet-getconf.

AC_SYS_LARGEFILE arranges for #defines to appear in config.h however Xen's build system expects these to be part of C{PP}FLAGS. Since I'm not confident that everything in Xen includes config.h I instead arrange for the result of running AC_SYS_LARGERFILE to end up in CFLAGS.

This looks plausible, assuming you've actually tested it :-).

#3 lore raw

PATCH 2/9 blktap2: use sys/eventfd.h if it is available

In reply to Ian Campbell

arm64 only has the eventfd2 system call and using the libc wrapper when available hides this from us. eventfd() has been in libc since glibc 2.8.

This code is already Linux specific.

---
 tools/blktap2/drivers/libaio-compat.h |   12 ++++++++++++
 tools/config.h.in                     |    3 +++
 tools/configure                       |    9 +++++----
 tools/configure.ac                    |    2 +-
 4 files changed, 21 insertions(+), 5 deletions(-)
tools/blktap2/drivers/libaio-compat.h +12 -0
index 353c36a..47cd96d 100644
@@ -29,6 +29,7 @@
 #ifndef __LIBAIO_COMPAT
 #define __LIBAIO_COMPAT
 
+#include "../../config.h"
 #include <libaio.h>
 #include <unistd.h>
 #include <sys/syscall.h>
@@ -50,6 +51,16 @@ static inline void __io_set_eventfd(struct iocb *iocb, int eventfd)
 	c->resfd = eventfd;
 }
 
+#ifdef HAVE_SYS_EVENTFD_H
+
+#include <sys/eventfd.h>
+
+static inline int tapdisk_sys_eventfd(int initval)
+{
+	return eventfd(initval, 0);
+}
+
+#else /* Fallback */
 #ifndef SYS_eventfd
 #ifndef __NR_eventfd
 # if defined(__alpha__)
@@ -88,5 +99,6 @@ static inline int tapdisk_sys_eventfd(int initval)
 {
 	return syscall(SYS_eventfd, initval, 0);
 }
+#endif
 
 #endif /* __LIBAIO_COMPAT */
tools/config.h.in +3 -0
index 08e337a..a67910b 100644
@@ -27,6 +27,9 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
+/* Define to 1 if you have the <sys/eventfd.h> header file. */
+#undef HAVE_SYS_EVENTFD_H
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
tools/configure +5 -4
index 9f73172..a98dd9e 100755
@@ -7817,12 +7817,13 @@ fi
 
 
 # Checks for header files.
-for ac_header in yajl/yajl_version.h
+for ac_header in yajl/yajl_version.h sys/eventfd.h
 do :
-  ac_fn_c_check_header_mongrel "$LINENO" "yajl/yajl_version.h" "ac_cv_header_yajl_yajl_version_h" "$ac_includes_default"
-if test "x$ac_cv_header_yajl_yajl_version_h" = x""yes; then :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_YAJL_YAJL_VERSION_H 1
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
tools/configure.ac +1 -1
index f6e2fec..36a3343 100644
@@ -166,6 +166,6 @@ AC_CHECK_LIB([iconv], [libiconv_open], [libiconv="y"], [libiconv="n"])
 AC_SUBST(libiconv)
 
 # Checks for header files.
-AC_CHECK_HEADERS([yajl/yajl_version.h])
+AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h])
 
 AC_OUTPUT()
Signature · 1 line
1.7.2.5
Acked-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] blktap2: use sys/eventfd.h if it is available

Ian Campbell writes ("[PATCH 2/9] blktap2: use sys/eventfd.h if it is available"):

Quoted 6 lines

arm64 only has the eventfd2 system call and using the libc wrapper when available hides this from us. eventfd() has been in libc since glibc 2.8.

This code is already Linux specific.

#5 lore raw

PATCH 3/9 tools: only build blktap1 on x86

In reply to Ian Campbell

It does not cross-compile for ARM and no sane new port is going to use it.

---
 tools/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/Makefile +2 -0
index bea1489..8a30c83 100644
@@ -21,7 +21,9 @@ SUBDIRS-y += xenmon
 SUBDIRS-y += xenstat
 SUBDIRS-$(CONFIG_Linux) += $(SUBDIRS-libaio)
 SUBDIRS-$(CONFIG_Linux) += memshr 
+ifeq ($(CONFIG_X86),y)
 SUBDIRS-$(CONFIG_Linux) += blktap
+endif
 SUBDIRS-$(CONFIG_Linux) += blktap2
 SUBDIRS-$(CONFIG_NetBSD) += $(SUBDIRS-libaio)
 SUBDIRS-$(CONFIG_NetBSD) += blktap2
Signature · 1 line
1.7.2.5
#7 lore raw

PATCH 4/9 tools: only check for Python devel tools if not cross-compiling.

In reply to Ian Campbell

tools/python and tools/pygrub are already skipped in tools/Makefile when cross-compiling, so no point in checking for the prerequisites either.

---
 tools/configure    |    8 +++++++-
 tools/configure.ac |    6 +++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
tools/configure +7 -1
index a98dd9e..4cd46e0 100755
@@ -5911,7 +5911,8 @@ else
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 fi
- ac_ext=c
+
+ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -6308,6 +6309,8 @@ fi
 done
 
 
+if test "$cross_compiling" != yes; then :
+
 
 ac_previous_cppflags=$CPPFLAGS
 ac_previous_ldflags=$LDFLAGS
@@ -6439,6 +6442,9 @@ fi
 CPPFLAGS=$ac_previous_cppflags
 LDLFAGS=$ac_previous_ldflags
 
+
+fi
+
 # Extract the first word of "xgettext", so it can be a program name with args.
 set dummy xgettext; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
tools/configure.ac +5 -1
index 36a3343..c5eb2b1 100644
@@ -121,7 +121,11 @@ AS_IF([echo "$PYTHON" | grep -q "^/"], [
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
- AX_CHECK_PYTHON_DEVEL()
+
+AS_IF([test "$cross_compiling" != yes], [
+    AX_CHECK_PYTHON_DEVEL()
+])
+
 AX_PATH_PROG_OR_FAIL([XGETTEXT], [xgettext])
 dnl as86, ld86, bcc and iasl are only required when the host system is x86*.
 dnl "host" here means the platform on which the hypervisor and tools is
Signature · 1 line
1.7.2.5
Acked-by on v1 4/9
#8 lore raw

Re: [PATCH 4/9] tools: only check for Python devel tools if not cross-compiling.

Ian Campbell writes ("[PATCH 4/9] tools: only check for Python devel tools if not cross-compiling."):

Quoted 2 lines

tools/python and tools/pygrub are already skipped in tools/Makefile when cross-compiling, so no point in checking for the prerequisites either.

#9 lore raw

PATCH 5/9 tools: libxc: arm64 support

In reply to Ian Campbell
---
 tools/libxc/xc_core.h |    2 +-
 tools/libxc/xenctrl.h |    4 ++++
 2 files changed, 5 insertions(+), 1 deletions(-)
tools/libxc/xc_core.h +1 -1
index 67b56a4..10cbfca 100644
@@ -151,7 +151,7 @@ int xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_width,
 
 #if defined (__i386__) || defined (__x86_64__)
 # include "xc_core_x86.h"
-#elif defined (__arm__)
+#elif defined (__arm__) || defined(__aarch64__)
 # include "xc_core_arm.h"
 #else
 # error "unsupported architecture"
tools/libxc/xenctrl.h +4 -0
index 32122fd..50853af 100644
@@ -79,6 +79,10 @@
 #define xen_mb()   asm volatile ("dmb" : : : "memory")
 #define xen_rmb()  asm volatile ("dmb" : : : "memory")
 #define xen_wmb()  asm volatile ("dmb" : : : "memory")
+#elif defined(__aarch64__)
+#define xen_mb()   asm volatile ("dmb sy" : : : "memory")
+#define xen_rmb()  asm volatile ("dmb sy" : : : "memory")
+#define xen_wmb()  asm volatile ("dmb sy" : : : "memory")
 #else
 #error "Define barriers"
 #endif
Signature · 1 line
1.7.2.5
#10 lore raw

Re: [PATCH 5/9] tools: libxc: arm64 support

Ian Campbell writes ("[PATCH 5/9] tools: libxc: arm64 support"):

tools/libxc/xenctrl.h line 85

Quoted 4 lines
tools/libxc/xenctrl.h +4 -0
+#elif defined(__aarch64__)
+#define xen_mb()   asm volatile ("dmb sy" : : : "memory")
+#define xen_rmb()  asm volatile ("dmb sy" : : : "memory")
+#define xen_wmb()  asm volatile ("dmb sy" : : : "memory")

Someone who has read the arm64 manual should ack this.

Ian.

Acked-by
#11 lore raw

Re: [PATCH 5/9] tools: libxc: arm64 support

Quoted 7 lines · Ian Jackson

Ian Campbell writes ("[PATCH 5/9] tools: libxc: arm64 support"):

tools/libxc/xenctrl.h line 85

Quoted 4 lines
tools/libxc/xenctrl.h +4 -0
+#elif defined(__aarch64__)
+#define xen_mb()   asm volatile ("dmb sy" : : : "memory")
+#define xen_rmb()  asm volatile ("dmb sy" : : : "memory")
+#define xen_wmb()  asm volatile ("dmb sy" : : : "memory")

Someone who has read the arm64 manual should ack this.

#12 lore raw

PATCH 6/9 tools: memshr: arm64 support

In reply to Ian Campbell

I'm not mad keen on propagating these sorts of asm atomic operations throughout our code base. Other options would be:

- use libatomic-ops, http://www.hpl.hp.com/research/linux/atomic_ops/, although this doesn't seem to be as widespread as I would like (not in RHEL5 for example)
- use a pthread lock. This is probably the simplest/best option but I wasn't able to figure out the locking hierarchy of this code

So I've coped out and just copied the appropriate inlines here.

I also nuked some stray ia64 support and fixed a coment in the arm32 version while I was here.

---
 tools/memshr/bidir-hash.c |   48 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 36 insertions(+), 12 deletions(-)
tools/memshr/bidir-hash.c +36 -12
index 45d473e..bed8179 100644
@@ -100,22 +100,13 @@ int            __hash_iterator(struct __hash *h,
                         void *d);
 static void      hash_resize(struct __hash *h);
 
-#if defined(__ia64__)
-#define ia64_fetchadd4_rel(p, inc) do {                         \
-    uint64_t ia64_intri_res;                                    \
-    asm volatile ("fetchadd4.rel %0=[%1],%2"                    \
-                : "=r"(ia64_intri_res) : "r"(p), "i" (inc)      \
-                : "memory");                                    \
-} while (0)
-static inline void atomic_inc(uint32_t *v) { ia64_fetchadd4_rel(v, 1); }
-static inline void atomic_dec(uint32_t *v) { ia64_fetchadd4_rel(v, -1); }
-#elif defined(__arm__)
+#if defined(__arm__)
 static inline void atomic_inc(uint32_t *v)
 {
         unsigned long tmp;
         int result;
 
-        __asm__ __volatile__("@ atomic_add\n"
+        __asm__ __volatile__("@ atomic_inc\n"
 "1:     ldrex   %0, [%3]\n"
 "       add     %0, %0, #1\n"
 "       strex   %1, %0, [%3]\n"
@@ -130,7 +121,7 @@ static inline void atomic_dec(uint32_t *v)
         unsigned long tmp;
         int result;
 
-        __asm__ __volatile__("@ atomic_sub\n"
+        __asm__ __volatile__("@ atomic_dec\n"
 "1:     ldrex   %0, [%3]\n"
 "       sub     %0, %0, #1\n"
 "       strex   %1, %0, [%3]\n"
@@ -140,6 +131,39 @@ static inline void atomic_dec(uint32_t *v)
         : "r" (v)
         : "cc");
 }
+
+#elif defined(__aarch64__)
+
+static inline void atomic_inc(uint32_t *v)
+{
+        unsigned long tmp;
+        int result;
+
+        asm volatile("// atomic_inc\n"
+"1:     ldxr    %w0, [%3]\n"
+"       add     %w0, %w0, #1\n"
+"       stxr    %w1, %w0, [%3]\n"
+"       cbnz    %w1, 1b"
+        : "=&r" (result), "=&r" (tmp), "+o" (v)
+        : "r" (v)
+        : "cc");
+}
+
+static inline void atomic_dec(uint32_t *v)
+{
+        unsigned long tmp;
+        int result;
+
+        asm volatile("// atomic_dec\n"
+"1:     ldxr    %w0, [%3]\n"
+"       sub     %w0, %w0, #1\n"
+"       stxr    %w1, %w0, [%3]\n"
+"       cbnz    %w1, 1b"
+        : "=&r" (result), "=&r" (tmp), "+o" (v)
+        : "r" (v)
+        : "cc");
+}
+
 #else /* __x86__ */
 static inline void atomic_inc(uint32_t *v)
 {
Signature · 1 line
1.7.2.5
Acked-by on v1 6/9
#13 lore raw

Re: [PATCH 6/9] tools: memshr: arm64 support

Ian Campbell writes ("[PATCH 6/9] tools: memshr: arm64 support"):

Quoted 2 lines

I'm not mad keen on propagating these sorts of asm atomic operations throughout our code base. Other options would be:

How unpleasant, indeed.

Quoted 1 line

So I've coped out and just copied the appropriate inlines here.

Understandable. (YM "copped".)

This looks plausible to me so

but it needs review by someone who has read the arm64 manual.

Ian.

Acked-by on v1 6/9
#14 lore raw

Re: [PATCH 6/9] tools: memshr: arm64 support

In reply to Ian Campbell
Quoted 9 lines · Ian Campbell

I'm not mad keen on propagating these sorts of asm atomic operations throughout our code base. Other options would be:

- use libatomic-ops, http://www.hpl.hp.com/research/linux/atomic_ops/, although this doesn't seem to be as widespread as I would like (not in RHEL5 for example)
- use a pthread lock. This is probably the simplest/best option but I wasn't able to figure out the locking hierarchy of this code

Quoted 6 lines

So I've coped out and just copied the appropriate inlines here.

I also nuked some stray ia64 support and fixed a coment in the arm32 version while I was here.

Quoted 84 lines
 tools/memshr/bidir-hash.c |   48 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 36 insertions(+), 12 deletions(-)
tools/memshr/bidir-hash.c +36 -12
index 45d473e..bed8179 100644
@@ -100,22 +100,13 @@ int            __hash_iterator(struct __hash *h,
                         void *d);
 static void      hash_resize(struct __hash *h);
 
-#if defined(__ia64__)
-#define ia64_fetchadd4_rel(p, inc) do {                         \
-    uint64_t ia64_intri_res;                                    \
-    asm volatile ("fetchadd4.rel %0=[%1],%2"                    \
-                : "=r"(ia64_intri_res) : "r"(p), "i" (inc)      \
-                : "memory");                                    \
-} while (0)
-static inline void atomic_inc(uint32_t *v) { ia64_fetchadd4_rel(v, 1); }
-static inline void atomic_dec(uint32_t *v) { ia64_fetchadd4_rel(v, -1); }
-#elif defined(__arm__)
+#if defined(__arm__)
 static inline void atomic_inc(uint32_t *v)
 {
         unsigned long tmp;
         int result;
 
-        __asm__ __volatile__("@ atomic_add\n"
+        __asm__ __volatile__("@ atomic_inc\n"
 "1:     ldrex   %0, [%3]\n"
 "       add     %0, %0, #1\n"
 "       strex   %1, %0, [%3]\n"
@@ -130,7 +121,7 @@ static inline void atomic_dec(uint32_t *v)
         unsigned long tmp;
         int result;
 
-        __asm__ __volatile__("@ atomic_sub\n"
+        __asm__ __volatile__("@ atomic_dec\n"
 "1:     ldrex   %0, [%3]\n"
 "       sub     %0, %0, #1\n"
 "       strex   %1, %0, [%3]\n"
@@ -140,6 +131,39 @@ static inline void atomic_dec(uint32_t *v)
         : "r" (v)
         : "cc");
 }
+
+#elif defined(__aarch64__)
+
+static inline void atomic_inc(uint32_t *v)
+{
+        unsigned long tmp;
+        int result;
+
+        asm volatile("// atomic_inc\n"
+"1:     ldxr    %w0, [%3]\n"
+"       add     %w0, %w0, #1\n"
+"       stxr    %w1, %w0, [%3]\n"
+"       cbnz    %w1, 1b"
+        : "=&r" (result), "=&r" (tmp), "+o" (v)
+        : "r" (v)
+        : "cc");
+}
+
+static inline void atomic_dec(uint32_t *v)
+{
+        unsigned long tmp;
+        int result;
+
+        asm volatile("// atomic_dec\n"
+"1:     ldxr    %w0, [%3]\n"
+"       sub     %w0, %w0, #1\n"
+"       stxr    %w1, %w0, [%3]\n"
+"       cbnz    %w1, 1b"
+        : "=&r" (result), "=&r" (tmp), "+o" (v)
+        : "r" (v)
+        : "cc");
+}
+
 #else /* __x86__ */
 static inline void atomic_inc(uint32_t *v)
 {
Signature · 1 line
1.7.2.5
#15 lore raw

PATCH 7/9 xenctx: Support arm64.

In reply to Ian Campbell

I also nuked some stray ia64 support while I was here.

---
 tools/xentrace/xenctx.c |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)
tools/xentrace/xenctx.c +6 -13
index 62327f7..d47b7da 100644
@@ -49,23 +49,16 @@ int guest_word_size = sizeof (unsigned long);
 /* Word-length of the context record we get from xen */
 int ctxt_word_size = sizeof (unsigned long);
 int guest_protected_mode = 1;
-#elif defined (__ia64__)
-/* On ia64, we can't translate virtual address to physical address.  */
-#define NO_TRANSLATION
-typedef size_t guest_word_t;
-
-/* Which registers should be displayed.  */
-int disp_cr_regs;
-int disp_ar_regs;
-int disp_br_regs;
-int disp_bank_regs;
-int disp_tlb;
-
 #elif defined(__arm__)
 #define NO_TRANSLATION
 typedef uint64_t guest_word_t;
 #define FMT_32B_WORD "%08llx"
 #define FMT_64B_WORD "%016llx"
+#elif defined(__aarch64__)
+#define NO_TRANSLATION
+typedef uint64_t guest_word_t;
+#define FMT_32B_WORD "%08lx"
+#define FMT_64B_WORD "%016lx"
 #endif
 
 struct symbol {
@@ -684,7 +677,7 @@ void print_ctx(vcpu_guest_context_any_t *ctx)
             print_tr(i, &tr->dtrs[i]);
     }
 }
-#elif defined(__arm__)
+#elif defined(__arm__) || defined(__aarch64__)
 static void print_ctx(vcpu_guest_context_any_t *ctx)
 {
     /* XXX: properly implement this */
Signature · 1 line
1.7.2.5
#16 lore raw

Re: [PATCH 7/9] xenctx: Support arm64.

Ian Campbell writes ("[PATCH 7/9] xenctx: Support arm64."):

Quoted 1 line

I also nuked some stray ia64 support while I was here.

Doesn't arm64 have some more registers ?

Ian.

#17 lore raw

Re: [PATCH 7/9] xenctx: Support arm64.

Quoted 4 lines · Ian Jackson

Ian Campbell writes ("[PATCH 7/9] xenctx: Support arm64."):

Quoted 1 line

I also nuked some stray ia64 support while I was here.

Doesn't arm64 have some more registers ?

Yes, which would matter except:

        #elif defined(__arm__)
        static void print_ctx(vcpu_guest_context_any_t *ctx)
        {
            /* XXX: properly implement this */
            print_symbol(0);
        }
        #endif

Ahem.... I expect it wouldn't run on arm64 due to this missing symbol.

I also missed a whole load of other ia64 remnants in here.

Ian.

#18 lore raw

PATCH 8/9 xen: arm64 uses the same I/O ABI as arm32

In reply to Ian Campbell
---
 xen/include/public/io/protocols.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
xen/include/public/io/protocols.h +1 -1
index d932edc..80b196b 100644
@@ -31,7 +31,7 @@
 # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
 #elif defined(__x86_64__)
 # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
-#elif defined(__arm__)
+#elif defined(__arm__) || defined(__aarch64__)
 # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM
 #else
 # error arch fixup needed here
Signature · 1 line
1.7.2.5
Acked-by on v1 8/9
#19 lore raw

Re: [PATCH 8/9] xen: arm64 uses the same I/O ABI as arm32

Quoted 1 line · Ian Campbell
Quoted 19 lines
 xen/include/public/io/protocols.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
xen/include/public/io/protocols.h +1 -1
index d932edc..80b196b 100644
@@ -31,7 +31,7 @@
 # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
 #elif defined(__x86_64__)
 # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
-#elif defined(__arm__)
+#elif defined(__arm__) || defined(__aarch64__)
 # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM
 #else
 # error arch fixup needed here
Signature · 1 line
1.7.2.5
#20 lore raw

PATCH 9/9 xen: arm: remove PSR_MODE_MASK from public interface.

In reply to Ian Campbell

This is also defined in sys/ptrace.h on arm64 which breaks the tools build due to multiple definitions. I expect this is really a bug in the kernel and/or glibc but we don't really need this symbol in the public headers, at least not right now, so move it into include/asm instead.

---
 xen/arch/arm/arm32/entry.S    |    1 +
 xen/arch/arm/arm64/entry.S    |    1 +
 xen/include/asm-arm/regs.h    |    6 ++++++
 xen/include/public/arch-arm.h |    3 ---
 4 files changed, 8 insertions(+), 3 deletions(-)
xen/arch/arm/arm32/entry.S +1 -0
index 3611427..76814dd 100644
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <asm/asm_defns.h>
+#include <asm/regs.h>
 #include <public/xen.h>
 
 #define SAVE_ONE_BANKED(reg)    mrs r11, reg; str r11, [sp, #UREGS_##reg]
xen/arch/arm/arm64/entry.S +1 -0
index 9d38088..5656f45 100644
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <asm/asm_defns.h>
+#include <asm/regs.h>
 #include <public/xen.h>
 
 /*
xen/include/asm-arm/regs.h +6 -0
index 079c0ca..0130b94 100644
@@ -1,6 +1,10 @@
 #ifndef __ARM_REGS_H__
 #define __ARM_REGS_H__
 
+#define PSR_MODE_MASK 0x1f
+
+#ifndef __ASSEMBLY__
+
 #include <xen/types.h>
 #include <public/xen.h>
 #include <asm/processor.h>
@@ -42,6 +46,8 @@
  */
 extern register_t *select_user_reg(struct cpu_user_regs *regs, int reg);
 
+#endif
+
 #endif /* __ARM_REGS_H__ */
 /*
  * Local variables:
xen/include/public/arch-arm.h +0 -3
index 3333399..2addf60 100644
@@ -195,9 +195,6 @@ typedef uint64_t xen_callback_t;
 
 /* PSR bits (CPSR, SPSR)*/
 
-/* 0-4: Mode */
-#define PSR_MODE_MASK 0x1f
-
 /* 32 bit modes */
 #define PSR_MODE_USR 0x10
 #define PSR_MODE_FIQ 0x11
Signature · 1 line
1.7.2.5
Acked-by on v1 9/9
#21 lore raw

Re: [PATCH 9/9] xen: arm: remove PSR_MODE_MASK from public interface.

Quoted 6 lines · Ian Campbell

This is also defined in sys/ptrace.h on arm64 which breaks the tools build due to multiple definitions. I expect this is really a bug in the kernel and/or glibc but we don't really need this symbol in the public headers, at least not right now, so move it into include/asm instead.

Quoted 69 lines
 xen/arch/arm/arm32/entry.S    |    1 +
 xen/arch/arm/arm64/entry.S    |    1 +
 xen/include/asm-arm/regs.h    |    6 ++++++
 xen/include/public/arch-arm.h |    3 ---
 4 files changed, 8 insertions(+), 3 deletions(-)
xen/arch/arm/arm32/entry.S +1 -0
index 3611427..76814dd 100644
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <asm/asm_defns.h>
+#include <asm/regs.h>
 #include <public/xen.h>
 
 #define SAVE_ONE_BANKED(reg)    mrs r11, reg; str r11, [sp, #UREGS_##reg]
xen/arch/arm/arm64/entry.S +1 -0
index 9d38088..5656f45 100644
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <asm/asm_defns.h>
+#include <asm/regs.h>
 #include <public/xen.h>
 
 /*
xen/include/asm-arm/regs.h +6 -0
index 079c0ca..0130b94 100644
@@ -1,6 +1,10 @@
 #ifndef __ARM_REGS_H__
 #define __ARM_REGS_H__
 
+#define PSR_MODE_MASK 0x1f
+
+#ifndef __ASSEMBLY__
+
 #include <xen/types.h>
 #include <public/xen.h>
 #include <asm/processor.h>
@@ -42,6 +46,8 @@
  */
 extern register_t *select_user_reg(struct cpu_user_regs *regs, int reg);
 
+#endif
+
 #endif /* __ARM_REGS_H__ */
 /*
  * Local variables:
xen/include/public/arch-arm.h +0 -3
index 3333399..2addf60 100644
@@ -195,9 +195,6 @@ typedef uint64_t xen_callback_t;
 
 /* PSR bits (CPSR, SPSR)*/
 
-/* 0-4: Mode */
-#define PSR_MODE_MASK 0x1f
-
 /* 32 bit modes */
 #define PSR_MODE_USR 0x10
 #define PSR_MODE_FIQ 0x11
Signature · 1 line
1.7.2.5
author Applied
#22 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell

The following patches shave some rough edges off the tools build system to allow cross compiling for at least arm32 and arm64 based on the Debian/Ubuntu multiarch infrastructure. They also add the necessary fixes to build for arm64 (which I have only tried cross, not native).

I have posted some instructions on how to compile with these patches on the wiki:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/CrossCompiling

I applied all of this except #7 (xenctx one) which I need to have another look at.

Ian.