]> err.no Git - linux-2.6/blobdiff - arch/x86/mm/pageattr.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[linux-2.6] / arch / x86 / mm / pageattr.c
index 938df5e8402b5886770bf3e17f88cf454c3e9045..60bcb5b6a37ef0130fb08da8ef38db58fd37910a 100644 (file)
@@ -31,6 +31,7 @@ struct cpa_data {
        int             numpages;
        int             flushtlb;
        unsigned long   pfn;
+       unsigned        force_split : 1;
 };
 
 #ifdef CONFIG_X86_64
@@ -262,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
@@ -479,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
@@ -538,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)) {
@@ -696,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;
@@ -707,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 */
@@ -724,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;
@@ -762,31 +766,56 @@ 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)
 {
+       /*
+        * 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, NULL))
+                           _PAGE_CACHE_UC_MINUS, NULL))
                return -EINVAL;
 
        return _set_memory_uc(addr, numpages);
 }
 EXPORT_SYMBOL(set_memory_uc);
 
+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,
@@ -828,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);
@@ -962,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;