arm: gic-v3-its: Fix LPI pending table size calculation
PATCH 1/1 arm: gic-v3-its: Fix LPI pending table size calculation
From: Lyrix liu <[email protected]>
The variable pend_tab_total_sz is calculated using the macro LPI_PENDBASE_SZ, which depends on the global variable lpi_id_bits.
However, lpi_id_bits is initialized later in the function based on the GICD_TYPER register. This results in pend_tab_total_sz being calculated with an uninitialized lpi_id_bits value (0), This leads to the LPI pending tables being mapped with an incorrect size.
--- arch/arm/lib/gic-v3-its.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/lib/gic-v3-its.c +2 -1
@@ -81,7 +81,7 @@ int gic_lpi_tables_init(u64 base, u32 num_redist)int i;u64 redist_lpi_base;u64 pend_base; -ulong pend_tab_total_sz = num_redist *LPI_PENDBASE_SZ ; +ulong pend_tab_total_sz;void *pend_tab_va;if (gic_v3_its_get_gic_addr (&priv))
@@ -133,6 +133,7 @@ int gic_lpi_tables_init(u64 base, u32 num_redist) } redist_lpi_base = base +LPI_PROPBASE_SZ ; + pend_tab_total_sz = num_redist *LPI_PENDBASE_SZ ; pend_tab_va =map_physmem (redist_lpi_base, pend_tab_total_sz,MAP_NOCACHE );memset (pend_tab_va,0 , pend_tab_total_sz);
Signature · 1 line
2.37.1
Hi Ye Li,
Quoted 11 lines · Ye Li
From: Lyrix liu <[email protected]>
The variable
pend_tab_total_szis calculated using the macroLPI_PENDBASE_SZ, which depends on the global variablelpi_id_bits.However,
lpi_id_bitsis initialized later in the function based on theGICD_TYPERregister. This results inpend_tab_total_szbeing calculated with an uninitializedlpi_id_bitsvalue (0), This leads to the LPI pending tables being mapped with an incorrect size.Fixes 60b9b47d295b ("Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"")
I came to the same conclusion and this matches what was implemented in commit 6f6876a0c030 ("arm64: gic-v3-its: Clear the Pending table before enabling LPIs") before the commit you point at. From a "mechanical" point of view, which is the only thing I can do as I know nothing about GIC :), this makes sense so:
Cheers,
Quentin