18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * livepatch.h - powerpc-specific Kernel Live Patching Core 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2015-2016, SUSE, IBM Corp. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_LIVEPATCH_H 88c2ecf20Sopenharmony_ci#define _ASM_POWERPC_LIVEPATCH_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/module.h> 118c2ecf20Sopenharmony_ci#include <linux/ftrace.h> 128c2ecf20Sopenharmony_ci#include <linux/sched/task_stack.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#ifdef CONFIG_LIVEPATCH 158c2ecf20Sopenharmony_cistatic inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci regs->nip = ip; 188c2ecf20Sopenharmony_ci} 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define klp_get_ftrace_location klp_get_ftrace_location 218c2ecf20Sopenharmony_cistatic inline unsigned long klp_get_ftrace_location(unsigned long faddr) 228c2ecf20Sopenharmony_ci{ 238c2ecf20Sopenharmony_ci /* 248c2ecf20Sopenharmony_ci * Live patch works only with -mprofile-kernel on PPC. In this case, 258c2ecf20Sopenharmony_ci * the ftrace location is always within the first 16 bytes. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci return ftrace_location_range(faddr, faddr + 16); 288c2ecf20Sopenharmony_ci} 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic inline void klp_init_thread_info(struct task_struct *p) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci /* + 1 to account for STACK_END_MAGIC */ 338c2ecf20Sopenharmony_ci task_thread_info(p)->livepatch_sp = end_of_stack(p) + 1; 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci#else 368c2ecf20Sopenharmony_cistatic inline void klp_init_thread_info(struct task_struct *p) { } 378c2ecf20Sopenharmony_ci#endif /* CONFIG_LIVEPATCH */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_LIVEPATCH_H */ 40