x86/fsgsbase/64: Factor out FS/GS segment loading from __switch_to()
Instead of open coding the calls to load_seg_legacy(), introduce x86_fsgsbase_load() to load FS/GS segments. This makes it more explicit that this is part of FSGSBASE functionality, and the new helper can be updated when FSGSBASE instructions are enabled. [ mingo: Wrote new changelog. ] Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> Reviewed-by: Andi Kleen <ak@linux.intel.com> Reviewed-by: Andy Lutomirski <luto@kernel.org> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Markus T Metzger <markus.t.metzger@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Shankar <ravi.v.shankar@intel.com> Cc: Rik van Riel <riel@surriel.com> Link: http://lkml.kernel.org/r/1537312139-5580-6-git-send-email-chang.seok.bae@intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
824eea38d2
commit
f4550b52e4
@ -287,6 +287,15 @@ static __always_inline void load_seg_legacy(unsigned short prev_index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __always_inline void x86_fsgsbase_load(struct thread_struct *prev,
|
||||||
|
struct thread_struct *next)
|
||||||
|
{
|
||||||
|
load_seg_legacy(prev->fsindex, prev->fsbase,
|
||||||
|
next->fsindex, next->fsbase, FS);
|
||||||
|
load_seg_legacy(prev->gsindex, prev->gsbase,
|
||||||
|
next->gsindex, next->gsbase, GS);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned long x86_fsgsbase_read_task(struct task_struct *task,
|
static unsigned long x86_fsgsbase_read_task(struct task_struct *task,
|
||||||
unsigned short selector)
|
unsigned short selector)
|
||||||
{
|
{
|
||||||
@ -597,10 +606,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
|
|||||||
if (unlikely(next->ds | prev->ds))
|
if (unlikely(next->ds | prev->ds))
|
||||||
loadsegment(ds, next->ds);
|
loadsegment(ds, next->ds);
|
||||||
|
|
||||||
load_seg_legacy(prev->fsindex, prev->fsbase,
|
x86_fsgsbase_load(prev, next);
|
||||||
next->fsindex, next->fsbase, FS);
|
|
||||||
load_seg_legacy(prev->gsindex, prev->gsbase,
|
|
||||||
next->gsindex, next->gsbase, GS);
|
|
||||||
|
|
||||||
switch_fpu_finish(next_fpu, cpu);
|
switch_fpu_finish(next_fpu, cpu);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user