Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / arch / powerpc / include / asm / mmu_context.h
index 44fdf4786638b1fe2f21b8c15927eea8c19ee47f..e2a2b8400490049143edee40316313a906ca6db7 100644 (file)
@@ -78,6 +78,52 @@ extern void switch_cop(struct mm_struct *next);
 extern int use_cop(unsigned long acop, struct mm_struct *mm);
 extern void drop_cop(unsigned long acop, struct mm_struct *mm);
 
+#ifdef CONFIG_PPC_BOOK3S_64
+static inline void inc_mm_active_cpus(struct mm_struct *mm)
+{
+       atomic_inc(&mm->context.active_cpus);
+}
+
+static inline void dec_mm_active_cpus(struct mm_struct *mm)
+{
+       atomic_dec(&mm->context.active_cpus);
+}
+
+static inline void mm_context_add_copro(struct mm_struct *mm)
+{
+       /*
+        * On hash, should only be called once over the lifetime of
+        * the context, as we can't decrement the active cpus count
+        * and flush properly for the time being.
+        */
+       inc_mm_active_cpus(mm);
+}
+
+static inline void mm_context_remove_copro(struct mm_struct *mm)
+{
+       /*
+        * Need to broadcast a global flush of the full mm before
+        * decrementing active_cpus count, as the next TLBI may be
+        * local and the nMMU and/or PSL need to be cleaned up.
+        * Should be rare enough so that it's acceptable.
+        *
+        * Skip on hash, as we don't know how to do the proper flush
+        * for the time being. Invalidations will remain global if
+        * used on hash.
+        */
+       if (radix_enabled()) {
+               flush_all_mm(mm);
+               dec_mm_active_cpus(mm);
+       }
+}
+#else
+static inline void inc_mm_active_cpus(struct mm_struct *mm) { }
+static inline void dec_mm_active_cpus(struct mm_struct *mm) { }
+static inline void mm_context_add_copro(struct mm_struct *mm) { }
+static inline void mm_context_remove_copro(struct mm_struct *mm) { }
+#endif
+
+
 extern void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
                               struct task_struct *tsk);
 
@@ -120,9 +166,13 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm,
        return 0;
 }
 
+#ifndef CONFIG_PPC_BOOK3S_64
 static inline void arch_exit_mmap(struct mm_struct *mm)
 {
 }
+#else
+extern void arch_exit_mmap(struct mm_struct *mm);
+#endif
 
 static inline void arch_unmap(struct mm_struct *mm,
                              struct vm_area_struct *vma,