~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/hexagon/include/asm/pgalloc.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * Page table support for the Hexagon architecture
  4  *
  5  * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  6  */
  7 
  8 #ifndef _ASM_PGALLOC_H
  9 #define _ASM_PGALLOC_H
 10 
 11 #include <asm/mem-layout.h>
 12 #include <asm/atomic.h>
 13 
 14 #include <asm-generic/pgalloc.h>
 15 
 16 extern unsigned long long kmap_generation;
 17 
 18 /*
 19  * Page table creation interface
 20  */
 21 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 22 {
 23         pgd_t *pgd;
 24 
 25         pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
 26 
 27         /*
 28          * There may be better ways to do this, but to ensure
 29          * that new address spaces always contain the kernel
 30          * base mapping, and to ensure that the user area is
 31          * initially marked invalid, initialize the new map
 32          * map with a copy of the kernel's persistent map.
 33          */
 34 
 35         memcpy(pgd, swapper_pg_dir, PTRS_PER_PGD*sizeof(pgd_t));
 36         mm->context.generation = kmap_generation;
 37 
 38         /* Physical version is what is passed to virtual machine on switch */
 39         mm->context.ptbase = __pa(pgd);
 40 
 41         return pgd;
 42 }
 43 
 44 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
 45                                 pgtable_t pte)
 46 {
 47         /*
 48          * Conveniently, zero in 3 LSB means indirect 4K page table.
 49          * Not so convenient when you're trying to vary the page size.
 50          */
 51         set_pmd(pmd, __pmd(((unsigned long)page_to_pfn(pte) << PAGE_SHIFT) |
 52                 HEXAGON_L1_PTE_SIZE));
 53 }
 54 
 55 /*
 56  * Other architectures seem to have ways of making all processes
 57  * share the same pmd's for their kernel mappings, but the v0.3
 58  * Hexagon VM spec has a "monolithic" L1 table for user and kernel
 59  * segments.  We track "generations" of the kernel map to minimize
 60  * overhead, and update the "slave" copies of the kernel mappings
 61  * as part of switch_mm.  However, we still need to update the
 62  * kernel map of the active thread who's calling pmd_populate_kernel...
 63  */
 64 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
 65                                        pte_t *pte)
 66 {
 67         extern spinlock_t kmap_gen_lock;
 68         pmd_t *ppmd;
 69         int pmdindex;
 70 
 71         spin_lock(&kmap_gen_lock);
 72         kmap_generation++;
 73         mm->context.generation = kmap_generation;
 74         current->active_mm->context.generation = kmap_generation;
 75         spin_unlock(&kmap_gen_lock);
 76 
 77         set_pmd(pmd, __pmd(((unsigned long)__pa(pte)) | HEXAGON_L1_PTE_SIZE));
 78 
 79         /*
 80          * Now the "slave" copy of the current thread.
 81          * This is pointer arithmetic, not byte addresses!
 82          */
 83         pmdindex = (pgd_t *)pmd - mm->pgd;
 84         ppmd = (pmd_t *)current->active_mm->pgd + pmdindex;
 85         set_pmd(ppmd, __pmd(((unsigned long)__pa(pte)) | HEXAGON_L1_PTE_SIZE));
 86         if (pmdindex > max_kernel_seg)
 87                 max_kernel_seg = pmdindex;
 88 }
 89 
 90 #define __pte_free_tlb(tlb, pte, addr)                          \
 91 do {                                                            \
 92         pagetable_pte_dtor((page_ptdesc(pte)));                 \
 93         tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte)));      \
 94 } while (0)
 95 
 96 #endif
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php