arch/powerpc/kernel/ptrace/ptrace-tm.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/ptrace/ptrace-tm.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/ptrace/ptrace-tm.c- Extension
.c- Size
- 20624 bytes
- Lines
- 789
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- 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/regset.hasm/switch_to.hasm/tm.hasm/asm-prototypes.hptrace-decl.h
Detected Declarations
function flush_tmregs_to_threadfunction get_user_ckpt_msrfunction set_user_ckpt_msrfunction set_user_ckpt_trapfunction tm_cgpr_activefunction tm_cgpr_getfunction tm_cgpr_setfunction tm_cfpr_activefunction tm_cfpr_getfunction tm_cfpr_setfunction tm_cvmx_activefunction tm_cvmx_getfunction tm_cvmx_setfunction tm_cvsx_activefunction tm_cvsx_getfunction tm_cvsx_setfunction tm_spr_activefunction tm_spr_getfunction tm_spr_setfunction tm_tar_activefunction tm_tar_getfunction tm_tar_setfunction tm_ppr_activefunction tm_ppr_getfunction tm_ppr_setfunction tm_dscr_activefunction tm_dscr_getfunction tm_dscr_setfunction tm_cgpr32_getfunction tm_cgpr32_set
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/regset.h>
#include <asm/switch_to.h>
#include <asm/tm.h>
#include <asm/asm-prototypes.h>
#include "ptrace-decl.h"
void flush_tmregs_to_thread(struct task_struct *tsk)
{
/*
* If task is not current, it will have been flushed already to
* its thread_struct during __switch_to().
*
* A reclaim flushes ALL the state or if not in TM save TM SPRs
* in the appropriate thread structures from live.
*/
if (!cpu_has_feature(CPU_FTR_TM) || tsk != current)
return;
if (MSR_TM_SUSPENDED(mfmsr())) {
tm_reclaim_current(TM_CAUSE_SIGNAL);
} else {
tm_enable();
tm_save_sprs(&tsk->thread);
}
}
static unsigned long get_user_ckpt_msr(struct task_struct *task)
{
return task->thread.ckpt_regs.msr | task->thread.fpexc_mode;
}
static int set_user_ckpt_msr(struct task_struct *task, unsigned long msr)
{
task->thread.ckpt_regs.msr &= ~MSR_DEBUGCHANGE;
task->thread.ckpt_regs.msr |= msr & MSR_DEBUGCHANGE;
return 0;
}
static int set_user_ckpt_trap(struct task_struct *task, unsigned long trap)
{
set_trap(&task->thread.ckpt_regs, trap);
return 0;
}
/**
* tm_cgpr_active - get active number of registers in CGPR
* @target: The target task.
* @regset: The user regset structure.
*
* This function checks for the active number of available
* regisers in transaction checkpointed GPR category.
*/
int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset)
{
if (!cpu_has_feature(CPU_FTR_TM))
return -ENODEV;
if (!MSR_TM_ACTIVE(target->thread.regs->msr))
return 0;
return regset->n;
}
/**
* tm_cgpr_get - get CGPR registers
* @target: The target task.
* @regset: The user regset structure.
* @to: Destination of copy.
*
* This function gets transaction checkpointed GPR registers.
*
* When the transaction is active, 'ckpt_regs' holds all the checkpointed
* GPR register values for the current transaction to fall back on if it
* aborts in between. This function gets those checkpointed GPR registers.
* The userspace interface buffer layout is as follows.
*
* struct data {
* struct pt_regs ckpt_regs;
* };
*/
int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
struct membuf to)
{
struct membuf to_msr = membuf_at(&to, offsetof(struct pt_regs, msr));
#ifdef CONFIG_PPC64
Annotation
- Immediate include surface: `linux/regset.h`, `asm/switch_to.h`, `asm/tm.h`, `asm/asm-prototypes.h`, `ptrace-decl.h`.
- Detected declarations: `function flush_tmregs_to_thread`, `function get_user_ckpt_msr`, `function set_user_ckpt_msr`, `function set_user_ckpt_trap`, `function tm_cgpr_active`, `function tm_cgpr_get`, `function tm_cgpr_set`, `function tm_cfpr_active`, `function tm_cfpr_get`, `function tm_cfpr_set`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source 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.