aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Qiao <taget@linux.vnet.ibm.com>2014-01-13 13:28:21 +0800
committerEli Qiao <taget@linux.vnet.ibm.com>2014-01-13 13:28:54 +0800
commit2ac12af016995bd4a7b3f35438346c3e66ea6a0f (patch)
treea1dcf92875472f9c66848c7209f277303efc00b9
parent9112fe27ae3ad245d18fc50d612bfe38a7c146a6 (diff)
downloadpowerkvm-2ac12af016995bd4a7b3f35438346c3e66ea6a0f.tar.gz
This commit breaks PR KVM.
Request by Alexey Kardashevskiy Revert "PPC: KVM: move TCE cache alloc/free from KVM-common to KVM-HV" This reverts commit af4c301bd5b700f62597bcdf8e6f66bd2fd65db9.
-rw-r--r--arch/powerpc/kvm/book3s.c22
-rw-r--r--arch/powerpc/kvm/book3s_hv.c15
2 files changed, 22 insertions, 15 deletions
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 97d224ca03b03..b13098c5d9055 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -768,11 +768,30 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
{
struct kvm_vcpu *vcpu;
+#ifdef CONFIG_PPC64
+ unsigned long *tmp;
+
+ /*
+ * As we want to minimize the chance of having H_PUT_TCE_INDIRECT
+ * half executed, we first read TCEs from the user, check them and
+ * return error if something went wrong and only then put TCEs into
+ * the TCE table.
+ *
+ * tce_tmp_hpas is a cache for TCEs to avoid stack allocation or
+ * kmalloc as the whole TCE list can take up to 512 items 8 bytes
+ * each (4096 bytes).
+ */
+ tmp = kmalloc(4096, GFP_KERNEL);
+ if (!tmp)
+ return ERR_PTR(-ENOMEM);
+#endif
+
vcpu = kvm->arch.kvm_ops->vcpu_create(kvm, id);
#ifdef CONFIG_PPC64
if (IS_ERR_OR_NULL(vcpu))
return vcpu;
+ vcpu->arch.tce_tmp_hpas = tmp;
#endif
return vcpu;
@@ -780,6 +799,9 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
{
+#ifdef CONFIG_PPC64
+ kfree(vcpu->arch.tce_tmp_hpas);
+#endif
vcpu->kvm->arch.kvm_ops->vcpu_free(vcpu);
}
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 38ae80305fec5..884c1fb1b00c7 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1425,20 +1425,6 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm,
vcpu->arch.cpu_type = KVM_CPU_3S_64;
kvmppc_sanity_check(vcpu);
- /*
- * As we want to minimize the chance of having H_PUT_TCE_INDIRECT
- * half executed, we first read TCEs from the user, check them and
- * return error if something went wrong and only then put TCEs into
- * the TCE table.
- *
- * tce_tmp_hpas is a cache for TCEs to avoid stack allocation or
- * kmalloc as the whole TCE list can take up to 512 items 8 bytes
- * each (4096 bytes).
- */
- vcpu->arch.tce_tmp_hpas = kmalloc(4096, GFP_KERNEL);
- if (!vcpu->arch.tce_tmp_hpas)
- goto free_vcpu;
-
return vcpu;
free_vcpu:
@@ -1461,7 +1447,6 @@ static void kvmppc_core_vcpu_free_hv(struct kvm_vcpu *vcpu)
unpin_vpa(vcpu->kvm, &vcpu->arch.slb_shadow);
unpin_vpa(vcpu->kvm, &vcpu->arch.vpa);
spin_unlock(&vcpu->arch.vpa_update_lock);
- kfree(vcpu->arch.tce_tmp_hpas);
kvm_vcpu_uninit(vcpu);
kmem_cache_free(kvm_vcpu_cache, vcpu);
}