5 #include <asm/atomic.h>
6 #include <asm/pgalloc.h>
7 #include <asm/tlbflush.h>
8 #include <asm/paravirt.h>
9 #ifndef CONFIG_PARAVIRT
10 #include <asm-generic/mm_hooks.h>
12 static inline void paravirt_activate_mm(struct mm_struct
*prev
,
13 struct mm_struct
*next
)
16 #endif /* !CONFIG_PARAVIRT */
20 * Used for LDT copy/destruction.
22 int init_new_context(struct task_struct
*tsk
, struct mm_struct
*mm
);
23 void destroy_context(struct mm_struct
*mm
);
26 static inline void enter_lazy_tlb(struct mm_struct
*mm
, struct task_struct
*tsk
)
29 unsigned cpu
= smp_processor_id();
30 if (per_cpu(cpu_tlbstate
, cpu
).state
== TLBSTATE_OK
)
31 per_cpu(cpu_tlbstate
, cpu
).state
= TLBSTATE_LAZY
;
35 void leave_mm(unsigned long cpu
);
37 static inline void switch_mm(struct mm_struct
*prev
,
38 struct mm_struct
*next
,
39 struct task_struct
*tsk
)
41 int cpu
= smp_processor_id();
43 if (likely(prev
!= next
)) {
44 /* stop flush ipis for the previous mm */
45 cpu_clear(cpu
, prev
->cpu_vm_mask
);
47 per_cpu(cpu_tlbstate
, cpu
).state
= TLBSTATE_OK
;
48 per_cpu(cpu_tlbstate
, cpu
).active_mm
= next
;
50 cpu_set(cpu
, next
->cpu_vm_mask
);
52 /* Re-load page tables */
56 * load the LDT, if the LDT is different:
58 if (unlikely(prev
->context
.ldt
!= next
->context
.ldt
))
59 load_LDT_nolock(&next
->context
);
63 per_cpu(cpu_tlbstate
, cpu
).state
= TLBSTATE_OK
;
64 BUG_ON(per_cpu(cpu_tlbstate
, cpu
).active_mm
!= next
);
66 if (!cpu_test_and_set(cpu
, next
->cpu_vm_mask
)) {
67 /* We were in lazy tlb mode and leave_mm disabled
68 * tlb flush IPI delivery. We must reload %cr3.
71 load_LDT_nolock(&next
->context
);
77 #define deactivate_mm(tsk, mm) \
78 asm("movl %0,%%gs": :"r" (0));
80 #define activate_mm(prev, next) \
82 paravirt_activate_mm(prev, next); \
83 switch_mm((prev),(next),NULL); \