Skip to content

Commit 0e5c1c9

Browse files
shashi-jpm215
authored andcommitted
hw/arm/virt: add ITS support in virt GIC
Included creation of ITS as part of virt platform GIC initialization. This Emulated ITS model now co-exists with kvm ITS and is enabled in absence of kvm irq kernel support in a platform. Signed-off-by: Shashi Mallela <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
1 parent d7830a9 commit 0e5c1c9

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

hw/arm/virt.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,12 @@ static void create_its(VirtMachineState *vms)
584584
const char *itsclass = its_class_name();
585585
DeviceState *dev;
586586

587+
if (!strcmp(itsclass, "arm-gicv3-its")) {
588+
if (!vms->tcg_its) {
589+
itsclass = NULL;
590+
}
591+
}
592+
587593
if (!itsclass) {
588594
/* Do nothing if not supported */
589595
return;
@@ -621,7 +627,7 @@ static void create_v2m(VirtMachineState *vms)
621627
vms->msi_controller = VIRT_MSI_CTRL_GICV2M;
622628
}
623629

624-
static void create_gic(VirtMachineState *vms)
630+
static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
625631
{
626632
MachineState *ms = MACHINE(vms);
627633
/* We create a standalone GIC */
@@ -655,6 +661,14 @@ static void create_gic(VirtMachineState *vms)
655661
nb_redist_regions);
656662
qdev_prop_set_uint32(vms->gic, "redist-region-count[0]", redist0_count);
657663

664+
if (!kvm_irqchip_in_kernel()) {
665+
if (vms->tcg_its) {
666+
object_property_set_link(OBJECT(vms->gic), "sysmem",
667+
OBJECT(mem), &error_fatal);
668+
qdev_prop_set_bit(vms->gic, "has-lpi", true);
669+
}
670+
}
671+
658672
if (nb_redist_regions == 2) {
659673
uint32_t redist1_capacity =
660674
vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE;
@@ -2039,7 +2053,7 @@ static void machvirt_init(MachineState *machine)
20392053

20402054
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
20412055

2042-
create_gic(vms);
2056+
create_gic(vms, sysmem);
20432057

20442058
virt_cpu_post_init(vms, sysmem);
20452059

@@ -2742,6 +2756,12 @@ static void virt_instance_init(Object *obj)
27422756
} else {
27432757
/* Default allows ITS instantiation */
27442758
vms->its = true;
2759+
2760+
if (vmc->no_tcg_its) {
2761+
vms->tcg_its = false;
2762+
} else {
2763+
vms->tcg_its = true;
2764+
}
27452765
}
27462766

27472767
/* Default disallows iommu instantiation */
@@ -2791,8 +2811,13 @@ DEFINE_VIRT_MACHINE_AS_LATEST(6, 2)
27912811

27922812
static void virt_machine_6_1_options(MachineClass *mc)
27932813
{
2814+
VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
2815+
27942816
virt_machine_6_2_options(mc);
27952817
compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len);
2818+
2819+
/* qemu ITS was introduced with 6.2 */
2820+
vmc->no_tcg_its = true;
27962821
}
27972822
DEFINE_VIRT_MACHINE(6, 1)
27982823

include/hw/arm/virt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ struct VirtMachineClass {
120120
MachineClass parent;
121121
bool disallow_affinity_adjustment;
122122
bool no_its;
123+
bool no_tcg_its;
123124
bool no_pmu;
124125
bool claim_edge_triggered_timers;
125126
bool smbios_old_sys_ver;
@@ -141,6 +142,7 @@ struct VirtMachineState {
141142
bool highmem;
142143
bool highmem_ecam;
143144
bool its;
145+
bool tcg_its;
144146
bool virt;
145147
bool ras;
146148
bool mte;

target/arm/kvm_arm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ static inline const char *its_class_name(void)
525525
/* KVM implementation requires this capability */
526526
return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL;
527527
} else {
528-
/* Software emulation is not implemented yet */
529-
return NULL;
528+
/* Software emulation based model */
529+
return "arm-gicv3-its";
530530
}
531531
}
532532

0 commit comments

Comments
 (0)