]> err.no Git - linux-2.6/blobdiff - arch/x86/mm/pageattr.c
Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / arch / x86 / mm / pageattr.c
index f7d5ca170c22141db4e3360b15fc57966399177f..60bcb5b6a37ef0130fb08da8ef38db58fd37910a 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/uaccess.h>
 #include <asm/pgalloc.h>
 #include <asm/proto.h>
+#include <asm/pat.h>
 
 /*
  * The current flushing context - we pass it instead of 5 arguments:
@@ -30,6 +31,7 @@ struct cpa_data {
        int             numpages;
        int             flushtlb;
        unsigned long   pfn;
+       unsigned        force_split : 1;
 };
 
 #ifdef CONFIG_X86_64
@@ -261,6 +263,9 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
        int i, do_split = 1;
        unsigned int level;
 
+       if (cpa->force_split)
+               return 1;
+
        spin_lock_irqsave(&pgd_lock, flags);
        /*
         * Check for races, another CPU might have split this page
@@ -478,9 +483,7 @@ static int split_large_page(pte_t *kpte, unsigned long address)
                goto out_unlock;
 
        pbase = (pte_t *)page_address(base);
-#ifdef CONFIG_X86_32
-       paravirt_alloc_pt(&init_mm, page_to_pfn(base));
-#endif
+       paravirt_alloc_pte(&init_mm, page_to_pfn(base));
        ref_prot = pte_pgprot(pte_clrhuge(*kpte));
 
 #ifdef CONFIG_X86_64
@@ -537,7 +540,7 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
 repeat:
        kpte = lookup_address(address, &level);
        if (!kpte)
-               return primary ? -EINVAL : 0;
+               return 0;
 
        old_pte = *kpte;
        if (!pte_val(old_pte)) {
@@ -695,7 +698,8 @@ static inline int cache_attr(pgprot_t attr)
 }
 
 static int change_page_attr_set_clr(unsigned long addr, int numpages,
-                                   pgprot_t mask_set, pgprot_t mask_clr)
+                                   pgprot_t mask_set, pgprot_t mask_clr,
+                                   int force_split)
 {
        struct cpa_data cpa;
        int ret, cache, checkalias;
@@ -706,7 +710,7 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
         */
        mask_set = canon_pgprot(mask_set);
        mask_clr = canon_pgprot(mask_clr);
-       if (!pgprot_val(mask_set) && !pgprot_val(mask_clr))
+       if (!pgprot_val(mask_set) && !pgprot_val(mask_clr) && !force_split)
                return 0;
 
        /* Ensure we are PAGE_SIZE aligned */
@@ -723,6 +727,7 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
        cpa.mask_set = mask_set;
        cpa.mask_clr = mask_clr;
        cpa.flushtlb = 0;
+       cpa.force_split = force_split;
 
        /* No alias checking for _NX bit modifications */
        checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX;
@@ -761,27 +766,68 @@ out:
 static inline int change_page_attr_set(unsigned long addr, int numpages,
                                       pgprot_t mask)
 {
-       return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0));
+       return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0);
 }
 
 static inline int change_page_attr_clear(unsigned long addr, int numpages,
                                         pgprot_t mask)
 {
-       return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask);
+       return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0);
 }
 
-int set_memory_uc(unsigned long addr, int numpages)
+int _set_memory_uc(unsigned long addr, int numpages)
 {
+       /*
+        * for now UC MINUS. see comments in ioremap_nocache()
+        */
        return change_page_attr_set(addr, numpages,
-                                   __pgprot(_PAGE_CACHE_UC));
+                                   __pgprot(_PAGE_CACHE_UC_MINUS));
+}
+
+int set_memory_uc(unsigned long addr, int numpages)
+{
+       /*
+        * for now UC MINUS. see comments in ioremap_nocache()
+        */
+       if (reserve_memtype(addr, addr + numpages * PAGE_SIZE,
+                           _PAGE_CACHE_UC_MINUS, NULL))
+               return -EINVAL;
+
+       return _set_memory_uc(addr, numpages);
 }
 EXPORT_SYMBOL(set_memory_uc);
 
-int set_memory_wb(unsigned long addr, int numpages)
+int _set_memory_wc(unsigned long addr, int numpages)
+{
+       return change_page_attr_set(addr, numpages,
+                                   __pgprot(_PAGE_CACHE_WC));
+}
+
+int set_memory_wc(unsigned long addr, int numpages)
+{
+       if (!pat_wc_enabled)
+               return set_memory_uc(addr, numpages);
+
+       if (reserve_memtype(addr, addr + numpages * PAGE_SIZE,
+               _PAGE_CACHE_WC, NULL))
+               return -EINVAL;
+
+       return _set_memory_wc(addr, numpages);
+}
+EXPORT_SYMBOL(set_memory_wc);
+
+int _set_memory_wb(unsigned long addr, int numpages)
 {
        return change_page_attr_clear(addr, numpages,
                                      __pgprot(_PAGE_CACHE_MASK));
 }
+
+int set_memory_wb(unsigned long addr, int numpages)
+{
+       free_memtype(addr, addr + numpages * PAGE_SIZE);
+
+       return _set_memory_wb(addr, numpages);
+}
 EXPORT_SYMBOL(set_memory_wb);
 
 int set_memory_x(unsigned long addr, int numpages)
@@ -811,6 +857,12 @@ int set_memory_np(unsigned long addr, int numpages)
        return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_PRESENT));
 }
 
+int set_memory_4k(unsigned long addr, int numpages)
+{
+       return change_page_attr_set_clr(addr, numpages, __pgprot(0),
+                                       __pgprot(0), 1);
+}
+
 int set_pages_uc(struct page *page, int numpages)
 {
        unsigned long addr = (unsigned long)page_address(page);
@@ -945,7 +997,7 @@ static const struct file_operations dpa_fops = {
        .release        = single_release,
 };
 
-int __init debug_pagealloc_proc_init(void)
+static int __init debug_pagealloc_proc_init(void)
 {
        struct dentry *de;