OSDN Git Service

powerpc/nohash: Convert set_context() to C
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 3 Jun 2021 09:29:03 +0000 (09:29 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Jun 2021 14:09:09 +0000 (00:09 +1000)
ppc8xx already has set_context() in C.

Other ones have it in assembly. The only thing it does is to
write the context id into SPRN_PID.

Do it in C.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a5d0759064f3831c6b88af49ef5d3b05ba1c4dad.1622712515.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/mmu_context.h
arch/powerpc/kernel/head_40x.S
arch/powerpc/kernel/head_44x.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 4bc45d3..ef6df26 100644 (file)
@@ -57,7 +57,6 @@ static inline bool mm_iommu_is_devmem(struct mm_struct *mm, unsigned long hpa,
 static inline void mm_iommu_init(struct mm_struct *mm) { }
 #endif
 extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
-extern void set_context(unsigned long id, pgd_t *pgd);
 
 #ifdef CONFIG_PPC_BOOK3S_64
 extern void radix__switch_mmu_context(struct mm_struct *prev,
index 7ef1bbc..2717aa8 100644 (file)
@@ -702,13 +702,6 @@ _GLOBAL(abort)
         oris    r13,r13,DBCR0_RST_SYSTEM@h
         mtspr   SPRN_DBCR0,r13
 
-_GLOBAL(set_context)
-       sync
-       mtspr   SPRN_PID,r3
-       isync                           /* Need an isync to flush shadow */
-                                       /* TLBs after changing PID */
-       blr
-
 /* We put a few things here that have to be page-aligned. This stuff
  * goes at the beginning of the data segment, which is page-aligned.
  */
index 76c84ac..2c4ffec 100644 (file)
@@ -788,11 +788,6 @@ _GLOBAL(__fixup_440A_mcheck)
        sync
        blr
 
-_GLOBAL(set_context)
-       mtspr   SPRN_PID,r3
-       isync                   /* Force context change */
-       blr
-
 /*
  * Init CPU state. This is called at boot time or for secondary CPUs
  * to setup initial TLB entries, setup IVORs, etc...
index 590f34c..ab718fd 100644 (file)
@@ -985,11 +985,6 @@ _GLOBAL(abort)
        mtspr   SPRN_DBCR0,r13
        isync
 
-_GLOBAL(set_context)
-       mtspr   SPRN_PID,r3
-       isync                   /* Force context change */
-       blr
-
 #ifdef CONFIG_SMP
 /* When we get here, r24 needs to hold the CPU # */
        .globl __secondary_start
index 4dd02bb..60780e0 100644 (file)
@@ -212,31 +212,6 @@ void __init setup_initial_memory_limit(phys_addr_t first_memblock_base,
        memblock_set_current_limit(min_t(u64, first_memblock_size, SZ_32M));
 }
 
-/*
- * Set up to use a given MMU context.
- * id is context number, pgd is PGD pointer.
- *
- * We place the physical address of the new task page directory loaded
- * into the MMU base register, and set the ASID compare register with
- * the new "context."
- */
-void set_context(unsigned long id, pgd_t *pgd)
-{
-       s16 offset = (s16)(__pa(swapper_pg_dir));
-
-       /* 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
-        * address.
-        */
-       mtspr(SPRN_M_TWB, __pa(pgd) - offset);
-
-       /* Update context */
-       mtspr(SPRN_M_CASID, id - 1);
-       /* sync */
-       mb();
-}
-
 #ifdef CONFIG_PPC_KUEP
 void __init setup_kuep(bool disabled)
 {
index eae4863..0d22bc9 100644 (file)
@@ -264,6 +264,33 @@ static void context_check_map(void)
 static void context_check_map(void) { }
 #endif
 
+static void set_context(unsigned long id, pgd_t *pgd)
+{
+       if (IS_ENABLED(CONFIG_PPC_8xx)) {
+               s16 offset = (s16)(__pa(swapper_pg_dir));
+
+               /*
+                * 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
+                * address.
+                */
+               mtspr(SPRN_M_TWB, __pa(pgd) - offset);
+
+               /* Update context */
+               mtspr(SPRN_M_CASID, id - 1);
+
+               /* sync */
+               mb();
+       } else {
+               if (IS_ENABLED(CONFIG_40x))
+                       mb();   /* sync */
+
+               mtspr(SPRN_PID, id);
+               isync();
+       }
+}
+
 void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next,
                        struct task_struct *tsk)
 {
index b3d0f01..4613bf8 100644 (file)
@@ -360,11 +360,6 @@ _GLOBAL(_tlbivax_bcast)
        sync
        wrtee   r10
        blr
-
-_GLOBAL(set_context)
-       mtspr   SPRN_PID,r3
-       isync                   /* Force context change */
-       blr
 #else
 #error Unsupported processor type !
 #endif