Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\alternative.c Create Date:2022-07-28 07:45:01
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:recompute_jump

Proto:static void __init_or_module recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insn_buff)

Type:void

Parameter:

TypeParameterName
struct alt_instr *a
u8 *orig_insn
u8 *repl_insn
u8 *insn_buff
288  If length of new instruction != 5 Then Return
291  o_dspl = *(insn_buff + 1)
294  next_rip = repl_insn + length of new instruction
296  tgt_rip = next_rip + o_dspl
297  n_dspl = tgt_rip - orig_insn
299  DPRINTK("target RIP: %px, new_displ: 0x%x", tgt_rip, n_dspl)
301  If tgt_rip - orig_insn >= 0 Then
302  If n_dspl - 2 <= 127 Then Go to two_byte_jmp
304  Else Go to five_byte_jmp
307  Else
308  If ( n_dspl - 2 & 0xff) == n_dspl - 2 Then Go to two_byte_jmp
310  Else Go to five_byte_jmp
314  two_byte_jmp :
315  n_dspl -= 2
317  insn_buff[0] = 0xeb
318  insn_buff[1] = n_dspl
319  Use this to add nops to a buffer, then text_poke the whole buffer.
321  repl_len = 2
322  Go to done
324  five_byte_jmp :
325  n_dspl -= 5
327  insn_buff[0] = 0xe9
328  * (s32 * ) & insn_buff[1] = n_dspl
330  repl_len = 5
332  done :
334  DPRINTK("final displ: 0x%08x, JMP 0x%lx", n_dspl, (unsignedlong)orig_insn + n_dspl + repl_len)
Caller
NameDescribe
apply_alternativesReplace instructions with better alternatives for this CPU type. This runs* before SMP is initialized to avoid SMP problems with self modifying code.* This implies that asymmetric systems where APs have less capabilities than