1*b3a04ed5SBabu Moger/* 2*b3a04ed5SBabu Moger * M7patch.S: Patch generic routines with M7 variant. 3*b3a04ed5SBabu Moger * 4*b3a04ed5SBabu Moger * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 5*b3a04ed5SBabu Moger */ 6*b3a04ed5SBabu Moger 7*b3a04ed5SBabu Moger#include <linux/linkage.h> 8*b3a04ed5SBabu Moger 9*b3a04ed5SBabu Moger#define BRANCH_ALWAYS 0x10680000 10*b3a04ed5SBabu Moger#define NOP 0x01000000 11*b3a04ed5SBabu Moger#define NG_DO_PATCH(OLD, NEW) \ 12*b3a04ed5SBabu Moger sethi %hi(NEW), %g1; \ 13*b3a04ed5SBabu Moger or %g1, %lo(NEW), %g1; \ 14*b3a04ed5SBabu Moger sethi %hi(OLD), %g2; \ 15*b3a04ed5SBabu Moger or %g2, %lo(OLD), %g2; \ 16*b3a04ed5SBabu Moger sub %g1, %g2, %g1; \ 17*b3a04ed5SBabu Moger sethi %hi(BRANCH_ALWAYS), %g3; \ 18*b3a04ed5SBabu Moger sll %g1, 11, %g1; \ 19*b3a04ed5SBabu Moger srl %g1, 11 + 2, %g1; \ 20*b3a04ed5SBabu Moger or %g3, %lo(BRANCH_ALWAYS), %g3; \ 21*b3a04ed5SBabu Moger or %g3, %g1, %g3; \ 22*b3a04ed5SBabu Moger stw %g3, [%g2]; \ 23*b3a04ed5SBabu Moger sethi %hi(NOP), %g3; \ 24*b3a04ed5SBabu Moger or %g3, %lo(NOP), %g3; \ 25*b3a04ed5SBabu Moger stw %g3, [%g2 + 0x4]; \ 26*b3a04ed5SBabu Moger flush %g2; 27*b3a04ed5SBabu Moger 28*b3a04ed5SBabu MogerENTRY(m7_patch_copyops) 29*b3a04ed5SBabu Moger NG_DO_PATCH(memcpy, M7memcpy) 30*b3a04ed5SBabu Moger NG_DO_PATCH(raw_copy_from_user, M7copy_from_user) 31*b3a04ed5SBabu Moger NG_DO_PATCH(raw_copy_to_user, M7copy_to_user) 32*b3a04ed5SBabu Moger retl 33*b3a04ed5SBabu Moger nop 34*b3a04ed5SBabu MogerENDPROC(m7_patch_copyops) 35*b3a04ed5SBabu Moger 36*b3a04ed5SBabu MogerENTRY(m7_patch_bzero) 37*b3a04ed5SBabu Moger NG_DO_PATCH(memset, M7memset) 38*b3a04ed5SBabu Moger NG_DO_PATCH(__bzero, M7bzero) 39*b3a04ed5SBabu Moger NG_DO_PATCH(__clear_user, NGclear_user) 40*b3a04ed5SBabu Moger NG_DO_PATCH(tsb_init, NGtsb_init) 41*b3a04ed5SBabu Moger retl 42*b3a04ed5SBabu Moger nop 43*b3a04ed5SBabu MogerENDPROC(m7_patch_bzero) 44*b3a04ed5SBabu Moger 45*b3a04ed5SBabu MogerENTRY(m7_patch_pageops) 46*b3a04ed5SBabu Moger NG_DO_PATCH(copy_user_page, NG4copy_user_page) 47*b3a04ed5SBabu Moger NG_DO_PATCH(_clear_page, M7clear_page) 48*b3a04ed5SBabu Moger NG_DO_PATCH(clear_user_page, M7clear_user_page) 49*b3a04ed5SBabu Moger retl 50*b3a04ed5SBabu Moger nop 51*b3a04ed5SBabu MogerENDPROC(m7_patch_pageops) 52