From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, qemu-riscv@nongnu.org,
"Alex Bennée" <alex.bennee@linaro.org>,
qemu-arm@nongnu.org, kvm@vger.kernel.org, qemu-ppc@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Shannon Zhao" <shannon.zhaosl@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Ani Sinha" <ani@anisinha.ca>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 03/10] hw/intc/arm_gic: Un-inline GIC*/ITS class_name() helpers
Date: Wed, 5 Apr 2023 18:04:47 +0200 [thread overview]
Message-ID: <20230405160454.97436-4-philmd@linaro.org> (raw)
In-Reply-To: <20230405160454.97436-1-philmd@linaro.org>
"kvm_arm.h" contains external and internal prototype declarations.
Files under the hw/ directory should only access the KVM external
API.
In order to avoid machine / device models to include "kvm_arm.h"
simply to get the QOM GIC/ITS class name, un-inline each class
name getter to the proper device model file.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/intc/arm_gic.h | 2 ++
include/hw/intc/arm_gicv3_common.h | 10 ++++++
include/hw/intc/arm_gicv3_its_common.h | 9 ++++++
target/arm/kvm_arm.h | 45 --------------------------
hw/arm/virt-acpi-build.c | 2 +-
hw/arm/virt.c | 1 +
hw/intc/arm_gic_common.c | 7 ++++
hw/intc/arm_gicv3_common.c | 14 ++++++++
hw/intc/arm_gicv3_its_common.c | 12 +++++++
9 files changed, 56 insertions(+), 46 deletions(-)
diff --git a/include/hw/intc/arm_gic.h b/include/hw/intc/arm_gic.h
index 116ccbb5a9..48f6a51a70 100644
--- a/include/hw/intc/arm_gic.h
+++ b/include/hw/intc/arm_gic.h
@@ -86,4 +86,6 @@ struct ARMGICClass {
DeviceRealize parent_realize;
};
+const char *gic_class_name(void);
+
#endif
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
index ab5182a28a..4e2fb518e7 100644
--- a/include/hw/intc/arm_gicv3_common.h
+++ b/include/hw/intc/arm_gicv3_common.h
@@ -329,4 +329,14 @@ struct ARMGICv3CommonClass {
void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
const MemoryRegionOps *ops);
+/**
+ * gicv3_class_name
+ *
+ * Return name of GICv3 class to use depending on whether KVM acceleration is
+ * in use. May throw an error if the chosen implementation is not available.
+ *
+ * Returns: class name to use
+ */
+const char *gicv3_class_name(void);
+
#endif
diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h
index a11a0f6654..7dc712b38d 100644
--- a/include/hw/intc/arm_gicv3_its_common.h
+++ b/include/hw/intc/arm_gicv3_its_common.h
@@ -122,5 +122,14 @@ struct GICv3ITSCommonClass {
void (*post_load)(GICv3ITSState *s);
};
+/**
+ * its_class_name:
+ *
+ * Return the ITS class name to use depending on whether KVM acceleration
+ * and KVM CAP_SIGNAL_MSI are supported
+ *
+ * Returns: class name to use or NULL
+ */
+const char *its_class_name(void);
#endif
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index 99017b635c..fe6d824a52 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -445,32 +445,6 @@ static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs)
#endif
-static inline const char *gic_class_name(void)
-{
- return kvm_irqchip_in_kernel() ? "kvm-arm-gic" : "arm_gic";
-}
-
-/**
- * gicv3_class_name
- *
- * Return name of GICv3 class to use depending on whether KVM acceleration is
- * in use. May throw an error if the chosen implementation is not available.
- *
- * Returns: class name to use
- */
-static inline const char *gicv3_class_name(void)
-{
- if (kvm_irqchip_in_kernel()) {
- return "kvm-arm-gicv3";
- } else {
- if (kvm_enabled()) {
- error_report("Userspace GICv3 is not supported with KVM");
- exit(1);
- }
- return "arm-gicv3";
- }
-}
-
/**
* kvm_arm_handle_debug:
* @cs: CPUState
@@ -508,23 +482,4 @@ void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
*/
bool kvm_arm_verify_ext_dabt_pending(CPUState *cs);
-/**
- * its_class_name:
- *
- * Return the ITS class name to use depending on whether KVM acceleration
- * and KVM CAP_SIGNAL_MSI are supported
- *
- * Returns: class name to use or NULL
- */
-static inline const char *its_class_name(void)
-{
- if (kvm_irqchip_in_kernel()) {
- /* KVM implementation requires this capability */
- return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL;
- } else {
- /* Software emulation based model */
- return "arm-gicv3-its";
- }
-}
-
#endif
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 4156111d49..e8bab19847 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -48,12 +48,12 @@
#include "hw/pci/pci_bus.h"
#include "hw/pci-host/gpex.h"
#include "hw/arm/virt.h"
+#include "hw/intc/arm_gicv3_its_common.h"
#include "hw/mem/nvdimm.h"
#include "hw/platform-bus.h"
#include "sysemu/numa.h"
#include "sysemu/reset.h"
#include "sysemu/tpm.h"
-#include "kvm_arm.h"
#include "migration/vmstate.h"
#include "hw/acpi/ghes.h"
#include "hw/acpi/viot.h"
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 1fe39c6683..dbbe639e61 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -63,6 +63,7 @@
#include "hw/arm/fdt.h"
#include "hw/intc/arm_gic.h"
#include "hw/intc/arm_gicv3_common.h"
+#include "hw/intc/arm_gicv3_its_common.h"
#include "hw/irq.h"
#include "kvm_arm.h"
#include "hw/firmware/smbios.h"
diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c
index a379cea395..9702197856 100644
--- a/hw/intc/arm_gic_common.c
+++ b/hw/intc/arm_gic_common.c
@@ -21,10 +21,12 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/module.h"
+#include "qemu/error-report.h"
#include "gic_internal.h"
#include "hw/arm/linux-boot-if.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
+#include "sysemu/kvm.h"
static int gic_pre_save(void *opaque)
{
@@ -393,3 +395,8 @@ static void register_types(void)
}
type_init(register_types)
+
+const char *gic_class_name(void)
+{
+ return kvm_irqchip_in_kernel() ? "kvm-arm-gic" : "arm_gic";
+}
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
index 642a8243ed..2ebf880ead 100644
--- a/hw/intc/arm_gicv3_common.c
+++ b/hw/intc/arm_gicv3_common.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/module.h"
+#include "qemu/error-report.h"
#include "hw/core/cpu.h"
#include "hw/intc/arm_gicv3_common.h"
#include "hw/qdev-properties.h"
@@ -608,3 +609,16 @@ static void register_types(void)
}
type_init(register_types)
+
+const char *gicv3_class_name(void)
+{
+ if (kvm_irqchip_in_kernel()) {
+ return "kvm-arm-gicv3";
+ } else {
+ if (kvm_enabled()) {
+ error_report("Userspace GICv3 is not supported with KVM");
+ exit(1);
+ }
+ return "arm-gicv3";
+ }
+}
diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c
index d7532a7a89..abaf77057e 100644
--- a/hw/intc/arm_gicv3_its_common.c
+++ b/hw/intc/arm_gicv3_its_common.c
@@ -24,6 +24,7 @@
#include "hw/intc/arm_gicv3_its_common.h"
#include "qemu/log.h"
#include "qemu/module.h"
+#include "sysemu/kvm.h"
static int gicv3_its_pre_save(void *opaque)
{
@@ -158,3 +159,14 @@ static void gicv3_its_common_register_types(void)
}
type_init(gicv3_its_common_register_types)
+
+const char *its_class_name(void)
+{
+ if (kvm_irqchip_in_kernel()) {
+ /* KVM implementation requires this capability */
+ return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL;
+ } else {
+ /* Software emulation based model */
+ return "arm-gicv3-its";
+ }
+}
--
2.38.1
next prev parent reply other threads:[~2023-04-05 16:07 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 16:04 [PATCH 00/10] accel/kvm: Spring cleaning Philippe Mathieu-Daudé
2023-04-05 16:04 ` [PATCH 01/10] sysemu/kvm: Remove unused headers Philippe Mathieu-Daudé
2023-04-06 8:58 ` Alex Bennée
2023-04-08 0:36 ` Richard Henderson
2023-06-06 5:32 ` Philippe Mathieu-Daudé
2023-04-05 16:04 ` [PATCH 02/10] accel/kvm: Declare kvm_direct_msi_allowed in stubs Philippe Mathieu-Daudé
2023-04-06 8:59 ` Alex Bennée
2023-04-08 0:37 ` Richard Henderson
2023-04-05 16:04 ` Philippe Mathieu-Daudé [this message]
2023-04-08 4:22 ` [PATCH 03/10] hw/intc/arm_gic: Un-inline GIC*/ITS class_name() helpers Richard Henderson
2023-04-05 16:04 ` [PATCH 04/10] hw/intc/arm_gic: Rename 'first_cpu' argument Philippe Mathieu-Daudé
2023-04-08 4:23 ` Richard Henderson
2023-04-08 4:24 ` Richard Henderson
2023-04-11 7:31 ` Alex Bennée
2023-04-05 16:04 ` [PATCH 05/10] hw/arm/sbsa-ref: Include missing 'sysemu/kvm.h' header Philippe Mathieu-Daudé
2023-04-05 18:23 ` Leif Lindholm
2023-04-08 4:24 ` Richard Henderson
2023-04-05 16:04 ` [PATCH 06/10] target/arm: Reduce QMP header pressure by not including 'kvm_arm.h' Philippe Mathieu-Daudé
2023-04-08 4:25 ` Richard Henderson
2023-04-05 16:04 ` [PATCH 07/10] target/arm: Restrict KVM-specific fields from ArchCPU Philippe Mathieu-Daudé
2023-04-08 4:25 ` Richard Henderson
2023-04-05 16:04 ` [PATCH 08/10] target/ppc: Restrict KVM-specific field " Philippe Mathieu-Daudé
2023-04-05 20:07 ` Daniel Henrique Barboza
2023-04-06 17:46 ` Cédric Le Goater
2023-04-05 16:04 ` [RFC PATCH 09/10] target/riscv: Restrict KVM-specific fields " Philippe Mathieu-Daudé
2023-04-05 20:44 ` Daniel Henrique Barboza
2023-04-08 4:28 ` Richard Henderson
2023-04-08 4:29 ` Richard Henderson
2023-04-05 16:04 ` [PATCH 10/10] hw/s390x: Rename pv.c -> pv-kvm.c Philippe Mathieu-Daudé
2023-04-06 7:50 ` Thomas Huth
2023-04-06 8:04 ` Janosch Frank
2023-04-06 8:22 ` Philippe Mathieu-Daudé
2023-04-06 8:30 ` Thomas Huth
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=20230405160454.97436-4-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=ani@anisinha.ca \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--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=shannon.zhaosl@gmail.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).