All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Support explicit targets for PowerPC
@ 2017-11-07  2:50 Aaron Sierra
  2017-11-07  4:48 ` no-reply
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Aaron Sierra @ 2017-11-07  2:50 UTC (permalink / raw)
  To: Riku Voipio, Laurent Vivier; +Cc: qemu-devel

Enable building PowerPC targets supporting a specific CPU, without
having to set QEMU_CPU via the environment. For example these build
targets (and many more) become available:

    qemu-ppc.e500mc
    qemu-ppc.e500v2
    qemu-ppc.e5500
    qemu-ppc.e600
    qemu-ppc.e6500

These (statically compiled) binaries have proven useful for emulating
PowerPC CPUs within Docker containers, where it's hard to reliably
define environment variables that are available for every process.

Additional Makefile rules are all that should be needed to support
other architectures.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
---
 Makefile              |  4 ++++
 configure             | 40 ++++++++++++++++++++++++++--------------
 linux-user/main.c     |  4 +++-
 scripts/create_config |  3 +++
 4 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index ec73acf..7de6d88 100644
--- a/Makefile
+++ b/Makefile
@@ -281,6 +281,10 @@ endif
 
 -include $(SUBDIR_DEVICES_MAK_DEP)
 
+# Support PowerPC targets with explicit CPU defined
+default-configs/ppc-linux-user.%.mak: default-configs/ppc-linux-user.mak
+	cp $< $@
+
 %/config-devices.mak: default-configs/%.mak $(SRC_PATH)/scripts/make_device_config.sh
 	$(call quiet-command, \
             $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-config-devices.mak.d $@ > $@.tmp,"GEN","$@.tmp")
diff --git a/configure b/configure
index e31d6a7..49aed47 100755
--- a/configure
+++ b/configure
@@ -240,6 +240,13 @@ supported_target() {
     return 1
 }
 
+set_target_variables() {
+    alias_name=$(echo $target | cut -d '-' -f 1)
+    alias_base=$(echo $target | cut -d '.' -f 1)
+    target_cpu=$(echo $target | cut -d '.' -f 2)
+    target_name=${alias_name}.${target_cpu}
+    target_suffix=$(echo $alias_base | sed s/${alias_name}//)
+}
 
 ld_has() {
     $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
@@ -1828,14 +1835,15 @@ else
     for target in $target_list; do
         # Check that we recognised the target name; this allows a more
         # friendly error message than if we let it fall through.
+        set_target_variables $target
         case " $default_target_list " in
-            *" $target "*)
+            *" $alias_base "*)
                 ;;
             *)
                 error_exit "Unknown target name '$target'"
                 ;;
         esac
-        supported_target $target || exit 1
+        supported_target $alias_base || exit 1
     done
 fi
 
@@ -6348,10 +6356,10 @@ fi
 for target in $target_list; do
 target_dir="$target"
 config_target_mak=$target_dir/config-target.mak
-target_name=$(echo $target | cut -d '-' -f 1)
+set_target_variables $target
 target_bigendian="no"
 
-case "$target_name" in
+case "$alias_name" in
   armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
   target_bigendian=yes
   ;;
@@ -6360,15 +6368,15 @@ target_softmmu="no"
 target_user_only="no"
 target_linux_user="no"
 target_bsd_user="no"
-case "$target" in
-  ${target_name}-softmmu)
+case "$target_suffix" in
+  -softmmu)
     target_softmmu="yes"
     ;;
-  ${target_name}-linux-user)
+  -linux-user)
     target_user_only="yes"
     target_linux_user="yes"
     ;;
-  ${target_name}-bsd-user)
+  -bsd-user)
     target_user_only="yes"
     target_bsd_user="yes"
     ;;
@@ -6383,14 +6391,14 @@ echo "# Automatically generated by configure - do not modify" > $config_target_m
 
 bflt="no"
 mttcg="no"
-interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
+interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$alias_name/g")
 gdb_xml_files=""
 
-TARGET_ARCH="$target_name"
+TARGET_ARCH="$alias_name"
 TARGET_BASE_ARCH=""
 TARGET_ABI_DIR=""
 
-case "$target_name" in
+case "$alias_name" in
   i386)
     gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
   ;;
@@ -6514,6 +6522,10 @@ if [ "$TARGET_BASE_ARCH" = "" ]; then
   TARGET_BASE_ARCH=$TARGET_ARCH
 fi
 
+if [ "$alias_name" != "$target_cpu" ]; then
+  echo "TARGET_EXPLICIT_CPU=$target_cpu" >> $config_target_mak
+fi
+
 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
 
 upper() {
@@ -6532,13 +6544,13 @@ if [ "$HOST_VARIANT_DIR" != "" ]; then
     echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
 fi
 
-if supported_xen_target $target; then
+if supported_xen_target $alias_base; then
     echo "CONFIG_XEN=y" >> $config_target_mak
     if test "$xen_pci_passthrough" = yes; then
         echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
     fi
 fi
-if supported_kvm_target $target; then
+if supported_kvm_target $alias_base; then
     echo "CONFIG_KVM=y" >> $config_target_mak
     if test "$vhost_net" = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
@@ -6547,7 +6559,7 @@ if supported_kvm_target $target; then
         fi
     fi
 fi
-if supported_hax_target $target; then
+if supported_hax_target $alias_base; then
     echo "CONFIG_HAX=y" >> $config_target_mak
 fi
 if test "$target_bigendian" = "yes" ; then
diff --git a/linux-user/main.c b/linux-user/main.c
index aa02f25..9d0c4b6 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4298,7 +4298,9 @@ int main(int argc, char **argv, char **envp)
     init_qemu_uname_release();
 
     if (cpu_model == NULL) {
-#if defined(TARGET_I386)
+#if defined(TARGET_EXPLICIT_CPU)
+        cpu_model = TARGET_EXPLICIT_CPU;
+#elif defined(TARGET_I386)
 #ifdef TARGET_X86_64
         cpu_model = "qemu64";
 #else
diff --git a/scripts/create_config b/scripts/create_config
index 603b826..8aa4a9f 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -107,6 +107,9 @@ case $line in
     target_name=${line#*=}
     echo "#define TARGET_NAME \"$target_name\""
     ;;
+ TARGET_EXPLICIT_CPU=*)
+    echo "#define TARGET_EXPLICIT_CPU \"${line#*=}\""
+    ;;
  TARGET_DIRS=*)
     # do nothing
     ;;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-11-11  4:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07  2:50 [Qemu-devel] [PATCH] linux-user: Support explicit targets for PowerPC Aaron Sierra
2017-11-07  4:48 ` no-reply
2017-11-07  4:51 ` no-reply
2017-11-07  6:57 ` Laurent Vivier
2017-11-07  9:29   ` Peter Maydell
2017-11-07  9:41     ` Laurent Vivier
2017-11-07 15:25     ` Aaron Sierra
2017-11-07  9:24 ` Laurent Vivier
2017-11-07 15:20   ` Aaron Sierra
2017-11-07 15:24     ` Peter Maydell
2017-11-07 15:28       ` Aaron Sierra
2017-11-07 15:27     ` Laurent Vivier
2017-11-07 15:42       ` Aaron Sierra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.