Commit a336f2f5 authored by Michael Ellerman's avatar Michael Ellerman

powerpc/mm/hash: Abstract context id allocation for KVM

KVM wants to be able to allocate an MMU context id, which it does
currently by calling __init_new_context().

We're about to rework that code, so provide a wrapper for KVM so it
can not worry about the details.
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 302413ca
...@@ -51,7 +51,7 @@ static inline void switch_mmu_context(struct mm_struct *prev, ...@@ -51,7 +51,7 @@ static inline void switch_mmu_context(struct mm_struct *prev,
return switch_slb(tsk, next); return switch_slb(tsk, next);
} }
extern int __init_new_context(void); extern int hash__alloc_context_id(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
......
...@@ -390,7 +390,7 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu) ...@@ -390,7 +390,7 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
int err; int err;
err = __init_new_context(); err = hash__alloc_context_id();
if (err < 0) if (err < 0)
return -1; return -1;
vcpu3s->context_id[0] = err; vcpu3s->context_id[0] = err;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
static DEFINE_SPINLOCK(mmu_context_lock); static DEFINE_SPINLOCK(mmu_context_lock);
static DEFINE_IDA(mmu_context_ida); static DEFINE_IDA(mmu_context_ida);
int __init_new_context(void) static int __init_new_context(void)
{ {
int index; int index;
int err; int err;
...@@ -57,7 +57,13 @@ int __init_new_context(void) ...@@ -57,7 +57,13 @@ int __init_new_context(void)
return index; return index;
} }
EXPORT_SYMBOL_GPL(__init_new_context);
int hash__alloc_context_id(void)
{
return __init_new_context();
}
EXPORT_SYMBOL_GPL(hash__alloc_context_id);
static int radix__init_new_context(struct mm_struct *mm, int index) static int radix__init_new_context(struct mm_struct *mm, int index)
{ {
unsigned long rts_field; unsigned long rts_field;
......
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