[PATCH] Use proper accessors to change PSE bits in change_page_attr()
authorAndi Kleen <ak@suse.de>
Tue, 26 Sep 2006 08:52:37 +0000 (10:52 +0200)
committerAndi Kleen <andi@basil.nowhere.org>
Tue, 26 Sep 2006 08:52:37 +0000 (10:52 +0200)
Use normal pte accessors in change_page_attr() to access the PSE
bits.

Signed-off-by: Andi Kleen <ak@suse.de>
arch/x86_64/mm/pageattr.c
include/asm-x86_64/pgtable.h

index 01591b649f4e919deeb8604bad767f7af2e187ba..3e231d762aaa8527d112687c711747f98f4bac83 100644 (file)
@@ -108,8 +108,8 @@ static void revert_page(unsigned long address, pgprot_t ref_prot)
        BUG_ON(pud_none(*pud));
        pmd = pmd_offset(pud, address);
        BUG_ON(pmd_val(*pmd) & _PAGE_PSE);
-       pgprot_val(ref_prot) |= _PAGE_PSE;
        large_pte = mk_pte_phys(__pa(address) & LARGE_PAGE_MASK, ref_prot);
+       large_pte = pte_mkhuge(large_pte);
        set_pte((pte_t *)pmd, large_pte);
 }      
 
@@ -119,32 +119,28 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
 { 
        pte_t *kpte; 
        struct page *kpte_page;
-       unsigned kpte_flags;
        pgprot_t ref_prot2;
        kpte = lookup_address(address);
        if (!kpte) return 0;
        kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
-       kpte_flags = pte_val(*kpte); 
        if (pgprot_val(prot) != pgprot_val(ref_prot)) { 
-               if ((kpte_flags & _PAGE_PSE) == 0) { 
+               if (!pte_huge(*kpte)) {
                        set_pte(kpte, pfn_pte(pfn, prot));
                } else {
                        /*
                         * split_large_page will take the reference for this
                         * change_page_attr on the split page.
                         */
-
                        struct page *split;
-                       ref_prot2 = __pgprot(pgprot_val(pte_pgprot(*lookup_address(address))) & ~(1<<_PAGE_BIT_PSE));
-
+                       ref_prot2 = pte_pgprot(pte_clrhuge(*kpte));
                        split = split_large_page(address, prot, ref_prot2);
                        if (!split)
                                return -ENOMEM;
-                       set_pte(kpte,mk_pte(split, ref_prot2));
+                       set_pte(kpte, mk_pte(split, ref_prot2));
                        kpte_page = split;
-               }       
+               }
                page_private(kpte_page)++;
-       } else if ((kpte_flags & _PAGE_PSE) == 0) { 
+       } else if (!pte_huge(*kpte)) {
                set_pte(kpte, pfn_pte(pfn, ref_prot));
                BUG_ON(page_private(kpte_page) == 0);
                page_private(kpte_page)--;
index f7614670c6553668711b7960e2a2fdaa4a4a860c..b34f43acdef10bce3bc99c69ddf8eb363f62b54e 100644 (file)
@@ -283,6 +283,7 @@ static inline pte_t pte_mkdirty(pte_t pte)  { set_pte(&pte, __pte(pte_val(pte) |
 static inline pte_t pte_mkyoung(pte_t pte)     { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
 static inline pte_t pte_mkwrite(pte_t pte)     { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
 static inline pte_t pte_mkhuge(pte_t pte)      { set_pte(&pte, __pte(pte_val(pte) | _PAGE_PSE)); return pte; }
+static inline pte_t pte_clrhuge(pte_t pte)     { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_PSE)); return pte; }
 
 struct vm_area_struct;