Skip to contentSkip to conversation

linux-user: A serie of patches to set default CPU

PATCH In review Laurent Vivier 2 participants 7 messages Jan 22, 2012 – Jan 31, 2012

lore
Share & tools
lore
#0 lore raw

cover linux-user: A serie of patches to set default CPU

This serie of patches has already been sent, more or less, several time, last time in july 2011.

For chrooted environment, it allows to define the default cpu model as we can't use '-cpu' argument.

For instance:

 ./configure --target-list=m68k-linux-user,arm-linux-user \
                   --m68k-default-cpu=m5206 --arm-default-cpu=sa1100

./m68k-linux-user/qemu-m68k -cpu ?

Quoted 1 line

m5206

m5208
cfv4e
any
./arm-linux-user/qemu-arm -cpu ?
Available CPUs:
arm926
arm946
arm1026
arm1136
arm1136-r2
arm1176
arm11mpcore
cortex-m3
cortex-a8
cortex-a9
ti925t
pxa250

Quoted 1 line

sa1100

sa1110
pxa255
pxa260
pxa261
pxa262
pxa270
pxa270-a0
pxa270-a1
pxa270-b0
pxa270-b1
pxa270-c0
pxa270-c5
any

[PATCH 1/4] linux-user: define default cpu model in configure [PATCH 2/4] linux-user: specify the cpu model during configure [PATCH 3/4] linux-user,m68k: display default cpu [PATCH 4/4] linux-user,arm: display default cpu

#1 lore raw

PATCH 1/4 linux-user: define default cpu model in configure instead of linux-user/main.c

From: Laurent Vivier <[email protected]>

---
 configure         |   14 ++++++++++++++
 linux-user/main.c |   34 +---------------------------------
 2 files changed, 15 insertions(+), 33 deletions(-)
configure +14 -0
index 467e87b..c251df2 100755
@@ -3313,6 +3313,7 @@ target_dir="$target"
 config_target_mak=$target_dir/config-target.mak
 target_arch2=`echo $target | cut -d '-' -f 1`
 target_bigendian="no"
+target_default_cpu="any"
 
 case "$target_arch2" in
   armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
@@ -3388,11 +3389,13 @@ TARGET_ABI_DIR=""
 case "$target_arch2" in
   i386)
     target_phys_bits=64
+    target_default_cpu="qemu32"
   ;;
   x86_64)
     TARGET_BASE_ARCH=i386
     target_phys_bits=64
     target_long_alignment=8
+    target_default_cpu="qemu64"
   ;;
   alpha)
     target_phys_bits=64
@@ -3435,12 +3438,14 @@ case "$target_arch2" in
     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
     target_nptl="yes"
     target_phys_bits=64
+    target_default_cpu="24Kf"
   ;;
   mipsn32|mipsn32el)
     TARGET_ARCH=mipsn32
     TARGET_BASE_ARCH=mips
     echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
     target_phys_bits=64
+    target_default_cpu="20Kc"
   ;;
   mips64|mips64el)
     TARGET_ARCH=mips64
@@ -3448,12 +3453,14 @@ case "$target_arch2" in
     echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
     target_phys_bits=64
     target_long_alignment=8
+    target_default_cpu="20Kc"
   ;;
   ppc)
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
     target_phys_bits=64
     target_nptl="yes"
     target_libs_softmmu="$fdt_libs"
+    target_default_cpu="750"
   ;;
   ppcemb)
     TARGET_BASE_ARCH=ppc
@@ -3462,6 +3469,7 @@ case "$target_arch2" in
     target_phys_bits=64
     target_nptl="yes"
     target_libs_softmmu="$fdt_libs"
+    target_default_cpu="750"
   ;;
   ppc64)
     TARGET_BASE_ARCH=ppc
@@ -3470,6 +3478,7 @@ case "$target_arch2" in
     target_phys_bits=64
     target_long_alignment=8
     target_libs_softmmu="$fdt_libs"
+    target_default_cpu="970fx"
   ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
@@ -3479,6 +3488,7 @@ case "$target_arch2" in
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
     target_phys_bits=64
     target_libs_softmmu="$fdt_libs"
+    target_default_cpu="750"
   ;;
   sh4|sh4eb)
     TARGET_ARCH=sh4
@@ -3488,11 +3498,13 @@ case "$target_arch2" in
   ;;
   sparc)
     target_phys_bits=64
+    target_default_cpu="Fujitsu MB86904"
   ;;
   sparc64)
     TARGET_BASE_ARCH=sparc
     target_phys_bits=64
     target_long_alignment=8
+    target_default_cpu="TI UltraSparc II"
   ;;
   sparc32plus)
     TARGET_ARCH=sparc64
@@ -3500,6 +3512,7 @@ case "$target_arch2" in
     TARGET_ABI_DIR=sparc
     echo "TARGET_ABI32=y" >> $config_target_mak
     target_phys_bits=64
+    target_default_cpu="Fujitsu MB86904"
   ;;
   s390x)
     target_nptl="yes"
@@ -3522,6 +3535,7 @@ echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
 echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
 echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
 echo "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
+echo "TARGET_DEFAULT_CPU=\"$target_default_cpu\"" >> $config_target_mak
 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
 echo "TARGET_$target_arch_name=y" >> $config_target_mak
