Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hw/intc/arm_gic: Un-inline GIC*/ITS class_name() helpers
"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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230405160454.97436-4-philmd@linaro.org>
  • Loading branch information
philmd committed Jun 28, 2023
1 parent dec68f7 commit 0c40daf
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 46 deletions.
1 change: 1 addition & 0 deletions hw/arm/sbsa-ref.c
Expand Up @@ -36,6 +36,7 @@
#include "hw/ide/internal.h"
#include "hw/ide/ahci_internal.h"
#include "hw/intc/arm_gicv3_common.h"
#include "hw/intc/arm_gicv3_its_common.h"
#include "hw/loader.h"
#include "hw/pci-host/gpex.h"
#include "hw/qdev-properties.h"
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/virt-acpi-build.c
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions hw/arm/virt.c
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions hw/intc/arm_gic_common.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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";
}
14 changes: 14 additions & 0 deletions hw/intc/arm_gicv3_common.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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";
}
}
12 changes: 12 additions & 0 deletions hw/intc/arm_gicv3_its_common.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 changes: 2 additions & 0 deletions include/hw/intc/arm_gic.h
Expand Up @@ -86,4 +86,6 @@ struct ARMGICClass {
DeviceRealize parent_realize;
};

const char *gic_class_name(void);

#endif
10 changes: 10 additions & 0 deletions include/hw/intc/arm_gicv3_common.h
Expand Up @@ -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
9 changes: 9 additions & 0 deletions include/hw/intc/arm_gicv3_its_common.h
Expand Up @@ -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
45 changes: 0 additions & 45 deletions target/arm/kvm_arm.h
Expand Up @@ -453,32 +453,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
Expand Down Expand Up @@ -516,23 +490,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

0 comments on commit 0c40daf

Please sign in to comment.