1 #ifndef _ASM_X86_PGTABLE_H
2 #define _ASM_X86_PGTABLE_H
12 #define pgprot_noncached(prot) \
13 ((boot_cpu_data.x86 > 3) \
14 ? (__pgprot(pgprot_val(prot) | _PAGE_CACHE_UC_MINUS)) \
26 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
33 #ifdef CONFIG_PARAVIRT
34 #include <asm/paravirt.h>
36 #define set_pte(ptep, pte) native_set_pte(ptep, pte)
37 #define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte)
38 #define set_pmd_at(mm, addr, pmdp, pmd) native_set_pmd_at(mm, addr, pmdp, pmd)
40 #define set_pte_atomic(ptep, pte) \
41 native_set_pte_atomic(ptep, pte)
43 #define set_pmd(pmdp, pmd) native_set_pmd(pmdp, pmd)
45 #ifndef __PAGETABLE_PUD_FOLDED
46 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
47 #define pgd_clear(pgd) native_pgd_clear(pgd)
51 # define set_pud(pudp, pud) native_set_pud(pudp, pud)
54 #ifndef __PAGETABLE_PMD_FOLDED
55 #define pud_clear(pud) native_pud_clear(pud)
58 #define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep)
59 #define pmd_clear(pmd) native_pmd_clear(pmd)
61 #define pte_update(mm, addr, ptep) do { } while (0)
62 #define pte_update_defer(mm, addr, ptep) do { } while (0)
63 #define pmd_update(mm, addr, ptep) do { } while (0)
64 #define pmd_update_defer(mm, addr, ptep) do { } while (0)
66 #define pgd_val(x) native_pgd_val(x)
67 #define __pgd(x) native_make_pgd(x)
69 #ifndef __PAGETABLE_PUD_FOLDED
70 #define pud_val(x) native_pud_val(x)
71 #define __pud(x) native_make_pud(x)
74 #ifndef __PAGETABLE_PMD_FOLDED
75 #define pmd_val(x) native_pmd_val(x)
76 #define __pmd(x) native_make_pmd(x)
79 #define pte_val(x) native_pte_val(x)
80 #define __pte(x) native_make_pte(x)
82 #define arch_end_context_switch(prev) do {} while(0)
120 static inline int pte_global(
pte_t pte)
145 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
152 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
153 static inline int pmd_trans_splitting(
pmd_t pmd)
158 static inline int pmd_trans_huge(
pmd_t pmd)
163 static inline int has_transparent_hugepage(
void)
173 return native_make_pte(v |
set);
180 return native_make_pte(v & ~clear);
195 return pte_clear_flags(pte,
_PAGE_RW);
200 return pte_clear_flags(pte,
_PAGE_NX);
215 return pte_set_flags(pte,
_PAGE_RW);
247 return __pmd(v |
set);
254 return __pmd(v & ~clear);
264 return pmd_clear_flags(pmd,
_PAGE_RW);
284 return pmd_set_flags(pmd,
_PAGE_RW);
309 massage_pgprot(pgprot));
315 massage_pgprot(pgprot));
343 #define pgprot_modify pgprot_modify
348 return __pgprot(preservebits | addbits);
351 #define pte_pgprot(x) __pgprot(pte_flags(x) & PTE_FLAGS_MASK)
353 #define canon_pgprot(p) __pgprot(massage_pgprot(p))
355 static inline int is_new_memtype_allowed(
u64 paddr,
unsigned long size,
357 unsigned long new_flags)
362 if (
x86_platform.is_untracked_pat_range(paddr, paddr + size))
386 # include <asm/pgtable_32.h>
388 # include <asm/pgtable_64.h>
399 #define __HAVE_ARCH_PTE_SAME
410 static inline int pte_hidden(
pte_t pte)
430 return (
unsigned long)native_pmd_val(pmd) == 0;
442 #define pmd_page(pmd) pfn_to_page((pmd_val(pmd) & PTE_PFN_MASK) >> PAGE_SHIFT)
462 #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
485 static inline unsigned long pages_to_mb(
unsigned long npg)
490 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
491 remap_pfn_range(vma, vaddr, pfn, size, prot)
493 #if PAGETABLE_LEVELS > 2
496 return native_pud_val(pud) == 0;
513 #define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
538 #if PAGETABLE_LEVELS > 3
553 #define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
556 static inline unsigned long pud_index(
unsigned long address)
573 return !native_pgd_val(pgd);
585 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
591 #define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
596 #define pgd_offset_k(address) pgd_offset(&init_mm, (address))
599 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
600 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
607 static inline pte_t native_local_ptep_get_and_clear(
pte_t *ptep)
612 native_pte_clear(
NULL, 0, ptep);
616 static inline pmd_t native_local_pmdp_get_and_clear(
pmd_t *pmdp)
620 native_pmd_clear(pmdp);
624 static inline void native_set_pte_at(
struct mm_struct *mm,
unsigned long addr,
627 native_set_pte(ptep, pte);
630 static inline void native_set_pmd_at(
struct mm_struct *mm,
unsigned long addr,
633 native_set_pmd(pmdp, pmd);
636 #ifndef CONFIG_PARAVIRT
650 #define pte_update(mm, addr, ptep) do { } while (0)
651 #define pte_update_defer(mm, addr, ptep) do { } while (0)
663 #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
665 unsigned long address,
pte_t *ptep,
668 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
672 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
674 unsigned long address,
pte_t *ptep);
676 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
685 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
696 pte = native_local_ptep_get_and_clear(ptep);
703 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
711 #define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
713 #define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot))
715 #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
717 unsigned long address,
pmd_t *pmdp,
720 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
724 #define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
726 unsigned long address,
pmd_t *pmdp);
729 #define __HAVE_ARCH_PMDP_SPLITTING_FLUSH
733 #define __HAVE_ARCH_PMD_WRITE
739 #define __HAVE_ARCH_PMDP_GET_AND_CLEAR
748 #define __HAVE_ARCH_PMDP_SET_WRPROTECT
749 static inline void pmdp_set_wrprotect(
struct mm_struct *mm,