linux-user/main.c +1 -33
index 64d2208..25dc0eb 100644
@@ -3322,39 +3322,7 @@ int main(int argc, char **argv, char **envp)
     init_paths(interp_prefix);
 
     if (cpu_model == NULL) {
-#if defined(TARGET_I386)
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-#elif defined(TARGET_ARM)
-        cpu_model = "any";
-#elif defined(TARGET_UNICORE32)
-        cpu_model = "any";
-#elif defined(TARGET_M68K)
-        cpu_model = "any";
-#elif defined(TARGET_SPARC)
-#ifdef TARGET_SPARC64
-        cpu_model = "TI UltraSparc II";
-#else
-        cpu_model = "Fujitsu MB86904";
-#endif
-#elif defined(TARGET_MIPS)
-#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
-        cpu_model = "20Kc";
-#else
-        cpu_model = "24Kf";
-#endif
-#elif defined(TARGET_PPC)
-#ifdef TARGET_PPC64
-        cpu_model = "970fx";
-#else
-        cpu_model = "750";
-#endif
-#else
-        cpu_model = "any";
-#endif
+        cpu_model = TARGET_DEFAULT_CPU;
     }
     tcg_exec_init(0);
     cpu_exec_init_all();
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/4 linux-user: specify the cpu model during configure

In reply to Laurent Vivier

From: Laurent Vivier <[email protected]>

This patch allows to set the default cpu model for a given architecture, for instance:

 ./configure --target-list=m68k-linux-user,arm-linux-user \
               --m68k-default-cpu=m68040 --arm-default-cpu=sa1100
---
 configure |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
configure +9 -0
index c251df2..98acce1 100755
@@ -544,6 +544,10 @@ for opt do
   ;;
   --target-list=*) target_list="$optarg"
   ;;
+  --*-default-cpu=*)
+    tmp=`expr "x$opt" : 'x--\(.*\)-default-cpu=.*'`
+    eval ${tmp}_default_cpu="$optarg"
+  ;;
   --enable-trace-backend=*) trace_backend="$optarg"
   ;;
   --with-trace-file=*) trace_file="$optarg"
@@ -951,6 +955,7 @@ echo "                           use %M for cpu name [$interp_prefix]"
 echo "  --target-list=LIST       set target list (default: build everything)"
 echo "Available targets: $default_target_list" | \
     fold -s -w 53 | sed -e 's/^/                           /'
+echo "  --ARCH-default-cpu=CPU   set the default cpu for a given architecture"
 echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH       path of source code [$source_path]"
@@ -3531,6 +3536,10 @@ case "$target_arch2" in
     exit 1
   ;;
 esac
+tmp_target_default_cpu=`eval echo \\$${target_arch2}_default_cpu`
+if [ "x$tmp_target_default_cpu" != "x" ] ; then
+  target_default_cpu="$tmp_target_default_cpu"
+fi
 echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
 echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
 echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/4 linux-user,m68k: display default cpu

In reply to Laurent Vivier

From: Laurent Vivier <[email protected]>

---
 target-m68k/helper.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
target-m68k/helper.c +5 -0
index 674c8e6..ede5180 100644
@@ -57,6 +57,11 @@ void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
     unsigned int i;
 
     for (i = 0; m68k_cpu_defs[i].name; i++) {
+        if (strcmp(m68k_cpu_defs[i].name, TARGET_DEFAULT_CPU) == 0) {
+            (*cpu_fprintf)(f, " >");
+        } else {
+            (*cpu_fprintf)(f, "  ");
+        }
         (*cpu_fprintf)(f, "%s\n", m68k_cpu_defs[i].name);
     }
 }
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 4/4 linux-user,arm: display default cpu

In reply to Laurent Vivier
---
 target-arm/helper.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
target-arm/helper.c +6 -1
index 00458fc..7be315f 100644
@@ -438,7 +438,12 @@ void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 
     (*cpu_fprintf)(f, "Available CPUs:\n");
     for (i = 0; arm_cpu_names[i].name; i++) {
-        (*cpu_fprintf)(f, "  %s\n", arm_cpu_names[i].name);
+        if (strcmp(arm_cpu_names[i].name, TARGET_DEFAULT_CPU) == 0) {
+            (*cpu_fprintf)(f, " >");
+        } else {
+            (*cpu_fprintf)(f, "  ");
+        }
+        (*cpu_fprintf)(f, "%s\n", arm_cpu_names[i].name);
     }
 }
 
Signature · 1 line
1.7.5.4
#5 lore raw
In reply to Laurent Vivier
Quoted 4 lines · Laurent Vivier

This serie of patches has already been sent, more or less, several time, last time in july 2011.

For chrooted environment, it allows to define the default cpu model as we can't use '-cpu' argument.

We now can, with QEMU_CPU enviroment variable.

Riku

#6 lore raw
Quoted 7 lines · Riku Voipio
Quoted 4 lines · Laurent Vivier

This serie of patches has already been sent, more or less, several time, last time in july 2011.

For chrooted environment, it allows to define the default cpu model as we can't use '-cpu' argument.

We now can, with QEMU_CPU enviroment variable.

Yes, but to define the default CPU is also interesting, it avoids to set the variable if we know we always want to run the same CPU.

Regards,
Laurent