aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@ozlabs.org>2018-01-11 00:54:26 -0500
committerPaul Mackerras <paulus@ozlabs.org>2018-01-17 20:05:19 -0500
commit00608e1f007e4cf6031485c5630e0e504bceef9b (patch)
tree4d77031b241c77ff089cfa6ee43c78020ec700a2
parent6964e6a4e4894c707e42d51d9d30683c57f43201 (diff)
KVM: PPC: Book3S HV: Allow HPT and radix on the same core for POWER9 v2.2
POWER9 chip versions starting with "Nimbus" v2.2 can support running with some threads of a core in HPT mode and others in radix mode. This means that we don't have to prohibit independent-threads mode when running a HPT guest on a radix host, and we don't have to do any of the synchronization between threads that was introduced in commit c01015091a77 ("KVM: PPC: Book3S HV: Run HPT guests on POWER9 radix hosts", 2017-10-19). Rather than using up another CPU feature bit, we just do an explicit test on the PVR (processor version register) at module startup time to determine whether we have to take steps to avoid having some threads in HPT mode and some in radix mode (so-called "mixed mode"). We test for "Nimbus" (indicated by 0 or 1 in the top nibble of the lower 16 bits) v2.2 or later, or "Cumulus" (indicated by 2 or 3 in that nibble) v1.1 or later. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r--arch/powerpc/kvm/book3s_hv.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index b2d448c75008..76cf48051eb3 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -118,6 +118,9 @@ module_param_cb(h_ipi_redirect, &module_param_ops, &h_ipi_redirect,
118MODULE_PARM_DESC(h_ipi_redirect, "Redirect H_IPI wakeup to a free host core"); 118MODULE_PARM_DESC(h_ipi_redirect, "Redirect H_IPI wakeup to a free host core");
119#endif 119#endif
120 120
121/* If set, the threads on each CPU core have to be in the same MMU mode */
122static bool no_mixing_hpt_and_radix;
123
121static void kvmppc_end_cede(struct kvm_vcpu *vcpu); 124static void kvmppc_end_cede(struct kvm_vcpu *vcpu);
122static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu); 125static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu);
123 126
@@ -2386,8 +2389,8 @@ static void init_core_info(struct core_info *cip, struct kvmppc_vcore *vc)
2386static bool subcore_config_ok(int n_subcores, int n_threads) 2389static bool subcore_config_ok(int n_subcores, int n_threads)
2387{ 2390{
2388 /* 2391 /*
2389 * POWER9 "SMT4" cores are permanently in what is effectively a 4-way split-core 2392 * POWER9 "SMT4" cores are permanently in what is effectively a 4-way
2390 * mode, with one thread per subcore. 2393 * split-core mode, with one thread per subcore.
2391 */ 2394 */
2392 if (cpu_has_feature(CPU_FTR_ARCH_300)) 2395 if (cpu_has_feature(CPU_FTR_ARCH_300))
2393 return n_subcores <= 4 && n_threads == 1; 2396 return n_subcores <= 4 && n_threads == 1;
@@ -2423,8 +2426,8 @@ static bool can_dynamic_split(struct kvmppc_vcore *vc, struct core_info *cip)
2423 if (!cpu_has_feature(CPU_FTR_ARCH_207S)) 2426 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
2424 return false; 2427 return false;
2425 2428
2426 /* POWER9 currently requires all threads to be in the same MMU mode */ 2429 /* Some POWER9 chips require all threads to be in the same MMU mode */
2427 if (cpu_has_feature(CPU_FTR_ARCH_300) && 2430 if (no_mixing_hpt_and_radix &&
2428 kvm_is_radix(vc->kvm) != kvm_is_radix(cip->vc[0]->kvm)) 2431 kvm_is_radix(vc->kvm) != kvm_is_radix(cip->vc[0]->kvm))
2429 return false; 2432 return false;
2430 2433
@@ -2687,9 +2690,11 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
2687 * threads are offline. Also check if the number of threads in this 2690 * threads are offline. Also check if the number of threads in this
2688 * guest are greater than the current system threads per guest. 2691 * guest are greater than the current system threads per guest.
2689 * On POWER9, we need to be not in independent-threads mode if 2692 * On POWER9, we need to be not in independent-threads mode if
2690 * this is a HPT guest on a radix host. 2693 * this is a HPT guest on a radix host machine where the
2694 * CPU threads may not be in different MMU modes.
2691 */ 2695 */
2692 hpt_on_radix = radix_enabled() && !kvm_is_radix(vc->kvm); 2696 hpt_on_radix = no_mixing_hpt_and_radix && radix_enabled() &&
2697 !kvm_is_radix(vc->kvm);
2693 if (((controlled_threads > 1) && 2698 if (((controlled_threads > 1) &&
2694 ((vc->num_threads > threads_per_subcore) || !on_primary_thread())) || 2699 ((vc->num_threads > threads_per_subcore) || !on_primary_thread())) ||
2695 (hpt_on_radix && vc->kvm->arch.threads_indep)) { 2700 (hpt_on_radix && vc->kvm->arch.threads_indep)) {
@@ -4446,6 +4451,19 @@ static int kvmppc_book3s_init_hv(void)
4446 4451
4447 if (kvmppc_radix_possible()) 4452 if (kvmppc_radix_possible())
4448 r = kvmppc_radix_init(); 4453 r = kvmppc_radix_init();
4454
4455 /*
4456 * POWER9 chips before version 2.02 can't have some threads in
4457 * HPT mode and some in radix mode on the same core.
4458 */
4459 if (cpu_has_feature(CPU_FTR_ARCH_300)) {
4460 unsigned int pvr = mfspr(SPRN_PVR);
4461 if ((pvr >> 16) == PVR_POWER9 &&
4462 (((pvr & 0xe000) == 0 && (pvr & 0xfff) < 0x202) ||
4463 ((pvr & 0xe000) == 0x2000 && (pvr & 0xfff) < 0x101)))
4464 no_mixing_hpt_and_radix = true;
4465 }
4466
4449 return r; 4467 return r;
4450} 4468}
4451 4469