diff --git a/etc/system.conf b/etc/system.conf index d47fd9a59..bc1962dd9 100644 --- a/etc/system.conf +++ b/etc/system.conf @@ -717,3 +717,8 @@ service pty SYSTEM vfs rs vm ; }; + +service edfictl +{ + ipc ALL; +}; diff --git a/include/minix/com.h b/include/minix/com.h index 324f82117..82fc9daf1 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -646,6 +646,9 @@ # define GCOV_BUFF_P m1_p1 # define GCOV_BUFF_SZ m1_i1 +/* Common fault injection ctl request to all processes. */ +#define COMMON_REQ_FI_CTL (COMMON_RQ_BASE+2) + /*===========================================================================* * Messages for VM server * *===========================================================================*/ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 59f19c4bb..7962f7476 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -691,6 +691,21 @@ typedef struct { } mess_linputdriver_input_event; _ASSERT_MSG_SIZE(mess_linputdriver_input_event); +typedef struct { + cp_grant_id_t gid; + size_t size; + + uint8_t padding[48]; +} mess_lsys_fi_ctl; +_ASSERT_MSG_SIZE(mess_lsys_fi_ctl); + +typedef struct { + int status; + + uint8_t padding[52]; +} mess_lsys_fi_reply; +_ASSERT_MSG_SIZE(mess_lsys_fi_reply); + typedef struct { int what; vir_bytes where; @@ -1795,6 +1810,8 @@ typedef struct { mess_linputdriver_input_event m_linputdriver_input_event; mess_lsys_getsysinfo m_lsys_getsysinfo; + mess_lsys_fi_ctl m_lsys_fi_ctl; + mess_lsys_fi_reply m_lsys_fi_reply; mess_lsys_krn_schedctl m_lsys_krn_schedctl; mess_lsys_krn_schedule m_lsys_krn_schedule; diff --git a/include/minix/sef.h b/include/minix/sef.h index 1a6809101..25434410d 100644 --- a/include/minix/sef.h +++ b/include/minix/sef.h @@ -233,6 +233,17 @@ void sef_cb_signal_handler_posix_default(int signo); #define sef_signal_debug_begin sef_debug_begin #define sef_signal_debug_end sef_debug_end +/*===========================================================================* + * SEF Fault Injection * + *===========================================================================*/ +/* What to intercept. */ +#define INTERCEPT_SEF_FI_REQUESTS 1 +#define IS_SEF_FI_REQUEST(mp, status) \ + (m_ptr->m_type == COMMON_REQ_FI_CTL) + +/* Fault injection tool support. */ +#define SEF_FI_ALLOW_EDFI 1 + #if !defined(USE_LIVEUPDATE) #undef INTERCEPT_SEF_LU_REQUESTS #undef SEF_LU_DEBUG diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 4d09fa4b9..c95a0b90a 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -40,6 +40,7 @@ SRCS+= \ sched_start.c \ sched_stop.c \ sef.c \ + sef_fi.c \ sef_init.c \ sef_liveupdate.c \ sef_ping.c \ diff --git a/lib/libsys/sef.c b/lib/libsys/sef.c index 46817934c..389118719 100644 --- a/lib/libsys/sef.c +++ b/lib/libsys/sef.c @@ -27,9 +27,6 @@ char* sef_debug_header(void); #endif /* SEF Init prototypes. */ -#ifdef USE_COVERAGE -EXTERN int do_sef_gcov_request(message *m_ptr); -#endif EXTERN int do_sef_rs_init(endpoint_t old_endpoint); EXTERN int do_sef_init_request(message *m_ptr); @@ -43,6 +40,14 @@ EXTERN int do_sef_lu_request(message *m_ptr); /* SEF Signal prototypes. */ EXTERN int do_sef_signal_request(message *m_ptr); +/* SEF GCOV prototypes. */ +#ifdef USE_COVERAGE +EXTERN int do_sef_gcov_request(message *m_ptr); +#endif + +/* SEF Fault Injection prototypes. */ +EXTERN int do_sef_fi_request(message *m_ptr); + /*===========================================================================* * sef_startup * *===========================================================================*/ @@ -181,6 +186,15 @@ int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr) } #endif +#ifdef INTERCEPT_SEF_FI_REQUESTS + /* Intercept Fault injection requests. */ + if(IS_SEF_FI_REQUEST(m_ptr, status)) { + if(do_sef_fi_request(m_ptr) == OK) { + continue; + } + } +#endif + /* If we get this far, this is not a valid SEF request, return and * let the caller deal with that. */ diff --git a/lib/libsys/sef_fi.c b/lib/libsys/sef_fi.c new file mode 100644 index 000000000..36ae8d6f1 --- /dev/null +++ b/lib/libsys/sef_fi.c @@ -0,0 +1,21 @@ + +#include "syslib.h" +#include +#include + +EXTERN __attribute__((weak)) int edfi_ctl_process_request(void *ctl_request); + +/*===========================================================================* + * do_sef_fi_request * + *===========================================================================*/ +int do_sef_fi_request(message *m_ptr) +{ +#if SEF_FI_ALLOW_EDFI + /* Forward the request to the EDFI fault injector, if linked in. */ + if(edfi_ctl_process_request) + return edfi_ctl_process_request(m_ptr); +#endif + + return ENOSYS; +} +