qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au,
	sam.bobroff@au1.ibm.com, rnsastry@linux.vnet.ibm.com,
	Bharata B Rao <bharata@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC PATCH 2/2] spapr: Fix migration of Radix guests
Date: Mon,  8 May 2017 14:36:17 +0530	[thread overview]
Message-ID: <1494234377-1773-3-git-send-email-bharata@linux.vnet.ibm.com> (raw)
In-Reply-To: <1494234377-1773-1-git-send-email-bharata@linux.vnet.ibm.com>

Currently HTAB savevm handlers get registered by default and migration
of radix guest will fail.

- Ensure that HTAB savevm handlers are not registered for radix case.
- Ensure that we issue KVM_PPC_CONFIGURE_V3_MMU for radix case post
  migration.

TODO: Right now I have delayed the HTAB savevm handler registration
to CAS call where we know if the guest is radix or hash. Another approach
is to let the HTAB handlers to be registered by default (as it is being
done currently, but unregister them from CAS when we discover radix
capability).

Reported-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 hw/ppc/spapr.c         | 18 +++++++++++++++---
 hw/ppc/spapr_hcall.c   |  5 +++++
 include/hw/ppc/spapr.h |  3 +++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e2dc77c..e14f55c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1436,6 +1436,14 @@ static int spapr_post_load(void *opaque, int version_id)
         err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
     }
 
+    if (spapr->patb_entry && (spapr->patb_flags & SPAPR_PROC_TABLE_RADIX) &&
+        kvmppc_has_cap_mmu_radix() && kvm_enabled()) {
+        err = kvmppc_configure_v3_mmu(POWERPC_CPU(first_cpu),
+                                      spapr->patb_flags &
+                                      SPAPR_PROC_TABLE_RADIX,
+                                      spapr->patb_flags & SPAPR_PROC_TABLE_GTSE,
+                                      spapr->patb_entry);
+    }
     return err;
 }
 
@@ -1520,6 +1528,7 @@ static const VMStateDescription vmstate_spapr_patb_entry = {
     .needed = spapr_patb_entry_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT64(patb_entry, sPAPRMachineState),
+        VMSTATE_UINT64(patb_flags, sPAPRMachineState),
         VMSTATE_END_OF_LIST()
     },
 };
@@ -1869,6 +1878,12 @@ static SaveVMHandlers savevm_htab_handlers = {
     .load_state = htab_load,
 };
 
+void spapr_htab_savevm_register(sPAPRMachineState *spapr)
+{
+    register_savevm_live(NULL, "spapr/htab", -1, 1,
+                         &savevm_htab_handlers, spapr);
+}
+
 static void spapr_boot_set(void *opaque, const char *boot_device,
                            Error **errp)
 {
@@ -2331,9 +2346,6 @@ static void ppc_spapr_init(MachineState *machine)
      * interface, this is a legacy from the sPAPREnvironment structure
      * which predated MachineState but had a similar function */
     vmstate_register(NULL, 0, &vmstate_spapr, spapr);
-    register_savevm_live(NULL, "spapr/htab", -1, 1,
-                         &savevm_htab_handlers, spapr);
-
     /* used by RTAS */
     QTAILQ_INIT(&spapr->ccs_list);
     qemu_register_reset(spapr_ccs_reset_hook, spapr);
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 3600b0e..fa03ca0 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -988,6 +988,7 @@ static target_ulong h_register_process_table(PowerPCCPU *cpu,
     spapr_check_setup_free_hpt(spapr, spapr->patb_entry, cproc);
 
     spapr->patb_entry = cproc; /* Save new process table */
+    spapr->patb_flags = flags; /* Save the flags */
 
     /* Update the UPRT and GTSE bits in the LPCR for all cpus */
     CPU_FOREACH(cs) {
@@ -1169,6 +1170,10 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
         }
     }
 
+    /* Register savevm handlers for HTAB case */
+    if (!guest_radix || !kvmppc_has_cap_mmu_radix()) {
+        spapr_htab_savevm_register(spapr);
+    }
     return H_SUCCESS;
 }
 
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index a692e63..0d0e9e4 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -75,6 +75,7 @@ struct sPAPRMachineState {
     void *htab;
     uint32_t htab_shift;
     uint64_t patb_entry; /* Process tbl registed in H_REGISTER_PROCESS_TABLE */
+    uint64_t patb_flags;
     hwaddr rma_size;
     int vrma_adjust;
     ssize_t rtas_size;
@@ -691,4 +692,6 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg);
 #define SPAPR_PROC_TABLE_HPT_PT      0x02
 #define SPAPR_PROC_TABLE_GTSE        0x01
 
+void spapr_htab_savevm_register(sPAPRMachineState *spapr);
+
 #endif /* HW_SPAPR_H */
-- 
2.7.4

  parent reply	other threads:[~2017-05-08  9:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08  9:06 [Qemu-devel] [RFC PATCH 0/2] ppc/spapr: Fix migration of radix guests Bharata B Rao
2017-05-08  9:06 ` [Qemu-devel] [RFC PATCH 1/2] spapr: Make h_register_process_table hcall flags global Bharata B Rao
2017-05-11  0:14   ` David Gibson
2017-05-08  9:06 ` Bharata B Rao [this message]
2017-05-11  1:02   ` [Qemu-devel] [RFC PATCH 2/2] spapr: Fix migration of Radix guests David Gibson
2017-05-17  3:42     ` Bharata B Rao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494234377-1773-3-git-send-email-bharata@linux.vnet.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rnsastry@linux.vnet.ibm.com \
    --cc=sam.bobroff@au1.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).