* [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values
@ 2018-01-16 17:25 Laurent Vivier
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function Laurent Vivier
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 17:25 UTC (permalink / raw)
To: qemu-devel
Cc: YunQiang Su, Richard Henderson, Philippe Mathieu-Daudé,
Peter Maydell, Riku Voipio, Aaron Sierra, Laurent Vivier
This idea has been suggested to me before by Philippe
Mathieu-Daudé, and recently YunQiang Su has proposed a
patch to manage the MIPS r6 case.
Based on this, this series tries to clean-up the original
patch, and introduces the use for m68k architecture and
port the patch from YunQiang Su.
v2: move cpu_model selection to linux-user/*/target_elf.h
provide eflags to cpu_get_model() instead of fd
(and modify other patches accordingly)
Laurent Vivier (2):
linux-user: Move CPU type name selection to a function
linux-user,m68k: select CPU according to ELF header values
YunQiang Su (2):
linux-user: introduce functions to detect CPU type
linux-user: MIPS set cpu to r6 CPU if binary is R6
include/elf.h | 4 +++
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/elfload.c | 35 ++++++++++++++++++++++
linux-user/hppa/target_elf.h | 14 +++++++++
linux-user/i386/target_elf.h | 14 +++++++++
linux-user/m68k/target_elf.h | 20 +++++++++++++
linux-user/main.c | 59 +++++++-------------------------------
linux-user/microblaze/target_elf.h | 14 +++++++++
linux-user/mips/target_elf.h | 17 +++++++++++
linux-user/mips64/target_elf.h | 17 +++++++++++
linux-user/nios2/target_elf.h | 14 +++++++++
linux-user/openrisc/target_elf.h | 14 +++++++++
linux-user/ppc/target_elf.h | 21 ++++++++++++++
linux-user/qemu.h | 1 +
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 +++++++++
24 files changed, 350 insertions(+), 48 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
--
2.14.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function
2018-01-16 17:25 [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values Laurent Vivier
@ 2018-01-16 17:25 ` Laurent Vivier
2018-01-16 20:10 ` Richard Henderson
2018-01-16 20:34 ` Philippe Mathieu-Daudé
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 2/4] linux-user: introduce functions to detect CPU type Laurent Vivier
` (3 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 17:25 UTC (permalink / raw)
To: qemu-devel
Cc: YunQiang Su, Richard Henderson, Philippe Mathieu-Daudé,
Peter Maydell, Riku Voipio, Aaron Sierra, Laurent Vivier
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
conflic in elfload.c
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
Notes:
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 | 21 +++++++++++++++++++
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, 289 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..f72f63a53c
--- /dev/null
+++ b/linux-user/ppc/target_elf.h
@@ -0,0 +1,21 @@
+/*
+ * 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
+#ifdef TARGET_PPC64
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+ return "POWER8";
+}
+#else
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+ 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
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 2/4] linux-user: introduce functions to detect CPU type
2018-01-16 17:25 [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values Laurent Vivier
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function Laurent Vivier
@ 2018-01-16 17:25 ` Laurent Vivier
2018-01-16 20:11 ` Richard Henderson
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 3/4] linux-user, m68k: select CPU according to ELF header values Laurent Vivier
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 17:25 UTC (permalink / raw)
To: qemu-devel
Cc: YunQiang Su, Richard Henderson, Philippe Mathieu-Daudé,
Peter Maydell, Riku Voipio, Aaron Sierra, Laurent Vivier
From: YunQiang Su <syq@debian.org>
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 <laurent@vivier.eu>
---
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);
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 3/4] linux-user, m68k: select CPU according to ELF header values
2018-01-16 17:25 [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values Laurent Vivier
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function Laurent Vivier
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 2/4] linux-user: introduce functions to detect CPU type Laurent Vivier
@ 2018-01-16 17:25 ` Laurent Vivier
2018-01-16 20:22 ` Richard Henderson
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6 Laurent Vivier
2018-01-16 17:33 ` [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values no-reply
4 siblings, 1 reply; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 17:25 UTC (permalink / raw)
To: qemu-devel
Cc: YunQiang Su, Richard Henderson, Philippe Mathieu-Daudé,
Peter Maydell, Riku Voipio, Aaron Sierra, Laurent Vivier
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 ("m68020" 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 <laurent@vivier.eu>
---
Notes:
v2: call cpu_get_model() with the result of get_elf_eflags()
linux-user/m68k/target_elf.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/m68k/target_elf.h b/linux-user/m68k/target_elf.h
index df375ad5d3..946b90f342 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) {
+ /* 680x0 */
+ return "m68020";
+ }
+
+ /* Coldfire */
return "any";
}
#endif
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6
2018-01-16 17:25 [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values Laurent Vivier
` (2 preceding siblings ...)
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 3/4] linux-user, m68k: select CPU according to ELF header values Laurent Vivier
@ 2018-01-16 17:25 ` Laurent Vivier
2018-01-16 20:26 ` Richard Henderson
2018-01-16 20:29 ` Philippe Mathieu-Daudé
2018-01-16 17:33 ` [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values no-reply
4 siblings, 2 replies; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 17:25 UTC (permalink / raw)
To: qemu-devel
Cc: YunQiang Su, Richard Henderson, Philippe Mathieu-Daudé,
Peter Maydell, Riku Voipio, Aaron Sierra, Laurent Vivier
From: YunQiang Su <syq@debian.org>
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 <laurent@vivier.eu>
---
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()
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 e8a515ce3d..f2104809b1 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..ac14f99ac5 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) != 0) {
+ return "mips32r6-generic";
+ }
return "24Kf";
}
#endif
diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h
index 5b6f4692e0..6cda7ae435 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) != 0) {
+ return "I6400";
+ }
return "5KEf";
}
#endif
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values
2018-01-16 17:25 [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values Laurent Vivier
` (3 preceding siblings ...)
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6 Laurent Vivier
@ 2018-01-16 17:33 ` no-reply
4 siblings, 0 replies; 14+ messages in thread
From: no-reply @ 2018-01-16 17:33 UTC (permalink / raw)
To: laurent
Cc: famz, qemu-devel, peter.maydell, syq, riku.voipio,
richard.henderson, f4bug, asierra
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20180116172510.28878-1-laurent@vivier.eu
Subject: [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
aae39d24a3..c1d5b9add7 master -> master
* [new tag] patchew/20180116172510.28878-1-laurent@vivier.eu -> patchew/20180116172510.28878-1-laurent@vivier.eu
Switched to a new branch 'test'
a63a09bfe5 linux-user: MIPS set cpu to r6 CPU if binary is R6
24f37601e2 linux-user, m68k: select CPU according to ELF header values
5e73ad86f5 linux-user: introduce functions to detect CPU type
2eef204e3d linux-user: Move CPU type name selection to a function
=== OUTPUT BEGIN ===
Checking PATCH 1/4: linux-user: Move CPU type name selection to a function...
Checking PATCH 2/4: linux-user: introduce functions to detect CPU type...
Checking PATCH 3/4: linux-user, m68k: select CPU according to ELF header values...
Checking PATCH 4/4: linux-user: MIPS set cpu to r6 CPU if binary is R6...
ERROR: suspect code indent for conditional statements (5, 9)
#36: FILE: linux-user/mips/target_elf.h:12:
+ if ((eflags & EF_MIPS_ARCH_32R6) != 0) {
+ return "mips32r6-generic";
ERROR: suspect code indent for conditional statements (5, 9)
#50: FILE: linux-user/mips64/target_elf.h:12:
+ if ((eflags & EF_MIPS_ARCH_64R6) != 0) {
+ return "I6400";
total: 2 errors, 0 warnings, 28 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function Laurent Vivier
@ 2018-01-16 20:10 ` Richard Henderson
2018-01-16 20:34 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2018-01-16 20:10 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Cc: YunQiang Su, Philippe Mathieu-Daudé, Peter Maydell,
Riku Voipio, Aaron Sierra
On 01/16/2018 09:25 AM, Laurent Vivier wrote:
> 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
> conflic in elfload.c
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>
> Notes:
> v2: new patch in the series
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/4] linux-user: introduce functions to detect CPU type
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 2/4] linux-user: introduce functions to detect CPU type Laurent Vivier
@ 2018-01-16 20:11 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2018-01-16 20:11 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Cc: YunQiang Su, Philippe Mathieu-Daudé, Peter Maydell,
Riku Voipio, Aaron Sierra
On 01/16/2018 09:25 AM, Laurent Vivier wrote:
> From: YunQiang Su <syq@debian.org>
>
> 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 <laurent@vivier.eu>
> ---
>
> 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(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/4] linux-user, m68k: select CPU according to ELF header values
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 3/4] linux-user, m68k: select CPU according to ELF header values Laurent Vivier
@ 2018-01-16 20:22 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2018-01-16 20:22 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Cc: YunQiang Su, Philippe Mathieu-Daudé, Peter Maydell,
Riku Voipio, Aaron Sierra
On 01/16/2018 09:25 AM, Laurent Vivier wrote:
> 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 ("m68020" 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 <laurent@vivier.eu>
> ---
>
> Notes:
> v2: call cpu_get_model() with the result of get_elf_eflags()
>
> linux-user/m68k/target_elf.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/linux-user/m68k/target_elf.h b/linux-user/m68k/target_elf.h
> index df375ad5d3..946b90f342 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) {
> + /* 680x0 */
> + return "m68020";
> + }
> +
> + /* Coldfire */
> return "any";
This isn't quite right. From binutils:
/* 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
It looks like m68000 series for flags == 0 || flags & EF_M68K_M68000.
While we're at it, surely 68040 is a better default than 68020 for user-only,
especially once all your fpu patches are in.
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6 Laurent Vivier
@ 2018-01-16 20:26 ` Richard Henderson
2018-01-16 22:01 ` Laurent Vivier
2018-01-16 20:29 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2018-01-16 20:26 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Cc: YunQiang Su, Philippe Mathieu-Daudé, Peter Maydell,
Riku Voipio, Aaron Sierra
On 01/16/2018 09:25 AM, Laurent Vivier wrote:
> From: YunQiang Su <syq@debian.org>
>
> 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 <laurent@vivier.eu>
> ---
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> static inline const char *cpu_get_model(uint32_t eflags)
> {
> + if ((eflags & EF_MIPS_ARCH_32R6) != 0) {
> + return "mips32r6-generic";
> + }
> return "24Kf";
That said, I don't suppose it's worth diagnosing cases that we can't support
somehow? E.g. mips-linux-user and EF_MIPS_ARCH_64. Or even coldfire ISA-C.
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6 Laurent Vivier
2018-01-16 20:26 ` Richard Henderson
@ 2018-01-16 20:29 ` Philippe Mathieu-Daudé
2018-01-16 21:58 ` Laurent Vivier
1 sibling, 1 reply; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-01-16 20:29 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Cc: Peter Maydell, YunQiang Su, Riku Voipio, Richard Henderson,
Aaron Sierra
On 01/16/2018 02:25 PM, Laurent Vivier wrote:
> From: YunQiang Su <syq@debian.org>
>
> 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 <laurent@vivier.eu>
> ---
>
> 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()
>
> 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 e8a515ce3d..f2104809b1 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..ac14f99ac5 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) != 0) {
if (eflags & EF_MIPS_ARCH_32R6) {
> + return "mips32r6-generic";
What is the gain of the "-generic" suffix?
Using "mips32r6":
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> + }
> return "24Kf";
> }
> #endif
> diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h
> index 5b6f4692e0..6cda7ae435 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) != 0) {
> + return "I6400";
> + }
> return "5KEf";
> }
> #endif
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function Laurent Vivier
2018-01-16 20:10 ` Richard Henderson
@ 2018-01-16 20:34 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-01-16 20:34 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Cc: Peter Maydell, YunQiang Su, Riku Voipio, Richard Henderson,
Aaron Sierra
On 01/16/2018 02:25 PM, Laurent Vivier wrote:
> 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
> conflic in elfload.c
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>
> Notes:
> 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 | 21 +++++++++++++++++++
> 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, 289 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..f72f63a53c
> --- /dev/null
> +++ b/linux-user/ppc/target_elf.h
> @@ -0,0 +1,21 @@
> +/*
> + * 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
I'd rather use:
> +static inline const char *cpu_get_model(uint32_t eflags)
> +{
#ifdef TARGET_PPC64
return "POWER8";
#else
return "750";
#endif
> +}
anyway:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 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
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6
2018-01-16 20:29 ` Philippe Mathieu-Daudé
@ 2018-01-16 21:58 ` Laurent Vivier
0 siblings, 0 replies; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 21:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Peter Maydell, YunQiang Su, Riku Voipio, Richard Henderson,
Aaron Sierra
Le 16/01/2018 à 21:29, Philippe Mathieu-Daudé a écrit :
> On 01/16/2018 02:25 PM, Laurent Vivier wrote:
>> From: YunQiang Su <syq@debian.org>
>>
>> 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 <laurent@vivier.eu>
>> ---
>>
>> 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()
>>
>> 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 e8a515ce3d..f2104809b1 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..ac14f99ac5 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) != 0) {
>
> if (eflags & EF_MIPS_ARCH_32R6) {
>
>> + return "mips32r6-generic";
>
> What is the gain of the "-generic" suffix?
Don't know, but this the name in list given by:
qemu-system-mips -cpu help
>
> Using "mips32r6":
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
qemu-system-mips -cpu mips32r6
qemu-system-mips: unable to find CPU model 'mips32r6'
mips-softmmu/qemu-system-mips -cpu mips32r6-generic
qemu-system-mips: Could not load MIPS bios 'mips_bios.bin', and no
-kernel argument was specified
Thanks,
Laurent
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6
2018-01-16 20:26 ` Richard Henderson
@ 2018-01-16 22:01 ` Laurent Vivier
0 siblings, 0 replies; 14+ messages in thread
From: Laurent Vivier @ 2018-01-16 22:01 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: YunQiang Su, Philippe Mathieu-Daudé, Peter Maydell,
Riku Voipio, Aaron Sierra
Le 16/01/2018 à 21:26, Richard Henderson a écrit :
> On 01/16/2018 09:25 AM, Laurent Vivier wrote:
>> From: YunQiang Su <syq@debian.org>
>>
>> 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 <laurent@vivier.eu>
>> ---
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
>> static inline const char *cpu_get_model(uint32_t eflags)
>> {
>> + if ((eflags & EF_MIPS_ARCH_32R6) != 0) {
>> + return "mips32r6-generic";
>> + }
>> return "24Kf";
>
> That said, I don't suppose it's worth diagnosing cases that we can't support
> somehow? E.g. mips-linux-user and EF_MIPS_ARCH_64. Or even coldfire ISA-C.
Yes, the idea is "if we don't know, do as before":
the real error will be reported by the loader.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-01-17 9:20 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 17:25 [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values Laurent Vivier
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 1/4] linux-user: Move CPU type name selection to a function Laurent Vivier
2018-01-16 20:10 ` Richard Henderson
2018-01-16 20:34 ` Philippe Mathieu-Daudé
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 2/4] linux-user: introduce functions to detect CPU type Laurent Vivier
2018-01-16 20:11 ` Richard Henderson
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 3/4] linux-user, m68k: select CPU according to ELF header values Laurent Vivier
2018-01-16 20:22 ` Richard Henderson
2018-01-16 17:25 ` [Qemu-devel] [PATCH v2 4/4] linux-user: MIPS set cpu to r6 CPU if binary is R6 Laurent Vivier
2018-01-16 20:26 ` Richard Henderson
2018-01-16 22:01 ` Laurent Vivier
2018-01-16 20:29 ` Philippe Mathieu-Daudé
2018-01-16 21:58 ` Laurent Vivier
2018-01-16 17:33 ` [Qemu-devel] [PATCH v2 0/4] linux-user: select CPU type according ELF header values no-reply
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).