@samitouri / QOSamiQemu / commits / 836026f1dd

hw/intc: Skeleton of GICv5 IRS classes

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 <peter.maydell@linaro.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20260327111700.795099-4-peter.maydell@linaro.org

Peter Maydell committed Mar 27, 2026 at 11:15 UTC 836026f1ddd58d4d20f24d3cec45c5bcb1e9a791
6 files changed +142
hw/intc/Kconfig
+5
@@ -35,6 +35,11 @@ config ARM_GIC_KVM
35 bool
36 depends on ARM_GIC && KVM
37
38 +config ARM_GICV5
39 + bool
40 + depends on TCG
41 + select MSI_NONBROKEN
42 +
43 config XICS
44 bool
45
hw/intc/arm_gicv5.c new
+39
@@ -0,0 +1,39 @@
1 +/*
2 + * ARM GICv5 emulation: Interrupt Routing Service (IRS)
3 + *
4 + * Copyright (c) 2025 Linaro Limited
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +
9 +#include "qemu/osdep.h"
10 +#include "hw/intc/arm_gicv5.h"
11 +
12 +OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON)
13 +
14 +static void gicv5_reset_hold(Object *obj, ResetType type)
15 +{
16 + GICv5 *s = ARM_GICV5(obj);
17 + GICv5Class *c = ARM_GICV5_GET_CLASS(s);
18 +
19 + if (c->parent_phases.hold) {
20 + c->parent_phases.hold(obj, type);
21 + }
22 +}
23 +
24 +static void gicv5_init(Object *obj)
25 +{
26 +}
27 +
28 +static void gicv5_finalize(Object *obj)
29 +{
30 +}
31 +
32 +static void gicv5_class_init(ObjectClass *oc, const void *data)
33 +{
34 + ResettableClass *rc = RESETTABLE_CLASS(oc);
35 + GICv5Class *gc = ARM_GICV5_CLASS(oc);
36 +
37 + resettable_class_set_parent_phases(rc, NULL, gicv5_reset_hold, NULL,
38 + &gc->parent_phases);
39 +}
hw/intc/arm_gicv5_common.c new
+31
@@ -0,0 +1,31 @@
1 +/*
2 + * Common base class for GICv5 IRS
3 + *
4 + * Copyright (c) 2025 Linaro Limited
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +
9 +#include "qemu/osdep.h"
10 +#include "hw/intc/arm_gicv5_common.h"
11 +
12 +OBJECT_DEFINE_ABSTRACT_TYPE(GICv5Common, gicv5_common, ARM_GICV5_COMMON, SYS_BUS_DEVICE)
13 +
14 +static void gicv5_common_reset_hold(Object *obj, ResetType type)
15 +{
16 +}
17 +
18 +static void gicv5_common_init(Object *obj)
19 +{
20 +}
21 +
22 +static void gicv5_common_finalize(Object *obj)
23 +{
24 +}
25 +
26 +static void gicv5_common_class_init(ObjectClass *oc, const void *data)
27 +{
28 + ResettableClass *rc = RESETTABLE_CLASS(oc);
29 +
30 + rc->phases.hold = gicv5_common_reset_hold;
31 +}
hw/intc/meson.build
+4
@@ -12,6 +12,10 @@ system_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files(
12 'arm_gicv3_its.c',
13 'arm_gicv3_redist.c',
14 ))
15 +system_ss.add(when: 'CONFIG_ARM_GICV5', if_true: files(
16 + 'arm_gicv5_common.c',
17 + 'arm_gicv5.c',
18 +))
19 system_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c'))
20 system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_vic.c'))
21 system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_intc.c'))
include/hw/intc/arm_gicv5.h new
+32
@@ -0,0 +1,32 @@
1 +/*
2 + * ARM GICv5 emulation: Interrupt Routing Service (IRS)
3 + *
4 + * Copyright (c) 2025 Linaro Limited
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +
9 +#ifndef HW_INTC_ARM_GICV5_H
10 +#define HW_INTC_ARM_GICV5_H
11 +
12 +#include "qom/object.h"
13 +#include "hw/core/sysbus.h"
14 +#include "hw/intc/arm_gicv5_common.h"
15 +
16 +#define TYPE_ARM_GICV5 "arm-gicv5"
17 +
18 +OBJECT_DECLARE_TYPE(GICv5, GICv5Class, ARM_GICV5)
19 +
20 +/*
21 + * This class is for TCG-specific state for the GICv5.
22 + */
23 +struct GICv5 {
24 + GICv5Common parent_obj;
25 +};
26 +
27 +struct GICv5Class {
28 + GICv5CommonClass parent_class;
29 + ResettablePhases parent_phases;
30 +};
31 +
32 +#endif
include/hw/intc/arm_gicv5_common.h new
+31
@@ -0,0 +1,31 @@
1 +/*
2 + * Common base class for GICv5 IRS
3 + *
4 + * Copyright (c) 2025 Linaro Limited
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +
9 +#ifndef HW_INTC_ARM_GICV5_COMMON_H
10 +#define HW_INTC_ARM_GICV5_COMMON_H
11 +
12 +#include "qom/object.h"
13 +#include "hw/core/sysbus.h"
14 +
15 +#define TYPE_ARM_GICV5_COMMON "arm-gicv5-common"
16 +
17 +OBJECT_DECLARE_TYPE(GICv5Common, GICv5CommonClass, ARM_GICV5_COMMON)
18 +
19 +/*
20 + * This class is for common state that will eventually be shared
21 + * between TCG and KVM implementations of the GICv5.
22 + */
23 +struct GICv5Common {
24 + SysBusDevice parent_obj;
25 +};
26 +
27 +struct GICv5CommonClass {
28 + SysBusDeviceClass parent_class;
29 +};
30 +
31 +#endif