arch/csky/kernel/probes/simulate-insn.c
Source file repositories/reference/linux-study-clean/arch/csky/kernel/probes/simulate-insn.c
File Facts
- System
- Linux kernel
- Corpus path
arch/csky/kernel/probes/simulate-insn.c- Extension
.c- Size
- 8148 bytes
- Lines
- 391
- Domain
- Architecture Layer
- Bucket
- arch/csky
- 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.hdecode-insn.hsimulate-insn.h
Detected Declarations
function csky_insn_reg_get_valfunction csky_insn_reg_set_valfunction simulate_br16function simulate_br32function simulate_bt16function simulate_bt32function simulate_bf16function simulate_bf32function simulate_jmp16function simulate_jmp32function simulate_jsr16function simulate_jsr32function simulate_lrw16function simulate_lrw32function simulate_pop16function simulate_pop32function simulate_bez32function simulate_bnez32function simulate_bnezad32function simulate_bhsz32function simulate_bhz32function simulate_blsz32function simulate_blz32function simulate_bsr32function simulate_jmpi32function simulate_jsri32
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/kprobes.h>
#include "decode-insn.h"
#include "simulate-insn.h"
static inline bool csky_insn_reg_get_val(struct pt_regs *regs,
unsigned long index,
unsigned long *ptr)
{
if (index < 14)
*ptr = *(®s->a0 + index);
if (index > 15 && index < 31)
*ptr = *(®s->exregs[0] + index - 16);
switch (index) {
case 14:
*ptr = regs->usp;
break;
case 15:
*ptr = regs->lr;
break;
case 31:
*ptr = regs->tls;
break;
default:
goto fail;
}
return true;
fail:
return false;
}
static inline bool csky_insn_reg_set_val(struct pt_regs *regs,
unsigned long index,
unsigned long val)
{
if (index < 14)
*(®s->a0 + index) = val;
if (index > 15 && index < 31)
*(®s->exregs[0] + index - 16) = val;
switch (index) {
case 14:
regs->usp = val;
break;
case 15:
regs->lr = val;
break;
case 31:
regs->tls = val;
break;
default:
goto fail;
}
return true;
fail:
return false;
}
void __kprobes
simulate_br16(u32 opcode, long addr, struct pt_regs *regs)
{
instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0x3ff) << 1, 9));
}
void __kprobes
simulate_br32(u32 opcode, long addr, struct pt_regs *regs)
{
instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0xffff0000) >> 15, 15));
}
void __kprobes
simulate_bt16(u32 opcode, long addr, struct pt_regs *regs)
{
if (regs->sr & 1)
instruction_pointer_set(regs,
addr + sign_extend32((opcode & 0x3ff) << 1, 9));
else
instruction_pointer_set(regs, addr + 2);
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/kernel.h`, `linux/kprobes.h`, `decode-insn.h`, `simulate-insn.h`.
- Detected declarations: `function csky_insn_reg_get_val`, `function csky_insn_reg_set_val`, `function simulate_br16`, `function simulate_br32`, `function simulate_bt16`, `function simulate_bt32`, `function simulate_bf16`, `function simulate_bf32`, `function simulate_jmp16`, `function simulate_jmp32`.
- Atlas domain: Architecture Layer / arch/csky.
- 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.