diff mbox

[RFC,for,2.8,1/3] configure: check CPU width and disable larger guests

Message ID 1470758127-17769-2-git-send-email-alex.bennee@linaro.org
State New
Headers show

Commit Message

Alex Bennée Aug. 9, 2016, 3:55 p.m. UTC
Emulating 64 bit guests on a 32 bit host is either impossible with KVM
or needs a lot of special casing for TCG targets. As 64 bit hosts are
fairly normal nowadays and there can't be many people trying this
combination lets disable it completely.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 configure | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

-- 
2.7.4

Comments

Peter Maydell Aug. 9, 2016, 4:13 p.m. UTC | #1
On 9 August 2016 at 16:55, Alex Bennée <alex.bennee@linaro.org> wrote:
> Emulating 64 bit guests on a 32 bit host is either impossible with KVM

> or needs a lot of special casing for TCG targets. As 64 bit hosts are

> fairly normal nowadays and there can't be many people trying this

> combination lets disable it completely.

>

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  configure | 34 +++++++++++++++++++++++++++++++++-

>  1 file changed, 33 insertions(+), 1 deletion(-)

>

> diff --git a/configure b/configure

> index f57fcc6..7b779c1 100755

> --- a/configure

> +++ b/configure

> @@ -478,6 +478,7 @@ elif check_define __x86_64__ ; then

>      cpu="x32"

>    else

>      cpu="x86_64"

> +    cpu_width=64

>    fi

>  elif check_define __sparc__ ; then

>    if check_define __arch64__ ; then

> @@ -515,26 +516,36 @@ ARCH=

>  # Normalise host CPU name and set ARCH.

>  # Note that this case should only have supported host CPUs, not guests.

>  case "$cpu" in

> -  ia64|ppc|ppc64|s390|s390x|sparc64|x32)

> +  ppc|s390|x32)

>      cpu="$cpu"

> +    cpu_width=32

> +  ;;

> +  ia64|ppc64|s390x|sparc64)

> +    cpu="$cpu"

> +    cpu_width=64


We can detect the host pointer width generically at configure time,
in a similar way to how we detect its endianness:

cat > $TMPC << EOF
#include <inttypes.h>

uintptr_t be[] = { (uintptr_t)0x4c6f4e674c6f4e67ULL };
uintptr_t le[] = { (uintptr_t)0x674e6f4c674e6f4cULL };
extern int foo(uintptr_t *a, uintptr_t *b);

int main(void) {
    return foo(le, be);
}
EOF
if compile_object; then
    if grep -q LoNgLoNg $TMPO; then
        hostwidth=64
    elif grep -q LoNg $TMPO; then
        hostwidth=32
    else
        error_exit "Host pointer width detection failed"
    fi
else
    error_exit "Host pointer width detection failed"
fi

(I've tested the C code here but not the shell-scriptery.)


>  ##########################################

> +# host address width checks

> +too_wide_targets=""

> +

> +if test "$cpu_width" = "32"; then

> +    for target in $target_list; do

> +        target_name=$(echo $target | cut -d '-' -f 1)

> +        case "$target_name" in

> +            aarch64|mips64|ppc64|s390x|sparc64)


We should find a way to avoid having to specify the guest
CPU's pointer width twice (once here and once by setting
TARGET_LONG_BITS in its cpu.h). Otherwise people are going
to forget to update this list for new CPUs.

> +                too_wide_targets="$too_wide_targets $target"

> +                ;;

> +        esac

> +    done

> +fi

> +

> +if test ! -z "$too_wide_targets" ; then

> +    error_exit "Support for the following targets can't be built on 32 bit systems:\n\t$too_wide_targets"

> +fi


Won't this break running configure on a 32-bit host with
no target-list specified at all?

thanks
-- PMM
diff mbox

Patch

diff --git a/configure b/configure
index f57fcc6..7b779c1 100755
--- a/configure
+++ b/configure
@@ -478,6 +478,7 @@  elif check_define __x86_64__ ; then
     cpu="x32"
   else
     cpu="x86_64"
+    cpu_width=64
   fi
 elif check_define __sparc__ ; then
   if check_define __arch64__ ; then
@@ -515,26 +516,36 @@  ARCH=
 # Normalise host CPU name and set ARCH.
 # Note that this case should only have supported host CPUs, not guests.
 case "$cpu" in
-  ia64|ppc|ppc64|s390|s390x|sparc64|x32)
+  ppc|s390|x32)
     cpu="$cpu"
+    cpu_width=32
+  ;;
+  ia64|ppc64|s390x|sparc64)
+    cpu="$cpu"
+    cpu_width=64
   ;;
   i386|i486|i586|i686|i86pc|BePC)
     cpu="i386"
+    cpu_width=32
   ;;
   x86_64|amd64)
     cpu="x86_64"
+    cpu_width=64
   ;;
   armv*b|armv*l|arm)
     cpu="arm"
+    cpu_width=32
   ;;
   aarch64)
     cpu="aarch64"
+    cpu_width=32
   ;;
   mips*)
     cpu="mips"
   ;;
   sparc|sun4[cdmuv])
     cpu="sparc"
+    cpu_width=32
   ;;
   *)
     # This will result in either an error or falling back to TCI later
@@ -1700,6 +1711,26 @@  else
 fi
 
 ##########################################
+# host address width checks
+too_wide_targets=""
+
+if test "$cpu_width" = "32"; then
+    for target in $target_list; do
+        target_name=$(echo $target | cut -d '-' -f 1)
+        case "$target_name" in
+            aarch64|mips64|ppc64|s390x|sparc64)
+                too_wide_targets="$too_wide_targets $target"
+                ;;
+        esac
+    done
+fi
+
+if test ! -z "$too_wide_targets" ; then
+    error_exit "Support for the following targets can't be built on 32 bit systems:\n\t$too_wide_targets"
+fi
+
+
+##########################################
 # cocoa implies not SDL or GTK
 # (the cocoa UI code currently assumes it is always the active UI
 # and doesn't interact well with other UI frontend code)
@@ -4795,6 +4826,7 @@  if test "$slirp" = "yes" ; then
 fi
 echo "module support    $modules"
 echo "host CPU          $cpu"
+echo "host CPU width    $cpu_width"
 echo "host big endian   $bigendian"
 echo "target list       $target_list"
 echo "tcg debug enabled $debug_tcg"