diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2014-01-06 18:07:57 +1100 |
---|---|---|
committer | Eli Qiao <taget@linux.vnet.ibm.com> | 2014-01-06 15:58:16 +0800 |
commit | af4c301bd5b700f62597bcdf8e6f66bd2fd65db9 (patch) | |
tree | e1a2fd42a8ec9328f005c65dc99c2a81c27c7400 | |
parent | 1dc745db4fd87b58811330771f8ef33425010d64 (diff) | |
download | powerkvm-af4c301bd5b700f62597bcdf8e6f66bd2fd65db9.tar.gz |
PPC: KVM: move TCE cache alloc/free from KVM-common to KVM-HV
The idea of the tce_tmp_hpas cache is to pass partially processed TCEs
from real mode to virtual mode via H_TOO_HARD mechanism.
Since TCE hypercalls are never called in real mode under PR KVM, move them
to HV KVM.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 22 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_hv.c | 15 |
2 files changed, 15 insertions, 22 deletions
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 5b98cb4973c0c..39779096b298d 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -768,30 +768,11 @@ 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; @@ -799,9 +780,6 @@ 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 5b716139aa769..2be1c0aeee674 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1425,6 +1425,20 @@ 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: @@ -1447,6 +1461,7 @@ 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); } |