Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * livepatch.h - powerpc-specific Kernel Live Patching Core
4 *
5 * Copyright (C) 2015-2016, SUSE, IBM Corp.
6 */
7#ifndef _ASM_POWERPC_LIVEPATCH_H
8#define _ASM_POWERPC_LIVEPATCH_H
9
10#include <linux/module.h>
11#include <linux/ftrace.h>
12#include <linux/sched/task_stack.h>
13
14#ifdef CONFIG_LIVEPATCH
15static inline void klp_arch_set_pc(struct ftrace_regs *fregs, unsigned long ip)
16{
17 struct pt_regs *regs = ftrace_get_regs(fregs);
18
19 regs->nip = ip;
20}
21
22#define klp_get_ftrace_location klp_get_ftrace_location
23static inline unsigned long klp_get_ftrace_location(unsigned long faddr)
24{
25 /*
26 * Live patch works only with -mprofile-kernel on PPC. In this case,
27 * the ftrace location is always within the first 16 bytes.
28 */
29 return ftrace_location_range(faddr, faddr + 16);
30}
31
32static inline void klp_init_thread_info(struct task_struct *p)
33{
34 /* + 1 to account for STACK_END_MAGIC */
35 task_thread_info(p)->livepatch_sp = end_of_stack(p) + 1;
36}
37#else
38static inline void klp_init_thread_info(struct task_struct *p) { }
39#endif /* CONFIG_LIVEPATCH */
40
41#endif /* _ASM_POWERPC_LIVEPATCH_H */