From patchwork Tue Jan 16 22:22:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 861920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLl9M5vm2z9s7v for ; Wed, 17 Jan 2018 09:23:19 +1100 (AEDT) Received: from localhost ([::1]:41295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZdV-0004rv-Tp for incoming@patchwork.ozlabs.org; Tue, 16 Jan 2018 17:23:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZcr-0004p6-4Z for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebZcn-0003NH-V0 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:37 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:54094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebZcn-0003MJ-Hy for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:33 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LgcCX-1fER5A2Ux3-00o0dA; Tue, 16 Jan 2018 23:22:18 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 23:22:09 +0100 Message-Id: <20180116222212.1266-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116222212.1266-1-laurent@vivier.eu> References: <20180116222212.1266-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K0:cvgjkBtcqhaPYmcMunT+XWCLOXNVuYsPUBSwhhZKT6rbV6labr9 /1zAjD2Eunl4rrTHlopA27ZdLTf1CnWFwgziH56lmvvBK6CNmZ0wRKrTyCvY8XtOZMAUHn/ QlPCIJDqtAJusTcS7m2thXtq/KQktulGGaokXA0U64RrF9XtU2Qur5qjBHXzxYTD2tzjmCn D9yAP1nzLj47KWFw/5UYw== X-UI-Out-Filterresults: notjunk:1; V01:K0:MLsUhGyRNVk=:GhoyhhUS/FERnDTP9Oh4/0 T0xkZECMv/y5GrfHoLZRkNzs9wGToXWpFKeZvWjjHVrn8+m25W1z6GB28uhwE00Wkx0HNv72Y YQBl+nOsMTKnDeSrsrVlrbVXGOpx6lD35QYPZ1vzV+lK67NIArtPb6+wJGwH3Vmc+PjO57eo5 Cl2Qa0djryDNsO1Gp5T4BJ1ZfI+FqvIct1OuW7szqTOBrPXzT9EK8ZH9koBiFCwiJzlms9zCn 6ALotfaW82ihXQC69Ucne2AvZPfzH6EDFfr12aopbYH5GcLLjcbp9Ouy3R71UMHQYEb120ZAU AIfLlSu5cZNXv/uzlrvsriQPweQl2Gn0YqkzGAFrpkHi6IZQMcX0dura6OkCJfQ6U73fRyL3a tcSuO/PQSb5vUjJC0ykCxOB9gxtlvyJLw9S4VOL4JY/wN3rMxyQvq3/suXohQDqruHHP8FTnW hCh+X+Rt5gpDBvQcy1qBNt4ezlcB/DQpj6lejQNdctBfP0nIkJjnHXzCqUpyrJGh285bHiepN mt3svrVq4BDWTT0ef3BqH4sNSm9Om2kwmF/qXVOvMwn05b9eMWUOf1F2SeCwUsv7FFmQGrRk9 f5z62Lzd6MhkhNdKxUx/6WQxEenRtYsCUZseGkbJk76sjJ8GNxVN//KuEb2Eqa0/27fTrtKGc ELdfQSlT0cdoWIpxNtB/f5uw8XarB1+Wm8lYfSd+gqp7f68EpCaZS8bQKwCR0KQYoY+N/ts2E Ba6ZJ9bQU1k2BDJobP0mEhLZzg6IeBAbgiQM9z+LuEHLJrtcdHszEmCVhVM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PATCH v3 1/4] linux-user: Move CPU type name selection to a function 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: Peter Maydell , YunQiang Su , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Aaron Sierra Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead of a sequence of "#if ... #endif" move the selection to a function in linux-user/*/target_elf.h We can't add them in linux-user/*/target_cpu.h because we will need to include "elf.h" to use ELF flags with eflags, and including "elf.h" in "target_cpu.h" introduces some conflicts in elfload.c Suggested-by: Richard Henderson Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- Notes: v3: change "#if ... #endif" structure for ppc v2: new patch in the series linux-user/aarch64/target_elf.h | 14 +++++++++++++ linux-user/alpha/target_elf.h | 14 +++++++++++++ linux-user/arm/target_elf.h | 14 +++++++++++++ linux-user/cris/target_elf.h | 14 +++++++++++++ linux-user/hppa/target_elf.h | 14 +++++++++++++ linux-user/i386/target_elf.h | 14 +++++++++++++ linux-user/m68k/target_elf.h | 14 +++++++++++++ linux-user/main.c | 41 ++------------------------------------ linux-user/microblaze/target_elf.h | 14 +++++++++++++ linux-user/mips/target_elf.h | 14 +++++++++++++ linux-user/mips64/target_elf.h | 14 +++++++++++++ linux-user/nios2/target_elf.h | 14 +++++++++++++ linux-user/openrisc/target_elf.h | 14 +++++++++++++ linux-user/ppc/target_elf.h | 18 +++++++++++++++++ linux-user/s390x/target_elf.h | 14 +++++++++++++ linux-user/sh4/target_elf.h | 14 +++++++++++++ linux-user/sparc/target_elf.h | 14 +++++++++++++ linux-user/sparc64/target_elf.h | 14 +++++++++++++ linux-user/tilegx/target_elf.h | 14 +++++++++++++ linux-user/unicore32/target_elf.h | 14 +++++++++++++ linux-user/x86_64/target_elf.h | 14 +++++++++++++ 21 files changed, 286 insertions(+), 39 deletions(-) create mode 100644 linux-user/aarch64/target_elf.h create mode 100644 linux-user/alpha/target_elf.h create mode 100644 linux-user/arm/target_elf.h create mode 100644 linux-user/cris/target_elf.h create mode 100644 linux-user/hppa/target_elf.h create mode 100644 linux-user/i386/target_elf.h create mode 100644 linux-user/m68k/target_elf.h create mode 100644 linux-user/microblaze/target_elf.h create mode 100644 linux-user/mips/target_elf.h create mode 100644 linux-user/mips64/target_elf.h create mode 100644 linux-user/nios2/target_elf.h create mode 100644 linux-user/openrisc/target_elf.h create mode 100644 linux-user/ppc/target_elf.h create mode 100644 linux-user/s390x/target_elf.h create mode 100644 linux-user/sh4/target_elf.h create mode 100644 linux-user/sparc/target_elf.h create mode 100644 linux-user/sparc64/target_elf.h create mode 100644 linux-user/tilegx/target_elf.h create mode 100644 linux-user/unicore32/target_elf.h create mode 100644 linux-user/x86_64/target_elf.h diff --git a/linux-user/aarch64/target_elf.h b/linux-user/aarch64/target_elf.h new file mode 100644 index 0000000000..a7eb962fba --- /dev/null +++ b/linux-user/aarch64/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef AARCH64_TARGET_ELF_H +#define AARCH64_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/alpha/target_elf.h b/linux-user/alpha/target_elf.h new file mode 100644 index 0000000000..344e9f4d39 --- /dev/null +++ b/linux-user/alpha/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef ALPHA_TARGET_ELF_H +#define ALPHA_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/arm/target_elf.h b/linux-user/arm/target_elf.h new file mode 100644 index 0000000000..58ff6a0986 --- /dev/null +++ b/linux-user/arm/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef ARM_TARGET_ELF_H +#define ARM_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/cris/target_elf.h b/linux-user/cris/target_elf.h new file mode 100644 index 0000000000..99eb4ec704 --- /dev/null +++ b/linux-user/cris/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef CRIS_TARGET_ELF_H +#define CRIS_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/hppa/target_elf.h b/linux-user/hppa/target_elf.h new file mode 100644 index 0000000000..82b4e9535e --- /dev/null +++ b/linux-user/hppa/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef HPPA_TARGET_ELF_H +#define HPPA_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/i386/target_elf.h b/linux-user/i386/target_elf.h new file mode 100644 index 0000000000..1c6142e7da --- /dev/null +++ b/linux-user/i386/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef I386_TARGET_ELF_H +#define I386_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "qemu32"; +} +#endif diff --git a/linux-user/m68k/target_elf.h b/linux-user/m68k/target_elf.h new file mode 100644 index 0000000000..df375ad5d3 --- /dev/null +++ b/linux-user/m68k/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef M68K_TARGET_ELF_H +#define M68K_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/main.c b/linux-user/main.c index 450eb3ce65..3954e8996b 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -35,6 +35,7 @@ #include "elf.h" #include "exec/log.h" #include "trace/control.h" +#include "target_elf.h" char *exec_path; @@ -4319,45 +4320,7 @@ int main(int argc, char **argv, char **envp) init_qemu_uname_release(); 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 = "5KEf"; -#else - cpu_model = "24Kf"; -#endif -#elif defined TARGET_OPENRISC - cpu_model = "or1200"; -#elif defined(TARGET_PPC) -# ifdef TARGET_PPC64 - cpu_model = "POWER8"; -# else - cpu_model = "750"; -# endif -#elif defined TARGET_SH4 - cpu_model = "sh7785"; -#elif defined TARGET_S390X - cpu_model = "qemu"; -#else - cpu_model = "any"; -#endif + cpu_model = cpu_get_model(0); } tcg_exec_init(0); /* NOTE: we need to init the CPU at this stage to get diff --git a/linux-user/microblaze/target_elf.h b/linux-user/microblaze/target_elf.h new file mode 100644 index 0000000000..8a8f1debff --- /dev/null +++ b/linux-user/microblaze/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef MICROBLAZE_TARGET_ELF_H +#define MICROBLAZE_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/mips/target_elf.h b/linux-user/mips/target_elf.h new file mode 100644 index 0000000000..bed0b43259 --- /dev/null +++ b/linux-user/mips/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef MIPS_TARGET_ELF_H +#define MIPS_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "24Kf"; +} +#endif diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h new file mode 100644 index 0000000000..5b6f4692e0 --- /dev/null +++ b/linux-user/mips64/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef MIPS64_TARGET_ELF_H +#define MIPS64_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "5KEf"; +} +#endif diff --git a/linux-user/nios2/target_elf.h b/linux-user/nios2/target_elf.h new file mode 100644 index 0000000000..801e20afaf --- /dev/null +++ b/linux-user/nios2/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef NIOS2_TARGET_ELF_H +#define NIOS2_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/openrisc/target_elf.h b/linux-user/openrisc/target_elf.h new file mode 100644 index 0000000000..40ceb025c9 --- /dev/null +++ b/linux-user/openrisc/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef OPENRISC_TARGET_ELF_H +#define OPENRISC_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "or1200"; +} +#endif diff --git a/linux-user/ppc/target_elf.h b/linux-user/ppc/target_elf.h new file mode 100644 index 0000000000..576a5b9959 --- /dev/null +++ b/linux-user/ppc/target_elf.h @@ -0,0 +1,18 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef PPC_TARGET_ELF_H +#define PPC_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ +#ifdef TARGET_PPC64 + return "POWER8"; +#else + return "750"; +#endif +} +#endif diff --git a/linux-user/s390x/target_elf.h b/linux-user/s390x/target_elf.h new file mode 100644 index 0000000000..8114b59c1d --- /dev/null +++ b/linux-user/s390x/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef S390X_TARGET_ELF_H +#define S390X_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "qemu"; +} +#endif diff --git a/linux-user/sh4/target_elf.h b/linux-user/sh4/target_elf.h new file mode 100644 index 0000000000..f485e0cef2 --- /dev/null +++ b/linux-user/sh4/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef SH4_TARGET_ELF_H +#define SH4_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "sh7785"; +} +#endif diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h new file mode 100644 index 0000000000..31d508c0df --- /dev/null +++ b/linux-user/sparc/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef SPARC_TARGET_ELF_H +#define SPARC_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "Fujitsu MB86904"; +} +#endif diff --git a/linux-user/sparc64/target_elf.h b/linux-user/sparc64/target_elf.h new file mode 100644 index 0000000000..d6e388f1cf --- /dev/null +++ b/linux-user/sparc64/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef SPARC64_TARGET_ELF_H +#define SPARC64_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "TI UltraSparc II"; +} +#endif diff --git a/linux-user/tilegx/target_elf.h b/linux-user/tilegx/target_elf.h new file mode 100644 index 0000000000..7197bb0005 --- /dev/null +++ b/linux-user/tilegx/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef TILEGX_TARGET_ELF_H +#define TILEGX_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/unicore32/target_elf.h b/linux-user/unicore32/target_elf.h new file mode 100644 index 0000000000..e2bfcb2ca3 --- /dev/null +++ b/linux-user/unicore32/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef UNICORE32_TARGET_ELF_H +#define UNICORE32_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "any"; +} +#endif diff --git a/linux-user/x86_64/target_elf.h b/linux-user/x86_64/target_elf.h new file mode 100644 index 0000000000..7b76a90de8 --- /dev/null +++ b/linux-user/x86_64/target_elf.h @@ -0,0 +1,14 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation, or (at your option) any + * later version. See the COPYING file in the top-level directory. + */ + +#ifndef X86_64_TARGET_ELF_H +#define X86_64_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "qemu64"; +} +#endif From patchwork Tue Jan 16 22:22:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 861919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLl9K0DxSz9sCZ for ; Wed, 17 Jan 2018 09:23:16 +1100 (AEDT) Received: from localhost ([::1]:41293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZdR-0004q4-IT for incoming@patchwork.ozlabs.org; Tue, 16 Jan 2018 17:23:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZcr-0004p8-4c for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebZco-0003NQ-6f for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:37 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:56811) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebZcn-0003Mk-Qw for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:34 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MWvfk-1eN9uI37pM-00VvY5; Tue, 16 Jan 2018 23:22:18 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 23:22:10 +0100 Message-Id: <20180116222212.1266-3-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116222212.1266-1-laurent@vivier.eu> References: <20180116222212.1266-1-laurent@vivier.eu> X-Provags-ID: V03:K0:lZz5882cz5KBWlk/uQ5eiQnhV+xGBL5QgwvslVj40KWmeM6n2eX BjasvrZpWuhYNEUSbngcYGv0k6GeIVpYxZt5jIU7WcAHocNV1OIRdVph4H9TrRMAzGjytRR 0wFZhMBSBN89U75YkMkRjqgPBMK+YEDQKZFU9Q3Y8E5BlnA45waOBPGUfVlanW6IuuNhYMb dszns/GjA4S0PufOtjrhw== X-UI-Out-Filterresults: notjunk:1; V01:K0:u+/2DBn+FY0=:KUh4s6Jq9Vj9YozpdcVASh 99Uunc6aK0u0Pj4pRKtvGJVl/115WMHRZ3qAAwHC58kd5ceBamMDSedGhRaiEz6gDSGIXqrIW 0dK1QplZeSrp9AFCB1Yu/3TlSgksh26ZAVfrlKZNCkfnVZm9iAbowefEpPOyzJzoVjQnyu5/i EPI4WcdSlOPuF6MQcJfvCBIQFNKldO0M1QAI8z/21ZZ7tjXxi2svVbVmYuKTv7nO10ESjLdGd /C8uObecnC2Ta2RTabVxde/eKJAhajcvt3PC1qZDNTmG2lkO1iLzIZSpkZgLheN6r4XNiIWe2 5wbt4PJxHI0w7ykH2bM6f2h0nsb/9QXDAvbLgVya43d6R9B/teTZvDcqG1R0+RopVQrEiG836 5H7O9DZQ2IImocJCjV+EUAf/DDom3LaR3dyk59K3araosDvuKxIHUw0hqxazTHgYFXPm/IdhD GUikqx+FFgPfxwVElpn4cCw+984oJwun/liLiPTmJIWr+xrJSrA6M0Fd/lvJJZvSnP6MX+6Om czZwHzSxhK3V5YZy0mSC2eFm4cmSPaoIhXcLT81skO5bUizOTgs2g2FTxw5TuSKyqq0T/44Iu XTv/PlGYt3uHK3fTyqEa43lZLy7GcZsX3bl8I1eZJsE6rnGZJWe3q9FYMyNH9w0Vj6PTZCP7K SqSklncZsaixnbRry2k2Cc/eY9+AZJ3O3lcziJy9Bl0WjrbLeNPbQJ5GORUDyb+qnEmZ7So1I 7KZDLGU7qvBGtnzL5UK7OPZTCP7PLGk9q1myeA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PATCH v3 2/4] linux-user: introduce functions to detect CPU type 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: Peter Maydell , YunQiang Su , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Aaron Sierra Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: YunQiang Su Add a function to return ELF e_flags and use it to select the CPU model. [lv: split the patch and some cleanup in get_elf_eflags()] Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- Notes: YunQiang Su, please add your Signed-off-by that was missing in your original patch. v2: call cpu_get_model() with the result of get_elf_eflags() linux-user/elfload.c | 35 +++++++++++++++++++++++++++++++++++ linux-user/main.c | 20 ++++++++++---------- linux-user/qemu.h | 1 + 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 20f3d8c2c3..67e2425ac6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2376,6 +2376,41 @@ give_up: g_free(syms); } +uint32_t get_elf_eflags(int fd) +{ + struct elfhdr ehdr; + off_t offset; + int ret; + + /* Read ELF header */ + offset = lseek(fd, 0, SEEK_SET); + if (offset == (off_t) -1) { + return 0; + } + ret = read(fd, &ehdr, sizeof(ehdr)); + if (ret < sizeof(ehdr)) { + return 0; + } + offset = lseek(fd, offset, SEEK_SET); + if (offset == (off_t) -1) { + return 0; + } + + /* Check ELF signature */ + if (!elf_check_ident(&ehdr)) { + return 0; + } + + /* check header */ + bswap_ehdr(&ehdr); + if (!elf_check_ehdr(&ehdr)) { + return 0; + } + + /* return architecture id */ + return ehdr.e_flags; +} + int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) { struct image_info interp_info; diff --git a/linux-user/main.c b/linux-user/main.c index 3954e8996b..6845b56030 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -4319,8 +4319,17 @@ int main(int argc, char **argv, char **envp) init_qemu_uname_release(); + execfd = qemu_getauxval(AT_EXECFD); + if (execfd == 0) { + execfd = open(filename, O_RDONLY); + if (execfd < 0) { + printf("Error while loading %s: %s\n", filename, strerror(errno)); + _exit(EXIT_FAILURE); + } + } + if (cpu_model == NULL) { - cpu_model = cpu_get_model(0); + cpu_model = cpu_get_model(get_elf_eflags(execfd)); } tcg_exec_init(0); /* NOTE: we need to init the CPU at this stage to get @@ -4413,15 +4422,6 @@ int main(int argc, char **argv, char **envp) cpu->opaque = ts; task_settid(ts); - execfd = qemu_getauxval(AT_EXECFD); - if (execfd == 0) { - execfd = open(filename, O_RDONLY); - if (execfd < 0) { - printf("Error while loading %s: %s\n", filename, strerror(errno)); - _exit(EXIT_FAILURE); - } - } - ret = loader_exec(execfd, filename, target_argv, target_environ, regs, info, &bprm); if (ret != 0) { diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4edd7d0c08..47ca71159c 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -188,6 +188,7 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp, struct target_pt_regs * regs, struct image_info *infop, struct linux_binprm *); +uint32_t get_elf_eflags(int fd); int load_elf_binary(struct linux_binprm *bprm, struct image_info *info); int load_flt_binary(struct linux_binprm *bprm, struct image_info *info); From patchwork Tue Jan 16 22:22:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 861922 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLlD10tkwz9s7v for ; Wed, 17 Jan 2018 09:25:37 +1100 (AEDT) Received: from localhost ([::1]:41385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZfj-00071r-35 for incoming@patchwork.ozlabs.org; Tue, 16 Jan 2018 17:25:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZd1-0004wP-Ne for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebZcy-0003WX-J6 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:47 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:57860) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebZcy-0003Vs-7i for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:44 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LlItW-1f9GHN2R8w-00b6Sd; Tue, 16 Jan 2018 23:22:19 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 23:22:11 +0100 Message-Id: <20180116222212.1266-4-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116222212.1266-1-laurent@vivier.eu> References: <20180116222212.1266-1-laurent@vivier.eu> X-Provags-ID: V03:K0:1pJR/p3UCTSmS9PPTbL/4ZL+uHUp00YCx8zpG2jDNraYu227KLn hDvYEn4y9jocnhDUvt3PhJnv9zoeeajtKsdVXq/iwMP5YBRbjcWBZJ1YzZsFISlN9/KFh62 oGHbBGahBjHP+zTQHg0djsLw61JD7vP0m0O27vVQyqNmZ7O4+EAG/7ir/KjggYq3iGWpmpm 7fIbGll3xCiaHwoipPeJA== X-UI-Out-Filterresults: notjunk:1; V01:K0:8HgeAFKiDT8=:OUvphxXlAdjvcUd1cxE7e9 NRFARMlBy49JnNv2C50IIi9j9YDWxtLfGukpnMw3awcvleutkwpWWraqh9f0kvSSsKkvA0R+A xtZTqkUyoSdCxwf3slJhw0ZgJrcnIQuNWrqBBztQrB3KIfi3bpf8oQmfuiyOKWJZ4Nubenh72 aSeOWUlOB9UT5eoZ3tVmJGdj20HaMTUUGfFki/xLMu4Jqu6UP/nqtleVNcWzgACpN+DYFOLbQ 3j+99qG0bgfYOiTW2gmAp0HBPjprQJIJpqPZd/wENRw2Krfpyue61THgqakU62xU38H7sEGEj nsmUDFGOcs6Fc4DiwZbt+SXEfsyuONtEvO4GTrWATWCIqSaFQgOjL4Gct4HwqlYosTQBKg8rl oDSYdjB/pxa+ZjBcwg1v+D0EqEo43DNRSghbDml5bJTGcLeKRHLw79qHH+Sn+v5MRshE31pci cS3TBnIcuGpCdNrd/gZ9uscCzt4W6h500miN9E36DLMKpD+jOgjiOoGHOq6/fmVx8hF6RPayQ 6pYfH6O2sfuqmRjPMiyOkj/pMt6i8u9nLKf+RwenXmYhvWPwHYXq4qa9wdVi5fRdNaLR/5AuG 26US6Des0nyjfgMer7wHynFa517YRqPIqpJWYP2RaZ4dQU/0aTvoeKo6GpxWxBx7tLsVvxvpy JJ71I8HP0l9w7+rFjaAcibz5MkMsHBs5VRQLJR6el3XrttIe/peO7g7pPa1RNjlDD2zHoZdWR OYqqV4mU05DRK7osNOm5+WjUcOIOor3mSbSbmA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 Subject: [Qemu-devel] [PATCH v3 3/4] linux-user, m68k: select CPU according to ELF header values 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: Peter Maydell , YunQiang Su , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Aaron Sierra Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" M680x0 doesn't support the same set of instructions as ColdFire, so we can't use "any" CPU type to execute m68020 instructions. We select CPU type ("m68040" or "any" for ColdFire) according to the ELF header. If we can't, we use by default the value used until now: "any". Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- Notes: v3: check for EF_M68K_M68000 add EF_M68K_* flags in elf.h set 680x0 default CPU to m68040 v2: call cpu_get_model() with the result of get_elf_eflags() include/elf.h | 28 ++++++++++++++++++++++++++++ linux-user/m68k/target_elf.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/include/elf.h b/include/elf.h index e8a515ce3d..ca9a419043 100644 --- a/include/elf.h +++ b/include/elf.h @@ -537,6 +537,34 @@ typedef struct { #define HWCAP_S390_HIGH_GPRS 512 #define HWCAP_S390_TE 1024 +/* M68K specific definitions. */ +/* We use the top 24 bits to encode information about the + architecture variant. */ +#define EF_M68K_CPU32 0x00810000 +#define EF_M68K_M68000 0x01000000 +#define EF_M68K_CFV4E 0x00008000 +#define EF_M68K_FIDO 0x02000000 +#define EF_M68K_ARCH_MASK \ + (EF_M68K_M68000 | EF_M68K_CPU32 | EF_M68K_CFV4E | EF_M68K_FIDO) + +/* We use the bottom 8 bits to encode information about the + coldfire variant. If we use any of these bits, the top 24 bits are + either 0 or EF_M68K_CFV4E. */ +#define EF_M68K_CF_ISA_MASK 0x0F /* Which ISA */ +#define EF_M68K_CF_ISA_A_NODIV 0x01 /* ISA A except for div */ +#define EF_M68K_CF_ISA_A 0x02 +#define EF_M68K_CF_ISA_A_PLUS 0x03 +#define EF_M68K_CF_ISA_B_NOUSP 0x04 /* ISA_B except for USP */ +#define EF_M68K_CF_ISA_B 0x05 +#define EF_M68K_CF_ISA_C 0x06 +#define EF_M68K_CF_ISA_C_NODIV 0x07 /* ISA C except for div */ +#define EF_M68K_CF_MAC_MASK 0x30 +#define EF_M68K_CF_MAC 0x10 /* MAC */ +#define EF_M68K_CF_EMAC 0x20 /* EMAC */ +#define EF_M68K_CF_EMAC_B 0x30 /* EMAC_B */ +#define EF_M68K_CF_FLOAT 0x40 /* Has float insns */ +#define EF_M68K_CF_MASK 0xFF + /* * 68k ELF relocation types */ diff --git a/linux-user/m68k/target_elf.h b/linux-user/m68k/target_elf.h index df375ad5d3..998fe0fe2f 100644 --- a/linux-user/m68k/target_elf.h +++ b/linux-user/m68k/target_elf.h @@ -9,6 +9,12 @@ #define M68K_TARGET_ELF_H static inline const char *cpu_get_model(uint32_t eflags) { + if (eflags == 0 || (eflags & EF_M68K_M68000)) { + /* 680x0 */ + return "m68040"; + } + + /* Coldfire */ return "any"; } #endif From patchwork Tue Jan 16 22:22:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 861921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLl9Z3hyCz9s7v for ; Wed, 17 Jan 2018 09:23:30 +1100 (AEDT) Received: from localhost ([::1]:41299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZdg-0004zi-Ju for incoming@patchwork.ozlabs.org; Tue, 16 Jan 2018 17:23:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZd2-0004wQ-2r for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebZcy-0003We-Ue for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:48 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:58761) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebZcy-0003W4-JZ for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:44 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0M85Ej-1ep6C539FZ-00vfZo; Tue, 16 Jan 2018 23:22:21 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 23:22:12 +0100 Message-Id: <20180116222212.1266-5-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116222212.1266-1-laurent@vivier.eu> References: <20180116222212.1266-1-laurent@vivier.eu> X-Provags-ID: V03:K0:pylrkmBEtpxmodkjxvNAwVYNOzSbBRw2Guw+WD9u35gzSPgFBEH rEQiox5Nc7V7IiXw1TzDIhzdHuQyVkTmzUF2plHE7AElY9wY+CdGJx1SdU6+U+e7fOU9Nd4 KRZN399TT61Aw3fb7K2xvLY1szPvdZ8IYH/g4S/niyJCm2Y8zwH0+CIEGMskH8CPhIoUr44 42ockskioYDua+gfON7VQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZSd/WDf0jHA=:o7rAQvMqtzg5p2TVGeuK5F T3PrPOMtCV9D2SEi7zlIo61yG9VEXO//QqKLHZGKVHnKxULFqmcEqWu+PMSu1TQZz8/r4hE90 xgNMHtUxvSj/PQKdiogFu+KMF1HBT8gJs+qXLwtfN3+vP0ZaEOcSPgdXdx/v7ZCDJkd1vHIXo QubwIvC7QYRvRxTHjOeClp2qBPc4lPAwFKytTBg2s3TyU9I2XzJPTmqtaCj+W2ma+Xpmh0D3R OotM/OefCLHwy6r8E8IBP9Tbn9WXzWYeBPAAbxM0c9X2KdFM3kuH62XiJgqmXyRiCneEkLHuE a2HSvjVcEgkTMUaz0HteWUYY+EvaHxmJ/B4XF4x0ylxcncToHH/8Bnf8RBNbQBJmCO5Z2oqbY /0I+nBrxK2ZljnzTS/b2kWTrqZMVG7Gy0iuEJBbPrCH71oJUVsPohONQAK2fR8qMk8YazLSPT mBFPEZ210oYgbO3iSHdnBafXJQcHGeantAo9WolO3h7gCoVC+wvcY14bk1IRGSOfY8QFPDYv2 HwRMHoSbWlMORynfZUkoeRjCoPG2AlDN9hkAjK71Yu7HjQQpW5F5dkg7WfRcRAolNBVvrbLBX VYScogE3Erl3VhH9EnrcB0EHZh75nXoRal7hLb1PC3Y4eJHaCeqSsaZ0dtOFifn+4YuLxQfsz 8XXIH1ehY2q755rn6ARKvWGyH60hdvcZs+eu7dGc8qi09gOIx4zq+7oxoGo2m1ALKX0w/g5/Y gBdzfoHv8wD3CZJdqQUwIvQ9keLx0EKuVpYTOg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [PATCH v3 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6 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: Peter Maydell , YunQiang Su , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Aaron Sierra Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: YunQiang Su So here we need to detect the version of binaries and set cpu_model for it. [lv: original patch modified to move code into cpu_get_model()] Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- Notes: YunQiang Su, please add your Signed-off-by that was missing in your original patch. v3: fix code indent problem reported by patchew remove useless "!= 0" v2: call cpu_get_model() with the result of get_elf_eflags() include/elf.h | 4 ++++ linux-user/mips/target_elf.h | 3 +++ linux-user/mips64/target_elf.h | 3 +++ 3 files changed, 10 insertions(+) diff --git a/include/elf.h b/include/elf.h index ca9a419043..746b6d393b 100644 --- a/include/elf.h +++ b/include/elf.h @@ -40,6 +40,10 @@ typedef int64_t Elf64_Sxword; #define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ #define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */ #define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */ +#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */ +#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */ +#define EF_MIPS_ARCH_32R6 0x90000000 /* MIPS32r6 code. */ +#define EF_MIPS_ARCH_64R6 0xa0000000 /* MIPS64r6 code. */ /* The ABI of a file. */ #define EF_MIPS_ABI_O32 0x00001000 /* O32 ABI. */ diff --git a/linux-user/mips/target_elf.h b/linux-user/mips/target_elf.h index bed0b43259..14b53d7469 100644 --- a/linux-user/mips/target_elf.h +++ b/linux-user/mips/target_elf.h @@ -9,6 +9,9 @@ #define MIPS_TARGET_ELF_H static inline const char *cpu_get_model(uint32_t eflags) { + if (eflags & EF_MIPS_ARCH_32R6) { + return "mips32r6-generic"; + } return "24Kf"; } #endif diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h index 5b6f4692e0..ae14b38bfa 100644 --- a/linux-user/mips64/target_elf.h +++ b/linux-user/mips64/target_elf.h @@ -9,6 +9,9 @@ #define MIPS64_TARGET_ELF_H static inline const char *cpu_get_model(uint32_t eflags) { + if (eflags & EF_MIPS_ARCH_64R6) { + return "I6400"; + } return "5KEf"; } #endif