From: Stefan Weil <sw@weilnetz.de>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Weil <sw@weilnetz.de>, Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH] tci: Detect function argument alignment
Date: Thu, 12 Sep 2013 21:45:24 +0200 [thread overview]
Message-ID: <1379015124-21055-1-git-send-email-sw@weilnetz.de> (raw)
This fixes TCI on ARM hosts (tested with Debian's busybox-static
running in linux-user emulation).
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
configure | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
tcg/tci/tcg-target.h | 6 ++++-
2 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 2b83936..93c3a32 100755
--- a/configure
+++ b/configure
@@ -185,6 +185,7 @@ debug_tcg="no"
debug="no"
strip_opt="yes"
tcg_interpreter="no"
+call_align_args=""
bigendian="no"
mingw32="no"
gcov="no"
@@ -808,6 +809,10 @@ for opt do
;;
--enable-tcg-interpreter) tcg_interpreter="yes"
;;
+ --disable-call-align-args) call_align_args="no"
+ ;;
+ --enable-call-align-args) call_align_args="yes"
+ ;;
--disable-cap-ng) cap_ng="no"
;;
--enable-cap-ng) cap_ng="yes"
@@ -1461,6 +1466,58 @@ esac
fi
##########################################
+# Alignment probe for 64 bit function arguments (only needed for TCG interpreter)
+
+if test "$tcg_interpreter" = "yes" -a -z "$call_align_args"; then
+
+if test -z "$cross_prefix"; then
+
+cat > $TMPC << EOF
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
+static bool call_align_args(uint32_t arg1, uint64_t arg2) {
+ if (arg2 == 0x000000030000004ULL || arg2 == 0x0000000400000003ULL) {
+ return true;
+ } else if (arg2 == 2) {
+ /* 64 bit host, 64 bit function arguments are not aligned. */
+ } else if (arg2 == 0x0000000200000003 || arg2 == 0x0000000300000002ULL) {
+ /* 64 bit function arguments are not aligned. */
+ } else {
+ fprintf(stderr, "unexpected 64 bit function argument 0x%016" PRIx64 "\n", arg2);
+ }
+ return false;
+}
+
+typedef bool (*fptr)(uint32_t, uint32_t, uint32_t, uint32_t);
+
+int main(void) {
+ fptr f = (fptr)call_align_args;
+ return f(1, 2, 3, 4) ? 0 : 1;
+}
+EOF
+
+if compile_prog "" ""; then
+ call_align_args="no"
+ $TMPE && call_align_args="yes"
+else
+ error_exit "Function argument alignment test failed"
+fi
+
+else
+
+ # Cross compilation, so we cannot launch a program. Require configure argument.
+ error_exit "Unknown function argument alignment" \
+ "The TCG interpreter must know the alignment of function arguments." \
+ "Configure cannot determine the alignment because this is a cross build," \
+ "so please add --enable-call-align-args or --disable-call-align-args."
+
+fi
+
+fi # "$tcg_interpreter" = "yes"
+
+##########################################
# pkg-config probe
if ! has "$pkg_config_exe"; then
@@ -3709,6 +3766,9 @@ echo "Install blobs $blobs"
echo "KVM support $kvm"
echo "RDMA support $rdma"
echo "TCG interpreter $tcg_interpreter"
+if test "$tcg_interpreter" = "yes"; then
+echo "call align args $call_align_args"
+fi
echo "fdt support $fdt"
echo "preadv support $preadv"
echo "fdatasync $fdatasync"
@@ -4029,6 +4089,9 @@ if test "$signalfd" = "yes" ; then
fi
if test "$tcg_interpreter" = "yes" ; then
echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
+ if test "$call_align_args" = "yes"; then
+ echo "CONFIG_CALL_ALIGN_ARGS=y" >> $config_host_mak
+ fi
fi
if test "$fdatasync" = "yes" ; then
echo "CONFIG_FDATASYNC=y" >> $config_host_mak
diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h
index c2ecfbe..0420e96 100644
--- a/tcg/tci/tcg-target.h
+++ b/tcg/tci/tcg-target.h
@@ -1,7 +1,7 @@
/*
* Tiny Code Generator for QEMU
*
- * Copyright (c) 2009, 2011 Stefan Weil
+ * Copyright (c) 2009, 2013 Stefan Weil
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -63,6 +63,10 @@
#endif
#endif
+#if defined(CONFIG_CALL_ALIGN_ARGS)
+# define TCG_TARGET_CALL_ALIGN_ARGS 1
+#endif
+
/* Optional instructions. */
#define TCG_TARGET_HAS_bswap16_i32 1
--
1.7.10.4
next reply other threads:[~2013-09-12 19:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 19:45 Stefan Weil [this message]
2013-09-12 20:29 ` [Qemu-devel] [PATCH] tci: Detect function argument alignment Richard Henderson
2013-09-12 20:40 ` Stefan Weil
2013-09-12 21:04 ` Richard Henderson
2013-09-12 20:35 ` Peter Maydell
2013-09-14 7:18 ` Stefan Weil
2013-09-14 9:51 ` Peter Maydell
2013-09-14 20:34 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379015124-21055-1-git-send-email-sw@weilnetz.de \
--to=sw@weilnetz.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).