From: Ian Campbell <ian.campbell@citrix.com>
To: stefano.stabellini@eu.citrix.com, julien.grall@citrix.com,
xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH RFC LINUX v1] xen: arm: enable migration on ARM.
Date: Wed, 9 Dec 2015 14:33:37 +0000 [thread overview]
Message-ID: <1449671617-26379-1-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1449671507.16124.264.camel@citrix.com>
Replace various stub functions with real functionality, including
reestablishing the shared info page and the per-vcpu info pages on
restore.
Reestablishing the vcpu info page is a little subtle. The
VCPUOP_register_vcpu_info hypercall can only be called on either the
current VCPU or on an offline different VCPU. Since migration occurs
with all VCPUS online they are all therefore online at the point of
resume.
Therefore we must perform a cross VCPU call to each non-boot VCPU,
which cannot be done in the xen_arch_post_suspend() callback since
that is run from stop_machine() with interrupts disabled.
Furthermore VCPUOP_register_vcpu_info can only be called once per-VCPU
in a given domain, so it must not be called after a cancelled suspend
(which resumes in the same domain).
Therefore xen_arch_resume() gains a suspend_cancelled parameter and we
resume the secondary VCPUs there only if needed.
The VCPU which is running the suspend is resumed earlier in the
xen_arch_post_suspend callback, again conditionally only for
non-cancelled suspends.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
arch/arm/xen/Makefile | 2 +-
arch/arm/xen/enlighten.c | 54 +++++++++++++++++++++++++++++++-----------------
arch/arm/xen/suspend.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
arch/arm/xen/xen-ops.h | 9 ++++++++
arch/x86/xen/suspend.c | 2 +-
drivers/xen/manage.c | 2 +-
include/xen/xen-ops.h | 2 +-
7 files changed, 102 insertions(+), 23 deletions(-)
create mode 100644 arch/arm/xen/suspend.c
create mode 100644 arch/arm/xen/xen-ops.h
diff --git a/arch/arm/xen/Makefile b/arch/arm/xen/Makefile
index 1296952..677022c 100644
--- a/arch/arm/xen/Makefile
+++ b/arch/arm/xen/Makefile
@@ -1 +1 @@
-obj-y := enlighten.o hypercall.o grant-table.o p2m.o mm.o
+obj-y := enlighten.o hypercall.o grant-table.o p2m.o mm.o suspend.o
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index eeeab07..72f314e 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -182,10 +182,41 @@ void __init xen_early_init(void)
add_preferred_console("hvc", 0, NULL);
}
-static int __init xen_guest_init(void)
+static struct shared_info *shared_info_page;
+
+int xen_register_shared_info(void)
{
struct xen_add_to_physmap xatp;
- struct shared_info *shared_info_page = NULL;
+
+ /*
+ * This function is called on boot and on restore. On boot we
+ * allocate this page immediately before calling this function
+ * and bail on failure. On resume that allocation must have
+ * succeeded or we couldn't be doing a save/restore.
+ */
+ BUG_ON(!shared_info_page);
+
+ xatp.domid = DOMID_SELF;
+ xatp.idx = 0;
+ xatp.space = XENMAPSPACE_shared_info;
+ xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT;
+ if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+ BUG();
+
+ HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;
+
+ return 0;
+}
+
+void xen_vcpu_restore(void)
+{
+ xen_percpu_init();
+
+ /* XXX TODO: xen_setup_runstate_info(cpu); */
+}
+
+static int __init xen_guest_init(void)
+{
struct resource res;
phys_addr_t grant_frames;
@@ -210,18 +241,12 @@ static int __init xen_guest_init(void)
pr_err("not enough memory\n");
return -ENOMEM;
}
- xatp.domid = DOMID_SELF;
- xatp.idx = 0;
- xatp.space = XENMAPSPACE_shared_info;
- xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT;
- if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
- BUG();
- HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;
+ xen_register_shared_info();
/* xen_vcpu is a pointer to the vcpu_info struct in the shared_info
* page, we use it in the event channel upcall and in some pvclock
- * related functions.
+ * related functions.
* The shared info contains exactly 1 CPU (the boot CPU). The guest
* is required to use VCPUOP_register_vcpu_info to place vcpu info
* for secondary CPUs as they are brought up.
@@ -275,15 +300,6 @@ static int __init xen_pm_init(void)
}
late_initcall(xen_pm_init);
-
-/* empty stubs */
-void xen_arch_pre_suspend(void) { }
-void xen_arch_post_suspend(int suspend_cancelled) { }
-void xen_timer_resume(void) { }
-void xen_arch_resume(void) { }
-void xen_arch_suspend(void) { }
-
-
/* In the hypervisor.S file. */
EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op);
EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op);
diff --git a/arch/arm/xen/suspend.c b/arch/arm/xen/suspend.c
new file mode 100644
index 0000000..b420758
--- /dev/null
+++ b/arch/arm/xen/suspend.c
@@ -0,0 +1,54 @@
+#include <linux/types.h>
+#include <linux/tick.h>
+
+#include <xen/interface/xen.h>
+
+#include <asm/xen/hypercall.h>
+
+#include "xen-ops.h"
+
+void xen_arch_pre_suspend(void) {
+ /* Nothing to do */
+}
+
+void xen_arch_post_suspend(int suspend_cancelled)
+{
+ xen_register_shared_info();
+ if (!suspend_cancelled)
+ xen_vcpu_restore();
+}
+
+static void xen_vcpu_notify_suspend(void *data)
+{
+ tick_suspend_local();
+}
+
+static void xen_vcpu_notify_resume(void *data)
+{
+ int suspend_cancelled = *(int *)data;
+
+ if (smp_processor_id() == 0)
+ return;
+
+ /* Boot processor done in post_suspend */
+ if (!suspend_cancelled)
+ xen_vcpu_restore();
+
+ /* Boot processor notified via generic timekeeping_resume() */
+ tick_resume_local();
+}
+
+void xen_arch_suspend(void)
+{
+ on_each_cpu(xen_vcpu_notify_suspend, NULL, 1);
+}
+
+void xen_arch_resume(int suspend_cancelled)
+{
+ on_each_cpu(xen_vcpu_notify_resume, &suspend_cancelled, 1);
+}
+
+void xen_timer_resume(void)
+{
+ /* Nothing to do */
+}
diff --git a/arch/arm/xen/xen-ops.h b/arch/arm/xen/xen-ops.h
new file mode 100644
index 0000000..de23e91
--- /dev/null
+++ b/arch/arm/xen/xen-ops.h
@@ -0,0 +1,9 @@
+#ifndef XEN_OPS_H
+#define XEN_OPS_H
+
+#include <xen/xen-ops.h>
+
+void xen_register_shared_info(void);
+void xen_vcpu_restore(void);
+
+#endif /* XEN_OPS_H */
diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c
index feddabd..ce2545a 100644
--- a/arch/x86/xen/suspend.c
+++ b/arch/x86/xen/suspend.c
@@ -104,7 +104,7 @@ static void xen_vcpu_notify_suspend(void *data)
tick_suspend_local();
}
-void xen_arch_resume(void)
+void xen_arch_resume(int suspend_cancelled)
{
on_each_cpu(xen_vcpu_notify_restore, NULL, 1);
}
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index b6e4c40..a1a64bc 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -156,7 +156,7 @@ static void do_suspend(void)
si.cancelled = 1;
}
- xen_arch_resume();
+ xen_arch_resume(si.cancelled);
out_resume:
if (!si.cancelled)
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index e4e214a..d93da50 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -12,7 +12,7 @@ void xen_arch_pre_suspend(void);
void xen_arch_post_suspend(int suspend_cancelled);
void xen_timer_resume(void);
-void xen_arch_resume(void);
+void xen_arch_resume(int suspend_cancelled);
void xen_arch_suspend(void);
void xen_resume_notifier_register(struct notifier_block *nb);
--
2.1.4
next prev parent reply other threads:[~2015-12-09 14:33 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 14:31 [PATCH RFC v1 00/14] xen: arm: support for save restore and dead migration Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 01/14] xen: arm: Add gic_hw_desc Ian Campbell
2015-12-15 16:15 ` Stefano Stabellini
2015-12-15 16:21 ` Ian Campbell
2015-12-15 16:35 ` Andrew Cooper
2015-12-15 16:56 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 02/14] xen: arm: Provide a mechanism to read (and decode) an LR from a saved VCPU Ian Campbell
2015-12-15 16:22 ` Stefano Stabellini
2015-12-09 14:32 ` [PATCH RFC XEN v1 03/14] xen: arm: switch arch_do_domctl to a common exit path Ian Campbell
2015-12-15 16:34 ` Stefano Stabellini
2015-12-15 16:57 ` Ian Campbell
2015-12-15 17:07 ` Andrew Cooper
2015-12-15 17:11 ` Jan Beulich
2015-12-09 14:32 ` [PATCH RFC XEN v1 04/14] xen: arm: Implement XEN_DOMCTL_getpageframeinfo3 Ian Campbell
2015-12-15 16:44 ` Stefano Stabellini
2015-12-09 14:32 ` [PATCH RFC XEN v1 05/14] xen: arm: Implement basic XEN_DOMCTL_{set, get}hvmcontext support Ian Campbell
2015-12-15 18:00 ` Stefano Stabellini
2015-12-16 10:18 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 06/14] xen: arm: Add some basic platform info to save header Ian Campbell
2015-12-15 18:37 ` Stefano Stabellini
2015-12-16 10:20 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 07/14] xen: arm: Save and restore basic per-VCPU state Ian Campbell
2015-12-16 14:55 ` Stefano Stabellini
2015-12-16 15:04 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 08/14] xen: arm: Save and restore arch timer state Ian Campbell
2015-12-16 15:53 ` Stefano Stabellini
2015-12-16 16:02 ` Ian Campbell
2015-12-16 16:17 ` Julien Grall
2015-12-16 16:37 ` Ian Campbell
2015-12-16 18:05 ` Stefano Stabellini
2015-12-17 9:33 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 09/14] xen: arm: Save and restore GIC state Ian Campbell
2015-12-16 18:30 ` Stefano Stabellini
2015-12-17 9:54 ` Ian Campbell
2015-12-22 16:44 ` Stefano Stabellini
2015-12-09 14:32 ` [PATCH RFC XEN v1 10/14] tools: Switch a few CONFIG_MIGRATE features to CONFIG_X86 Ian Campbell
2015-12-09 15:16 ` Andrew Cooper
2015-12-09 14:32 ` [PATCH RFC XEN v1 11/14] tools: migrate: refactor selection of save/restore ops to be arch specific Ian Campbell
2015-12-09 15:26 ` Andrew Cooper
2015-12-09 15:33 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 12/14] tools: libxc: implement modify_returncode for ARM Ian Campbell
2015-12-16 16:22 ` Stefano Stabellini
2015-12-16 16:36 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 13/14] tools: libxc: wire up migration " Ian Campbell
2015-12-09 15:48 ` Andrew Cooper
2015-12-09 14:32 ` [PATCH RFC XEN v1 14/14] tools/libxl: BODGE ARM save/restore and (dead) migration Ian Campbell
2015-12-09 14:33 ` Ian Campbell [this message]
2016-01-06 17:47 ` [PATCH RFC LINUX v1] xen: arm: enable migration on ARM Stefano Stabellini
2016-01-06 17:57 ` Stefano Stabellini
2016-01-07 9:47 ` Ian Campbell
2016-01-07 9:43 ` Ian Campbell
2016-01-06 17:55 ` Stefano Stabellini
2016-01-07 9:47 ` Ian Campbell
2016-01-07 11:32 ` Stefano Stabellini
2015-12-09 15:51 ` [PATCH RFC v1 00/14] xen: arm: support for save restore and dead migration Andrew Cooper
2015-12-09 16:09 ` Ian Campbell
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=1449671617-26379-1-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=julien.grall@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.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).