diff --git a/minix/include/minix/sef.h b/minix/include/minix/sef.h index 5f9920eb4..061502e1e 100644 --- a/minix/include/minix/sef.h +++ b/minix/include/minix/sef.h @@ -69,6 +69,7 @@ int sef_cb_init_fail(int type, sef_init_info_t *info); int sef_cb_init_reset(int type, sef_init_info_t *info); int sef_cb_init_crash(int type, sef_init_info_t *info); int sef_cb_init_timeout(int type, sef_init_info_t *info); +int sef_cb_init_restart_generic(int type, sef_init_info_t *info); int sef_cb_init_identity_state_transfer(int type, sef_init_info_t *info); int sef_cb_init_lu_identity_as_restart(int type, sef_init_info_t *info); int sef_cb_init_lu_generic(int type, sef_init_info_t *info); @@ -80,7 +81,7 @@ int sef_cb_init_response_rs_asyn_once(message *m_ptr); #define SEF_CB_INIT_LU_NULL sef_cb_init_null #define SEF_CB_INIT_RESTART_NULL sef_cb_init_null #define SEF_CB_INIT_RESPONSE_NULL sef_cb_init_response_null -#define SEF_CB_INIT_RESTART_STATEFUL sef_cb_init_identity_state_transfer +#define SEF_CB_INIT_RESTART_STATEFUL sef_cb_init_restart_generic #define SEF_CB_INIT_FRESH_DEFAULT sef_cb_init_null #define SEF_CB_INIT_LU_DEFAULT sef_cb_init_lu_generic @@ -375,6 +376,7 @@ int sef_llvm_ac_munmap(void *buf, size_t len); int sef_llvm_ltckpt_enabled(void); int sef_llvm_get_ltckpt_offset(void); +int sef_llvm_ltckpt_restart(int type, sef_init_info_t *info); #if !defined(USE_LIVEUPDATE) #undef INTERCEPT_SEF_LU_REQUESTS diff --git a/minix/lib/libsys/sef_init.c b/minix/lib/libsys/sef_init.c index 41ec8e68b..425727e6c 100644 --- a/minix/lib/libsys/sef_init.c +++ b/minix/lib/libsys/sef_init.c @@ -306,6 +306,25 @@ int sef_cb_init_timeout(int UNUSED(type), sef_init_info_t *UNUSED(info)) return EBADCALL; } +/*===========================================================================* + * sef_cb_init_restart_generic * + *===========================================================================*/ +int sef_cb_init_restart_generic(int type, sef_init_info_t *info) +{ + /* Always resort to simple identity transfer for self updates. */ + if (type == SEF_INIT_LU && (info->flags & SEF_LU_SELF)) + return sef_cb_init_identity_state_transfer(type, info); + + /* Can only handle restart otherwise. */ + if(type != SEF_INIT_RESTART) { + printf("sef_cb_init_restart_generic: init failed\n"); + return ENOSYS; + } + + /* Perform instrumentation-supported checkpoint-restart. */ + return sef_llvm_ltckpt_restart(type, info); +} + /*===========================================================================* * sef_cb_init_identity_state_transfer * *===========================================================================*/ diff --git a/minix/lib/libsys/sef_llvm.c b/minix/lib/libsys/sef_llvm.c index 90eb3d5f1..f0ddd7dd7 100644 --- a/minix/lib/libsys/sef_llvm.c +++ b/minix/lib/libsys/sef_llvm.c @@ -209,8 +209,8 @@ int sef_llvm_ac_munmap(void *buf, size_t len) *===========================================================================*/ int sef_llvm_ltckpt_enabled() { - extern int __attribute__((weak)) ltckpt_get_offset(); - if (!ltckpt_get_offset) + extern int __attribute__((weak)) ltckpt_mechanism_enabled(void); + if (!sef_llvm_get_ltckpt_offset() || !ltckpt_mechanism_enabled()) return 0; return 1; } @@ -226,3 +226,17 @@ int sef_llvm_get_ltckpt_offset() return ltckpt_get_offset(); } +/*===========================================================================* + * sef_llvm_ltckpt_restart * + *===========================================================================*/ +int sef_llvm_ltckpt_restart(int type, sef_init_info_t *info) +{ + extern int __attribute__((weak)) ltckpt_restart(void *); + + if(!sef_llvm_ltckpt_enabled()) + return sef_cb_init_identity_state_transfer(type, info); + + assert(ltckpt_restart); + return ltckpt_restart(info); +} +