include/linux/regset.h
Source file repositories/reference/linux-study-clean/include/linux/regset.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/regset.h- Extension
.h- Size
- 11975 bytes
- Lines
- 351
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/compiler.hlinux/types.hlinux/bug.hlinux/uaccess.h
Detected Declarations
struct task_structstruct user_regsetstruct membufstruct user_regsetstruct user_regset_viewfunction membuf_zerofunction membuf_writefunction membuf_atfunction user_regset_copyinfunction user_regset_copyin_ignorefunction copy_regset_from_user
Annotated Snippet
struct membuf {
void *p;
size_t left;
};
static inline int membuf_zero(struct membuf *s, size_t size)
{
if (s->left) {
if (size > s->left)
size = s->left;
memset(s->p, 0, size);
s->p += size;
s->left -= size;
}
return s->left;
}
static inline int membuf_write(struct membuf *s, const void *v, size_t size)
{
if (s->left) {
if (size > s->left)
size = s->left;
memcpy(s->p, v, size);
s->p += size;
s->left -= size;
}
return s->left;
}
static inline struct membuf membuf_at(const struct membuf *s, size_t offs)
{
struct membuf n = *s;
if (offs > n.left)
offs = n.left;
n.p += offs;
n.left -= offs;
return n;
}
/* current s->p must be aligned for v; v must be a scalar */
#define membuf_store(s, v) \
({ \
struct membuf *__s = (s); \
if (__s->left) { \
typeof(v) __v = (v); \
size_t __size = sizeof(__v); \
if (unlikely(__size > __s->left)) { \
__size = __s->left; \
memcpy(__s->p, &__v, __size); \
} else { \
*(typeof(__v + 0) *)__s->p = __v; \
} \
__s->p += __size; \
__s->left -= __size; \
} \
__s->left;})
/**
* user_regset_active_fn - type of @active function in &struct user_regset
* @target: thread being examined
* @regset: regset being examined
*
* Return -%ENODEV if not available on the hardware found.
* Return %0 if no interesting state in this thread.
* Return >%0 number of @size units of interesting state.
* Any get call fetching state beyond that number will
* see the default initialization state for this data,
* so a caller that knows what the default state is need
* not copy it all out.
* This call is optional; the pointer is %NULL if there
* is no inexpensive check to yield a value < @n.
*/
typedef int user_regset_active_fn(struct task_struct *target,
const struct user_regset *regset);
typedef int user_regset_get2_fn(struct task_struct *target,
const struct user_regset *regset,
struct membuf to);
/**
* user_regset_set_fn - type of @set function in &struct user_regset
* @target: thread being examined
* @regset: regset being examined
* @pos: offset into the regset data to access, in bytes
* @count: amount of data to copy, in bytes
* @kbuf: if not %NULL, a kernel-space pointer to copy from
* @ubuf: if @kbuf is %NULL, a user-space pointer to copy from
*
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/types.h`, `linux/bug.h`, `linux/uaccess.h`.
- Detected declarations: `struct task_struct`, `struct user_regset`, `struct membuf`, `struct user_regset`, `struct user_regset_view`, `function membuf_zero`, `function membuf_write`, `function membuf_at`, `function user_regset_copyin`, `function user_regset_copyin_ignore`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.