Commit c83ec269 authored by Alexander Graf's avatar Alexander Graf Committed by Avi Kivity

PPC: Split context init/destroy functions

We need to reserve a context from KVM to make sure we have our own
segment space. While we did that split for Book3S_64 already, 32 bit
is still outstanding.

So let's split it now.
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 07372794
...@@ -27,6 +27,8 @@ extern int __init_new_context(void); ...@@ -27,6 +27,8 @@ extern int __init_new_context(void);
extern void __destroy_context(int context_id); extern void __destroy_context(int context_id);
static inline void mmu_context_init(void) { } static inline void mmu_context_init(void) { }
#else #else
extern unsigned long __init_new_context(void);
extern void __destroy_context(unsigned long context_id);
extern void mmu_context_init(void); extern void mmu_context_init(void);
#endif #endif
......
...@@ -60,11 +60,7 @@ ...@@ -60,11 +60,7 @@
static unsigned long next_mmu_context; static unsigned long next_mmu_context;
static unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1]; static unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];
unsigned long __init_new_context(void)
/*
* Set up the context for a new address space.
*/
int init_new_context(struct task_struct *t, struct mm_struct *mm)
{ {
unsigned long ctx = next_mmu_context; unsigned long ctx = next_mmu_context;
...@@ -74,11 +70,30 @@ int init_new_context(struct task_struct *t, struct mm_struct *mm) ...@@ -74,11 +70,30 @@ int init_new_context(struct task_struct *t, struct mm_struct *mm)
ctx = 0; ctx = 0;
} }
next_mmu_context = (ctx + 1) & LAST_CONTEXT; next_mmu_context = (ctx + 1) & LAST_CONTEXT;
mm->context.id = ctx;
return ctx;
}
EXPORT_SYMBOL_GPL(__init_new_context);
/*
* Set up the context for a new address space.
*/
int init_new_context(struct task_struct *t, struct mm_struct *mm)
{
mm->context.id = __init_new_context();
return 0; return 0;
} }
/*
* Free a context ID. Make sure to call this with preempt disabled!
*/
void __destroy_context(unsigned long ctx)
{
clear_bit(ctx, context_map);
}
EXPORT_SYMBOL_GPL(__destroy_context);
/* /*
* We're finished using the context for an address space. * We're finished using the context for an address space.
*/ */
...@@ -86,7 +101,7 @@ void destroy_context(struct mm_struct *mm) ...@@ -86,7 +101,7 @@ void destroy_context(struct mm_struct *mm)
{ {
preempt_disable(); preempt_disable();
if (mm->context.id != NO_CONTEXT) { if (mm->context.id != NO_CONTEXT) {
clear_bit(mm->context.id, context_map); __destroy_context(mm->context.id);
mm->context.id = NO_CONTEXT; mm->context.id = NO_CONTEXT;
} }
preempt_enable(); preempt_enable();
......
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