arch/um/kernel/tlb.c
Source file repositories/reference/linux-study-clean/arch/um/kernel/tlb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/kernel/tlb.c- Extension
.c- Size
- 5058 bytes
- Lines
- 226
- Domain
- Architecture Layer
- Bucket
- arch/um
- 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.
- 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/mm.hlinux/module.hlinux/sched/signal.hasm/tlbflush.hasm/mmu_context.has-layout.hmem_user.hos.hskas.hkern_util.h
Detected Declarations
struct vm_opsfunction kern_mapfunction kern_unmapfunction report_enomemfunction update_pte_rangefunction update_pmd_rangefunction update_pud_rangefunction update_p4d_rangefunction um_tlb_syncfunction flush_tlb_allfunction flush_tlb_mm
Annotated Snippet
struct vm_ops {
struct mm_id *mm_idp;
int (*mmap)(struct mm_id *mm_idp,
unsigned long virt, unsigned long len, int prot,
int phys_fd, unsigned long long offset);
int (*unmap)(struct mm_id *mm_idp,
unsigned long virt, unsigned long len);
};
static int kern_map(struct mm_id *mm_idp,
unsigned long virt, unsigned long len, int prot,
int phys_fd, unsigned long long offset)
{
return os_map_memory((void *)virt, phys_fd, offset, len,
prot & UM_PROT_READ, prot & UM_PROT_WRITE,
prot & UM_PROT_EXEC);
}
static int kern_unmap(struct mm_id *mm_idp,
unsigned long virt, unsigned long len)
{
return os_unmap_memory((void *)virt, len);
}
void report_enomem(void)
{
printk(KERN_ERR "UML ran out of memory on the host side! "
"This can happen due to a memory limitation or "
"vm.max_map_count has been reached.\n");
}
static inline int update_pte_range(pmd_t *pmd, unsigned long addr,
unsigned long end,
struct vm_ops *ops)
{
pte_t *pte;
int ret = 0;
pte = pte_offset_kernel(pmd, addr);
do {
if (!pte_needsync(*pte))
continue;
if (pte_present(*pte)) {
__u64 offset;
unsigned long phys = pte_val(*pte) & PAGE_MASK;
int fd = phys_mapping(phys, &offset);
int r, w, x, prot;
r = pte_read(*pte);
w = pte_write(*pte);
x = pte_exec(*pte);
if (!pte_young(*pte)) {
r = 0;
w = 0;
} else if (!pte_dirty(*pte))
w = 0;
prot = (r ? UM_PROT_READ : 0) |
(w ? UM_PROT_WRITE : 0) |
(x ? UM_PROT_EXEC : 0);
ret = ops->mmap(ops->mm_idp, addr, PAGE_SIZE,
prot, fd, offset);
} else
ret = ops->unmap(ops->mm_idp, addr, PAGE_SIZE);
*pte = pte_mkuptodate(*pte);
} while (pte++, addr += PAGE_SIZE, ((addr < end) && !ret));
return ret;
}
static inline int update_pmd_range(pud_t *pud, unsigned long addr,
unsigned long end,
struct vm_ops *ops)
{
pmd_t *pmd;
unsigned long next;
int ret = 0;
pmd = pmd_offset(pud, addr);
do {
next = pmd_addr_end(addr, end);
if (!pmd_present(*pmd)) {
if (pmd_needsync(*pmd)) {
ret = ops->unmap(ops->mm_idp, addr,
next - addr);
pmd_mkuptodate(*pmd);
}
Annotation
- Immediate include surface: `linux/mm.h`, `linux/module.h`, `linux/sched/signal.h`, `asm/tlbflush.h`, `asm/mmu_context.h`, `as-layout.h`, `mem_user.h`, `os.h`.
- Detected declarations: `struct vm_ops`, `function kern_map`, `function kern_unmap`, `function report_enomem`, `function update_pte_range`, `function update_pmd_range`, `function update_pud_range`, `function update_p4d_range`, `function um_tlb_sync`, `function flush_tlb_all`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
- 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.