Thomas Gleixner | 1ccea77 | 2019-05-19 15:51:43 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Michael Ellerman | f63e6d8 | 2016-03-24 22:04:03 +1100 | [diff] [blame] | 2 | /* |
| 3 | * livepatch.h - powerpc-specific Kernel Live Patching Core |
| 4 | * |
| 5 | * Copyright (C) 2015-2016, SUSE, IBM Corp. |
Michael Ellerman | f63e6d8 | 2016-03-24 22:04:03 +1100 | [diff] [blame] | 6 | */ |
| 7 | #ifndef _ASM_POWERPC_LIVEPATCH_H |
| 8 | #define _ASM_POWERPC_LIVEPATCH_H |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/ftrace.h> |
Christophe Leroy | ed1cd6d | 2019-01-31 10:08:58 +0000 | [diff] [blame] | 12 | #include <linux/sched/task_stack.h> |
Michael Ellerman | f63e6d8 | 2016-03-24 22:04:03 +1100 | [diff] [blame] | 13 | |
| 14 | #ifdef CONFIG_LIVEPATCH |
Michael Ellerman | f63e6d8 | 2016-03-24 22:04:03 +1100 | [diff] [blame] | 15 | static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip) |
| 16 | { |
| 17 | regs->nip = ip; |
| 18 | } |
| 19 | |
| 20 | #define klp_get_ftrace_location klp_get_ftrace_location |
| 21 | static inline unsigned long klp_get_ftrace_location(unsigned long faddr) |
| 22 | { |
| 23 | /* |
| 24 | * Live patch works only with -mprofile-kernel on PPC. In this case, |
| 25 | * the ftrace location is always within the first 16 bytes. |
| 26 | */ |
| 27 | return ftrace_location_range(faddr, faddr + 16); |
| 28 | } |
Michael Ellerman | 5d31a96 | 2016-03-24 22:04:04 +1100 | [diff] [blame] | 29 | |
Christophe Leroy | ed1cd6d | 2019-01-31 10:08:58 +0000 | [diff] [blame] | 30 | static inline void klp_init_thread_info(struct task_struct *p) |
Michael Ellerman | 5d31a96 | 2016-03-24 22:04:04 +1100 | [diff] [blame] | 31 | { |
| 32 | /* + 1 to account for STACK_END_MAGIC */ |
Christophe Leroy | ed1cd6d | 2019-01-31 10:08:58 +0000 | [diff] [blame] | 33 | task_thread_info(p)->livepatch_sp = end_of_stack(p) + 1; |
Michael Ellerman | 5d31a96 | 2016-03-24 22:04:04 +1100 | [diff] [blame] | 34 | } |
| 35 | #else |
Christophe Leroy | ed1cd6d | 2019-01-31 10:08:58 +0000 | [diff] [blame] | 36 | static inline void klp_init_thread_info(struct task_struct *p) { } |
Michael Ellerman | f63e6d8 | 2016-03-24 22:04:03 +1100 | [diff] [blame] | 37 | #endif /* CONFIG_LIVEPATCH */ |
| 38 | |
| 39 | #endif /* _ASM_POWERPC_LIVEPATCH_H */ |