powerpc/nohash: Refactor update of BDI2000 pointers in switch_mmu_context()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 3 Jun 2021 09:29:02 +0000 (09:29 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Jun 2021 14:09:09 +0000 (00:09 +1000)
Instead of duplicating the update of BDI2000 pointers in
set_context(), do it directly from switch_mmu_context().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/4c54997edd3548fa54717915e7c6ebaf60f208c0.1622712515.git.christophe.leroy@csgroup.eu
arch/powerpc/kernel/head_40x.S
arch/powerpc/kernel/head_44x.S
arch/powerpc/kernel/head_8xx.S
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/mm/nohash/8xx.c
arch/powerpc/mm/nohash/mmu_context.c
arch/powerpc/mm/nohash/tlb_low.S

index e1360b8..7ef1bbc 100644 (file)
@@ -703,14 +703,6 @@ _GLOBAL(abort)
         mtspr   SPRN_DBCR0,r13
 
 _GLOBAL(set_context)
-
-#ifdef CONFIG_BDI_SWITCH
-       /* Context switch the PTE pointer for the Abatron BDI2000.
-        * The PGDIR is the second parameter.
-        */
-       lis     r5, abatron_pteptrs@ha
-       stw     r4, abatron_pteptrs@l + 0x4(r5)
-#endif
        sync
        mtspr   SPRN_PID,r3
        isync                           /* Need an isync to flush shadow */
@@ -731,9 +723,3 @@ EXPORT_SYMBOL(empty_zero_page)
        .globl  swapper_pg_dir
 swapper_pg_dir:
        .space  PGD_TABLE_SIZE
-
-/* Room for two PTE pointers, usually the kernel and current user pointers
- * to their respective root page table.
- */
-abatron_pteptrs:
-       .space  8
index 2cfb496..76c84ac 100644 (file)
@@ -789,15 +789,6 @@ _GLOBAL(__fixup_440A_mcheck)
        blr
 
 _GLOBAL(set_context)
-
-#ifdef CONFIG_BDI_SWITCH
-       /* Context switch the PTE pointer for the Abatron BDI2000.
-        * The PGDIR is the second parameter.
-        */
-       lis     r5, abatron_pteptrs@h
-       ori     r5, r5, abatron_pteptrs@l
-       stw     r4, 0x4(r5)
-#endif
        mtspr   SPRN_PID,r3
        isync                   /* Force context change */
        blr
@@ -1267,13 +1258,6 @@ EXPORT_SYMBOL(empty_zero_page)
 swapper_pg_dir:
        .space  PGD_TABLE_SIZE
 
-/*
- * Room for two PTE pointers, usually the kernel and current user pointers
- * to their respective root page table.
- */
-abatron_pteptrs:
-       .space  8
-
 #ifdef CONFIG_SMP
        .align  12
 temp_boot_stack:
index 7d445e4..817df9f 100644 (file)
@@ -804,10 +804,3 @@ EXPORT_SYMBOL(empty_zero_page)
        .globl  swapper_pg_dir
 swapper_pg_dir:
        .space  PGD_TABLE_SIZE
-
-/* Room for two PTE table pointers, usually the kernel and current user
- * pointer to their respective root page table (pgdir).
- */
-       .globl  abatron_pteptrs
-abatron_pteptrs:
-       .space  8
index a1a5c3f..590f34c 100644 (file)
@@ -986,15 +986,6 @@ _GLOBAL(abort)
        isync
 
 _GLOBAL(set_context)
-
-#ifdef CONFIG_BDI_SWITCH
-       /* Context switch the PTE pointer for the Abatron BDI2000.
-        * The PGDIR is the second parameter.
-        */
-       lis     r5, abatron_pteptrs@h
-       ori     r5, r5, abatron_pteptrs@l
-       stw     r4, 0x4(r5)
-#endif
        mtspr   SPRN_PID,r3
        isync                   /* Force context change */
        blr
@@ -1242,10 +1233,3 @@ EXPORT_SYMBOL(empty_zero_page)
        .globl  swapper_pg_dir
 swapper_pg_dir:
        .space  PGD_TABLE_SIZE
-
-/*
- * Room for two PTE pointers, usually the kernel and current user pointers
- * to their respective root page table.
- */
-abatron_pteptrs:
-       .space  8
index fc66332..4dd02bb 100644 (file)
@@ -224,12 +224,6 @@ void set_context(unsigned long id, pgd_t *pgd)
 {
        s16 offset = (s16)(__pa(swapper_pg_dir));
 
-       /* Context switch the PTE pointer for the Abatron BDI2000.
-        * The PGDIR is passed as second argument.
-        */
-       if (IS_ENABLED(CONFIG_BDI_SWITCH))
-               abatron_pteptrs[1] = pgd;
-
        /* Register M_TWB will contain base address of level 1 table minus the
         * lower part of the kernel PGDIR base address, so that all accesses to
         * level 1 table are done relative to lower part of kernel PGDIR base
index aac81c9..eae4863 100644 (file)
 
 #include <mm/mmu_decl.h>
 
+/*
+ * Room for two PTE table pointers, usually the kernel and current user
+ * pointer to their respective root page table (pgdir).
+ */
+void *abatron_pteptrs[2];
+
 /*
  * The MPC8xx has only 16 contexts. We rotate through them on each task switch.
  * A better way would be to keep track of tasks that own contexts, and implement
@@ -357,6 +363,8 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next,
 
        /* Flick the MMU and release lock */
        pr_hardcont(" -> %d\n", id);
+       if (IS_ENABLED(CONFIG_BDI_SWITCH))
+               abatron_pteptrs[1] = next->pgd;
        set_context(id, next->pgd);
        raw_spin_unlock(&context_lock);
 }
index 68797e0..b3d0f01 100644 (file)
@@ -362,14 +362,6 @@ _GLOBAL(_tlbivax_bcast)
        blr
 
 _GLOBAL(set_context)
-#ifdef CONFIG_BDI_SWITCH
-       /* Context switch the PTE pointer for the Abatron BDI2000.
-        * The PGDIR is the second parameter.
-        */
-       lis     r5, abatron_pteptrs@h
-       ori     r5, r5, abatron_pteptrs@l
-       stw     r4, 0x4(r5)
-#endif
        mtspr   SPRN_PID,r3
        isync                   /* Force context change */
        blr