Skip to content

Commit 0b1b4a3

Browse files
committed
Merge tag 'trace-rv-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull runtime verifier updates from Steven Rostedt: - Adapt the ftracetest script to be run from a different folder This uses the already existing OPT_TEST_DIR but extends it further to run independent tests, then add an --rv flag to allow using the script for testing RV (mostly) independently on ftrace. - Add basic RV selftests in selftests/verification for more validations Add more validations for available/enabled monitors and reactors. This could have caught the bug introducing kernel panic solved above. Tests use ftracetest. - Convert react() function in reactor to use va_list directly Use a central helper to handle the variadic arguments. Clean up macros and mark functions as static. - Add lockdep annotations to reactors to have lockdep complain of errors If the reactors are called from improper context. Useful to develop new reactors. This highlights a warning in the panic reactor that is related to the printk subsystem and not to RV. - Convert core RV code to use lock guards and __free helpers This completely removes goto statements. - Fix compilation if !CONFIG_RV_REACTORS Fix the warning by keeping LTL monitor variable as always static. * tag 'trace-rv-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: rv: Fix compilation if !CONFIG_RV_REACTORS rv: Convert to use __free rv: Convert to use lock guard rv: Add explicit lockdep context for reactors rv: Make rv_reacting_on() static rv: Pass va_list to reactors selftests/verification: Add initial RV tests selftest/ftrace: Generalise ftracetest to use with RV
2 parents 0771cee + bbaacdc commit 0b1b4a3

23 files changed

Lines changed: 384 additions & 173 deletions

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22700,6 +22700,7 @@ F: Documentation/trace/rv/
2270022700
F: include/linux/rv.h
2270122701
F: include/rv/
2270222702
F: kernel/trace/rv/
22703+
F: tools/testing/selftests/verification/
2270322704
F: tools/verification/
2270422705

2270522706
RUST

