staticbool __kprobes aarch64_insn_is_steppable(u32 insn)
{ /* * Branch instructions will write a new value into the PC which is * likely to be relative to the XOL address and therefore invalid. * Deliberate generation of an exception during stepping is also not * currently safe. Lastly, MSR instructions can do any number of nasty * things we can't handle during single-stepping.
*/ if (aarch64_insn_is_class_branch_sys(insn)) { if (aarch64_insn_is_branch(insn) ||
aarch64_insn_is_msr_imm(insn) ||
aarch64_insn_is_msr_reg(insn) ||
aarch64_insn_is_exception(insn) ||
aarch64_insn_is_eret(insn) ||
aarch64_insn_is_eret_auth(insn)) returnfalse;
/* * The MRS instruction may not return a correct value when * executing in the single-stepping environment. We do make one * exception, for reading the DAIF bits.
*/ if (aarch64_insn_is_mrs(insn)) return aarch64_insn_extract_system_reg(insn)
!= AARCH64_INSN_SPCLREG_DAIF;
/* * The HINT instruction is steppable only if it is in whitelist * and the rest of other such instructions are blocked for * single stepping as they may cause exception or other * unintended behaviour.
*/ if (aarch64_insn_is_hint(insn)) return aarch64_insn_is_steppable_hint(insn);
returntrue;
}
/* * Instructions which load PC relative literals are not going to work * when executed from an XOL slot. Instructions doing an exclusive * load/store are not going to complete successfully when single-step * exception handling happens in the middle of the sequence. Memory * copy/set instructions require that all three instructions be placed * consecutively in memory.
*/ if (aarch64_insn_uses_literal(insn) ||
aarch64_insn_is_exclusive(insn) ||
aarch64_insn_is_mops(insn)) returnfalse;
returntrue;
}
/* Return: * INSN_REJECTED If instruction is one not allowed to kprobe, * INSN_GOOD If instruction is supported and uses instruction slot, * INSN_GOOD_NO_SLOT If instruction is supported but doesn't use its slot.
*/ enum probe_insn __kprobes
arm_probe_decode_insn(u32 insn, struct arch_probe_insn *api)
{ /* * While 'nop' instruction can execute in the out-of-line slot, * simulating them in breakpoint handling offers better performance.
*/ if (aarch64_insn_is_nop(insn)) {
api->handler = simulate_nop; return INSN_GOOD_NO_SLOT;
}
/* * Instructions reading or modifying the PC won't work from the XOL * slot.
*/ if (aarch64_insn_is_steppable(insn)) return INSN_GOOD;
/* * If there's a symbol defined in front of and near enough to * the probe address assume it is the entry point to this * code and use it to further limit how far back we search * when determining if we're in an atomic sequence. If we could * not find any symbol skip the atomic test altogether as we * could otherwise end up searching irrelevant text/literals. * KPROBES depends on KALLSYMS so this last case should never * happen.
*/ if (kallsyms_lookup_size_offset((unsignedlong) addr, &size, &offset)) { if (offset < (MAX_ATOMIC_CONTEXT_SIZE*sizeof(kprobe_opcode_t)))
scan_end = addr - (offset / sizeof(kprobe_opcode_t)); else
scan_end = addr - MAX_ATOMIC_CONTEXT_SIZE;
}
if (decoded != INSN_REJECTED && scan_end) if (is_probed_address_atomic(addr - 1, scan_end)) return INSN_REJECTED;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.