lib: arm/arm64: gicv3: Add missing barrier when sending IPIs
One common usage for IPIs is for one CPU to write to a shared memory
location, send the IPI to kick another CPU, and the receiver to read from
the same location. Proper synchronization is needed to make sure that the
IPI receiver reads the most recent value and not stale data (for example,
the write from the sender CPU might still be in a store buffer).
For GICv3, IPIs are generated with a write to the ICC_SGI1R_EL1 register.
To make sure the memory stores are observable by other CPUs, we need a
wmb() barrier (DSB ST), which waits for stores to complete.
From the definition of DSB from ARM DDI 0487F.b, page B2-139:
"In addition, no instruction that appears in program order after the DSB
instruction can alter any state of the system or perform any part of its
functionality until the DSB completes other than:
- Being fetched from memory and decoded.
- Reading the general-purpose, SIMD and floating-point, Special-purpose, or
System registers that are directly or indirectly read without causing
side-effects."
Similar definition for armv7 (ARM DDI 0406C.d, page A3-150).
The DSB instruction is enough to prevent reordering of the GIC register
write which comes in program order after the memory access.
This also matches what the Linux GICv3 irqchip driver does (commit
21ec30c0ef52 ("irqchip/gic-v3: Use wmb() instead of smb_wmb() in
gic_raise_softirq()")).
Reviewed-by:
Eric Auger <eric.auger@redhat.com>
Loading
Please register or sign in to comment