Skip to contentSkip to conversation

irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn

PATCH In review Li Dou 2 participants 4 messages Aug 24 – Aug 25

Subsystems (2)
lore
Share & tools
lore

Li Dou

author
#0 lore raw

PATCH 1/1 irqchip/gic-v3: Remove the ISB between AP0Rn and AP1Rn

ARM GICv3 specification says(in section 4.8.4 "System register access to the Active Priorities registers"):

	an ISB is not required between each write to ICC_AP0R<n>_EL1,
	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.

It means we can use one ISB after resetting AP0Rn and AP1Rn for context synchronization. So just remove the previous one.

---
 drivers/irqchip/irq-gic-v3.c | 2 --
 1 file changed, 2 deletions(-)
drivers/irqchip/irq-gic-v3.c +0 -2
index 6e1fa5b247fc..3c48f46abb25 100644
@@ -1205,8 +1205,6 @@ static void gic_cpu_sys_reg_init(void)
 		case 4:
 			write_gicreg(0, ICC_AP0R0_EL1);
 		}
-
-		isb();
 	}
 
 	switch(pribits) {
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 9 lines · Li Dou

ARM GICv3 specification says(in section 4.8.4 "System register access to the Active Priorities registers"):

	an ISB is not required between each write to ICC_AP0R<n>_EL1,
	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.

It means we can use one ISB after resetting AP0Rn and AP1Rn for context synchronization. So just remove the previous one.

I'm afraid you have misinterpreted the spec.

Within each of the AP0Rn, Secure AP1Rn and Non-Secure AP1Rn classes, for any value of 'n', there is no need for any synchronisation.

However, between classes, you absolutely need an ISB. And this is the reason why, just above the note you quote:

<quote>
Writes to these registers in any order other than the following can result in UNPREDICTABLE behavior:

1. ICC_AP0R<n>_EL1.
2. Secure ICC_AP1R<n>_EL1.
3. Non-secure ICC_AP1R<n>_EL1.
</quote>

While you can perfectly write each individual register of (1), (2) or
(3) without any synchronisation, you absolutely must have a CSE *between* each of (1), (2) and (3). Linux being non-secure only, you only deal with (1) and (3), and you must have an ISB in between. Without it, reordering can happen and you end-up violating the above rule.

To conclude, this patch does not optimise anything. Not only this is something that only happens once per CPU boot (aka *never*), it instead introduces a very subtle ordering bug.

It therefore must not be applied.

	M.
Signature · 1 line
Jazz isn't dead. It just smells funny.
author
#2 lore raw

Hi Marc,

Quoted 29 lines · Marc Zyngier
Quoted 9 lines · Li Dou

ARM GICv3 specification says(in section 4.8.4 "System register access to the Active Priorities registers"):

	an ISB is not required between each write to ICC_AP0R<n>_EL1,
	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.

It means we can use one ISB after resetting AP0Rn and AP1Rn for context synchronization. So just remove the previous one.

I'm afraid you have misinterpreted the spec.

Within each of the AP0Rn, Secure AP1Rn and Non-Secure AP1Rn classes, for any value of 'n', there is no need for any synchronisation.

However, between classes, you absolutely need an ISB. And this is the reason why, just above the note you quote:

<quote>
Writes to these registers in any order other than the following can result in UNPREDICTABLE behavior:

1. ICC_AP0R<n>_EL1.
2. Secure ICC_AP1R<n>_EL1.
3. Non-secure ICC_AP1R<n>_EL1.
</quote>

Quoted 6 lines

While you can perfectly write each individual register of (1), (2) or
(3) without any synchronisation, you absolutely must have a CSE *between* each of (1), (2) and (3). Linux being non-secure only, you only deal with (1) and (3), and you must have an ISB in between. Without it, reordering can happen and you end-up violating the above rule.

The spec sometimes is overly convoluted. Thanks for the clarification.

Best regards,
Li

maintainer
#3 lore raw
Quoted 33 lines · Li Dou

Hi Marc,

Quoted 29 lines · Marc Zyngier
Quoted 9 lines · Li Dou

ARM GICv3 specification says(in section 4.8.4 "System register access to the Active Priorities registers"):

	an ISB is not required between each write to ICC_AP0R<n>_EL1,
	Secure ICC_AP1R<n>_EL1, and Non-secure ICC_AP1R<n>_EL1.

It means we can use one ISB after resetting AP0Rn and AP1Rn for context synchronization. So just remove the previous one.

I'm afraid you have misinterpreted the spec.

Within each of the AP0Rn, Secure AP1Rn and Non-Secure AP1Rn classes, for any value of 'n', there is no need for any synchronisation.

However, between classes, you absolutely need an ISB. And this is the reason why, just above the note you quote:

<quote>
Writes to these registers in any order other than the following can result in UNPREDICTABLE behavior:

1. ICC_AP0R<n>_EL1.
2. Secure ICC_AP1R<n>_EL1.
3. Non-secure ICC_AP1R<n>_EL1.
</quote>

Quoted 8 lines
Quoted 6 lines

While you can perfectly write each individual register of (1), (2) or
(3) without any synchronisation, you absolutely must have a CSE *between* each of (1), (2) and (3). Linux being non-secure only, you only deal with (1) and (3), and you must have an ISB in between. Without it, reordering can happen and you end-up violating the above rule.

The spec sometimes is overly convoluted. Thanks for the clarification.

The spec is pretty clear in this particular case. It outlines the order by which group of registers must be written to, and therefore there is only one way to interpret the accompanying note.

As for any spec, you need to read the whole thing, and not take a particular statement out of context.

Thanks,

	M.
Signature · 1 line
Jazz isn't dead. It just smells funny.