cf81640
From: Thomas Huth <thuth@redhat.com>
cf81640
Date: Wed, 21 Sep 2016 11:42:15 +0200
cf81640
Subject: [PATCH] ppc/kvm: Mark 64kB page size support as disabled if not
cf81640
 available
cf81640
cf81640
QEMU currently refuses to start with KVM-PR and only prints out
cf81640
cf81640
	qemu: fatal: Unknown MMU model 851972
cf81640
cf81640
when being started there. This is because commit 4322e8ced5aaac719
cf81640
("ppc: Fix 64K pages support in full emulation") introduced a new
cf81640
POWERPC_MMU_64K bit to indicate support for this page size, but
cf81640
it never gets cleared on KVM-PR if the host kernel does not support
cf81640
this. Thus we've got to turn off this bit in the mmu_model for KVM-PR.
cf81640
cf81640
Signed-off-by: Thomas Huth <thuth@redhat.com>
cf81640
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
cf81640
(cherry picked from commit 0d594f5565837fe2886a8aa307ef8abb65eab8f7)
cf81640
---
cf81640
 target-ppc/kvm.c | 7 +++++++
cf81640
 1 file changed, 7 insertions(+)
cf81640
cf81640
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
cf81640
index dcb68b9..6bdc804 100644
cf81640
--- a/target-ppc/kvm.c
cf81640
+++ b/target-ppc/kvm.c
cf81640
@@ -427,6 +427,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
cf81640
     CPUPPCState *env = &cpu->env;
cf81640
     long rampagesize;
cf81640
     int iq, ik, jq, jk;
cf81640
+    bool has_64k_pages = false;
cf81640
 
cf81640
     /* We only handle page sizes for 64-bit server guests for now */
cf81640
     if (!(env->mmu_model & POWERPC_MMU_64)) {
cf81640
@@ -470,6 +471,9 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
cf81640
                                      ksps->enc[jk].page_shift)) {
cf81640
                 continue;
cf81640
             }
cf81640
+            if (ksps->enc[jk].page_shift == 16) {
cf81640
+                has_64k_pages = true;
cf81640
+            }
cf81640
             qsps->enc[jq].page_shift = ksps->enc[jk].page_shift;
cf81640
             qsps->enc[jq].pte_enc = ksps->enc[jk].pte_enc;
cf81640
             if (++jq >= PPC_PAGE_SIZES_MAX_SZ) {
cf81640
@@ -484,6 +488,9 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
cf81640
     if (!(smmu_info.flags & KVM_PPC_1T_SEGMENTS)) {
cf81640
         env->mmu_model &= ~POWERPC_MMU_1TSEG;
cf81640
     }
cf81640
+    if (!has_64k_pages) {
cf81640
+        env->mmu_model &= ~POWERPC_MMU_64K;
cf81640
+    }
cf81640
 }
cf81640
 #else /* defined (TARGET_PPC64) */
cf81640