diff options
| author | Linus Walleij <linusw@kernel.org> | 2026-06-30 18:05:56 +0100 |
|---|---|---|
| committer | Russell King <rmk+kernel@armlinux.org.uk> | 2026-08-05 16:48:11 +0100 |
| commit | bb3b2cfeb206f5b10b859e134651b54120e3f530 (patch) | |
| tree | 6717fcea088ba5c5f15002a48101fa2537135bf2 /samples/livepatch/livepatch-sample.c | |
| download | linux-stable-bb3b2cfeb206f5b10b859e134651b54120e3f530.tar.gz linux-stable-bb3b2cfeb206f5b10b859e134651b54120e3f530.zip | |
ARM: 9480/1: entry: expand comment in __switch_tografted
As per discussion between the developers in the mail thread
linked, expand the comment in __switch_to so that readers
of the code understand what is going on.
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'samples/livepatch/livepatch-sample.c')
| -rw-r--r-- | samples/livepatch/livepatch-sample.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/samples/livepatch/livepatch-sample.c b/samples/livepatch/livepatch-sample.c new file mode 100644 index 000000000..5263a2f31 --- /dev/null +++ b/samples/livepatch/livepatch-sample.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * livepatch-sample.c - Kernel Live Patching Sample Module + * + * Copyright (C) 2014 Seth Jennings <sjenning@redhat.com> + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/livepatch.h> + +/* + * This (dumb) live patch overrides the function that prints the + * kernel boot cmdline when /proc/cmdline is read. + * + * Example: + * + * $ cat /proc/cmdline + * <your cmdline> + * + * $ insmod livepatch-sample.ko + * $ cat /proc/cmdline + * this has been live patched + * + * $ echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled + * $ cat /proc/cmdline + * <your cmdline> + */ + +#include <linux/seq_file.h> +static int livepatch_cmdline_proc_show(struct seq_file *m, void *v) +{ + seq_printf(m, "%s\n", "this has been live patched"); + return 0; +} + +static struct klp_func funcs[] = { + { + .old_name = "cmdline_proc_show", + .new_func = livepatch_cmdline_proc_show, + }, { } +}; + +static struct klp_object objs[] = { + { + /* name being NULL means vmlinux */ + .funcs = funcs, + }, { } +}; + +static struct klp_patch patch = { + .mod = THIS_MODULE, + .objs = objs, +}; + +static int livepatch_init(void) +{ + return klp_enable_patch(&patch); +} + +static void livepatch_exit(void) +{ +} + +module_init(livepatch_init); +module_exit(livepatch_exit); +MODULE_DESCRIPTION("Kernel Live Patching Sample Module"); +MODULE_LICENSE("GPL"); +MODULE_INFO(livepatch, "Y"); |
