]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86_64/mm/pageattr.c
Pull misc into release branch
[linux-2.6-omap-h63xx.git] / arch / x86_64 / mm / pageattr.c
index 65c5eaa5990563048b1ac59e04e3dcd645441b5c..36377b6b8efe9af1039104b753665edf96a80821 100644 (file)
@@ -74,15 +74,14 @@ static void flush_kernel_map(void *arg)
        struct page *pg;
 
        /* When clflush is available always use it because it is
-          much cheaper than WBINVD */
+          much cheaper than WBINVD. */
        if (!cpu_has_clflush)
                asm volatile("wbinvd" ::: "memory");
-       list_for_each_entry(pg, l, lru) {
+       else list_for_each_entry(pg, l, lru) {
                void *adr = page_address(pg);
-               if (cpu_has_clflush)
-                       cache_flush_page(adr);
-               __flush_tlb_one(adr);
+               cache_flush_page(adr);
        }
+       __flush_tlb_all();
 }
 
 static inline void flush_map(struct list_head *l)
@@ -94,7 +93,8 @@ static LIST_HEAD(deferred_pages); /* protected by init_mm.mmap_sem */
 
 static inline void save_page(struct page *fpage)
 {
-       list_add(&fpage->lru, &deferred_pages);
+       if (!test_and_set_bit(PG_arch_1, &fpage->flags))
+               list_add(&fpage->lru, &deferred_pages);
 }
 
 /* 
@@ -128,9 +128,12 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
        pte_t *kpte; 
        struct page *kpte_page;
        pgprot_t ref_prot2;
+
        kpte = lookup_address(address);
        if (!kpte) return 0;
        kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
+       BUG_ON(PageLRU(kpte_page));
+       BUG_ON(PageCompound(kpte_page));
        if (pgprot_val(prot) != pgprot_val(ref_prot)) { 
                if (!pte_huge(*kpte)) {
                        set_pte(kpte, pfn_pte(pfn, prot));
@@ -158,10 +161,9 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
        /* on x86-64 the direct mapping set at boot is not using 4k pages */
        BUG_ON(PageReserved(kpte_page));
 
-       if (page_private(kpte_page) == 0) {
-               save_page(kpte_page);
+       save_page(kpte_page);
+       if (page_private(kpte_page) == 0)
                revert_page(address, ref_prot);
-       }
        return 0;
 } 
 
@@ -180,16 +182,24 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
  */
 int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot)
 {
-       int err = 0
+       int err = 0, kernel_map = 0;
        int i; 
 
+       if (address >= __START_KERNEL_map
+           && address < __START_KERNEL_map + KERNEL_TEXT_SIZE) {
+               address = (unsigned long)__va(__pa(address));
+               kernel_map = 1;
+       }
+
        down_write(&init_mm.mmap_sem);
        for (i = 0; i < numpages; i++, address += PAGE_SIZE) {
                unsigned long pfn = __pa(address) >> PAGE_SHIFT;
 
-               err = __change_page_attr(address, pfn, prot, PAGE_KERNEL);
-               if (err) 
-                       break; 
+               if (!kernel_map || pte_present(pfn_pte(0, prot))) {
+                       err = __change_page_attr(address, pfn, prot, PAGE_KERNEL);
+                       if (err)
+                               break;
+               }
                /* Handle kernel mapping too which aliases part of the
                 * lowmem */
                if (__pa(address) < KERNEL_TEXT_SIZE) {
@@ -225,6 +235,10 @@ void global_flush_tlb(void)
        flush_map(&l);
 
        list_for_each_entry_safe(pg, next, &l, lru) {
+               list_del(&pg->lru);
+               clear_bit(PG_arch_1, &pg->flags);
+               if (page_private(pg) != 0)
+                       continue;
                ClearPagePrivate(pg);
                __free_page(pg);
        }