livepatch.h 979 字节
Newer Older
Z
Zou Cao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#ifndef _ASM_ARM64_LIVEPATCH_H
#define _ASM_ARM64_LIVEPATCH_H

#include <linux/module.h>
#include <linux/ftrace.h>

#ifdef CONFIG_LIVEPATCH

#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
static inline int klp_check_compiler_support(void)
{
	return 0;
}

static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long pc)
{
	regs->pc = pc + 2*AARCH64_INSN_SIZE;
}

#define klp_get_ftrace_location klp_get_ftrace_location
static inline unsigned long klp_get_ftrace_location(unsigned long faddr)
{
	return faddr + AARCH64_INSN_SIZE;
}

#else
static inline int  klp_check_compiler_support(void)
{
	return 1;
}

static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long pc)
{
}

#define klp_get_ftrace_location klp_get_ftrace_location
static inline unsigned long klp_get_ftrace_location(unsigned long faddr)
{
	return faddr + AARCH64_INSN_SIZE;
}
#endif

#else
#error Live patching support is disabled; check CONFIG_LIVEPATCH
#endif

#endif /* _ASM_ARM64_LIVEPATCH_H */