Skip to content

Commit d6062a6

Browse files
author
Marc Zyngier
committed
irqchip/gic-v3: Reset APgRn registers at boot time
Booting a crash kernel while in an interrupt handler is likely to leave the Active Priority Registers with some state that is not relevant to the new kernel, and is likely to lead to erratic behaviours such as interrupts not firing as their priority is already active. As a sanity measure, wipe the APRs clean on startup. We make sure to wipe both group 0 and 1 registers in order to avoid any surprise. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent c5e1035 commit d6062a6

2 files changed

Lines changed: 54 additions & 10 deletions

File tree

‎arch/arm/include/asm/arch_gicv3.h‎

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
#define ICC_IGRPEN1 __ACCESS_CP15(c12, 0, c12, 7)
3636
#define ICC_BPR1 __ACCESS_CP15(c12, 0, c12, 3)
3737

38+
#define __ICC_AP0Rx(x) __ACCESS_CP15(c12, 0, c8, 4 | x)
39+
#define ICC_AP0R0 __ICC_AP0Rx(0)
40+
#define ICC_AP0R1 __ICC_AP0Rx(1)
41+
#define ICC_AP0R2 __ICC_AP0Rx(2)
42+
#define ICC_AP0R3 __ICC_AP0Rx(3)
43+
44+
#define __ICC_AP1Rx(x) __ACCESS_CP15(c12, 0, c9, x)
45+
#define ICC_AP1R0 __ICC_AP1Rx(0)
46+
#define ICC_AP1R1 __ICC_AP1Rx(1)
47+
#define ICC_AP1R2 __ICC_AP1Rx(2)
48+
#define ICC_AP1R3 __ICC_AP1Rx(3)
49+
3850
#define ICC_HSRE __ACCESS_CP15(c12, 4, c9, 5)
3951

4052
#define ICH_VSEIR __ACCESS_CP15(c12, 4, c9, 4)
@@ -86,17 +98,17 @@
8698
#define ICH_LRC14 __LRC8(6)
8799
#define ICH_LRC15 __LRC8(7)
88100

89-
#define __AP0Rx(x) __ACCESS_CP15(c12, 4, c8, x)
90-
#define ICH_AP0R0 __AP0Rx(0)
91-
#define ICH_AP0R1 __AP0Rx(1)
92-
#define ICH_AP0R2 __AP0Rx(2)
93-
#define ICH_AP0R3 __AP0Rx(3)
101+
#define __ICH_AP0Rx(x) __ACCESS_CP15(c12, 4, c8, x)
102+
#define ICH_AP0R0 __ICH_AP0Rx(0)
103+
#define ICH_AP0R1 __ICH_AP0Rx(1)
104+
#define ICH_AP0R2 __ICH_AP0Rx(2)
105+
#define ICH_AP0R3 __ICH_AP0Rx(3)
94106

95-
#define __AP1Rx(x) __ACCESS_CP15(c12, 4, c9, x)
96-
#define ICH_AP1R0 __AP1Rx(0)
97-
#define ICH_AP1R1 __AP1Rx(1)
98-
#define ICH_AP1R2 __AP1Rx(2)
99-
#define ICH_AP1R3 __AP1Rx(3)
107+
#define __ICH_AP1Rx(x) __ACCESS_CP15(c12, 4, c9, x)
108+
#define ICH_AP1R0 __ICH_AP1Rx(0)
109+
#define ICH_AP1R1 __ICH_AP1Rx(1)
110+
#define ICH_AP1R2 __ICH_AP1Rx(2)
111+
#define ICH_AP1R3 __ICH_AP1Rx(3)
100112

101113
/* A32-to-A64 mappings used by VGIC save/restore */
102114

@@ -125,6 +137,15 @@ static inline u64 read_ ## a64(void) \
125137
return val; \
126138
}
127139

140+
CPUIF_MAP(ICC_AP0R0, ICC_AP0R0_EL1)
141+
CPUIF_MAP(ICC_AP0R1, ICC_AP0R1_EL1)
142+
CPUIF_MAP(ICC_AP0R2, ICC_AP0R2_EL1)
143+
CPUIF_MAP(ICC_AP0R3, ICC_AP0R3_EL1)
144+
CPUIF_MAP(ICC_AP1R0, ICC_AP1R0_EL1)
145+
CPUIF_MAP(ICC_AP1R1, ICC_AP1R1_EL1)
146+
CPUIF_MAP(ICC_AP1R2, ICC_AP1R2_EL1)
147+
CPUIF_MAP(ICC_AP1R3, ICC_AP1R3_EL1)
148+
128149
CPUIF_MAP(ICH_HCR, ICH_HCR_EL2)
129150
CPUIF_MAP(ICH_VTR, ICH_VTR_EL2)
130151
CPUIF_MAP(ICH_MISR, ICH_MISR_EL2)

‎drivers/irqchip/irq-gic-v3.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ static void gic_cpu_sys_reg_init(void)
532532
int i, cpu = smp_processor_id();
533533
u64 mpidr = cpu_logical_map(cpu);
534534
u64 need_rss = MPIDR_RS(mpidr);
535+
u32 val;
535536

536537
/*
537538
* Need to check that the SRE bit has actually been set. If
@@ -562,6 +563,28 @@ static void gic_cpu_sys_reg_init(void)
562563
gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop_dir);
563564
}
564565

566+
val = gic_read_ctlr();
567+
val &= ICC_CTLR_EL1_PRI_BITS_MASK;
568+
val >>= ICC_CTLR_EL1_PRI_BITS_SHIFT;
569+
570+
switch(val + 1) {
571+
case 8:
572+
case 7:
573+
write_gicreg(0, ICC_AP0R3_EL1);
574+
write_gicreg(0, ICC_AP1R3_EL1);
575+
write_gicreg(0, ICC_AP0R2_EL1);
576+
write_gicreg(0, ICC_AP1R2_EL1);
577+
case 6:
578+
write_gicreg(0, ICC_AP0R1_EL1);
579+
write_gicreg(0, ICC_AP1R1_EL1);
580+
case 5:
581+
case 4:
582+
write_gicreg(0, ICC_AP0R0_EL1);
583+
write_gicreg(0, ICC_AP1R0_EL1);
584+
}
585+
586+
isb();
587+
565588
/* ... and let's hit the road... */
566589
gic_write_grpen1(1);
567590

0 commit comments

Comments
 (0)