aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kvm/book3s_hv.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 0c5266e75a2e..5042cccd9fde 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1303,6 +1303,26 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
1303 return r; 1303 return r;
1304} 1304}
1305 1305
1306static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core)
1307{
1308 struct kvmppc_vcore *vcore;
1309
1310 vcore = kzalloc(sizeof(struct kvmppc_vcore), GFP_KERNEL);
1311
1312 if (vcore == NULL)
1313 return NULL;
1314
1315 INIT_LIST_HEAD(&vcore->runnable_threads);
1316 spin_lock_init(&vcore->lock);
1317 init_waitqueue_head(&vcore->wq);
1318 vcore->preempt_tb = TB_NIL;
1319 vcore->lpcr = kvm->arch.lpcr;
1320 vcore->first_vcpuid = core * threads_per_subcore;
1321 vcore->kvm = kvm;
1322
1323 return vcore;
1324}
1325
1306static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, 1326static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm,
1307 unsigned int id) 1327 unsigned int id)
1308{ 1328{
@@ -1354,16 +1374,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm,
1354 mutex_lock(&kvm->lock); 1374 mutex_lock(&kvm->lock);
1355 vcore = kvm->arch.vcores[core]; 1375 vcore = kvm->arch.vcores[core];
1356 if (!vcore) { 1376 if (!vcore) {
1357 vcore = kzalloc(sizeof(struct kvmppc_vcore), GFP_KERNEL); 1377 vcore = kvmppc_vcore_create(kvm, core);
1358 if (vcore) {
1359 INIT_LIST_HEAD(&vcore->runnable_threads);
1360 spin_lock_init(&vcore->lock);
1361 init_waitqueue_head(&vcore->wq);
1362 vcore->preempt_tb = TB_NIL;
1363 vcore->lpcr = kvm->arch.lpcr;
1364 vcore->first_vcpuid = core * threads_per_subcore;
1365 vcore->kvm = kvm;
1366 }
1367 kvm->arch.vcores[core] = vcore; 1378 kvm->arch.vcores[core] = vcore;
1368 kvm->arch.online_vcores++; 1379 kvm->arch.online_vcores++;
1369 } 1380 }