Implement a gicv5_class_name() function that does the same job as gicv3_class_name(): allows board code to get the correct QOM type for the GIC at runtime depending on whether KVM is enabled or not.
For the GICv5, we don't yet implement KVM support, so the KVM-enabled codepath is always an error. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-id: [email protected] --- include/hw/intc/arm_gicv5_common.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5_common.h index 233233bc3e..e7220b9dc7 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -13,6 +13,8 @@ #include "hw/core/sysbus.h" #include "hw/intc/arm_gicv5_types.h" #include "target/arm/cpu-qom.h" +#include "qemu/error-report.h" +#include "system/kvm.h" /* * QEMU interface: @@ -150,4 +152,22 @@ static inline bool gicv5_domain_implemented(GICv5Common *cs, GICv5Domain domain) return cs->implemented_domains & (1 << domain); } +/** + * gicv5_class_name + * + * Return name of GICv5 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 *gicv5_class_name(void) +{ + /* When we implement KVM GICv5 we might return "kvm-arm-gicv5" here. */ + if (kvm_enabled()) { + error_report("Userspace GICv5 is not supported with KVM"); + exit(1); + } + return "arm-gicv5"; +} + #endif -- 2.43.0
