diff mbox

[RFC,v3,2/2] target/ppc: move POWER9 DD1 workaround to ppc_cpu_initfn

Message ID 20170703131455.25424-3-lvivier@redhat.com
State New
Headers show

Commit Message

Laurent Vivier July 3, 2017, 1:14 p.m. UTC
Commit 5f3066d ("target/ppc: Allow workarounds for POWER9 DD1")
disables compatibility mode for POWER9 DD1 to allow to
boot on POWER9 DD1 host with KVM.

As the workaround has been added in kvmppc_host_cpu_class_init(),
it applies only on CPU created with "-cpu host".
As we want to be able to use also "-cpu POWER9" on a POWER9 DD1
host, this patch moves the workaround from kvmppc_host_cpu_class_init()
to ppc_cpu_initfn().

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 target/ppc/kvm.c            | 11 -----------
 target/ppc/translate_init.c | 10 ++++++++++
 2 files changed, 10 insertions(+), 11 deletions(-)

Comments

Thomas Huth July 4, 2017, 8:17 a.m. UTC | #1
On 03.07.2017 15:14, Laurent Vivier wrote:
> Commit 5f3066d ("target/ppc: Allow workarounds for POWER9 DD1")
> disables compatibility mode for POWER9 DD1 to allow to
> boot on POWER9 DD1 host with KVM.
> 
> As the workaround has been added in kvmppc_host_cpu_class_init(),
> it applies only on CPU created with "-cpu host".
> As we want to be able to use also "-cpu POWER9" on a POWER9 DD1
> host, this patch moves the workaround from kvmppc_host_cpu_class_init()
> to ppc_cpu_initfn().

Would it be feasible to move it to init_proc_POWER9() instead? I think
that would be a better location for the POWER9 workaround ... not sure
whether it can be done there, though.

 Thomas
David Gibson July 4, 2017, 9:27 a.m. UTC | #2
On Tue, Jul 04, 2017 at 10:17:18AM +0200, Thomas Huth wrote:
> On 03.07.2017 15:14, Laurent Vivier wrote:
> > Commit 5f3066d ("target/ppc: Allow workarounds for POWER9 DD1")
> > disables compatibility mode for POWER9 DD1 to allow to
> > boot on POWER9 DD1 host with KVM.
> > 
> > As the workaround has been added in kvmppc_host_cpu_class_init(),
> > it applies only on CPU created with "-cpu host".
> > As we want to be able to use also "-cpu POWER9" on a POWER9 DD1
> > host, this patch moves the workaround from kvmppc_host_cpu_class_init()
> > to ppc_cpu_initfn().
> 
> Would it be feasible to move it to init_proc_POWER9() instead? I think
> that would be a better location for the POWER9 workaround ... not sure
> whether it can be done there, though.

That would be neater if it works.  I've applied the patch as is for
now, but if that does work, a follow up to move the workaround would
be nice.
Thomas Huth July 4, 2017, 11:13 a.m. UTC | #3
On 04.07.2017 11:27, David Gibson wrote:
> On Tue, Jul 04, 2017 at 10:17:18AM +0200, Thomas Huth wrote:
>> On 03.07.2017 15:14, Laurent Vivier wrote:
>>> Commit 5f3066d ("target/ppc: Allow workarounds for POWER9 DD1")
>>> disables compatibility mode for POWER9 DD1 to allow to
>>> boot on POWER9 DD1 host with KVM.
>>>
>>> As the workaround has been added in kvmppc_host_cpu_class_init(),
>>> it applies only on CPU created with "-cpu host".
>>> As we want to be able to use also "-cpu POWER9" on a POWER9 DD1
>>> host, this patch moves the workaround from kvmppc_host_cpu_class_init()
>>> to ppc_cpu_initfn().
>>
>> Would it be feasible to move it to init_proc_POWER9() instead? I think
>> that would be a better location for the POWER9 workaround ... not sure
>> whether it can be done there, though.
> 
> That would be neater if it works.  I've applied the patch as is for
> now, but if that does work, a follow up to move the workaround would
> be nice.

Seems like it works ... Could you use the patches from v4 instead?

 Thomas
diff mbox

Patch

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index f2f7c53..9d76817 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2381,17 +2381,6 @@  static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)
 
 #if defined(TARGET_PPC64)
     pcc->radix_page_info = kvm_get_radix_page_info();
-
-    if ((pcc->pvr & 0xffffff00) == CPU_POWERPC_POWER9_DD1) {
-        /*
-         * POWER9 DD1 has some bugs which make it not really ISA 3.00
-         * compliant.  More importantly, advertising ISA 3.00
-         * architected mode may prevent guests from activating
-         * necessary DD1 workarounds.
-         */
-        pcc->pcr_supported &= ~(PCR_COMPAT_3_00 | PCR_COMPAT_2_07
-                                | PCR_COMPAT_2_06 | PCR_COMPAT_2_05);
-    }
 #endif /* defined(TARGET_PPC64) */
 }
 
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index 56a0ab2..ceb5bdb 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -10617,6 +10617,16 @@  static void ppc_cpu_initfn(Object *obj)
         };
         env->sps = (env->mmu_model & POWERPC_MMU_64K) ? defsps_64k : defsps_4k;
     }
+    if ((pcc->pvr & 0xffffff00) == CPU_POWERPC_POWER9_DD1) {
+        /*
+         * POWER9 DD1 has some bugs which make it not really ISA 3.00
+         * compliant.  More importantly, advertising ISA 3.00
+         * architected mode may prevent guests from activating
+         * necessary DD1 workarounds.
+         */
+        pcc->pcr_supported &= ~(PCR_COMPAT_3_00 | PCR_COMPAT_2_07
+                                | PCR_COMPAT_2_06 | PCR_COMPAT_2_05);
+    }
 #endif /* defined(TARGET_PPC64) */
 
     if (tcg_enabled()) {