powerpc: Add function to copy mm_context_t to the paca
authorMichael Neuling <mikey@neuling.org>
Wed, 28 Oct 2015 04:54:06 +0000 (15:54 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 19 Dec 2015 11:13:12 +0000 (22:13 +1100)
This adds a function to copy the mm->context to the paca.  This is
only a basic conversion for now but will be used more extensively in
the next patch.

This also adds #ifdef CONFIG_PPC_BOOK3S around this code since it's
not used elsewhere.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/paca.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/mm/hash_utils_64.c
arch/powerpc/mm/slb.c
arch/powerpc/mm/slice.c

index 70bd4381f8e6ac19115dc37d17a66766811b5fcf..1cc6e08289076997e522a1d75cf260bffdaa362d 100644 (file)
@@ -131,7 +131,9 @@ struct paca_struct {
        struct tlb_core_data tcd;
 #endif /* CONFIG_PPC_BOOK3E */
 
+#ifdef CONFIG_PPC_BOOK3S
        mm_context_t context;
+#endif
 
        /*
         * then miscellaneous read-write fields
@@ -194,6 +196,15 @@ struct paca_struct {
 #endif
 };
 
+#ifdef CONFIG_PPC_BOOK3S
+static inline void copy_mm_to_paca(mm_context_t *context)
+{
+       get_paca()->context = *context;
+}
+#else
+static inline void copy_mm_to_paca(mm_context_t *context){}
+#endif
+
 extern struct paca_struct *paca;
 extern void initialise_paca(struct paca_struct *new_paca, int cpu);
 extern void setup_paca(struct paca_struct *new_paca);
index 221d584d089f9418abfa1087cffd9d0b0117c090..9db7be292bf367c240b278785a4aabf4df8cf3ee 100644 (file)
@@ -185,6 +185,7 @@ int main(void)
        DEFINE(PACAKMSR, offsetof(struct paca_struct, kernel_msr));
        DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled));
        DEFINE(PACAIRQHAPPENED, offsetof(struct paca_struct, irq_happened));
+#ifdef CONFIG_PPC_BOOK3S
        DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id));
 #ifdef CONFIG_PPC_MM_SLICES
        DEFINE(PACALOWSLICESPSIZE, offsetof(struct paca_struct,
@@ -193,6 +194,7 @@ int main(void)
                                            context.high_slices_psize));
        DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def));
 #endif /* CONFIG_PPC_MM_SLICES */
+#endif
 
 #ifdef CONFIG_PPC_BOOK3E
        DEFINE(PACAPGD, offsetof(struct paca_struct, pgd));
index 4233dcccbaf7728d6afe86c0d250bd1b1e88a952..03279eac09571b944a5265f4d06778d1826ecd89 100644 (file)
@@ -882,7 +882,8 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)
        slice_set_range_psize(mm, addr, 1, MMU_PAGE_4K);
        copro_flush_all_slbs(mm);
        if ((get_paca_psize(addr) != MMU_PAGE_4K) && (current->mm == mm)) {
-               get_paca()->context = mm->context;
+
+               copy_mm_to_paca(&mm->context);
                slb_flush_and_rebolt();
        }
 }
@@ -949,7 +950,7 @@ static void check_paca_psize(unsigned long ea, struct mm_struct *mm,
 {
        if (user_region) {
                if (psize != get_paca_psize(ea)) {
-                       get_paca()->context = mm->context;
+                       copy_mm_to_paca(&mm->context);
                        slb_flush_and_rebolt();
                }
        } else if (get_paca()->vmalloc_sllp !=
index 515730e499fe663b7dbe2ba00c759e06e916d59d..825b6873391f9654f402d1b1a5ede306e5febe60 100644 (file)
@@ -228,7 +228,7 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
                asm volatile("slbie %0" : : "r" (slbie_data));
 
        get_paca()->slb_cache_ptr = 0;
-       get_paca()->context = mm->context;
+       copy_mm_to_paca(&mm->context);
 
        /*
         * preload some userspace segments into the SLB.
index 0f432a702870fa96a9d35b41110e0b6b4e99406e..42954f0b47aced31454d44103180df9202527fb6 100644 (file)
@@ -185,8 +185,7 @@ static void slice_flush_segments(void *parm)
        if (mm != current->active_mm)
                return;
 
-       /* update the paca copy of the context struct */
-       get_paca()->context = current->active_mm->context;
+       copy_mm_to_paca(&current->active_mm->context);
 
        local_irq_save(flags);
        slb_flush_and_rebolt();