• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SCORE_TLBFLUSH_H
3 #define _ASM_SCORE_TLBFLUSH_H
4 
5 #include <linux/mm.h>
6 
7 /*
8  * TLB flushing:
9  *
10  * - flush_tlb_all() flushes all processes TLB entries
11  * - flush_tlb_mm(mm) flushes the specified mm context TLB entries
12  * - flush_tlb_page(vma, vmaddr) flushes one page
13  * - flush_tlb_range(vma, start, end) flushes a range of pages
14  * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
15  */
16 extern void local_flush_tlb_all(void);
17 extern void local_flush_tlb_mm(struct mm_struct *mm);
18 extern void local_flush_tlb_range(struct vm_area_struct *vma,
19 	unsigned long start, unsigned long end);
20 extern void local_flush_tlb_kernel_range(unsigned long start,
21 	unsigned long end);
22 extern void local_flush_tlb_page(struct vm_area_struct *vma,
23 	unsigned long page);
24 extern void local_flush_tlb_one(unsigned long vaddr);
25 
26 #define flush_tlb_all()			local_flush_tlb_all()
27 #define flush_tlb_mm(mm)		local_flush_tlb_mm(mm)
28 #define flush_tlb_range(vma, vmaddr, end) \
29 	local_flush_tlb_range(vma, vmaddr, end)
30 #define flush_tlb_kernel_range(vmaddr, end) \
31 	local_flush_tlb_kernel_range(vmaddr, end)
32 #define flush_tlb_page(vma, page)	local_flush_tlb_page(vma, page)
33 #define flush_tlb_one(vaddr)		local_flush_tlb_one(vaddr)
34 
35 #ifndef __ASSEMBLY__
36 
pevn_get(void)37 static inline unsigned long pevn_get(void)
38 {
39 	unsigned long val;
40 
41 	__asm__ __volatile__(
42 		"mfcr %0, cr11\n"
43 		"nop\nnop\n"
44 		: "=r" (val));
45 
46 	return val;
47 }
48 
pevn_set(unsigned long val)49 static inline void pevn_set(unsigned long val)
50 {
51 	__asm__ __volatile__(
52 		"mtcr %0, cr11\n"
53 		"nop\nnop\nnop\nnop\nnop\n"
54 	: : "r" (val));
55 }
56 
pectx_set(unsigned long val)57 static inline void pectx_set(unsigned long val)
58 {
59 	__asm__ __volatile__(
60 		"mtcr %0, cr12\n"
61 		"nop\nnop\nnop\nnop\nnop\n"
62 	: : "r" (val));
63 }
64 
pectx_get(void)65 static inline unsigned long pectx_get(void)
66 {
67 	unsigned long val;
68 	__asm__ __volatile__(
69 		"mfcr %0, cr12\n"
70 		"nop\nnop\n"
71 	: "=r" (val));
72 	return val;
73 }
tlblock_get(void)74 static inline unsigned long tlblock_get(void)
75 {
76 	unsigned long val;
77 
78 	__asm__ __volatile__(
79 		"mfcr %0, cr7\n"
80 		"nop\nnop\n"
81 	: "=r" (val));
82 	return val;
83 }
tlblock_set(unsigned long val)84 static inline void tlblock_set(unsigned long val)
85 {
86 	__asm__ __volatile__(
87 		"mtcr %0, cr7\n"
88 		"nop\nnop\nnop\nnop\nnop\n"
89 	: : "r" (val));
90 }
91 
tlbpt_set(unsigned long val)92 static inline void tlbpt_set(unsigned long val)
93 {
94 	__asm__ __volatile__(
95 		"mtcr %0, cr8\n"
96 		"nop\nnop\nnop\nnop\nnop\n"
97 		: : "r" (val));
98 }
99 
tlbpt_get(void)100 static inline long tlbpt_get(void)
101 {
102 	long val;
103 
104 	__asm__ __volatile__(
105 		"mfcr %0, cr8\n"
106 		"nop\nnop\n"
107 		: "=r" (val));
108 
109 	return val;
110 }
111 
peaddr_set(unsigned long val)112 static inline void peaddr_set(unsigned long val)
113 {
114 	__asm__ __volatile__(
115 		"mtcr %0, cr9\n"
116 		"nop\nnop\nnop\nnop\nnop\n"
117 		: : "r" (val));
118 }
119 
120 /* TLB operations. */
tlb_probe(void)121 static inline void tlb_probe(void)
122 {
123 	__asm__ __volatile__("stlb;nop;nop;nop;nop;nop");
124 }
125 
tlb_read(void)126 static inline void tlb_read(void)
127 {
128 	__asm__ __volatile__("mftlb;nop;nop;nop;nop;nop");
129 }
130 
tlb_write_indexed(void)131 static inline void tlb_write_indexed(void)
132 {
133 	__asm__ __volatile__("mtptlb;nop;nop;nop;nop;nop");
134 }
135 
tlb_write_random(void)136 static inline void tlb_write_random(void)
137 {
138 	__asm__ __volatile__("mtrtlb;nop;nop;nop;nop;nop");
139 }
140 
141 #endif /* Not __ASSEMBLY__ */
142 
143 #endif /* _ASM_SCORE_TLBFLUSH_H */
144