[ARM] 4497/1: Only allow safe cache configurations on ARMv6 and later

Currently, Linux doesn't generate correct page tables for ARMv6 and
later cores if the cache policy is different from the default one (it
may lead to strongly ordered or shared device mappings). This patch
disallows cache policies other than writeback and the
CPU_[ID]CACHE_DISABLE options only affect the CP15 system control
register rather than the page tables.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Catalin Marinas and committed by Russell King 11179d8c 2eb8c82b

+11 -5
+1 -1
arch/arm/mm/Kconfig
··· 599 599 600 600 config CPU_DCACHE_WRITETHROUGH 601 601 bool "Force write through D-cache" 602 - depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020 || CPU_V6) && !CPU_DCACHE_DISABLE 602 + depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020) && !CPU_DCACHE_DISABLE 603 603 default y if CPU_ARM925T 604 604 help 605 605 Say Y here to use the data cache in writethrough mode. Unless you
+10 -4
arch/arm/mm/mmu.c
··· 114 114 } 115 115 if (i == ARRAY_SIZE(cache_policies)) 116 116 printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n"); 117 + if (cpu_architecture() >= CPU_ARCH_ARMv6) { 118 + printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n"); 119 + cachepolicy = CPOLICY_WRITEBACK; 120 + } 117 121 flush_cache_all(); 118 122 set_cr(cr_alignment); 119 123 } ··· 256 252 int cpu_arch = cpu_architecture(); 257 253 int i; 258 254 255 + if (cpu_arch < CPU_ARCH_ARMv6) { 259 256 #if defined(CONFIG_CPU_DCACHE_DISABLE) 260 - if (cachepolicy > CPOLICY_BUFFERED) 261 - cachepolicy = CPOLICY_BUFFERED; 257 + if (cachepolicy > CPOLICY_BUFFERED) 258 + cachepolicy = CPOLICY_BUFFERED; 262 259 #elif defined(CONFIG_CPU_DCACHE_WRITETHROUGH) 263 - if (cachepolicy > CPOLICY_WRITETHROUGH) 264 - cachepolicy = CPOLICY_WRITETHROUGH; 260 + if (cachepolicy > CPOLICY_WRITETHROUGH) 261 + cachepolicy = CPOLICY_WRITETHROUGH; 265 262 #endif 263 + } 266 264 if (cpu_arch < CPU_ARCH_ARMv5) { 267 265 if (cachepolicy >= CPOLICY_WRITEALLOC) 268 266 cachepolicy = CPOLICY_WRITEBACK;