// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2017 Joe Lawrence <joe.lawrence@redhat.com>
*/
/* * livepatch-callbacks-demo.c - (un)patching callbacks livepatch demo * * * Purpose * ------- * * Demonstration of registering livepatch (un)patching callbacks. * * * Usage * ----- * * Step 1 - load the simple module * * insmod samples/livepatch/livepatch-callbacks-mod.ko * * * Step 2 - load the demonstration livepatch (with callbacks) * * insmod samples/livepatch/livepatch-callbacks-demo.ko * * * Step 3 - cleanup * * echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo/enabled * rmmod livepatch_callbacks_demo * rmmod livepatch_callbacks_mod * * Watch dmesg output to see livepatch enablement, callback execution * and patching operations for both vmlinux and module targets. * * NOTE: swap the insmod order of livepatch-callbacks-mod.ko and * livepatch-callbacks-demo.ko to observe what happens when a * target module is loaded after a livepatch with callbacks. * * NOTE: 'pre_patch_ret' is a module parameter that sets the pre-patch * callback return status. Try setting up a non-zero status * such as -19 (-ENODEV): * * # Load demo livepatch, vmlinux is patched * insmod samples/livepatch/livepatch-callbacks-demo.ko * * # Setup next pre-patch callback to return -ENODEV * echo -19 > /sys/module/livepatch_callbacks_demo/parameters/pre_patch_ret * * # Module loader refuses to load the target module * insmod samples/livepatch/livepatch-callbacks-mod.ko * insmod: ERROR: could not insert module samples/livepatch/livepatch-callbacks-mod.ko: No such device * * NOTE: There is a second target module, * livepatch-callbacks-busymod.ko, available for experimenting * with livepatch (un)patch callbacks. This module contains * a 'sleep_secs' parameter that parks the module on one of the * functions that the livepatch demo module wants to patch. * Modifying this value and tweaking the order of module loads can * effectively demonstrate stalled patch transitions: * * # Load a target module, let it park on 'busymod_work_func' for * # thirty seconds * insmod samples/livepatch/livepatch-callbacks-busymod.ko sleep_secs=30 * * # Meanwhile load the livepatch * insmod samples/livepatch/livepatch-callbacks-demo.ko * * # ... then load and unload another target module while the * # transition is in progress * insmod samples/livepatch/livepatch-callbacks-mod.ko * rmmod samples/livepatch/livepatch-callbacks-mod.ko * * # Finally cleanup * echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo/enabled * rmmod samples/livepatch/livepatch-callbacks-demo.ko
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.