]>
git.proxmox.com Git - mirror_ubuntu-kernels.git/blob - arch/s390/include/asm/tlb.h
5 * TLB flushing on s390 is complicated. The following requirement
6 * from the principles of operation is the most arduous:
8 * "A valid table entry must not be changed while it is attached
9 * to any CPU and may be used for translation by that CPU except to
10 * (1) invalidate the entry by using INVALIDATE PAGE TABLE ENTRY,
11 * or INVALIDATE DAT TABLE ENTRY, (2) alter bits 56-63 of a page
12 * table entry, or (3) make a change by means of a COMPARE AND SWAP
13 * AND PURGE instruction that purges the TLB."
15 * The modification of a pte of an active mm struct therefore is
16 * a two step process: i) invalidate the pte, ii) store the new pte.
17 * This is true for the page protection bit as well.
18 * The only possible optimization is to flush at the beginning of
19 * a tlb_gather_mmu cycle if the mm_struct is currently not in use.
21 * Pages used for the page tables is a different story. FIXME: more
25 #include <linux/pagemap.h>
26 #include <linux/swap.h>
27 #include <asm/processor.h>
28 #include <asm/pgalloc.h>
30 #include <asm/tlbflush.h>
42 static inline void __tlb_alloc_page(struct mmu_gather
*tlb
)
44 unsigned long addr
= __get_free_pages(GFP_NOWAIT
| __GFP_NOWARN
, 0);
47 tlb
->array
= (void *) addr
;
48 tlb
->max
= PAGE_SIZE
/ sizeof(void *);
52 static inline void tlb_gather_mmu(struct mmu_gather
*tlb
,
54 unsigned int full_mm_flush
)
57 tlb
->max
= ARRAY_SIZE(tlb
->local
);
58 tlb
->array
= tlb
->local
;
59 tlb
->fullmm
= full_mm_flush
;
63 __tlb_alloc_page(tlb
);
65 tlb
->nr_pxds
= tlb
->max
;
68 static inline void tlb_flush_mmu(struct mmu_gather
*tlb
)
70 if (!tlb
->fullmm
&& (tlb
->nr_ptes
> 0 || tlb
->nr_pxds
< tlb
->max
))
71 __tlb_flush_mm(tlb
->mm
);
72 while (tlb
->nr_ptes
> 0)
73 page_table_free_rcu(tlb
->mm
, tlb
->array
[--tlb
->nr_ptes
]);
74 while (tlb
->nr_pxds
< tlb
->max
)
75 crst_table_free_rcu(tlb
->mm
, tlb
->array
[tlb
->nr_pxds
++]);
78 static inline void tlb_finish_mmu(struct mmu_gather
*tlb
,
79 unsigned long start
, unsigned long end
)
83 rcu_table_freelist_finish();
85 /* keep the page table cache within bounds */
88 if (tlb
->array
!= tlb
->local
)
89 free_pages((unsigned long) tlb
->array
, 0);
93 * Release the page cache reference for a pte removed by
94 * tlb_ptep_clear_flush. In both flush modes the tlb for a page cache page
95 * has already been freed, so just do free_page_and_swap_cache.
97 static inline int __tlb_remove_page(struct mmu_gather
*tlb
, struct page
*page
)
99 free_page_and_swap_cache(page
);
100 return 1; /* avoid calling tlb_flush_mmu */
103 static inline void tlb_remove_page(struct mmu_gather
*tlb
, struct page
*page
)
105 free_page_and_swap_cache(page
);
109 * pte_free_tlb frees a pte table and clears the CRSTE for the
110 * page table from the tlb.
112 static inline void pte_free_tlb(struct mmu_gather
*tlb
, pgtable_t pte
,
113 unsigned long address
)
116 tlb
->array
[tlb
->nr_ptes
++] = pte
;
117 if (tlb
->nr_ptes
>= tlb
->nr_pxds
)
120 page_table_free(tlb
->mm
, (unsigned long *) pte
);
124 * pmd_free_tlb frees a pmd table and clears the CRSTE for the
125 * segment table entry from the tlb.
126 * If the mm uses a two level page table the single pmd is freed
127 * as the pgd. pmd_free_tlb checks the asce_limit against 2GB
128 * to avoid the double free of the pmd in this case.
130 static inline void pmd_free_tlb(struct mmu_gather
*tlb
, pmd_t
*pmd
,
131 unsigned long address
)
134 if (tlb
->mm
->context
.asce_limit
<= (1UL << 31))
137 tlb
->array
[--tlb
->nr_pxds
] = pmd
;
138 if (tlb
->nr_ptes
>= tlb
->nr_pxds
)
141 crst_table_free(tlb
->mm
, (unsigned long *) pmd
);
146 * pud_free_tlb frees a pud table and clears the CRSTE for the
147 * region third table entry from the tlb.
148 * If the mm uses a three level page table the single pud is freed
149 * as the pgd. pud_free_tlb checks the asce_limit against 4TB
150 * to avoid the double free of the pud in this case.
152 static inline void pud_free_tlb(struct mmu_gather
*tlb
, pud_t
*pud
,
153 unsigned long address
)
156 if (tlb
->mm
->context
.asce_limit
<= (1UL << 42))
159 tlb
->array
[--tlb
->nr_pxds
] = pud
;
160 if (tlb
->nr_ptes
>= tlb
->nr_pxds
)
163 crst_table_free(tlb
->mm
, (unsigned long *) pud
);
167 #define tlb_start_vma(tlb, vma) do { } while (0)
168 #define tlb_end_vma(tlb, vma) do { } while (0)
169 #define tlb_remove_tlb_entry(tlb, ptep, addr) do { } while (0)
170 #define tlb_migrate_finish(mm) do { } while (0)
172 #endif /* _S390_TLB_H */