Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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>

authored by

Alexander Graf and committed by
Avi Kivity
c83ec269 07372794

+24 -7
+2
arch/powerpc/include/asm/mmu_context.h
··· 27 27 extern void __destroy_context(int context_id); 28 28 static inline void mmu_context_init(void) { } 29 29 #else 30 + extern unsigned long __init_new_context(void); 31 + extern void __destroy_context(unsigned long context_id); 30 32 extern void mmu_context_init(void); 31 33 #endif 32 34
+22 -7
arch/powerpc/mm/mmu_context_hash32.c
··· 60 60 static unsigned long next_mmu_context; 61 61 static unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1]; 62 62 63 - 64 - /* 65 - * Set up the context for a new address space. 66 - */ 67 - int init_new_context(struct task_struct *t, struct mm_struct *mm) 63 + unsigned long __init_new_context(void) 68 64 { 69 65 unsigned long ctx = next_mmu_context; 70 66 ··· 70 74 ctx = 0; 71 75 } 72 76 next_mmu_context = (ctx + 1) & LAST_CONTEXT; 73 - mm->context.id = ctx; 77 + 78 + return ctx; 79 + } 80 + EXPORT_SYMBOL_GPL(__init_new_context); 81 + 82 + /* 83 + * Set up the context for a new address space. 84 + */ 85 + int init_new_context(struct task_struct *t, struct mm_struct *mm) 86 + { 87 + mm->context.id = __init_new_context(); 74 88 75 89 return 0; 76 90 } 91 + 92 + /* 93 + * Free a context ID. Make sure to call this with preempt disabled! 94 + */ 95 + void __destroy_context(unsigned long ctx) 96 + { 97 + clear_bit(ctx, context_map); 98 + } 99 + EXPORT_SYMBOL_GPL(__destroy_context); 77 100 78 101 /* 79 102 * We're finished using the context for an address space. ··· 101 86 { 102 87 preempt_disable(); 103 88 if (mm->context.id != NO_CONTEXT) { 104 - clear_bit(mm->context.id, context_map); 89 + __destroy_context(mm->context.id); 105 90 mm->context.id = NO_CONTEXT; 106 91 } 107 92 preempt_enable();