arch/loongarch/include/asm/ptrace.h
Source file repositories/reference/linux-study-clean/arch/loongarch/include/asm/ptrace.h
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/include/asm/ptrace.h- Extension
.h- Size
- 5514 bytes
- Lines
- 197
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- 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
asm/page.hasm/irqflags.hasm/thread_info.huapi/asm/ptrace.h
Detected Declarations
struct pt_regsstruct task_structfunction regs_irqs_disabledfunction kernel_stack_pointerfunction instruction_pointer_setfunction regs_get_registerfunction regs_within_kernel_stackfunction regs_get_kernel_stack_nthfunction regs_get_kernel_argumentfunction regs_return_valuefunction regs_set_return_valuefunction die_if_kernelfunction user_stack_pointerfunction user_stack_pointer_set
Annotated Snippet
struct pt_regs {
/* Main processor registers. */
unsigned long regs[32];
/* Original syscall arg0. */
unsigned long orig_a0;
/* Special CSR registers. */
unsigned long csr_era;
unsigned long csr_badvaddr;
unsigned long csr_crmd;
unsigned long csr_prmd;
unsigned long csr_euen;
unsigned long csr_ecfg;
unsigned long csr_estat;
unsigned long __last[];
} __aligned(8);
static __always_inline bool regs_irqs_disabled(struct pt_regs *regs)
{
return !(regs->csr_prmd & CSR_PRMD_PIE);
}
static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
{
return regs->regs[3];
}
/*
* Don't use asm-generic/ptrace.h it defines FP accessors that don't make
* sense on LoongArch. We rather want an error if they get invoked.
*/
static inline void instruction_pointer_set(struct pt_regs *regs, unsigned long val)
{
regs->csr_era = val;
}
/* Query offset/name of register from its name/offset */
extern int regs_query_register_offset(const char *name);
#define MAX_REG_OFFSET (offsetof(struct pt_regs, __last) - sizeof(unsigned long))
/**
* regs_get_register() - get register value from its offset
* @regs: pt_regs from which register value is gotten.
* @offset: offset number of the register.
*
* regs_get_register returns the value of a register. The @offset is the
* offset of the register in struct pt_regs address which specified by @regs.
* If @offset is bigger than MAX_REG_OFFSET, this returns 0.
*/
static inline unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)
{
if (unlikely(offset > MAX_REG_OFFSET))
return 0;
return *(unsigned long *)((unsigned long)regs + offset);
}
/**
* regs_within_kernel_stack() - check the address in the stack
* @regs: pt_regs which contains kernel stack pointer.
* @addr: address which is checked.
*
* regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
* If @addr is within the kernel stack, it returns true. If not, returns false.
*/
static inline int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr)
{
return ((addr & ~(THREAD_SIZE - 1)) ==
(kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
}
/**
* regs_get_kernel_stack_nth() - get Nth entry of the stack
* @regs: pt_regs which contains kernel stack pointer.
* @n: stack entry number.
*
* regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
* is specified by @regs. If the @n th entry is NOT in the kernel stack,
* this returns 0.
*/
static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n)
{
unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
addr += n;
if (regs_within_kernel_stack(regs, (unsigned long)addr))
return *addr;
else
Annotation
- Immediate include surface: `asm/page.h`, `asm/irqflags.h`, `asm/thread_info.h`, `uapi/asm/ptrace.h`.
- Detected declarations: `struct pt_regs`, `struct task_struct`, `function regs_irqs_disabled`, `function kernel_stack_pointer`, `function instruction_pointer_set`, `function regs_get_register`, `function regs_within_kernel_stack`, `function regs_get_kernel_stack_nth`, `function regs_get_kernel_argument`, `function regs_return_value`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.