Skip to content

Commit 39a0526

Browse files
hansendcIngo Molnar
authored and
Ingo Molnar
committed
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: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Thomas 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.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 66d3757 commit 39a0526

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

arch/x86/include/asm/mmu_context.h

+16-5
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ struct ldt_struct {
5252
/*
5353
* Used for LDT copy/destruction.
5454
*/
55-
int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
56-
void destroy_context(struct mm_struct *mm);
55+
int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm);
56+
void destroy_context_ldt(struct mm_struct *mm);
5757
#else /* CONFIG_MODIFY_LDT_SYSCALL */
58-
static inline int init_new_context(struct task_struct *tsk,
59-
struct mm_struct *mm)
58+
static inline int init_new_context_ldt(struct task_struct *tsk,
59+
struct mm_struct *mm)
6060
{
6161
return 0;
6262
}
63-
static inline void destroy_context(struct mm_struct *mm) {}
63+
static inline void destroy_context_ldt(struct mm_struct *mm) {}
6464
#endif
6565

6666
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)
104104
#endif
105105
}
106106

107+
static inline int init_new_context(struct task_struct *tsk,
108+
struct mm_struct *mm)
109+
{
110+
init_new_context_ldt(tsk, mm);
111+
return 0;
112+
}
113+
static inline void destroy_context(struct mm_struct *mm)
114+
{
115+
destroy_context_ldt(mm);
116+
}
117+
107118
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
108119
struct task_struct *tsk)
109120
{

arch/x86/kernel/ldt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void free_ldt_struct(struct ldt_struct *ldt)
103103
* we do not have to muck with descriptors here, that is
104104
* done in switch_mm() as needed.
105105
*/
106-
int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
106+
int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm)
107107
{
108108
struct ldt_struct *new_ldt;
109109
struct mm_struct *old_mm;
@@ -144,7 +144,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
144144
*
145145
* 64bit: Don't touch the LDT register - we're already in the next thread.
146146
*/
147-
void destroy_context(struct mm_struct *mm)
147+
void destroy_context_ldt(struct mm_struct *mm)
148148
{
149149
free_ldt_struct(mm->context.ldt);
150150
mm->context.ldt = NULL;

0 commit comments

Comments
 (0)