arch/riscv/mm/pageattr.c
Source file repositories/reference/linux-study-clean/arch/riscv/mm/pageattr.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/mm/pageattr.c- Extension
.c- Size
- 10777 bytes
- Lines
- 471
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- 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.
- 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/pagewalk.hlinux/pgtable.hlinux/vmalloc.hasm/tlbflush.hasm/bitops.hasm/set_memory.h
Detected Declarations
struct pageattr_masksfunction set_pageattr_masksfunction pageattr_p4d_entryfunction pageattr_pud_entryfunction pageattr_pmd_entryfunction pageattr_pte_entryfunction pageattr_pte_holefunction __split_linear_mapping_pmdfunction __split_linear_mapping_pudfunction __split_linear_mapping_p4dfunction __split_linear_mapping_pgdfunction split_linear_mappingfunction __set_memoryfunction set_memory_rw_nxfunction set_memory_rofunction set_memory_rwfunction set_memory_xfunction set_memory_nxfunction set_direct_map_invalid_noflushfunction set_direct_map_default_noflushfunction set_direct_map_valid_noflushfunction debug_pagealloc_set_pagefunction __kernel_map_pagesfunction kernel_page_present
Annotated Snippet
struct pageattr_masks {
pgprot_t set_mask;
pgprot_t clear_mask;
};
static unsigned long set_pageattr_masks(unsigned long val, struct mm_walk *walk)
{
struct pageattr_masks *masks = walk->private;
unsigned long new_val = val;
new_val &= ~(pgprot_val(masks->clear_mask));
new_val |= (pgprot_val(masks->set_mask));
return new_val;
}
static int pageattr_p4d_entry(p4d_t *p4d, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
p4d_t val = p4dp_get(p4d);
if (p4d_leaf(val)) {
val = __p4d(set_pageattr_masks(p4d_val(val), walk));
set_p4d(p4d, val);
}
return 0;
}
static int pageattr_pud_entry(pud_t *pud, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pud_t val = pudp_get(pud);
if (pud_leaf(val)) {
val = __pud(set_pageattr_masks(pud_val(val), walk));
set_pud(pud, val);
}
return 0;
}
static int pageattr_pmd_entry(pmd_t *pmd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pmd_t val = pmdp_get(pmd);
if (pmd_leaf(val)) {
val = __pmd(set_pageattr_masks(pmd_val(val), walk));
set_pmd(pmd, val);
}
return 0;
}
static int pageattr_pte_entry(pte_t *pte, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pte_t val = ptep_get(pte);
val = __pte(set_pageattr_masks(pte_val(val), walk));
set_pte(pte, val);
return 0;
}
static int pageattr_pte_hole(unsigned long addr, unsigned long next,
int depth, struct mm_walk *walk)
{
/* Nothing to do here */
return 0;
}
static const struct mm_walk_ops pageattr_ops = {
.p4d_entry = pageattr_p4d_entry,
.pud_entry = pageattr_pud_entry,
.pmd_entry = pageattr_pmd_entry,
.pte_entry = pageattr_pte_entry,
.pte_hole = pageattr_pte_hole,
.walk_lock = PGWALK_RDLOCK,
};
#ifdef CONFIG_64BIT
static int __split_linear_mapping_pmd(pud_t *pudp,
unsigned long vaddr, unsigned long end)
{
pmd_t *pmdp;
unsigned long next;
pmdp = pmd_offset(pudp, vaddr);
Annotation
- Immediate include surface: `linux/pagewalk.h`, `linux/pgtable.h`, `linux/vmalloc.h`, `asm/tlbflush.h`, `asm/bitops.h`, `asm/set_memory.h`.
- Detected declarations: `struct pageattr_masks`, `function set_pageattr_masks`, `function pageattr_p4d_entry`, `function pageattr_pud_entry`, `function pageattr_pmd_entry`, `function pageattr_pte_entry`, `function pageattr_pte_hole`, `function __split_linear_mapping_pmd`, `function __split_linear_mapping_pud`, `function __split_linear_mapping_p4d`.
- Atlas domain: Architecture Layer / arch/riscv.
- 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.