include/linux/rv.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ union rv_task_monitor {
8888
struct rv_reactor {
8989
const char *name;
9090
const char *description;
91-
__printf(1, 2) void (*react)(const char *msg, ...);
91+
__printf(1, 0) void (*react)(const char *msg, va_list args);
9292
struct list_head list;
9393
};
9494
#endif
@@ -102,7 +102,7 @@ struct rv_monitor {
102102
void (*reset)(void);
103103
#ifdef CONFIG_RV_REACTORS
104104
struct rv_reactor *reactor;
105-
__printf(1, 2) void (*react)(const char *msg, ...);
105+
__printf(1, 0) void (*react)(const char *msg, va_list args);
106106
#endif
107107
struct list_head list;
108108
struct rv_monitor *parent;
@@ -116,13 +116,14 @@ int rv_get_task_monitor_slot(void);
116116
void rv_put_task_monitor_slot(int slot);
117117

118118
#ifdef CONFIG_RV_REACTORS
119-
bool rv_reacting_on(void);
120119
int rv_unregister_reactor(struct rv_reactor *reactor);
121120
int rv_register_reactor(struct rv_reactor *reactor);
121+
__printf(2, 3)
122+
void rv_react(struct rv_monitor *monitor, const char *msg, ...);
122123
#else
123-
static inline bool rv_reacting_on(void)
124+
__printf(2, 3)
125+
static inline void rv_react(struct rv_monitor *monitor, const char *msg, ...)
124126
{
125-
return false;
126127
}
127128
#endif /* CONFIG_RV_REACTORS */
128129

include/rv/da_monitor.h

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,19 @@
1616
#include <linux/bug.h>
1717
#include <linux/sched.h>
1818

19-
#ifdef CONFIG_RV_REACTORS
20-
21-
#define DECLARE_RV_REACTING_HELPERS(name, type) \
22-
static void cond_react_##name(type curr_state, type event) \
23-
{ \
24-
if (!rv_reacting_on() || !rv_##name.react) \
25-
return; \
26-
rv_##name.react("rv: monitor %s does not allow event %s on state %s\n", \
27-
#name, \
28-
model_get_event_name_##name(event), \
29-
model_get_state_name_##name(curr_state)); \
30-
}
31-
32-
#else /* CONFIG_RV_REACTOR */
33-
34-
#define DECLARE_RV_REACTING_HELPERS(name, type) \
35-
static void cond_react_##name(type curr_state, type event) \
36-
{ \
37-
return; \
38-
}
39-
#endif
40-
4119
/*
4220
* Generic helpers for all types of deterministic automata monitors.
4321
*/
4422
#define DECLARE_DA_MON_GENERIC_HELPERS(name, type) \
4523
\
46-
DECLARE_RV_REACTING_HELPERS(name, type) \
24+
static void react_##name(type curr_state, type event) \
25+
{ \
26+
rv_react(&rv_##name, \
27+
"rv: monitor %s does not allow event %s on state %s\n", \
28+
#name, \
29+
model_get_event_name_##name(event), \
30+
model_get_state_name_##name(curr_state)); \
31+
} \
4732
\
4833
/* \
4934
* da_monitor_reset_##name - reset a monitor and setting it to init state \
@@ -126,7 +111,7 @@ da_event_##name(struct da_monitor *da_mon, enum events_##name event) \
126111
for (int i = 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) { \
127112
next_state = model_get_next_state_##name(curr_state, event); \
128113
if (next_state == INVALID_STATE) { \
129-
cond_react_##name(curr_state, event); \
114+
react_##name(curr_state, event); \
130115
trace_error_##name(model_get_state_name_##name(curr_state), \
131116
model_get_event_name_##name(event)); \
132117
return false; \
@@ -165,7 +150,7 @@ static inline bool da_event_##name(struct da_monitor *da_mon, struct task_struct
165150
for (int i = 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) { \
166151
next_state = model_get_next_state_##name(curr_state, event); \
167152
if (next_state == INVALID_STATE) { \
168-
cond_react_##name(curr_state, event); \
153+
react_##name(curr_state, event); \
169154
trace_error_##name(tsk->pid, \
170155
model_get_state_name_##name(curr_state), \
171156
model_get_event_name_##name(event)); \

include/rv/ltl_monitor.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,9 @@
1616
#error "Please include $(MODEL_NAME).h generated by rvgen"
1717
#endif
1818

19-
#ifdef CONFIG_RV_REACTORS
2019
#define RV_MONITOR_NAME CONCATENATE(rv_, MONITOR_NAME)
2120
static struct rv_monitor RV_MONITOR_NAME;
2221

23-
static void rv_cond_react(struct task_struct *task)
24-
{
25-
if (!rv_reacting_on() || !RV_MONITOR_NAME.react)
26-
return;
27-
RV_MONITOR_NAME.react("rv: "__stringify(MONITOR_NAME)": %s[%d]: violation detected\n",
28-
task->comm, task->pid);
29-
}
30-
#else
31-
static void rv_cond_react(struct task_struct *task)
32-
{
33-
}
34-
#endif
35-
3622
static int ltl_monitor_slot = RV_PER_TASK_MONITOR_INIT;
3723

3824
static void ltl_atoms_fetch(struct task_struct *task, struct ltl_monitor *mon);
@@ -98,7 +84,8 @@ static void ltl_monitor_destroy(void)
9884
static void ltl_illegal_state(struct task_struct *task, struct ltl_monitor *mon)
9985
{
10086
CONCATENATE(trace_error_, MONITOR_NAME)(task);
101-
rv_cond_react(task);
87+
rv_react(&RV_MONITOR_NAME, "rv: "__stringify(MONITOR_NAME)": %s[%d]: violation detected\n",
88+
task->comm, task->pid);
10289
}
10390

10491
static void ltl_attempt_start(struct task_struct *task, struct ltl_monitor *mon)

kernel/trace/rv/reactor_panic.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
#include <linux/init.h>
1414
#include <linux/rv.h>
1515

16-
__printf(1, 2) static void rv_panic_reaction(const char *msg, ...)
16+
__printf(1, 0) static void rv_panic_reaction(const char *msg, va_list args)
1717
{
18-
va_list args;
19-
20-
va_start(args, msg);
2118
vpanic(msg, args);
22-
va_end(args);
2319
}
2420

2521
static struct rv_reactor rv_panic = {

kernel/trace/rv/reactor_printk.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
#include <linux/init.h>
1313
#include <linux/rv.h>
1414

15-
__printf(1, 2) static void rv_printk_reaction(const char *msg, ...)
15+
__printf(1, 0) static void rv_printk_reaction(const char *msg, va_list args)
1616
{
17-
va_list args;
18-
19-
va_start(args, msg);
2017
vprintk_deferred(msg, args);
21-
va_end(args);
2218
}
2319

2420
static struct rv_reactor rv_printk = {

0 commit comments

Comments
 (0)