lkml.org 
[lkml]   [2019]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 11/17] parisc/tlb: Fix __p*_free_tlb()
Just like regular pages, page directories need to observe the
following order:

1) unhook
2) TLB invalidate
3) free

to ensure it is safe against concurrent accesses.

Because PARISC has non-page-size PMDs, use a custom table freeer.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/parisc/Kconfig | 1 +
arch/parisc/include/asm/pgalloc.h | 25 ++++++++++++++++++++++---
arch/parisc/include/asm/tlb.h | 7 +++++--
3 files changed, 28 insertions(+), 5 deletions(-)

--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -62,6 +62,7 @@ config PARISC
select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE
select HAVE_KPROBES_ON_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_REGS
+ select MMU_GATHER_TABLE_FREE if PGTABLE_LEVELS >= 3

help
The PA-RISC microprocessor is designed by Hewlett-Packard and used
--- a/arch/parisc/include/asm/pgalloc.h
+++ b/arch/parisc/include/asm/pgalloc.h
@@ -73,7 +73,7 @@ static inline pmd_t *pmd_alloc_one(struc
return pmd;
}

-static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
+static inline bool __pmd_free(struct mm_struct *mm, pmd_t *pmd)
{
if (pmd_flag(*pmd) & PxD_FLAG_ATTACHED) {
/*
@@ -83,11 +83,28 @@ static inline void pmd_free(struct mm_st
* done by generic mm code.
*/
mm_inc_nr_pmds(mm);
- return;
+ return false;
}
- free_pages((unsigned long)pmd, PMD_ORDER);
+ return true;
+}
+
+static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
+{
+ if (__pmd_free(mm, pmd))
+ free_pages((unsigned long)pmd, PMD_ORDER);
}

+static inline void __tlb_remove_table(void *table)
+{
+ free_pages((unsigned long)table, PMD_ORDER);
+}
+
+#define __pmd_free_tlb(tlb, pmd, addr) \
+do { \
+ if (__pmd_free((tlb)->mm, (pmd))) \
+ tlb_remove_table((tlb), (pmd)); \
+} while (0)
+
#else

/* Two Level Page Table Support for pmd's */
@@ -101,6 +118,8 @@ static inline void pmd_free(struct mm_st
#define pmd_free(mm, x) do { } while (0)
#define pgd_populate(mm, pmd, pte) BUG()

+#define __pmd_free_tlb(tlb, pmd, addr) do { } while (0)
+
#endif

static inline void
--- a/arch/parisc/include/asm/tlb.h
+++ b/arch/parisc/include/asm/tlb.h
@@ -4,7 +4,10 @@

#include <asm-generic/tlb.h>

-#define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd)
-#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte)
+#define __pte_free_tlb(tlb,pte,addr) \
+do { \
+ pgtable_pte_page_dtor(pte); \
+ tlb_remove_page((tlb), (pte)); \
+} while (0)

#endif

\
 
 \ /
  Last update: 2019-12-11 13:32    [W:0.135 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site