arch/x86/include/asm/nospec-branch.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/nospec-branch.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/nospec-branch.h- Extension
.h- Size
- 17816 bytes
- Lines
- 627
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
Dependency Surface
linux/static_key.hlinux/objtool.hlinux/linkage.hasm/alternative.hasm/cpufeatures.hasm/msr-index.hasm/unwind_hints.hasm/percpu.hasm/asm-offsets.hasm/GEN-for-each-reg.hasm/segment.h
Detected Declarations
enum spectre_v2_mitigationenum spectre_v2_user_mitigationenum ssb_mitigationfunction __x86_return_thunkfunction retbleed_return_thunkfunction srso_return_thunkfunction its_return_thunkfunction call_depth_return_thunkfunction alternative_msr_writefunction indirect_branch_prediction_barrierfunction x86_clear_cpu_buffersfunction x86_idle_clear_cpu_buffers
Annotated Snippet
static inline void __x86_return_thunk(void) {}
#endif
#ifdef CONFIG_MITIGATION_UNRET_ENTRY
extern void retbleed_return_thunk(void);
#else
static inline void retbleed_return_thunk(void) {}
#endif
extern void srso_alias_untrain_ret(void);
#ifdef CONFIG_MITIGATION_SRSO
extern void srso_return_thunk(void);
extern void srso_alias_return_thunk(void);
#else
static inline void srso_return_thunk(void) {}
static inline void srso_alias_return_thunk(void) {}
#endif
#ifdef CONFIG_MITIGATION_ITS
extern void its_return_thunk(void);
#else
static inline void its_return_thunk(void) {}
#endif
extern void retbleed_return_thunk(void);
extern void srso_return_thunk(void);
extern void srso_alias_return_thunk(void);
extern void entry_untrain_ret(void);
extern void write_ibpb(void);
#ifdef CONFIG_X86_64
extern void clear_bhb_loop(void);
#endif
extern void (*x86_return_thunk)(void);
extern void __warn_thunk(void);
#ifdef CONFIG_MITIGATION_CALL_DEPTH_TRACKING
extern void call_depth_return_thunk(void);
#define CALL_DEPTH_ACCOUNT \
ALTERNATIVE("", \
__stringify(INCREMENT_CALL_DEPTH), \
X86_FEATURE_CALL_DEPTH)
DECLARE_PER_CPU_CACHE_HOT(u64, __x86_call_depth);
#ifdef CONFIG_CALL_THUNKS_DEBUG
DECLARE_PER_CPU(u64, __x86_call_count);
DECLARE_PER_CPU(u64, __x86_ret_count);
DECLARE_PER_CPU(u64, __x86_stuffs_count);
DECLARE_PER_CPU(u64, __x86_ctxsw_count);
#endif
#else /* !CONFIG_MITIGATION_CALL_DEPTH_TRACKING */
static inline void call_depth_return_thunk(void) {}
#define CALL_DEPTH_ACCOUNT ""
#endif /* CONFIG_MITIGATION_CALL_DEPTH_TRACKING */
#ifdef CONFIG_MITIGATION_RETPOLINE
#define GEN(reg) \
extern retpoline_thunk_t __x86_indirect_thunk_ ## reg;
#include <asm/GEN-for-each-reg.h>
#undef GEN
#define GEN(reg) \
extern retpoline_thunk_t __x86_indirect_call_thunk_ ## reg;
#include <asm/GEN-for-each-reg.h>
#undef GEN
#define GEN(reg) \
extern retpoline_thunk_t __x86_indirect_jump_thunk_ ## reg;
#include <asm/GEN-for-each-reg.h>
#undef GEN
#ifdef CONFIG_X86_64
/*
* Emits a conditional CS prefix that is compatible with
* -mindirect-branch-cs-prefix.
*/
#define __CS_PREFIX(reg) \
".irp rs,r8,r9,r10,r11,r12,r13,r14,r15\n" \
".ifc \\rs," reg "\n" \
".byte 0x2e\n" \
Annotation
- Immediate include surface: `linux/static_key.h`, `linux/objtool.h`, `linux/linkage.h`, `asm/alternative.h`, `asm/cpufeatures.h`, `asm/msr-index.h`, `asm/unwind_hints.h`, `asm/percpu.h`.
- Detected declarations: `enum spectre_v2_mitigation`, `enum spectre_v2_user_mitigation`, `enum ssb_mitigation`, `function __x86_return_thunk`, `function retbleed_return_thunk`, `function srso_return_thunk`, `function its_return_thunk`, `function call_depth_return_thunk`, `function alternative_msr_write`, `function indirect_branch_prediction_barrier`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.