1*9162620eSNam Cao /* SPDX-License-Identifier: GPL-2.0 */ 2*9162620eSNam Cao 3*9162620eSNam Cao /* 4*9162620eSNam Cao * C implementation of Buchi automaton, automatically generated by 5*9162620eSNam Cao * tools/verification/rvgen from the linear temporal logic specification. 6*9162620eSNam Cao * For further information, see kernel documentation: 7*9162620eSNam Cao * Documentation/trace/rv/linear_temporal_logic.rst 8*9162620eSNam Cao */ 9*9162620eSNam Cao 10*9162620eSNam Cao #include <linux/rv.h> 11*9162620eSNam Cao 12*9162620eSNam Cao #define MONITOR_NAME pagefault 13*9162620eSNam Cao 14*9162620eSNam Cao enum ltl_atom { 15*9162620eSNam Cao LTL_PAGEFAULT, 16*9162620eSNam Cao LTL_RT, 17*9162620eSNam Cao LTL_NUM_ATOM 18*9162620eSNam Cao }; 19*9162620eSNam Cao static_assert(LTL_NUM_ATOM <= RV_MAX_LTL_ATOM); 20*9162620eSNam Cao 21*9162620eSNam Cao static const char *ltl_atom_str(enum ltl_atom atom) 22*9162620eSNam Cao { 23*9162620eSNam Cao static const char *const names[] = { 24*9162620eSNam Cao "pa", 25*9162620eSNam Cao "rt", 26*9162620eSNam Cao }; 27*9162620eSNam Cao 28*9162620eSNam Cao return names[atom]; 29*9162620eSNam Cao } 30*9162620eSNam Cao 31*9162620eSNam Cao enum ltl_buchi_state { 32*9162620eSNam Cao S0, 33*9162620eSNam Cao RV_NUM_BA_STATES 34*9162620eSNam Cao }; 35*9162620eSNam Cao static_assert(RV_NUM_BA_STATES <= RV_MAX_BA_STATES); 36*9162620eSNam Cao 37*9162620eSNam Cao static void ltl_start(struct task_struct *task, struct ltl_monitor *mon) 38*9162620eSNam Cao { 39*9162620eSNam Cao bool pagefault = test_bit(LTL_PAGEFAULT, mon->atoms); 40*9162620eSNam Cao bool val3 = !pagefault; 41*9162620eSNam Cao bool rt = test_bit(LTL_RT, mon->atoms); 42*9162620eSNam Cao bool val1 = !rt; 43*9162620eSNam Cao bool val4 = val1 || val3; 44*9162620eSNam Cao 45*9162620eSNam Cao if (val4) 46*9162620eSNam Cao __set_bit(S0, mon->states); 47*9162620eSNam Cao } 48*9162620eSNam Cao 49*9162620eSNam Cao static void 50*9162620eSNam Cao ltl_possible_next_states(struct ltl_monitor *mon, unsigned int state, unsigned long *next) 51*9162620eSNam Cao { 52*9162620eSNam Cao bool pagefault = test_bit(LTL_PAGEFAULT, mon->atoms); 53*9162620eSNam Cao bool val3 = !pagefault; 54*9162620eSNam Cao bool rt = test_bit(LTL_RT, mon->atoms); 55*9162620eSNam Cao bool val1 = !rt; 56*9162620eSNam Cao bool val4 = val1 || val3; 57*9162620eSNam Cao 58*9162620eSNam Cao switch (state) { 59*9162620eSNam Cao case S0: 60*9162620eSNam Cao if (val4) 61*9162620eSNam Cao __set_bit(S0, next); 62*9162620eSNam Cao break; 63*9162620eSNam Cao } 64*9162620eSNam Cao } 65