This commit adds the skeleton of the classes for the GICv5 IRS (Interrupt Routing Service). Since the IRS is the main (and only non-optional) part of the GICv5 outside the CPU, we call it simply "GICv5", in line with how we've handled the GICv3.
Since we're definitely going to need to have support for KVM VMs where we present the guest with a GICv5, we use the same split between an abstract "common" and a concrete specific-to-TCG child class that we have for the various GICv3 components. This avoids having to refactor out the base class later. Signed-off-by: Peter Maydell <[email protected]> --- hw/intc/Kconfig | 4 +++ hw/intc/arm_gicv5.c | 39 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 31 ++++++++++++++++++++++++ hw/intc/meson.build | 4 +++ include/hw/intc/arm_gicv5.h | 32 ++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 31 ++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 hw/intc/arm_gicv5.c create mode 100644 hw/intc/arm_gicv5_common.c create mode 100644 include/hw/intc/arm_gicv5.h create mode 100644 include/hw/intc/arm_gicv5_common.h diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index 9f456d7e43..a3241fc1eb 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -35,6 +35,10 @@ config ARM_GIC_KVM bool depends on ARM_GIC && KVM +config ARM_GICV5 + bool + select MSI_NONBROKEN + config XICS bool diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c new file mode 100644 index 0000000000..f9dab710d3 --- /dev/null +++ b/hw/intc/arm_gicv5.c @@ -0,0 +1,39 @@ +/* + * ARM GICv5 emulation: Interrupt Routing Service (IRS) + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/intc/arm_gicv5.h" + +OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON) + +static void gicv5_reset_hold(Object *obj, ResetType type) +{ + GICv5 *s = ARM_GICV5(obj); + GICv5Class *c = ARM_GICV5_GET_CLASS(s); + + if (c->parent_phases.hold) { + c->parent_phases.hold(obj, type); + } +} + +static void gicv5_init(Object *obj) +{ +} + +static void gicv5_finalize(Object *obj) +{ +} + +static void gicv5_class_init(ObjectClass *oc, const void *data) +{ + ResettableClass *rc = RESETTABLE_CLASS(oc); + GICv5Class *gc = ARM_GICV5_CLASS(oc); + + resettable_class_set_parent_phases(rc, NULL, gicv5_reset_hold, NULL, + &gc->parent_phases); +} diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c new file mode 100644 index 0000000000..b0194f7f26 --- /dev/null +++ b/hw/intc/arm_gicv5_common.c @@ -0,0 +1,31 @@ +/* + * Common base class for GICv5 IRS + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/intc/arm_gicv5_common.h" + +OBJECT_DEFINE_ABSTRACT_TYPE(GICv5Common, gicv5_common, ARM_GICV5_COMMON, SYS_BUS_DEVICE) + +static void gicv5_common_reset_hold(Object *obj, ResetType type) +{ +} + +static void gicv5_common_init(Object *obj) +{ +} + +static void gicv5_common_finalize(Object *obj) +{ +} + +static void gicv5_common_class_init(ObjectClass *oc, const void *data) +{ + ResettableClass *rc = RESETTABLE_CLASS(oc); + + rc->phases.hold = gicv5_common_reset_hold; +} diff --git a/hw/intc/meson.build b/hw/intc/meson.build index 96742df090..e4ddc5107f 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -12,6 +12,10 @@ system_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files( 'arm_gicv3_its.c', 'arm_gicv3_redist.c', )) +system_ss.add(when: 'CONFIG_ARM_GICV5', if_true: files( + 'arm_gicv5_common.c', + 'arm_gicv5.c', +)) system_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_vic.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_intc.c')) diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h new file mode 100644 index 0000000000..3cd9652f6f --- /dev/null +++ b/include/hw/intc/arm_gicv5.h @@ -0,0 +1,32 @@ +/* + * ARM GICv5 emulation: Interrupt Routing Service (IRS) + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_ARM_GICV5_H +#define HW_INTC_ARM_GICV5_H + +#include "qom/object.h" +#include "hw/core/sysbus.h" +#include "hw/intc/arm_gicv5_common.h" + +#define TYPE_ARM_GICV5 "arm-gicv5" + +OBJECT_DECLARE_TYPE(GICv5, GICv5Class, ARM_GICV5) + +/* + * This class is for TCG-specific state for the GICv5. + */ +struct GICv5 { + GICv5Common parent_obj; +}; + +struct GICv5Class { + GICv5CommonClass parent_class; + ResettablePhases parent_phases; +}; + +#endif diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5_common.h new file mode 100644 index 0000000000..d2243c7660 --- /dev/null +++ b/include/hw/intc/arm_gicv5_common.h @@ -0,0 +1,31 @@ +/* + * Common base class for GICv5 IRS + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_ARM_GICV5_COMMON_H +#define HW_INTC_ARM_GICV5_COMMON_H + +#include "qom/object.h" +#include "hw/core/sysbus.h" + +#define TYPE_ARM_GICV5_COMMON "arm-gicv5-common" + +OBJECT_DECLARE_TYPE(GICv5Common, GICv5CommonClass, ARM_GICV5_COMMON) + +/* + * This class is for common state that will eventually be shared + * between TCG and KVM implementations of the GICv5. + */ +struct GICv5Common { + SysBusDevice parent_obj; +}; + +struct GICv5CommonClass { + SysBusDeviceClass parent_class; +}; + +#endif -- 2.43.0
