From: Cristiano Giuffrida Date: Sun, 2 Mar 2014 00:15:08 +0000 (+0100) Subject: kernel: Extend the {sys,vm}_update() interfaces. X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=a1760b573b3c6eeb6dc9e54e446ae9e9a438033d;p=minix.git kernel: Extend the {sys,vm}_update() interfaces. Change-Id: I9ada3c04c08d219b198e9081f4e1942b11c722f6 --- diff --git a/minix/include/minix/com.h b/minix/include/minix/com.h index 2b2d33bf9..2082eb59d 100644 --- a/minix/include/minix/com.h +++ b/minix/include/minix/com.h @@ -429,6 +429,9 @@ /* Field names for SYS_UPDATE. */ #define SYS_UPD_SRC_ENDPT m1_i1 /* source endpoint */ #define SYS_UPD_DST_ENDPT m1_i2 /* destination endpoint */ +#define SYS_UPD_FLAGS m1_i3 /* update flags */ +# define SYS_UPD_ROLLBACK 0x1 /* update is rollback */ + /* Subfunctions for SYS_STATECTL */ #define SYS_STATE_CLEAR_IPC_REFS 1 /* clear IPC references */ diff --git a/minix/include/minix/ipc.h b/minix/include/minix/ipc.h index 2515a5f55..97a42221d 100644 --- a/minix/include/minix/ipc.h +++ b/minix/include/minix/ipc.h @@ -1377,7 +1377,8 @@ _ASSERT_MSG_SIZE(mess_lsys_vm_unmap_phys); typedef struct { endpoint_t src; endpoint_t dst; - uint8_t padding[48]; + int flags; + uint8_t padding[44]; } mess_lsys_vm_update; _ASSERT_MSG_SIZE(mess_lsys_vm_update); diff --git a/minix/include/minix/syslib.h b/minix/include/minix/syslib.h index 9b783fe0b..37b3f0f5a 100644 --- a/minix/include/minix/syslib.h +++ b/minix/include/minix/syslib.h @@ -48,7 +48,7 @@ int sys_schedctl(unsigned flags, endpoint_t proc_ep, int priority, int #define sys_resume(proc_ep) sys_runctl(proc_ep, RC_RESUME, 0) int sys_runctl(endpoint_t proc_ep, int action, int flags); -int sys_update(endpoint_t src_ep, endpoint_t dst_ep); +int sys_update(endpoint_t src_ep, endpoint_t dst_ep, int flags); int sys_statectl(int request, void* address, int length); int sys_privctl(endpoint_t proc_ep, int req, void *p); int sys_privquery_mem(endpoint_t proc_ep, phys_bytes physstart, diff --git a/minix/include/minix/vm.h b/minix/include/minix/vm.h index b8a1c399e..9761502a5 100644 --- a/minix/include/minix/vm.h +++ b/minix/include/minix/vm.h @@ -17,7 +17,7 @@ int vm_unmap_phys(endpoint_t who, void *vaddr, size_t len); int vm_notify_sig(endpoint_t ep, endpoint_t ipc_ep); int vm_set_priv(endpoint_t ep, void *buf, int sys_proc); -int vm_update(endpoint_t src_e, endpoint_t dst_e); +int vm_update(endpoint_t src_e, endpoint_t dst_e, int flags); int vm_memctl(endpoint_t ep, int req); int vm_query_exit(endpoint_t *endpt); int vm_watch_exit(endpoint_t ep); diff --git a/minix/kernel/system/do_update.c b/minix/kernel/system/do_update.c index d0f7ceb90..36559156e 100644 --- a/minix/kernel/system/do_update.c +++ b/minix/kernel/system/do_update.c @@ -4,6 +4,7 @@ * The parameters for this kernel call are: * m2_i1: SYS_UPD_SRC_ENDPT (source process endpoint) * m2_i2: SYS_UPD_DST_ENDPT (destination process endpoint) + * m2_i3: SYS_UPD_FLAGS (update flags) */ #include "kernel/system.h" diff --git a/minix/lib/libsys/sef.c b/minix/lib/libsys/sef.c index 2033f1a89..119e8e801 100644 --- a/minix/lib/libsys/sef.c +++ b/minix/lib/libsys/sef.c @@ -59,6 +59,7 @@ void sef_startup() endpoint_t old_endpoint; int priv_flags; int init_flags; + int sys_upd_flags = 0; /* Get information about self. */ r = sys_whoami(&sef_self_endpoint, sef_self_name, SEF_SELF_NAME_MAXLEN, @@ -72,7 +73,7 @@ void sef_startup() #if USE_LIVEUPDATE /* RS may wake up with the wrong endpoint, perfom the update in that case. */ if((sef_self_priv_flags & ROOT_SYS_PROC) && sef_self_endpoint != RS_PROC_NR) { - r = vm_update(RS_PROC_NR, sef_self_endpoint); + r = vm_update(RS_PROC_NR, sef_self_endpoint, sys_upd_flags); if(r != OK) { panic("unable to update RS from instance %d to %d: %d", RS_PROC_NR, sef_self_endpoint, r); diff --git a/minix/lib/libsys/sys_update.c b/minix/lib/libsys/sys_update.c index c93845b62..86274628f 100644 --- a/minix/lib/libsys/sys_update.c +++ b/minix/lib/libsys/sys_update.c @@ -1,11 +1,12 @@ #include "syslib.h" -int sys_update(endpoint_t src_ep, endpoint_t dst_ep) +int sys_update(endpoint_t src_ep, endpoint_t dst_ep, int flags) { message m; m.SYS_UPD_SRC_ENDPT = src_ep; m.SYS_UPD_DST_ENDPT = dst_ep; + m.SYS_UPD_FLAGS = flags; return _kernel_call(SYS_UPDATE, &m); } diff --git a/minix/lib/libsys/vm_update.c b/minix/lib/libsys/vm_update.c index c51cb0120..a8635ac93 100644 --- a/minix/lib/libsys/vm_update.c +++ b/minix/lib/libsys/vm_update.c @@ -4,13 +4,14 @@ #include int -vm_update(endpoint_t src_e, endpoint_t dst_e) +vm_update(endpoint_t src_e, endpoint_t dst_e, int flags) { message m; memset(&m, 0, sizeof(m)); m.m_lsys_vm_update.src = src_e; m.m_lsys_vm_update.dst = dst_e; + m.m_lsys_vm_update.flags = flags; return _taskcall(VM_PROC_NR, VM_RS_UPDATE, &m); } diff --git a/minix/servers/rs/manager.c b/minix/servers/rs/manager.c index 57b8b8a35..9fb6e2702 100644 --- a/minix/servers/rs/manager.c +++ b/minix/servers/rs/manager.c @@ -218,6 +218,7 @@ void build_cmd_dep(struct rproc *rp) int srv_update(endpoint_t src_e, endpoint_t dst_e) { int r; + int sys_upd_flags = 0; /* Ask VM to swap the slots of the two processes and tell the kernel to * do the same. If VM is the service being updated, only perform the kernel @@ -225,10 +226,10 @@ int srv_update(endpoint_t src_e, endpoint_t dst_e) * initialization time. */ if(src_e != VM_PROC_NR) { - r = vm_update(src_e, dst_e); + r = vm_update(src_e, dst_e, sys_upd_flags); } else { - r = sys_update(src_e, dst_e); + r = sys_update(src_e, dst_e, sys_upd_flags); } return r; diff --git a/minix/servers/vm/rs.c b/minix/servers/vm/rs.c index 5d9971538..064f8de87 100644 --- a/minix/servers/vm/rs.c +++ b/minix/servers/vm/rs.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -71,10 +72,11 @@ int do_rs_update(message *m_ptr) endpoint_t src_e, dst_e, reply_e; int src_p, dst_p; struct vmproc *src_vmp, *dst_vmp; - int r; + int r, sys_upd_flags; src_e = m_ptr->m_lsys_vm_update.src; dst_e = m_ptr->m_lsys_vm_update.dst; + sys_upd_flags = m_ptr->m_lsys_vm_update.flags; /* Lookup slots for source and destination process. */ if(vm_isokendpt(src_e, &src_p) != OK) { @@ -89,7 +91,8 @@ int do_rs_update(message *m_ptr) dst_vmp = &vmproc[dst_p]; /* Let the kernel do the update first. */ - r = sys_update(src_e, dst_e); + r = sys_update(src_e, dst_e, + sys_upd_flags & SF_VM_ROLLBACK ? SYS_UPD_ROLLBACK : 0); if(r != OK) { return r; }