ARM: 7661/1: mm: perform explicit branch predictor maintenance when required
authorWill Deacon <will.deacon@arm.com>
Thu, 28 Feb 2013 16:48:40 +0000 (17:48 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 3 Mar 2013 22:54:16 +0000 (22:54 +0000)
The ARM ARM requires branch predictor maintenance if, for a given ASID,
the instructions at a specific virtual address appear to change.

From the kernel's point of view, that means:

- Changing the kernel's view of memory (e.g. switching to the
  identity map)
- ASID rollover (since ASIDs will be re-allocated to new tasks)

This patch adds explicit branch predictor maintenance when either of the
two conditions above are met.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/smp.c
arch/arm/kernel/suspend.c
arch/arm/mm/context.c
arch/arm/mm/idmap.c

index 1bdfd87c8e41d026bcaf9fe1893c2645e6dce6dd..31644f1978d56d8e6fad053804ed8d730bff9003 100644 (file)
@@ -285,6 +285,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
         * switch away from it before attempting any exclusive accesses.
         */
        cpu_switch_mm(mm->pgd, mm);
+       local_flush_bp_all();
        enter_lazy_tlb(mm, current);
        local_flush_tlb_all();
 
index 358bca3a995ed37ec66da93ec40841abd99fa804..c59c97ea8268b461b45b8d46066b2f4208f9afe5 100644 (file)
@@ -68,6 +68,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
        ret = __cpu_suspend(arg, fn);
        if (ret == 0) {
                cpu_switch_mm(mm->pgd, mm);
+               local_flush_bp_all();
                local_flush_tlb_all();
        }
 
index 44d4ee52f3e209beb134c6de9be256925fd29309..a5a4b2bc42ba353e7e0ae94461cf4d8691b2b68a 100644 (file)
@@ -212,8 +212,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
                atomic64_set(&mm->context.id, asid);
        }
 
-       if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
+       if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
+               local_flush_bp_all();
                local_flush_tlb_all();
+       }
 
        atomic64_set(&per_cpu(active_asids, cpu), asid);
        cpumask_set_cpu(cpu, mm_cpumask(mm));
index 2dffc010cc41b930f28a07f1dfb2b88045fc3049..5ee505c937d171902839369f3cd98c13b93b11ca 100644 (file)
@@ -141,6 +141,7 @@ void setup_mm_for_reboot(void)
 {
        /* Switch to the identity mapping. */
        cpu_switch_mm(idmap_pgd, &init_mm);
+       local_flush_bp_all();
 
 #ifdef CONFIG_CPU_HAS_ASID
        /*