arch/powerpc/lib/sstep.c
Source file repositories/reference/linux-study-clean/arch/powerpc/lib/sstep.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/lib/sstep.c- Extension
.c- Size
- 83817 bytes
- Lines
- 3661
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/kprobes.hlinux/ptrace.hlinux/prefetch.hasm/sstep.hasm/processor.hlinux/uaccess.hasm/cpu_has_feature.hasm/cputable.hasm/disassemble.h
Detected Declarations
function truncate_if_32bitfunction branch_takenfunction address_okfunction dform_eafunction dsform_eafunction dqform_eafunction xform_eafunction mlsd_8lsd_eafunction max_alignfunction byterev_2function byterev_4function byterev_8function do_byte_reversefunction __read_mem_alignedfunction read_mem_alignedfunction __copy_mem_infunction copy_mem_infunction read_mem_unalignedfunction read_memfunction __write_mem_alignedfunction write_mem_alignedfunction __copy_mem_outfunction copy_mem_outfunction write_mem_unalignedfunction write_memfunction do_fp_loadfunction do_fp_storefunction do_vec_loadfunction do_vec_storefunction emulate_lqfunction emulate_stqfunction emulate_vsx_loadfunction emulate_vsx_storefunction do_vsx_loadfunction do_vsx_storefunction __emulate_dcbzfunction emulate_dcbzfunction __volatile__function set_ca32function add_with_carryfunction do_cmp_signedfunction do_cmp_unsignedfunction do_cmpbfunction do_popcntfunction do_bpermdfunction do_prtyfunction trap_comparefunction analyse_instr
Annotated Snippet
switch (c) {
case 1:
unsafe_get_user(*dest, (u8 __user *)ea, Efault);
break;
case 2:
unsafe_get_user(*(u16 *)dest, (u16 __user *)ea, Efault);
break;
case 4:
unsafe_get_user(*(u32 *)dest, (u32 __user *)ea, Efault);
break;
#ifdef __powerpc64__
case 8:
unsafe_get_user(*(u64 *)dest, (u64 __user *)ea, Efault);
break;
#endif
}
dest += c;
ea += c;
}
return 0;
Efault:
regs->dar = ea;
return -EFAULT;
}
static nokprobe_inline int copy_mem_in(u8 *dest, unsigned long ea, int nb, struct pt_regs *regs)
{
void __user *uea = (void __user *)ea;
if (is_kernel_addr(ea))
return __copy_mem_in(dest, ea, nb, regs);
scoped_user_read_access_size(uea, nb, efault)
return __copy_mem_in(dest, (unsigned long)uea, nb, regs);
efault:
regs->dar = ea;
return -EFAULT;
}
static nokprobe_inline int read_mem_unaligned(unsigned long *dest,
unsigned long ea, int nb,
struct pt_regs *regs)
{
union {
unsigned long ul;
u8 b[sizeof(unsigned long)];
} u;
int i;
int err;
u.ul = 0;
i = IS_BE ? sizeof(unsigned long) - nb : 0;
err = copy_mem_in(&u.b[i], ea, nb, regs);
if (!err)
*dest = u.ul;
return err;
}
/*
* Read memory at address ea for nb bytes, return 0 for success
* or -EFAULT if an error occurred. N.B. nb must be 1, 2, 4 or 8.
* If nb < sizeof(long), the result is right-justified on BE systems.
*/
static int read_mem(unsigned long *dest, unsigned long ea, int nb,
struct pt_regs *regs)
{
if (!address_ok(regs, ea, nb))
return -EFAULT;
if ((ea & (nb - 1)) == 0)
return read_mem_aligned(dest, ea, nb, regs);
return read_mem_unaligned(dest, ea, nb, regs);
}
NOKPROBE_SYMBOL(read_mem);
static __always_inline int
__write_mem_aligned(unsigned long val, unsigned long ea, int nb, struct pt_regs *regs)
{
switch (nb) {
case 1:
unsafe_put_user(val, (unsigned char __user *)ea, Efault);
break;
case 2:
unsafe_put_user(val, (unsigned short __user *)ea, Efault);
break;
case 4:
unsafe_put_user(val, (unsigned int __user *)ea, Efault);
break;
#ifdef __powerpc64__
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kprobes.h`, `linux/ptrace.h`, `linux/prefetch.h`, `asm/sstep.h`, `asm/processor.h`, `linux/uaccess.h`, `asm/cpu_has_feature.h`.
- Detected declarations: `function truncate_if_32bit`, `function branch_taken`, `function address_ok`, `function dform_ea`, `function dsform_ea`, `function dqform_ea`, `function xform_ea`, `function mlsd_8lsd_ea`, `function max_align`, `function byterev_2`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.