Skip to content

Commit d1cb143

Browse files
gclementKAGA-KOKO
authored andcommitted
irqchip/mips-gic: Prevent indirect access to clusters without CPU cores
It is possible to have zero CPU cores in a cluster; in such cases, it is not possible to access the GIC, and any indirect access leads to an exception. Prevent access to such clusters by checking the number of cores in the cluster at all places which issue indirect cluster access. Signed-off-by: Gregory CLEMENT <[email protected]> Signed-off-by: Aleksandar Rikalo <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 322a906 commit d1cb143

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/irqchip/irq-mips-gic.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ static bool gic_irq_lock_cluster(struct irq_data *d)
141141
cl = cpu_cluster(&cpu_data[cpu]);
142142
if (cl == cpu_cluster(&current_cpu_data))
143143
return false;
144-
144+
if (mips_cps_numcores(cl) == 0)
145+
return false;
145146
mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
146147
return true;
147148
}
@@ -507,6 +508,9 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d)
507508
struct gic_all_vpes_chip_data *cd;
508509
int intr, cpu;
509510

511+
if (!mips_cps_multicluster_cpus())
512+
return;
513+
510514
intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
511515
cd = irq_data_get_irq_chip_data(d);
512516
cd->mask = false;
@@ -520,6 +524,9 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
520524
struct gic_all_vpes_chip_data *cd;
521525
int intr, cpu;
522526

527+
if (!mips_cps_multicluster_cpus())
528+
return;
529+
523530
intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
524531
cd = irq_data_get_irq_chip_data(d);
525532
cd->mask = true;
@@ -687,8 +694,10 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
687694
if (!gic_local_irq_is_routable(intr))
688695
return -EPERM;
689696

690-
for_each_online_cpu_gic(cpu, &gic_lock)
691-
write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
697+
if (mips_cps_multicluster_cpus()) {
698+
for_each_online_cpu_gic(cpu, &gic_lock)
699+
write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
700+
}
692701

693702
return 0;
694703
}
@@ -982,14 +991,17 @@ static int __init gic_of_init(struct device_node *node,
982991
change_gic_trig(i, GIC_TRIG_LEVEL);
983992
write_gic_rmask(i);
984993
}
985-
} else {
994+
} else if (mips_cps_numcores(cl) != 0) {
986995
mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
987996
for (i = 0; i < gic_shared_intrs; i++) {
988997
change_gic_redir_pol(i, GIC_POL_ACTIVE_HIGH);
989998
change_gic_redir_trig(i, GIC_TRIG_LEVEL);
990999
write_gic_redir_rmask(i);
9911000
}
9921001
mips_cm_unlock_other();
1002+
1003+
} else {
1004+
pr_warn("No CPU cores on the cluster %d skip it\n", cl);
9931005
}
9941006
}
9951007

0 commit comments

Comments
 (0)