arch/powerpc/mm/pgtable.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/pgtable.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/pgtable.c- Extension
.c- Size
- 14886 bytes
- Lines
- 568
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/gfp.hlinux/mm.hlinux/percpu.hlinux/hardirq.hlinux/page_table_check.hlinux/hugetlb.hasm/tlbflush.hasm/tlb.hasm/hugetlb.hasm/pte-walk.h
Detected Declarations
function is_exec_faultfunction pte_looks_normalfunction pagefunction cpu_has_featurefunction set_pte_filter_hashfunction set_pte_filterfunction set_access_flags_filterfunction set_ptesfunction set_pte_at_uncheckedfunction unmap_kernel_pagefunction ptep_set_access_flagsfunction huge_ptep_set_access_flagsfunction __set_huge_pte_atfunction set_huge_pte_atfunction set_huge_pte_atfunction assert_pte_lockedfunction vmalloc_to_physexport vmalloc_to_physexport __find_linux_pte
Annotated Snippet
cpu_has_feature(CPU_FTR_NOEXECUTE))) {
struct folio *folio = maybe_pte_to_folio(pte);
if (!folio)
return pte;
if (!test_bit(PG_dcache_clean, &folio->flags.f)) {
flush_dcache_icache_folio(folio);
set_bit(PG_dcache_clean, &folio->flags.f);
}
}
return pte;
}
#else /* CONFIG_PPC_BOOK3S */
static pte_t set_pte_filter_hash(pte_t pte, unsigned long addr) { return pte; }
#endif /* CONFIG_PPC_BOOK3S */
/* Embedded type MMU with HW exec support. This is a bit more complicated
* as we don't have two bits to spare for _PAGE_EXEC and _PAGE_HWEXEC so
* instead we "filter out" the exec permission for non clean pages.
*
* This is also called once for the folio. So only work with folio->flags here.
*/
static inline pte_t set_pte_filter(pte_t pte, unsigned long addr)
{
struct folio *folio;
if (radix_enabled())
return pte;
if (mmu_has_feature(MMU_FTR_HPTE_TABLE))
return set_pte_filter_hash(pte, addr);
/* No exec permission in the first place, move on */
if (!pte_exec(pte) || !pte_looks_normal(pte, addr))
return pte;
/* If you set _PAGE_EXEC on weird pages you're on your own */
folio = maybe_pte_to_folio(pte);
if (unlikely(!folio))
return pte;
/* If the page clean, we move on */
if (test_bit(PG_dcache_clean, &folio->flags.f))
return pte;
/* If it's an exec fault, we flush the cache and make it clean */
if (is_exec_fault()) {
flush_dcache_icache_folio(folio);
set_bit(PG_dcache_clean, &folio->flags.f);
return pte;
}
/* Else, we filter out _PAGE_EXEC */
return pte_exprotect(pte);
}
static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
int dirty)
{
struct folio *folio;
if (IS_ENABLED(CONFIG_PPC_BOOK3S_64))
return pte;
if (mmu_has_feature(MMU_FTR_HPTE_TABLE))
return pte;
/* So here, we only care about exec faults, as we use them
* to recover lost _PAGE_EXEC and perform I$/D$ coherency
* if necessary. Also if _PAGE_EXEC is already set, same deal,
* we just bail out
*/
if (dirty || pte_exec(pte) || !is_exec_fault())
return pte;
#ifdef CONFIG_DEBUG_VM
/* So this is an exec fault, _PAGE_EXEC is not set. If it was
* an error we would have bailed out earlier in do_page_fault()
* but let's make sure of it
*/
if (WARN_ON(!(vma->vm_flags & VM_EXEC)))
return pte;
#endif /* CONFIG_DEBUG_VM */
/* If you set _PAGE_EXEC on weird pages you're on your own */
folio = maybe_pte_to_folio(pte);
if (unlikely(!folio))
goto bail;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/gfp.h`, `linux/mm.h`, `linux/percpu.h`, `linux/hardirq.h`, `linux/page_table_check.h`, `linux/hugetlb.h`, `asm/tlbflush.h`.
- Detected declarations: `function is_exec_fault`, `function pte_looks_normal`, `function page`, `function cpu_has_feature`, `function set_pte_filter_hash`, `function set_pte_filter`, `function set_access_flags_filter`, `function set_ptes`, `function set_pte_at_unchecked`, `function unmap_kernel_page`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.