kmod/core: pass 'replace' flag to kpatch_apply_patch()

Make kpatch_apply_patch() aware of whether the patch should replace other
patches.

This will be used by subsequent fixes.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
This commit is contained in:
Evgenii Shatokhin 2019-07-01 12:44:17 +03:00
parent 8e3daab9f7
commit 6881c07f6c
1 changed files with 15 additions and 2 deletions

View File

@ -83,6 +83,11 @@ struct kpatch_kallsyms_args {
unsigned long pos;
};
struct kpatch_apply_patch_args {
struct kpatch_module *kpmod;
bool replace;
};
/* this is a double loop, use goto instead of break */
#define do_for_each_linked_func(kpmod, func) { \
struct kpatch_object *_object; \
@ -350,11 +355,14 @@ static inline void post_unpatch_callback(struct kpatch_object *object)
/* Called from stop_machine */
static int kpatch_apply_patch(void *data)
{
struct kpatch_module *kpmod = data;
struct kpatch_apply_patch_args *args = data;
struct kpatch_module *kpmod;
struct kpatch_func *func;
struct kpatch_object *object;
int ret;
kpmod = args->kpmod;
ret = kpatch_verify_activeness_safety(kpmod);
if (ret) {
kpatch_state_finish(KPATCH_STATE_FAILURE);
@ -980,6 +988,11 @@ int kpatch_register(struct kpatch_module *kpmod, bool replace)
struct kpatch_object *object, *object_err = NULL;
struct kpatch_func *func;
struct kpatch_apply_patch_args args = {
.kpmod = kpmod,
.replace = replace,
};
if (!kpmod->mod || list_empty(&kpmod->objects))
return -EINVAL;
@ -1031,7 +1044,7 @@ int kpatch_register(struct kpatch_module *kpmod, bool replace)
* Idle the CPUs, verify activeness safety, and atomically make the new
* functions visible to the ftrace handler.
*/
ret = stop_machine(kpatch_apply_patch, kpmod, NULL);
ret = stop_machine(kpatch_apply_patch, &args, NULL);
/*
* For the replace case, remove any obsolete funcs from the hash and