powerpc/kernel: Fix L1D_SIZE to a non-zero value on missing cache nodes
PATCH 1/1 powerpc/kernel: Fix L1D_SIZE to a non-zero value on missing cache nodes
parse_cache_info() parse device tree to detect various [i/d] cache properties. But if no cache nodes found in device tree, these properties are set to zero as default in init_cache_info().
Having a zero value could cause a infinite loop in rfi_flush_callback() since l1d_size is used to determine the lid_flush_set parameter which is used as the upper bounce in L1D cache flush loop. So default the l1d_size to 64K if it is zero.
Fixes aa8a5e0062ac9 ('powerpc/64s: Add support for RFI flush of L1-D cache')
Signed-off-by Madhavan Srinivasan <[email protected]>
--- arch/powerpc/include/asm/setup.h | 2 ++ arch/powerpc/kernel/setup_64.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
arch/powerpc/include/asm/setup.h +2 -0
@@ -41,6 +41,8 @@ static inline void pseries_little_endian_exceptions(void) {}void rfi_flush_enable (bool enable); +#define DEFAULT_L1D_SIZE (1024 * 64) +/* These are bit flags */ enum l1d_flush_type {L1D_FLUSH_NONE =0x1 ,
arch/powerpc/kernel/setup_64.c +16 -0
@@ -856,6 +856,22 @@ static void init_fallback_flush(void)int cpu; l1d_size = ppc64_caches.l1d.size; + +/* +* If there is no cache node in cpus/ device tree, +* l1d_size could be zero. This in turn make l1d_flush_sets as +* zero, which will be an issue in RFI_FLUSH_CALLBACK. +* +* RFI_FLUSH_CALLBACK use the l1d_flush_sets value as upper bounce +* (loaded in CTR) and loop with a `bdnz` instruction. If the CTR +* happen to zero, instruction (as per definition) will decrement +* CTR first and then compare. So we end up in a really big +* loop (becos of negative value in CTR). Avoid this by defaulting +* to a sane value (64kb). +*/ +if (!l1d_size) + l1d_size =DEFAULT_L1D_SIZE ; + limit =min (safe_stack_limit (), ppc64_rma_size);/*
Signature · 1 line
2.7.4