18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// Copyright (C) 2014 Seth Jennings <sjenning@redhat.com> 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/module.h> 78c2ecf20Sopenharmony_ci#include <linux/kernel.h> 88c2ecf20Sopenharmony_ci#include <linux/livepatch.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/seq_file.h> 118c2ecf20Sopenharmony_cistatic int livepatch_cmdline_proc_show(struct seq_file *m, void *v) 128c2ecf20Sopenharmony_ci{ 138c2ecf20Sopenharmony_ci seq_printf(m, "%s: %s\n", THIS_MODULE->name, 148c2ecf20Sopenharmony_ci "this has been live patched"); 158c2ecf20Sopenharmony_ci return 0; 168c2ecf20Sopenharmony_ci} 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic struct klp_func funcs[] = { 198c2ecf20Sopenharmony_ci { 208c2ecf20Sopenharmony_ci .old_name = "cmdline_proc_show", 218c2ecf20Sopenharmony_ci .new_func = livepatch_cmdline_proc_show, 228c2ecf20Sopenharmony_ci }, { } 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistatic struct klp_object objs[] = { 268c2ecf20Sopenharmony_ci { 278c2ecf20Sopenharmony_ci /* name being NULL means vmlinux */ 288c2ecf20Sopenharmony_ci .funcs = funcs, 298c2ecf20Sopenharmony_ci }, { } 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic struct klp_patch patch = { 338c2ecf20Sopenharmony_ci .mod = THIS_MODULE, 348c2ecf20Sopenharmony_ci .objs = objs, 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic int test_klp_livepatch_init(void) 388c2ecf20Sopenharmony_ci{ 398c2ecf20Sopenharmony_ci return klp_enable_patch(&patch); 408c2ecf20Sopenharmony_ci} 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic void test_klp_livepatch_exit(void) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cimodule_init(test_klp_livepatch_init); 478c2ecf20Sopenharmony_cimodule_exit(test_klp_livepatch_exit); 488c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 498c2ecf20Sopenharmony_ciMODULE_INFO(livepatch, "Y"); 508c2ecf20Sopenharmony_ciMODULE_AUTHOR("Seth Jennings <sjenning@redhat.com>"); 518c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Livepatch test: livepatch module"); 52