arch/x86/mm/ioremap.c
Source file repositories/reference/linux-study-clean/arch/x86/mm/ioremap.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/mm/ioremap.c- Extension
.c- Size
- 24967 bytes
- Lines
- 908
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- 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/memblock.hlinux/init.hlinux/io.hlinux/ioport.hlinux/ioremap.hlinux/slab.hlinux/vmalloc.hlinux/mmiotrace.hlinux/cc_platform.hlinux/efi.hlinux/pgtable.hlinux/kmsan.hasm/set_memory.hasm/e820/api.hasm/efi.hasm/fixmap.hasm/tlbflush.hasm/pgalloc.hasm/memtype.hasm/setup.hphysaddr.h
Detected Declarations
struct ioremap_descfunction ioremap_change_attrfunction __ioremap_check_ramfunction __ioremap_check_encryptedfunction walk_mem_resfunction __ioremap_collect_map_flagsfunction IORES_DESC_NONEfunction sizefunction iounmapfunction iounmapfunction unxlate_dev_mem_ptrfunction memremap_should_map_decryptedfunction memremap_is_efi_datafunction __memremap_is_setup_datafunction memremap_is_setup_datafunction early_memremap_is_setup_datafunction arch_memremap_can_ram_remapfunction early_memremap_pgprot_adjustfunction phys_mem_access_encryptedfunction pat_initfunction pat_initfunction early_ioremap_pmdfunction early_ioremap_ptefunction is_early_ioremap_ptepfunction early_ioremap_initfunction __early_set_fixmapexport ioremapexport ioremap_ucexport ioremap_wcexport ioremap_wtexport ioremap_encryptedexport ioremap_cacheexport ioremap_protexport iounmap
Annotated Snippet
struct ioremap_desc {
unsigned int flags;
};
/*
* Fix up the linear direct mapping of the kernel to avoid cache attribute
* conflicts.
*/
int ioremap_change_attr(unsigned long vaddr, unsigned long size,
enum page_cache_mode pcm)
{
unsigned long nrpages = size >> PAGE_SHIFT;
int err;
switch (pcm) {
case _PAGE_CACHE_MODE_UC:
default:
err = _set_memory_uc(vaddr, nrpages);
break;
case _PAGE_CACHE_MODE_WC:
err = _set_memory_wc(vaddr, nrpages);
break;
case _PAGE_CACHE_MODE_WT:
err = _set_memory_wt(vaddr, nrpages);
break;
case _PAGE_CACHE_MODE_WB:
err = _set_memory_wb(vaddr, nrpages);
break;
}
return err;
}
/* Does the range (or a subset of) contain normal RAM? */
static unsigned int __ioremap_check_ram(struct resource *res)
{
unsigned long start_pfn, stop_pfn;
unsigned long pfn;
if ((res->flags & IORESOURCE_SYSTEM_RAM) != IORESOURCE_SYSTEM_RAM)
return 0;
start_pfn = (res->start + PAGE_SIZE - 1) >> PAGE_SHIFT;
stop_pfn = (res->end + 1) >> PAGE_SHIFT;
if (stop_pfn > start_pfn) {
for_each_valid_pfn(pfn, start_pfn, stop_pfn)
if (!PageReserved(pfn_to_page(pfn)))
return IORES_MAP_SYSTEM_RAM;
}
return 0;
}
/*
* In a SEV guest, NONE and RESERVED should not be mapped encrypted because
* there the whole memory is already encrypted.
*/
static unsigned int __ioremap_check_encrypted(struct resource *res)
{
if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
return 0;
switch (res->desc) {
case IORES_DESC_NONE:
case IORES_DESC_RESERVED:
break;
default:
return IORES_MAP_ENCRYPTED;
}
return 0;
}
/*
* The EFI runtime services data area is not covered by walk_mem_res(), but must
* be mapped encrypted when SEV is active.
*/
static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *desc)
{
if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
return;
if (x86_platform.hyper.is_private_mmio(addr)) {
desc->flags |= IORES_MAP_ENCRYPTED;
return;
}
if (!IS_ENABLED(CONFIG_EFI))
return;
Annotation
- Immediate include surface: `linux/memblock.h`, `linux/init.h`, `linux/io.h`, `linux/ioport.h`, `linux/ioremap.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/mmiotrace.h`.
- Detected declarations: `struct ioremap_desc`, `function ioremap_change_attr`, `function __ioremap_check_ram`, `function __ioremap_check_encrypted`, `function walk_mem_res`, `function __ioremap_collect_map_flags`, `function IORES_DESC_NONE`, `function size`, `function iounmap`, `function iounmap`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration 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.