* [PATCH 0/2] arm, arm64/xen: preliminary suspend support @ 2014-05-08 10:09 David Vrabel 2014-05-08 10:09 ` [PATCH 1/2] xen: refactor suspend pre/post hooks David Vrabel 2014-05-08 10:09 ` [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend David Vrabel 0 siblings, 2 replies; 6+ messages in thread From: David Vrabel @ 2014-05-08 10:09 UTC (permalink / raw) To: xen-devel; +Cc: Boris Ostrovsky, Stefano Stabellini, David Vrabel Introduce the necessary infrastructure to allow the suspend to build for the arm and arm64 architectures. The first patch refactors Xen's suspend code to allow support for new architectures to be added. The second adds HYPERVISOR_suspend and empty stubs for the arch specific calls. David ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] xen: refactor suspend pre/post hooks 2014-05-08 10:09 [PATCH 0/2] arm, arm64/xen: preliminary suspend support David Vrabel @ 2014-05-08 10:09 ` David Vrabel 2014-05-08 14:05 ` Boris Ostrovsky 2014-05-08 10:09 ` [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend David Vrabel 1 sibling, 1 reply; 6+ messages in thread From: David Vrabel @ 2014-05-08 10:09 UTC (permalink / raw) To: xen-devel; +Cc: Boris Ostrovsky, Stefano Stabellini, David Vrabel 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: David Vrabel <david.vrabel@citrix.com> --- arch/x86/xen/suspend.c | 23 ++++++++++++++++++++--- arch/x86/xen/xen-ops.h | 2 ++ drivers/xen/manage.c | 45 +++++++-------------------------------------- include/xen/xen-ops.h | 4 ---- 4 files changed, 29 insertions(+), 45 deletions(-) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index 45329c8..c4df9db 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -12,8 +12,10 @@ #include "xen-ops.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->console.domU.mfn = mfn_to_pfn(xen_start_info->console.domU.mfn); @@ -26,7 +28,7 @@ void xen_arch_pre_suspend(void) BUG(); } -void xen_arch_hvm_post_suspend(int suspend_cancelled) +static void xen_hvm_post_suspend(int suspend_cancelled) { #ifdef CONFIG_XEN_PVHVM int cpu; @@ -41,7 +43,7 @@ void xen_arch_hvm_post_suspend(int suspend_cancelled) #endif } -void xen_arch_post_suspend(int suspend_cancelled) +static void xen_pv_post_suspend(int suspend_cancelled) { xen_build_mfn_list_list(); @@ -60,6 +62,21 @@ void xen_arch_post_suspend(int suspend_cancelled) 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) diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 1cb6f4c..c834d4b 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -31,6 +31,8 @@ void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn); void xen_reserve_top(void); extern unsigned long xen_max_p2m_pfn; +void xen_mm_pin_all(void); +void xen_mm_unpin_all(void); void xen_set_pat(u64); char * __init xen_memory_setup(void); diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 32f9236..c3667b2 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c @@ -41,9 +41,6 @@ static enum shutdown_state shutting_down = SHUTDOWN_INVALID; struct suspend_info { int cancelled; - unsigned long arg; /* extra hypercall argument */ - void (*pre)(void); - void (*post)(int cancelled); }; static RAW_NOTIFIER_HEAD(xen_resume_notifier); @@ -61,26 +58,6 @@ void xen_resume_notifier_unregister(struct notifier_block *nb) EXPORT_SYMBOL_GPL(xen_resume_notifier_unregister); #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) { struct suspend_info *si = data; @@ -94,18 +71,20 @@ static int xen_suspend(void *data) return err; } - if (si->pre) - si->pre(); + gnttab_suspend(); + xen_arch_pre_suspend(); /* * This hypercall returns 1 if suspend was cancelled * or the domain was merely checkpointed, and 0 if it * 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) - si->post(si->cancelled); + xen_arch_post_suspend(si->cancelled); + gnttab_resume(); if (!si->cancelled) { xen_irq_resume(); @@ -154,16 +133,6 @@ static void do_suspend(void) 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)); raw_notifier_call_chain(&xen_resume_notifier, 0, NULL); diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index 2cf4717..0b3149e 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h @@ -9,10 +9,6 @@ DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); void xen_arch_pre_suspend(void); 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_arch_resume(void); -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] xen: refactor suspend pre/post hooks 2014-05-08 10:09 ` [PATCH 1/2] xen: refactor suspend pre/post hooks David Vrabel @ 2014-05-08 14:05 ` Boris Ostrovsky 0 siblings, 0 replies; 6+ messages in thread From: Boris Ostrovsky @ 2014-05-08 14:05 UTC (permalink / raw) To: David Vrabel; +Cc: xen-devel, Stefano Stabellini On 05/08/2014 06:09 AM, David Vrabel wrote: > 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: David Vrabel <david.vrabel@citrix.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> > --- > arch/x86/xen/suspend.c | 23 ++++++++++++++++++++--- > arch/x86/xen/xen-ops.h | 2 ++ > drivers/xen/manage.c | 45 +++++++-------------------------------------- > include/xen/xen-ops.h | 4 ---- > 4 files changed, 29 insertions(+), 45 deletions(-) > > diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c > index 45329c8..c4df9db 100644 > --- a/arch/x86/xen/suspend.c > +++ b/arch/x86/xen/suspend.c > @@ -12,8 +12,10 @@ > #include "xen-ops.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->console.domU.mfn = > mfn_to_pfn(xen_start_info->console.domU.mfn); > @@ -26,7 +28,7 @@ void xen_arch_pre_suspend(void) > BUG(); > } > > -void xen_arch_hvm_post_suspend(int suspend_cancelled) > +static void xen_hvm_post_suspend(int suspend_cancelled) > { > #ifdef CONFIG_XEN_PVHVM > int cpu; > @@ -41,7 +43,7 @@ void xen_arch_hvm_post_suspend(int suspend_cancelled) > #endif > } > > -void xen_arch_post_suspend(int suspend_cancelled) > +static void xen_pv_post_suspend(int suspend_cancelled) > { > xen_build_mfn_list_list(); > > @@ -60,6 +62,21 @@ void xen_arch_post_suspend(int suspend_cancelled) > 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) > diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h > index 1cb6f4c..c834d4b 100644 > --- a/arch/x86/xen/xen-ops.h > +++ b/arch/x86/xen/xen-ops.h > @@ -31,6 +31,8 @@ void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn); > void xen_reserve_top(void); > extern unsigned long xen_max_p2m_pfn; > > +void xen_mm_pin_all(void); > +void xen_mm_unpin_all(void); > void xen_set_pat(u64); > > char * __init xen_memory_setup(void); > diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c > index 32f9236..c3667b2 100644 > --- a/drivers/xen/manage.c > +++ b/drivers/xen/manage.c > @@ -41,9 +41,6 @@ static enum shutdown_state shutting_down = SHUTDOWN_INVALID; > > struct suspend_info { > int cancelled; > - unsigned long arg; /* extra hypercall argument */ > - void (*pre)(void); > - void (*post)(int cancelled); > }; > > static RAW_NOTIFIER_HEAD(xen_resume_notifier); > @@ -61,26 +58,6 @@ void xen_resume_notifier_unregister(struct notifier_block *nb) > EXPORT_SYMBOL_GPL(xen_resume_notifier_unregister); > > #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) > { > struct suspend_info *si = data; > @@ -94,18 +71,20 @@ static int xen_suspend(void *data) > return err; > } > > - if (si->pre) > - si->pre(); > + gnttab_suspend(); > + xen_arch_pre_suspend(); > > /* > * This hypercall returns 1 if suspend was cancelled > * or the domain was merely checkpointed, and 0 if it > * 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) > - si->post(si->cancelled); > + xen_arch_post_suspend(si->cancelled); > + gnttab_resume(); > > if (!si->cancelled) { > xen_irq_resume(); > @@ -154,16 +133,6 @@ static void do_suspend(void) > > 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)); > > raw_notifier_call_chain(&xen_resume_notifier, 0, NULL); > diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h > index 2cf4717..0b3149e 100644 > --- a/include/xen/xen-ops.h > +++ b/include/xen/xen-ops.h > @@ -9,10 +9,6 @@ DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); > > void xen_arch_pre_suspend(void); > 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_arch_resume(void); ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend 2014-05-08 10:09 [PATCH 0/2] arm, arm64/xen: preliminary suspend support David Vrabel 2014-05-08 10:09 ` [PATCH 1/2] xen: refactor suspend pre/post hooks David Vrabel @ 2014-05-08 10:09 ` David Vrabel 2014-05-08 15:54 ` Stefano Stabellini 1 sibling, 1 reply; 6+ messages in thread From: David Vrabel @ 2014-05-08 10:09 UTC (permalink / raw) To: xen-devel; +Cc: Boris Ostrovsky, Stefano Stabellini, David Vrabel From: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Introduce HYPERVISOR_suspend: it is a call to sched_op with an additional argument that is always 0 on arm and arm64. Introduce a few additional empty stubs for Xen arch specific functions called by drivers/xen/manage.c. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com> --- arch/arm/include/asm/xen/hypercall.h | 10 ++++++++++ arch/arm/xen/enlighten.c | 9 +++++++++ arch/arm/xen/hypercall.S | 6 ++++++ arch/arm64/xen/hypercall.S | 6 ++++++ 4 files changed, 31 insertions(+) diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h index 7704e28..24135be 100644 --- a/arch/arm/include/asm/xen/hypercall.h +++ b/arch/arm/include/asm/xen/hypercall.h @@ -48,6 +48,16 @@ int HYPERVISOR_memory_op(unsigned int cmd, void *arg); int HYPERVISOR_physdev_op(int cmd, void *arg); int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args); int HYPERVISOR_tmem_op(void *arg); +int HYPERVISOR_sched_op_shutdown(int cmd, void *arg, unsigned long unused); + +static inline int +HYPERVISOR_suspend(unsigned long start_info_mfn) +{ + struct sched_shutdown r = { .reason = SHUTDOWN_suspend }; + + /* start_info_mfn is unused on ARM, pass 0 instead */ + return HYPERVISOR_sched_op_shutdown(SCHEDOP_shutdown, &r, 0); +} static inline void MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index b96723e..7f01565 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -339,6 +339,14 @@ 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) { } + + /* In the hypervisor.S file. */ EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op); EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op); @@ -351,3 +359,4 @@ EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op); EXPORT_SYMBOL_GPL(privcmd_call); +EXPORT_SYMBOL_GPL(HYPERVISOR_sched_op_shutdown); diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S index d1cf7b7..7da8837 100644 --- a/arch/arm/xen/hypercall.S +++ b/arch/arm/xen/hypercall.S @@ -102,3 +102,9 @@ ENTRY(privcmd_call) ldm sp!, {r4} mov pc, lr ENDPROC(privcmd_call); + +ENTRY(HYPERVISOR_sched_op_shutdown) + mov r12, #__HYPERVISOR_sched_op + __HVC(XEN_IMM) + mov pc, lr +ENDPROC(HYPERVISOR_sched_op_shutdown) diff --git a/arch/arm64/xen/hypercall.S b/arch/arm64/xen/hypercall.S index 531342e..aa51678 100644 --- a/arch/arm64/xen/hypercall.S +++ b/arch/arm64/xen/hypercall.S @@ -91,3 +91,9 @@ ENTRY(privcmd_call) hvc XEN_IMM ret ENDPROC(privcmd_call); + +ENTRY(HYPERVISOR_sched_op_shutdown) + mov x16, #__HYPERVISOR_sched_op + hvc XEN_IMM + ret +ENDPROC(HYPERVISOR_sched_op_shutdown) -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend 2014-05-08 10:09 ` [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend David Vrabel @ 2014-05-08 15:54 ` Stefano Stabellini 2014-05-12 16:50 ` David Vrabel 0 siblings, 1 reply; 6+ messages in thread From: Stefano Stabellini @ 2014-05-08 15:54 UTC (permalink / raw) To: David Vrabel; +Cc: xen-devel, Boris Ostrovsky, Stefano Stabellini On Thu, 8 May 2014, David Vrabel wrote: > From: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > Introduce HYPERVISOR_suspend: it is a call to sched_op with an > additional argument that is always 0 on arm and arm64. Given that the third argument is not actually mandatory, we can have a simpler arm side patch: --- arm,arm64/xen: introduce HYPERVISOR_suspend Introduce HYPERVISOR_suspend. Also introduce a few additional empty stubs for Xen arch specific functions called by drivers/xen/manage.c. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com> diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h index 7658150..712b50e 100644 --- a/arch/arm/include/asm/xen/hypercall.h +++ b/arch/arm/include/asm/xen/hypercall.h @@ -34,6 +34,7 @@ #define _ASM_ARM_XEN_HYPERCALL_H #include <xen/interface/xen.h> +#include <xen/interface/sched.h> long privcmd_call(unsigned call, unsigned long a1, unsigned long a2, unsigned long a3, @@ -50,6 +51,15 @@ int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args); int HYPERVISOR_tmem_op(void *arg); int HYPERVISOR_multicall(struct multicall_entry *calls, uint32_t nr); +static inline int +HYPERVISOR_suspend(unsigned long start_info_mfn) +{ + struct sched_shutdown r = { .reason = SHUTDOWN_suspend }; + + /* start_info_mfn is unused on ARM */ + return HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); +} + static inline void MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, unsigned int new_val, unsigned long flags) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index b96723e..1a7087b 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -339,6 +339,14 @@ 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) { } + + /* In the hypervisor.S file. */ EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op); EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend 2014-05-08 15:54 ` Stefano Stabellini @ 2014-05-12 16:50 ` David Vrabel 0 siblings, 0 replies; 6+ messages in thread From: David Vrabel @ 2014-05-12 16:50 UTC (permalink / raw) To: Stefano Stabellini; +Cc: xen-devel, Boris Ostrovsky On 08/05/14 16:54, Stefano Stabellini wrote: > On Thu, 8 May 2014, David Vrabel wrote: >> From: Stefano Stabellini <stefano.stabellini@eu.citrix.com> >> >> Introduce HYPERVISOR_suspend: it is a call to sched_op with an >> additional argument that is always 0 on arm and arm64. > > Given that the third argument is not actually mandatory, we can have a > simpler arm side patch: Thanks. Applied to devel/for-linus-3.16 David ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-12 16:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-05-08 10:09 [PATCH 0/2] arm, arm64/xen: preliminary suspend support David Vrabel 2014-05-08 10:09 ` [PATCH 1/2] xen: refactor suspend pre/post hooks David Vrabel 2014-05-08 14:05 ` Boris Ostrovsky 2014-05-08 10:09 ` [PATCH 2/2] arm, arm64/xen: introduce HYPERVISOR_suspend David Vrabel 2014-05-08 15:54 ` Stefano Stabellini 2014-05-12 16:50 ` David Vrabel
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).