aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86_64/tlbflush.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-x86_64/tlbflush.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-x86_64/tlbflush.h')
-rw-r--r--include/asm-x86_64/tlbflush.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/include/asm-x86_64/tlbflush.h b/include/asm-x86_64/tlbflush.h
new file mode 100644
index 000000000000..2e811ac262af
--- /dev/null
+++ b/include/asm-x86_64/tlbflush.h
@@ -0,0 +1,119 @@
1#ifndef _X8664_TLBFLUSH_H
2#define _X8664_TLBFLUSH_H
3
4#include <linux/config.h>
5#include <linux/mm.h>
6#include <asm/processor.h>
7
8#define __flush_tlb() \
9 do { \
10 unsigned long tmpreg; \
11 \
12 __asm__ __volatile__( \
13 "movq %%cr3, %0; # flush TLB \n" \
14 "movq %0, %%cr3; \n" \
15 : "=r" (tmpreg) \
16 :: "memory"); \
17 } while (0)
18
19/*
20 * Global pages have to be flushed a bit differently. Not a real
21 * performance problem because this does not happen often.
22 */
23#define __flush_tlb_global() \
24 do { \
25 unsigned long tmpreg; \
26 \
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)
37
38extern unsigned long pgkern_mask;
39
40#define __flush_tlb_all() __flush_tlb_global()
41
42#define __flush_tlb_one(addr) \
43 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr))
44
45
46/*
47 * TLB flushing:
48 *
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
56 *
57 * ..but the x86_64 has somewhat limited tlb flushing capabilities,
58 * and page-granular flushes are available only on i486 and up.
59 */
60
61#ifndef CONFIG_SMP
62
63#define flush_tlb() __flush_tlb()
64#define flush_tlb_all() __flush_tlb_all()
65#define local_flush_tlb() __flush_tlb()
66
67static inline void flush_tlb_mm(struct mm_struct *mm)
68{
69 if (mm == current->active_mm)
70 __flush_tlb();
71}
72
73static inline void flush_tlb_page(struct vm_area_struct *vma,
74 unsigned long addr)
75{
76 if (vma->vm_mm == current->active_mm)
77 __flush_tlb_one(addr);
78}
79
80static inline void flush_tlb_range(struct vm_area_struct *vma,
81 unsigned long start, unsigned long end)
82{
83 if (vma->vm_mm == current->active_mm)
84 __flush_tlb();
85}
86
87#else
88
89#include <asm/smp.h>
90
91#define local_flush_tlb() \
92 __flush_tlb()
93
94extern void flush_tlb_all(void);
95extern void flush_tlb_current_task(void);
96extern void flush_tlb_mm(struct mm_struct *);
97extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
98
99#define flush_tlb() flush_tlb_current_task()
100
101static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
102{
103 flush_tlb_mm(vma->vm_mm);
104}
105
106#define TLBSTATE_OK 1
107#define TLBSTATE_LAZY 2
108
109#endif
110
111#define flush_tlb_kernel_range(start, end) flush_tlb_all()
112
113static inline void flush_tlb_pgtables(struct mm_struct *mm,
114 unsigned long start, unsigned long end)
115{
116 /* x86_64 does not keep any page table caches in TLB */
117}
118
119#endif /* _X8664_TLBFLUSH_H */