blob: 19c099afa8613ead6565917f5787deb3df12c9e7 [file] [log] [blame]
Seth Jenningsb700e7f2014-12-16 11:58:19 -06001/*
2 * livepatch.h - x86-specific Kernel Live Patching Core
3 *
4 * Copyright (C) 2014 Seth Jennings <sjenning@redhat.com>
5 * Copyright (C) 2014 SUSE
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef _ASM_X86_LIVEPATCH_H
22#define _ASM_X86_LIVEPATCH_H
23
Jiri Kosina5d4351b2015-04-27 13:25:23 +020024#include <asm/setup.h>
Seth Jenningsb700e7f2014-12-16 11:58:19 -060025#include <linux/module.h>
Li Binb5bfc512014-12-19 14:11:17 +080026#include <linux/ftrace.h>
Seth Jenningsb700e7f2014-12-16 11:58:19 -060027
Josh Poimboeuf12cf89b2015-02-03 16:45:18 -060028#ifdef CONFIG_LIVEPATCH
Jiri Kosinab9dfe0b2015-01-09 10:53:21 +010029static inline int klp_check_compiler_support(void)
30{
Seth Jenningsb700e7f2014-12-16 11:58:19 -060031#ifndef CC_USING_FENTRY
Jiri Kosinab9dfe0b2015-01-09 10:53:21 +010032 return 1;
Seth Jenningsb700e7f2014-12-16 11:58:19 -060033#endif
Jiri Kosinab9dfe0b2015-01-09 10:53:21 +010034 return 0;
35}
Miroslav Benes4421f8f2015-02-18 15:21:07 +010036int klp_write_module_reloc(struct module *mod, unsigned long type,
37 unsigned long loc, unsigned long value);
Seth Jenningsb700e7f2014-12-16 11:58:19 -060038
Li Binb5bfc512014-12-19 14:11:17 +080039static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
40{
41 regs->ip = ip;
42}
Seth Jenningsb700e7f2014-12-16 11:58:19 -060043#else
Josh Poimboeuf12cf89b2015-02-03 16:45:18 -060044#error Live patching support is disabled; check CONFIG_LIVEPATCH
Seth Jenningsb700e7f2014-12-16 11:58:19 -060045#endif
46
47#endif /* _ASM_X86_LIVEPATCH_H */