[MIPS] Fix another trap decoding issue
[linux-2.6/linux-mips/linux-dm7025.git] / include / asm-x86 / tlbflush.h
blob0c0674d9425559408fba244df6240760bf5cbcf9
1 #ifndef _ASM_X86_TLBFLUSH_H
2 #define _ASM_X86_TLBFLUSH_H
4 #include <linux/mm.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>
12 #else
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)
16 #endif
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();
27 /* clear PGE */
28 write_cr4(cr4 & ~X86_CR4_PGE);
29 /* write old PGE again and flush TLBs */
30 write_cr4(cr4);
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)
40 if (cpu_has_pge)
41 __flush_tlb_global();
42 else
43 __flush_tlb();
46 static inline void __flush_tlb_one(unsigned long addr)
48 if (cpu_has_invlpg)
49 __flush_tlb_single(addr);
50 else
51 __flush_tlb();
54 #ifdef CONFIG_X86_32
55 # define TLB_FLUSH_ALL 0xffffffff
56 #else
57 # define TLB_FLUSH_ALL -1ULL
58 #endif
61 * TLB flushing:
63 * - flush_tlb() flushes the current mm struct TLBs
64 * - flush_tlb_all() flushes all processes TLBs
65 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
66 * - flush_tlb_page(vma, vmaddr) flushes one page
67 * - flush_tlb_range(vma, start, end) flushes a range of pages
68 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
69 * - flush_tlb_others(cpumask, mm, va) flushes TLBs on other cpus
71 * ..but the i386 has somewhat limited tlb flushing capabilities,
72 * and page-granular flushes are available only on i486 and up.
74 * x86-64 can only flush individual pages or full VMs. For a range flush
75 * we always do the full VM. Might be worth trying if for a small
76 * range a few INVLPGs in a row are a win.
79 #ifndef CONFIG_SMP
81 #define flush_tlb() __flush_tlb()
82 #define flush_tlb_all() __flush_tlb_all()
83 #define local_flush_tlb() __flush_tlb()
85 static inline void flush_tlb_mm(struct mm_struct *mm)
87 if (mm == current->active_mm)
88 __flush_tlb();
91 static inline void flush_tlb_page(struct vm_area_struct *vma,
92 unsigned long addr)
94 if (vma->vm_mm == current->active_mm)
95 __flush_tlb_one(addr);
98 static inline void flush_tlb_range(struct vm_area_struct *vma,
99 unsigned long start, unsigned long end)
101 if (vma->vm_mm == current->active_mm)
102 __flush_tlb();
105 static inline void native_flush_tlb_others(const cpumask_t *cpumask,
106 struct mm_struct *mm,
107 unsigned long va)
111 #else /* SMP */
113 #include <asm/smp.h>
115 #define local_flush_tlb() __flush_tlb()
117 extern void flush_tlb_all(void);
118 extern void flush_tlb_current_task(void);
119 extern void flush_tlb_mm(struct mm_struct *);
120 extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
122 #define flush_tlb() flush_tlb_current_task()
124 static inline void flush_tlb_range(struct vm_area_struct *vma,
125 unsigned long start, unsigned long end)
127 flush_tlb_mm(vma->vm_mm);
130 void native_flush_tlb_others(const cpumask_t *cpumask, struct mm_struct *mm,
131 unsigned long va);
133 #define TLBSTATE_OK 1
134 #define TLBSTATE_LAZY 2
136 #ifdef CONFIG_X86_32
137 struct tlb_state {
138 struct mm_struct *active_mm;
139 int state;
140 char __cacheline_padding[L1_CACHE_BYTES-8];
142 DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
143 #endif
145 #endif /* SMP */
147 #ifndef CONFIG_PARAVIRT
148 #define flush_tlb_others(mask, mm, va) native_flush_tlb_others(&mask, mm, va)
149 #endif
151 static inline void flush_tlb_kernel_range(unsigned long start,
152 unsigned long end)
154 flush_tlb_all();
157 #endif /* _ASM_X86_TLBFLUSH_H */