arch/s390/mm/mmap.c
Source file repositories/reference/linux-study-clean/arch/s390/mm/mmap.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/mm/mmap.c- Extension
.c- Size
- 5708 bytes
- Lines
- 216
- Domain
- Architecture Layer
- Bucket
- arch/s390
- 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/elf-randomize.hlinux/personality.hlinux/mm.hlinux/mman.hlinux/sched/signal.hlinux/sched/mm.hlinux/random.hlinux/security.hlinux/hugetlb.hasm/elf.h
Detected Declarations
function stack_maxrandom_sizefunction mmap_is_legacyfunction arch_mmap_rndfunction mmap_base_legacyfunction mmap_basefunction get_align_maskfunction arch_get_unmapped_areafunction arch_get_unmapped_area_topdownfunction mmapfunction arch_pick_mmap_layoutfunction setup_protection_map
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* flexible mmap layout support
*
* Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* Started by Ingo Molnar <mingo@elte.hu>
*/
#include <linux/elf-randomize.h>
#include <linux/personality.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/sched/signal.h>
#include <linux/sched/mm.h>
#include <linux/random.h>
#include <linux/security.h>
#include <linux/hugetlb.h>
#include <asm/elf.h>
static unsigned long stack_maxrandom_size(void)
{
if (!(current->flags & PF_RANDOMIZE))
return 0;
return STACK_RND_MASK << PAGE_SHIFT;
}
static inline int mmap_is_legacy(const struct rlimit *rlim_stack)
{
if (current->personality & ADDR_COMPAT_LAYOUT)
return 1;
if (rlim_stack->rlim_cur == RLIM_INFINITY)
return 1;
return sysctl_legacy_va_layout;
}
unsigned long arch_mmap_rnd(void)
{
return (get_random_u32() & MMAP_RND_MASK) << PAGE_SHIFT;
}
static unsigned long mmap_base_legacy(unsigned long rnd)
{
return TASK_UNMAPPED_BASE + rnd;
}
static inline unsigned long mmap_base(unsigned long rnd,
const struct rlimit *rlim_stack)
{
unsigned long gap = rlim_stack->rlim_cur;
unsigned long pad = stack_maxrandom_size() + stack_guard_gap;
/* Values close to RLIM_INFINITY can overflow. */
if (gap + pad > gap)
gap += pad;
/*
* Top of mmap area (just below the process stack).
* Leave at least a ~128 MB hole.
*/
gap = clamp(gap, SZ_128M, (STACK_TOP / 6) * 5);
return PAGE_ALIGN(STACK_TOP - gap - rnd);
}
static int get_align_mask(struct file *filp, unsigned long flags)
{
if (filp && is_file_hugepages(filp))
return huge_page_mask_align(filp);
if (!(current->flags & PF_RANDOMIZE))
return 0;
if (filp || (flags & MAP_SHARED))
return MMAP_ALIGN_MASK << PAGE_SHIFT;
return 0;
}
unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff,
unsigned long flags, vm_flags_t vm_flags)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
struct vm_unmapped_area_info info = {};
if (len > TASK_SIZE - mmap_min_addr)
return -ENOMEM;
if (flags & MAP_FIXED)
goto check_asce_limit;
Annotation
- Immediate include surface: `linux/elf-randomize.h`, `linux/personality.h`, `linux/mm.h`, `linux/mman.h`, `linux/sched/signal.h`, `linux/sched/mm.h`, `linux/random.h`, `linux/security.h`.
- Detected declarations: `function stack_maxrandom_size`, `function mmap_is_legacy`, `function arch_mmap_rnd`, `function mmap_base_legacy`, `function mmap_base`, `function get_align_mask`, `function arch_get_unmapped_area`, `function arch_get_unmapped_area_topdown`, `function mmap`, `function arch_pick_mmap_layout`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.