From nobody Mon Apr 29 04:05:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510030004275383.5568833340192; Mon, 6 Nov 2017 20:46:44 -0800 (PST) Received: from localhost ([::1]:51406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBvmI-0001Cc-Uu for importer@patchew.org; Mon, 06 Nov 2017 23:46:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBty3-00069G-RD for qemu-devel@nongnu.org; Mon, 06 Nov 2017 21:50:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBtxz-0002Ex-BL for qemu-devel@nongnu.org; Mon, 06 Nov 2017 21:50:23 -0500 Received: from xes-mad.com ([216.165.139.220]:19886 helo=mail.xes-mad.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBtxz-0002Dq-4A for qemu-devel@nongnu.org; Mon, 06 Nov 2017 21:50:19 -0500 Received: from zimbra.xes-mad.com (zimbra.xes-mad.com [10.52.0.127]) by mail.xes-mad.com (Postfix) with ESMTP id D16502021C; Mon, 6 Nov 2017 20:50:15 -0600 (CST) Date: Mon, 6 Nov 2017 20:50:15 -0600 (CST) From: Aaron Sierra To: Riku Voipio , Laurent Vivier Message-ID: <492245211.936616.1510023015797.JavaMail.zimbra@xes-inc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.52.0.127] X-Mailer: Zimbra 8.7.5_GA_1764 (ZimbraWebClient - FF56 (Linux)/8.7.5_GA_1764) Thread-Index: TbdM2eB+UV0rlylfkVDX3Wicn3nc9g== Thread-Topic: linux-user: Support explicit targets for PowerPC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.165.139.220 X-Mailman-Approved-At: Mon, 06 Nov 2017 23:45:28 -0500 Subject: [Qemu-devel] [PATCH] linux-user: Support explicit targets for PowerPC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- 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 =20 -include $(SUBDIR_DEVICES_MAK_DEP) =20 +# 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_devic= e_config.sh $(call quiet-command, \ $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-confi= g-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 } =20 +set_target_variables() { + alias_name=3D$(echo $target | cut -d '-' -f 1) + alias_base=3D$(echo $target | cut -d '.' -f 1) + target_cpu=3D$(echo $target | cut -d '.' -f 2) + target_name=3D${alias_name}.${target_cpu} + target_suffix=3D$(echo $alias_base | sed s/${alias_name}//) +} =20 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 =20 @@ -6348,10 +6356,10 @@ fi for target in $target_list; do target_dir=3D"$target" config_target_mak=3D$target_dir/config-target.mak -target_name=3D$(echo $target | cut -d '-' -f 1) +set_target_variables $target target_bigendian=3D"no" =20 -case "$target_name" in +case "$alias_name" in armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcem= b|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb) target_bigendian=3Dyes ;; @@ -6360,15 +6368,15 @@ target_softmmu=3D"no" target_user_only=3D"no" target_linux_user=3D"no" target_bsd_user=3D"no" -case "$target" in - ${target_name}-softmmu) +case "$target_suffix" in + -softmmu) target_softmmu=3D"yes" ;; - ${target_name}-linux-user) + -linux-user) target_user_only=3D"yes" target_linux_user=3D"yes" ;; - ${target_name}-bsd-user) + -bsd-user) target_user_only=3D"yes" target_bsd_user=3D"yes" ;; @@ -6383,14 +6391,14 @@ echo "# Automatically generated by configure - do n= ot modify" > $config_target_m =20 bflt=3D"no" mttcg=3D"no" -interp_prefix1=3D$(echo "$interp_prefix" | sed "s/%M/$target_name/g") +interp_prefix1=3D$(echo "$interp_prefix" | sed "s/%M/$alias_name/g") gdb_xml_files=3D"" =20 -TARGET_ARCH=3D"$target_name" +TARGET_ARCH=3D"$alias_name" TARGET_BASE_ARCH=3D"" TARGET_ABI_DIR=3D"" =20 -case "$target_name" in +case "$alias_name" in i386) gdb_xml_files=3D"i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml" ;; @@ -6514,6 +6522,10 @@ if [ "$TARGET_BASE_ARCH" =3D "" ]; then TARGET_BASE_ARCH=3D$TARGET_ARCH fi =20 +if [ "$alias_name" !=3D "$target_cpu" ]; then + echo "TARGET_EXPLICIT_CPU=3D$target_cpu" >> $config_target_mak +fi + symlink "$source_path/Makefile.target" "$target_dir/Makefile" =20 upper() { @@ -6532,13 +6544,13 @@ if [ "$HOST_VARIANT_DIR" !=3D "" ]; then echo "HOST_VARIANT_DIR=3D$HOST_VARIANT_DIR" >> $config_target_mak fi =20 -if supported_xen_target $target; then +if supported_xen_target $alias_base; then echo "CONFIG_XEN=3Dy" >> $config_target_mak if test "$xen_pci_passthrough" =3D yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=3Dy" >> "$config_target_mak" fi fi -if supported_kvm_target $target; then +if supported_kvm_target $alias_base; then echo "CONFIG_KVM=3Dy" >> $config_target_mak if test "$vhost_net" =3D "yes" ; then echo "CONFIG_VHOST_NET=3Dy" >> $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=3Dy" >> $config_target_mak fi if test "$target_bigendian" =3D "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(); =20 if (cpu_model =3D=3D NULL) { -#if defined(TARGET_I386) +#if defined(TARGET_EXPLICIT_CPU) + cpu_model =3D TARGET_EXPLICIT_CPU; +#elif defined(TARGET_I386) #ifdef TARGET_X86_64 cpu_model =3D "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=3D${line#*=3D} echo "#define TARGET_NAME \"$target_name\"" ;; + TARGET_EXPLICIT_CPU=3D*) + echo "#define TARGET_EXPLICIT_CPU \"${line#*=3D}\"" + ;; TARGET_DIRS=3D*) # do nothing ;; --=20 2.7.4