[PATCH 06/10] target/i386: Select a 32-bit/64-bit default CPU during runtime

Thomas Huth posted 10 patches 1 week, 2 days ago
Maintainers: Pierrick Bouvier <pierrick.bouvier@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Zhao Liu <zhao1.liu@intel.com>
[PATCH 06/10] target/i386: Select a 32-bit/64-bit default CPU during runtime
Posted by Thomas Huth 1 week, 2 days ago
From: Thomas Huth <thuth@redhat.com>

For supporting both, the i386 and the x86_64 target in one binary,
TARGET_DEFAULT_CPU_TYPE needs to be adjusted during runtime.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 target/i386/cpu.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 9cb357aa797..9d71d1dcca7 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2777,7 +2777,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define CPU_RESOLVING_TYPE TYPE_X86_CPU
 
 #ifdef TARGET_X86_64
-#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64")
+#define TARGET_DEFAULT_CPU_TYPE \
+            (target_i386() ? X86_CPU_TYPE_NAME("qemu32") \
+                           : X86_CPU_TYPE_NAME("qemu64"))
 #else
 #define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32")
 #endif
-- 
2.53.0