ARM: mm: don't override huge page cache attributes
authorGrazvydas Ignotas <notasas@gmail.com>
Thu, 5 Jun 2014 00:33:56 +0000 (03:33 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 11 Jul 2014 22:37:14 +0000 (01:37 +0300)
arch/arm/include/asm/hugetlb-2level.h
arch/arm/include/asm/pgtable-2level.h
arch/arm/mm/mmu.c

index eb0e8b6..b08353a 100644 (file)
 static inline pte_t huge_ptep_get(pte_t *ptep)
 {
        pmd_t pmd =  *((pmd_t *)ptep);
+       u32 pmdval = pmd_val(pmd);
        pte_t retval;
 
        if (!pmd_val(pmd))
                return __pte(0);
 
        retval = __pte((pteval_t) (pmd_val(pmd) & HPAGE_MASK)
-                       | arm_hugepteprotval);
+                       | (pmdval & 0x0c) | ((pmdval >> 8) & 0x10)
+                       | L_PTE_PRESENT | L_PTE_USER | L_PTE_VALID);
 
        if (pmd_exec(pmd))
                retval = pte_mkexec(retval);
index 18d7bfb..1300888 100644 (file)
@@ -231,9 +231,6 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
        flush_pmd_entry(pmdp);
 }
 
-extern pmdval_t arm_hugepmdprotval;
-extern pteval_t arm_hugepteprotval;
-
 #define pmd_mkhuge(pmd)                (__pmd((pmd_val(pmd) & ~PMD_TYPE_MASK) | PMD_TYPE_SECT))
 
 PMD_BIT_FUNC(mkold, &= ~PMD_DSECT_AF);
@@ -255,10 +252,10 @@ PMD_BIT_FUNC(mknexec,     |= PMD_SECT_XN);
 
 #define pmd_modify(pmd, prot)                                                  \
 ({                                                                             \
-       pmd_t pmdret = __pmd((pmd_val(pmd) & (PMD_MASK | PMD_DOMAIN_MASK))      \
-               | arm_hugepmdprotval);                                          \
+       pmd_t pmdret = __pmd(pmd_val(pmd) & (PMD_MASK | PMD_DOMAIN_MASK));      \
        pgprot_t inprot = prot;                                                 \
-       pte_t newprot = __pte(pgprot_val(inprot));                              \
+       u32 inprotval = pgprot_val(inprot);                                     \
+       pte_t newprot = __pte(inprotval);                                       \
                                                                                \
        if (pte_dirty(newprot))                                                 \
                pmdret = pmd_mkdirty(pmdret);                                   \
@@ -279,6 +276,10 @@ PMD_BIT_FUNC(mknexec,      |= PMD_SECT_XN);
                pmdret = pmd_mkyoung(pmdret);                                   \
        else                                                                    \
                pmdret = pmd_mkold(pmdret);                                     \
+       pmdret = __pmd(pmd_val(pmdret) | (inprotval & 0x0c)                     \
+                       | ((inprotval << 8) & 0x1000)                           \
+                       | PMD_TYPE_SECT | PMD_SECT_AP_WRITE                     \
+                       | PMD_SECT_AP_READ | PMD_SECT_nG);                      \
                                                                                \
        pmdret;                                                                 \
 })
index 0a5191e..1ca8e17 100644 (file)
@@ -299,21 +299,6 @@ const struct mem_type *get_mem_type(unsigned int type)
 }
 EXPORT_SYMBOL(get_mem_type);
 
-/*
- * If the system supports huge pages and we are running with short descriptors,
- * then compute the pmd and linux pte prot values for a huge page.
- *
- * These values are used by both the HugeTLB and THP code.
- */
-#if defined(CONFIG_SYS_SUPPORTS_HUGETLBFS) && !defined(CONFIG_ARM_LPAE)
-pmdval_t arm_hugepmdprotval;
-EXPORT_SYMBOL(arm_hugepmdprotval);
-
-pteval_t arm_hugepteprotval;
-EXPORT_SYMBOL(arm_hugepteprotval);
-#endif
-
-
 /*
  * Adjust the PMD section entries according to the CPU in use.
  */
@@ -562,18 +547,6 @@ static void __init build_mem_type_table(void)
                if (t->prot_sect)
                        t->prot_sect |= PMD_DOMAIN(t->domain);
        }
-
-#if defined(CONFIG_SYS_SUPPORTS_HUGETLBFS) && !defined(CONFIG_ARM_LPAE)
-       /*
-        * we assume all huge pages are user pages and that hardware access
-        * flag updates are disabled (i.e. SCTLR.AFE == 0b).
-        */
-       arm_hugepteprotval = mem_types[MT_MEMORY].prot_pte | L_PTE_USER | L_PTE_VALID;
-
-       arm_hugepmdprotval = mem_types[MT_MEMORY].prot_sect | PMD_SECT_AP_READ
-                               | PMD_SECT_nG;
-#endif
-
 }
 
 #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE