1 #ifndef _X86_TLBFLUSH_H
2 #define _X86_TLBFLUSH_H
5 #include <linux/sched.h>
7 #include <asm/processor.h>
8 #include <asm/system.h>
10 #ifdef CONFIG_PARAVIRT
11 #include <asm/paravirt.h>
13 #define __flush_tlb() __native_flush_tlb()
14 #define __flush_tlb_global() __native_flush_tlb_global()
15 #define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
18 static inline void __native_flush_tlb(void)
20 write_cr3(read_cr3());
23 static inline void __native_flush_tlb_global(void)
25 unsigned long cr4
= read_cr4();
28 write_cr4(cr4
& ~X86_CR4_PGE
);
29 /* write old PGE again and flush TLBs */
33 static inline void __native_flush_tlb_single(unsigned long addr
)
35 __asm__
__volatile__("invlpg (%0)" ::"r" (addr
) : "memory");
38 static inline void __flush_tlb_all(void)
46 static inline void __flush_tlb_one(unsigned long addr
)
49 __flush_tlb_single(addr
);
57 * - flush_tlb() flushes the current mm struct TLBs
58 * - flush_tlb_all() flushes all processes TLBs
59 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
60 * - flush_tlb_page(vma, vmaddr) flushes one page
61 * - flush_tlb_range(vma, start, end) flushes a range of pages
62 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
64 * x86-64 can only flush individual pages or full VMs. For a range flush
65 * we always do the full VM. Might be worth trying if for a small
66 * range a few INVLPGs in a row are a win.
69 #define TLB_FLUSH_ALL -1ULL
73 #define flush_tlb() __flush_tlb()
74 #define flush_tlb_all() __flush_tlb_all()
75 #define local_flush_tlb() __flush_tlb()
77 static inline void flush_tlb_mm(struct mm_struct
*mm
)
79 if (mm
== current
->active_mm
)
83 static inline void flush_tlb_page(struct vm_area_struct
*vma
,
86 if (vma
->vm_mm
== current
->active_mm
)
87 __flush_tlb_one(addr
);
90 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
91 unsigned long start
, unsigned long end
)
93 if (vma
->vm_mm
== current
->active_mm
)
97 static inline void native_flush_tlb_others(const cpumask_t
*cpumask
,
107 #define local_flush_tlb() __flush_tlb()
109 extern void flush_tlb_all(void);
110 extern void flush_tlb_current_task(void);
111 extern void flush_tlb_mm(struct mm_struct
*);
112 extern void flush_tlb_page(struct vm_area_struct
*, unsigned long);
114 #define flush_tlb() flush_tlb_current_task()
116 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
117 unsigned long start
, unsigned long end
)
119 flush_tlb_mm(vma
->vm_mm
);
122 void native_flush_tlb_others(const cpumask_t
*cpumask
, struct mm_struct
*mm
,
125 #define TLBSTATE_OK 1
126 #define TLBSTATE_LAZY 2
130 #ifndef CONFIG_PARAVIRT
131 #define flush_tlb_others(mask, mm, va) native_flush_tlb_others(&mask, mm, va)
134 static inline void flush_tlb_kernel_range(unsigned long start
,
140 #endif /* _X86_TLBFLUSH_H */