Lines Matching +full:kernel +full:- +full:parameters

2 # SPDX-License-Identifier: GPL-2.0
9 SYSFS_KERNEL_DIR="/sys/kernel"
13 if [[ -e /sys/kernel/tracing/trace ]]; then
19 # Kselftest framework requirement - SKIP code is 4
22 # log(msg) - write message to kernel log
23 # msg - insightful words
28 # skip(msg) - testing can't proceed
29 # msg - explanation
38 uid=$(id -u)
39 if [ $uid -ne 0 ]; then
47 if [ -z "$KDIR" ]; then
48 KDIR="/lib/modules/$(uname -r)/build"
51 if [ ! -d "$KDIR" ]; then
57 # die(msg) - game over, man
58 # msg - dying words
66 DYNAMIC_DEBUG=$(grep '^kernel/livepatch' "$SYSFS_DEBUG_DIR/dynamic_debug/control" | \
67 awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}')
68 FTRACE_ENABLED=$(sysctl --values kernel.ftrace_enabled)
76 if [[ -n "$DYNAMIC_DEBUG" ]]; then
77 echo -n "$DYNAMIC_DEBUG" > "$SYSFS_DEBUG_DIR/dynamic_debug/control"
79 if [[ -n "$FTRACE_ENABLED" ]]; then
80 sysctl kernel.ftrace_enabled="$FTRACE_ENABLED" &> /dev/null
82 if [[ -n "$KPROBE_ENABLED" ]]; then
85 if [[ -n "$TRACING_ON" ]]; then
88 if [[ -n "$CURRENT_TRACER" ]]; then
91 if [[ -n "$FTRACE_FILTER" ]]; then
93 | sed -e "/#### all functions enabled ####/d" \
99 cat <<-EOF > "$SYSFS_DEBUG_DIR/dynamic_debug/control"
100 file kernel/livepatch/* +p
101 func klp_try_switch_task -p
107 if [[ "$1" == "--fail" ]] ; then
112 local err=$(sysctl -q kernel.ftrace_enabled="$1" 2>&1)
113 local result=$(sysctl --values kernel.ftrace_enabled)
116 if [[ $can_fail -eq 1 ]] ; then
117 echo "livepatch: $err" | sed 's#/proc/sys/kernel/#kernel.#' > /dev/kmsg
121 skip "failed to set kernel.ftrace_enabled = $1"
124 echo "livepatch: kernel.ftrace_enabled = $result" > /dev/kmsg
131 # setup_config - save the current config and set a script exit trap that
144 # loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES,
146 # cmd - command and its arguments to run
152 [[ $((i++)) -eq $MAX_RETRIES ]] && return 1
160 if [[ ! -f "test_modules/$mod.ko" ]]; then
182 loop_until '[[ -e "/sys/module/$mod" ]]' ||
187 # load_mod(modname, params) - load a kernel module
188 # modname - module name to load
189 # params - module parameters to pass to insmod
199 # load_lp_nowait(modname, params) - load a kernel module with a livepatch
201 # modname - module name to load
202 # params - module parameters to pass to insmod
212 loop_until '[[ -e "$SYSFS_KLP_DIR/$mod" ]]' ||
216 # load_lp(modname, params) - load a kernel module with a livepatch
217 # modname - module name to load
218 # params - module parameters to pass to insmod
225 loop_until 'grep -q '^0$' $SYSFS_KLP_DIR/$mod/transition' ||
229 # load_failing_mod(modname, params) - load a kernel module, expect to fail
230 # modname - module name to load
231 # params - module parameters to pass to insmod
244 # unload_mod(modname) - unload a kernel module
245 # modname - module name to unload
260 loop_until '[[ ! -e "/sys/module/$mod" ]]' ||
264 # unload_lp(modname) - unload a kernel module with a livepatch
265 # modname - module name to unload
270 # disable_lp(modname) - disable a livepatch
271 # modname - module name to unload
280 loop_until '[[ ! -e "$SYSFS_KLP_DIR/$mod" ]]' ||
285 # modname - module name to set
286 # pre_patch_ret - new pre_patch_ret value
291 log "% echo $ret > /sys/module/$mod/parameters/pre_patch_ret"
292 echo "$ret" > /sys/module/"$mod"/parameters/pre_patch_ret
295 loop_until '[[ $(cat "/sys/module/$mod/parameters/pre_patch_ret") == "$ret" ]]' ||
304 # find new kernel messages since the test started.
305 local last_dmesg_msg="livepatch kselftest timestamp: $(date --rfc-3339=ns)"
307 loop_until 'dmesg | grep -q "$last_dmesg_msg"' ||
311 echo -n "TEST: $test ... "
315 # check_result() - verify dmesg output
316 # TODO - better filter, out of order msgs, etc?
322 # - include lines matching keywords
323 # - exclude lines matching keywords
324 # - filter out dmesg timestamp prefixes
325 result=$(dmesg | awk -v last_dmesg="$LAST_DMESG" 'p; $0 == last_dmesg { p=1 }' | \
326 grep -e 'livepatch:' -e 'test_klp' | \
327 grep -v '\(tainting\|taints\) kernel' | \
328 sed 's/^\[[ 0-9.]*\] //' | \
329 sed 's/^\[[ ]*[CT][0-9]*\] //')
334 echo -e "not ok\n\nbuffer overrun? can't find canary dmesg entry: $LAST_DMESG\n"
337 …echo -e "not ok\n\n$(diff -upr --label expected --label result <(echo "$expect") <(echo "$result")…
342 # check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs
344 # modname - livepatch module creating the sysfs interface
345 # rel_path - relative path of the sysfs interface
346 # expected_rights - expected access rights
353 local rights=$(/bin/stat --format '%A' "$path")
359 # check_sysfs_value(modname, rel_path, expected_value) - check sysfs value
360 # modname - livepatch module creating the sysfs interface
361 # rel_path - relative path of the sysfs interface
362 # expected_value - expected value read from the file
375 # cleanup_tracing() - stop and clean up function tracing
383 # trace_function(function) - start tracing of a function
384 # function - to be traced function
395 # check_traced_functions(functions...) - check whether each function appeared in the trace log
396 # functions - list of functions to be checked
401 if ! grep -Fwq "$function" "$SYSFS_TRACING_DIR/trace" ; then