1 #ifndef _I386_TLBFLUSH_H
2 #define _I386_TLBFLUSH_H
4 #include <linux/config.h>
6 #include <asm/processor.h>
8 #define __flush_tlb() \
10 unsigned int tmpreg; \
12 __asm__ __volatile__( \
13 "movl %%cr3, %0; \n" \
14 "movl %0, %%cr3; # flush TLB \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 int tmpreg; \
27 __asm__ __volatile__( \
28 "movl %1, %%cr4; # turn off PGE \n" \
29 "movl %%cr3, %0; \n" \
30 "movl %0, %%cr3; # flush TLB \n" \
31 "movl %2, %%cr4; # turn PGE back on \n" \
33 : "r" (mmu_cr4_features & ~X86_CR4_PGE), \
34 "r" (mmu_cr4_features) \
38 extern unsigned long pgkern_mask
;
40 # define __flush_tlb_all() \
43 __flush_tlb_global(); \
48 #define cpu_has_invlpg (boot_cpu_data.x86 > 3)
50 #define __flush_tlb_single(addr) \
51 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr))
53 #ifdef CONFIG_X86_INVLPG
54 # define __flush_tlb_one(addr) __flush_tlb_single(addr)
56 # define __flush_tlb_one(addr) \
59 __flush_tlb_single(addr); \
68 * - flush_tlb() flushes the current mm struct TLBs
69 * - flush_tlb_all() flushes all processes TLBs
70 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
71 * - flush_tlb_page(vma, vmaddr) flushes one page
72 * - flush_tlb_range(vma, start, end) flushes a range of pages
73 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
74 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
76 * ..but the i386 has somewhat limited tlb flushing capabilities,
77 * and page-granular flushes are available only on i486 and up.
82 #define flush_tlb() __flush_tlb()
83 #define flush_tlb_all() __flush_tlb_all()
84 #define local_flush_tlb() __flush_tlb()
86 static inline void flush_tlb_mm(struct mm_struct
*mm
)
88 if (mm
== current
->active_mm
)
92 static inline void flush_tlb_page(struct vm_area_struct
*vma
,
95 if (vma
->vm_mm
== current
->active_mm
)
96 __flush_tlb_one(addr
);
99 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
100 unsigned long start
, unsigned long end
)
102 if (vma
->vm_mm
== current
->active_mm
)
110 #define local_flush_tlb() \
113 extern void flush_tlb_all(void);
114 extern void flush_tlb_current_task(void);
115 extern void flush_tlb_mm(struct mm_struct
*);
116 extern void flush_tlb_page(struct vm_area_struct
*, unsigned long);
118 #define flush_tlb() flush_tlb_current_task()
120 static inline void flush_tlb_range(struct vm_area_struct
* vma
, unsigned long start
, unsigned long end
)
122 flush_tlb_mm(vma
->vm_mm
);
125 #define TLBSTATE_OK 1
126 #define TLBSTATE_LAZY 2
130 struct mm_struct
*active_mm
;
132 char __cacheline_padding
[L1_CACHE_BYTES
-8];
134 DECLARE_PER_CPU(struct tlb_state
, cpu_tlbstate
);
139 #define flush_tlb_kernel_range(start, end) flush_tlb_all()
141 static inline void flush_tlb_pgtables(struct mm_struct
*mm
,
142 unsigned long start
, unsigned long end
)
144 /* i386 does not keep any page table caches in TLB */
147 #endif /* _I386_TLBFLUSH_H */