arch/riscv/include/asm/vector.h
Source file repositories/reference/linux-study-clean/arch/riscv/include/asm/vector.h
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/include/asm/vector.h- Extension
.h- Size
- 12314 bytes
- Lines
- 445
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- 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
linux/types.huapi/asm-generic/errno.hlinux/stringify.hlinux/sched.hlinux/sched/task_stack.hasm/ptrace.hasm/cpufeature.hasm/csr.hasm/asm.hasm/vendorid_list.hasm/vendor_extensions.hasm/vendor_extensions/thead.h
Detected Declarations
struct pt_regsfunction riscv_v_flagsfunction has_vectorfunction has_xtheadvector_no_alternativesfunction has_xtheadvectorfunction __riscv_v_vstate_cleanfunction __riscv_v_vstate_dirtyfunction riscv_v_vstate_offfunction riscv_v_vstate_onfunction riscv_v_vstate_queryfunction riscv_v_enablefunction riscv_v_disablefunction riscv_v_is_onfunction __vstate_csr_savefunction __vstate_csr_restorefunction __riscv_v_vstate_savefunction __riscv_v_vstate_restorefunction __riscv_v_vstate_discardfunction riscv_v_vstate_discardfunction riscv_v_vstate_savefunction riscv_v_vstate_restorefunction riscv_v_vstate_set_restorefunction riscv_preempt_v_dirtyfunction riscv_preempt_v_restorefunction riscv_preempt_v_clear_dirtyfunction riscv_preempt_v_set_restorefunction riscv_preempt_v_startedfunction riscv_preempt_v_dirtyfunction riscv_preempt_v_restorefunction riscv_preempt_v_startedfunction __switch_to_vectorfunction riscv_v_setup_vsizefunction has_vectorfunction insn_is_vectorfunction has_xtheadvector_no_alternativesfunction has_xtheadvectorfunction riscv_v_first_use_handlerfunction riscv_v_vstate_queryfunction riscv_v_vstate_ctrl_user_allowedfunction riscv_vector_vlen
Annotated Snippet
static inline bool riscv_preempt_v_dirty(struct task_struct *task) { return false; }
static inline bool riscv_preempt_v_restore(struct task_struct *task) { return false; }
static inline bool riscv_preempt_v_started(struct task_struct *task) { return false; }
#define riscv_preempt_v_clear_dirty(tsk) do {} while (0)
#define riscv_preempt_v_set_restore(tsk) do {} while (0)
#endif /* CONFIG_RISCV_ISA_V_PREEMPTIVE */
static inline void __switch_to_vector(struct task_struct *prev,
struct task_struct *next)
{
struct pt_regs *regs;
if (riscv_preempt_v_started(prev)) {
if (riscv_v_is_on()) {
WARN_ON(prev->thread.riscv_v_flags & RISCV_V_CTX_DEPTH_MASK);
riscv_v_disable();
prev->thread.riscv_v_flags |= RISCV_PREEMPT_V_IN_SCHEDULE;
}
if (riscv_preempt_v_dirty(prev)) {
__riscv_v_vstate_save(&prev->thread.kernel_vstate,
prev->thread.kernel_vstate.datap);
riscv_preempt_v_clear_dirty(prev);
}
} else {
regs = task_pt_regs(prev);
riscv_v_vstate_save(&prev->thread.vstate, regs);
}
if (riscv_preempt_v_started(next)) {
if (next->thread.riscv_v_flags & RISCV_PREEMPT_V_IN_SCHEDULE) {
next->thread.riscv_v_flags &= ~RISCV_PREEMPT_V_IN_SCHEDULE;
riscv_v_enable();
} else {
riscv_preempt_v_set_restore(next);
}
} else {
riscv_v_vstate_set_restore(next, task_pt_regs(next));
}
}
void riscv_v_vstate_ctrl_init(struct task_struct *tsk);
bool riscv_v_vstate_ctrl_user_allowed(void);
#else /* ! CONFIG_RISCV_ISA_V */
struct pt_regs;
static inline int riscv_v_setup_vsize(void) { return -EOPNOTSUPP; }
static __always_inline bool has_vector(void) { return false; }
static __always_inline bool insn_is_vector(u32 insn_buf) { return false; }
static __always_inline bool has_xtheadvector_no_alternatives(void) { return false; }
static __always_inline bool has_xtheadvector(void) { return false; }
static inline bool riscv_v_first_use_handler(struct pt_regs *regs) { return false; }
static inline bool riscv_v_vstate_query(struct pt_regs *regs) { return false; }
static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; }
#define riscv_v_vsize (0)
#define riscv_v_vstate_discard(regs) do {} while (0)
#define riscv_v_vstate_save(vstate, regs) do {} while (0)
#define riscv_v_vstate_restore(vstate, regs) do {} while (0)
#define __switch_to_vector(__prev, __next) do {} while (0)
#define riscv_v_vstate_off(regs) do {} while (0)
#define riscv_v_vstate_on(regs) do {} while (0)
#define riscv_v_thread_free(tsk) do {} while (0)
#define riscv_v_setup_ctx_cache() do {} while (0)
#define riscv_v_thread_alloc(tsk) do {} while (0)
#define get_cpu_vector_context() do {} while (0)
#define put_cpu_vector_context() do {} while (0)
#define riscv_v_vstate_set_restore(task, regs) do {} while (0)
#endif /* CONFIG_RISCV_ISA_V */
/*
* Return the implementation's vlen value.
*
* riscv_v_vsize contains the value of "32 vector registers with vlenb length"
* so rebuild the vlen value in bits from it.
*/
static inline int riscv_vector_vlen(void)
{
return riscv_v_vsize / 32 * 8;
}
#endif /* ! __ASM_RISCV_VECTOR_H */
Annotation
- Immediate include surface: `linux/types.h`, `uapi/asm-generic/errno.h`, `linux/stringify.h`, `linux/sched.h`, `linux/sched/task_stack.h`, `asm/ptrace.h`, `asm/cpufeature.h`, `asm/csr.h`.
- Detected declarations: `struct pt_regs`, `function riscv_v_flags`, `function has_vector`, `function has_xtheadvector_no_alternatives`, `function has_xtheadvector`, `function __riscv_v_vstate_clean`, `function __riscv_v_vstate_dirty`, `function riscv_v_vstate_off`, `function riscv_v_vstate_on`, `function riscv_v_vstate_query`.
- Atlas domain: Architecture Layer / arch/riscv.
- 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.