2008-10-23 05:26:29 +00:00
|
|
|
#ifndef _ASM_X86_MMU_CONTEXT_32_H
|
|
|
|
#define _ASM_X86_MMU_CONTEXT_32_H
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
2008-12-16 11:46:58 +00:00
|
|
|
if (x86_read_percpu(cpu_tlbstate.state) == TLBSTATE_OK)
|
|
|
|
x86_write_percpu(cpu_tlbstate.state, TLBSTATE_LAZY);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void switch_mm(struct mm_struct *prev,
|
|
|
|
struct mm_struct *next,
|
|
|
|
struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
int cpu = smp_processor_id();
|
|
|
|
|
|
|
|
if (likely(prev != next)) {
|
|
|
|
/* stop flush ipis for the previous mm */
|
|
|
|
cpu_clear(cpu, prev->cpu_vm_mask);
|
|
|
|
#ifdef CONFIG_SMP
|
2008-12-16 11:46:58 +00:00
|
|
|
x86_write_percpu(cpu_tlbstate.state, TLBSTATE_OK);
|
|
|
|
x86_write_percpu(cpu_tlbstate.active_mm, next);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
cpu_set(cpu, next->cpu_vm_mask);
|
|
|
|
|
|
|
|
/* Re-load page tables */
|
|
|
|
load_cr3(next->pgd);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* load the LDT, if the LDT is different:
|
|
|
|
*/
|
|
|
|
if (unlikely(prev->context.ldt != next->context.ldt))
|
2006-12-07 01:14:01 +00:00
|
|
|
load_LDT_nolock(&next->context);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
else {
|
2008-12-16 11:46:58 +00:00
|
|
|
x86_write_percpu(cpu_tlbstate.state, TLBSTATE_OK);
|
|
|
|
BUG_ON(x86_read_percpu(cpu_tlbstate.active_mm) != next);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
|
2008-03-23 08:02:42 +00:00
|
|
|
/* We were in lazy tlb mode and leave_mm disabled
|
2005-04-16 22:20:36 +00:00
|
|
|
* tlb flush IPI delivery. We must reload %cr3.
|
|
|
|
*/
|
|
|
|
load_cr3(next->pgd);
|
2006-12-07 01:14:01 +00:00
|
|
|
load_LDT_nolock(&next->context);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
[PATCH] i386: Use %gs as the PDA base-segment in the kernel
This patch is the meat of the PDA change. This patch makes several related
changes:
1: Most significantly, %gs is now used in the kernel. This means that on
entry, the old value of %gs is saved away, and it is reloaded with
__KERNEL_PDA.
2: entry.S constructs the stack in the shape of struct pt_regs, and this
is passed around the kernel so that the process's saved register
state can be accessed.
Unfortunately struct pt_regs doesn't currently have space for %gs
(or %fs). This patch extends pt_regs to add space for gs (no space
is allocated for %fs, since it won't be used, and it would just
complicate the code in entry.S to work around the space).
3: Because %gs is now saved on the stack like %ds, %es and the integer
registers, there are a number of places where it no longer needs to
be handled specially; namely context switch, and saving/restoring the
register state in a signal context.
4: And since kernel threads run in kernel space and call normal kernel
code, they need to be created with their %gs == __KERNEL_PDA.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
2006-12-07 01:14:02 +00:00
|
|
|
#define deactivate_mm(tsk, mm) \
|
2007-02-13 12:26:20 +00:00
|
|
|
asm("movl %0,%%gs": :"r" (0));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-23 05:26:29 +00:00
|
|
|
#endif /* _ASM_X86_MMU_CONTEXT_32_H */
|