[TG3]: Add tagged status support.
[linux-2.6/verdex.git] / include / asm-x86_64 / tlbflush.h
blob2e811ac262af78062c2ffb661bfa9eef3815b824
1 #ifndef _X8664_TLBFLUSH_H
2 #define _X8664_TLBFLUSH_H
4 #include <linux/config.h>
5 #include <linux/mm.h>
6 #include <asm/processor.h>
8 #define __flush_tlb() \
9 do { \
10 unsigned long tmpreg; \
12 __asm__ __volatile__( \
13 "movq %%cr3, %0; # flush TLB \n" \
14 "movq %0, %%cr3; \n" \
15 : "=r" (tmpreg) \
16 :: "memory"); \
17 } while (0)
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() \
24 do { \
25 unsigned long tmpreg; \
27 __asm__ __volatile__( \
28 "movq %1, %%cr4; # turn off PGE \n" \
29 "movq %%cr3, %0; # flush TLB \n" \
30 "movq %0, %%cr3; \n" \
31 "movq %2, %%cr4; # turn PGE back on \n" \
32 : "=&r" (tmpreg) \
33 : "r" (mmu_cr4_features & ~X86_CR4_PGE), \
34 "r" (mmu_cr4_features) \
35 : "memory"); \
36 } while (0)
38 extern unsigned long pgkern_mask;
40 #define __flush_tlb_all() __flush_tlb_global()
42 #define __flush_tlb_one(addr) \
43 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr))
47 * TLB flushing:
49 * - flush_tlb() flushes the current mm struct TLBs
50 * - flush_tlb_all() flushes all processes TLBs
51 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
52 * - flush_tlb_page(vma, vmaddr) flushes one page
53 * - flush_tlb_range(vma, start, end) flushes a range of pages
54 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
55 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
57 * ..but the x86_64 has somewhat limited tlb flushing capabilities,
58 * and page-granular flushes are available only on i486 and up.
61 #ifndef CONFIG_SMP
63 #define flush_tlb() __flush_tlb()
64 #define flush_tlb_all() __flush_tlb_all()
65 #define local_flush_tlb() __flush_tlb()
67 static inline void flush_tlb_mm(struct mm_struct *mm)
69 if (mm == current->active_mm)
70 __flush_tlb();
73 static inline void flush_tlb_page(struct vm_area_struct *vma,
74 unsigned long addr)
76 if (vma->vm_mm == current->active_mm)
77 __flush_tlb_one(addr);
80 static inline void flush_tlb_range(struct vm_area_struct *vma,
81 unsigned long start, unsigned long end)
83 if (vma->vm_mm == current->active_mm)
84 __flush_tlb();
87 #else
89 #include <asm/smp.h>
91 #define local_flush_tlb() \
92 __flush_tlb()
94 extern void flush_tlb_all(void);
95 extern void flush_tlb_current_task(void);
96 extern void flush_tlb_mm(struct mm_struct *);
97 extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
99 #define flush_tlb() flush_tlb_current_task()
101 static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
103 flush_tlb_mm(vma->vm_mm);
106 #define TLBSTATE_OK 1
107 #define TLBSTATE_LAZY 2
109 #endif
111 #define flush_tlb_kernel_range(start, end) flush_tlb_all()
113 static inline void flush_tlb_pgtables(struct mm_struct *mm,
114 unsigned long start, unsigned long end)
116 /* x86_64 does not keep any page table caches in TLB */
119 #endif /* _X8664_TLBFLUSH_H */