函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\alternative.c Create Date:2022-07-27 08:44:55
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Replace 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

函数原型:void __init_or_module noinline apply_alternatives(struct alt_instr *start, struct alt_instr *end)

返回类型:void

参数:

类型参数名称
struct alt_instr *start
struct alt_instr *end
377  DPRINTK("alt table %px, -> %px", start, end)
387 a小于end循环
388  insn_buff_sz等于0
390  instr = (u8 * ) & original instruction + original instruction
391  replacement = (u8 * ) & offset to replacement instruction + offset to replacement instruction
392  BUG_ON( length of original instruction > insn_buff的长度)
393  BUG_ON( cpuid bit set for replacement >= (N 32-bit words worth of info + N 32-bit bug flags ) * 32)
398  继续下一循环
401  DPRINTK("feat: %d*32+%d, old: (%pS (%px) len: %d), repl: (%px, len: %d), pad: %d", cpuid bit set for replacement >> 5, cpuid bit set for replacement & 0x1f, instr, instr, length of original instruction , replacement, length of new instruction , length of build-time padding )
407  DUMP_BYTES(instr, length of original instruction , "%px: old_insn: ", instr)
408  DUMP_BYTES(replacement, length of new instruction , "%px: rpl_insn: ", replacement)
410  memcpy(insn_buff, replacement, length of new instruction )
411  insn_buff_sz等于 length of new instruction
419  如果 length of new instruction 恒等于5且insn_buff恒等于0xe8则
420  *insn_buff加1的和加等于replacementinstr
421  DPRINTK("Fix CALL offset: 0x%x, CALL 0x%lx", * (s32 * )(insn_buff + 1), (unsignedlong)instr + * (s32 * )(insn_buff + 1) + 5)
426  如果 length of new instruction Are we looking at a near JMP with a 1 or 4-byte displacement.recompute_jump(a, instr, replacement, insn_buff)
434  DUMP_BYTES(insn_buff, insn_buff_sz, "%px: final_insn: ", instr)
436  xt_poke_early - Update instructions on a live kernel at boot time*@addr: address to modify*@opcode: source of the copy*@len: length to copy* When you use this code to patch more than one byte of an instruction
调用者
名称描述
alternative_instructions
arch_klp_init_object_loadedApply per-object alternatives. Based on x86 module_finalize()
module_finalize