]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/asm-x86_64/tlbflush.h
1 #ifndef _X8664_TLBFLUSH_H
2 #define _X8664_TLBFLUSH_H
4 #include <linux/config.h>
6 #include <asm/processor.h>
8 #define __flush_tlb() \
10 unsigned long tmpreg; \
12 __asm__ __volatile__( \
13 "movq %%cr3, %0; # flush TLB \n" \
14 "movq %0, %%cr3; \n" \
20 * Global pages have to be flushed a bit differently. Not a real
21 * performance problem because this does not happen often.
23 #define __flush_tlb_global() \
25 unsigned long tmpreg, cr4, cr4_orig; \
27 __asm__ __volatile__( \
28 "movq %%cr4, %2; # turn off PGE \n" \
31 "movq %1, %%cr4; \n" \
32 "movq %%cr3, %0; # flush TLB \n" \
33 "movq %0, %%cr3; \n" \
34 "movq %2, %%cr4; # turn PGE back on \n" \
35 : "=&r" (tmpreg), "=&r" (cr4), "=&r" (cr4_orig) \
36 : "i" (~X86_CR4_PGE) \
40 extern unsigned long pgkern_mask
;
42 #define __flush_tlb_all() __flush_tlb_global()
44 #define __flush_tlb_one(addr) \
45 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr))
51 * - flush_tlb() flushes the current mm struct TLBs
52 * - flush_tlb_all() flushes all processes TLBs
53 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
54 * - flush_tlb_page(vma, vmaddr) flushes one page
55 * - flush_tlb_range(vma, start, end) flushes a range of pages
56 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
57 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
59 * x86-64 can only flush individual pages or full VMs. For a range flush
60 * we always do the full VM. Might be worth trying if for a small
61 * range a few INVLPGs in a row are a win.
66 #define flush_tlb() __flush_tlb()
67 #define flush_tlb_all() __flush_tlb_all()
68 #define local_flush_tlb() __flush_tlb()
70 static inline void flush_tlb_mm(struct mm_struct
*mm
)
72 if (mm
== current
->active_mm
)
76 static inline void flush_tlb_page(struct vm_area_struct
*vma
,
79 if (vma
->vm_mm
== current
->active_mm
)
80 __flush_tlb_one(addr
);
83 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
84 unsigned long start
, unsigned long end
)
86 if (vma
->vm_mm
== current
->active_mm
)
94 #define local_flush_tlb() \
97 extern void flush_tlb_all(void);
98 extern void flush_tlb_current_task(void);
99 extern void flush_tlb_mm(struct mm_struct
*);
100 extern void flush_tlb_page(struct vm_area_struct
*, unsigned long);
102 #define flush_tlb() flush_tlb_current_task()
104 static inline void flush_tlb_range(struct vm_area_struct
* vma
, unsigned long start
, unsigned long end
)
106 flush_tlb_mm(vma
->vm_mm
);
109 #define TLBSTATE_OK 1
110 #define TLBSTATE_LAZY 2
114 #define flush_tlb_kernel_range(start, end) flush_tlb_all()
116 static inline void flush_tlb_pgtables(struct mm_struct
*mm
,
117 unsigned long start
, unsigned long end
)
119 /* x86_64 does not keep any page table caches in a software TLB.
120 The CPUs do in their hardware TLBs, but they are handled
121 by the normal TLB flushing algorithms. */
124 #endif /* _X8664_TLBFLUSH_H */