arch/powerpc/mm/book3s32/mmu.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/book3s32/mmu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/book3s32/mmu.c- Extension
.c- Size
- 12150 bytes
- Lines
- 445
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/mm.hlinux/init.hlinux/highmem.hlinux/memblock.hasm/mmu.hasm/machdep.hasm/text-patching.hasm/sections.hmm/mmu_decl.h
Detected Declarations
function v_block_mappedfunction p_block_mappedfunction find_free_batfunction addressfunction setibatfunction clearibatfunction __mmu_mapin_ramfunction mmu_mapin_ramfunction is_module_segmentfunction mmu_mark_initmem_nxfunction mmu_mark_rodata_rofunction setbatfunction hash_preloadfunction __update_mmu_cachefunction MMU_init_hwfunction MMU_init_hw_patchfunction setup_initial_memory_limitfunction print_system_hash_infofunction early_init_mmu
Annotated Snippet
if ((top - base) > size) {
size <<= 1;
if (strict_kernel_rwx_enabled() && base + size > border)
pr_warn("Some RW data is getting mapped X. "
"Adjust CONFIG_DATA_SHIFT to avoid that.\n");
}
setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_X);
base += size;
}
for (; i < nb; i++)
clearibat(i);
update_bats();
for (i = ALIGN(TASK_SIZE, SZ_256M) >> 28; i < 16; i++) {
/* Do not set NX on VM space for modules */
if (is_module_segment(i << 28))
continue;
mtsr(mfsr(i << 28) | 0x10000000, i << 28);
}
return 0;
}
int mmu_mark_rodata_ro(void)
{
int nb = mmu_has_feature(MMU_FTR_USE_HIGH_BATS) ? 8 : 4;
int i;
for (i = 0; i < nb; i++) {
struct ppc_bat *bat = BATS[i];
if (bat_addrs[i].start < (unsigned long)__end_rodata)
bat[1].batl = (bat[1].batl & ~BPP_RW) | BPP_RX;
}
update_bats();
return 0;
}
/*
* Set up one of the D BAT (block address translation) register pairs.
* The parameters are not checked; in particular size must be a power
* of 2 between 128k and 256M.
*/
void __init setbat(int index, unsigned long virt, phys_addr_t phys,
unsigned int size, pgprot_t prot)
{
unsigned int bl;
int wimgxpp;
struct ppc_bat *bat;
unsigned long flags = pgprot_val(prot);
if (index == -1)
index = find_free_bat();
if (index == -1) {
pr_err("%s: no BAT available for mapping 0x%llx\n", __func__,
(unsigned long long)phys);
return;
}
bat = BATS[index];
if ((flags & _PAGE_NO_CACHE) ||
(cpu_has_feature(CPU_FTR_NEED_COHERENT) == 0))
flags &= ~_PAGE_COHERENT;
bl = (size >> 17) - 1;
/* Do DBAT first */
wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
| _PAGE_COHERENT | _PAGE_GUARDED);
wimgxpp |= (flags & _PAGE_WRITE) ? BPP_RW : BPP_RX;
bat[1].batu = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
bat[1].batl = BAT_PHYS_ADDR(phys) | wimgxpp;
if (!is_kernel_addr(virt))
bat[1].batu |= 1; /* Vp = 1 */
if (flags & _PAGE_GUARDED) {
/* G bit must be zero in IBATs */
flags &= ~_PAGE_EXEC;
}
bat_addrs[index].start = virt;
bat_addrs[index].limit = virt + ((bl + 1) << 17) - 1;
bat_addrs[index].phys = phys;
}
/*
* Preload a translation in the hash table
*/
static void hash_preload(struct mm_struct *mm, unsigned long ea)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mm.h`, `linux/init.h`, `linux/highmem.h`, `linux/memblock.h`, `asm/mmu.h`, `asm/machdep.h`, `asm/text-patching.h`.
- Detected declarations: `function v_block_mapped`, `function p_block_mapped`, `function find_free_bat`, `function address`, `function setibat`, `function clearibat`, `function __mmu_mapin_ram`, `function mmu_mapin_ram`, `function is_module_segment`, `function mmu_mark_initmem_nx`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.