]> git.ipfire.org Git - people/ms/linux.git/commitdiff
MIPS: asm: pgtable: Prevent HTW race when updating PTEs
authorMarkos Chandras <markos.chandras@imgtec.com>
Mon, 26 Jan 2015 09:40:36 +0000 (09:40 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Mar 2015 22:52:55 +0000 (14:52 -0800)
commit fde3538a8a711aedf1173ecb2d45aed868f51c97 upstream.

Whenever we modify a page table entry, we need to ensure that the HTW
will not fetch a stable entry. And for that to happen we need to ensure
that HTW is stopped before we modify the said entry otherwise the HTW
may already be in the process of reading that entry and fetching the
old information. As a result of which, we replace the htw_reset() calls
with htw_{stop,start} in more appropriate places. This also removes the
remaining users of htw_reset() and as a result we drop that macro

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9116/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/mips/include/asm/pgtable.h

index 7f7c558de9fc7ce8af81a61815beed0253bc433f..b9b9c810d92429d6f28db53acaba0cf0e5f57e50 100644 (file)
@@ -116,14 +116,6 @@ do {                                                                       \
 } while(0)
 
 
-#define htw_reset()                                                    \
-do {                                                                   \
-       if (cpu_has_htw) {                                              \
-               htw_stop();                                             \
-               htw_start();                                            \
-       }                                                               \
-} while(0)
-
 extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
        pte_t pteval);
 
@@ -155,12 +147,13 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
 {
        pte_t null = __pte(0);
 
+       htw_stop();
        /* Preserve global status for the pair */
        if (ptep_buddy(ptep)->pte_low & _PAGE_GLOBAL)
                null.pte_low = null.pte_high = _PAGE_GLOBAL;
 
        set_pte_at(mm, addr, ptep, null);
-       htw_reset();
+       htw_start();
 }
 #else
 
@@ -190,6 +183,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
 
 static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
+       htw_stop();
 #if !defined(CONFIG_CPU_R3000) && !defined(CONFIG_CPU_TX39XX)
        /* Preserve global status for the pair */
        if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
@@ -197,7 +191,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
        else
 #endif
                set_pte_at(mm, addr, ptep, __pte(0));
-       htw_reset();
+       htw_start();
 }
 #endif