1 // SPDX-License-Identifier: GPL-2.0
4 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6 #include <linux/module.h>
7 #include <linux/kernel.h>
8 #include <linux/livepatch.h>
11 module_param(replace, int, 0644);
12 MODULE_PARM_DESC(replace, "replace (default=0)");
14 #include <linux/seq_file.h>
15 static int livepatch_meminfo_proc_show(struct seq_file *m, void *v)
17 seq_printf(m, "%s: %s\n", THIS_MODULE->name,
18 "this has been live patched");
22 static struct klp_func funcs[] = {
24 .old_name = "meminfo_proc_show",
25 .new_func = livepatch_meminfo_proc_show,
29 static struct klp_object objs[] = {
31 /* name being NULL means vmlinux */
36 static struct klp_patch patch = {
39 /* set .replace in the init function below for demo purposes */
42 static int test_klp_atomic_replace_init(void)
44 patch.replace = replace;
45 return klp_enable_patch(&patch);
48 static void test_klp_atomic_replace_exit(void)
52 module_init(test_klp_atomic_replace_init);
53 module_exit(test_klp_atomic_replace_exit);
54 MODULE_LICENSE("GPL");
55 MODULE_INFO(livepatch, "Y");
57 MODULE_DESCRIPTION("Livepatch test: atomic replace");