arch/powerpc/include/asm/mmu_context.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/mmu_context.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/mmu_context.h- Extension
.h- Size
- 8882 bytes
- Lines
- 293
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/mm.hlinux/sched.hlinux/spinlock.hasm/mmu.hasm/cputable.hasm/cputhreads.hasm-generic/mmu_context.h
Detected Declarations
struct mm_iommu_table_group_mem_tfunction mm_iommu_is_devmemfunction mm_iommu_initfunction switch_mmu_contextfunction mmu_context_initfunction need_extra_contextfunction alloc_extended_contextfunction need_extra_contextfunction inc_mm_active_cpusfunction dec_mm_active_cpusfunction mm_context_add_coprofunction mm_context_remove_coprofunction radix__flush_all_mmfunction mappingfunction mm_context_remove_vas_windowfunction inc_mm_active_cpusfunction do_h_rpt_invalidate_prtfunction switch_mmfunction activate_mmfunction enter_lazy_tlbfunction arch_vma_access_permittedfunction pte_to_hpte_pkey_bitsfunction arch_dup_mmap
Annotated Snippet
static inline void mm_iommu_init(struct mm_struct *mm) { }
#endif
extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
#ifdef CONFIG_PPC_BOOK3S_64
extern void radix__switch_mmu_context(struct mm_struct *prev,
struct mm_struct *next);
static inline void switch_mmu_context(struct mm_struct *prev,
struct mm_struct *next,
struct task_struct *tsk)
{
if (radix_enabled())
return radix__switch_mmu_context(prev, next);
return switch_slb(tsk, next);
}
extern int hash__alloc_context_id(void);
void __init hash__reserve_context_id(int id);
extern void __destroy_context(int context_id);
static inline void mmu_context_init(void) { }
#ifdef CONFIG_PPC_64S_HASH_MMU
static inline int alloc_extended_context(struct mm_struct *mm,
unsigned long ea)
{
int context_id;
int index = ea >> MAX_EA_BITS_PER_CONTEXT;
context_id = hash__alloc_context_id();
if (context_id < 0)
return context_id;
VM_WARN_ON(mm->context.extended_id[index]);
mm->context.extended_id[index] = context_id;
return context_id;
}
static inline bool need_extra_context(struct mm_struct *mm, unsigned long ea)
{
int context_id;
context_id = get_user_context(&mm->context, ea);
if (!context_id)
return true;
return false;
}
#endif
#else
extern void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next,
struct task_struct *tsk);
extern unsigned long __init_new_context(void);
extern void __destroy_context(unsigned long context_id);
extern void mmu_context_init(void);
static inline int alloc_extended_context(struct mm_struct *mm,
unsigned long ea)
{
/* non book3s_64 should never find this called */
WARN_ON(1);
return -ENOMEM;
}
static inline bool need_extra_context(struct mm_struct *mm, unsigned long ea)
{
return false;
}
#endif
#ifdef CONFIG_PPC_BOOK3S_64
static inline void inc_mm_active_cpus(struct mm_struct *mm)
{
atomic_inc(&mm->context.active_cpus);
}
static inline void dec_mm_active_cpus(struct mm_struct *mm)
{
VM_WARN_ON_ONCE(atomic_read(&mm->context.active_cpus) <= 0);
atomic_dec(&mm->context.active_cpus);
}
static inline void mm_context_add_copro(struct mm_struct *mm)
{
/*
* If any copro is in use, increment the active CPU count
* in order to force TLB invalidations to be global as to
* propagate to the Nest MMU.
*/
if (atomic_inc_return(&mm->context.copros) == 1)
inc_mm_active_cpus(mm);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mm.h`, `linux/sched.h`, `linux/spinlock.h`, `asm/mmu.h`, `asm/cputable.h`, `asm/cputhreads.h`, `asm-generic/mmu_context.h`.
- Detected declarations: `struct mm_iommu_table_group_mem_t`, `function mm_iommu_is_devmem`, `function mm_iommu_init`, `function switch_mmu_context`, `function mmu_context_init`, `function need_extra_context`, `function alloc_extended_context`, `function need_extra_context`, `function inc_mm_active_cpus`, `function dec_mm_active_cpus`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.