From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Herrenschmidt Subject: Re: [PATCH 05/27] PPC: Split context init/destroy functions Date: Fri, 16 Apr 2010 16:46:45 +1000 Message-ID: <1271400405.13059.177.camel@pasglop> References: <1271369518-11247-1-git-send-email-agraf@suse.de> <1271369518-11247-6-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org To: Alexander Graf Return-path: Received: from gate.crashing.org ([63.228.1.57]:34848 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754813Ab0DPGqz (ORCPT ); Fri, 16 Apr 2010 02:46:55 -0400 In-Reply-To: <1271369518-11247-6-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 2010-04-16 at 00:11 +0200, Alexander Graf wrote: > 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 Acked-by: Benjamin Herrenschmidt > --- > arch/powerpc/include/asm/mmu_context.h | 2 ++ > arch/powerpc/mm/mmu_context_hash32.c | 29 ++++++++++++++++++++++------- > 2 files changed, 24 insertions(+), 7 deletions(-) > > diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h > index 26383e0..81fb412 100644 > --- a/arch/powerpc/include/asm/mmu_context.h > +++ b/arch/powerpc/include/asm/mmu_context.h > @@ -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 > > diff --git a/arch/powerpc/mm/mmu_context_hash32.c b/arch/powerpc/mm/mmu_context_hash32.c > index 0dfba2b..d0ee554 100644 > --- a/arch/powerpc/mm/mmu_context_hash32.c > +++ b/arch/powerpc/mm/mmu_context_hash32.c > @@ -60,11 +60,7 @@ > 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,19 +70,38 @@ 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. > */ > 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();