Chapter 3. Machine State

Table of Contents

struct user_regset
System Call Information
System Call Tracing

The task_current_syscall function can be used on any valid struct task_struct at any time, and does not even require that utrace_attach_task was used at all.

The other ways to access the registers and other machine-dependent state of a task can only be used on a task that is at a known safe point. The safe points are all the places where utrace_set_events can request callbacks (except for the DEATH and REAP events). So at any event callback, it is safe to examine current.

One task can examine another only after a callback in the target task that returns UTRACE_STOP so that task will not return to user mode after the safe point. This guarantees that the task will not resume until the same engine uses utrace_control, unless the task dies suddenly. To examine safely, one must use a pair of calls to utrace_prepare_examine and utrace_finish_examine surrounding the calls to struct user_regset functions or direct examination of task data structures. utrace_prepare_examine returns an error if the task is not properly stopped, or is dead. After a successful examination, the paired utrace_finish_examine call returns an error if the task ever woke up during the examination. If so, any data gathered may be scrambled and should be discarded. This means there was a spurious wake-up (which should not happen), or a sudden death.

struct user_regset

user_regset_active_fn — type of active function in struct user_regset
user_regset_get_fn — type of get function in struct user_regset
user_regset_set_fn — type of set function in struct user_regset
user_regset_writeback_fn — type of writeback function in struct user_regset
struct user_regset — accessible thread CPU state
struct user_regset_view — available regsets
task_user_regset_view — Return the process's native regset view.
copy_regset_to_user — fetch a thread's user_regset data into user memory
copy_regset_from_user — store into thread's user_regset data from user memory

The struct user_regset API is declared in <linux/regset.h>.