]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: selftests: gic_v3: Add irq group setting helper
authorMarc Zyngier <maz@kernel.org>
Thu, 20 Nov 2025 17:25:30 +0000 (17:25 +0000)
committerOliver Upton <oupton@kernel.org>
Mon, 24 Nov 2025 22:29:14 +0000 (14:29 -0800)
Being able to set the group of an interrupt is pretty useful.
Add such a helper.

Tested-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Tested-by: Mark Brown <broonie@kernel.org>
Link: https://msgid.link/20251120172540.2267180-41-maz@kernel.org
Signed-off-by: Oliver Upton <oupton@kernel.org>
tools/testing/selftests/kvm/include/arm64/gic.h
tools/testing/selftests/kvm/lib/arm64/gic.c
tools/testing/selftests/kvm/lib/arm64/gic_private.h
tools/testing/selftests/kvm/lib/arm64/gic_v3.c

index baeb3c859389ddbd2c473d6cffc45a7b8edbced4..cc7a7f34ed37721b3e57c8d00a9090d912c64149 100644 (file)
@@ -57,6 +57,7 @@ void gic_irq_set_pending(unsigned int intid);
 void gic_irq_clear_pending(unsigned int intid);
 bool gic_irq_get_pending(unsigned int intid);
 void gic_irq_set_config(unsigned int intid, bool is_edge);
+void gic_irq_set_group(unsigned int intid, bool group);
 
 void gic_rdist_enable_lpis(vm_paddr_t cfg_table, size_t cfg_table_size,
                           vm_paddr_t pend_table);
index 7abbf8866512a1c8f327df727cc37f6d35ac38a7..b023868fe0b8201bc74d887ff3f78eb3585a50a2 100644 (file)
@@ -155,3 +155,9 @@ void gic_irq_set_config(unsigned int intid, bool is_edge)
        GUEST_ASSERT(gic_common_ops);
        gic_common_ops->gic_irq_set_config(intid, is_edge);
 }
+
+void gic_irq_set_group(unsigned int intid, bool group)
+{
+       GUEST_ASSERT(gic_common_ops);
+       gic_common_ops->gic_irq_set_group(intid, group);
+}
index d24e9ecc96c6d83a35ba461b9ca8686ddb11c6d9..b6a7e30c3eb1ff061a4715708af853827c335631 100644 (file)
@@ -25,6 +25,7 @@ struct gic_common_ops {
        void (*gic_irq_clear_pending)(uint32_t intid);
        bool (*gic_irq_get_pending)(uint32_t intid);
        void (*gic_irq_set_config)(uint32_t intid, bool is_edge);
+       void (*gic_irq_set_group)(uint32_t intid, bool group);
 };
 
 extern const struct gic_common_ops gicv3_ops;
index 66d05506f78b13b23cbf3970e2b910d8becf7cd4..3e4e1a6a4f7c32ff3bf30415956c955b3cf8cc25 100644 (file)
@@ -293,6 +293,20 @@ static void gicv3_enable_redist(volatile void *redist_base)
        }
 }
 
+static void gicv3_set_group(uint32_t intid, bool grp)
+{
+       uint32_t cpu_or_dist;
+       uint32_t val;
+
+       cpu_or_dist = (get_intid_range(intid) == SPI_RANGE) ? DIST_BIT : guest_get_vcpuid();
+       val = gicv3_reg_readl(cpu_or_dist, GICD_IGROUPR + (intid / 32) * 4);
+       if (grp)
+               val |= BIT(intid % 32);
+       else
+               val &= ~BIT(intid % 32);
+       gicv3_reg_writel(cpu_or_dist, GICD_IGROUPR + (intid / 32) * 4, val);
+}
+
 static void gicv3_cpu_init(unsigned int cpu)
 {
        volatile void *sgi_base;
@@ -400,6 +414,7 @@ const struct gic_common_ops gicv3_ops = {
        .gic_irq_clear_pending = gicv3_irq_clear_pending,
        .gic_irq_get_pending = gicv3_irq_get_pending,
        .gic_irq_set_config = gicv3_irq_set_config,
+       .gic_irq_set_group = gicv3_set_group,
 };
 
 void gic_rdist_enable_lpis(vm_paddr_t cfg_table, size_t cfg_table_size,