hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/powerpc/include/asm/nohash/pgalloc.h
....@@ -3,6 +3,7 @@
33 #define _ASM_POWERPC_NOHASH_PGALLOC_H
44
55 #include <linux/mm.h>
6
+#include <linux/slab.h>
67
78 extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
89 #ifdef CONFIG_PPC64
....@@ -16,9 +17,56 @@
1617 }
1718 #endif /* !CONFIG_PPC_BOOK3E */
1819
20
+static inline pgd_t *pgd_alloc(struct mm_struct *mm)
21
+{
22
+ return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
23
+ pgtable_gfp_flags(mm, GFP_KERNEL));
24
+}
25
+
26
+static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
27
+{
28
+ kmem_cache_free(PGT_CACHE(PGD_INDEX_SIZE), pgd);
29
+}
30
+
1931 #ifdef CONFIG_PPC64
2032 #include <asm/nohash/64/pgalloc.h>
2133 #else
2234 #include <asm/nohash/32/pgalloc.h>
2335 #endif
36
+
37
+static inline void pgtable_free(void *table, int shift)
38
+{
39
+ if (!shift) {
40
+ pte_fragment_free((unsigned long *)table, 0);
41
+ } else {
42
+ BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
43
+ kmem_cache_free(PGT_CACHE(shift), table);
44
+ }
45
+}
46
+
47
+#define get_hugepd_cache_index(x) (x)
48
+
49
+static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
50
+{
51
+ unsigned long pgf = (unsigned long)table;
52
+
53
+ BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
54
+ pgf |= shift;
55
+ tlb_remove_table(tlb, (void *)pgf);
56
+}
57
+
58
+static inline void __tlb_remove_table(void *_table)
59
+{
60
+ void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
61
+ unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
62
+
63
+ pgtable_free(table, shift);
64
+}
65
+
66
+static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
67
+ unsigned long address)
68
+{
69
+ tlb_flush_pgtable(tlb, address);
70
+ pgtable_free_tlb(tlb, table, 0);
71
+}
2472 #endif /* _ASM_POWERPC_NOHASH_PGALLOC_H */