From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
qemu-arm@nongnu.org, "Igor Mammedov" <imammedo@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org,
"David Hildenbrand" <david@redhat.com>,
qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 17/20] cpus: Have cpu_class_init_props() per user / system emulation
Date: Fri, 24 Jan 2025 00:44:11 +0100 [thread overview]
Message-ID: <20250123234415.59850-18-philmd@linaro.org> (raw)
In-Reply-To: <20250123234415.59850-1-philmd@linaro.org>
Rather than maintaining a mix of system / user code for CPU
class properties, move system properties to cpu-system.c
and user ones to the new cpu-user.c unit.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
cpu-target.c | 58 --------------------------------------------
hw/core/cpu-system.c | 40 ++++++++++++++++++++++++++++++
hw/core/cpu-user.c | 27 +++++++++++++++++++++
hw/core/meson.build | 5 +++-
4 files changed, 71 insertions(+), 59 deletions(-)
create mode 100644 hw/core/cpu-user.c
diff --git a/cpu-target.c b/cpu-target.c
index c05ef1ff096..dff8c0747f9 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -19,15 +19,12 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "hw/qdev-core.h"
-#include "hw/qdev-properties.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
#include "migration/vmstate.h"
#ifndef CONFIG_USER_ONLY
#include "hw/core/sysemu-cpu-ops.h"
#include "exec/address-spaces.h"
-#include "exec/memory.h"
#endif
#include "system/accel-ops.h"
#include "system/cpus.h"
@@ -179,61 +176,6 @@ void cpu_exec_unrealizefn(CPUState *cpu)
accel_cpu_common_unrealize(cpu);
}
-/*
- * This can't go in hw/core/cpu.c because that file is compiled only
- * once for both user-mode and system builds.
- */
-static const Property cpu_common_props[] = {
-#ifdef CONFIG_USER_ONLY
- /*
- * Create a property for the user-only object, so users can
- * adjust prctl(PR_SET_UNALIGN) from the command-line.
- * Has no effect if the target does not support the feature.
- */
- DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState,
- prctl_unalign_sigbus, false),
-#else
- /*
- * Create a memory property for system CPU object, so users can
- * wire up its memory. The default if no link is set up is to use
- * the system address space.
- */
- DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
- MemoryRegion *),
-#endif
-};
-
-#ifndef CONFIG_USER_ONLY
-static bool cpu_get_start_powered_off(Object *obj, Error **errp)
-{
- CPUState *cpu = CPU(obj);
- return cpu->start_powered_off;
-}
-
-static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp)
-{
- CPUState *cpu = CPU(obj);
- cpu->start_powered_off = value;
-}
-#endif
-
-void cpu_class_init_props(DeviceClass *dc)
-{
-#ifndef CONFIG_USER_ONLY
- ObjectClass *oc = OBJECT_CLASS(dc);
-
- /*
- * We can't use DEFINE_PROP_BOOL in the Property array for this
- * property, because we want this to be settable after realize.
- */
- object_class_property_add_bool(oc, "start-powered-off",
- cpu_get_start_powered_off,
- cpu_set_start_powered_off);
-#endif
-
- device_class_set_props(dc, cpu_common_props);
-}
-
void cpu_exec_initfn(CPUState *cpu)
{
#ifndef CONFIG_USER_ONLY
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 6aae28a349a..c63c984a803 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -20,7 +20,10 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "exec/memory.h"
#include "exec/tswap.h"
+#include "hw/qdev-core.h"
+#include "hw/qdev-properties.h"
#include "hw/core/sysemu-cpu-ops.h"
bool cpu_paging_enabled(const CPUState *cpu)
@@ -142,3 +145,40 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
}
return res;
}
+
+static const Property cpu_system_props[] = {
+ /*
+ * Create a memory property for system CPU object, so users can
+ * wire up its memory. The default if no link is set up is to use
+ * the system address space.
+ */
+ DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
+ MemoryRegion *),
+};
+
+static bool cpu_get_start_powered_off(Object *obj, Error **errp)
+{
+ CPUState *cpu = CPU(obj);
+ return cpu->start_powered_off;
+}
+
+static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp)
+{
+ CPUState *cpu = CPU(obj);
+ cpu->start_powered_off = value;
+}
+
+void cpu_class_init_props(DeviceClass *dc)
+{
+ ObjectClass *oc = OBJECT_CLASS(dc);
+
+ /*
+ * We can't use DEFINE_PROP_BOOL in the Property array for this
+ * property, because we want this to be settable after realize.
+ */
+ object_class_property_add_bool(oc, "start-powered-off",
+ cpu_get_start_powered_off,
+ cpu_set_start_powered_off);
+
+ device_class_set_props(dc, cpu_system_props);
+}
diff --git a/hw/core/cpu-user.c b/hw/core/cpu-user.c
new file mode 100644
index 00000000000..e5ccf6bf13a
--- /dev/null
+++ b/hw/core/cpu-user.c
@@ -0,0 +1,27 @@
+/*
+ * QEMU CPU model (user specific)
+ *
+ * Copyright (c) Linaro, Ltd.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev-core.h"
+#include "hw/qdev-properties.h"
+#include "hw/core/cpu.h"
+
+static const Property cpu_user_props[] = {
+ /*
+ * Create a property for the user-only object, so users can
+ * adjust prctl(PR_SET_UNALIGN) from the command-line.
+ * Has no effect if the target does not support the feature.
+ */
+ DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState,
+ prctl_unalign_sigbus, false),
+};
+
+void cpu_class_init_props(DeviceClass *dc)
+{
+ device_class_set_props(dc, cpu_user_props);
+}
diff --git a/hw/core/meson.build b/hw/core/meson.build
index 65a1698ed1f..b5a545a0edd 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -46,4 +46,7 @@ system_ss.add(files(
'vm-change-state-handler.c',
'clock-vmstate.c',
))
-user_ss.add(files('qdev-user.c'))
+user_ss.add(files(
+ 'cpu-user.c',
+ 'qdev-user.c',
+))
--
2.47.1
next prev parent reply other threads:[~2025-01-23 23:45 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 23:43 [PATCH 00/20] accel: Simplify cpu-target.c (omnibus) Philippe Mathieu-Daudé
2025-01-23 23:43 ` [PATCH 01/20] qemu/compiler: Absorb 'clang-tsa.h' Philippe Mathieu-Daudé
2025-01-23 23:43 ` [PATCH 02/20] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé
2025-01-23 23:45 ` Philippe Mathieu-Daudé
2025-01-26 19:55 ` Richard Henderson
2025-01-23 23:43 ` [PATCH 03/20] gdbstub: Check for TCG before calling tb_flush() Philippe Mathieu-Daudé
2025-01-24 12:50 ` Alex Bennée
2025-01-26 19:56 ` Richard Henderson
2025-01-23 23:43 ` [PATCH 04/20] cpus: Cache CPUClass early in instance_init() handler Philippe Mathieu-Daudé
2025-01-23 23:43 ` [PATCH 05/20] cpus: Keep default fields initialization in cpu_common_initfn() Philippe Mathieu-Daudé
2025-01-26 20:00 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 06/20] accel/kvm: Remove unused 'system/cpus.h' header in kvm-cpus.h Philippe Mathieu-Daudé
2025-01-26 20:00 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 07/20] accel/tcg: Build tcg_flags helpers as common code Philippe Mathieu-Daudé
2025-01-26 20:00 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 08/20] accel/tcg: Restrict tlb_init() / destroy() to TCG Philippe Mathieu-Daudé
2025-01-26 20:32 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 09/20] accel/tcg: Restrict 'icount_align_option' global " Philippe Mathieu-Daudé
2025-01-26 20:34 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 10/20] accel/tcg: Rename 'hw/core/tcg-cpu-ops.h' -> 'accel/tcg/cpu-ops.h' Philippe Mathieu-Daudé
2025-01-26 20:36 ` Richard Henderson
2025-01-26 20:38 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 11/20] accel: Rename 'hw/core/accel-cpu.h' -> 'accel/accel-cpu-target.h' Philippe Mathieu-Daudé
2025-01-26 20:39 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 12/20] accel/accel-cpu-target.h: Include missing 'cpu.h' header Philippe Mathieu-Daudé
2025-01-26 20:40 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 13/20] accel: Forward-declare AccelOpsClass in 'qemu/typedefs.h' Philippe Mathieu-Daudé
2025-01-26 20:42 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 14/20] accel/tcg: Move cpu_memory_rw_debug() user implementation to user-exec.c Philippe Mathieu-Daudé
2025-01-26 21:13 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 15/20] cpus: Fix style in cpu-target.c Philippe Mathieu-Daudé
2025-01-26 21:14 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 16/20] cpus: Restrict cpu_common_post_load() code to TCG Philippe Mathieu-Daudé
2025-01-26 21:16 ` Richard Henderson
2025-02-17 17:19 ` Philippe Mathieu-Daudé
2025-02-17 19:28 ` Richard Henderson
2025-01-23 23:44 ` Philippe Mathieu-Daudé [this message]
2025-01-26 21:18 ` [PATCH 17/20] cpus: Have cpu_class_init_props() per user / system emulation Richard Henderson
2025-01-23 23:44 ` [PATCH 18/20] cpus: Have cpu_exec_initfn() " Philippe Mathieu-Daudé
2025-01-26 21:21 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 19/20] cpus: Register VMState " Philippe Mathieu-Daudé
2025-01-26 21:35 ` Richard Henderson
2025-01-23 23:44 ` [PATCH 20/20] cpus: Build cpu_exec_[un]realizefn() methods once Philippe Mathieu-Daudé
2025-01-26 21:37 ` Richard Henderson
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=20250123234415.59850-18-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=david@redhat.com \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=xen-devel@lists.xenproject.org \
/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