Skip to content

Commit e3201ff

Browse files
Markos Chandrasgregkh
authored andcommitted
MIPS: asm: pgtable: Prevent HTW race when updating PTEs
commit fde3538 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>
1 parent 6ce23db commit e3201ff

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

‎arch/mips/include/asm/pgtable.h‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ do { \
116116
} while(0)
117117

118118

119-
#define htw_reset() \
120-
do { \
121-
if (cpu_has_htw) { \
122-
htw_stop(); \
123-
htw_start(); \
124-
} \
125-
} while(0)
126-
127119
extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
128120
pte_t pteval);
129121

@@ -155,12 +147,13 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
155147
{
156148
pte_t null = __pte(0);
157149

150+
htw_stop();
158151
/* Preserve global status for the pair */
159152
if (ptep_buddy(ptep)->pte_low & _PAGE_GLOBAL)
160153
null.pte_low = null.pte_high = _PAGE_GLOBAL;
161154

162155
set_pte_at(mm, addr, ptep, null);
163-
htw_reset();
156+
htw_start();
164157
}
165158
#else
166159

@@ -190,14 +183,15 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
190183

191184
static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
192185
{
186+
htw_stop();
193187
#if !defined(CONFIG_CPU_R3000) && !defined(CONFIG_CPU_TX39XX)
194188
/* Preserve global status for the pair */
195189
if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
196190
set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL));
197191
else
198192
#endif
199193
set_pte_at(mm, addr, ptep, __pte(0));
200-
htw_reset();
194+
htw_start();
201195
}
202196
#endif
203197

0 commit comments

Comments
 (0)