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