1*f63e6d89SMichael Ellerman /* 2*f63e6d89SMichael Ellerman * livepatch.h - powerpc-specific Kernel Live Patching Core 3*f63e6d89SMichael Ellerman * 4*f63e6d89SMichael Ellerman * Copyright (C) 2015-2016, SUSE, IBM Corp. 5*f63e6d89SMichael Ellerman * 6*f63e6d89SMichael Ellerman * This program is free software; you can redistribute it and/or 7*f63e6d89SMichael Ellerman * modify it under the terms of the GNU General Public License 8*f63e6d89SMichael Ellerman * as published by the Free Software Foundation; either version 2 9*f63e6d89SMichael Ellerman * of the License, or (at your option) any later version. 10*f63e6d89SMichael Ellerman * 11*f63e6d89SMichael Ellerman * This program is distributed in the hope that it will be useful, 12*f63e6d89SMichael Ellerman * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*f63e6d89SMichael Ellerman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*f63e6d89SMichael Ellerman * GNU General Public License for more details. 15*f63e6d89SMichael Ellerman * 16*f63e6d89SMichael Ellerman * You should have received a copy of the GNU General Public License 17*f63e6d89SMichael Ellerman * along with this program; if not, see <http://www.gnu.org/licenses/>. 18*f63e6d89SMichael Ellerman */ 19*f63e6d89SMichael Ellerman #ifndef _ASM_POWERPC_LIVEPATCH_H 20*f63e6d89SMichael Ellerman #define _ASM_POWERPC_LIVEPATCH_H 21*f63e6d89SMichael Ellerman 22*f63e6d89SMichael Ellerman #include <linux/module.h> 23*f63e6d89SMichael Ellerman #include <linux/ftrace.h> 24*f63e6d89SMichael Ellerman 25*f63e6d89SMichael Ellerman #ifdef CONFIG_LIVEPATCH 26*f63e6d89SMichael Ellerman static inline int klp_check_compiler_support(void) 27*f63e6d89SMichael Ellerman { 28*f63e6d89SMichael Ellerman return 0; 29*f63e6d89SMichael Ellerman } 30*f63e6d89SMichael Ellerman 31*f63e6d89SMichael Ellerman static inline int klp_write_module_reloc(struct module *mod, unsigned long 32*f63e6d89SMichael Ellerman type, unsigned long loc, unsigned long value) 33*f63e6d89SMichael Ellerman { 34*f63e6d89SMichael Ellerman /* This requires infrastructure changes; we need the loadinfos. */ 35*f63e6d89SMichael Ellerman return -ENOSYS; 36*f63e6d89SMichael Ellerman } 37*f63e6d89SMichael Ellerman 38*f63e6d89SMichael Ellerman static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip) 39*f63e6d89SMichael Ellerman { 40*f63e6d89SMichael Ellerman regs->nip = ip; 41*f63e6d89SMichael Ellerman } 42*f63e6d89SMichael Ellerman 43*f63e6d89SMichael Ellerman #define klp_get_ftrace_location klp_get_ftrace_location 44*f63e6d89SMichael Ellerman static inline unsigned long klp_get_ftrace_location(unsigned long faddr) 45*f63e6d89SMichael Ellerman { 46*f63e6d89SMichael Ellerman /* 47*f63e6d89SMichael Ellerman * Live patch works only with -mprofile-kernel on PPC. In this case, 48*f63e6d89SMichael Ellerman * the ftrace location is always within the first 16 bytes. 49*f63e6d89SMichael Ellerman */ 50*f63e6d89SMichael Ellerman return ftrace_location_range(faddr, faddr + 16); 51*f63e6d89SMichael Ellerman } 52*f63e6d89SMichael Ellerman #endif /* CONFIG_LIVEPATCH */ 53*f63e6d89SMichael Ellerman 54*f63e6d89SMichael Ellerman #endif /* _ASM_POWERPC_LIVEPATCH_H */ 55