arch/x86/include/asm/tlbflush.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/tlbflush.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/tlbflush.h- Extension
.h- Size
- 14842 bytes
- Lines
- 517
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mm_types.hlinux/mmu_notifier.hlinux/sched.hasm/barrier.hasm/processor.hasm/cpufeature.hasm/special_insns.hasm/smp.hasm/invpcid.hasm/pti.hasm/processor-flags.hasm/pgtable.h
Detected Declarations
struct tlb_contextstruct tlb_statestruct tlb_state_sharedstruct flush_tlb_infofunction cr4_set_bits_irqsofffunction cr4_clear_bits_irqsofffunction cr4_set_bitsfunction cr4_clear_bitsfunction switch_to_kernel_threadfunction cr4_init_shadowfunction is_dyn_asidfunction is_global_asidfunction mm_global_asidfunction mm_init_global_asidfunction mm_assign_global_asidfunction mm_clear_asid_transitionfunction mm_in_asid_transitionfunction mm_global_asidfunction mm_init_global_asidfunction flush_tlb_pagefunction arch_tlbbatch_should_deferfunction inc_mm_tlb_genfunction arch_tlbbatch_add_pendingfunction pte_flags_need_flushfunction pte_needs_flushfunction huge_pmd_needs_flushfunction tlbstate_lam_cr3_maskfunction cpu_tlbstate_update_lamfunction tlbstate_lam_cr3_maskfunction cpu_tlbstate_update_lamfunction __native_tlb_flush_global
Annotated Snippet
struct tlb_context {
u64 ctx_id;
u64 tlb_gen;
};
struct tlb_state {
/*
* cpu_tlbstate.loaded_mm should match CR3 whenever interrupts
* are on. This means that it may not match current->active_mm,
* which will contain the previous user mm when we're in lazy TLB
* mode even if we've already switched back to swapper_pg_dir.
*
* During switch_mm_irqs_off(), loaded_mm will be set to
* LOADED_MM_SWITCHING during the brief interrupts-off window
* when CR3 and loaded_mm would otherwise be inconsistent. This
* is for nmi_uaccess_okay()'s benefit.
*/
struct mm_struct *loaded_mm;
#define LOADED_MM_SWITCHING ((struct mm_struct *)1UL)
/* Last user mm for optimizing IBPB */
union {
struct mm_struct *last_user_mm;
unsigned long last_user_mm_spec;
};
u16 loaded_mm_asid;
u16 next_asid;
/*
* If set we changed the page tables in such a way that we
* needed an invalidation of all contexts (aka. PCIDs / ASIDs).
* This tells us to go invalidate all the non-loaded ctxs[]
* on the next context switch.
*
* The current ctx was kept up-to-date as it ran and does not
* need to be invalidated.
*/
bool invalidate_other;
#ifdef CONFIG_ADDRESS_MASKING
/*
* Active LAM mode.
*
* X86_CR3_LAM_U57/U48 shifted right by X86_CR3_LAM_U57_BIT or 0 if LAM
* disabled.
*/
u8 lam;
#endif
/*
* Mask that contains TLB_NR_DYN_ASIDS+1 bits to indicate
* the corresponding user PCID needs a flush next time we
* switch to it; see SWITCH_TO_USER_CR3.
*/
unsigned short user_pcid_flush_mask;
/*
* Access to this CR4 shadow and to H/W CR4 is protected by
* disabling interrupts when modifying either one.
*/
unsigned long cr4;
/*
* This is a list of all contexts that might exist in the TLB.
* There is one per ASID that we use, and the ASID (what the
* CPU calls PCID) is the index into ctxts.
*
* For each context, ctx_id indicates which mm the TLB's user
* entries came from. As an invariant, the TLB will never
* contain entries that are out-of-date as when that mm reached
* the tlb_gen in the list.
*
* To be clear, this means that it's legal for the TLB code to
* flush the TLB without updating tlb_gen. This can happen
* (for now, at least) due to paravirt remote flushes.
*
* NB: context 0 is a bit special, since it's also used by
* various bits of init code. This is fine -- code that
* isn't aware of PCID will end up harmlessly flushing
* context 0.
*/
struct tlb_context ctxs[TLB_NR_DYN_ASIDS];
};
DECLARE_PER_CPU_ALIGNED(struct tlb_state, cpu_tlbstate);
struct tlb_state_shared {
/*
* We can be in one of several states:
Annotation
- Immediate include surface: `linux/mm_types.h`, `linux/mmu_notifier.h`, `linux/sched.h`, `asm/barrier.h`, `asm/processor.h`, `asm/cpufeature.h`, `asm/special_insns.h`, `asm/smp.h`.
- Detected declarations: `struct tlb_context`, `struct tlb_state`, `struct tlb_state_shared`, `struct flush_tlb_info`, `function cr4_set_bits_irqsoff`, `function cr4_clear_bits_irqsoff`, `function cr4_set_bits`, `function cr4_clear_bits`, `function switch_to_kernel_thread`, `function cr4_init_shadow`.
- 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.