From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
qemu-arm@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [RFC PATCH-for-9.1? 1/2] target/arm: Move qmp_query_gic_capabilities() to hw/intc/
Date: Tue, 6 Aug 2024 16:19:39 +0200 [thread overview]
Message-ID: <20240806141940.22095-2-philmd@linaro.org> (raw)
In-Reply-To: <20240806141940.22095-1-philmd@linaro.org>
qmp_query_gic_capabilities() is not specific to the ARM
architecture but to the GIC device which is modelled in
hw/intc/, so move the code there for clarity. No logical
change intended.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/intc/arm_gic_qmp.c | 59 +++++++++++++++++++++++++++++++++++++++
target/arm/arm-qmp-cmds.c | 52 +---------------------------------
hw/intc/meson.build | 1 +
3 files changed, 61 insertions(+), 51 deletions(-)
create mode 100644 hw/intc/arm_gic_qmp.c
diff --git a/hw/intc/arm_gic_qmp.c b/hw/intc/arm_gic_qmp.c
new file mode 100644
index 0000000000..71056a0c10
--- /dev/null
+++ b/hw/intc/arm_gic_qmp.c
@@ -0,0 +1,59 @@
+/*
+ * QEMU ARM GIC QMP command
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/util.h"
+#include "qapi/qapi-commands-misc-target.h"
+#include "kvm_arm.h"
+
+static GICCapability *gic_cap_new(int version)
+{
+ GICCapability *cap = g_new0(GICCapability, 1);
+ cap->version = version;
+ /* by default, support none */
+ cap->emulated = false;
+ cap->kernel = false;
+ return cap;
+}
+
+static inline void gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3)
+{
+#ifdef CONFIG_KVM
+ int fdarray[3];
+
+ if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, NULL)) {
+ return;
+ }
+
+ /* Test KVM GICv2 */
+ if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V2)) {
+ v2->kernel = true;
+ }
+
+ /* Test KVM GICv3 */
+ if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V3)) {
+ v3->kernel = true;
+ }
+
+ kvm_arm_destroy_scratch_host_vcpu(fdarray);
+#endif
+}
+
+GICCapabilityList *qmp_query_gic_capabilities(Error **errp)
+{
+ GICCapabilityList *head = NULL;
+ GICCapability *v2 = gic_cap_new(2), *v3 = gic_cap_new(3);
+
+ v2->emulated = true;
+ v3->emulated = true;
+
+ gic_cap_kvm_probe(v2, v3);
+
+ QAPI_LIST_PREPEND(head, v2);
+ QAPI_LIST_PREPEND(head, v3);
+
+ return head;
+}
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index 3cc8cc738b..3303c71b21 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -22,64 +22,14 @@
#include "qemu/osdep.h"
#include "hw/boards.h"
-#include "kvm_arm.h"
+#include "sysemu/kvm.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qapi-commands-machine-target.h"
-#include "qapi/qapi-commands-misc-target.h"
#include "qapi/qmp/qdict.h"
#include "qom/qom-qobject.h"
-static GICCapability *gic_cap_new(int version)
-{
- GICCapability *cap = g_new0(GICCapability, 1);
- cap->version = version;
- /* by default, support none */
- cap->emulated = false;
- cap->kernel = false;
- return cap;
-}
-
-static inline void gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3)
-{
-#ifdef CONFIG_KVM
- int fdarray[3];
-
- if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, NULL)) {
- return;
- }
-
- /* Test KVM GICv2 */
- if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V2)) {
- v2->kernel = true;
- }
-
- /* Test KVM GICv3 */
- if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V3)) {
- v3->kernel = true;
- }
-
- kvm_arm_destroy_scratch_host_vcpu(fdarray);
-#endif
-}
-
-GICCapabilityList *qmp_query_gic_capabilities(Error **errp)
-{
- GICCapabilityList *head = NULL;
- GICCapability *v2 = gic_cap_new(2), *v3 = gic_cap_new(3);
-
- v2->emulated = true;
- v3->emulated = true;
-
- gic_cap_kvm_probe(v2, v3);
-
- QAPI_LIST_PREPEND(head, v2);
- QAPI_LIST_PREPEND(head, v3);
-
- return head;
-}
-
QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16);
/*
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
index afd1aa51ee..45d3503d49 100644
--- a/hw/intc/meson.build
+++ b/hw/intc/meson.build
@@ -39,6 +39,7 @@ if config_all_devices.has_key('CONFIG_APIC') or \
endif
specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c'))
+specific_ss.add(when: 'CONFIG_ARM', if_true: files('arm_gic_qmp.c'))
specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c'))
specific_ss.add(when: 'CONFIG_ARM_GICV3_TCG', if_true: files('arm_gicv3_cpuif.c'))
specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c'))
--
2.45.2
next prev parent reply other threads:[~2024-08-06 14:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 14:19 [RFC PATCH-for-9.1? 0/2] hw/intc/arm_gic: Only provide query-gic-capabilities when GIC built-in Philippe Mathieu-Daudé
2024-08-06 14:19 ` Philippe Mathieu-Daudé [this message]
2024-08-07 3:46 ` [RFC PATCH-for-9.1? 1/2] target/arm: Move qmp_query_gic_capabilities() to hw/intc/ Richard Henderson
2024-08-07 7:31 ` Philippe Mathieu-Daudé
2024-08-07 16:17 ` Peter Maydell
2024-08-08 4:32 ` Markus Armbruster
2024-08-08 8:44 ` Peter Maydell
2024-08-08 9:02 ` Markus Armbruster
2024-08-08 10:15 ` Peter Maydell
2024-08-08 11:05 ` Markus Armbruster
2024-08-08 11:23 ` Daniel P. Berrangé
2024-08-08 11:32 ` Peter Maydell
2024-08-08 11:48 ` Daniel P. Berrangé
2024-08-08 11:56 ` Daniel P. Berrangé
2024-08-08 12:04 ` Peter Maydell
2024-08-07 5:12 ` Markus Armbruster
2024-08-07 7:28 ` Philippe Mathieu-Daudé
2024-08-07 8:16 ` Markus Armbruster
2024-08-06 14:19 ` [RFC PATCH-for-9.1? 2/2] hw/intc/arm_gic: Only provide query-gic-capabilities when GIC built-in Philippe Mathieu-Daudé
2024-08-07 3:47 ` Richard Henderson
2024-08-07 8:18 ` Markus Armbruster
2024-08-07 9:03 ` Philippe Mathieu-Daudé
2024-08-07 11:10 ` Markus Armbruster
2024-08-07 16:30 ` Peter Maydell
2024-08-08 5:35 ` Markus Armbruster
2024-08-08 8:48 ` Peter Maydell
2025-03-11 11:39 ` [RFC PATCH-for-9.1? 0/2] " 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=20240806141940.22095-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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).