arch/arm64/kernel/probes/simulate-insn.c
Source file repositories/reference/linux-study-clean/arch/arm64/kernel/probes/simulate-insn.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kernel/probes/simulate-insn.c- Extension
.c- Size
- 5373 bytes
- Lines
- 239
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/kernel.hlinux/kprobes.hasm/ptrace.hasm/traps.hsimulate-insn.hasm/gcs.h
Detected Declarations
function Copyrightfunction set_w_regfunction get_x_regfunction get_w_regfunction update_lrfunction check_cbzfunction check_cbnzfunction check_tbzfunction check_tbnzfunction simulate_adr_adrpfunction simulate_b_blfunction simulate_b_condfunction simulate_br_blrfunction simulate_retfunction simulate_cbz_cbnzfunction simulate_tbz_tbnzfunction simulate_ldr_literalfunction simulate_ldrsw_literalfunction simulate_nop
Annotated Snippet
if (err) {
force_sig(SIGSEGV);
return err;
}
}
procedure_link_pointer_set(regs, addr);
return err;
}
static bool __kprobes check_cbz(u32 opcode, struct pt_regs *regs)
{
int xn = opcode & 0x1f;
return (opcode & (1 << 31)) ?
(get_x_reg(regs, xn) == 0) : (get_w_reg(regs, xn) == 0);
}
static bool __kprobes check_cbnz(u32 opcode, struct pt_regs *regs)
{
int xn = opcode & 0x1f;
return (opcode & (1 << 31)) ?
(get_x_reg(regs, xn) != 0) : (get_w_reg(regs, xn) != 0);
}
static bool __kprobes check_tbz(u32 opcode, struct pt_regs *regs)
{
int xn = opcode & 0x1f;
int bit_pos = ((opcode & (1 << 31)) >> 26) | ((opcode >> 19) & 0x1f);
return ((get_x_reg(regs, xn) >> bit_pos) & 0x1) == 0;
}
static bool __kprobes check_tbnz(u32 opcode, struct pt_regs *regs)
{
int xn = opcode & 0x1f;
int bit_pos = ((opcode & (1 << 31)) >> 26) | ((opcode >> 19) & 0x1f);
return ((get_x_reg(regs, xn) >> bit_pos) & 0x1) != 0;
}
/*
* instruction simulation functions
*/
void __kprobes
simulate_adr_adrp(u32 opcode, long addr, struct pt_regs *regs)
{
long imm, xn, val;
xn = opcode & 0x1f;
imm = ((opcode >> 3) & 0x1ffffc) | ((opcode >> 29) & 0x3);
imm = sign_extend64(imm, 20);
if (opcode & 0x80000000)
val = (imm<<12) + (addr & 0xfffffffffffff000);
else
val = imm + addr;
set_x_reg(regs, xn, val);
instruction_pointer_set(regs, instruction_pointer(regs) + 4);
}
void __kprobes
simulate_b_bl(u32 opcode, long addr, struct pt_regs *regs)
{
int disp = bbl_displacement(opcode);
if (opcode & (1 << 31))
if (update_lr(regs, addr + 4))
return;
instruction_pointer_set(regs, addr + disp);
}
void __kprobes
simulate_b_cond(u32 opcode, long addr, struct pt_regs *regs)
{
int disp = 4;
if (aarch32_opcode_cond_checks[opcode & 0xf](regs->pstate & 0xffffffff))
disp = bcond_displacement(opcode);
instruction_pointer_set(regs, addr + disp);
}
void __kprobes
simulate_br_blr(u32 opcode, long addr, struct pt_regs *regs)
{
int xn = (opcode >> 5) & 0x1f;
u64 b_target = get_x_reg(regs, xn);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/kernel.h`, `linux/kprobes.h`, `asm/ptrace.h`, `asm/traps.h`, `simulate-insn.h`, `asm/gcs.h`.
- Detected declarations: `function Copyright`, `function set_w_reg`, `function get_x_reg`, `function get_w_reg`, `function update_lr`, `function check_cbz`, `function check_cbnz`, `function check_tbz`, `function check_tbnz`, `function simulate_adr_adrp`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.