arch/x86/mm/pat/set_memory.c
Source file repositories/reference/linux-study-clean/arch/x86/mm/pat/set_memory.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/mm/pat/set_memory.c- Extension
.c- Size
- 70243 bytes
- Lines
- 2784
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/highmem.hlinux/memblock.hlinux/sched.hlinux/mm.hlinux/interrupt.hlinux/seq_file.hlinux/proc_fs.hlinux/debugfs.hlinux/pfn.hlinux/percpu.hlinux/gfp.hlinux/pci.hlinux/vmalloc.hlinux/libnvdimm.hlinux/vmstat.hlinux/kernel.hlinux/cc_platform.hlinux/set_memory.hlinux/memregion.hasm/e820/api.hasm/processor.hasm/tlbflush.hasm/sections.hasm/setup.hlinux/uaccess.hasm/pgalloc.hasm/proto.hasm/memtype.h../mm_internal.hcpa-test.c
Detected Declarations
struct cpa_dataenum cpa_warnfunction cachemode2pgprotfunction update_page_countfunction split_page_countfunction collapse_page_countfunction arch_report_meminfofunction split_page_countfunction cpa_inc_1g_checkedfunction cpa_inc_2m_checkedfunction cpa_inc_4k_installfunction cpa_inc_lp_sameprotfunction cpa_inc_lp_preservedfunction cpastats_showfunction cpastats_openfunction cpa_stats_initfunction cpa_inc_1g_checkedfunction within_inclusivefunction limitedfunction highmap_end_pfnfunction __cpa_pfn_in_highmapfunction __cpa_pfn_in_highmapfunction set_mce_nospecfunction __cpa_addrfunction clflush_cache_range_optfunction clflush_cache_rangefunction arch_invalidate_pmemfunction cpu_cache_has_invalidate_memregionfunction cpu_cache_invalidate_memregionfunction __cpa_flush_allfunction cpa_flush_allfunction __cpa_flush_tlbfunction cpa_collapse_large_pagesfunction list_for_each_entry_safefunction cpa_flushfunction overlapsfunction accessfunction protect_pci_biosfunction protect_rodatafunction protect_kernel_textfunction ROfunction protect_kernel_text_rofunction conflictsfunction check_conflictfunction rightfunction text_pokefunction verify_rwxfunction entry
Annotated Snippet
static const struct file_operations cpastats_fops = {
.open = cpastats_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int __init cpa_stats_init(void)
{
debugfs_create_file("cpa_stats", S_IRUSR, arch_debugfs_dir, NULL,
&cpastats_fops);
return 0;
}
late_initcall(cpa_stats_init);
#else
static inline void cpa_inc_1g_checked(void) { }
static inline void cpa_inc_2m_checked(void) { }
static inline void cpa_inc_4k_install(void) { }
static inline void cpa_inc_lp_sameprot(int level) { }
static inline void cpa_inc_lp_preserved(int level) { }
#endif
static inline int
within(unsigned long addr, unsigned long start, unsigned long end)
{
return addr >= start && addr < end;
}
#ifdef CONFIG_X86_64
static inline int
within_inclusive(unsigned long addr, unsigned long start, unsigned long end)
{
return addr >= start && addr <= end;
}
/*
* The kernel image is mapped into two places in the virtual address space
* (addresses without KASLR, of course):
*
* 1. The kernel direct map (0xffff880000000000)
* 2. The "high kernel map" (0xffffffff81000000)
*
* We actually execute out of #2. If we get the address of a kernel symbol, it
* points to #2, but almost all physical-to-virtual translations point to #1.
*
* This is so that we can have both a directmap of all physical memory *and*
* take full advantage of the limited (s32) immediate addressing range (2G)
* of x86_64.
*
* See Documentation/arch/x86/x86_64/mm.rst for more detail.
*/
static inline unsigned long highmap_start_pfn(void)
{
return __pa_symbol(_text) >> PAGE_SHIFT;
}
static inline unsigned long highmap_end_pfn(void)
{
/* Do not reference physical address outside the kernel. */
return __pa_symbol(roundup(_brk_end, PMD_SIZE) - 1) >> PAGE_SHIFT;
}
static bool __cpa_pfn_in_highmap(unsigned long pfn)
{
/*
* Kernel text has an alias mapping at a high address, known
* here as "highmap".
*/
return within_inclusive(pfn, highmap_start_pfn(), highmap_end_pfn());
}
#else
static bool __cpa_pfn_in_highmap(unsigned long pfn)
{
/* There is no highmap on 32-bit */
return false;
}
#endif
/*
* See set_mce_nospec().
*
* Machine check recovery code needs to change cache mode of poisoned pages to
* UC to avoid speculative access logging another error. But passing the
* address of the 1:1 mapping to set_memory_uc() is a fine way to encourage a
Annotation
- Immediate include surface: `linux/highmem.h`, `linux/memblock.h`, `linux/sched.h`, `linux/mm.h`, `linux/interrupt.h`, `linux/seq_file.h`, `linux/proc_fs.h`, `linux/debugfs.h`.
- Detected declarations: `struct cpa_data`, `enum cpa_warn`, `function cachemode2pgprot`, `function update_page_count`, `function split_page_count`, `function collapse_page_count`, `function arch_report_meminfo`, `function split_page_count`, `function cpa_inc_1g_checked`, `function cpa_inc_2m_checked`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: pattern 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.