xref: /openbmc/linux/tools/perf/trace/beauty/seccomp.c (revision a36954f5)
1 #ifndef SECCOMP_SET_MODE_STRICT
2 #define SECCOMP_SET_MODE_STRICT 0
3 #endif
4 #ifndef SECCOMP_SET_MODE_FILTER
5 #define SECCOMP_SET_MODE_FILTER 1
6 #endif
7 
8 static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
9 {
10 	int op = arg->val;
11 	size_t printed = 0;
12 
13 	switch (op) {
14 #define	P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break
15 	P_SECCOMP_SET_MODE_OP(STRICT);
16 	P_SECCOMP_SET_MODE_OP(FILTER);
17 #undef P_SECCOMP_SET_MODE_OP
18 	default: printed = scnprintf(bf, size, "%#x", op);			  break;
19 	}
20 
21 	return printed;
22 }
23 
24 #define SCA_SECCOMP_OP  syscall_arg__scnprintf_seccomp_op
25 
26 #ifndef SECCOMP_FILTER_FLAG_TSYNC
27 #define SECCOMP_FILTER_FLAG_TSYNC 1
28 #endif
29 
30 static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size,
31 						   struct syscall_arg *arg)
32 {
33 	int printed = 0, flags = arg->val;
34 
35 #define	P_FLAG(n) \
36 	if (flags & SECCOMP_FILTER_FLAG_##n) { \
37 		printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
38 		flags &= ~SECCOMP_FILTER_FLAG_##n; \
39 	}
40 
41 	P_FLAG(TSYNC);
42 #undef P_FLAG
43 
44 	if (flags)
45 		printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
46 
47 	return printed;
48 }
49 
50 #define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags
51