From patchwork Thu Sep 12 19:45:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 274600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D6242C0112 for ; Fri, 13 Sep 2013 05:46:15 +1000 (EST) Received: from localhost ([::1]:43596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKCqD-0008JP-Lu for incoming@patchwork.ozlabs.org; Thu, 12 Sep 2013 15:46:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKCpW-0008G1-GJ for qemu-devel@nongnu.org; Thu, 12 Sep 2013 15:45:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKCpU-0003ZL-UP for qemu-devel@nongnu.org; Thu, 12 Sep 2013 15:45:30 -0400 Received: from qemu.weilnetz.de ([2a03:4000:2:362::1]:50331 helo=v2201305906712890.yourvserver.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKCpU-0003Z5-K7 for qemu-devel@nongnu.org; Thu, 12 Sep 2013 15:45:28 -0400 Received: by v2201305906712890.yourvserver.net (Postfix, from userid 1000) id 6795B180651; Thu, 12 Sep 2013 21:45:25 +0200 (CEST) From: Stefan Weil To: qemu-devel Date: Thu, 12 Sep 2013 21:45:24 +0200 Message-Id: <1379015124-21055-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a03:4000:2:362::1 Cc: Peter Maydell , Stefan Weil , Richard Henderson Subject: [Qemu-devel] [PATCH] tci: Detect function argument alignment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This fixes TCI on ARM hosts (tested with Debian's busybox-static running in linux-user emulation). Signed-off-by: Stefan Weil --- 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 +#include +#include +#include +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