arch/nios2/mm/cacheflush.c
Source file repositories/reference/linux-study-clean/arch/nios2/mm/cacheflush.c
File Facts
- System
- Linux kernel
- Corpus path
arch/nios2/mm/cacheflush.c- Extension
.c- Size
- 7421 bytes
- Lines
- 282
- Domain
- Architecture Layer
- Bucket
- arch/nios2
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/sched.hlinux/mm.hlinux/fs.hlinux/pagemap.hasm/cacheflush.hasm/cpuinfo.h
Detected Declarations
function Copyrightfunction __invalidate_dcachefunction __flush_icachefunction flush_aliasesfunction flush_cache_allfunction flush_cache_mmfunction flush_cache_dup_mmfunction flush_icache_rangefunction flush_dcache_rangefunction invalidate_dcache_rangefunction flush_cache_rangefunction flush_icache_pagesfunction flush_cache_pagefunction __flush_dcache_foliofunction flush_dcache_foliofunction flush_dcache_pagefunction update_mmu_cache_rangefunction copy_user_pagefunction clear_user_pagefunction copy_from_user_pagefunction copy_to_user_pageexport flush_dcache_rangeexport invalidate_dcache_rangeexport flush_dcache_folioexport flush_dcache_page
Annotated Snippet
if (mapping) {
unsigned long start = (unsigned long)folio_address(folio);
flush_aliases(mapping, folio);
flush_icache_range(start, start + folio_size(folio));
}
set_bit(PG_dcache_clean, &folio->flags.f);
}
}
EXPORT_SYMBOL(flush_dcache_folio);
void flush_dcache_page(struct page *page)
{
flush_dcache_folio(page_folio(page));
}
EXPORT_SYMBOL(flush_dcache_page);
void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
unsigned long address, pte_t *ptep, unsigned int nr)
{
pte_t pte = *ptep;
unsigned long pfn = pte_pfn(pte);
struct folio *folio;
struct address_space *mapping;
reload_tlb_page(vma, address, pte);
if (!pfn_valid(pfn))
return;
/*
* The zero page is never written to, so never has any dirty
* cache lines, and therefore never needs to be flushed.
*/
if (is_zero_pfn(pfn))
return;
folio = page_folio(pfn_to_page(pfn));
if (!test_and_set_bit(PG_dcache_clean, &folio->flags.f))
__flush_dcache_folio(folio);
mapping = folio_flush_mapping(folio);
if (mapping) {
flush_aliases(mapping, folio);
if (vma->vm_flags & VM_EXEC)
flush_icache_pages(vma, &folio->page,
folio_nr_pages(folio));
}
}
void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
struct page *to)
{
__flush_dcache(vaddr, vaddr + PAGE_SIZE);
__flush_icache(vaddr, vaddr + PAGE_SIZE);
copy_page(vto, vfrom);
__flush_dcache((unsigned long)vto, (unsigned long)vto + PAGE_SIZE);
__flush_icache((unsigned long)vto, (unsigned long)vto + PAGE_SIZE);
}
void clear_user_page(void *addr, unsigned long vaddr, struct page *page)
{
__flush_dcache(vaddr, vaddr + PAGE_SIZE);
__flush_icache(vaddr, vaddr + PAGE_SIZE);
clear_page(addr);
__flush_dcache((unsigned long)addr, (unsigned long)addr + PAGE_SIZE);
__flush_icache((unsigned long)addr, (unsigned long)addr + PAGE_SIZE);
}
void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
unsigned long user_vaddr,
void *dst, void *src, int len)
{
flush_cache_page(vma, user_vaddr, page_to_pfn(page));
memcpy(dst, src, len);
__flush_dcache((unsigned long)src, (unsigned long)src + len);
if (vma->vm_flags & VM_EXEC)
__flush_icache((unsigned long)src, (unsigned long)src + len);
}
void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
unsigned long user_vaddr,
void *dst, void *src, int len)
{
flush_cache_page(vma, user_vaddr, page_to_pfn(page));
memcpy(dst, src, len);
__flush_dcache((unsigned long)dst, (unsigned long)dst + len);
if (vma->vm_flags & VM_EXEC)
__flush_icache((unsigned long)dst, (unsigned long)dst + len);
}
Annotation
- Immediate include surface: `linux/export.h`, `linux/sched.h`, `linux/mm.h`, `linux/fs.h`, `linux/pagemap.h`, `asm/cacheflush.h`, `asm/cpuinfo.h`.
- Detected declarations: `function Copyright`, `function __invalidate_dcache`, `function __flush_icache`, `function flush_aliases`, `function flush_cache_all`, `function flush_cache_mm`, `function flush_cache_dup_mm`, `function flush_icache_range`, `function flush_dcache_range`, `function invalidate_dcache_range`.
- Atlas domain: Architecture Layer / arch/nios2.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.