Commit 39a0526f authored by Dave Hansen's avatar Dave Hansen Committed by Ingo Molnar

x86/mm: Factor out LDT init from context init

The arch-specific mm_context_t is a great place to put
protection-key allocation state.

But, we need to initialize the allocation state because pkey 0 is
always "allocated".  All of the runtime initialization of
mm_context_t is done in *_ldt() manipulation functions.  This
renames the existing LDT functions like this:

	init_new_context() -> init_new_context_ldt()
	destroy_context() -> destroy_context_ldt()

and makes init_new_context() and destroy_context() available for
generic use.
Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave@sr71.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/20160212210234.DB34FCC5@viggo.jf.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 66d37570
...@@ -52,15 +52,15 @@ struct ldt_struct { ...@@ -52,15 +52,15 @@ struct ldt_struct {
/* /*
* Used for LDT copy/destruction. * Used for LDT copy/destruction.
*/ */
int init_new_context(struct task_struct *tsk, struct mm_struct *mm); int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm);
void destroy_context(struct mm_struct *mm); void destroy_context_ldt(struct mm_struct *mm);
#else /* CONFIG_MODIFY_LDT_SYSCALL */ #else /* CONFIG_MODIFY_LDT_SYSCALL */
static inline int init_new_context(struct task_struct *tsk, static inline int init_new_context_ldt(struct task_struct *tsk,
struct mm_struct *mm) struct mm_struct *mm)
{ {
return 0; return 0;
} }
static inline void destroy_context(struct mm_struct *mm) {} static inline void destroy_context_ldt(struct mm_struct *mm) {}
#endif #endif
static inline void load_mm_ldt(struct mm_struct *mm) static inline void load_mm_ldt(struct mm_struct *mm)
...@@ -104,6 +104,17 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) ...@@ -104,6 +104,17 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
#endif #endif
} }
static inline int init_new_context(struct task_struct *tsk,
struct mm_struct *mm)
{
init_new_context_ldt(tsk, mm);
return 0;
}
static inline void destroy_context(struct mm_struct *mm)
{
destroy_context_ldt(mm);
}
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
struct task_struct *tsk) struct task_struct *tsk)
{ {
......
...@@ -103,7 +103,7 @@ static void free_ldt_struct(struct ldt_struct *ldt) ...@@ -103,7 +103,7 @@ static void free_ldt_struct(struct ldt_struct *ldt)
* we do not have to muck with descriptors here, that is * we do not have to muck with descriptors here, that is
* done in switch_mm() as needed. * done in switch_mm() as needed.
*/ */
int init_new_context(struct task_struct *tsk, struct mm_struct *mm) int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm)
{ {
struct ldt_struct *new_ldt; struct ldt_struct *new_ldt;
struct mm_struct *old_mm; struct mm_struct *old_mm;
...@@ -144,7 +144,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) ...@@ -144,7 +144,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
* *
* 64bit: Don't touch the LDT register - we're already in the next thread. * 64bit: Don't touch the LDT register - we're already in the next thread.
*/ */
void destroy_context(struct mm_struct *mm) void destroy_context_ldt(struct mm_struct *mm)
{ {
free_ldt_struct(mm->context.ldt); free_ldt_struct(mm->context.ldt);
mm->context.ldt = NULL; mm->context.ldt = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment