PATH:
usr
/
src
/
kernels
/
5.14.0-611.49.2.el9_7.x86_64
/
include
/
asm-generic
/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __ASM_GENERIC_PGALLOC_H #define __ASM_GENERIC_PGALLOC_H #ifdef CONFIG_MMU #define GFP_PGTABLE_KERNEL (GFP_KERNEL | __GFP_ZERO) #define GFP_PGTABLE_USER (GFP_PGTABLE_KERNEL | __GFP_ACCOUNT) /** * __pte_alloc_one_kernel - allocate memory for a PTE-level kernel page table * @mm: the mm_struct of the current context * * This function is intended for architectures that need * anything beyond simple page allocation. * * Return: pointer to the allocated memory or %NULL on error */ static inline pte_t *__pte_alloc_one_kernel(struct mm_struct *mm) { struct ptdesc *ptdesc = pagetable_alloc(GFP_PGTABLE_KERNEL & ~__GFP_HIGHMEM, 0); if (!ptdesc) return NULL; return ptdesc_address(ptdesc); } #ifndef __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL /** * pte_alloc_one_kernel - allocate memory for a PTE-level kernel page table * @mm: the mm_struct of the current context * * Return: pointer to the allocated memory or %NULL on error */ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) { return __pte_alloc_one_kernel(mm); } #endif /** * pte_free_kernel - free PTE-level kernel page table memory * @mm: the mm_struct of the current context * @pte: pointer to the memory containing the page table */ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) { pagetable_free(virt_to_ptdesc(pte)); } /** * __pte_alloc_one - allocate memory for a PTE-level user page table * @mm: the mm_struct of the current context * @gfp: GFP flags to use for the allocation * * Allocate memory for a page table and ptdesc and runs pagetable_pte_ctor(). * * This function is intended for architectures that need * anything beyond simple page allocation or must have custom GFP flags. * * Return: `struct page` referencing the ptdesc or %NULL on error */ static inline pgtable_t __pte_alloc_one(struct mm_struct *mm, gfp_t gfp) { struct ptdesc *ptdesc; ptdesc = pagetable_alloc(gfp, 0); if (!ptdesc) return NULL; if (!pagetable_pte_ctor(ptdesc)) { pagetable_free(ptdesc); return NULL; } return ptdesc_page(ptdesc); } #ifndef __HAVE_ARCH_PTE_ALLOC_ONE /** * pte_alloc_one - allocate a page for PTE-level user page table * @mm: the mm_struct of the current context * * Allocate memory for a page table and ptdesc and runs pagetable_pte_ctor(). * * Return: `struct page` referencing the ptdesc or %NULL on error */ static inline pgtable_t pte_alloc_one(struct mm_struct *mm) { return __pte_alloc_one(mm, GFP_PGTABLE_USER); } #endif /* * Should really implement gc for free page table pages. This could be * done with a reference count in struct page. */ /** * pte_free - free PTE-level user page table memory * @mm: the mm_struct of the current context * @pte_page: the `struct page` referencing the ptdesc */ static inline void pte_free(struct mm_struct *mm, struct page *pte_page) { struct ptdesc *ptdesc = page_ptdesc(pte_page); pagetable_pte_dtor(ptdesc); pagetable_free(ptdesc); } #if CONFIG_PGTABLE_LEVELS > 2 #ifndef __HAVE_ARCH_PMD_ALLOC_ONE /** * pmd_alloc_one - allocate memory for a PMD-level page table * @mm: the mm_struct of the current context * * Allocate memory for a page table and ptdesc and runs pagetable_pmd_ctor(). * * Allocations use %GFP_PGTABLE_USER in user context and * %GFP_PGTABLE_KERNEL in kernel context. * * Return: pointer to the allocated memory or %NULL on error */ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) { struct ptdesc *ptdesc; gfp_t gfp = GFP_PGTABLE_USER; if (mm == &init_mm) gfp = GFP_PGTABLE_KERNEL; ptdesc = pagetable_alloc(gfp, 0); if (!ptdesc) return NULL; if (!pagetable_pmd_ctor(ptdesc)) { pagetable_free(ptdesc); return NULL; } return ptdesc_address(ptdesc); } #endif #ifndef __HAVE_ARCH_PMD_FREE static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) { struct ptdesc *ptdesc = virt_to_ptdesc(pmd); BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); pagetable_pmd_dtor(ptdesc); pagetable_free(ptdesc); } #endif #endif /* CONFIG_PGTABLE_LEVELS > 2 */ #if CONFIG_PGTABLE_LEVELS > 3 static inline pud_t *__pud_alloc_one(struct mm_struct *mm, unsigned long addr) { gfp_t gfp = GFP_PGTABLE_USER; struct ptdesc *ptdesc; if (mm == &init_mm) gfp = GFP_PGTABLE_KERNEL; gfp &= ~__GFP_HIGHMEM; ptdesc = pagetable_alloc(gfp, 0); if (!ptdesc) return NULL; return ptdesc_address(ptdesc); } #ifndef __HAVE_ARCH_PUD_ALLOC_ONE /** * pud_alloc_one - allocate memory for a PUD-level page table * @mm: the mm_struct of the current context * * Allocate memory for a page table using %GFP_PGTABLE_USER for user context * and %GFP_PGTABLE_KERNEL for kernel context. * * Return: pointer to the allocated memory or %NULL on error */ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) { return __pud_alloc_one(mm, addr); } #endif static inline void __pud_free(struct mm_struct *mm, pud_t *pud) { BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); pagetable_free(virt_to_ptdesc(pud)); } #ifndef __HAVE_ARCH_PUD_FREE static inline void pud_free(struct mm_struct *mm, pud_t *pud) { __pud_free(mm, pud); } #endif #endif /* CONFIG_PGTABLE_LEVELS > 3 */ #ifndef __HAVE_ARCH_PGD_FREE static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) { pagetable_free(virt_to_ptdesc(pgd)); } #endif #endif /* CONFIG_MMU */ #endif /* __ASM_GENERIC_PGALLOC_H */
[-] mmu_context.h
[edit]
[-] tlbflush.h
[edit]
[-] access_ok.h
[edit]
[-] ftrace.h
[edit]
[-] percpu.h
[edit]
[-] asm-offsets.h
[edit]
[-] runtime-const.h
[edit]
[-] bug.h
[edit]
[-] current.h
[edit]
[-] shmparam.h
[edit]
[-] vmlinux.lds.h
[edit]
[-] vga.h
[edit]
[-] spinlock_types.h
[edit]
[-] irq.h
[edit]
[-] dma-mapping.h
[edit]
[-] audit_dir_write.h
[edit]
[-] ide_iops.h
[edit]
[-] cfi.h
[edit]
[+]
vdso
[-] topology.h
[edit]
[-] cmpxchg-local.h
[edit]
[-] mshyperv.h
[edit]
[-] rwonce.h
[edit]
[-] logic_io.h
[edit]
[-] flat.h
[edit]
[-] qspinlock.h
[edit]
[-] module.h
[edit]
[-] cmpxchg.h
[edit]
[-] termios.h
[edit]
[-] int-ll64.h
[edit]
[-] kmap_size.h
[edit]
[-] numa.h
[edit]
[-] user.h
[edit]
[-] audit_signal.h
[edit]
[-] asm-prototypes.h
[edit]
[-] pci_iomap.h
[edit]
[-] syscalls.h
[edit]
[-] ioctl.h
[edit]
[-] xor.h
[edit]
[-] hardirq.h
[edit]
[-] audit_read.h
[edit]
[-] atomic.h
[edit]
[-] hw_irq.h
[edit]
[-] bugs.h
[edit]
[-] preempt.h
[edit]
[-] irqflags.h
[edit]
[-] trace_clock.h
[edit]
[-] seccomp.h
[edit]
[-] vermagic.h
[edit]
[-] uaccess.h
[edit]
[-] barrier.h
[edit]
[-] mm_hooks.h
[edit]
[-] set_memory.h
[edit]
[-] page.h
[edit]
[-] hugetlb.h
[edit]
[-] exec.h
[edit]
[-] statfs.h
[edit]
[-] parport.h
[edit]
[-] cache.h
[edit]
[-] extable.h
[edit]
[-] kvm_para.h
[edit]
[-] mmiowb.h
[edit]
[-] device.h
[edit]
[-] cacheflush.h
[edit]
[-] local64.h
[edit]
[-] msi.h
[edit]
[-] dma.h
[edit]
[-] linkage.h
[edit]
[-] timex.h
[edit]
[-] vtime.h
[edit]
[-] mmiowb_types.h
[edit]
[-] mmu.h
[edit]
[-] param.h
[edit]
[-] bitsperlong.h
[edit]
[-] softirq_stack.h
[edit]
[-] nommu_context.h
[edit]
[-] qrwlock_types.h
[edit]
[-] kvm_types.h
[edit]
[-] fb.h
[edit]
[-] audit_write.h
[edit]
[-] pci.h
[edit]
[-] sections.h
[edit]
[-] pgtable-nopud.h
[edit]
[-] archrandom.h
[edit]
[-] pgalloc.h
[edit]
[-] futex.h
[edit]
[-] syscall.h
[edit]
[-] serial.h
[edit]
[-] spinlock.h
[edit]
[-] module.lds.h
[edit]
[-] qrwlock.h
[edit]
[-] delay.h
[edit]
[-] atomic64.h
[edit]
[+]
bitops
[-] unaligned.h
[edit]
[-] checksum.h
[edit]
[-] emergency-restart.h
[edit]
[-] signal.h
[edit]
[-] irq_work.h
[edit]
[-] audit_change_attr.h
[edit]
[-] error-injection.h
[edit]
[-] qspinlock_types.h
[edit]
[-] string.h
[edit]
[-] early_ioremap.h
[edit]
[-] io.h
[edit]
[-] iomap.h
[edit]
[-] mcs_spinlock.h
[edit]
[-] bitops.h
[edit]
[-] kprobes.h
[edit]
[-] fixmap.h
[edit]
[-] pgtable-nopmd.h
[edit]
[-] irq_regs.h
[edit]
[-] word-at-a-time.h
[edit]
[-] compat.h
[edit]
[-] pgtable-nop4d.h
[edit]
[-] div64.h
[edit]
[-] local.h
[edit]
[-] tlb.h
[edit]
[-] resource.h
[edit]
[-] simd.h
[edit]
[-] export.h
[edit]
[-] kdebug.h
[edit]
[+]
..
[-] pgtable_uffd.h
[edit]
[-] memory_model.h
[edit]
[-] switch_to.h
[edit]
[-] Kbuild
[edit]
[-] getorder.h
[edit]