Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_PGTABLE_32_H
0003 #define _ASM_X86_PGTABLE_32_H
0004 
0005 #include <asm/pgtable_32_types.h>
0006 
0007 /*
0008  * The Linux memory management assumes a three-level page table setup. On
0009  * the i386, we use that, but "fold" the mid level into the top-level page
0010  * table, so that we physically have the same two-level page table as the
0011  * i386 mmu expects.
0012  *
0013  * This file contains the functions and defines necessary to modify and use
0014  * the i386 page table tree.
0015  */
0016 #ifndef __ASSEMBLY__
0017 #include <asm/processor.h>
0018 #include <linux/threads.h>
0019 #include <asm/paravirt.h>
0020 
0021 #include <linux/bitops.h>
0022 #include <linux/list.h>
0023 #include <linux/spinlock.h>
0024 
0025 struct mm_struct;
0026 struct vm_area_struct;
0027 
0028 extern pgd_t swapper_pg_dir[1024];
0029 extern pgd_t initial_page_table[1024];
0030 extern pmd_t initial_pg_pmd[];
0031 
0032 void paging_init(void);
0033 void sync_initial_page_table(void);
0034 
0035 #ifdef CONFIG_X86_PAE
0036 # include <asm/pgtable-3level.h>
0037 #else
0038 # include <asm/pgtable-2level.h>
0039 #endif
0040 
0041 /* Clear a kernel PTE and flush it from the TLB */
0042 #define kpte_clear_flush(ptep, vaddr)       \
0043 do {                        \
0044     pte_clear(&init_mm, (vaddr), (ptep));   \
0045     flush_tlb_one_kernel((vaddr));      \
0046 } while (0)
0047 
0048 #endif /* !__ASSEMBLY__ */
0049 
0050 /*
0051  * kern_addr_valid() is (1) for FLATMEM and (0) for SPARSEMEM
0052  */
0053 #ifdef CONFIG_FLATMEM
0054 #define kern_addr_valid(addr)   (1)
0055 #else
0056 #define kern_addr_valid(kaddr)  (0)
0057 #endif
0058 
0059 /*
0060  * This is used to calculate the .brk reservation for initial pagetables.
0061  * Enough space is reserved to allocate pagetables sufficient to cover all
0062  * of LOWMEM_PAGES, which is an upper bound on the size of the direct map of
0063  * lowmem.
0064  *
0065  * With PAE paging (PTRS_PER_PMD > 1), we allocate PTRS_PER_PGD == 4 pages for
0066  * the PMD's in addition to the pages required for the last level pagetables.
0067  */
0068 #if PTRS_PER_PMD > 1
0069 #define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
0070 #else
0071 #define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
0072 #endif
0073 
0074 /*
0075  * Number of possible pages in the lowmem region.
0076  *
0077  * We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a
0078  * gas warning about overflowing shift count when gas has been compiled
0079  * with only a host target support using a 32-bit type for internal
0080  * representation.
0081  */
0082 #define LOWMEM_PAGES ((((_ULL(2)<<31) - __PAGE_OFFSET) >> PAGE_SHIFT))
0083 
0084 #endif /* _ASM_X86_PGTABLE_32_H */