arch/powerpc/lib/test_emulate_step_exec_instr.S
Source file repositories/reference/linux-study-clean/arch/powerpc/lib/test_emulate_step_exec_instr.S
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/lib/test_emulate_step_exec_instr.S- Extension
.S- Size
- 3507 bytes
- Lines
- 151
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: arch/powerpc
- Status
- atlas-only
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
asm/asm-offsets.hasm/ppc_asm.hasm/code-patching-asm.hlinux/errno.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#include <asm/asm-offsets.h>
#include <asm/ppc_asm.h>
#include <asm/code-patching-asm.h>
#include <linux/errno.h>
/* int exec_instr(struct pt_regs *regs) */
_GLOBAL(exec_instr)
/*
* Stack frame layout (INT_FRAME_SIZE bytes)
* In-memory pt_regs (SP + STACK_INT_FRAME_REGS)
* Scratch space (SP + 8)
* Back chain (SP + 0)
*/
/*
* Allocate a new stack frame with enough space to hold the register
* states in an in-memory pt_regs and also create the back chain to
* the caller's stack frame.
*/
stdu r1, -INT_FRAME_SIZE(r1)
/*
* Save non-volatile GPRs on stack. This includes TOC pointer (GPR2)
* and local variables (GPR14 to GPR31). The register for the pt_regs
* parameter (GPR3) is saved additionally to ensure that the resulting
* register state can still be saved even if GPR3 gets overwritten
* when loading the initial register state for the test instruction.
* The stack pointer (GPR1) and the thread pointer (GPR13) are not
* saved as these should not be modified anyway.
*/
SAVE_GPRS(2, 3, r1)
SAVE_NVGPRS(r1)
/*
* Save LR on stack to ensure that the return address is available
* even if it gets overwritten by the test instruction.
*/
mflr r0
std r0, _LINK(r1)
/*
* Save CR on stack. For simplicity, the entire register is saved
* even though only fields 2 to 4 are non-volatile.
*/
mfcr r0
std r0, _CCR(r1)
/*
* Load register state for the test instruction without touching the
* critical non-volatile registers. The register state is passed as a
* pointer to a pt_regs instance.
*/
subi r31, r3, GPR0
/* Load LR from pt_regs */
ld r0, _LINK(r31)
mtlr r0
/* Load CR from pt_regs */
ld r0, _CCR(r31)
mtcr r0
/* Load XER from pt_regs */
ld r0, _XER(r31)
mtxer r0
/* Load GPRs from pt_regs */
REST_GPR(0, r31)
REST_GPRS(2, 12, r31)
Annotation
- Immediate include surface: `asm/asm-offsets.h`, `asm/ppc_asm.h`, `asm/code-patching-asm.h`, `linux/errno.h`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: atlas-only.
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.