Commit aa8532c3 authored by David Vrabel's avatar David Vrabel

xen: refactor suspend pre/post hooks

New architectures currently have to provide implementations of 5 different
functions: xen_arch_pre_suspend(), xen_arch_post_suspend(),
xen_arch_hvm_post_suspend(), xen_mm_pin_all(), and xen_mm_unpin_all().

Refactor the suspend code to only require xen_arch_pre_suspend() and
xen_arch_post_suspend().
Signed-off-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent 9f1d3414
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
#include "xen-ops.h" #include "xen-ops.h"
#include "mmu.h" #include "mmu.h"
void xen_arch_pre_suspend(void) static void xen_pv_pre_suspend(void)
{ {
xen_mm_pin_all();
xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn); xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
xen_start_info->console.domU.mfn = xen_start_info->console.domU.mfn =
mfn_to_pfn(xen_start_info->console.domU.mfn); mfn_to_pfn(xen_start_info->console.domU.mfn);
...@@ -26,7 +28,7 @@ void xen_arch_pre_suspend(void) ...@@ -26,7 +28,7 @@ void xen_arch_pre_suspend(void)
BUG(); BUG();
} }
void xen_arch_hvm_post_suspend(int suspend_cancelled) static void xen_hvm_post_suspend(int suspend_cancelled)
{ {
#ifdef CONFIG_XEN_PVHVM #ifdef CONFIG_XEN_PVHVM
int cpu; int cpu;
...@@ -41,7 +43,7 @@ void xen_arch_hvm_post_suspend(int suspend_cancelled) ...@@ -41,7 +43,7 @@ void xen_arch_hvm_post_suspend(int suspend_cancelled)
#endif #endif
} }
void xen_arch_post_suspend(int suspend_cancelled) static void xen_pv_post_suspend(int suspend_cancelled)
{ {
xen_build_mfn_list_list(); xen_build_mfn_list_list();
...@@ -60,6 +62,21 @@ void xen_arch_post_suspend(int suspend_cancelled) ...@@ -60,6 +62,21 @@ void xen_arch_post_suspend(int suspend_cancelled)
xen_vcpu_restore(); xen_vcpu_restore();
} }
xen_mm_unpin_all();
}
void xen_arch_pre_suspend(void)
{
if (xen_pv_domain())
xen_pv_pre_suspend();
}
void xen_arch_post_suspend(int cancelled)
{
if (xen_pv_domain())
xen_pv_post_suspend(cancelled);
else
xen_hvm_post_suspend(cancelled);
} }
static void xen_vcpu_notify_restore(void *data) static void xen_vcpu_notify_restore(void *data)
......
...@@ -31,6 +31,8 @@ void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn); ...@@ -31,6 +31,8 @@ void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn);
void xen_reserve_top(void); void xen_reserve_top(void);
extern unsigned long xen_max_p2m_pfn; extern unsigned long xen_max_p2m_pfn;
void xen_mm_pin_all(void);
void xen_mm_unpin_all(void);
void xen_set_pat(u64); void xen_set_pat(u64);
char * __init xen_memory_setup(void); char * __init xen_memory_setup(void);
......
...@@ -41,9 +41,6 @@ static enum shutdown_state shutting_down = SHUTDOWN_INVALID; ...@@ -41,9 +41,6 @@ static enum shutdown_state shutting_down = SHUTDOWN_INVALID;
struct suspend_info { struct suspend_info {
int cancelled; int cancelled;
unsigned long arg; /* extra hypercall argument */
void (*pre)(void);
void (*post)(int cancelled);
}; };
static RAW_NOTIFIER_HEAD(xen_resume_notifier); static RAW_NOTIFIER_HEAD(xen_resume_notifier);
...@@ -61,26 +58,6 @@ void xen_resume_notifier_unregister(struct notifier_block *nb) ...@@ -61,26 +58,6 @@ void xen_resume_notifier_unregister(struct notifier_block *nb)
EXPORT_SYMBOL_GPL(xen_resume_notifier_unregister); EXPORT_SYMBOL_GPL(xen_resume_notifier_unregister);
#ifdef CONFIG_HIBERNATE_CALLBACKS #ifdef CONFIG_HIBERNATE_CALLBACKS
static void xen_hvm_post_suspend(int cancelled)
{
xen_arch_hvm_post_suspend(cancelled);
gnttab_resume();
}
static void xen_pre_suspend(void)
{
xen_mm_pin_all();
gnttab_suspend();
xen_arch_pre_suspend();
}
static void xen_post_suspend(int cancelled)
{
xen_arch_post_suspend(cancelled);
gnttab_resume();
xen_mm_unpin_all();
}
static int xen_suspend(void *data) static int xen_suspend(void *data)
{ {
struct suspend_info *si = data; struct suspend_info *si = data;
...@@ -94,18 +71,20 @@ static int xen_suspend(void *data) ...@@ -94,18 +71,20 @@ static int xen_suspend(void *data)
return err; return err;
} }
if (si->pre) gnttab_suspend();
si->pre(); xen_arch_pre_suspend();
/* /*
* This hypercall returns 1 if suspend was cancelled * This hypercall returns 1 if suspend was cancelled
* or the domain was merely checkpointed, and 0 if it * or the domain was merely checkpointed, and 0 if it
* is resuming in a new domain. * is resuming in a new domain.
*/ */
si->cancelled = HYPERVISOR_suspend(si->arg); si->cancelled = HYPERVISOR_suspend(xen_pv_domain()
? virt_to_mfn(xen_start_info)
: 0);
if (si->post) xen_arch_post_suspend(si->cancelled);
si->post(si->cancelled); gnttab_resume();
if (!si->cancelled) { if (!si->cancelled) {
xen_irq_resume(); xen_irq_resume();
...@@ -154,16 +133,6 @@ static void do_suspend(void) ...@@ -154,16 +133,6 @@ static void do_suspend(void)
si.cancelled = 1; si.cancelled = 1;
if (xen_hvm_domain()) {
si.arg = 0UL;
si.pre = NULL;
si.post = &xen_hvm_post_suspend;
} else {
si.arg = virt_to_mfn(xen_start_info);
si.pre = &xen_pre_suspend;
si.post = &xen_post_suspend;
}
err = stop_machine(xen_suspend, &si, cpumask_of(0)); err = stop_machine(xen_suspend, &si, cpumask_of(0));
raw_notifier_call_chain(&xen_resume_notifier, 0, NULL); raw_notifier_call_chain(&xen_resume_notifier, 0, NULL);
......
...@@ -9,10 +9,6 @@ DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); ...@@ -9,10 +9,6 @@ DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
void xen_arch_pre_suspend(void); void xen_arch_pre_suspend(void);
void xen_arch_post_suspend(int suspend_cancelled); void xen_arch_post_suspend(int suspend_cancelled);
void xen_arch_hvm_post_suspend(int suspend_cancelled);
void xen_mm_pin_all(void);
void xen_mm_unpin_all(void);
void xen_timer_resume(void); void xen_timer_resume(void);
void xen_arch_resume(void); void xen_arch_resume(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment