forked from luck/tmp_suning_uos_patched
1ccea77e2a
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not see http www gnu org licenses this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details [based] [from] [clk] [highbank] [c] you should have received a copy of the gnu general public license along with this program if not see http www gnu org licenses extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 355 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com> Reviewed-by: Steve Winslow <swinslow@gmail.com> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* livepatch.c - x86-specific Kernel Live Patching Core
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/livepatch.h>
|
|
#include <asm/text-patching.h>
|
|
|
|
/* Apply per-object alternatives. Based on x86 module_finalize() */
|
|
void arch_klp_init_object_loaded(struct klp_patch *patch,
|
|
struct klp_object *obj)
|
|
{
|
|
int cnt;
|
|
struct klp_modinfo *info;
|
|
Elf_Shdr *s, *alt = NULL, *para = NULL;
|
|
void *aseg, *pseg;
|
|
const char *objname;
|
|
char sec_objname[MODULE_NAME_LEN];
|
|
char secname[KSYM_NAME_LEN];
|
|
|
|
info = patch->mod->klp_info;
|
|
objname = obj->name ? obj->name : "vmlinux";
|
|
|
|
/* See livepatch core code for BUILD_BUG_ON() explanation */
|
|
BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 128);
|
|
|
|
for (s = info->sechdrs; s < info->sechdrs + info->hdr.e_shnum; s++) {
|
|
/* Apply per-object .klp.arch sections */
|
|
cnt = sscanf(info->secstrings + s->sh_name,
|
|
".klp.arch.%55[^.].%127s",
|
|
sec_objname, secname);
|
|
if (cnt != 2)
|
|
continue;
|
|
if (strcmp(sec_objname, objname))
|
|
continue;
|
|
if (!strcmp(".altinstructions", secname))
|
|
alt = s;
|
|
if (!strcmp(".parainstructions", secname))
|
|
para = s;
|
|
}
|
|
|
|
if (alt) {
|
|
aseg = (void *) alt->sh_addr;
|
|
apply_alternatives(aseg, aseg + alt->sh_size);
|
|
}
|
|
|
|
if (para) {
|
|
pseg = (void *) para->sh_addr;
|
|
apply_paravirt(pseg, pseg + para->sh_size);
|
|
}
|
|
}
|