arch/arm64/include/asm/mmu_context.h
Source file repositories/reference/linux-study-clean/arch/arm64/include/asm/mmu_context.h
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/include/asm/mmu_context.h- Extension
.h- Size
- 8534 bytes
- Lines
- 329
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- 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/compiler.hlinux/sched.hlinux/sched/hotplug.hlinux/mm_types.hlinux/pgtable.hlinux/pkeys.hasm/cacheflush.hasm/cpufeature.hasm/daifflags.hasm/gcs.hasm/proc-fns.hasm/cputype.hasm/sysreg.hasm/tlbflush.hasm-generic/mmu_context.h
Detected Declarations
function contextidr_thread_switchfunction cpu_set_reserved_ttbr0_nosyncfunction cpu_set_reserved_ttbr0function cpu_switch_mmfunction __cpu_set_tcr_t0szfunction cpu_uninstall_idmapfunction cpu_install_idmapfunction tablesfunction cpu_enable_swapper_cnpfunction cpu_replace_ttbr1function init_new_contextfunction arch_dup_pkeysfunction arch_dup_mmapfunction arch_exit_mmapfunction update_saved_ttbr0function __switch_mmfunction switch_mmfunction __task_cpu_possible_maskfunction task_cpu_possible_maskfunction mm_untag_maskfunction arch_vma_access_permittedfunction deactivate_mm
Annotated Snippet
#ifndef __ASM_MMU_CONTEXT_H
#define __ASM_MMU_CONTEXT_H
#ifndef __ASSEMBLER__
#include <linux/compiler.h>
#include <linux/sched.h>
#include <linux/sched/hotplug.h>
#include <linux/mm_types.h>
#include <linux/pgtable.h>
#include <linux/pkeys.h>
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
#include <asm/daifflags.h>
#include <asm/gcs.h>
#include <asm/proc-fns.h>
#include <asm/cputype.h>
#include <asm/sysreg.h>
#include <asm/tlbflush.h>
extern bool rodata_full;
static inline void contextidr_thread_switch(struct task_struct *next)
{
if (!IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR))
return;
write_sysreg(task_pid_nr(next), contextidr_el1);
isb();
}
/*
* Set TTBR0 to reserved_pg_dir. No translations will be possible via TTBR0.
*/
static inline void cpu_set_reserved_ttbr0_nosync(void)
{
unsigned long ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
write_sysreg(ttbr, ttbr0_el1);
}
static inline void cpu_set_reserved_ttbr0(void)
{
cpu_set_reserved_ttbr0_nosync();
isb();
}
void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
static inline void cpu_switch_mm(pgd_t *pgd, struct mm_struct *mm)
{
BUG_ON(pgd == swapper_pg_dir);
cpu_do_switch_mm(virt_to_phys(pgd),mm);
}
/*
* Ensure TCR.T0SZ is set to the provided value.
*/
static inline void __cpu_set_tcr_t0sz(unsigned long t0sz)
{
unsigned long tcr = read_sysreg(tcr_el1);
if ((tcr & TCR_EL1_T0SZ_MASK) == t0sz)
return;
tcr &= ~TCR_EL1_T0SZ_MASK;
tcr |= t0sz;
write_sysreg(tcr, tcr_el1);
isb();
}
/*
* Remove the idmap from TTBR0_EL1 and install the pgd of the active mm.
*
* The idmap lives in the same VA range as userspace, but uses global entries
* and may use a different TCR_EL1.T0SZ. To avoid issues resulting from
* speculative TLB fetches, we must temporarily install the reserved page
* tables while we invalidate the TLBs and set up the correct TCR_EL1.T0SZ.
*
* If current is a not a user task, the mm covers the TTBR1_EL1 page tables,
* which should not be installed in TTBR0_EL1. In this case we can leave the
* reserved page tables in place.
*/
static inline void cpu_uninstall_idmap(void)
{
struct mm_struct *mm = current->active_mm;
cpu_set_reserved_ttbr0();
local_flush_tlb_all();
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/sched.h`, `linux/sched/hotplug.h`, `linux/mm_types.h`, `linux/pgtable.h`, `linux/pkeys.h`, `asm/cacheflush.h`, `asm/cpufeature.h`.
- Detected declarations: `function contextidr_thread_switch`, `function cpu_set_reserved_ttbr0_nosync`, `function cpu_set_reserved_ttbr0`, `function cpu_switch_mm`, `function __cpu_set_tcr_t0sz`, `function cpu_uninstall_idmap`, `function cpu_install_idmap`, `function tables`, `function cpu_enable_swapper_cnp`, `function cpu_replace_ttbr1`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.