Save/Restore Support for mini-OS PVH
Subsystems (3)
cover Save/Restore Support for mini-OS PVH
Hi all,
I have been working on supporting save/restore for mini-os PVH. Some parts of the implementation were taken from the sysml/mini-os repository. The branch can be found at:
https://github.com/balvisio/mini-os/tree/feature/mini-os-suspend-support
Any feedback would be greatly appreciated.
Cheers,
Bruno
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 1/16 Save/Restore Support: Refactor HYPERVISOR_suspend hypercall
Directly using the SHUTDOWN_suspend macro as a parameter for the schedop hypercall causes an error in the Xen hypercall handler. Also for consistency, the SHUTDOWN_suspend param is wrapped in the sched_shutdown struct.
--- include/x86/x86_32/hypercall-x86_32.h | 4 ++-- include/x86/x86_64/hypercall-x86_64.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/x86/x86_32/hypercall-x86_32.h +2 -2
@@ -298,8 +298,8 @@ static inline intHYPERVISOR_suspend ( unsigned long srec) { -return _hypercall3 (int, sched_op, SCHEDOP_shutdown, - SHUTDOWN_suspend, srec); +struct sched_shutdown shutdown = { .reason = SHUTDOWN_suspend }; +return _hypercall3 (int, sched_op, SCHEDOP_shutdown, &shutdown, srec); } static inline int
include/x86/x86_64/hypercall-x86_64.h +2 -2
@@ -305,8 +305,8 @@ static inline intHYPERVISOR_suspend ( unsigned long srec) { -return _hypercall3 (int, sched_op, SCHEDOP_shutdown, - SHUTDOWN_suspend, srec); +struct sched_shutdown shutdown = { .reason = SHUTDOWN_suspend }; +return _hypercall3 (int, sched_op, SCHEDOP_shutdown, &shutdown, srec); } static inline int
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 01/16] Save/Restore Support: Refactor HYPERVISOR_suspend hypercall
Quoted 5 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:41:56 -0800, wrote:
Directly using the
SHUTDOWN_suspendmacro as a parameter for the schedop hypercall causes an error in the Xen hypercall handler. Also for consistency, theSHUTDOWN_suspendparam is wrapped in thesched_shutdownstruct.Signed-off-by Bruno Alvisio <[email protected]>
Quoted 43 lines
--- include/x86/x86_32/hypercall-x86_32.h | 4 ++-- include/x86/x86_64/hypercall-x86_64.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)include/x86/x86_32/hypercall-x86_32.h +2
-2@@ -298,8 +298,8 @@ static inline intHYPERVISOR_suspend ( unsigned long srec) { -return _hypercall3 (int, sched_op, SCHEDOP_shutdown, - SHUTDOWN_suspend, srec); +struct sched_shutdown shutdown = { .reason = SHUTDOWN_suspend }; +return _hypercall3 (int, sched_op, SCHEDOP_shutdown, &shutdown, srec); } static inline intinclude/x86/x86_64/hypercall-x86_64.h +2
-2@@ -305,8 +305,8 @@ static inline intHYPERVISOR_suspend ( unsigned long srec) { -return _hypercall3 (int, sched_op, SCHEDOP_shutdown, - SHUTDOWN_suspend, srec); +struct sched_shutdown shutdown = { .reason = SHUTDOWN_suspend }; +return _hypercall3 (int, sched_op, SCHEDOP_shutdown, &shutdown, srec); } static inline intSignature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 8 lines
Samuel <T> csp.tar.gz: ascii text -+- #ens-mim - vive les browsers qui prennent des initiatives à la con -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 2/16 Save/Restore Support: Refactor trap_init() and setup vector callbacks
In reply to Bruno AlvisioCurrently the setup of the IDT and the request to set the HVM vector callbacks are performed both in the trap_init function.
As part of the post-suspend operation, the HVM vector callback needs to be setup again while the IDT does not. Thus, the trap_init function is split into two separate functions: trap_init (sets up IDT) and xen_callback_vector (sets the HVM vector callback). During the post-suspend operations the xen_callback_vector function will be invoked.
--- arch/x86/traps.c | 17 +++++++++++------ include/x86/os.h | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-)
arch/x86/traps.c +11 -6
@@ -389,6 +389,16 @@ static void setup_gate(unsigned int entry, void *addr, unsigned int dpl)#endif } +void xen_callback_vector (void ) +{ +if (hvm_set_parameter (HVM_PARAM_CALLBACK_IRQ , + (2ULL <<56 ) | TRAP_xen_callback)) + { +xprintk ("Request for Xen HVM callback vector failed\n" ); +do_exit (); + } +} +void trap_init (void ) {setup_gate (TRAP_divide_error, ÷_error,0 );
@@ -415,12 +425,7 @@ void trap_init(void) gdt[GDTE_TSS] = (typeof(*gdt))INIT_GDTE((unsigned long)&tss, 0x67, 0x89); asmvolatile ("ltr %w0" ::"rm" (GDTE_TSS *8 )); -if (hvm_set_parameter (HVM_PARAM_CALLBACK_IRQ , - (2ULL <<56 ) | TRAP_xen_callback) ) - { -xprintk ("Request for Xen HVM callback vector failed\n" ); -do_exit (); - } +xen_callback_vector (); }void trap_fini (void )
include/x86/os.h +3 -0
@@ -67,6 +67,9 @@ extern shared_info_t *HYPERVISOR_shared_info;void trap_init (void );void trap_fini (void ); +#ifndef CONFIG_PARAVIRT +void xen_callback_vector (void ); +#endif void arch_fini (void );
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 02/16] Save/Restore Support: Refactor trap_init() and setup vector callbacks
Quoted 10 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:41:57 -0800, wrote:
Currently the setup of the IDT and the request to set the HVM vector callbacks are performed both in the
trap_initfunction.As part of the post-suspend operation, the HVM vector callback needs to be setup again while the IDT does not. Thus, the
trap_initfunction is split into two separate functions:trap_init(sets up IDT) andxen_callback_vector(sets the HVM vector callback). During the post-suspend operations thexen_callback_vectorfunction will be invoked.Signed-off-by Bruno Alvisio <[email protected]>
Quoted 62 lines
--- arch/x86/traps.c | 17 +++++++++++------ include/x86/os.h | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-)arch/x86/traps.c +11
-6@@ -389,6 +389,16 @@ static void setup_gate(unsigned int entry, void *addr, unsigned int dpl)#endif } +void xen_callback_vector (void ) +{ +if (hvm_set_parameter (HVM_PARAM_CALLBACK_IRQ , + (2ULL <<56 ) | TRAP_xen_callback)) + { +xprintk ("Request for Xen HVM callback vector failed\n" ); +do_exit (); + } +} +void trap_init (void ) {setup_gate (TRAP_divide_error, ÷_error,0 );@@ -415,12 +425,7 @@ void trap_init(void) gdt[GDTE_TSS] = (typeof(*gdt))INIT_GDTE((unsigned long)&tss, 0x67, 0x89); asmvolatile ("ltr %w0" ::"rm" (GDTE_TSS *8 )); -if (hvm_set_parameter (HVM_PARAM_CALLBACK_IRQ , - (2ULL <<56 ) | TRAP_xen_callback) ) - { -xprintk ("Request for Xen HVM callback vector failed\n" ); -do_exit (); - } +xen_callback_vector (); }void trap_fini (void )include/x86/os.h +3
-0@@ -67,6 +67,9 @@ extern shared_info_t *HYPERVISOR_shared_info;void trap_init (void );void trap_fini (void ); +#ifndef CONFIG_PARAVIRT +void xen_callback_vector (void ); +#endif void arch_fini (void );Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 9 lines
Samuel <O> Ça peut être une madeleine à sous munitions (avec des composants, par exemple) -+- #runtime -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 3/16 Save/Restore Support: Declare kernel and arch pre/post suspend functions
In reply to Bruno AlvisioFor mini-OS to support suspend and restore, the kernel will have to suspend different modules such as xenbus, console, irq, etc. During save/restore the kernel and arch pre_suspend and post_suspend functions will be invoked to suspend/resume each of the modules.
--- arch/x86/setup.c | 10 ++++++++++ include/kernel.h | 2 ++ include/x86/os.h | 4 ++-- kernel.c | 10 ++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-)
arch/x86/setup.c +10 -0
@@ -204,6 +204,16 @@ arch_init(void *par)start_kernel (); } +void arch_pre_suspend (void ) +{ + +} + +void arch_post_suspend (int canceled) +{ + +} +void arch_fini (void ) {
include/kernel.h +2 -0
@@ -5,6 +5,8 @@extern char cmdline[MAX_CMDLINE_SIZE ];void start_kernel (void ); +void pre_suspend (void ); +void post_suspend (int canceled);void do_exit (void ) __attribute__((noreturn));void arch_do_exit (void );void stop_kernel (void );
include/x86/os.h +2 -2
@@ -71,10 +71,10 @@ void trap_fini(void);void xen_callback_vector (void );#endif +void arch_pre_suspend (void ); +void arch_post_suspend (int canceled);void arch_fini (void ); - -#ifdef CONFIG_PARAVIRT /*
kernel.c +10 -0
@@ -155,6 +155,16 @@ void start_kernel(void)run_idle_thread (); } +void pre_suspend (void ) +{ + +} + +void post_suspend (int canceled) +{ + +} +void stop_kernel (void ) {/* TODO: fs import */
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 03/16] Save/Restore Support: Declare kernel and arch pre/post suspend functions
Quoted 6 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:41:58 -0800, wrote:
For mini-OS to support suspend and restore, the kernel will have to suspend different modules such as xenbus, console, irq, etc. During save/restore the kernel and arch
pre_suspendandpost_suspendfunctions will be invoked to suspend/resume each of the modules.Signed-off-by Bruno Alvisio <[email protected]>
Quoted 87 lines
--- arch/x86/setup.c | 10 ++++++++++ include/kernel.h | 2 ++ include/x86/os.h | 4 ++-- kernel.c | 10 ++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-)arch/x86/setup.c +10
-0@@ -204,6 +204,16 @@ arch_init(void *par)start_kernel (); } +void arch_pre_suspend (void ) +{ + +} + +void arch_post_suspend (int canceled) +{ + +} +void arch_fini (void ) {include/kernel.h +2
-0@@ -5,6 +5,8 @@extern char cmdline[MAX_CMDLINE_SIZE ];void start_kernel (void ); +void pre_suspend (void ); +void post_suspend (int canceled);void do_exit (void ) __attribute__((noreturn));void arch_do_exit (void );void stop_kernel (void );include/x86/os.h +2
-2@@ -71,10 +71,10 @@ void trap_fini(void);void xen_callback_vector (void );#endif +void arch_pre_suspend (void ); +void arch_post_suspend (int canceled);void arch_fini (void ); - -#ifdef CONFIG_PARAVIRT /* kernel.c +10
-0@@ -155,6 +155,16 @@ void start_kernel(void)run_idle_thread (); } +void pre_suspend (void ) +{ + +} + +void post_suspend (int canceled) +{ + +} +void stop_kernel (void ) {/* TODO: fs import */ Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 7 lines
Samuel <g> r: et la marmotte, elle écrit un papier IPDPS _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 4/16 Save/Restore Support: Add xenbus_release_wait_for_watch
In reply to Bruno Alvisioxenbus_release_wait_for_watch generates a fake event to trigger make xenbus_wait_for_watch return. This is necessary to wake up waiting threads.
--- include/xenbus.h | 1 + xenbus/xenbus.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
include/xenbus.h +1 -0
@@ -42,6 +42,7 @@ char *xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, consextern struct wait_queue_head xenbus_watch_queue;void xenbus_wait_for_watch (xenbus_event_queue *queue);char **xenbus_wait_for_watch_return (xenbus_event_queue *queue); +void xenbus_release_wait_for_watch (xenbus_event_queue *queue);char *xenbus_wait_for_value (const char *path,const char *value,xenbus_event_queue *queue);char *xenbus_wait_for_state_change (const char * path,XenbusState *state,xenbus_event_queue *queue);char *xenbus_switch_state (xenbus_transaction_t xbt,const char * path,XenbusState state);
xenbus/xenbus.c +9 -1
@@ -129,6 +129,14 @@ void xenbus_wait_for_watch(xenbus_event_queue *queue)printk ("unexpected path returned by watch\n" ); } +void xenbus_release_wait_for_watch (xenbus_event_queue *queue) +{ +struct xenbus_event *event =malloc (sizeof (*event)); + event->next = *queue; + *queue = event; +wake_up (&xenbus_watch_queue); +} +char *xenbus_wait_for_value (const char * path,const char * value,xenbus_event_queue *queue) {if (!queue)
@@ -318,7 +326,7 @@ static void release_xenbus_id(int id) req_info[id].in_use =0 ; nr_live_reqs--; req_info[id].in_use =0 ; -if (nr_live_reqs ==NR_REQS -1 ) +if (nr_live_reqs ==0 || nr_live_reqs ==NR_REQS -1 )wake_up (&req_wq);spin_unlock (&req_lock); }
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 04/16] Save/Restore Support: Add xenbus_release_wait_for_watch
Quoted 2 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:41:59 -0800, wrote:
xenbus_release_wait_for_watchgenerates a fake event to trigger makexenbus_wait_for_watchreturn. This is necessary to wake up waiting threads.
Please also document the release_xenbus_id change.
Quoted 1 line
Signed-off-by Bruno Alvisio <[email protected]>
Quoted 53 lines
--- include/xenbus.h | 1 + xenbus/xenbus.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)include/xenbus.h +1
-0@@ -42,6 +42,7 @@ char *xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, consextern struct wait_queue_head xenbus_watch_queue;void xenbus_wait_for_watch (xenbus_event_queue *queue);char **xenbus_wait_for_watch_return (xenbus_event_queue *queue); +void xenbus_release_wait_for_watch (xenbus_event_queue *queue);char *xenbus_wait_for_value (const char *path,const char *value,xenbus_event_queue *queue);char *xenbus_wait_for_state_change (const char * path,XenbusState *state,xenbus_event_queue *queue);char *xenbus_switch_state (xenbus_transaction_t xbt,const char * path,XenbusState state);xenbus/xenbus.c +9
-1@@ -129,6 +129,14 @@ void xenbus_wait_for_watch(xenbus_event_queue *queue)printk ("unexpected path returned by watch\n" ); } +void xenbus_release_wait_for_watch (xenbus_event_queue *queue) +{ +struct xenbus_event *event =malloc (sizeof (*event)); + event->next = *queue; + *queue = event; +wake_up (&xenbus_watch_queue); +} +char *xenbus_wait_for_value (const char * path,const char * value,xenbus_event_queue *queue) {if (!queue)@@ -318,7 +326,7 @@ static void release_xenbus_id(int id) req_info[id].in_use =0 ; nr_live_reqs--; req_info[id].in_use =0 ; -if (nr_live_reqs ==NR_REQS -1 ) +if (nr_live_reqs ==0 || nr_live_reqs ==NR_REQS -1 )wake_up (&req_wq);spin_unlock (&req_lock); }Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 7 lines
Samuel "c'est pas nous qui sommes à la rue, c'est la rue qui est à nous" _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 5/16 Save/Restore Support: Add kernel shutdown logic to shutdown.c
In reply to Bruno AlvisioCreated shutdown.c for the shutdown thread and all the shutdown related functions.
--- Makefile | 1 + include/shutdown.h | 11 ++++ shutdown.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 include/shutdown.h create mode 100644 shutdown.c
Makefile +1 -0
@@ -53,6 +53,7 @@ src-y += mm.c src-$(CONFIG_NETFRONT) += netfront.c src-$(CONFIG_PCIFRONT) += pcifront.c src-y += sched.c +src-y += shutdown.c src-$(CONFIG_TEST) += test.c src-$(CONFIG_BALLOON) += balloon.c
include/shutdown.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef _SHUTDOWN_H_ +#define _SHUTDOWN_H_ + +#include <mini-os/hypervisor.h> + +void init_shutdown (start_info_t *si); + +void kernel_shutdown (int reason) __attribute__((noreturn)); +void kernel_suspend (void ); + +#endif
shutdown.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
2.3.2 (Apple Git-55)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 05/16] Save/Restore Support: Add kernel shutdown logic to shutdown.c
Quoted 24 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:42:00 -0800, wrote:
+ * NEC Europe Ltd. PROPRIETARY INFORMATION
+ *
+ * This software is supplied under the terms of a license agreement
+ * or nondisclosure agreement with NEC Europe Ltd. and may not be
+ * copied or disclosed except in accordance with the terms of that
+ * agreement. The software and its source code contain valuable trade
+ * secrets and confidential information which have to be maintained in
+ * confidence.
+ * Any unauthorized publication, transfer to third parties or duplication
+ * of the object or source code - either totally or in part – is
+ * prohibited.
+ *
+ * Copyright (c) 2014 NEC Europe Ltd. All Rights Reserved.
+ *
+ * Authors: Filipe Manco <[email protected]>
+ *
+ * NEC Europe Ltd. DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE AND THE WARRANTY AGAINST LATENT
+ * DEFECTS, WITH RESPECT TO THE PROGRAM AND THE ACCOMPANYING
+ * DOCUMENTATION.
+ *
+ * No Liability For Consequential Damages IN NO EVENT SHALL NEC Europe
+ * Ltd., NEC Corporation OR ANY OF ITS SUBSIDIARIES BE LIABLE FOR ANY
Quoted 8 lines
+ * DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS
+ * OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF INFORMATION, OR
+ * OTHER PECUNIARY LOSS AND INDIRECT, CONSEQUENTIAL, INCIDENTAL,
+ * ECONOMIC OR PUNITIVE DAMAGES) ARISING OUT OF THE USE OF OR INABILITY
+ * TO USE THIS PROGRAM, EVEN IF NEC Europe Ltd. HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
Err, AIUI, this makes it unusable for mini-os (or whatever free software).
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 05/16] Save/Restore Support: Add kernel shutdown logic to shutdown.c
In reply to Bruno Alvisio.snip..
Quoted 7 lines
shutdown.c new file +1
-0@@ -0,0 +1,188 @@ +/*
shutdown.c line 11
Quoted 10 lines
shutdown.c new file +10
-0+* MiniOS +* +* file: fromdevice.cc +* +* NEC Europe Ltd. PROPRIETARY INFORMATION +* +* This software is supplied under the terms of a license agreement +* or nondisclosure agreement with NEC Europe Ltd. and may not be +* copied or disclosed except in accordance with the terms of that +* agreement. The software and its source code contain valuable trade
Um?!?
shutdown.c line 16
Quoted 5 lines
shutdown.c new file +5
-0+* secrets and confidential information which have to be maintained in +* confidence. +* Any unauthorized publication, transfer to third parties or duplication +* of the object or source code - either totally or in part – is +* prohibited.
So ... this needs to be a different license I think.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 6/16 Save/Restore Support: Moved shutdown thread to shutdown.c
In reply to Bruno AlvisioThe shutdown thread present in kernel.c was removed and now the thread in shutdown.c is created instead.
--- arch/x86/setup.c | 2 +- include/kernel.h | 2 +- kernel.c | 50 ++++++-------------------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-)
arch/x86/setup.c +1 -1
@@ -201,7 +201,7 @@ arch_init(void *par)memcpy (&start_info, par,sizeof (start_info));#endif -start_kernel (); +start_kernel ((start_info_t *)par); }void arch_pre_suspend (void )
include/kernel.h +1 -1
@@ -4,7 +4,7 @@#define MAX_CMDLINE_SIZE 1024extern char cmdline[MAX_CMDLINE_SIZE ]; -void start_kernel (void ); +void start_kernel (void * par);void pre_suspend (void );void post_suspend (int canceled);void do_exit (void ) __attribute__((noreturn));
kernel.c +6 -44
74 lines not on this page · raw message
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 7/16 Save/Restore Support: Add unmap_shared_info
In reply to Bruno AlvisioThis function is necessary as part of the pre-suspend operation.
--- arch/x86/setup.c | 12 ++++++++++++ hypervisor.c | 12 ++++++++++++ include/hypervisor.h | 1 + 3 files changed, 25 insertions(+)
arch/x86/setup.c +12 -0
@@ -93,6 +93,18 @@ shared_info_t *map_shared_info(void *p)return (shared_info_t *)shared_info; } +void unmap_shared_info (void ) +{ +int rc; + +if ( (rc =HYPERVISOR_update_va_mapping ((unsigned long )HYPERVISOR_shared_info, +__pte ((virt_to_mfn (shared_info)<<L1_PAGETABLE_SHIFT )|L1_PROT ),UVMF_INVLPG )) ) + { +printk ("Failed to unmap shared_info page!! rc=%d\n" , rc); +do_exit (); + } +} +static void get_cmdline (void *p) {start_info_t *si = p;
hypervisor.c +12 -0
@@ -78,6 +78,18 @@ shared_info_t *map_shared_info(void *p) return &shared_info; } + +void unmap_shared_info (void ) +{ +struct xen_remove_from_physmap xrtp; + + xrtp.domid =DOMID_SELF ; + xrtp.gpfn =virt_to_pfn (&shared_info); +if (HYPERVISOR_memory_op (XENMEM_remove_from_physmap, &xrtp) !=0 ) +BUG (); + +return ; +}#endif void do_hypervisor_callback (struct pt_regs *regs)
include/hypervisor.h +1 -0
@@ -43,6 +43,7 @@ int hvm_get_parameter(int idx, uint64_t *value);int hvm_set_parameter (int idx,uint64_t value);#endif shared_info_t *map_shared_info (void *p); +void unmap_shared_info (void );void force_evtchn_callback (void );void do_hypervisor_callback (struct pt_regs *regs);void mask_evtchn (uint32_t port);
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 07/16] Save/Restore Support: Add unmap_shared_info
arch/x86/setup.c shared_info_t *map_shared_info(void *p) · line 100
Quoted 10 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:42:02 -0800, wrote:
This function is necessary as part of the pre-suspend operation.
Signed-off-by Bruno Alvisio <[email protected]>---
arch/x86/setup.c +5
-0+void unmap_shared_info(void) +{ + int rc; + + if ( (rc = HYPERVISOR_update_va_mapping((unsigned long)HYPERVISOR_shared_info,
For coherency, I'd say use shared_info there too.
Apart from that,
Quoted 53 lines
arch/x86/setup.c +7
-0+ __pte((virt_to_mfn(shared_info)<<L1_PAGETABLE_SHIFT)| L1_PROT), UVMF_INVLPG)) ) + { +printk ("Failed to unmap shared_info page!! rc=%d\n" , rc); +do_exit (); + } +} +static void get_cmdline (void *p) {start_info_t *si = p;hypervisor.c +12
-0@@ -78,6 +78,18 @@ shared_info_t *map_shared_info(void *p) return &shared_info; } + +void unmap_shared_info (void ) +{ +struct xen_remove_from_physmap xrtp; + + xrtp.domid =DOMID_SELF ; + xrtp.gpfn =virt_to_pfn (&shared_info); +if (HYPERVISOR_memory_op (XENMEM_remove_from_physmap, &xrtp) !=0 ) +BUG (); + +return ; +}#endif void do_hypervisor_callback (struct pt_regs *regs)include/hypervisor.h +1
-0@@ -43,6 +43,7 @@ int hvm_get_parameter(int idx, uint64_t *value);int hvm_set_parameter (int idx,uint64_t value);#endif shared_info_t *map_shared_info (void *p); +void unmap_shared_info (void );void force_evtchn_callback (void );void do_hypervisor_callback (struct pt_regs *regs);void mask_evtchn (uint32_t port);Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 7 lines
Samuel <y> la vraie vie, c'est quand le prompt passe de $ à # _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 8/16 Save/Restore Support: Add arch_mm_pre|post_suspend
In reply to Bruno AlvisioFor PV guests the pagetables reference the real MFNs rather than PFNs, so when the guest is resumed into a different area of a hosts memory, these will need to be rewritten. Thus for PV guests the MFNs need to be replaced with PFNs:
canonicalization.
PVH guests are auto-translated so no memory operation is needed.
--- arch/x86/mm.c | 14 ++++++++++++++ include/x86/arch_mm.h | 3 +++ 2 files changed, 17 insertions(+)
arch/x86/mm.c +14 -0
@@ -848,6 +848,20 @@ void arch_init_p2m(unsigned long max_pfn) arch_remap_p2m(max_pfn); } + +void arch_mm_pre_suspend (void ) +{ +//TODO: Canonicalize pagetables +} + +void arch_mm_post_suspend (int canceled) +{ +//TODO: Locate pagetables and 'uncanonicalize' them +} +#else +void arch_mm_pre_suspend (void ){ } + +void arch_mm_post_suspend (int canceled){ }#endif void arch_init_mm (unsigned long * start_pfn_p,unsigned long * max_pfn_p)
include/x86/arch_mm.h +3 -0
@@ -279,6 +279,9 @@ pgentry_t *need_pgt(unsigned long addr);void arch_mm_preinit (void *p);unsigned long alloc_virt_kernel (unsigned n_pages); +void arch_mm_pre_suspend (void ); +void arch_mm_post_suspend (int canceled); +#ifndef CONFIG_PARAVIRT void arch_print_memmap (void );#endif
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 08/16] Save/Restore Support: Add arch_mm_pre|post_suspend
Quoted 8 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:42:03 -0800, wrote:
For PV guests the pagetables reference the real MFNs rather than PFNs, so when the guest is resumed into a different area of a hosts memory, these will need to be rewritten. Thus for PV guests the MFNs need to be replaced with PFNs:
canonicalization.PVH guests are auto-translated so no memory operation is needed.
Signed-off-by Bruno Alvisio <[email protected]>
Quoted 52 lines
--- arch/x86/mm.c | 14 ++++++++++++++ include/x86/arch_mm.h | 3 +++ 2 files changed, 17 insertions(+)arch/x86/mm.c +14
-0@@ -848,6 +848,20 @@ void arch_init_p2m(unsigned long max_pfn) arch_remap_p2m(max_pfn); } + +void arch_mm_pre_suspend (void ) +{ +//TODO: Canonicalize pagetables +} + +void arch_mm_post_suspend (int canceled) +{ +//TODO: Locate pagetables and 'uncanonicalize' them +} +#else +void arch_mm_pre_suspend (void ){ } + +void arch_mm_post_suspend (int canceled){ }#endif void arch_init_mm (unsigned long * start_pfn_p,unsigned long * max_pfn_p)include/x86/arch_mm.h +3
-0@@ -279,6 +279,9 @@ pgentry_t *need_pgt(unsigned long addr);void arch_mm_preinit (void *p);unsigned long alloc_virt_kernel (unsigned n_pages); +void arch_mm_pre_suspend (void ); +void arch_mm_post_suspend (int canceled); +#ifndef CONFIG_PARAVIRT void arch_print_memmap (void );#endif Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 10 lines
Samuel J'ai un gros problème: j'ai cet exercice à rendre demain lundi, mais ma TI 89 ne sait pas le faire... Est-ce que quelqu'un pourrait m'aider?? -+- OD In Guide du Neuneu Usenet : Comment ça ! Il faut réfléchir ?-+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 9/16 Save/Restore Support: Disable/enable IRQs during suspend/restore
In reply to Bruno Alvisio--- kernel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel.c +2 -2
@@ -119,12 +119,12 @@ void start_kernel(void* par)void pre_suspend (void ) { - +local_irq_disable (); }void post_suspend (int canceled) { - +local_irq_enable (); }void stop_kernel (void )
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 09/16] Save/Restore Support: Disable/enable IRQs during suspend/restore
Quoted 1 line · Bruno Alvisio, on mar. 19 déc. 2017 15:42:04 -0800, wrote:
Signed-off-by Bruno Alvisio <[email protected]>
Quoted 31 lines
--- kernel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel.c +2
-2@@ -119,12 +119,12 @@ void start_kernel(void* par)void pre_suspend (void ) { - +local_irq_disable (); }void post_suspend (int canceled) { - +local_irq_enable (); }void stop_kernel (void )Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 8 lines
Samuel Q: How do you play religious roulette? A: You stand around in a circle and blaspheme and see who gets struck by lightning first. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 10/16 Save/Restore Support: Add suspend/resume support for timers
In reply to Bruno Alvisio--- arch/x86/time.c | 13 +++++++++++++ include/time.h | 2 ++ kernel.c | 4 ++++ 3 files changed, 19 insertions(+)
arch/x86/time.c +13 -0
@@ -244,3 +244,16 @@ void fini_time(void)HYPERVISOR_set_timer_op (0 );unbind_evtchn (port); } + +void suspend_time (void ) +{ +/* Clear any pending timer */ +HYPERVISOR_set_timer_op (0 ); +unbind_evtchn (port); +} + +void resume_time (void ) +{ + port =bind_virq (VIRQ_TIMER , &timer_handler,NULL ); +unmask_evtchn (port); +}
include/time.h +2 -0
@@ -55,6 +55,8 @@ typedef long suseconds_t;/* prototypes */ void init_time (void );void fini_time (void ); +void suspend_time (void ); +void resume_time (void );s_time_t get_s_time (void );s_time_t get_v_time (void );uint64_t monotonic_clock (void );
kernel.c +4 -0
@@ -120,10 +120,14 @@ void start_kernel(void* par)void pre_suspend (void ) {local_irq_disable (); + +suspend_time (); }void post_suspend (int canceled) { +resume_time (); +local_irq_enable (); }
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 10/16] Save/Restore Support: Add suspend/resume support for timers
arch/x86/time.c void fini_time(void) · line 259
Quoted 7 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:42:05 -0800, wrote:
Signed-off-by Bruno Alvisio <[email protected]>arch/x86/time.c +5
-0+void resume_time (void ) +{ + port =bind_virq (VIRQ_TIMER , &timer_handler,NULL ); +unmask_evtchn (port); +}
I'd say rather factorize it with init_time.
(you could even just remove the printf there to avoid having to write yet another function)
Quoted 40 lines
include/time.h +2
-0@@ -55,6 +55,8 @@ typedef long suseconds_t;/* prototypes */ void init_time (void );void fini_time (void ); +void suspend_time (void ); +void resume_time (void );s_time_t get_s_time (void );s_time_t get_v_time (void );uint64_t monotonic_clock (void );kernel.c +4
-0@@ -120,10 +120,14 @@ void start_kernel(void* par)void pre_suspend (void ) {local_irq_disable (); + +suspend_time (); }void post_suspend (int canceled) { +resume_time (); +local_irq_enable (); }Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 9 lines
Samuel <y> ça gaze ? <l> prout -+- #ens-mim - ouvrez les fenêtres ! -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 11/16 Save/Restore Support: Add suspend/restore support for console
In reply to Bruno Alvisio--- console/console.c | 15 ++++++++++++++- console/xenbus.c | 3 +-- console/xencons_ring.c | 41 +++++++++++++++++++++++++++++++---------- include/console.h | 6 +++++- kernel.c | 4 ++++ lib/sys.c | 2 +- 6 files changed, 56 insertions(+), 15 deletions(-)
console/console.c +14 -1
@@ -52,6 +52,7 @@/* If console not initialised the printk will be sent to xen serial line NOTE: you need to enable verbose in xen/Rules.mk for it to work. */ +static struct consfront_dev * xen_console =NULL ;static int console_initialised =0 ; __attribute__((weak))void console_input (char * buf,unsigned len)
@@ -162,8 +163,20 @@ void xprintk(const char *fmt, ...)void init_console (void ) {printk ("Initialising console ... " ); -xencons_ring_init (); + xen_console =xencons_ring_init (); console_initialised =1 ;/* This is also required to notify the daemon */ printk ("done.\n" ); } + +void suspend_console (void ) +{ + console_initialised =0 ; +xencons_ring_fini (xen_console); +} + +void resume_console (void ) +{ +xencons_ring_resume (xen_console); + console_initialised =1 ; +}
console/xenbus.c +1 -2
@@ -188,8 +188,7 @@ error:return NULL ; } -void fini_console (struct consfront_dev *dev) +void fini_consfront (struct consfront_dev *dev) {if (dev)free_consfront (dev); } -
console/xencons_ring.c +31 -10
87 lines not on this page · raw message
include/console.h +5 -1
@@ -78,11 +78,15 @@ void xencons_tx(void);void get_console (void *p);void init_console (void );void console_print (struct consfront_dev *dev,char *data,int length); -void fini_console (struct consfront_dev *dev); +void fini_consfront (struct consfront_dev *dev); +void suspend_console (void ); +void resume_console (void );/* Low level functions defined in xencons_ring.c */ extern struct wait_queue_head console_queue;struct consfront_dev *xencons_ring_init (void ); +void xencons_ring_fini (struct consfront_dev * dev); +void xencons_ring_resume (struct consfront_dev * dev);struct consfront_dev *init_consfront (char *_nodename);int xencons_ring_send (struct consfront_dev *dev,const char *data,unsigned len);int xencons_ring_send_no_notify (struct consfront_dev *dev,const char *data,unsigned len);
kernel.c +4 -0
@@ -122,10 +122,14 @@ void pre_suspend(void)local_irq_disable ();suspend_time (); + +suspend_console (); }void post_suspend (int canceled) { +resume_console (); +resume_time ();local_irq_enable ();
lib/sys.c +1 -1
@@ -487,7 +487,7 @@ int close(int fd)#ifdef CONFIG_CONSFRONT case FTYPE_SAVEFILE :case FTYPE_CONSOLE : -fini_console (files[fd].cons.dev); +fini_consfront (files[fd].cons.dev); files[fd].type =FTYPE_NONE ;return 0 ;#endif
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 12/16 Save/Restore Support: Add support for suspend/restore events.
In reply to Bruno Alvisio--- events.c | 5 +++++ include/events.h | 1 + kernel.c | 2 ++ 3 files changed, 8 insertions(+)
events.c +5 -0
@@ -183,6 +183,11 @@ void fini_events(void)arch_fini_events (); } +void suspend_events (void ) +{ +unbind_all_ports (); +} +void default_handler (evtchn_port_t port,struct pt_regs *regs,void *ignore) {printk ("[Port %d] - event received\n" , port);
include/events.h +1 -0
@@ -55,5 +55,6 @@ static inline int notify_remote_via_evtchn(evtchn_port_t port) }void fini_events (void ); +void suspend_events (void );#endif /* _EVENTS_H_ */
kernel.c +2 -0
@@ -124,6 +124,8 @@ void pre_suspend(void)suspend_time ();suspend_console (); + +suspend_events (); }void post_suspend (int canceled)
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 12/16] Save/Restore Support: Add support for suspend/restore events.
Quoted 1 line · Bruno Alvisio, on mar. 19 déc. 2017 15:42:07 -0800, wrote:
Signed-off-by Bruno Alvisio <[email protected]>
Quoted 54 lines
--- events.c | 5 +++++ include/events.h | 1 + kernel.c | 2 ++ 3 files changed, 8 insertions(+)events.c +5
-0@@ -183,6 +183,11 @@ void fini_events(void)arch_fini_events (); } +void suspend_events (void ) +{ +unbind_all_ports (); +} +void default_handler (evtchn_port_t port,struct pt_regs *regs,void *ignore) {printk ("[Port %d] - event received\n" , port);include/events.h +1
-0@@ -55,5 +55,6 @@ static inline int notify_remote_via_evtchn(evtchn_port_t port) }void fini_events (void ); +void suspend_events (void );#endif /* _EVENTS_H_ */ kernel.c +2
-0@@ -124,6 +124,8 @@ void pre_suspend(void)suspend_time ();suspend_console (); + +suspend_events (); }void post_suspend (int canceled)Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 8 lines
Samuel X-Favorit-Cartoon: Calvin and Hobbes -+- Mail header of Wim van Dorst -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 13/16 Save/Restore Support: Add suspend/restore support for Grant Tables.
In reply to Bruno Alvisio--- gnttab.c | 33 +++++++++++++++++++++++++++++++++ include/gnttab.h | 2 ++ kernel.c | 4 ++++ 3 files changed, 39 insertions(+)
gnttab.c +33 -0
@@ -194,3 +194,36 @@ fini_gnttab(void)HYPERVISOR_grant_table_op (GNTTABOP_setup_table, &setup,1 ); } + +void suspend_gnttab (void ) +{ +#ifdef CONFIG_PARAVIRT +int i; + +for (i =0 ; i <NR_GRANT_FRAMES ; i++) { +HYPERVISOR_update_va_mapping ((unsigned long )(((char *)gnttab_table) +PAGE_SIZE *i), + (pte_t ){0x0 <<PAGE_SHIFT },UVMF_INVLPG ); + } +#endif +return ; +} + +void resume_gnttab (void ) +{ +struct gnttab_setup_table setup; +unsigned long frames[NR_GRANT_FRAMES ]; + + setup.dom =DOMID_SELF ; + setup.nr_frames =NR_GRANT_FRAMES ; +set_xen_guest_handle (setup.frame_list, frames); + +HYPERVISOR_grant_table_op (GNTTABOP_setup_table, &setup,1 ); + +#ifdef CONFIG_PARAVIRT +int i; +for (i =0 ; i <NR_GRANT_FRAMES ; i++) { +HYPERVISOR_update_va_mapping ((unsigned long )(((char *)gnttab_table) +PAGE_SIZE *i), + (pte_t ){(frames[i] <<PAGE_SHIFT ) |L1_PROT },UVMF_INVLPG ); + } +#endif +}
include/gnttab.h +2 -0
@@ -12,6 +12,8 @@ unsigned long gnttab_end_transfer(grant_ref_t gref);int gnttab_end_access (grant_ref_t ref);const char *gnttabop_error (int16_t status);void fini_gnttab (void ); +void suspend_gnttab (void ); +void resume_gnttab (void );grant_entry_v1_t *arch_init_gnttab (int nr_grant_frames);#endif /* !__GNTTAB_H__ */
kernel.c +4 -0
@@ -121,6 +121,8 @@ void pre_suspend(void) {local_irq_disable (); +suspend_gnttab (); +suspend_time ();suspend_console ();
@@ -134,6 +136,8 @@ void post_suspend(int canceled)resume_time (); +resume_gnttab (); +local_irq_enable (); }
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables.
Quoted 5 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:42:08 -0800, wrote:
gnttab.c +5
-0+void suspend_gnttab (void ) +{ +#ifdef CONFIG_PARAVIRT +int i; +
gnttab.c fini_gnttab(void)
Quoted 10 lines
gnttab.c +10
-0+for (i =0 ; i <NR_GRANT_FRAMES ; i++) { +HYPERVISOR_update_va_mapping ((unsigned long )(((char *)gnttab_table) +PAGE_SIZE *i), + (pte_t ){0x0 <<PAGE_SHIFT },UVMF_INVLPG ); + } +#endif +return ; +} + +void resume_gnttab (void ) +{...
The initialization in arch_init_gnttab is different for arm, so I'd say this should be arch-specific.
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 14/16 Save/Restore Support: Add suspend/restore support for xenbus
In reply to Bruno AlvisioCurrently the watch path is not saved in the watch struct when it is registered. During xenbus resume the path is needed so that the watches can be registered again. Thus, 'path' field is added to struct watch so that watches can be re-registered during xenbus resume.
--- include/xenbus.h | 2 ++ kernel.c | 8 +++++ xenbus/xenbus.c | 106 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 85 insertions(+), 31 deletions(-)
include/xenbus.h +2 -0
@@ -120,6 +120,8 @@ domid_t xenbus_get_self_id(void);#ifdef CONFIG_XENBUS /* Reset the XenBus system. */ void fini_xenbus (void ); +void suspend_xenbus (void ); +void resume_xenbus (int canceled);#else static inline void fini_xenbus (void ) {
kernel.c +8 -0
@@ -119,6 +119,10 @@ void start_kernel(void* par)void pre_suspend (void ) { +#ifdef CONFIG_XENBUS +suspend_xenbus (); +#endif +local_irq_disable ();suspend_gnttab ();
@@ -139,6 +143,10 @@ void post_suspend(int canceled)resume_gnttab ();local_irq_enable (); + +#ifdef CONFIG_XENBUS +resume_xenbus (canceled); +#endif }void stop_kernel (void )
xenbus/xenbus.c +75 -31
172 lines not on this page · raw message
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Minios-devel] [PATCH RFC 14/16] Save/Restore Support: Add suspend/restore support for xenbus
Quoted 6 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:42:09 -0800, wrote:
Currently the watch path is not saved in the watch struct when it is registered. During xenbus resume the path is needed so that the watches can be registered again. Thus, 'path' field is added to struct watch so that watches can be re-registered during xenbus resume.
Signed-off-by Bruno Alvisio <[email protected]>
Again, there are spurious hunks in this patch due to oddities in indentation, please remove them. Apart from that,
Quoted 237 lines
--- include/xenbus.h | 2 ++ kernel.c | 8 +++++ xenbus/xenbus.c | 106 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 85 insertions(+), 31 deletions(-)include/xenbus.h +2
-0@@ -120,6 +120,8 @@ domid_t xenbus_get_self_id(void);#ifdef CONFIG_XENBUS /* Reset the XenBus system. */ void fini_xenbus (void ); +void suspend_xenbus (void ); +void resume_xenbus (int canceled);#else static inline void fini_xenbus (void ) {kernel.c +8
-0@@ -119,6 +119,10 @@ void start_kernel(void* par)void pre_suspend (void ) { +#ifdef CONFIG_XENBUS +suspend_xenbus (); +#endif +local_irq_disable ();suspend_gnttab ();@@ -139,6 +143,10 @@ void post_suspend(int canceled)resume_gnttab ();local_irq_enable (); + +#ifdef CONFIG_XENBUS +resume_xenbus (canceled); +#endif }void stop_kernel (void )xenbus/xenbus.c +75
-31@@ -50,6 +50,7 @@ DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);xenbus_event_queue xenbus_events;static struct watch {char *token; +char *path;xenbus_event_queue *events;struct watch *next; } *watches;@@ -63,6 +64,8 @@ struct xenbus_req_info#define NR_REQS 32static struct xenbus_req_info req_info[NR_REQS ]; +static char *errmsg (struct xsd_sockmsg *rep); +uint32_t xenbus_evtchn;#ifdef CONFIG_PARAVIRT @@ -231,45 +234,39 @@ static void xenbus_thread_func(void *ign)struct xsd_sockmsg msg;unsigned prod = xenstore_buf->rsp_prod; -for (;;) - { +for (;;) {wait_event (xb_waitq, prod != xenstore_buf->rsp_prod); -while (1 ) - { +while (1 ) { prod = xenstore_buf->rsp_prod;DEBUG ("Rsp_cons %d, rsp_prod %d.\n" , xenstore_buf->rsp_cons, - xenstore_buf->rsp_prod); + xenstore_buf->rsp_prod);if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons <sizeof (msg))break ;rmb (); -memcpy_from_ring (xenstore_buf->rsp, - &msg, -MASK_XENSTORE_IDX (xenstore_buf->rsp_cons), -sizeof (msg)); -DEBUG ("Msg len %d, %d avail, id %d.\n" , - msg.len +sizeof (msg), - xenstore_buf->rsp_prod - xenstore_buf->rsp_cons, - msg.req_id); +memcpy_from_ring (xenstore_buf->rsp, &msg, +MASK_XENSTORE_IDX (xenstore_buf->rsp_cons), +sizeof (msg)); +DEBUG ("Msg len %d, %d avail, id %d.\n" , msg.len +sizeof (msg), + xenstore_buf->rsp_prod - xenstore_buf->rsp_cons, msg.req_id); +if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < -sizeof (msg) + msg.len) +sizeof (msg) + msg.len)break ;DEBUG ("Message is good.\n" ); -if (msg.type ==XS_WATCH_EVENT ) - { -struct xenbus_event *event =malloc (sizeof (*event) + msg.len); +if (msg.type ==XS_WATCH_EVENT ) { +struct xenbus_event *event =malloc (sizeof (*event) + msg.len);xenbus_event_queue *events =NULL ; -char *data = (char *)event +sizeof (*event); +char *data = (char *)event +sizeof (*event);struct watch *watch; -memcpy_from_ring (xenstore_buf->rsp, - data, +memcpy_from_ring (xenstore_buf->rsp, data,MASK_XENSTORE_IDX (xenstore_buf->rsp_cons +sizeof (msg)), msg.len); - event->path = data; - event->token = event->path +strlen (event->path) +1 ; + event->path = data; + event->token = event->path +strlen (event->path) +1 ;mb (); xenstore_buf->rsp_cons += msg.len +sizeof (msg);@@ -288,15 +285,11 @@ static void xenbus_thread_func(void *ign)printk ("unexpected watch token %s\n" , event->token);free (event); } - } - -else - { + }else { req_info[msg.req_id].reply =malloc (sizeof (msg) + msg.len); -memcpy_from_ring (xenstore_buf->rsp, - req_info[msg.req_id].reply, -MASK_XENSTORE_IDX (xenstore_buf->rsp_cons), - msg.len +sizeof (msg)); +memcpy_from_ring (xenstore_buf->rsp, req_info[msg.req_id].reply, +MASK_XENSTORE_IDX (xenstore_buf->rsp_cons), + msg.len +sizeof (msg));mb (); xenstore_buf->rsp_cons += msg.len +sizeof (msg);wake_up (&req_info[msg.req_id].waitq);@@ -380,6 +373,55 @@ void fini_xenbus(void) { } +void suspend_xenbus (void ) +{ +/* Check for live requests and wait until they finish */ +while (1 ) + { +spin_lock (&req_lock); +if (nr_live_reqs ==0 ) +break ; +spin_unlock (&req_lock); +wait_event (req_wq, (nr_live_reqs ==0 )); + } + +mask_evtchn (xenbus_evtchn); + xenstore_buf =NULL ; +spin_unlock (&req_lock); +} + +void resume_xenbus (int canceled) +{ +char *msg; +struct watch *watch; +struct write_req req[2 ]; +struct xsd_sockmsg *rep; + +#ifdef CONFIG_PARAVIRT +get_xenbus (&start_info); +#else +get_xenbus (0 ); +#endif +unmask_evtchn (xenbus_evtchn); + +if (!canceled) { +for (watch = watches; watch; watch = watch->next) { + req[0 ].data = watch->path; + req[0 ].len =strlen (watch->path) +1 ; + req[1 ].data = watch->token; + req[1 ].len =strlen (watch->token) +1 ; + + rep =xenbus_msg_reply (XS_WATCH ,XBT_NIL , req,ARRAY_SIZE (req)); + msg =errmsg (rep); +if (msg) +xprintk ("error on XS_WATCH: %s\n" , msg); +free (rep); + } + } + +notify_remote_via_evtchn (xenbus_evtchn); +} +/* Send data to xenbus. This can block. All of the requests are seen by xenbus as if sent atomically. The header is added automatically, using type %type, req_id %req_id, and trans_id @@ -501,7 +543,7 @@ static char *errmsg(struct xsd_sockmsg *rep) res[rep->len] =0 ;free (rep);return res; -} +}/* Send a debug message to xenbus. Can block. */ static void xenbus_debug_msg (const char *msg)@@ -601,6 +643,7 @@ char* xenbus_watch_path_token( xenbus_transaction_t xbt, const char *path, const events = &xenbus_events; watch->token =strdup (token); + watch->path =strdup (path); watch->events = events; watch->next = watches; watches = watch;@@ -636,6 +679,7 @@ char* xenbus_unwatch_path_token( xenbus_transaction_t xbt, const char *path, confor (prev = &watches, watch = *prev; watch; prev = &watch->next, watch = *prev)if (!strcmp (watch->token, token)) {free (watch->token); +free (watch->path); *prev = watch->next;free (watch);break ;Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/minios-devel
Signature · 11 lines
Samuel
quit When the quit statement is read, the bc processor
is terminated, regardless of where the quit state-
ment is found. For example, "if (0 == 1) quit"
will cause bc to terminate.
(Seen in the manpage for "bc". Note the "if" statement's logic)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-develRFC PATCH 15/16 Save/Restore Support: Add suspend/restore support for netfront
In reply to Bruno AlvisioPerformed an additional cleanup to make the file more syntactically consistent.
--- include/netfront.h | 8 +- kernel.c | 8 ++ netfront.c | 242 +++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 204 insertions(+), 54 deletions(-)
include/netfront.h +7 -1
@@ -3,9 +3,15 @@#include <lwip/netif.h> #endif struct netfront_dev ; -struct netfront_dev *init_netfront (char *nodename,void (*netif_rx)(unsigned char *data,int len),unsigned char rawmac[6 ],char **ip); +struct netfront_dev *init_netfront (char *nodename, +void (*netif_rx)(unsigned char *data, +int len,void * arg), +unsigned char rawmac[6 ], +char **ip);void netfront_xmit (struct netfront_dev *dev,unsigned char * data,int len);void shutdown_netfront (struct netfront_dev *dev); +void suspend_netfront (void ); +void resume_netfront (void );#ifdef HAVE_LIBC int netfront_tap_open (char *nodename);ssize_t netfront_receive (struct netfront_dev *dev,unsigned char *data,size_t len);
kernel.c +8 -0
@@ -119,6 +119,10 @@ void start_kernel(void* par)void pre_suspend (void ) { +#ifdef CONFIG_NETFRONT +suspend_netfront (); +#endif +#ifdef CONFIG_XENBUS suspend_xenbus ();#endif
@@ -147,6 +151,10 @@ void post_suspend(int canceled)#ifdef CONFIG_XENBUS resume_xenbus (canceled);#endif + +#ifdef CONFIG_NETFRONT +resume_netfront (); +#endif }void stop_kernel (void )
netfront.c +189 -53
378 lines not on this page · raw message
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 16/16 Save/Restore Support: Implement code for arch suspend/resume
In reply to Bruno AlvisioBefore 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.
--- arch/x86/setup.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
arch/x86/setup.c +51 -0
@@ -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 pfns with the correspondent mfns */ + 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
Signature · 7 lines
2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
I can't find patch 06 in my mbox, but
Quoted 5 lines · Bruno Alvisio, on mar. 19 déc. 2017 15:41:55 -0800, wrote:
I have been working on supporting save/restore for mini-os PVH. Some parts of the implementation were taken from the sysml/mini-os repository. The branch can be found at:
https://github.com/balvisio/mini-os/tree/feature/mini-os-suspend-support
I got commit 3869ff5bf4e88d708fb62c16fbe8eb9c0eee9d45 from there, and you can consider it
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Again, I didn't find patch 11, so I got it from here
Quoted 1 line · Bruno Alvisio, on mar. 19 déc. 2017 15:41:55 -0800, wrote:
https://github.com/balvisio/mini-os/tree/feature/mini-os-suspend-support
There are indentation oddities bringing spurious hunks. Apart from that,
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
About patch 15, it seems your terminal is set to see tabs as 4 spaces. Where tabs are used, the mini-os source code assumes 8 spaces. Avoid using tabs, just use spaces :)
And, avoid
for (list = dev_list; list->next != NULL; list = list->next);
better write
for (list = dev_list; list->next != NULL; list = list->next)
;
to make it explicit that the loop is empty.
Also,
*ip = malloc(strlen(ldev->ip) + 1); strncpy(*ip, ldev->ip, strlen(ldev->ip) + 1);
can be a mere *ip = strdup(ldev->ip), can't it?
Apart from that,
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
About patch 16,
"Replace xenstore and console pfns with the correspondent mfns" seems exactly contrary to what the code does.
Apart from that,
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel