pgtable_32.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_PGTABLE_32_H
  3. #define _ASM_X86_PGTABLE_32_H
  4. #include <asm/pgtable_32_types.h>
  5. /*
  6. * The Linux memory management assumes a three-level page table setup. On
  7. * the i386, we use that, but "fold" the mid level into the top-level page
  8. * table, so that we physically have the same two-level page table as the
  9. * i386 mmu expects.
  10. *
  11. * This file contains the functions and defines necessary to modify and use
  12. * the i386 page table tree.
  13. */
  14. #ifndef __ASSEMBLY__
  15. #include <asm/processor.h>
  16. #include <linux/threads.h>
  17. #include <asm/paravirt.h>
  18. #include <linux/bitops.h>
  19. #include <linux/list.h>
  20. #include <linux/spinlock.h>
  21. struct mm_struct;
  22. struct vm_area_struct;
  23. extern pgd_t swapper_pg_dir[1024];
  24. extern pgd_t initial_page_table[1024];
  25. extern pmd_t initial_pg_pmd[];
  26. void paging_init(void);
  27. void sync_initial_page_table(void);
  28. #ifdef CONFIG_X86_PAE
  29. # include <asm/pgtable-3level.h>
  30. #else
  31. # include <asm/pgtable-2level.h>
  32. #endif
  33. /* Clear a kernel PTE and flush it from the TLB */
  34. #define kpte_clear_flush(ptep, vaddr) \
  35. do { \
  36. pte_clear(&init_mm, (vaddr), (ptep)); \
  37. flush_tlb_one_kernel((vaddr)); \
  38. } while (0)
  39. #endif /* !__ASSEMBLY__ */
  40. /*
  41. * kern_addr_valid() is (1) for FLATMEM and (0) for SPARSEMEM
  42. */
  43. #ifdef CONFIG_FLATMEM
  44. #define kern_addr_valid(addr) (1)
  45. #else
  46. #define kern_addr_valid(kaddr) (0)
  47. #endif
  48. /*
  49. * This is used to calculate the .brk reservation for initial pagetables.
  50. * Enough space is reserved to allocate pagetables sufficient to cover all
  51. * of LOWMEM_PAGES, which is an upper bound on the size of the direct map of
  52. * lowmem.
  53. *
  54. * With PAE paging (PTRS_PER_PMD > 1), we allocate PTRS_PER_PGD == 4 pages for
  55. * the PMD's in addition to the pages required for the last level pagetables.
  56. */
  57. #if PTRS_PER_PMD > 1
  58. #define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
  59. #else
  60. #define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
  61. #endif
  62. /*
  63. * Number of possible pages in the lowmem region.
  64. *
  65. * We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a
  66. * gas warning about overflowing shift count when gas has been compiled
  67. * with only a host target support using a 32-bit type for internal
  68. * representation.
  69. */
  70. #define LOWMEM_PAGES ((((_ULL(2)<<31) - __PAGE_OFFSET) >> PAGE_SHIFT))
  71. #endif /* _ASM_X86_PGTABLE_32_H */