mirror of https://github.com/dynup/kpatch
integration/ubuntu1604: replace macro-hooks.patch with macro-callbacks.patch
Macroses used in macro-hoos.patch are deprecated, use updated macro-callbacs.patch instead. Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
parent
086f7f6319
commit
36ba4343bb
|
@ -0,0 +1,163 @@
|
||||||
|
kpatch/livepatch callback test patch:
|
||||||
|
|
||||||
|
vmlinux
|
||||||
|
pcspkr (mod)
|
||||||
|
joydev (mod)
|
||||||
|
|
||||||
|
Note: update joydev's pre-patch callback to return -ENODEV to test failure path
|
||||||
|
|
||||||
|
diff -Nupr src.old/drivers/input/joydev.c src/drivers/input/joydev.c
|
||||||
|
--- src.old/drivers/input/joydev.c 2017-09-03 16:56:17.000000000 -0400
|
||||||
|
+++ src/drivers/input/joydev.c 2018-03-22 16:32:40.963082354 -0400
|
||||||
|
@@ -1010,3 +1010,47 @@ static void __exit joydev_exit(void)
|
||||||
|
|
||||||
|
module_init(joydev_init);
|
||||||
|
module_exit(joydev_exit);
|
||||||
|
+
|
||||||
|
+#include <linux/module.h>
|
||||||
|
+#include "kpatch-macros.h"
|
||||||
|
+
|
||||||
|
+static const char *const module_state[] = {
|
||||||
|
+ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
|
||||||
|
+ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init",
|
||||||
|
+ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away",
|
||||||
|
+ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up",
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void callback_info(const char *callback, patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ if (obj->mod)
|
||||||
|
+ pr_info("%s: %s -> %s\n", callback, obj->mod->name,
|
||||||
|
+ module_state[obj->mod->state]);
|
||||||
|
+ else
|
||||||
|
+ pr_info("%s: vmlinux\n", callback);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int pre_patch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+ return 0; /* return -ENODEV; */
|
||||||
|
+}
|
||||||
|
+KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback);
|
||||||
|
+
|
||||||
|
+static void post_patch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_POST_PATCH_CALLBACK(post_patch_callback);
|
||||||
|
+
|
||||||
|
+static void pre_unpatch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback);
|
||||||
|
+
|
||||||
|
+static void post_unpatch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback);
|
||||||
|
diff -Nupr src.old/drivers/input/misc/pcspkr.c src/drivers/input/misc/pcspkr.c
|
||||||
|
--- src.old/drivers/input/misc/pcspkr.c 2018-03-22 16:29:27.716082354 -0400
|
||||||
|
+++ src/drivers/input/misc/pcspkr.c 2018-03-22 16:32:40.963082354 -0400
|
||||||
|
@@ -132,3 +132,46 @@ static struct platform_driver pcspkr_pla
|
||||||
|
};
|
||||||
|
module_platform_driver(pcspkr_platform_driver);
|
||||||
|
|
||||||
|
+#include <linux/module.h>
|
||||||
|
+#include "kpatch-macros.h"
|
||||||
|
+
|
||||||
|
+static const char *const module_state[] = {
|
||||||
|
+ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
|
||||||
|
+ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init",
|
||||||
|
+ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away",
|
||||||
|
+ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up",
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void callback_info(const char *callback, patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ if (obj->mod)
|
||||||
|
+ pr_info("%s: %s -> %s\n", callback, obj->mod->name,
|
||||||
|
+ module_state[obj->mod->state]);
|
||||||
|
+ else
|
||||||
|
+ pr_info("%s: vmlinux\n", callback);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int pre_patch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback);
|
||||||
|
+
|
||||||
|
+static void post_patch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_POST_PATCH_CALLBACK(post_patch_callback);
|
||||||
|
+
|
||||||
|
+static void pre_unpatch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback);
|
||||||
|
+
|
||||||
|
+static void post_unpatch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback);
|
||||||
|
diff -Nupr src.old/fs/aio.c src/fs/aio.c
|
||||||
|
--- src.old/fs/aio.c 2017-09-03 16:56:17.000000000 -0400
|
||||||
|
+++ src/fs/aio.c 2018-03-22 16:32:40.962082354 -0400
|
||||||
|
@@ -46,6 +46,50 @@
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
+#include <linux/module.h>
|
||||||
|
+#include "kpatch-macros.h"
|
||||||
|
+
|
||||||
|
+static const char *const module_state[] = {
|
||||||
|
+ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
|
||||||
|
+ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init",
|
||||||
|
+ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away",
|
||||||
|
+ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up",
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void callback_info(const char *callback, patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ if (obj->mod)
|
||||||
|
+ pr_info("%s: %s -> %s\n", callback, obj->mod->name,
|
||||||
|
+ module_state[obj->mod->state]);
|
||||||
|
+ else
|
||||||
|
+ pr_info("%s: vmlinux\n", callback);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int pre_patch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback);
|
||||||
|
+
|
||||||
|
+static void post_patch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_POST_PATCH_CALLBACK(post_patch_callback);
|
||||||
|
+
|
||||||
|
+static void pre_unpatch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback);
|
||||||
|
+
|
||||||
|
+static void post_unpatch_callback(patch_object *obj)
|
||||||
|
+{
|
||||||
|
+ callback_info(__func__, obj);
|
||||||
|
+}
|
||||||
|
+KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback);
|
||||||
|
+
|
||||||
|
#define AIO_RING_MAGIC 0xa10a10a1
|
||||||
|
#define AIO_RING_COMPAT_FEATURES 1
|
||||||
|
#define AIO_RING_INCOMPAT_FEATURES 0
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
[[ $(cat /proc/sys/fs/aio-max-nr) = 262144 ]]
|
|
|
@ -1,24 +0,0 @@
|
||||||
diff -Nupr src.orig/fs/aio.c src/fs/aio.c
|
|
||||||
--- src.orig/fs/aio.c 2016-12-15 19:55:38.992000000 +0000
|
|
||||||
+++ src/fs/aio.c 2016-12-15 19:57:05.396000000 +0000
|
|
||||||
@@ -1716,6 +1716,20 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int aio_max_nr_orig;
|
|
||||||
+void kpatch_load_aio_max_nr(void)
|
|
||||||
+{
|
|
||||||
+ aio_max_nr_orig = aio_max_nr;
|
|
||||||
+ aio_max_nr = 0x40000;
|
|
||||||
+}
|
|
||||||
+void kpatch_unload_aio_max_nr(void)
|
|
||||||
+{
|
|
||||||
+ aio_max_nr = aio_max_nr_orig;
|
|
||||||
+}
|
|
||||||
+#include "kpatch-macros.h"
|
|
||||||
+KPATCH_LOAD_HOOK(kpatch_load_aio_max_nr);
|
|
||||||
+KPATCH_UNLOAD_HOOK(kpatch_unload_aio_max_nr);
|
|
||||||
+
|
|
||||||
/* io_getevents:
|
|
||||||
* Attempts to read at least min_nr events and up to nr events from
|
|
||||||
* the completion queue for the aio_context specified by ctx_id. If
|
|
Loading…
Reference in New Issue