xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bruno Alvisio <bruno.alvisio@gmail.com>
To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org
Cc: jgross@suse.com, samuel.thibault@ens-lyon.org, wei.liu2@citrix.com
Subject: [PATCH v2 16/16] Save/Restore Support: Implement code for arch suspend/resume
Date: Tue, 13 Feb 2018 18:27:39 -0800	[thread overview]
Message-ID: <1518575259-71141-17-git-send-email-bruno.alvisio@gmail.com> (raw)
In-Reply-To: <1518575259-71141-1-git-send-email-bruno.alvisio@gmail.com>

Before suspending the domain the shared_info_page is unmapped and for PVs the
pagetables should be canonicalized. After resume the shared_info_page should be
mapped again.

Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
Changed since v1:
  * Fixed comment
---
 arch/x86/setup.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/arch/x86/setup.c b/arch/x86/setup.c
index b6e0541..b5ed1c8 100644
--- a/arch/x86/setup.c
+++ b/arch/x86/setup.c
@@ -32,6 +32,7 @@
 #include <xen/xen.h>
 #include <xen/arch-x86/cpuid.h>
 #include <xen/arch-x86/hvm/start_info.h>
+#include <xen/hvm/params.h>
 
 #ifdef CONFIG_PARAVIRT
 /*
@@ -42,6 +43,11 @@ union start_info_union start_info_union;
 #endif
 
 /*
+ * This pointer holds a reference to the copy of the start_info struct.
+ */
+static start_info_t *start_info_ptr;
+
+/*
  * Shared page for communicating with the hypervisor.
  * Events flags go here, for example.
  */
@@ -212,18 +218,63 @@ arch_init(void *par)
 #ifdef CONFIG_PARAVIRT
 	memcpy(&start_info, par, sizeof(start_info));
 #endif
+	start_info_ptr = (start_info_t *)par;
 
 	start_kernel((start_info_t *)par);
 }
 
 void arch_pre_suspend(void)
 {
+#ifdef CONFIG_PARAVIRT
+   /* Replace xenstore and console mfns with the correspondent pfns */
+    start_info_ptr->store_mfn =
+        virt_to_pfn(mfn_to_virt(start_info_ptr->store_mfn));
+    start_info_ptr->console.domU.mfn =
+        virt_to_pfn(mfn_to_virt(start_info_ptr->console.domU.mfn));
+#else
+    uint64_t store_v;
+    uint64_t console_v;
+
+    if( hvm_get_parameter(HVM_PARAM_STORE_PFN, &store_v) )
+        BUG();
+    start_info_ptr->store_mfn = store_v;
+
+    if( hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &console_v) )
+        BUG();
+    start_info_ptr->console.domU.mfn = console_v;
+#endif
+    unmap_shared_info();
 
+    arch_mm_pre_suspend();
 }
 
 void arch_post_suspend(int canceled)
 {
+#if CONFIG_PARAVIRT
+    if (canceled) {
+        start_info_ptr->store_mfn = pfn_to_mfn(start_info_ptr->store_mfn);
+        start_info_ptr->console.domU.mfn = pfn_to_mfn(start_info_ptr->console.domU.mfn);
+    } else {
+        memcpy(&start_info, start_info_ptr, sizeof(start_info_t));
+    }
+#else
+    uint64_t store_v;
+    uint64_t console_v;
+
+    if (hvm_get_parameter(HVM_PARAM_STORE_PFN, &store_v))
+        BUG();
+    start_info_ptr->store_mfn = pfn_to_mfn(store_v);
 
+    if (hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &console_v))
+        BUG();
+    start_info_ptr->console.domU.mfn = pfn_to_mfn(console_v);
+#endif
+
+    HYPERVISOR_shared_info = map_shared_info((void*) start_info_ptr->shared_info);
+#ifndef CONFIG_PARAVIRT
+    xen_callback_vector();
+#endif
+    arch_mm_post_suspend(canceled);
 }
 
 void
-- 
2.3.2 (Apple Git-55)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      parent reply	other threads:[~2018-02-14  2:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  2:27 [PATCH v2 00/16] Save/Restore Support for mini-OS PVH Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 01/16] Save/Restore Support: Refactor HYPERVISOR_suspend hypercall Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 02/16] Save/Restore Support: Refactor trap_init() and setup vector callbacks Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 03/16] Save/Restore Support: Declare kernel and arch pre/post suspend functions Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 04/16] Save/Restore Support: Add xenbus_release_wait_for_watch Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 05/16] Save/Restore Support: Add kernel shutdown logic to shutdown.c Bruno Alvisio
2018-02-14  8:19   ` Juergen Gross
2018-02-14  2:27 ` [PATCH v2 06/16] Save/Restore Support: Moved shutdown thread " Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 07/16] Save/Restore Support: Add unmap_shared_info Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 08/16] Save/Restore Support: Add arch_mm_pre|post_suspend Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 09/16] Save/Restore Support: Disable/enable IRQs during suspend/restore Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 10/16] Save/Restore Support: Add suspend/resume support for timers Bruno Alvisio
2018-02-14  8:20   ` Juergen Gross
2018-02-14  2:27 ` [PATCH v2 11/16] Save/Restore Support: Add suspend/restore support for console Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 12/16] Save/Restore Support: Add support for suspend/restore events Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables Bruno Alvisio
2018-02-14 12:42   ` Juergen Gross
2018-02-14  2:27 ` [PATCH v2 14/16] Save/Restore Support: Add suspend/restore support for xenbus Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 15/16] Save/Restore Support: Add suspend/restore support for netfront Bruno Alvisio
2018-02-14  2:27 ` Bruno Alvisio [this message]

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=1518575259-71141-17-git-send-email-bruno.alvisio@gmail.com \
    --to=bruno.alvisio@gmail.com \
    --cc=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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).