1*c4bbe83dSMarcos Paulo de Souza // SPDX-License-Identifier: GPL-2.0
2*c4bbe83dSMarcos Paulo de Souza // Copyright (C) 2014 Seth Jennings <sjenning@redhat.com>
3*c4bbe83dSMarcos Paulo de Souza
4*c4bbe83dSMarcos Paulo de Souza #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
5*c4bbe83dSMarcos Paulo de Souza
6*c4bbe83dSMarcos Paulo de Souza #include <linux/module.h>
7*c4bbe83dSMarcos Paulo de Souza #include <linux/kernel.h>
8*c4bbe83dSMarcos Paulo de Souza #include <linux/livepatch.h>
9*c4bbe83dSMarcos Paulo de Souza
10*c4bbe83dSMarcos Paulo de Souza #include <linux/seq_file.h>
livepatch_cmdline_proc_show(struct seq_file * m,void * v)11*c4bbe83dSMarcos Paulo de Souza static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
12*c4bbe83dSMarcos Paulo de Souza {
13*c4bbe83dSMarcos Paulo de Souza seq_printf(m, "%s: %s\n", THIS_MODULE->name,
14*c4bbe83dSMarcos Paulo de Souza "this has been live patched");
15*c4bbe83dSMarcos Paulo de Souza return 0;
16*c4bbe83dSMarcos Paulo de Souza }
17*c4bbe83dSMarcos Paulo de Souza
18*c4bbe83dSMarcos Paulo de Souza static struct klp_func funcs[] = {
19*c4bbe83dSMarcos Paulo de Souza {
20*c4bbe83dSMarcos Paulo de Souza .old_name = "cmdline_proc_show",
21*c4bbe83dSMarcos Paulo de Souza .new_func = livepatch_cmdline_proc_show,
22*c4bbe83dSMarcos Paulo de Souza }, { }
23*c4bbe83dSMarcos Paulo de Souza };
24*c4bbe83dSMarcos Paulo de Souza
25*c4bbe83dSMarcos Paulo de Souza static struct klp_object objs[] = {
26*c4bbe83dSMarcos Paulo de Souza {
27*c4bbe83dSMarcos Paulo de Souza /* name being NULL means vmlinux */
28*c4bbe83dSMarcos Paulo de Souza .funcs = funcs,
29*c4bbe83dSMarcos Paulo de Souza }, { }
30*c4bbe83dSMarcos Paulo de Souza };
31*c4bbe83dSMarcos Paulo de Souza
32*c4bbe83dSMarcos Paulo de Souza static struct klp_patch patch = {
33*c4bbe83dSMarcos Paulo de Souza .mod = THIS_MODULE,
34*c4bbe83dSMarcos Paulo de Souza .objs = objs,
35*c4bbe83dSMarcos Paulo de Souza };
36*c4bbe83dSMarcos Paulo de Souza
test_klp_livepatch_init(void)37*c4bbe83dSMarcos Paulo de Souza static int test_klp_livepatch_init(void)
38*c4bbe83dSMarcos Paulo de Souza {
39*c4bbe83dSMarcos Paulo de Souza return klp_enable_patch(&patch);
40*c4bbe83dSMarcos Paulo de Souza }
41*c4bbe83dSMarcos Paulo de Souza
test_klp_livepatch_exit(void)42*c4bbe83dSMarcos Paulo de Souza static void test_klp_livepatch_exit(void)
43*c4bbe83dSMarcos Paulo de Souza {
44*c4bbe83dSMarcos Paulo de Souza }
45*c4bbe83dSMarcos Paulo de Souza
46*c4bbe83dSMarcos Paulo de Souza module_init(test_klp_livepatch_init);
47*c4bbe83dSMarcos Paulo de Souza module_exit(test_klp_livepatch_exit);
48*c4bbe83dSMarcos Paulo de Souza MODULE_LICENSE("GPL");
49*c4bbe83dSMarcos Paulo de Souza MODULE_INFO(livepatch, "Y");
50*c4bbe83dSMarcos Paulo de Souza MODULE_AUTHOR("Seth Jennings <sjenning@redhat.com>");
51*c4bbe83dSMarcos Paulo de Souza MODULE_DESCRIPTION("Livepatch test: livepatch module");
52