]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/mm: move update_mmu_cache() into book3s hash utils.
authorChristophe Leroy <christophe.leroy@c-s.fr>
Fri, 16 Aug 2019 05:41:42 +0000 (05:41 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 20 Aug 2019 11:22:14 +0000 (21:22 +1000)
update_mmu_cache() is only for BOOK3S, and can be simplified for
BOOK3S32.

Move it out of mem.c into respective BOOK3S32 and BOOK3S64 files
containing hash utils.

BOOK3S64 version of hash_preload() is only used locally, declare it
static.

Remove the radix_enabled() stuff in BOOK3S32 version.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/107aaf43583a5f5d09e0d4e84c4c4390ecfcd512.1565933217.git.christophe.leroy@c-s.fr
arch/powerpc/mm/book3s32/mmu.c
arch/powerpc/mm/book3s64/hash_utils.c
arch/powerpc/mm/mem.c
arch/powerpc/mm/mmu_decl.h

index 8d68f03bf5a409138c33a7fabb35b3d38a7ee0ee..1e77dca8b497d747cd2c6ca963d34ed7d9a9bcbb 100644 (file)
@@ -309,6 +309,52 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
                add_hash_page(mm->context.id, ea, pmd_val(*pmd));
 }
 
+/*
+ * This is called at the end of handling a user page fault, when the
+ * fault has been handled by updating a PTE in the linux page tables.
+ * We use it to preload an HPTE into the hash table corresponding to
+ * the updated linux PTE.
+ *
+ * This must always be called with the pte lock held.
+ */
+void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
+                     pte_t *ptep)
+{
+       /*
+        * We don't need to worry about _PAGE_PRESENT here because we are
+        * called with either mm->page_table_lock held or ptl lock held
+        */
+       unsigned long trap;
+       bool is_exec;
+
+       /* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */
+       if (!pte_young(*ptep) || address >= TASK_SIZE)
+               return;
+
+       /*
+        * We try to figure out if we are coming from an instruction
+        * access fault and pass that down to __hash_page so we avoid
+        * double-faulting on execution of fresh text. We have to test
+        * for regs NULL since init will get here first thing at boot.
+        *
+        * We also avoid filling the hash if not coming from a fault.
+        */
+
+       trap = current->thread.regs ? TRAP(current->thread.regs) : 0UL;
+       switch (trap) {
+       case 0x300:
+               is_exec = false;
+               break;
+       case 0x400:
+               is_exec = true;
+               break;
+       default:
+               return;
+       }
+
+       hash_preload(vma->vm_mm, address, is_exec, trap);
+}
+
 /*
  * Initialize the hash table and patch the instructions in hashtable.S.
  */
index c363e850550ef9d6fc6d46fd7f7b09738cda05ca..c3bfef08dcf8755f324c3c44052c21d8fcad900b 100644 (file)
@@ -1519,8 +1519,8 @@ static bool should_hash_preload(struct mm_struct *mm, unsigned long ea)
 }
 #endif
 
-void hash_preload(struct mm_struct *mm, unsigned long ea,
-                 bool is_exec, unsigned long trap)
+static void hash_preload(struct mm_struct *mm, unsigned long ea,
+                        bool is_exec, unsigned long trap)
 {
        int hugepage_shift;
        unsigned long vsid;
@@ -1600,6 +1600,57 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
        local_irq_restore(flags);
 }
 
+/*
+ * This is called at the end of handling a user page fault, when the
+ * fault has been handled by updating a PTE in the linux page tables.
+ * We use it to preload an HPTE into the hash table corresponding to
+ * the updated linux PTE.
+ *
+ * This must always be called with the pte lock held.
+ */
+void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
+                     pte_t *ptep)
+{
+       /*
+        * We don't need to worry about _PAGE_PRESENT here because we are
+        * called with either mm->page_table_lock held or ptl lock held
+        */
+       unsigned long trap;
+       bool is_exec;
+
+       if (radix_enabled()) {
+               prefetch((void *)address);
+               return;
+       }
+
+       /* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */
+       if (!pte_young(*ptep) || address >= TASK_SIZE)
+               return;
+
+       /*
+        * We try to figure out if we are coming from an instruction
+        * access fault and pass that down to __hash_page so we avoid
+        * double-faulting on execution of fresh text. We have to test
+        * for regs NULL since init will get here first thing at boot.
+        *
+        * We also avoid filling the hash if not coming from a fault.
+        */
+
+       trap = current->thread.regs ? TRAP(current->thread.regs) : 0UL;
+       switch (trap) {
+       case 0x300:
+               is_exec = false;
+               break;
+       case 0x400:
+               is_exec = true;
+               break;
+       default:
+               return;
+       }
+
+       hash_preload(vma->vm_mm, address, is_exec, trap);
+}
+
 #ifdef CONFIG_PPC_MEM_KEYS
 /*
  * Return the protection key associated with the given address and the
index 58d11362eee4fdc3fb6f62be7960f1c340e6600b..69f99128a8d6888673cd57dd8d1e5500f80e0635 100644 (file)
@@ -407,58 +407,6 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
 }
 EXPORT_SYMBOL(flush_icache_user_range);
 
-/*
- * This is called at the end of handling a user page fault, when the
- * fault has been handled by updating a PTE in the linux page tables.
- * We use it to preload an HPTE into the hash table corresponding to
- * the updated linux PTE.
- * 
- * This must always be called with the pte lock held.
- */
-#ifdef CONFIG_PPC_BOOK3S
-void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
-                     pte_t *ptep)
-{
-       /*
-        * We don't need to worry about _PAGE_PRESENT here because we are
-        * called with either mm->page_table_lock held or ptl lock held
-        */
-       unsigned long trap;
-       bool is_exec;
-
-       if (radix_enabled()) {
-               prefetch((void *)address);
-               return;
-       }
-
-       /* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */
-       if (!pte_young(*ptep) || address >= TASK_SIZE)
-               return;
-
-       /* We try to figure out if we are coming from an instruction
-        * access fault and pass that down to __hash_page so we avoid
-        * double-faulting on execution of fresh text. We have to test
-        * for regs NULL since init will get here first thing at boot
-        *
-        * We also avoid filling the hash if not coming from a fault
-        */
-
-       trap = current->thread.regs ? TRAP(current->thread.regs) : 0UL;
-       switch (trap) {
-       case 0x300:
-               is_exec = false;
-               break;
-       case 0x400:
-               is_exec = true;
-               break;
-       default:
-               return;
-       }
-
-       hash_preload(vma->vm_mm, address, is_exec, trap);
-}
-#endif /* CONFIG_PPC_BOOK3S */
-
 /*
  * System memory should not be in /proc/iomem but various tools expect it
  * (eg kdump).
index 32c1a191c28aecba9df94a565b1ced825a11342e..9f325a7a09cbf61b973bdefb05b00fd53ac7282c 100644 (file)
@@ -82,10 +82,6 @@ static inline void print_system_hash_info(void) {}
 
 #else /* CONFIG_PPC_MMU_NOHASH */
 
-extern void hash_preload(struct mm_struct *mm, unsigned long ea,
-                        bool is_exec, unsigned long trap);
-
-
 extern void _tlbie(unsigned long address);
 extern void _tlbia(void);
 
@@ -95,6 +91,9 @@ void print_system_hash_info(void);
 
 #ifdef CONFIG_PPC32
 
+void hash_preload(struct mm_struct *mm, unsigned long ea,
+                 bool is_exec, unsigned long trap);
+
 extern void mapin_ram(void);
 extern void setbat(int index, unsigned long virt, phys_addr_t phys,
                   unsigned int size, pgprot_t prot);