PPC: Split context init/destroy functions
authorAlexander Graf <agraf@suse.de>
Thu, 15 Apr 2010 22:11:36 +0000 (00:11 +0200)
committerAvi Kivity <avi@redhat.com>
Mon, 17 May 2010 09:18:20 +0000 (12:18 +0300)
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: Alexander Graf <agraf@suse.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/powerpc/include/asm/mmu_context.h
arch/powerpc/mm/mmu_context_hash32.c

index 26383e0778aaaa143ad3aa793753204d5f8d7ca9..81fb41289d6cb071474c5df484a4ca81b963d1db 100644 (file)
@@ -27,6 +27,8 @@ extern int __init_new_context(void);
 extern void __destroy_context(int context_id);
 static inline void mmu_context_init(void) { }
 #else
+extern unsigned long __init_new_context(void);
+extern void __destroy_context(unsigned long context_id);
 extern void mmu_context_init(void);
 #endif
 
index 0dfba2bf7f3189e0fd93c3168ad769a4968a6522..d0ee554e86e47c77d5084a7ac6d4f640e5cf763c 100644 (file)
 static unsigned long next_mmu_context;
 static unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];
 
-
-/*
- * Set up the context for a new address space.
- */
-int init_new_context(struct task_struct *t, struct mm_struct *mm)
+unsigned long __init_new_context(void)
 {
        unsigned long ctx = next_mmu_context;
 
@@ -74,11 +70,30 @@ int init_new_context(struct task_struct *t, struct mm_struct *mm)
                        ctx = 0;
        }
        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;
 }
 
+/*
+ * 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.
  */
@@ -86,7 +101,7 @@ void destroy_context(struct mm_struct *mm)
 {
        preempt_disable();
        if (mm->context.id != NO_CONTEXT) {
-               clear_bit(mm->context.id, context_map);
+               __destroy_context(mm->context.id);
                mm->context.id = NO_CONTEXT;
        }
        preempt_enable();
This page took 0.027791 seconds and 5 git commands to generate.