aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/powerpc.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2013-10-07 12:47:56 -0400
committerAlexander Graf <agraf@suse.de>2013-10-17 09:29:09 -0400
commit699cc87641c123128bf3a4e12c0a8d739b1ac2f3 (patch)
tree78f71debe6f457154f507aeb7d909e27ee9a38be /arch/powerpc/kvm/powerpc.c
parentdd96b2c2dc408faf2213bc0a05897c1359f7969c (diff)
kvm: powerpc: book3s: Add is_hv_enabled to kvmppc_ops
This help us to identify whether we are running with hypervisor mode KVM enabled. The change is needed so that we can have both HV and PR kvm enabled in the same kernel. If both HV and PR KVM are included, interrupts come in to the HV version of the kvmppc_interrupt code, which then jumps to the PR handler, renamed to kvmppc_interrupt_pr, if the guest is a PR guest. Allowing both PR and HV in the same kernel required some changes to kvm_dev_ioctl_check_extension(), since the values returned now can't be selected with #ifdefs as much as previously. We look at is_hv_enabled to return the right value when checking for capabilities.For capabilities that are only provided by HV KVM, we return the HV value only if is_hv_enabled is true. For capabilities provided by PR KVM but not HV, we return the PR value only if is_hv_enabled is false. NOTE: in later patch we replace is_hv_enabled with a static inline function comparing kvm_ppc_ops Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/powerpc.c')
-rw-r--r--arch/powerpc/kvm/powerpc.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 69b930550d2e..874a2a5e6cec 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -52,7 +52,6 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
52 return 1; 52 return 1;
53} 53}
54 54
55#ifndef CONFIG_KVM_BOOK3S_64_HV
56/* 55/*
57 * Common checks before entering the guest world. Call with interrupts 56 * Common checks before entering the guest world. Call with interrupts
58 * disabled. 57 * disabled.
@@ -127,7 +126,6 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
127 126
128 return r; 127 return r;
129} 128}
130#endif /* CONFIG_KVM_BOOK3S_64_HV */
131 129
132int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) 130int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
133{ 131{
@@ -194,11 +192,9 @@ int kvmppc_sanity_check(struct kvm_vcpu *vcpu)
194 if ((vcpu->arch.cpu_type != KVM_CPU_3S_64) && vcpu->arch.papr_enabled) 192 if ((vcpu->arch.cpu_type != KVM_CPU_3S_64) && vcpu->arch.papr_enabled)
195 goto out; 193 goto out;
196 194
197#ifdef CONFIG_KVM_BOOK3S_64_HV
198 /* HV KVM can only do PAPR mode for now */ 195 /* HV KVM can only do PAPR mode for now */
199 if (!vcpu->arch.papr_enabled) 196 if (!vcpu->arch.papr_enabled && kvmppc_ops->is_hv_enabled)
200 goto out; 197 goto out;
201#endif
202 198
203#ifdef CONFIG_KVM_BOOKE_HV 199#ifdef CONFIG_KVM_BOOKE_HV
204 if (!cpu_has_feature(CPU_FTR_EMB_HV)) 200 if (!cpu_has_feature(CPU_FTR_EMB_HV))
@@ -322,22 +318,26 @@ int kvm_dev_ioctl_check_extension(long ext)
322 case KVM_CAP_DEVICE_CTRL: 318 case KVM_CAP_DEVICE_CTRL:
323 r = 1; 319 r = 1;
324 break; 320 break;
325#ifndef CONFIG_KVM_BOOK3S_64_HV
326 case KVM_CAP_PPC_PAIRED_SINGLES: 321 case KVM_CAP_PPC_PAIRED_SINGLES:
327 case KVM_CAP_PPC_OSI: 322 case KVM_CAP_PPC_OSI:
328 case KVM_CAP_PPC_GET_PVINFO: 323 case KVM_CAP_PPC_GET_PVINFO:
329#if defined(CONFIG_KVM_E500V2) || defined(CONFIG_KVM_E500MC) 324#if defined(CONFIG_KVM_E500V2) || defined(CONFIG_KVM_E500MC)
330 case KVM_CAP_SW_TLB: 325 case KVM_CAP_SW_TLB:
331#endif 326#endif
332#ifdef CONFIG_KVM_MPIC 327 /* We support this only for PR */
333 case KVM_CAP_IRQ_MPIC: 328 r = !kvmppc_ops->is_hv_enabled;
334#endif
335 r = 1;
336 break; 329 break;
330#ifdef CONFIG_KVM_MMIO
337 case KVM_CAP_COALESCED_MMIO: 331 case KVM_CAP_COALESCED_MMIO:
338 r = KVM_COALESCED_MMIO_PAGE_OFFSET; 332 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
339 break; 333 break;
340#endif 334#endif
335#ifdef CONFIG_KVM_MPIC
336 case KVM_CAP_IRQ_MPIC:
337 r = 1;
338 break;
339#endif
340
341#ifdef CONFIG_PPC_BOOK3S_64 341#ifdef CONFIG_PPC_BOOK3S_64
342 case KVM_CAP_SPAPR_TCE: 342 case KVM_CAP_SPAPR_TCE:
343 case KVM_CAP_PPC_ALLOC_HTAB: 343 case KVM_CAP_PPC_ALLOC_HTAB:
@@ -348,32 +348,37 @@ int kvm_dev_ioctl_check_extension(long ext)
348 r = 1; 348 r = 1;
349 break; 349 break;
350#endif /* CONFIG_PPC_BOOK3S_64 */ 350#endif /* CONFIG_PPC_BOOK3S_64 */
351#ifdef CONFIG_KVM_BOOK3S_64_HV 351#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
352 case KVM_CAP_PPC_SMT: 352 case KVM_CAP_PPC_SMT:
353 r = threads_per_core; 353 if (kvmppc_ops->is_hv_enabled)
354 r = threads_per_core;
355 else
356 r = 0;
354 break; 357 break;
355 case KVM_CAP_PPC_RMA: 358 case KVM_CAP_PPC_RMA:
356 r = 1; 359 r = kvmppc_ops->is_hv_enabled;
357 /* PPC970 requires an RMA */ 360 /* PPC970 requires an RMA */
358 if (cpu_has_feature(CPU_FTR_ARCH_201)) 361 if (r && cpu_has_feature(CPU_FTR_ARCH_201))
359 r = 2; 362 r = 2;
360 break; 363 break;
361#endif 364#endif
362 case KVM_CAP_SYNC_MMU: 365 case KVM_CAP_SYNC_MMU:
363#ifdef CONFIG_KVM_BOOK3S_64_HV 366#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
364 r = cpu_has_feature(CPU_FTR_ARCH_206) ? 1 : 0; 367 if (kvmppc_ops->is_hv_enabled)
368 r = cpu_has_feature(CPU_FTR_ARCH_206) ? 1 : 0;
369 else
370 r = 0;
365#elif defined(KVM_ARCH_WANT_MMU_NOTIFIER) 371#elif defined(KVM_ARCH_WANT_MMU_NOTIFIER)
366 r = 1; 372 r = 1;
367#else 373#else
368 r = 0; 374 r = 0;
369 break;
370#endif 375#endif
371#ifdef CONFIG_KVM_BOOK3S_64_HV 376 break;
377#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
372 case KVM_CAP_PPC_HTAB_FD: 378 case KVM_CAP_PPC_HTAB_FD:
373 r = 1; 379 r = kvmppc_ops->is_hv_enabled;
374 break; 380 break;
375#endif 381#endif
376 break;
377 case KVM_CAP_NR_VCPUS: 382 case KVM_CAP_NR_VCPUS:
378 /* 383 /*
379 * Recommending a number of CPUs is somewhat arbitrary; we 384 * Recommending a number of CPUs is somewhat arbitrary; we
@@ -381,11 +386,10 @@ int kvm_dev_ioctl_check_extension(long ext)
381 * will have secondary threads "offline"), and for other KVM 386 * will have secondary threads "offline"), and for other KVM
382 * implementations just count online CPUs. 387 * implementations just count online CPUs.
383 */ 388 */
384#ifdef CONFIG_KVM_BOOK3S_64_HV 389 if (kvmppc_ops->is_hv_enabled)
385 r = num_present_cpus(); 390 r = num_present_cpus();
386#else 391 else
387 r = num_online_cpus(); 392 r = num_online_cpus();
388#endif
389 break; 393 break;
390 case KVM_CAP_MAX_VCPUS: 394 case KVM_CAP_MAX_VCPUS:
391 r = KVM_MAX_VCPUS; 395 r = KVM_MAX_VCPUS;