blob: 7774a1cac0cc42f77ac551d046604d31ee616004 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_IA64_TLBFLUSH_H
2#define _ASM_IA64_TLBFLUSH_H
3
4/*
5 * Copyright (C) 2002 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#include <linux/mm.h>
11
12#include <asm/intrinsics.h>
13#include <asm/mmu_context.h>
14#include <asm/page.h>
15
16/*
17 * Now for some TLB flushing routines. This is the kind of stuff that
18 * can be very expensive, so try to avoid them whenever possible.
19 */
20
21/*
22 * Flush everything (kernel mapping may also have changed due to
23 * vmalloc/vfree).
24 */
25extern void local_flush_tlb_all (void);
26
27#ifdef CONFIG_SMP
28 extern void smp_flush_tlb_all (void);
29 extern void smp_flush_tlb_mm (struct mm_struct *mm);
Jack Steiner3be44b92007-05-08 14:50:43 -070030 extern void smp_flush_tlb_cpumask (cpumask_t xcpumask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031# define flush_tlb_all() smp_flush_tlb_all()
32#else
33# define flush_tlb_all() local_flush_tlb_all()
Jack Steiner3be44b92007-05-08 14:50:43 -070034# define smp_flush_tlb_cpumask(m) local_flush_tlb_all()
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#endif
36
37static inline void
38local_finish_flush_tlb_mm (struct mm_struct *mm)
39{
40 if (mm == current->active_mm)
41 activate_context(mm);
42}
43
44/*
45 * Flush a specified user mapping. This is called, e.g., as a result of fork() and
46 * exit(). fork() ends up here because the copy-on-write mechanism needs to write-protect
47 * the PTEs of the parent task.
48 */
49static inline void
50flush_tlb_mm (struct mm_struct *mm)
51{
52 if (!mm)
53 return;
54
Peter Keiltydcc17d12005-10-31 16:44:47 -050055 set_bit(mm->context, ia64_ctx.flushmap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 mm->context = 0;
57
58 if (atomic_read(&mm->mm_users) == 0)
59 return; /* happens as a result of exit_mmap() */
60
61#ifdef CONFIG_SMP
62 smp_flush_tlb_mm(mm);
63#else
64 local_finish_flush_tlb_mm(mm);
65#endif
66}
67
68extern void flush_tlb_range (struct vm_area_struct *vma, unsigned long start, unsigned long end);
69
70/*
71 * Page-granular tlb flush.
72 */
73static inline void
74flush_tlb_page (struct vm_area_struct *vma, unsigned long addr)
75{
76#ifdef CONFIG_SMP
77 flush_tlb_range(vma, (addr & PAGE_MASK), (addr & PAGE_MASK) + PAGE_SIZE);
78#else
79 if (vma->vm_mm == current->active_mm)
80 ia64_ptcl(addr, (PAGE_SHIFT << 2));
81 else
82 vma->vm_mm->context = 0;
83#endif
84}
85
86/*
Jack Steiner3be44b92007-05-08 14:50:43 -070087 * Flush the local TLB. Invoked from another cpu using an IPI.
88 */
89#ifdef CONFIG_SMP
90void smp_local_flush_tlb(void);
91#else
92#define smp_local_flush_tlb()
93#endif
94
Jan Beulich285fbd62007-12-19 12:30:30 -080095static inline void flush_tlb_kernel_range(unsigned long start,
96 unsigned long end)
97{
98 flush_tlb_all(); /* XXX fix me */
99}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101#endif /* _ASM_IA64_TLBFLUSH_H */