qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [RFC PATCH 08/18] hw/i386: Inline TARGET_DEFAULT_CPU_TYPE definition
Date: Wed,  5 Mar 2025 16:39:18 +0100	[thread overview]
Message-ID: <20250305153929.43687-9-philmd@linaro.org> (raw)
In-Reply-To: <20250305153929.43687-1-philmd@linaro.org>

For legacy x86 binaries, legacy_binary_is_64bit() is equivalent
of the compile time TARGET_X86_64 definition. Use it in place in
machine class_init() handlers, removing the need on TARGET_X86_64.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/cpu.h     | 6 ------
 hw/i386/microvm.c     | 5 ++++-
 hw/i386/pc.c          | 5 ++++-
 hw/i386/xen/xen-pvh.c | 5 ++++-
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0ab2e1bdb40..7f3c1ceaca7 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2555,12 +2555,6 @@ 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")
-#else
-#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32")
-#endif
-
 #define cpu_list x86_cpu_list
 
 /* MMU modes definitions */
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index d0a236c74f3..cc94e1408c6 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -19,6 +19,7 @@
 #include "qemu/error-report.h"
 #include "qemu/cutils.h"
 #include "qemu/units.h"
+#include "qemu/legacy_binary_info.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qapi/qapi-visit-common.h"
@@ -654,7 +655,9 @@ static void microvm_class_init(ObjectClass *oc, void *data)
     mc->has_hotpluggable_cpus = false;
     mc->auto_enable_numa_with_memhp = false;
     mc->auto_enable_numa_with_memdev = false;
-    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = legacy_binary_is_64bit()
+                           ? X86_CPU_TYPE_NAME("qemu64")
+                           : X86_CPU_TYPE_NAME("qemu32");
     mc->nvdimm_supported = false;
     mc->default_ram_id = "microvm.ram";
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 63a96cd23f8..936a770aad8 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -24,6 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
+#include "qemu/legacy_binary_info.h"
 #include "hw/i386/pc.h"
 #include "hw/char/serial-isa.h"
 #include "hw/char/parallel.h"
@@ -1794,7 +1795,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     hc->plug = pc_machine_device_plug_cb;
     hc->unplug_request = pc_machine_device_unplug_request_cb;
     hc->unplug = pc_machine_device_unplug_cb;
-    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = legacy_binary_is_64bit()
+                           ? X86_CPU_TYPE_NAME("qemu64")
+                           : X86_CPU_TYPE_NAME("qemu32");
     mc->nvdimm_supported = true;
     mc->smp_props.dies_supported = true;
     mc->smp_props.modules_supported = true;
diff --git a/hw/i386/xen/xen-pvh.c b/hw/i386/xen/xen-pvh.c
index 33c10279763..f0080c83021 100644
--- a/hw/i386/xen/xen-pvh.c
+++ b/hw/i386/xen/xen-pvh.c
@@ -8,6 +8,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/legacy_binary_info.h"
 #include "qemu/error-report.h"
 #include "hw/boards.h"
 #include "system/system.h"
@@ -81,7 +82,9 @@ static void xen_pvh_machine_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Xen PVH x86 machine";
-    mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
+    mc->default_cpu_type = legacy_binary_is_64bit()
+                           ? X86_CPU_TYPE_NAME("qemu64")
+                           : X86_CPU_TYPE_NAME("qemu32");
 
     /* mc->max_cpus holds the MAX value allowed in the -smp cmd-line opts. */
     mc->max_cpus = HVM_MAX_VCPUS;
-- 
2.47.1



  parent reply	other threads:[~2025-03-05 15:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo Philippe Mathieu-Daudé
2025-03-05 16:53   ` Pierrick Bouvier
2025-03-06  1:35   ` Richard Henderson
2025-03-13  8:10   ` Michael Tokarev
2025-03-13  9:40     ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers Philippe Mathieu-Daudé
2025-03-06  1:37   ` Richard Henderson
2025-03-05 15:39 ` [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition Philippe Mathieu-Daudé
2025-03-06  1:37   ` Richard Henderson
2025-03-05 15:39 ` [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h' Philippe Mathieu-Daudé
2025-03-05 16:59   ` Pierrick Bouvier
2025-03-06  7:26     ` Thomas Huth
2025-03-06  9:26       ` Philippe Mathieu-Daudé
2025-03-06 11:34         ` Paolo Bonzini
2025-03-06 11:52           ` Daniel P. Berrangé
2025-03-06 13:45             ` BALATON Zoltan
2025-03-06 15:15               ` Daniel P. Berrangé
2025-03-06 15:28                 ` BALATON Zoltan
2025-03-06 21:45                   ` Pierrick Bouvier
2025-03-07  0:46                     ` BALATON Zoltan
2025-03-05 19:19   ` Paolo Bonzini
2025-03-06  1:56   ` Richard Henderson
2025-03-06 12:13     ` Daniel P. Berrangé
2025-03-19 14:25     ` Philippe Mathieu-Daudé
2025-03-22  6:59       ` Markus Armbruster
2025-03-05 15:39 ` [RFC PATCH 05/18] qemu: Introduce legacy_binary_is_64bit() helper Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 06/18] hw/mips/mipssim: Replace TARGET_MIPS64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 07/18] hw/mips/malta: " Philippe Mathieu-Daudé
2025-03-05 15:39 ` Philippe Mathieu-Daudé [this message]
2025-03-05 15:39 ` [RFC PATCH 09/18] hw/ppc/mac: Replace TARGET_PPC64 " Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper Philippe Mathieu-Daudé
2025-03-06  7:28   ` Thomas Huth
2025-03-06 14:10     ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 11/18] hw/mips/jazz: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 12/18] hw/mips/mipssim: Use legacy_binary_is_big_endian() Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 13/18] hw/xtensa/sim: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 14/18] hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian() Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 15/18] hw/microblaze/petalogix_ml605_mmu: Use legacy_binary_is_big_endian() Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 16/18] hw/microblaze/petalogix_s3adsp1800_mmu: Use legacy_binary_is_big_endian Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 17/18] meson: Allow symlinking system emulation binaries Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 18/18] configs/targets: Merge qemu-system-microblaze{el} binaries Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250305153929.43687-9-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).