MIPS: KASLR: Avoid endless loop in sync_icache if synci_step is zero
authorJinyang He <hejinyang@loongson.cn>
Fri, 4 Dec 2020 01:11:46 +0000 (09:11 +0800)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Sat, 5 Dec 2020 10:23:16 +0000 (11:23 +0100)
Most platforms do not need to do synci instruction operations when
synci_step is 0. But for example, the synci implementation on Loongson64
platform has some changes. On the one hand, it ensures that the memory
access instructions have been completed. On the other hand, it guarantees
that all prefetch instructions need to be fetched again. And its address
information is useless. Thus, only one synci operation is required when
synci_step is 0 on Loongson64 platform. I guess that some other platforms
have similar implementations on synci, so add judgment conditions in
`while` to ensure that at least all platforms perform synci operations
once. For those platforms that do not need synci, they just do one more
operation similar to nop.

Signed-off-by: Jinyang He <hejinyang@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/kernel/relocate.c

index 57bdd2761c78e1ddaed47370ed8b989f0008482f..47aeb3350a76029edaf96a03d29d8ce975058232 100644 (file)
@@ -64,7 +64,7 @@ static void __init sync_icache(void *kbase, unsigned long kernel_length)
                        : "r" (kbase));
 
                kbase += step;
-       } while (kbase < kend);
+       } while (step && kbase < kend);
 
        /* Completion barrier */
        __sync();