parisc: Check for valid stride size for cache flushes
authorHelge Deller <deller@gmx.de>
Wed, 17 Jan 2024 16:46:43 +0000 (17:46 +0100)
committerHelge Deller <deller@gmx.de>
Sun, 28 Jan 2024 08:49:46 +0000 (09:49 +0100)
Report if the calculated cache stride size is zero, otherwise the cache
flushing routine will never finish and hang the machine.
This can be reproduced with a testcase in qemu, where the firmware reports
wrong cache values.

Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/kernel/cache.c

index 268d90a9325b468603b634b86b48980a31b4fba7..0c015487e5db6d419994de9b59b2586b46ed7a97 100644 (file)
@@ -264,6 +264,10 @@ parisc_cache_init(void)
        icache_stride = CAFL_STRIDE(cache_info.ic_conf);
 #undef CAFL_STRIDE
 
+       /* stride needs to be non-zero, otherwise cache flushes will not work */
+       WARN_ON(cache_info.dc_size && dcache_stride == 0);
+       WARN_ON(cache_info.ic_size && icache_stride == 0);
+
        if ((boot_cpu_data.pdc.capabilities & PDC_MODEL_NVA_MASK) ==
                                                PDC_MODEL_NVA_UNSUPPORTED) {
                printk(KERN_WARNING "parisc_cache_init: Only equivalent aliasing supported!\n");