- Updated to 2.6.22-rc2-git7:
[linux-flexiantxendom0-3.2.10.git] / include / asm-i386 / mach-xen / asm / tlbflush.h
1 #ifndef _I386_TLBFLUSH_H
2 #define _I386_TLBFLUSH_H
3
4 #include <linux/mm.h>
5 #include <asm/processor.h>
6
7 #define __flush_tlb() xen_tlb_flush()
8 #define __flush_tlb_global() xen_tlb_flush()
9 #define __flush_tlb_all() xen_tlb_flush()
10
11 #define cpu_has_invlpg  (boot_cpu_data.x86 > 3)
12
13 #define __flush_tlb_single(addr) xen_invlpg(addr)
14
15 #define __flush_tlb_one(addr) __flush_tlb_single(addr)
16
17 /*
18  * TLB flushing:
19  *
20  *  - flush_tlb() flushes the current mm struct TLBs
21  *  - flush_tlb_all() flushes all processes TLBs
22  *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
23  *  - flush_tlb_page(vma, vmaddr) flushes one page
24  *  - flush_tlb_range(vma, start, end) flushes a range of pages
25  *  - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
26  *  - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
27  *
28  * ..but the i386 has somewhat limited tlb flushing capabilities,
29  * and page-granular flushes are available only on i486 and up.
30  */
31
32 #ifndef CONFIG_SMP
33
34 #define flush_tlb() __flush_tlb()
35 #define flush_tlb_all() __flush_tlb_all()
36 #define local_flush_tlb() __flush_tlb()
37
38 static inline void flush_tlb_mm(struct mm_struct *mm)
39 {
40         if (mm == current->active_mm)
41                 __flush_tlb();
42 }
43
44 static inline void flush_tlb_page(struct vm_area_struct *vma,
45         unsigned long addr)
46 {
47         if (vma->vm_mm == current->active_mm)
48                 __flush_tlb_one(addr);
49 }
50
51 static inline void flush_tlb_range(struct vm_area_struct *vma,
52         unsigned long start, unsigned long end)
53 {
54         if (vma->vm_mm == current->active_mm)
55                 __flush_tlb();
56 }
57
58 #else
59
60 #include <asm/smp.h>
61
62 #define local_flush_tlb() \
63         __flush_tlb()
64
65 extern void flush_tlb_all(void);
66 extern void flush_tlb_current_task(void);
67 extern void flush_tlb_mm(struct mm_struct *);
68 extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
69
70 #define flush_tlb()     flush_tlb_current_task()
71
72 static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
73 {
74         flush_tlb_mm(vma->vm_mm);
75 }
76
77 #define TLBSTATE_OK     1
78 #define TLBSTATE_LAZY   2
79
80 struct tlb_state
81 {
82         struct mm_struct *active_mm;
83         int state;
84         char __cacheline_padding[L1_CACHE_BYTES-8];
85 };
86 DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
87
88
89 #endif
90
91 #define flush_tlb_kernel_range(start, end) flush_tlb_all()
92
93 static inline void flush_tlb_pgtables(struct mm_struct *mm,
94                                       unsigned long start, unsigned long end)
95 {
96         /* i386 does not keep any page table caches in TLB */
97 }
98
99 #endif /* _I386_TLBFLUSH_H */